|
29 | 29 | "!pip install --pre --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ \"nbody-sim-RO[vis]==1.0.4.dev0\"" |
30 | 30 | ] |
31 | 31 | }, |
| 32 | + { |
| 33 | + "cell_type": "code", |
| 34 | + "execution_count": null, |
| 35 | + "id": "e0a76d28", |
| 36 | + "metadata": {}, |
| 37 | + "outputs": [], |
| 38 | + "source": [ |
| 39 | + "from google.colab import output\n", |
| 40 | + "output.enable_custom_widget_manager()" |
| 41 | + ] |
| 42 | + }, |
32 | 43 | { |
33 | 44 | "cell_type": "code", |
34 | 45 | "execution_count": null, |
|
71 | 82 | "from nbody_sim.api import Simulation, ureg\n", |
72 | 83 | "from nbody_sim.render import create_k3d_animation\n", |
73 | 84 | "\n", |
74 | | - "print(\"Initializing N-Body Physics Engine...\")\n", |
| 85 | + "print(\"Initializing n-body physics engine\")\n", |
75 | 86 | "sim = Simulation()\n", |
76 | 87 | "\n", |
77 | | - "# 1. Generate 500 procedural asteroids\n", |
78 | 88 | "np.random.seed(42)\n", |
79 | 89 | "n_bodies = 500\n", |
80 | 90 | "\n", |
81 | | - "# Using your Pint unit registry for strict physical definitions\n", |
82 | 91 | "positions = np.random.uniform(-5.0, 5.0, (n_bodies, 3)) * ureg.astronomical_unit\n", |
83 | 92 | "velocities = np.random.uniform(-0.5, 0.5, (n_bodies, 3)) * (ureg.astronomical_unit / ureg.nbody_time)\n", |
84 | 93 | "masses = np.random.uniform(0.1, 2.0, n_bodies) * ureg.solar_mass\n", |
85 | 94 | "\n", |
86 | | - "# Add them to the Barnes-Hut tree\n", |
87 | 95 | "sim.add_bodies(positions, velocities, masses)\n", |
88 | 96 | "\n", |
89 | | - "# Generate procedural colours (RGBA floats) and sizes for the renderer\n", |
90 | 97 | "colours = np.random.uniform(0.4, 1.0, (n_bodies, 4))\n", |
91 | 98 | "colours[:, 3] = 1.0 # Set full opacity\n", |
92 | 99 | "sizes = np.random.uniform(0.5, 2.0, n_bodies)\n", |
93 | 100 | "\n", |
94 | | - "print(\"Baking 3D WebGL animation. Please wait...\")\n", |
| 101 | + "print(\"Preparing animation\")\n", |
95 | 102 | "\n", |
96 | | - "# 2. Render the interactive K3D plot\n", |
97 | 103 | "plot = create_k3d_animation(\n", |
98 | 104 | " sim,\n", |
99 | 105 | " dt=0.01,\n", |
|
102 | 108 | " steps=150\n", |
103 | 109 | ")\n", |
104 | 110 | "\n", |
105 | | - "# Display the widget!\n", |
106 | 111 | "plot.display()" |
107 | 112 | ] |
108 | 113 | } |
|
0 commit comments