trajectory_export_func Subroutine

public subroutine trajectory_export_func(me, t, x)

Export a trajectory point during propagation.

Note

It saves both the inertial and rotating trajectory for plotting and exporting later.

Arguments

Type IntentOptional Attributes Name
class(ddeabm_class), intent(inout) :: me
real(kind=wp), intent(in) :: t

time from integrator (sec from sim epoch)

real(kind=wp), intent(in), dimension(:) :: x

state [moon-centered inertial frame]


Calls

proc~~trajectory_export_func~~CallsGraph proc~trajectory_export_func trajectory_export_func add add proc~trajectory_export_func->add icrf_frame icrf_frame proc~trajectory_export_func->icrf_frame transform transform proc~trajectory_export_func->transform two_body_rotating_frame two_body_rotating_frame proc~trajectory_export_func->two_body_rotating_frame

Source Code

    subroutine trajectory_export_func(me,t,x)

    implicit none

    class(ddeabm_class),intent(inout) :: me
    real(wp),intent(in)               :: t    !! time from integrator (sec from sim epoch)
    real(wp),dimension(:),intent(in)  :: x    !! state [moon-centered inertial frame]

    real(wp) :: et !! ephemeris time [sec]
    real(wp),dimension(6) :: x_rotating !! the state to export
    real(wp),dimension(6) :: x_se_rotating !! the state to export
    type(icrf_frame) :: inertial
    type(two_body_rotating_frame) :: rotating
    type(two_body_rotating_frame) :: se_rotating
    logical :: status_ok !! transformation status flag

    select type (me)
    class is (segment)

        et = me%data%et_ref + t  ! convert to ephemeris time [sec]

        ! convert state to the moon-centered rotating frame
        inertial = icrf_frame(b=body_moon)
        rotating = two_body_rotating_frame(primary_body=body_earth,&
                                           secondary_body=body_moon,&
                                           center=center_at_secondary_body,&
                                           et=et)
        ! from inertial to rotating:
        call inertial%transform(x,rotating,et,me%eph,x_rotating,status_ok)
        if (.not. status_ok) error stop 'transformation error in propagate_segment'

        ! also convert to sun-earth rotating for plotting: -- really should only do when when exporting the json traj file
        se_rotating = two_body_rotating_frame(primary_body=body_sun,&
                                              secondary_body=body_earth,&
                                              center=center_at_secondary_body,&
                                              et=et)
        ! from inertial to rotating:
        call inertial%transform(x,se_rotating,et,me%eph,x_se_rotating,status_ok)
        if (.not. status_ok) error stop 'transformation error in propagate_segment'

        ! save both the inertial and rotating trajectories:
        call me%traj_inertial%add(et,x)
        call me%traj_rotating%add(et,x_rotating)
        call me%traj_se_rotating%add(et,x_se_rotating)

    class default
        error stop 'invalid class in trajectory_export_func'
    end select

    end subroutine trajectory_export_func