Compute the two-body orbital energy.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | mu |
gravitational parameter [] |
||
real(kind=wp), | intent(in), | dimension(6) | :: | rv |
position and velocity vector [km,km/s] |
two-body orbital energy []
pure function orbit_energy(mu,rv) result(energy) implicit none real(wp),intent(in) :: mu !! gravitational parameter [\(km^{3}/s^{2}\)] real(wp),dimension(6),intent(in) :: rv !! position and velocity vector [km,km/s] real(wp) :: energy !! two-body orbital energy [\(km^{2}/s^{2}\)] real(wp) :: rmag !! position vector magnitude [km] real(wp) :: vmag !! velocity vector magnitude [km] rmag = norm2(rv(1:3)) vmag = norm2(rv(4:6)) energy = (vmag**2 / two) - (mu / rmag) end function orbit_energy