Under the hood
The physics model
Six degrees of freedom, the gravity field, the atmosphere, and the integrator that ties them together.
This page describes what the simulator integrates, with which equations, at what step and to what accuracy. It is written for someone deciding whether to trust the numbers, so it names every model and approximation by its real name, and quotes the measured error where there is one. Fidelity and its limits is the companion page: what the model leaves out, and where it knowingly departs from reality.
There are two fidelities. A flight on the classic range — a procedural equatorial range launching due east, kept so that programs written for the original planar simulator still fly as they did — uses that original model, generalised to three dimensions. A flight from any real launch site uses the audited, realistic model. Everything below describes the realistic one; where the classic range differs, it says so.
The state and its frames
The simulator integrates one rigid body per vehicle, and a separated stage, fairing half or payload becomes a body of its own. Each carries thirteen numbers:
- position and velocity of the centre of mass, in an inertial frame;
- an attitude quaternion , the rotation from body axes to that frame;
- body angular rates about the three body axes.
The inertial frame is centred on Earth, with along the spin axis and through the Greenwich meridian at liftoff. Earth-fixed coordinates are that frame turned by about , where is Earth's rotation rate and the mission time. On an interplanetary mission the same frame is tied to the stars: it is the J2000 equatorial frame rotated about its pole by Greenwich mean sidereal time at the launch instant. After a sphere-of-influence crossing the frame is re-centred on the new body, with that body's pole as its axis. Positions on Earth are geodetic latitude and longitude on the WGS84 ellipsoid, and altitude is height above that ellipsoid, not above a sphere and not above sea level.
The equations of motion are Newton's and Euler's:
where is the gravitational acceleration, the sum of thrust, aerodynamic, reaction-control and contact forces, the current mass, the quaternion product, and the torque about the centre of mass. is the inertia tensor, taken as diagonal — — because every vehicle is axisymmetric: the pitch and yaw inertia comes from the stack of tanks, engines and structure, the roll inertia from the stages' radii. The gyroscopic term is kept; it vanishes for a vehicle that does not roll.
Nothing is added for Coriolis or centrifugal effects. Integrating in an inertial frame produces them, which is also why a vehicle on the pad already moves east at 465 m/s times the cosine of the latitude. The air turns with Earth, so the velocity the aerodynamics see is , with the wind.
Mass properties are recomputed every step as the tanks drain. Tank walls are thin shells, propellant columns solid cylinders settled at the bottom of their tanks, and engines, avionics, legs and fins point masses. Only 10 % of the liquid's own inertia counts in roll, because a liquid barely spins with its tank, and methalox stages carry their oxidiser aft. Propellant slosh is not modelled.
The integrator
The flight model: fixed-step RK4
Every vehicle is advanced by the classical fourth-order Runge–Kutta method at a fixed step of 20 ms (50 Hz). Within 2 m of the ground the step is split into four 5 ms sub-steps, so that stiff leg springs and friction stay stable.
Within a step, four quantities are evaluated afresh at every Runge–Kutta stage: gravity, the aerodynamic forces and moments, the air density, and the contact forces. The engines are evaluated at every stage too — the spool-up, the throttle slew, the tail-off, the mass flow and the mass already burned — so a burn converges at the integrator's own order; in the audit's test the position error of a powered segment fell from 0.91 m to m. A burn that runs its tanks dry inside a step pushes only until the propellant is gone. What is held for the step is what a real flight computer holds for a control cycle: the commands. The autopilot runs once per step, and the wind is sampled once per step at the vehicle's position.
On the classic range the thrust, the mass and the density above 86 km are held for the step instead. That makes powered flight first order in the step — about 3 m of error after 70 s of burn — but it reproduces the original model's numbers, which is the point of that range.
The step is fixed for determinism. The app runs these 20 ms steps in chunks inside an 11 ms budget per frame; time warp changes how many steps are taken per frame and never the step itself. The same flight is bit-identical at 30 and 144 frames per second and at every warp. For numerical studies a headless simulation accepts any step up to 0.1 s, and everything that depends on the step follows it.
The audit's checks of this integrator, with the vehicle model around it:
| Check | Result |
|---|---|
| Energy and angular momentum of a coasting body | conserved to about |
| Specific orbital energy after 3 hours of coasting | drift under |
| Free fall in vacuum against the reference | within m |
| A vertical burn against the rocket equation | within 0.007 % |
| Torque-free rigid body over 100 s | angular momentum , energy |
| Step-size convergence, unpowered | fourth order |
How a simulator steps through time explains these methods, their errors and how to test a result for convergence.
Rails: the same step, a cheaper derivative
A vehicle whose program is asleep (fc.sleep), or a body nobody flies, is put
on rails once it is above 151 km, with its engines, reaction control and
ullage off and — if it is holding an attitude — once the autopilot has
settled on that command. It then advances at the same 20 ms step, but on a
cheaper derivative: Kepler motion plus , and on real sites point-mass drag
below 600 km so that a sleeping stage's orbit decays like an awake one's. A
held attitude stays fixed relative to its command frame; a free body turns by
the exact torque-free solution, nutation included. Rails change the cost of a
coast, not its answer.
About the Moon and Mars, and on the way there, the rails keep the full field instead: one RK4 step of the same gravity the awake vehicle feels, the body's and the third bodies included, so that a stage asleep in a low Mars orbit and one awake in it follow the same path to the bit. (Until the third physics audit they flew a two-body conic there, which put a sleeping Mars orbiter 99 km along its track from where it should have been after two hours.)
Cruise rails: RK4 sized by the turn
An interplanetary cruise at 20 ms would be over a billion steps, so a program
can call fc.cruise(seconds) to allow cruise rails. The vehicle is then
advanced through the full n-body field — the current body's point mass and
, and every other body's pull — by the same classic fourth-order
Runge–Kutta method as the rest of the simulator, with fixed sub-steps and no
error control. What changes is the step. Each is sized by how fast the
trajectory is turning, being the time it takes to
turn through a radian: a sub-step turns the path by about 0.02 rad at most,
and never lasts less than 5 s.
On top of that the simulator limits how much mission time one cruise step may cover: never more than an hour; never so much that the trajectory turns by more than 0.5°; never more than half the time it would take to reach any body's 2 000 km clearance shell, or to cross a sphere of influence; never past the program's next wake-up; and never a step whose arc would dip inside that shell, which it checks by walking the conic before committing. In practice that is one RK4 step per cruise step. Near anything the rails fall back to 20 ms steps before the encounter, not after it.
The simulator also carries an adaptive integrator — Dormand and Prince's 5(4) pair, whose error estimate controls its step — but it does not fly with it. It is the reference the tests measure the cruise against. Measured that way, at a tolerance of , the cruise lands 0.08 m from it after a 280-day Earth-to-Mars cruise and 0.18 km from it at the end of a lunar transfer; the local error falls 32-fold each time the step is halved, fifth order, as RK4's should. The acceptance test flies the heliocentric leg to Mars in under two minutes of wall time and requires it to land within 100 km of a finer integration; it lands within 29 km.
Gravity
Earth: WGS84 and J2
Earth is the WGS84 ellipsoid — equatorial radius = 6 378 137 m, flattening 1/298.257 223 563 — with = 3.986 004 418 × 10¹⁴ m³/s², rotation rate = 7.292 115 9 × 10⁻⁵ rad/s, and the zonal harmonic = 1.082 626 68 × 10⁻³ (EGM96). The field is the point mass plus the full three-dimensional term:
where is the position in the inertial frame and its length. The term matters: it changes the radial pull at the surface by +0.16 % at the equator and −0.32 % at the poles, and without its latitude dependence inclined orbits would not precess. Checked against the gradient of the potential it agrees to m/s², and the surface gravity it produces matches WGS84 normal gravity to m/s² at the equator and the pole. Higher harmonics from up are about 0.2 % of or less, and are not modelled.
The most visible consequence is nodal precession: the bulge pulls an inclined orbit's plane round, westward for a prograde orbit. The simulator's orbits regress at the analytic rate to within 1 % — −5.0° a day for the International Space Station's 51.6°, and the +0.986° a day that makes a 700 km orbit at 98.2° sun-synchronous.
Figure · nodal precession
- NODAL DRIFT
- −4.95 °/day
- FULL CIRCUIT
- 73 days
- IN a 90-minute COAST
- 0.31 °
- SUN-SYNCHRONOUS HERE
- 97.10 °
The flight computer reads the local field's magnitude as fc.gravity, and the
pull a coasting vehicle actually feels — gravity less the centrifugal term of
its horizontal speed — as fc.effectiveGravity: 9.78 m/s² on the pad and
nearly zero in orbit.
The Moon and Mars
Each other body is a point mass plus its own , applied about its own pole. The Moon: = 4.902 800 118 × 10¹² m³/s² (JPL DE430 and GRAIL), a sphere of 1 737.4 km, = 2.033 053 × 10⁻⁴ (GRAIL GL0660B). Mars: = 4.282 837 362 × 10¹³ m³/s² (DE440), equatorial radius 3 396.19 km, flattening 1/169.894, = 1.955 45 × 10⁻³. Their poles and prime meridians follow the IAU working group's 2015 report, the Moon's with its thirteen libration terms. Neither body's field has anything beyond : no lunar mass concentrations, no Tharsis bulge.
The atmosphere
Earth
The base is the US Standard Atmosphere 1976, from the ground to 1 000 km: seven layers of constant temperature gradient in geopotential height up to 86 km, and tabulated values above. Below 86 km the implementation matches the published tables to 0.003 %. Above 86 km the realistic model integrates the hydrostatic equation between the table rows instead of interpolating them — straight interpolation was 8 % off at 115 km and is now 0.2 % — and takes the speed of sound from so that it follows the changing composition of the upper air.
On top of that sits the day. With live weather the measured temperature profile, to about 31 km, blends into the standard atmosphere above, and pressure is integrated hydrostatically from the measured surface pressure, with humidity as virtual temperature (weather has the details). Random days take the latitude's tropopause, a sea-level pressure spread and humidity; the classic range shifts the standard atmosphere by the day's surface temperature. On real sites the hydrostatics use WGS84 normal gravity at the site's latitude rather than standard gravity. The day's air is tabulated every 50 m for speed.
Drag stops at 600 km. Below that the drag coefficients are the continuum, Mach-dependent ones all the way up; the free-molecular regime that takes over above about 120 km is not modelled, and nor is the thermosphere's response to solar activity.
Figure · dynamic pressure
- MAX-Q
- 36.4 kPa
- ALTITUDE
- 11.0 km
- MACH
- 1.51
- AFTER LIFTOFF
- 63 s
The figure shows why the atmosphere matters most for a few kilometres of the climb. Density falls roughly tenfold every 16 km; speed rises; their product, the dynamic pressure , peaks once. Where it peaks is where aerodynamic loads, heating on the way up and the wind's effect are all greatest — dynamic pressure and max-Q is the course on it.
Mars
Below 40 km Mars uses the NASA Glenn Research Center engineering model, as specified: a linear temperature, °C below 7 km and °C above, with in metres; pressure kPa; density , with in kelvin. Above 40 km it is built from archived spacecraft measurements: the Mars Climate Sounder's retrievals from 40 to 75 km (the geometric mean of 591 148 levels from 7 840 profiles), and Mars Global Surveyor's accelerometer from 102.5 to 140 km (54 375 drag-derived samples over 123 aerobraking passes). Between them the density is carried hydrostatically through a 110 K mesopause, the coldest Mars is observed to reach, with an explicit, labelled correction factor of 2.48 for the part of the datasets' disagreement that temperature cannot explain. Above 140 km it is extrapolated to an exospheric 230 K. The profile is smooth — continuous in density, temperature and their first derivatives — and uses two gas constants, as the published model does: 192.1 J/(kg·K) for density and 188.92 for the speed of sound.
| Band | Accuracy |
|---|---|
| 0–40 km | The Glenn model as specified: about 1 % below 20 km, but measured 1.8 times too dense at 30 km and 2.6 times at 40 km |
| 40–60 km | A hand-over band, about 1.9 times too dense at 50 km |
| 60–75 km | Measurement-limited, a few percent |
| 75–105 km | A factor of about two either way, where the two datasets disagree |
| 105–140 km | Measurement-limited, but from one season and one latitude band |
| Above 140 km | Extrapolated; density below kg/m³, drag negligible |
It is a mean model. There are no dust storms, no daily cycle and no variation with latitude, and the real atmosphere scatters about these means by a factor of 1.3 at the surface, 2 at 60–80 km and 2.7 at 125 km. An entry that relies on this table should assume the density it meets could be half or double.
Aerodynamics, propulsion and heating, in brief
The vehicle goes through these with the design choices they drive; the models themselves are:
- Axial force from tabulated coefficients against Mach: nose first, 0.30 subsonic rising to 0.62 at Mach 1.15 and falling to 0.25 hypersonic; tail first, 0.85 rising to 1.45 at Mach 2. Flying tail-first under thrust, the plume holds the flow off the base and the coefficient falls as , with the thrust over times the reference area.
- Normal force from the two-dimensional crossflow drag of a cylinder, integrated segment by segment along the body in both lateral planes, including the flow the body's own rotation induces. Real finite cylinders carry less than the two-dimensional value, so the realistic model scales it by Jorgensen's crossflow efficiency — 0.55 to 0.72 subsonic, rising to 1 at supersonic crossflow. The nose adds slender-body lift.
- Grid fins on all three axes, with a normal-force slope that dips as the lattice chokes near Mach 1, a stall limit, and a Mach-dependent drag on all four fins.
- Thrust against ambient pressure, , with the throttle, the ambient pressure and the nozzle exit area; the mass flow is fixed by the throttle, so thrust and specific impulse rise as the air thins. Engines have an ignition dead time of 0.2–0.5 s, a spool-up, a 0.25 s tail-off, throttle and gimbal slew limits, a gimbal cone, nozzle flow separation at deep throttle in thick air, and 1 % of each stage's propellant unusable.
- Heating by the Sutton–Graves stagnation-point relation, with in SI units and the effective nose radius, reduced for a hot wall, with radiative cooling, and a heat shield treated as a single lumped mass with a 2 400 K limit.
- Structural limits of 250 kPa·° of bending load () and 15 g.
Ephemerides: where the bodies are
Moon and Mars missions need the real positions of the Sun, Earth, the Moon and Mars at any instant. They come from analytic series evaluated on the spot — no data files and no network.
- Earth and Mars: VSOP87D, truncated. The series were generated from the Institut de mécanique céleste's authoritative files, not transcribed, keeping the largest terms until the dropped amplitudes sum to at most : 198 terms for Earth and 787 for Mars. VSOP87D gives the ecliptic and equinox of date, so the result is precessed to J2000 with the IAU 1976 angles — by 2026 that correction is 0.36°, some 950 000 km, and could not be skipped. Velocity is the series' analytic derivative.
- The Moon: ELP2000-82B, truncated from the same institute's main-problem files — 235 terms in longitude, 198 in latitude and 154 in distance — driven by Meeus's fundamental arguments, with his correction for the drift of Earth's orbital eccentricity and the additive terms for Venus, Jupiter and Earth's flattening.
- Time. The series run on Terrestrial Time; Earth's rotation runs on Universal Time. The difference, ΔT, comes from Espenak and Meeus's polynomials, which read about 6 s high in 2026 — about 6 km of lunar position. Greenwich mean sidereal time uses the IAU 1982 series in its 2006-compatible form. Mixing the two time scales would rotate the whole solar system by 0.29°, 32 km at the equator, which is why each function takes the one it needs.
| Check | Result |
|---|---|
| Earth, 1950–2100, against the full VSOP87 series | within 273 km |
| Mars, 1950–2100, against the full VSOP87 series | within 255 km |
| Moon, truncation error over 1950–2100 | 0.16″ in longitude, 0.17″ in latitude, 0.36 km in distance |
| Moon against Meeus's worked example, 12 April 1992 | −2.81″, −0.20″, −4.92 km — about 7 km in position |
| Earth against Meeus's worked example, 13 October 1992 | −0.23″, −0.10″, +146 km |
| Sidereal time against Meeus's worked example, 10 April 1987 | exact |
| Mars oppositions 2025–2031 | at 180.00° ± 0.04° elongation |
These have not been checked against JPL's DE440 ephemeris: the service was not reachable from the machine they were built on. The residual against the Moon's worked example is the perturbation series that are not modelled.
Lambert's problem
Given two positions and the time to fly between them, Lambert's problem asks for the orbit that connects them. It is the core of every launch-window search. The simulator solves it with Izzo's method (2014): the problem is reduced to one free variable — is the minimum-energy ellipse, the parabola, a hyperbola — and the non-dimensional time of flight is inverted for by third-order Householder iterations, which converge in two to four steps from Izzo's initial guess. The method has no singularity at a 180° transfer and handles transfers of several revolutions on either branch. Solving a transfer, propagating the answer and comparing the arrival with the target position agrees to of the distance in the worst case tested; multi-revolution solutions agree to about .
The same module propagates any conic with the universal-variable form of Kepler's equation, and prices the burns at each end with the escape and capture relations on the missions page. Lambert's problem and launch windows derives it.
The n-body field
Once a mission leaves for the Moon or Mars, gravity is the central body's point mass and plus the pull of every other body in the field — the Sun, Earth, the Moon, and Mars on a Mars mission. Because the frame is centred on a body that is itself being pulled, each other body contributes a direct and an indirect term:
where is the body's gravitational parameter, its position relative to the central body, and the vehicle's. The first term is the body's pull on the vehicle; the second is its pull on the central body, which the frame falls with. Far from the two nearly cancel, and writing the difference this way keeps that cancellation in one subtraction. Only the central body's is applied; the others are point masses. The sign of the indirect term was wrong once in development — it put 601 % too much gravity into the Moon's sphere of influence — and is now checked against a hand-computed field to m/s².
How it is evaluated depends on the step:
- In the flight model, the other bodies' positions are computed once per 5 s of mission time and held. The Moon moves 5 km in 5 s against a distance of 384 000 km, so holding it costs about m/s², while recomputing the ephemeris at every stage cost 97 % of the step. The quantisation is on mission time, so the same flight still gives the same bits.
- On cruise rails, the adaptive integrator evaluates the full field at every stage.
- On parking-orbit rails (
fc.sleepat 20 ms), the cheap conic ignores the third bodies. Their tidal pull on a low orbit is under m/s².
Solar radiation pressure is implemented but not switched on in flight. Crossing a sphere of influence changes the frame and nothing else; the missions page describes the handover.
Sensors
By default a program reads the true state. With realistic sensors it reads a navigation estimate instead, and everything derived from it — prograde, the orbit, the target, every prediction — inherits the errors. Each sensor carries a slowly wandering bias (a first-order Gauss–Markov process) plus white noise:
- position and velocity from satellite navigation and inertial sensors, 2 m and 1 cm/s, wandering over 30–60 s, on all three axes;
- attitude with a 0.03° bias, and noisy body rates;
- radar altitude, 0.2 % plus 5 cm;
- air data: dynamic pressure, density and pressure 1 %, airspeed and Mach 0.5 %, angle of attack 0.2°;
- accelerometers 0.1 %, and the propellant gauge 0.2 % of what is left.
The hard setting triples every error. The errors are seeded — the same seed gives the same errors — and the physics always runs on the truth.
Determinism
The same vehicle, mission, weather snapshot and program give the same flight, step for step, in the browser and headless. Random draws come from seeded streams, each quantity from its own, so adding a model never reshuffles the numbers of another. Reading telemetry for the display never changes what the program sees. This is what lets a flight be shared as a link and replayed, and what makes the numbers on this page reproducible.