propagate_segment Subroutine

public subroutine propagate_segment(me, mode, tstep)

Propagate a segment (assumes the inputs have already been populated)

Type Bound

segment

Arguments

Type IntentOptional Attributes Name
class(segment), intent(inout) :: me
integer, intent(in), optional :: mode

1 - don't report steps, 2 - report steps (for plotting)

real(kind=wp), intent(in), optional :: tstep

fixed time step for mode=2


Calls

proc~~propagate_segment~~CallsGraph proc~propagate_segment segment%propagate_segment first_call first_call proc~propagate_segment->first_call icrf_frame icrf_frame proc~propagate_segment->icrf_frame integrate integrate proc~propagate_segment->integrate proc~identity_stm identity_stm proc~propagate_segment->proc~identity_stm proc~set_segment_outputs segment%set_segment_outputs proc~propagate_segment->proc~set_segment_outputs transform transform proc~propagate_segment->transform two_body_rotating_frame two_body_rotating_frame proc~propagate_segment->two_body_rotating_frame

Called by

proc~~propagate_segment~~CalledByGraph proc~propagate_segment segment%propagate_segment proc~constraint_violations mission_type%constraint_violations proc~constraint_violations->proc~propagate_segment proc~export_trajectory_json_file mission_type%export_trajectory_json_file proc~export_trajectory_json_file->proc~propagate_segment proc~find_rows find_rows proc~find_rows->proc~propagate_segment proc~generate_eclipse_data mission_type%generate_eclipse_data proc~generate_eclipse_data->proc~propagate_segment proc~iteration_trajectory iteration_trajectory proc~iteration_trajectory->proc~propagate_segment proc~plot_trajectory mission_type%plot_trajectory proc~plot_trajectory->proc~propagate_segment proc~row_ks row_ks proc~row_ks->proc~propagate_segment proc~eclipse_optimize eclipse_optimize proc~eclipse_optimize->proc~constraint_violations proc~eclipse_optimize->proc~find_rows proc~eval_rows eval_rows proc~eclipse_optimize->proc~eval_rows proc~newton_finish newton_finish proc~eclipse_optimize->proc~newton_finish proc~eval_rows->proc~row_ks proc~halo_export halo_export proc~halo_export->proc~iteration_trajectory proc~halo_solver_main halo_solver_main proc~halo_solver_main->proc~constraint_violations proc~halo_solver_main->proc~export_trajectory_json_file proc~halo_solver_main->proc~generate_eclipse_data proc~halo_solver_main->proc~plot_trajectory proc~write_solution_plot_data mission_type%write_solution_plot_data proc~halo_solver_main->proc~write_solution_plot_data interface~eclipse_optimize my_solver_type%eclipse_optimize proc~halo_solver_main->interface~eclipse_optimize proc~write_solution_plot_data->proc~constraint_violations interface~eclipse_optimize->proc~eclipse_optimize proc~eclipse_fc eclipse_fc proc~eclipse_fc->proc~eval_rows proc~eclipse_gjac eclipse_gjac proc~eclipse_gjac->proc~eval_rows proc~newton_finish->proc~eval_rows proc~newton_func newton_func proc~newton_finish->proc~newton_func proc~newton_func->proc~eval_rows proc~newton_grad newton_grad proc~newton_grad->proc~eval_rows

Source Code

    subroutine propagate_segment(me,mode,tstep)

    implicit none

    class(segment),intent(inout) :: me
    integer,intent(in),optional :: mode  !! 1 - don't report steps, 2 - report steps (for plotting)
    real(wp),intent(in),optional :: tstep !! fixed time step for mode=2

    integer  :: idid
    real(wp) :: t
    real(wp) :: tf
    real(wp),dimension(n_eoms_stm) :: x  !! the integration state (only the first `n_eoms` are used
                                         !! unless `stm_mode`, see [[propagate_segment_stm]])
    integer :: neq !! number of integrated variables
    type(icrf_frame) :: inertial
    type(two_body_rotating_frame) :: rotating
    real(wp) :: etf
    real(wp),dimension(6) :: xf !! inertial - from the propagation
    real(wp),dimension(6) :: xf_rotating
    logical :: status_ok
    integer :: integration_mode

    if (present(mode)) then
        integration_mode = mode
    else
        integration_mode = 1
    end if

    ! integrate in local time (from 0 at t0), see t_offset:
    me%t_offset = me%data%t0 * day2sec
    t  = zero
    tf = (me%data%tf - me%data%t0) * day2sec
    neq = merge(n_eoms_stm, n_eoms, me%stm_mode)
    x  = zero
    x(1:n_eoms) = me%data%x0   ! inertial state
    if (me%stm_mode) x(n_eoms+1:neq) = identity_stm()  ! (not integrated here: its derivatives are zero)

    !write(*,*) ''
    !write(*,*) 'propagate segment '//me%name, t0, tf
    !write(*,*) 't0:',t0
    !write(*,'(A,*(F15.3,1X))') 'x0:',x
    !write(*,*) 'tf:',tf

    ! with `always_stm`, the STM is integrated here too, so that this propagation takes
    ! exactly the steps of [[propagate_segment_stm]] (the STM changes the integrator's
    ! steps, through its error norm and its initial step), and its final state is
    ! the one the solver converged with `func_with_stm`:
    me%compute_stm = me%always_stm
    call me%first_call()  !restarting the integration
    if (present(tstep)) then
        call me%integrate(t,x(1:neq),tf,idid=idid,integration_mode=integration_mode,tstep=tstep)
    else
        call me%integrate(t,x(1:neq),tf,idid=idid,integration_mode=integration_mode)
    end if
    me%compute_stm = .false.
    me%t_offset = zero
    me%failed = .false.
    if (idid<0) then
        if (me%soft_fail) then
            me%failed = .true.
            return
        end if
        write(*,'(A,*(I5/))')    'idid: ',idid
        error stop 'error in integrator'
    end if

    xf = x(1:n_eoms)  ! final state [inertial frame]

    ! also save the rotating frame state at tf (to compute the constraint violations):
    etf = me%data%et_ref + me%data%tf * day2sec  ! convert to ephemeris time [sec]
    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)

    ! from inertial to rotating:
    call inertial%transform(xf,rotating,etf,me%eph,xf_rotating,status_ok)
    if (.not. status_ok) error stop 'transformation error in propagate_segment'

    ! put final states in the segment:
    call me%set_outputs(xf,xf_rotating)

    end subroutine propagate_segment