Event function: when the altitude drops below the deadband.
Moon is assumed to be a sphere.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| 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 |
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