specular.ode.ellipse_scheme
ellipse_scheme(F, t_0, T, u_0, *, h, sigma_n=None, third_order=False, fourth_order=False, auto=False, domain=None, admissible=None, derivatives_of_F=None, derivative_step=None, atol=1e-12, rtol=0.0, max_iter=100)
Solve a scalar initial-value problem on [t_0, T] with the implicit specular
ellipse method.
Parameters
| Name | Type and default | Description |
|---|---|---|
F |
callable | Field F(point) receiving a NumPy float64 vector point = [t, u] of shape (2,) and returning a finite real scalar. |
t_0 |
real scalar | Finite initial time. |
T |
real scalar | Finite final time, strictly greater than t_0. |
u_0 |
real scalar | Finite initial value at t_0. |
h |
positive real scalar, keyword-only | Prescribed constant step, with 0 < h <= T - t_0. The number of steps is N_h = floor((T - t_0)/h). |
sigma_n |
positive real scalar or callable, default None |
Required in the base mode. A callable sigma_n(n, t_n, u_n, h) returns a finite positive scale and is evaluated once at the accepted left endpoint. Its fourth argument is the prescribed constant h. Must be None in an automatic mode. |
third_order |
bool, default False |
Use the SE3 scale when 0 < beta_n*a_n < 3*p_n, and 1.0 otherwise; freeze it during each step. |
fourth_order |
bool, default False |
Use the SE4 scale only when both endpoint conditions and A*C < 0 hold; use 1.0 otherwise. |
auto |
bool, default False |
Prefer SE4, then the left-endpoint SE3 scale, then 1.0, reevaluating the checks at every trial value. |
derivatives_of_F |
callable or None, default None |
In an automatic mode, optionally map the NumPy array [t, u] to [D_F F, D_F^2 F], also of shape (2,). Omit to estimate these derivatives numerically. |
derivative_step |
positive real scalar or None, default None |
Finite-difference step for automatic modes. Cannot be combined with derivatives_of_F. |
atol |
real scalar, default 1e-12 |
Finite positive absolute tolerance zeta; accept only when abs(v_next - v) < atol. |
rtol |
real scalar, default 0.0 |
Compatibility parameter; must be zero because the algorithm uses an absolute tolerance. |
max_iter |
positive integer, default 100 |
Maximum number of fixed-point updates per step; failure raises RuntimeError. |
domain |
callable or None, default None |
Boolean predicate domain(t, u) for the field domain, checked before every field evaluation. |
admissible |
callable or None, default None |
Boolean predicate admissible(t_next, v) for trial states, checked before and after each update. |
All parameters after u_0 are keyword-only. The three automatic-mode flags are
mutually exclusive. Derivative controls are valid only in an automatic mode.
Here \(D_F=\partial_t+F\partial_u\) denotes differentiation along solution curves.
Returns
ODEResult: NumPy float64 arrays t and u of shape (N_h + 1,), a scale array
sigma of shape (N_h,), and the number of solver calls to F.
The arrays t and u are views of separate rows of one preallocated grid.
The nodes are t_0 + n*h; the final node may precede T because no shortened
last step is added.
Notes
For a prescribed scale, the update is
The scale is frozen during each implicit solve. Angular means use the selected calculation backend; the outer iteration uses Python floats and NumPy float64 arrays. See Prescribed scale.
The fixed-point iteration starts from the Euler predictor and returns the
updated trial value when the strict absolute stopping condition holds.
There is no bracket search or alternative predictor. Local convergence is
conditional. A failed solve raises RuntimeError; a smaller time step may
help. Exceptions from F are preserved.
See Nonlinear solve controls.
The order flags do not guarantee their named order for arbitrary fields.
Third-order convergence requires a sufficiently smooth, bounded selected branch
and accurate derivatives. The fourth-order theorem additionally requires the
stated solution-tube hypotheses, including elliptic malleability and
nondegeneracy; steps using a fallback scale do not inherit that guarantee.
The auto option permits an SE3 fallback and does not provide an unconditional
fourth-order guarantee. See Automatic scale-selection modes.
Numerical derivative estimation may sample F outside [t_0, T]; the field must
be defined on a neighborhood of the interval, or exact derivatives must be
supplied. Rapid variation can require an explicit derivative_step or an
accurate derivative callback. All recorded scales are finite and positive.
Examples
import specular.ode
result = specular.ode.ellipse_scheme(
lambda point: -point[1],
0.0,
1.0,
1.0,
h=0.01,
sigma_n=1.0,
)
print(result.t[-1], result.u[-1])
Source code in specular/ode/solver.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |