View source: R/conserved_quantities.R
| get_momentum | R Documentation |
'get_momentum()' computes the total linear momentum
\mathbf{P} = \sum_j m_j \mathbf{v}_j and 'get_angular_momentum()'
the total angular momentum about the origin,
\mathbf{L} = \sum_j m_j \mathbf{r}_j \times \mathbf{v}_j, at every
time step of a simulation.
get_momentum(sim_data)
get_angular_momentum(sim_data)
sim_data |
A tibble output from [simulate_system()]. |
Both are conserved exactly by Newtonian gravity, because every force comes in an equal and opposite pair directed along the line between the two bodies. The Velocity Verlet and Euler-Cromer integrators also conserve both to floating-point rounding, at any time step, so a drift in either points to a problem in the setup rather than the step size. A system whose total momentum is not zero has a center of mass that drifts at a constant velocity; see 'shift_reference_frame(sim_data, "barycenter")'.
A tibble with one row per time step: 'time, px, py, pz' (kg m/s) for 'get_momentum()', and 'time, Lx, Ly, Lz' (kg m^2/s) for 'get_angular_momentum()'.
# A binary built with zero total momentum
sim <- create_system() |>
add_body("A", mass = 2e30, x = 5e10, vy = 15000) |>
add_body("B", mass = 1e30, x = -1e11, vy = -30000) |>
simulate_system(time_step = seconds_per_hour, duration = seconds_per_year)
get_momentum(sim) # px, py, pz all zero to rounding
get_angular_momentum(sim) # Lz constant to rounding
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.