Skip to main content

get_angular_momentum

get_angular_momentum(sim_data)

Total angular momentum about the origin at every time step.

Sums \(m\,\mathbf{r} \times \mathbf{v}\) over every body. Gravity between two bodies acts along the line joining them, so it exerts no net torque and the total angular momentum of an isolated system is constant. For a system that orbits counterclockwise in the x-y plane the vector points along +z.

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.
• Lx, Ly, Lz: the components of the total angular momentum in kg m^2/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 is \(\mathbf{L} = \sum_i m_i\,\mathbf{r}_i \times \mathbf{v}_i\), measured about the origin of the coordinates in sim_data. Its value depends on that origin. It is conserved in the simulation’s own frame and in the barycentric frame, but not in a frame centered on an accelerating body.

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_angular_momentum(sim).head()
time Lx Ly Lz
0 0.0 0.0 0.0 2.661002e+40
1 86400.0 0.0 0.0 2.661002e+40
2 172800.0 0.0 0.0 2.661002e+40
3 259200.0 0.0 0.0 2.661002e+40
4 345600.0 0.0 0.0 2.661002e+40