<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Run Cheng's Engineering Blog]]></title><description><![CDATA[Run Cheng's Engineering Blog]]></description><link>https://runcheng.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 03 Nov 2026 04:29:55 GMT</lastBuildDate><atom:link href="https://runcheng.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Simulating N-Body Galactic Collisions and NASA TESS Exoplanet Transits in the Browser with WebGPU & WebGL2]]></title><description><![CDATA[When I launched Space Simulator Online as a zero-install 3D Solar System and night-sky planetarium in raw WebGL2, the most frequent request from physics…]]></description><link>https://runcheng.hashnode.dev/simulating-n-body-galactic-collisions-and-nasa-tess-exoplanet-transits-in-the-browser-with-webgpu-webgl2</link><guid isPermaLink="true">https://runcheng.hashnode.dev/simulating-n-body-galactic-collisions-and-nasa-tess-exoplanet-transits-in-the-browser-with-webgpu-webgl2</guid><category><![CDATA[webgpu]]></category><category><![CDATA[WebGL]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Astronomy]]></category><category><![CDATA[Physics]]></category><dc:creator><![CDATA[Run Cheng]]></dc:creator><pubDate>Mon, 26 Oct 2026 10:09:03 GMT</pubDate><content:encoded><![CDATA[<p>When I launched <a href="https://spacesimulator.online/">Space Simulator Online</a> as a zero-install 3D Solar System and night-sky planetarium in raw WebGL2, the most frequent request from physics teachers and students was: <em>"Can we go beyond static Keplerian orbits and interact with real astrophysical dynamics and telescope data in the browser?"</em></p>
<p>That led to three dedicated interactive labs inside Space Simulator Online:</p>
<ol>
<li><strong><a href="https://spacesimulator.online/galaxies/">Galactic Collisions (<code>/galaxies/</code>)</a></strong> — An interactive N-body gravitational simulator accelerated by <strong>WebGPU compute shaders</strong> (with a WebGL2 fallback) modeling the Milky Way–Andromeda merger and the Antennae Galaxies.</li>
<li><strong><a href="https://spacesimulator.online/planet-hunter/">TESS Planet Hunter (<code>/planet-hunter/</code>)</a></strong> — A browser photometry lab where students inspect real NASA TESS light curves to detect exoplanet transits and distinguish them from eclipsing binaries.</li>
<li><strong><a href="https://spacesimulator.online/gravitational-waves/">Gravitational Waves (<code>/gravitational-waves/</code>)</a></strong> — A real-time 3D binary inspiral and strain waveform visualizer built around LIGO's GW150914 detection, including real-time audio sonification.</li>
</ol>
<p>Here is how we built the GPU compute pipeline and astronomical data compression to keep the entire experience running at 60 FPS with zero install.</p>
<hr />
<h2>1. N-Body Galaxy Mergers with WebGPU Compute Shaders</h2>
<p>In our Solar System view, planets follow analytical Keplerian ellipses evaluated from NASA/JPL Horizons orbital elements. That is <code>O(N)</code> per frame.</p>
<p>A galaxy collision is fundamentally different: as two spiral galaxies pass through each other, tidal tails and bridges emerge from the gravitational interaction of thousands of stellar particles and dark-matter halos. A direct all-pairs gravitational sum scales as <code>O(N^2)</code>:</p>
<pre><code class="language-text">a_i = G * sum_{j != i} m_j * (r_j - r_i) / (||r_j - r_i||^2 + epsilon^2)^(3/2)
</code></pre>
<p>Where <code>epsilon</code> is the Plummer softening length that prevents numerical singularities during close stellar passes.</p>
<h3>Tile-Based Shared Memory in WGSL</h3>
<p>In <a href="https://spacesimulator.online/galaxies/">Space Simulator Online's Galactic Collisions lab</a>, when <code>navigator.gpu</code> is available, we dispatch a WebGPU compute shader with workgroup size <code>256</code>. Each workgroup loads a tile of particle positions and masses <code>(x, y, z, m)</code> into <code>var&lt;workgroup&gt; sharedTile: array&lt;vec4&lt;f32&gt;, 256&gt;</code>, synchronizes via <code>workgroupBarrier()</code>, and accumulates accelerations in registers before advancing positions with a symplectic Leapfrog (Kick–Drift–Kick) integrator.</p>
<p>Using a symplectic integrator rather than standard Euler integration preserves phase-space structure so spiral arms and tidal tails remain coherent over hundreds of millions of simulated years.</p>
<hr />
<h2>2. Packing 6,000+ NASA Exoplanets and TESS Transit Light Curves</h2>
<p>Our <a href="https://spacesimulator.online/exoplanets/">3D Exoplanet Explorer (<code>/exoplanets/</code>)</a> plots over 6,000 confirmed worlds from the NASA Exoplanet Archive in 3D galactic coordinates derived from Right Ascension, Declination, and Gaia parallax distances.</p>
<p>To let students experience <em>how</em> those planets are discovered, we built <a href="https://spacesimulator.online/planet-hunter/">Planet Hunter (<code>/planet-hunter/</code>)</a>. Instead of synthetic sine waves, it loads real photometric flux time series from NASA's Transiting Exoplanet Survey Satellite (TESS).</p>
<p>When a planet of radius <code>R_p</code> crosses a host star of radius <code>R_*</code>, the fractional drop in brightness gives the transit depth directly:</p>
<pre><code class="language-text">Delta_F / F = (R_p / R_*)^2
</code></pre>
<p>We pre-normalize the PDCSAP flux curves, quantize timestamps and relative flux deltas into compact typed arrays, and render an interactive phase-folding and transit-marking canvas. Students can also compare true planetary transits against classic astrophysical false positives—such as grazing eclipsing binaries and stellar rotation spots.</p>
<hr />
<h2>3. LIGO Strain Waveforms and Web Audio Chirps</h2>
<p>Finally, in the <a href="https://spacesimulator.online/gravitational-waves/">Gravitational Waves lab (<code>/gravitational-waves/</code>)</a>, we pair a 3D spacetime curvature mesh with the actual Hanford (H1) and Livingston (L1) strain data from <strong>GW150914</strong>—the first direct detection of two merging black holes (36 and 29 solar masses). Using the browser's <code>AudioContext</code>, you can play the frequency-swept chirp as the orbital separation shrinks toward coalescence.</p>
<hr />
<h2>Try It Live in Your Browser</h2>
<p>Everything runs client-side in your browser with no account, no install, and no ads:</p>
<ul>
<li><strong>Main 3D Solar System &amp; Planetarium</strong>: <a href="https://spacesimulator.online/">https://spacesimulator.online/</a></li>
<li><strong>6,000+ NASA Exoplanets 3D Map</strong>: <a href="https://spacesimulator.online/exoplanets/">https://spacesimulator.online/exoplanets/</a></li>
<li><strong>TESS Planet Hunter Light-Curve Lab</strong>: <a href="https://spacesimulator.online/planet-hunter/">https://spacesimulator.online/planet-hunter/</a></li>
<li><strong>WebGPU Galactic Collisions</strong>: <a href="https://spacesimulator.online/galaxies/">https://spacesimulator.online/galaxies/</a></li>
<li><strong>LIGO Gravitational Waves</strong>: <a href="https://spacesimulator.online/gravitational-waves/">https://spacesimulator.online/gravitational-waves/</a></li>
</ul>
]]></content:encoded></item></channel></rss>