Skip to content

selah_events ​

SELAH, L0: event location, a host object the caller drives between its steps.

An event is a zero of a scalar function g_i(t, q) of the caller's (a reduction over its boxes and ranks): an impact, a threshold crossed, a time of output defined by the solution. The caller evaluates every g_i at the end of each step and gives them to step; when one changes sign there (in the event's direction), the locator brackets the earliest zero over all the events and hands the caller the next trial point, a fraction theta of the step, at which the caller evaluates the g_i on the step's dense output (stepper%dense_output or hermite_output) and gives them to update, until the bracket is shorter than the tolerance. Then event() names the event, event_time() its time; a terminal event ends the step there (the caller restarts from it), a non-terminal one lets step look for the next zero in the rest of the step.

The trial points: the Illinois variant of the false position (Dowell & Jarratt 1971) on the event whose secant crosses zero earliest, the endpoint kept twice in a row has its value halved, as Shampine, Gladwell & Brankin (1991) locate events in RKSUITE's companion codes; when no event of the bracket changes sign at the trial, it is the new left end, otherwise the new right end; a trial point within tol of an end is moved tol inside it, so the zero ends bracketed within tol (a few trial points at 1e-10). The locator holds no field and does no reduction: the stepper's reverse-communication contract (decision D1 of #11).

Source: src/lib/selah_events.F90

Dependencies

Contents ​

Derived Types ​

event_locator ​

Locates the zeros of the caller's event functions inside a step.

Components

NameTypeAttributesDescription
ninteger(kind=I4P)Events.
directioninteger(kind=I4P)allocatable+1: rising only, -1: falling only, 0: both.
terminallogicalallocatableThe event ends the step.
tolreal(kind=R_P)The bracket's width at which a zero is located (in theta).
g_leftreal(kind=R_P)allocatableThe events' values at the bracket's ends.
g_rightreal(kind=R_P)allocatableThe events' values at the bracket's ends.
g_lastreal(kind=R_P)allocatableThe values at the end of the step (step's right end).
theta_leftreal(kind=R_P)Bracket, as fractions of the step.
theta_rightreal(kind=R_P)Bracket's right end.
theta_trialreal(kind=R_P)The trial point handed out.
t_startreal(kind=R_P)The step's start.
dtreal(kind=R_P)The step.
sideinteger(kind=I4P)The end kept by the last two updates (Illinois): -1, +1, 0.
foundinteger(kind=I4P)The event located (0 while none).
evaluationsinteger(kind=I4P)Trial points handed out for the current event.
searchinglogicalA bracket is open.

Type-Bound Procedures

NameAttributesDescription
initializepass(self)Choose the events.
startpass(self)The events' values at the start of the run (or after a restart).
steppass(self)The values at the end of a step: look for a zero.
locatingpass(self)A bracket is open: evaluate the events at next_theta.
next_thetapass(self)The trial point.
updatepass(self)The events' values at the trial point.
eventpass(self)The event located (0 if none).
event_thetapass(self)Its fraction of the step.
event_timepass(self)Its time.
is_terminalpass(self)It ends the step.
resumepass(self)After a non-terminal event: look for the next zero in the rest of the step.

event_locator%initialize ​

n events, each of a direction (+1, -1, 0; default 0) and terminal or not (default not); tol the width, as a fraction of the step, at which a zero is located (default 1e-10).

fortran
subroutine initialize(self, n, direction, terminal, tol)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inoutLocator.
ninteger(kind=I4P)inEvents.
directioninteger(kind=I4P)inoptionalDirections.
terminallogicalinoptionalTerminal events.
tolreal(kind=R_P)inoptionalTolerance (fraction of the step).

event_locator%start ​

The events' values at the start of the run, or at a restart (after a terminal event).

fortran
subroutine start(self, g0)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inoutLocator.
g0real(kind=R_P)inValues.

event_locator%step ​

The values at the end of the step [t_start, t_start + dt]: a bracket opens when an event changes sign in its direction (then locating()); otherwise the end's values become the next step's start.

fortran
subroutine step(self, t_start, dt, g_end)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inoutLocator.
t_startreal(kind=R_P)inThe step's start.
dtreal(kind=R_P)inThe step.
g_endreal(kind=R_P)inValues at its end.

Call graph

event_locator%locating ​

A bracket is open: evaluate the events at next_theta() and call update.

Attributes: pure

Returns: logical

fortran
function locating(self) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inLocator.

event_locator%next_theta ​

The trial point: Illinois's false position on the event whose secant crosses zero earliest, kept strictly inside the bracket (a bisection when the secant falls outside its middle 98 %).

Returns: real(kind=R_P)

fortran
function next_theta(self) result(theta)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inoutLocator.

Call graph

event_locator%update ​

The events' values at the trial point: the bracket shrinks to its side holding the earliest change of sign; when its width is below tol, the earliest event changing sign in it is located (at its right end).

fortran
subroutine update(self, g)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inoutLocator.
greal(kind=R_P)inValues at the trial point.

Call graph

event_locator%event ​

The event located, 0 if none.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function event(self) result(i)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inLocator.

event_locator%event_theta ​

The located event's fraction of the step (the right end of the last bracket, at most tol past the zero).

Attributes: pure

Returns: real(kind=R_P)

fortran
function event_theta(self) result(theta)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inLocator.

event_locator%event_time ​

The located event's time.

Attributes: pure

Returns: real(kind=R_P)

fortran
function event_time(self) result(t)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inLocator.

event_locator%is_terminal ​

The located event ends the step.

Attributes: pure

Returns: logical

fortran
function is_terminal(self) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inLocator.

event_locator%resume ​

After a non-terminal event: the rest of the step, [event, end], is searched for the next zero (locating() tells).

fortran
subroutine resume(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(event_locator)inoutLocator.

Call graph