Skip to main content

get_momentum

get_momentum(sim_data)

Total linear momentum at every time step.

Sums mass times velocity over every body. Gravity acts in equal and opposite pairs, so the total momentum of an isolated system is constant. In a simulation it should hold steady to within floating-point rounding.

Parameters

Name Type Description Default
sim_data DataFrame The output of simulate_system(): a pandas or polars DataFrame with columns id, mass, x, y, z, vx, vy, vz and time, in SI units. required

Returns

Name Type Description
DataFrame The same kind of DataFrame it was given (pandas or polars), with one row per time step, sorted by time, and these columns:
• time: time in seconds.
• px, py, pz: the components of the total momentum in kg m/s.

Raises

Name Type Description
TypeError If sim_data is not a pandas or polars DataFrame with the columns simulate_system() produces.

See Also

Notes

The total momentum is \(\mathbf{P} = \sum_i m_i \mathbf{v}_i\). Its value depends on the reference frame. A system built around a star at rest has a nonzero total, because the planets move and the star does not, and the whole system drifts slowly as a result. In the barycentric frame the total is zero.

Examples

import pyorbiter as orb

sim = (
    orb.create_system()
    .add_sun()
    .add_planet("Earth", parent="Sun")
    .simulate(time_step=orb.seconds_per_day, duration=orb.seconds_per_year)
)
orb.get_momentum(sim).head()
time px py pz
0 0.0 -1.762946e+29 -4.053879e+28 0.0
1 86400.0 -1.762946e+29 -4.053879e+28 0.0
2 172800.0 -1.762946e+29 -4.053879e+28 0.0
3 259200.0 -1.762946e+29 -4.053879e+28 0.0
4 345600.0 -1.762946e+29 -4.053879e+28 0.0