implementations.problem_classes.DiscontinuousTestODE module¶
- class DiscontinuousTestODE(newton_maxiter=100, newton_tol=1e-08, stop_at_nan=True)[source]¶
Bases:
ProblemThis class implements a very simple test case of a ordinary differential equation consisting of one discrete event. The dynamics of the solution changes when the state function \(h(u) := u - 5\) changes the sign. The problem is defined by:
if \(u - 5 < 0:\)
\[\frac{d u}{dt} = u\]else:
\[\frac{d u}{dt} = \frac{4}{t^*},\]where \(t^* = \log(5) \approx 1.6094379\). For \(h(u) < 0\), i.e. \(t \leq t^*\), the exact solution is \(u(t) = \exp(t)\); for \(h(u) \geq 0\), i.e. \(t \geq t^*\), the exact solution is \(u(t) = \frac{4 t}{t^*} + 1\).
- t_switch_exact¶
Exact event time with \(t^* = \log(5)\).
- Type:
float
- t_switch¶
Time point of the discrete event found by switch estimation.
- Type:
float
- nswitches¶
Number of switches found by switch estimation.
- Type:
int
- work_counters¶
Counts different things, here: Number of Newton iterations is counted.
- Type:
- dtype_f¶
alias of
mesh
- dtype_u¶
alias of
mesh
- get_switching_info(u, t)[source]¶
Provides information about the state function of the problem. When the state function changes its sign, typically an event occurs. So the check for an event should be done in the way that the state function is checked for a sign change. If this is the case, the intermediate value theorem states a root in this step.
- Parameters:
u (dtype_u) – Current values of the numerical solution at time \(t\).
t (float) – Current time of the numerical solution.
- Returns:
switch_detected (bool) – Indicates whether a discrete event is found or not.
m_guess (int) – The index before the sign changes.
state_function (list) – Defines the values of the state function at collocation nodes where it changes the sign.
- solve_system(rhs, dt, u0, t)[source]¶
Simple Newton solver for \((I-factor\cdot A)\vec{u}=\vec{rhs}\).
- Parameters:
- Returns:
me – The solution as mesh.
- Return type:
- class ExactDiscontinuousTestODE(newton_maxiter=100, newton_tol=1e-08)[source]¶
Bases:
DiscontinuousTestODEDummy ODE problem for testing the
SwitchEstimatorclass. The problem contains the exact dynamics of the problem classDiscontinuousTestODE.