Rebuild a system from one time step of a simulation.
Takes the positions, velocities and masses recorded at one time and turns them back into an OrbitSystem. Use it to restart a run from a chosen moment, to change something partway through (add a body, remove one) and simulate on, or to save the final state with save_system. The default is the last recorded step.
Parameters
Name
Type
Description
Default
sim_data
DataFrame
The output of simulate_system or continue_simulation, as a pandas or polars DataFrame.
required
time
float or None
The time to take the state from, in seconds since the start of the run. The recorded step closest to this time is used. The default None uses the last recorded step.
None
G
float or None
Gravitational constant of the new system, in m^3 kg^-1 s^-2. The default None uses the value recorded with the run, or the standard value orb.gravitational_constant if none was recorded.
None
Returns
Name
Type
Description
OrbitSystem
A system holding every body present at the chosen time, with its mass in kilograms, position in meters and velocity in meters per second. Bodies are in the order they appear in sim_data.
Raises
Name
Type
Description
TypeError
If sim_data is not a pandas or polars DataFrame with the columns id, mass, x, y, z, vx, vy, vz, time.
The new system starts its own clock: simulating it gives times that begin again at 0. continue_simulation keeps the clock running instead.
A polars DataFrame only carries the recorded G if it is the exact DataFrame pyorbiter returned. If you ran with a non-standard G and have filtered or transformed the polars result since, pass G here.
Examples
The state of the Sun and the Earth at the end of a one-year run.
import pyorbiter as orbsim = orb.create_system().add_sun().add_planet("Earth", parent="Sun").simulate( time_step=orb.seconds_per_day, duration=orb.seconds_per_year)orb.system_from_simulation(sim)
───────────────────────────────── orbit_system ─────────────────────────────────
G: 6.6743e-11 (standard)
Bodies: 2
id mass x y z vx vy vz
Sun 1.989000e+30 -2.797054e+06 -6.431760e+05 0.0 0.000087 -0.000381 0.0
Earth 5.972000e+24 -3.234357e+10 1.435019e+11 0.0 -29549.046043 -6661.380200 0.0
The state 100 days in, with Mars added before simulating on.