from_primary_to_center Subroutine

private subroutine from_primary_to_center(me, eph, et, rc, status_ok)

returns the state of the frame center w.r.t. the frame primary body.

Type Bound

two_body_rotating_frame

Arguments

Type IntentOptional Attributes Name
class(two_body_rotating_frame), intent(in) :: me
class(ephemeris_class), intent(inout) :: eph

for ephemeris computations (assumed to have already been initialized)

real(kind=wp), intent(in) :: et

ephemeris time [sec]

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

state of frame center w.r.t. primary body [inertial]

logical, intent(out) :: status_ok

true if no errors.


Calls

proc~~from_primary_to_center~~CallsGraph proc~from_primary_to_center transformation_module::two_body_rotating_frame%from_primary_to_center get_rv get_rv proc~from_primary_to_center->get_rv

Called by

proc~~from_primary_to_center~~CalledByGraph proc~from_primary_to_center transformation_module::two_body_rotating_frame%from_primary_to_center proc~rvcto_rvcfrom_icrf transformation_module::rvcto_rvcfrom_icrf proc~rvcto_rvcfrom_icrf->proc~from_primary_to_center proc~transform transformation_module::reference_frame%transform proc~transform->proc~rvcto_rvcfrom_icrf proc~transformation_module_test transformation_module::transformation_module_test proc~transformation_module_test->proc~transform

Source Code

    subroutine from_primary_to_center(me,eph,et,rc,status_ok)

    !! returns the state of the frame center w.r.t. the frame primary body.

    implicit none

    class(two_body_rotating_frame),intent(in) :: me
    class(ephemeris_class),intent(inout)      :: eph        !! for ephemeris computations (assumed to have already been initialized)
    real(wp),intent(in)                       :: et         !! ephemeris time [sec]
    real(wp),dimension(6),intent(out)         :: rc         !! state of frame center w.r.t. primary body [inertial]
    logical,intent(out)                       :: status_ok  !! true if no errors.

    real(wp) :: mu1 !! gravitational parameter of primary body
    real(wp) :: mu2 !! gravitational parameter of secondary body

    if (me%center == center_at_primary_body) then
        rc = zero
    else

        ! primary body -> secondary body state [inertial]:
        call eph%get_rv(et,me%secondary_body,me%primary_body,rc,status_ok)
        if (status_ok) then
            if (me%center == center_at_barycenter) then
                mu1 = me%primary_body%mu
                mu2 = me%secondary_body%mu
                rc = rc * ( mu2/(mu1 + mu2) )
            elseif (me%center == center_at_secondary_body) then
                !frame center is secondary body (rc already computed)
            else
                error stop 'invalid rotating frame center selection.'
            end if
        else
            write(error_unit,'(A)') 'Error in from_primary_to_center: '//&
                                    'Could not compute primary to secondary body state.'
        end if
    end if

    end subroutine from_primary_to_center