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
| Name | Type | Attributes | Description |
|---|---|---|---|
n | integer(kind=I4P) | Events. | |
direction | integer(kind=I4P) | allocatable | +1: rising only, -1: falling only, 0: both. |
terminal | logical | allocatable | The event ends the step. |
tol | real(kind=R_P) | The bracket's width at which a zero is located (in theta). | |
g_left | real(kind=R_P) | allocatable | The events' values at the bracket's ends. |
g_right | real(kind=R_P) | allocatable | The events' values at the bracket's ends. |
g_last | real(kind=R_P) | allocatable | The values at the end of the step (step's right end). |
theta_left | real(kind=R_P) | Bracket, as fractions of the step. | |
theta_right | real(kind=R_P) | Bracket's right end. | |
theta_trial | real(kind=R_P) | The trial point handed out. | |
t_start | real(kind=R_P) | The step's start. | |
dt | real(kind=R_P) | The step. | |
side | integer(kind=I4P) | The end kept by the last two updates (Illinois): -1, +1, 0. | |
found | integer(kind=I4P) | The event located (0 while none). | |
evaluations | integer(kind=I4P) | Trial points handed out for the current event. | |
searching | logical | A bracket is open. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
initialize | pass(self) | Choose the events. |
start | pass(self) | The events' values at the start of the run (or after a restart). |
step | pass(self) | The values at the end of a step: look for a zero. |
locating | pass(self) | A bracket is open: evaluate the events at next_theta. |
next_theta | pass(self) | The trial point. |
update | pass(self) | The events' values at the trial point. |
event | pass(self) | The event located (0 if none). |
event_theta | pass(self) | Its fraction of the step. |
event_time | pass(self) | Its time. |
is_terminal | pass(self) | It ends the step. |
resume | pass(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).
subroutine initialize(self, n, direction, terminal, tol)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | inout | Locator. | |
n | integer(kind=I4P) | in | Events. | |
direction | integer(kind=I4P) | in | optional | Directions. |
terminal | logical | in | optional | Terminal events. |
tol | real(kind=R_P) | in | optional | Tolerance (fraction of the step). |
event_locator%start
The events' values at the start of the run, or at a restart (after a terminal event).
subroutine start(self, g0)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | inout | Locator. | |
g0 | real(kind=R_P) | in | Values. |
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.
subroutine step(self, t_start, dt, g_end)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | inout | Locator. | |
t_start | real(kind=R_P) | in | The step's start. | |
dt | real(kind=R_P) | in | The step. | |
g_end | real(kind=R_P) | in | Values 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
function locating(self) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | in | Locator. |
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)
function next_theta(self) result(theta)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | inout | Locator. |
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).
subroutine update(self, g)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | inout | Locator. | |
g | real(kind=R_P) | in | Values at the trial point. |
Call graph
event_locator%event
The event located, 0 if none.
Attributes: pure
Returns: integer(kind=I4P)
function event(self) result(i)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | in | Locator. |
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)
function event_theta(self) result(theta)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | in | Locator. |
event_locator%event_time
The located event's time.
Attributes: pure
Returns: real(kind=R_P)
function event_time(self) result(t)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | in | Locator. |
event_locator%is_terminal
The located event ends the step.
Attributes: pure
Returns: logical
function is_terminal(self) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | in | Locator. |
event_locator%resume
After a non-terminal event: the rest of the step, [event, end], is searched for the next zero (locating() tells).
subroutine resume(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(event_locator) | inout | Locator. |
Call graph