Skip to main content

run_settings

run_settings(sim_data)

The settings of the run that produced a simulation.

simulate_system records the gravitational constant, softening length, integrator and time step it used alongside its result. The analysis functions read them from there, so that get_energy, for example, uses the same G and softening as the run. This function returns them as a dict, and works the same way for pandas and polars results.

Parameters

Name Type Description Default
sim_data DataFrame The output of simulate_system, continue_simulation or shift_reference_frame, as a pandas or polars DataFrame. required

Returns

Name Type Description
dict The recorded settings:
• G: gravitational constant in m^3 kg^-1 s^-2.
• softening: softening length in meters.
• method: the integrator, "verlet", "euler_cromer" or "euler".
• time_step: time between recorded states in seconds. After continue_simulation this is the step of the latest segment. The dict is a copy, so changing it does not change the DataFrame. It is empty if nothing is recorded for sim_data.

See Also

Notes

For a pandas DataFrame the settings live in sim_data.attrs, and this function returns a copy of that dict. pandas carries attrs through most operations, such as filtering rows.

A polars DataFrame has nowhere to keep them, so they are remembered only for the exact DataFrame pyorbiter returned. Anything you derive from it (filter, sort, with_columns, clone, a file read back) gives an empty dict here. For a polars run that did not use the defaults, pass G and softening to the analysis functions, and G, softening and method to continue_simulation, yourself.

Examples

import pyorbiter as orb

sim = orb.create_system().add_sun().add_planet("Earth", parent="Sun").simulate(
    time_step=orb.seconds_per_day, duration=30 * orb.seconds_per_day,
    softening=1e4)

orb.run_settings(sim)
{'G': 6.6743e-11, 'softening': 10000.0, 'method': 'verlet', 'time_step': 86400}

A polars result keeps its settings only until you derive a new DataFrame from it.

import polars as pl
import pyorbiter as orb

sim = orb.create_system().add_sun().add_planet("Earth", parent="Sun").simulate(
    time_step=orb.seconds_per_day, duration=30 * orb.seconds_per_day,
    backend="polars")
earth = sim.filter(pl.col("id") == "Earth")

{"returned by pyorbiter": orb.run_settings(sim), "after filter": orb.run_settings(earth)}
{'returned by pyorbiter': {'G': 6.6743e-11,
  'softening': 0,
  'method': 'verlet',
  'time_step': 86400},
 'after filter': {}}