propagate_segment_stm Subroutine

public subroutine propagate_segment_stm(me)

Propagate a segment with its state transition matrix, and compute the analytic partials of its final rotating-frame state (for jacobian_mode=2):

  • dxf_dx0 : w.r.t. the initial rotating-frame state,
  • dxf_dt0 : w.r.t. the initial epoch (at fixed final epoch, and fixed rotating-frame initial state ),
  • dxf_dtf : w.r.t. the final epoch,

where is the inertial state transition matrix, the equations of motion, and , the inertial-to-rotating and rotating-to-inertial transformations (see two_body_rotating_frame_matrices). The epoch partial uses .

The final state (and its rotating-frame version) is also set, as by propagate_segment.

Type Bound

segment

Arguments

Type IntentOptional Attributes Name
class(segment), intent(inout) :: me

Calls

proc~~propagate_segment_stm~~CallsGraph proc~propagate_segment_stm segment%propagate_segment_stm first_call first_call proc~propagate_segment_stm->first_call icrf_frame icrf_frame proc~propagate_segment_stm->icrf_frame integrate integrate proc~propagate_segment_stm->integrate proc~ballistic_derivs ballistic_derivs proc~propagate_segment_stm->proc~ballistic_derivs proc~earth_moon_frame_matrices earth_moon_frame_matrices proc~propagate_segment_stm->proc~earth_moon_frame_matrices proc~identity_stm identity_stm proc~propagate_segment_stm->proc~identity_stm proc~set_segment_outputs segment%set_segment_outputs proc~propagate_segment_stm->proc~set_segment_outputs transform transform proc~propagate_segment_stm->transform two_body_rotating_frame two_body_rotating_frame proc~propagate_segment_stm->two_body_rotating_frame get_acc get_acc proc~ballistic_derivs->get_acc get_r get_r proc~ballistic_derivs->get_r icrf_to_iau_moon icrf_to_iau_moon proc~ballistic_derivs->icrf_to_iau_moon j2000_to_frame j2000_to_frame proc~ballistic_derivs->j2000_to_frame proc~pines_gravity pines_gravity proc~ballistic_derivs->proc~pines_gravity proc~pointmass_gravity_gradient pointmass_gravity_gradient proc~ballistic_derivs->proc~pointmass_gravity_gradient proc~third_body_gravity_gradient third_body_gravity_gradient proc~ballistic_derivs->proc~third_body_gravity_gradient third_body_gravity third_body_gravity proc~ballistic_derivs->third_body_gravity get_rv get_rv proc~earth_moon_frame_matrices->get_rv get_rv_derivative get_rv_derivative proc~earth_moon_frame_matrices->get_rv_derivative proc~two_body_rotating_frame_matrices two_body_rotating_frame_matrices proc~earth_moon_frame_matrices->proc~two_body_rotating_frame_matrices proc~outer outer proc~pines_gravity->proc~outer proc~point_gradient point_gradient proc~pointmass_gravity_gradient->proc~point_gradient proc~third_body_gravity_gradient->proc~point_gradient 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 proc~point_gradient->proc~outer

Called by

proc~~propagate_segment_stm~~CalledByGraph proc~propagate_segment_stm segment%propagate_segment_stm proc~compute_jacobian_stm mission_type%compute_jacobian_stm proc~compute_jacobian_stm->proc~propagate_segment_stm 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

    subroutine propagate_segment_stm(me)

    implicit none

    class(segment),intent(inout) :: me

    integer  :: idid
    real(wp) :: t, t0, tf, et0, etf
    real(wp),dimension(n_eoms_stm) :: x
    real(wp),dimension(6) :: xf, xf_rotating, f0, ff
    real(wp),dimension(6,6) :: phi, m_f, mdot_f, n_0, ndot_0
    type(icrf_frame) :: inertial
    type(two_body_rotating_frame) :: rotating
    logical :: status_ok

    if (.not. me%stm_mode) error stop 'error: propagate_segment_stm requires stm_mode'

    t0 = me%data%t0 * day2sec  ! initial time in seconds from epoch
    tf = me%data%tf * day2sec  ! final time in seconds from epoch
    x(1:n_eoms) = me%data%x0   ! inertial state
    x(n_eoms+1:) = identity_stm()

    ! integrate in local time (from 0 at t0), see t_offset:
    me%t_offset = t0
    t = zero
    me%compute_stm = .true.
    call me%first_call()
    call me%integrate(t,x,(me%data%tf - me%data%t0) * day2sec,idid=idid,integration_mode=1)
    me%compute_stm = .false.
    me%t_offset = zero  ! (the calls below use the time from epoch)
    me%failed = .false.
    if (idid<0) then
        if (me%soft_fail) then
            me%failed = .true.
            me%dxf_dx0 = zero; me%dxf_dt0 = zero; me%dxf_dtf = zero
            return
        end if
        write(*,'(A,*(I5/))') 'idid: ',idid
        error stop 'error in integrator'
    end if

    xf  = x(1:n_eoms)
    phi = reshape(x(n_eoms+1:), [6,6])

    ! the final state in the rotating frame (as in propagate_segment):
    etf = me%data%et_ref + tf
    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=etf)
    call inertial%transform(xf,rotating,etf,me%eph,xf_rotating,status_ok)
    if (.not. status_ok) error stop 'transformation error in propagate_segment_stm'
    call me%set_outputs(xf,xf_rotating)

    ! the frame transformations and their time derivatives:
    et0 = me%data%et_ref + t0
    call earth_moon_frame_matrices(me, et0, n=n_0, ndot=ndot_0)
    call earth_moon_frame_matrices(me, etf, m=m_f, mdot=mdot_f)

    ! equations of motion at the start and the end:
    call ballistic_derivs(me, t0, me%data%x0, f0)
    call ballistic_derivs(me, tf, xf, ff)

    me%dxf_dx0 = matmul(m_f, matmul(phi, n_0))
    me%dxf_dt0 = matmul(m_f, matmul(phi, matmul(ndot_0, me%data%x0_rotating) - f0))
    me%dxf_dtf = matmul(mdot_f, xf) + matmul(m_f, ff)

    end subroutine propagate_segment_stm