row_ks Function

function row_ks(mission, seg, row, t0, tf, x0_rotating, ok) result(ks)

The KS aggregate of the shadow function at a row's samples, for the given start epoch, final epoch [days] and initial rotating-frame state (a copy of the segment is propagated, with output every eclipse_opt_sample_step seconds).

Arguments

Type IntentOptional Attributes Name
class(mission_type), intent(in) :: mission
type(segment), intent(in) :: seg
type(eclipse_row), intent(in) :: row
real(kind=wp), intent(in) :: t0
real(kind=wp), intent(in) :: tf
real(kind=wp), intent(in), dimension(6) :: x0_rotating
logical, intent(out) :: ok

false if the segment has none of the row's samples (e.g., a trial point that moved its epochs far): the row can't be evaluated there

Return Value real(kind=wp)


Calls

proc~~row_ks~~CallsGraph proc~row_ks row_ks proc~destroy_trajectory trajectory%destroy_trajectory proc~row_ks->proc~destroy_trajectory proc~get_sun_fraction get_sun_fraction proc~row_ks->proc~get_sun_fraction proc~propagate_segment segment%propagate_segment proc~row_ks->proc~propagate_segment proc~set_segment_inputs segment%set_segment_inputs proc~row_ks->proc~set_segment_inputs apparent_position apparent_position proc~get_sun_fraction->apparent_position cubic_shadow_model cubic_shadow_model proc~get_sun_fraction->cubic_shadow_model from_j2000body_to_j2000ssb from_j2000body_to_j2000ssb proc~get_sun_fraction->from_j2000body_to_j2000ssb 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 proc~set_segment_inputs->icrf_frame proc~set_segment_inputs->transform proc~set_segment_inputs->two_body_rotating_frame

Called by

proc~~row_ks~~CalledByGraph proc~row_ks row_ks proc~eval_rows eval_rows proc~eval_rows->proc~row_ks proc~eclipse_fc eclipse_fc proc~eclipse_fc->proc~eval_rows proc~eclipse_gjac eclipse_gjac proc~eclipse_gjac->proc~eval_rows proc~eclipse_optimize eclipse_optimize proc~eclipse_optimize->proc~eval_rows proc~newton_finish newton_finish proc~eclipse_optimize->proc~newton_finish 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 interface~eclipse_optimize my_solver_type%eclipse_optimize interface~eclipse_optimize->proc~eclipse_optimize proc~halo_solver_main halo_solver_main proc~halo_solver_main->interface~eclipse_optimize

Source Code

    function row_ks(mission, seg, row, t0, tf, x0_rotating, ok) result(ks)

    class(mission_type),intent(in) :: mission
    type(segment),intent(in) :: seg
    type(eclipse_row),intent(in) :: row
    real(wp),intent(in) :: t0, tf
    real(wp),dimension(6),intent(in) :: x0_rotating
    logical,intent(out) :: ok  !! false if the segment has none of the row's samples (e.g., a trial point
                               !! that moved its epochs far): the row can't be evaluated there
    real(wp) :: ks

    type(segment) :: s
    real(wp),dimension(:),allocatable :: phi
    real(wp),dimension(6) :: rv
    real(wp) :: step, rho, pmin
    integer :: i, k, n, np

    step = mission%eclipse_opt_sample_step
    rho  = mission%eclipse_opt_ks_rho
    s = seg
    call s%traj_inertial%destroy()
    call s%traj_rotating%destroy()
    call s%traj_se_rotating%destroy()
    call s%set_input(t0, tf, x0_rotating)
    call s%propagate(mode=2, tstep=step)
    if (s%failed) then
        ok = .false.
        ks = zero
        return
    end if

    ! the samples: the points at k*step from the start (the last point, at tf, is only one
    ! of them if it falls on the grid)
    n = size(s%traj_inertial%et)
    allocate(phi(row%k_hi - row%k_lo + 1))
    np = 0
    do k = row%k_lo, row%k_hi
        i = k + 1
        if (i > n) exit
        if (abs(abs(s%traj_inertial%et(i) - s%traj_inertial%et(1)) - k*step) > 1.0e-3_wp) exit
        rv = [s%traj_inertial%x(i),  s%traj_inertial%y(i),  s%traj_inertial%z(i), &
              s%traj_inertial%vx(i), s%traj_inertial%vy(i), s%traj_inertial%vz(i)]
        np = np + 1
        phi(np) = get_sun_fraction(s%eph, s%traj_inertial%et(i), rv, mission%eclipse_opt_bubble)
    end do
    ok = np > 0
    if (.not. ok) then
        ks = zero
        return
    end if
    pmin = minval(phi(1:np))
    ks = pmin - log(sum(exp(-rho*(phi(1:np) - pmin)))) / rho

    end function row_ks