specular.ode.euler_scheme_1
euler_scheme_1(F, t_0, T, u_0, u_1, *, h)
Apply the explicit two-step specular Euler method of Type 1 to a scalar initial-value problem.
Parameters
| Name | Type | Description |
|---|---|---|
F |
callable | Field F(point) receiving the NumPy float64 vector [t, u] 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. |
u_1 |
real scalar | Finite, externally computed starting value at the first time node t[1]. |
h |
positive real scalar, keyword-only | Prescribed constant step, with 0 < h <= T - t_0. |
Returns
ODEResult: NumPy float64 arrays t and u of shape (N_h + 1,), an array sigma
of N_h ones, and the number of solver calls to F, where
N_h = floor((T - t_0)/h).
Notes
With the prescribed \(h\), \(N_h=\lfloor(T-t_0)/h\rfloor\), and \(\mathcal C=\mathcal C_1\), the recurrence is
The solver preallocates the grid t_n = t_0 + n*h and fills its solution row
in place. The final node may precede T; there is no shortened final step.
The solver keeps the supplied u_1 unchanged. For N_h=1, it returns
u_0 and u_1 without evaluating F. The all-ones sigma array describes the
unscaled-mean convention, including the externally supplied first interval;
it does not describe how the caller produced u_1.
This method is generically first-order consistent. A more accurate starter does not give an unconditional higher-order theorem. See Type 1. Angular means use the selected backend; the outer iteration remains scalar and the stored arrays use float64.
Examples
import specular.ode
import numpy as np
def F(point):
return -point[1]
t_0, T, u_0 = 0.0, 1.0, 1.0
h = 0.01
u_1 = u_0 + h * F(np.array([t_0, u_0]))
result = specular.ode.euler_scheme_1(
F, t_0, T, u_0, u_1, h=h,
)
print(result.u[-1])
Source code in specular/ode/solver.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |