two_body_rotating_frame_matrices Subroutine

public pure subroutine two_body_rotating_frame_matrices(rv, rdot, vdot, m, mdot, n, ndot)

The 6x6 state transformations of a two-body rotating frame (as defined by the toolkit's two_body_rotating_frame), and their exact time derivatives.

The frame's axes are , (), , where is the secondary body's state w.r.t. the primary body. With the matrix whose rows are the axes, and (as in the toolkit) , :

  • inertial to rotating: ,
  • rotating to inertial: .

(Both frames are assumed to have the same origin.) The time derivatives of and are computed exactly from the time derivatives of and (rdot, vdot). Note that is the toolkit's definition, which is not exactly (it neglects the rotation of ); the derivatives here are of the transformation as it is actually defined.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(6) :: rv

state of the secondary w.r.t. the primary [km, km/s]

real(kind=wp), intent(in), dimension(3) :: rdot

time derivative of rv(1:3) [km/s]

real(kind=wp), intent(in), dimension(3) :: vdot

time derivative of rv(4:6) [km/s^2]

real(kind=wp), intent(out), optional, dimension(6,6) :: m

inertial to rotating

real(kind=wp), intent(out), optional, dimension(6,6) :: mdot

dM/dt [1/s]

real(kind=wp), intent(out), optional, dimension(6,6) :: n

rotating to inertial

real(kind=wp), intent(out), optional, dimension(6,6) :: ndot

dN/dt [1/s]


Calls

proc~~two_body_rotating_frame_matrices~~CallsGraph proc~two_body_rotating_frame_matrices two_body_rotating_frame_matrices proc~cross cross proc~two_body_rotating_frame_matrices->proc~cross proc~cross_matrix cross_matrix proc~two_body_rotating_frame_matrices->proc~cross_matrix

Called by

proc~~two_body_rotating_frame_matrices~~CalledByGraph proc~two_body_rotating_frame_matrices two_body_rotating_frame_matrices proc~earth_moon_frame_matrices earth_moon_frame_matrices proc~earth_moon_frame_matrices->proc~two_body_rotating_frame_matrices proc~compute_jacobian_stm mission_type%compute_jacobian_stm proc~compute_jacobian_stm->proc~earth_moon_frame_matrices proc~propagate_segment_stm segment%propagate_segment_stm proc~compute_jacobian_stm->proc~propagate_segment_stm proc~propagate_segment_stm->proc~earth_moon_frame_matrices proc~equilibrate equilibrate proc~equilibrate->proc~compute_jacobian_stm proc~equilibrate_scales mission_type%equilibrate_scales proc~equilibrate_scales->proc~compute_jacobian_stm proc~eclipse_optimize eclipse_optimize proc~eclipse_optimize->proc~equilibrate proc~initialize_the_mission mission_type%initialize_the_mission proc~initialize_the_mission->proc~equilibrate_scales interface~eclipse_optimize my_solver_type%eclipse_optimize interface~eclipse_optimize->proc~eclipse_optimize proc~initialize_the_solver my_solver_type%initialize_the_solver proc~initialize_the_solver->proc~initialize_the_mission proc~halo_solver_main halo_solver_main proc~halo_solver_main->interface~eclipse_optimize proc~halo_solver_main->proc~initialize_the_solver

Source Code

    pure subroutine two_body_rotating_frame_matrices(rv,rdot,vdot,m,mdot,n,ndot)

    implicit none

    real(wp),dimension(6),intent(in)  :: rv    !! state of the secondary w.r.t. the primary [km, km/s]
    real(wp),dimension(3),intent(in)  :: rdot  !! time derivative of `rv(1:3)` [km/s]
    real(wp),dimension(3),intent(in)  :: vdot  !! time derivative of `rv(4:6)` [km/s^2]
    real(wp),dimension(6,6),intent(out),optional :: m     !! inertial to rotating
    real(wp),dimension(6,6),intent(out),optional :: mdot  !! dM/dt [1/s]
    real(wp),dimension(6,6),intent(out),optional :: n     !! rotating to inertial
    real(wp),dimension(6,6),intent(out),optional :: ndot  !! dN/dt [1/s]

    real(wp),dimension(3) :: r, v, h, hdot, xhat, yhat, zhat, xhatd, yhatd, zhatd, w, wdot
    real(wp),dimension(3,3) :: c, cd, cf, cfd
    real(wp) :: rmag, hmag

    r = rv(1:3)
    v = rv(4:6)
    rmag = norm2(r)
    h    = cross(r,v)
    hmag = norm2(h)
    hdot = cross(rdot,v) + cross(r,vdot)

    xhat = r / rmag
    zhat = h / hmag
    yhat = cross(zhat,xhat)
    xhatd = (rdot - xhat*dot_product(xhat,rdot)) / rmag
    zhatd = (hdot - zhat*dot_product(zhat,hdot)) / hmag
    yhatd = cross(zhatd,xhat) + cross(zhat,xhatd)

    c(1,:)  = xhat ; c(2,:)  = yhat ; c(3,:)  = zhat
    cd(1,:) = xhatd; cd(2,:) = yhatd; cd(3,:) = zhatd   ! dC/dt

    w    = h / (rmag*rmag)
    wdot = hdot/(rmag*rmag) - two*h*dot_product(r,rdot)/rmag**4
    cf   = -matmul(c, cross_matrix(w))                               ! toolkit's "cdot"
    cfd  = -matmul(cd, cross_matrix(w)) - matmul(c, cross_matrix(wdot))  ! d(cf)/dt

    if (present(m)) then
        m = zero
        m(1:3,1:3) = c
        m(4:6,1:3) = cf
        m(4:6,4:6) = c
    end if
    if (present(mdot)) then
        mdot = zero
        mdot(1:3,1:3) = cd
        mdot(4:6,1:3) = cfd
        mdot(4:6,4:6) = cd
    end if
    if (present(n)) then
        n = zero
        n(1:3,1:3) = transpose(c)
        n(4:6,1:3) = transpose(cf)
        n(4:6,4:6) = transpose(c)
    end if
    if (present(ndot)) then
        ndot = zero
        ndot(1:3,1:3) = transpose(cd)
        ndot(4:6,1:3) = transpose(cfd)
        ndot(4:6,4:6) = transpose(cd)
    end if

    end subroutine two_body_rotating_frame_matrices