[HN Gopher] N-Body Simulator - Interactive 3 Body Problem and Gr...
       ___________________________________________________________________
        
       N-Body Simulator - Interactive 3 Body Problem and Gravitational
       Physics
        
       Author : speckx
       Score  : 102 points
       Date   : 2025-11-25 13:35 UTC (6 days ago)
        
 (HTM) web link (trisolarchaos.com)
 (TXT) w3m dump (trisolarchaos.com)
        
       | nhatcher wrote:
       | Discussed before here:
       | 
       | https://news.ycombinator.com/item?id=45967079 (245 and 112
       | comments)
        
       | jahnu wrote:
       | Love this.
       | 
       | It's not obvious from the UI but you can enter small mass changes
       | and watch things slowly fall apart. E.g. 1.0001 will work even
       | though the UI displays 1.0 after you hit enter.
        
       | modeless wrote:
       | Wow, this looks really nice on a 240 Hz display.
        
         | whoisthemachine wrote:
         | Would be a great screensaver!
        
       | d4rkn0d3z wrote:
       | Here is a thought; Instead of using F=ma, use the equations of
       | motion from GR:
       | 
       | =================================================================
       | =============== SCHWARZSCHILD METRIC AND GEODESIC EQUATIONS OF
       | MOTION (SUMMARY) ================================================
       | ================================
       | 
       | I. THE SCHWARZSCHILD METRIC (g_uv)
       | 
       | The spacetime geometry is defined by the *line element*, ds^2,
       | which relates coordinate changes (dt, dr, d(phi), etc.) to
       | physical distance or proper time: ds^2 = g_uv * dx^u * dx^v
       | 
       | For the Schwarzschild vacuum solution, the line element in the
       | equatorial plane (theta = pi/2) is: ds^2 = -(1 - r_s / r) * c^2 *
       | dt^2 + (1 - r_s / r)^(-1) * dr^2 + r^2 * d(phi)^2
       | 
       | The corresponding non-zero metric components (g_uv) are: g_tt =
       | -(1 - r_s / r) * c^2 g_rr = 1 / (1 - r_s / r) g_phi _phi = r^2
       | 
       | Where: r_s = 2 _ G * M / c^2 (Schwarzschild Radius)
       | 
       | The Lagrangian L for the geodesic path is constructed directly
       | from the metric: L = (1/2) * [ g_tt * (dt/d(lambda))^2 + g_rr *
       | (dr/d(lambda))^2 + g_phi _phi_ (d(phi) /d(lambda))^2 ]
       | 
       | -----------------------------------------------------------------
       | ---------------
       | 
       | II. CONSERVATION LAWS (FROM EULER-LAGRANGE EQUATIONS)
       | 
       | A. TIME EOM (Conserved Energy E) Since the metric is time-
       | independent, the quantity conjugate to t is conserved: *Specific
       | Energy (E)*.
       | 
       | EQUATION (1): Time Evolution d(t)/d(lambda) = E / ( c^2 * (1 -
       | r_s / r) )
       | 
       | B. PHI EOM (Conserved Angular Momentum L_z) Since the metric is
       | symmetric with respect to phi, the quantity conjugate to phi is
       | conserved: *Specific Angular Momentum (L_z)*.
       | 
       | EQUATION (2): Angular Evolution d(phi)/d(lambda) = L_z / r^2
       | 
       | -----------------------------------------------------------------
       | ---------------
       | 
       | III. RADIAL EQUATION OF MOTION (FROM THE METRIC CONSTRAINT)
       | 
       | The radial EOM is derived by imposing the metric normalization
       | condition (g_uv * u^u * u^v = epsilon).
       | 
       | A. MASSIVE PARTICLES (Mass m > 0) The proper time (tau) is the
       | affine parameter (lambda=tau), and the normalization is epsilon =
       | c^2. The final EOM is: (dr/d(tau))^2 = E^2/c^2 - V_eff^2
       | 
       | EQUATION (3M): Radial EOM (Massive) (dr/d(tau))^2 = E^2/c^2 - c^2
       | * (1 - r_s/r) * ( 1 + L_z^2 / (c^2 * r^2) )
       | 
       | B. MASSLESS PARTICLES (Mass m = 0) The normalization is epsilon =
       | 0. The final EOM is: (dr/d(lambda))^2 = E^2 - V_eff^2
       | 
       | EQUATION (3P): Radial EOM (Massless / Photon) (dr/d(lambda))^2 =
       | E^2 - (1 - r_s/r) * L_z^2 / r^2
       | 
       | -----------------------------------------------------------------
       | ---------------
       | 
       | IV. SUMMARY OF GEODESIC EQUATIONS OF MOTION (EOM)
       | 
       | The motion of any particle (massive or massless) in the
       | Schwarzschild spacetime is determined by the following three
       | coupled first-order differential equations:
       | 
       | A. TIME EVOLUTION: d(t)/d(lambda) = E / ( c^2 * (1 - r_s / r) )
       | 
       | B. ANGULAR EVOLUTION: d(phi)/d(lambda) = L_z / r^2
       | 
       | C. RADIAL EVOLUTION (Specific): 1. Massive Particle (using
       | d(tau)): (dr/d(tau))^2 = E^2/c^2 - c^2 * (1 - r_s/r) * ( 1 +
       | L_z^2 / (c^2 * r^2) )
       | 
       | 2. Massless Particle (using d(lambda)): (dr/d(lambda))^2 = E^2 -
       | (1 - r_s/r) * L_z^2 / r^2
       | 
       | =================================================================
       | ===============
       | 
       | This also holds for a non-rotating black hole.
        
         | pixelpoet wrote:
         | Is this AI generated?
        
           | d4rkn0d3z wrote:
           | Yes, just took a few seconds.
           | 
           | It is of course a very well known result.
           | 
           | Not sure why all the down votes.
        
       | herghost wrote:
       | As the default simulation played out beautifully on-load, I
       | immediately started to question: "hang on, I thought there wasn't
       | a solution for 3 bodies, but this looks stable".
       | 
       | Before I could complete the thought, it fell apart magnificently
       | :)
        
         | jahnu wrote:
         | There are quite a few solutions ;)
         | 
         | https://www.sciencealert.com/we-just-got-12000-new-solutions...
        
         | throwawayffffas wrote:
         | The default configuration is a special case. They are all in a
         | stable orbit around the common barycenter, always forming an
         | equilateral triangle. We actually have closed form solutions
         | for this kind of configuration.
         | 
         | See https://en.wikipedia.org/wiki/Three-
         | body_problem#General_sol...
         | 
         | PS: The site has more stable presets under load preset.
        
           | dtgriscom wrote:
           | These are meta-stable, in that only a perfect initial state
           | (positions and velocities) will be stable. Even then, I
           | expect quantum uncertainties would kick in at some point. (In
           | the simulator, the default system goes unstable at about 500
           | seconds, probably due to the limits of floating point math.)
        
             | forgotpwd16 wrote:
             | >probably due to the limits of floating point math
             | 
             | It's due to the integration scheme (2nd order, albeit
             | symplectic) and time step (5e-4, ok if better scheme is
             | used).
        
       | invalidusernam3 wrote:
       | Love the presets! The Broucke one is my favourite
        
       | NKosmatos wrote:
       | Love this, reminds me of a Windows program (whose name I've
       | forgotten) that I was playing with some decades ago... Solarwinds
       | or something similar. You could add planets/masses and play with
       | orbits, trajectories and all sort of options.
        
       | npodbielski wrote:
       | Seems like there is no way to actually make those collide with
       | each other. Even when they are really close, they are just make a
       | pass go in other direction.
        
         | fnands wrote:
         | I doubt they implemented any collision physics.
        
         | cellular wrote:
         | https://youtu.be/ByLhzd5biag
         | 
         | Commentary on close radius interactions. Very interesting wrt
         | nuclear forces!
        
         | dtgriscom wrote:
         | Just for fun, I set it up with six bodies, each 1 unit mass and
         | at 1 unit from origin, but along the three different axes (an
         | octahedron). No initial velocities. Start the sim, they fall
         | towards the center, and then BLAMMO they rocket off in opposite
         | directions at high velocity. Clearly, no conservation of energy
         | here (at least when the bodies are arbitrarily close to each
         | other).
         | 
         | Simple pleasures.
        
       ___________________________________________________________________
       (page generated 2025-12-01 23:02 UTC)