event_func Subroutine

private subroutine event_func(me, t, x, g)

Event function: when the altitude drops below the deadband.

Arguments

TypeIntentOptionalAttributesName
class(ddeabm_with_event_class), intent(inout) :: me
real(kind=wp), intent(in) :: t

time

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

state -- moon centered inertial frame

real(kind=wp), intent(out) :: g

event function


Calls

proc~~event_func~~CallsGraph proc~event_func event_func proc~rdot rdot proc~event_func->proc~rdot

Contents

Source Code


Source Code

    subroutine event_func(me,t,x,g)

    implicit none

    class(ddeabm_with_event_class),intent(inout) :: me
    real(wp),intent(in)              :: t  !! time
    real(wp),dimension(:),intent(in) :: x  !! state -- moon centered inertial frame
    real(wp),intent(out)             :: g  !! event function

    real(wp) :: alt  !! altitude (km)

    select type (me)
    class is (segment)

        select case (me%event)
        case (1)

            ! g is offset from deadband altitude
            alt = norm2(x(1:3)) - me%r_moon
            g = alt - (me%nominal_altitude - me%deadband)

        case (2)

            ! g is rdot, which is zero and periapsis
            ! and apoapsis of an ellipse:
            g = rdot(x(1:6))

            ! TODO: figure out how to get it to ignore periapsis roots
            ! [maybe need to update DDEABM so we have more control
            ! over which roots it stops at]

        case default
            error stop 'invalid event value in event_func'
        end select

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

    end subroutine event_func