展示HN:基于浏览器的交互式三体问题模拟器
Show HN: Browser-based interactive 3D Three-Body problem simulator

原始链接: https://trisolarchaos.com/?pr=O_8(0.6)&n=3&s=5.0&so=0.00&im=rk4&dt=1.00e-4&rt=1.0e-6&at=1.0e-8&bs=0.15&sf=0&sv=0&cm=free&kt=1&st=1&tl=1500&cp=2.5208,1.5125,2.5208&ct=0.0000,0.0000,0.1670

## 三体问题模拟器:摘要 三体问题是物理学中一个长期存在的挑战,它询问我们是否可以预测三个引力相互作用物体的运动。与两体系统不同,它缺乏通用的解析解,需要数值模拟来进行研究。 该模拟器使用牛顿万有引力定律对这个问题进行建模,计算物体之间的力,并随时间更新它们的位置。它提供了两种积分方法:速度Verlet,它擅长长期能量守恒和轨道稳定性;以及RK4,提供更高的短期精度。 该模拟器具有已知周期轨道的预设配置——包括8字编舞和拉格朗日配置——以及自定义设置的选项。用户可以调整质量、速度和物理参数,并通过时间线和能量漂移指标(衡量模拟精度)来分析轨道行为。 该模拟器使用Three.js构建,以3D方式可视化动力学,跟踪模拟历史,并允许共享配置。理解能量守恒——在引力系统中通常为负值,表示受限轨道——是解释结果的关键。

一个基于浏览器、交互式的三体问题3D模拟器在Hacker News上分享(trisolarchaos.com)。它使用Three.js构建,允许用户可视化和探索三个天体的复杂轨道力学,提供完整的3D相机控制和矢量可视化。 它包含预设轨道,包括新发现的3D解,并允许用户“拖动”时间线。用户称赞其易用性和性能,并指出在浏览器中运行此类模拟是一项了不起的成就。 创建者jgchaos受到数学挑战和刘慈欣的《三体》系列的启发,甚至在URL中加入了对书籍的致敬。他们乐于接受建议,已经有人提出了添加真实恒星系统和专注于行星宜居性的“三体人模式”的想法。
相关文章

原文

What is the Three-Body Problem?

The three-body problem is one of the most famous challenges in classical physics and celestial mechanics. It asks: given the initial positions, masses, and velocities of three bodies in space, can we predict their future motion under mutual gravitational attraction?

Unlike the two-body problem (which has an exact analytical solution), the three-body problem has no general closed-form solution. This makes numerical simulation the primary tool for studying these complex gravitational systems.

N-Body Gravitational Simulation

This simulator uses Newton's law of universal gravitation to model the gravitational forces between every pair of bodies:

F = G × m₁ × m₂ / (r² + ε²)

Each body experiences the sum of all pairwise gravitational forces from every other body. For N bodies, this requires calculating N(N-1)/2 force pairs each timestep. The ε² term is a softening parameter that prevents numerical singularities when bodies pass very close together.

The simulation supports multiple integration methods. By default, it uses the Velocity Verlet integration method, a symplectic integrator that provides superior energy conservation compared to simpler methods like Euler integration. This makes it ideal for long-term orbital mechanics simulations.

Users can switch to the 4th-order Runge-Kutta (RK4) method in the Advanced Settings, which offers higher accuracy per timestep and typically shows lower energy drift in short simulations. However, RK4 is not symplectic and accumulates systematic phase errors over long simulation times, causing orbits to gradually decay or expand. This makes RK4 better suited for short to medium duration simulations where minimizing instantaneous error is the priority, while Verlet excels at maintaining correct orbital shapes over extended periods.

Preset Configurations

The simulator includes several famous periodic three-body orbits discovered through numerical searches:

2D Orbits

  • Figure-8 choreography: Discovered by Cris Moore in 1993, where three equal masses chase each other along a figure-eight shaped path
  • Lagrange triangular configuration: Equilateral triangle configuration with circular orbits.
  • Butterfly, Broucke, Hénon, and Yarn: Periodic orbits from the Šuvakov-Dmitrašinović database of three-body choreographies, discovered through systematic numerical exploration of initial conditions

3D Orbits

Three-dimensional periodic orbits from Li and Liao (2025), which discovered 10,059 new periodic solutions including 21 choreographic orbits and 273 "piano-trio" orbits (where two equal-mass bodies share one orbit while a third body follows another). Paper | GitHub

Features & Applications

  • Real-time Physics: Experience gravitational dynamics in 3D with interactive controls
  • Multiple Integration Methods: Choose between Velocity Verlet (energy-conserving) and RK4 (high accuracy).
  • Exploration Platform: Experiment with different initial conditions and masses
  • Timeline Playback: Scrub through simulation history to analyze orbital behavior

How to Use

Getting Started: Use the preset configurations (Figure-8 or Lagrange) to see stable three-body orbits, or generate random initial conditions to explore chaotic dynamics.

Controls: Adjust body masses, simulation speed, and physics parameters. Use the timeline to review and analyze orbital patterns. Drag bodies while paused to create custom configurations.

Sharing: Click "Share Configuration" to generate a URL that preserves your exact simulation initial state.

Energy Conservation & Simulation Accuracy

The simulator displays two important energy metrics in the Advanced Settings panel:

  • Total Energy: The sum of kinetic energy (½mv²) and gravitational potential energy (-Gm₁m₂/r) of all bodies. In an ideal gravitational system, this value should remain constant over time.
  • Energy Drift: The percentage change in total energy from the initial state. This measures the numerical accuracy of the simulation.

In real physics, energy is conserved in isolated systems. However, numerical integration methods introduce small errors at each timestep. The energy drift indicator helps you evaluate simulation quality:

  • Green (<1%): Excellent energy conservation - the simulation is highly accurate
  • Yellow (1-5%): Moderate drift - acceptable for most purposes but consider reducing timestep
  • Red (>5%): Significant drift - simulation may be unreliable, reduce timestep or try other integration methods

The Velocity Verlet integration method is "symplectic," meaning it preserves the phase-space structure of Hamiltonian systems. While RK4 typically shows lower energy drift in short-term simulations (better local accuracy), Verlet prevents systematic phase errors that accumulate over extended simulations. This makes Verlet ideal for long-term orbital mechanics where maintaining orbital stability over thousands of periods is more important than minimizing instantaneous error.

Why is Total Energy Negative? In gravitational systems, total energy is often negative, and this is perfectly normal! Gravitational potential energy is defined as zero at infinite separation and becomes increasingly negative as bodies move closer together (PE = -Gm₁m₂/r). When total energy is negative, it means the system is gravitationally bound - the bodies don't have enough kinetic energy to escape to infinity, so they remain in orbit. This is exactly what you see in stable orbital systems like planets around stars or the choreographed orbits in this simulator. A negative total energy that remains constant indicates a stable, bound orbital system.

Technical Details

Built with Three.js for WebGL-accelerated 3D graphics and modern JavaScript. The physics engine implements N-body gravitational calculations with a configurable softening parameter to prevent numerical singularities during close encounters.

The simulator tracks up to 10,000 frames of history, allowing you to review and analyze the evolution of complex orbital systems. All simulations are deterministic and reproducible.

Feedback

Have suggestions, found a bug, or want to share your thoughts? Give feedback and help improve this simulator!

联系我们 contact @ memedata.com