Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
526 changes: 194 additions & 332 deletions qag. Warpdrive.ipynb

Large diffs are not rendered by default.

211 changes: 92 additions & 119 deletions MeetingZoneCzZ.ipynb
Original file line number Diff line number Diff line change
@@ -1,123 +1,96 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyPpDe3n5GVDH3zdVhh04Oon",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyPpDe3n5GVDH3zdVhh04Oon",
"include_colab_link": true
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/Sir-Ripley/AIsync/blob/main/MeetingZoneCzZ.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/Sir-Ripley/AIsync/blob/main/MeetingZoneCzZ.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "fgVrN3Lp-xqT",
"outputId": "559d5a71-f7d4-45cc-d7bf-14c45bd885de"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Starting Frequency Sweep... Let's find the peak!\n",
"Freq: 0.50 | Stability Score: 1.8034 | Avg Force: 0.003875\n",
"Freq: 0.55 | Stability Score: 1.8746 | Avg Force: 0.002009\n",
"Freq: 0.60 | Stability Score: 2.1271 | Avg Force: 0.000980\n",
"Freq: 0.65 | Stability Score: 2.4253 | Avg Force: 0.000499\n",
"Freq: 0.70 | Stability Score: 2.5630 | Avg Force: 0.000306\n",
"Freq: 0.75 | Stability Score: 2.1601 | Avg Force: 0.000218\n",
"Freq: 0.80 | Stability Score: 1.9856 | Avg Force: 0.000174\n",
"Freq: 0.85 | Stability Score: 1.9058 | Avg Force: 0.000148\n",
"Freq: 0.90 | Stability Score: 1.8906 | Avg Force: 0.000129\n",
"Freq: 0.95 | Stability Score: 1.8796 | Avg Force: 0.000114\n",
"Freq: 1.00 | Stability Score: 1.8702 | Avg Force: 0.000100\n",
"Freq: 1.05 | Stability Score: 1.8613 | Avg Force: 0.000089\n",
"Freq: 1.10 | Stability Score: 1.8527 | Avg Force: 0.000079\n",
"Freq: 1.15 | Stability Score: 1.8442 | Avg Force: 0.000071\n",
"Freq: 1.20 | Stability Score: 1.8358 | Avg Force: 0.000063\n",
"\n",
"--- WINNER FOUND ---\n",
"Optimal Frequency: 0.70\n",
"This is the frequency for your Patent and GitHub!\n"
]
}
],
"source": [
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# The Hunt for the Golden Frequency\n",
"grid_size = 100\n",
"frequencies = np.linspace(0.5, 1.2, 15) # Testing a range of 15 frequencies\n",
"stability_results = []\n",
"\n",
"# Core Simulation Logic (Stripped for speed)\n",
"def run_test(omega_test):\n",
" u = np.zeros((grid_size, grid_size))\n",
" u_prev = np.zeros((grid_size, grid_size))\n",
" V_gain = 0.15\n",
" c_squared = 0.20 # Hydrogen medium acoustic velocity\n",
"\n",
" # Emitters\n",
" emitter_x = 20\n",
" x, y = np.arange(0, grid_size), np.arange(0, grid_size)\n",
" X, Y = np.meshgrid(x, y)\n",
" footprint = np.exp(-((X - emitter_x)**2) / (2 * 1.5**2)) * np.exp(-((Y - 50)**2) / (2 * 15.0**2))\n",
"\n",
" peak_force = 0\n",
" force_history = []\n",
"\n",
" for t in range(300):\n",
" laplacian = (np.roll(u,1,0)+np.roll(u,-1,0)+np.roll(u,1,1)+np.roll(u,-1,1)-4*u)\n",
" u_next = 2*u - u_prev + c_squared * laplacian\n",
" u_next += V_gain * np.sin(omega_test * t) * footprint\n",
" u_next *= 0.994\n",
"\n",
" impact = np.abs(u[:, 90:]).mean()\n",
" current_force = 0.5 * (impact**2)\n",
" force_history.append(current_force)\n",
"\n",
" u_prev, u = u.copy(), u_next.copy()\n",
"\n",
" # Stability Score: Peak Force / Variance (We want high force, low dipping)\n",
" stability_score = np.mean(force_history[-50:]) / (np.std(force_history[-50:]) + 1e-6)\n",
" return stability_score, np.mean(force_history[-50:])\n",
"\n",
"print(\"Starting Frequency Sweep... Let's find the peak!\")\n",
"for omega in frequencies:\n",
" score, avg_force = run_test(omega)\n",
" stability_results.append((omega, score, avg_force))\n",
" print(f\"Freq: {omega:.2f} | Stability Score: {score:.4f} | Avg Force: {avg_force:.6f}\")\n",
"\n",
"# Find the winner\n",
"best_run = max(stability_results, key=lambda x: x[1])\n",
"print(f\"\\n--- WINNER FOUND ---\")\n",
"print(f\"Optimal Frequency: {best_run[0]:.2f}\")\n",
"print(f\"This is the frequency for your Patent and GitHub!\")"
]
}
]
"id": "fgVrN3Lp-xqT",
"outputId": "559d5a71-f7d4-45cc-d7bf-14c45bd885de"
},
"outputs": [],
"source": [
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# The Hunt for the Golden Frequency\n",
"grid_size = 100\n",
"frequencies = np.linspace(0.5, 1.2, 15) # Testing a range of 15 frequencies\n",
"stability_results = []\n",
"\n",
"# Core Simulation Logic (Stripped for speed)\n",
"def run_test(omega_test):\n",
" u = np.zeros((grid_size, grid_size))\n",
" u_prev = np.zeros((grid_size, grid_size))\n",
" V_gain = 0.15\n",
" c_squared = 0.20 # Hydrogen medium acoustic velocity\n",
"\n",
" # Emitters\n",
" emitter_x = 20\n",
" x, y = np.arange(0, grid_size), np.arange(0, grid_size)\n",
" X, Y = np.meshgrid(x, y)\n",
" footprint = np.exp(-((X - emitter_x)**2) / (2 * 1.5**2)) * np.exp(-((Y - 50)**2) / (2 * 15.0**2))\n",
"\n",
" peak_force = 0\n",
" force_history = []\n",
"\n",
" for t in range(300):\n",
" laplacian = (np.roll(u,1,0)+np.roll(u,-1,0)+np.roll(u,1,1)+np.roll(u,-1,1)-4*u)\n",
" u_next = 2*u - u_prev + c_squared * laplacian\n",
" u_next += V_gain * np.sin(omega_test * t) * footprint\n",
" u_next *= 0.994\n",
"\n",
" impact = np.abs(u[:, 90:]).mean()\n",
" current_force = 0.5 * (impact**2)\n",
" force_history.append(current_force)\n",
"\n",
" u_prev, u = u, u_next\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change is a great step for optimization by removing .copy()! To take it a step further and eliminate array allocations inside this hot loop, you could consider a triple-buffering pattern. This involves pre-allocating u_next before the loop and then cycling the array references.

Here's an example of how run_test could be refactored:

def run_test(omega_test):
    # Pre-allocate all three buffers
    u = np.zeros((grid_size, grid_size))
    u_prev = np.zeros((grid_size, grid_size))
    u_next = np.zeros((grid_size, grid_size))
    # ... (rest of initialization)

    for t in range(300):
        laplacian = (np.roll(u,1,0)+np.roll(u,-1,0)+np.roll(u,1,1)+np.roll(u,-1,1)-4*u)
        
        # Calculate result into the pre-allocated u_next buffer.
        # This avoids allocating a new array for `u_next` in each iteration.
        # Note: the RHS still creates temporary arrays. For maximum performance,
        # this expression could be broken down into in-place operations.
        np.copyto(u_next, 2*u - u_prev + c_squared * laplacian)
        
        u_next += V_gain * np.sin(omega_test * t) * footprint
        u_next *= 0.994

        # ... (force calculation)

        # Cycle the buffers to reuse memory
        u_prev, u, u_next = u, u_next, u_prev
    
    # ... (rest of function)

This pattern avoids allocating a large array on every iteration, which should give another significant performance boost.

"\n",
" # Stability Score: Peak Force / Variance (We want high force, low dipping)\n",
" stability_score = np.mean(force_history[-50:]) / (np.std(force_history[-50:]) + 1e-6)\n",
" return stability_score, np.mean(force_history[-50:])\n",
"\n",
"print(\"Starting Frequency Sweep... Let's find the peak!\")\n",
"for omega in frequencies:\n",
" score, avg_force = run_test(omega)\n",
" stability_results.append((omega, score, avg_force))\n",
" print(f\"Freq: {omega:.2f} | Stability Score: {score:.4f} | Avg Force: {avg_force:.6f}\")\n",
"\n",
"# Find the winner\n",
"best_run = max(stability_results, key=lambda x: x[1])\n",
"print(f\"\\n--- WINNER FOUND ---\")\n",
"print(f\"Optimal Frequency: {best_run[0]:.2f}\")\n",
"print(f\"This is the frequency for your Patent and GitHub!\")"
]
}
]
}
1,186 changes: 525 additions & 661 deletions QAG-recordpropulsuon.pynb

Large diffs are not rendered by default.