rkstiff.etd4
Constant-Step Fourth-Order Exponential Time-Differencing Integrator
Implements a fourth-order exponential time-differencing (ETD4) solver for stiff partial differential equations (PDEs) of the form
where \(\mathcal{L}\) is a linear spatial differential operator (e.g. Laplacian, biharmonic, etc.), and \(\mathcal{N}(\mathbf{U})\) is a nonlinear term in physical or spectral space.
The solver advances the field \(\mathbf{U}(x, t)\) in time using exponential Runge–Kutta (Krogstad, 2005) methods.
References
Krogstad, S. (2005). Generalized integrating factor methods for stiff PDEs. Journal of Computational Physics, 203(1), 72–88.
Classes
|
Fourth-order Exponential Time-Differencing solver for PDEs. |
|
ETD4 solver for diagonalized PDE systems. |
|
ETD4 solver for non-diagonal PDE operators. |
- class rkstiff.etd4.ETD4(lin_op, nl_func, etd_config=ETDConfig(), loglevel='WARNING')[source]
Bases:
ETDCSFourth-order Exponential Time-Differencing solver for PDEs.
Integrates stiff PDEs of the form
\[\frac{\partial \mathbf{U}}{\partial t} = \mathcal{L}\mathbf{U} + \mathcal{N}(\mathbf{U}),\]where - \(\mathcal{L}\) is the linear spatial operator (e.g. diffusion), - \(\mathcal{N}\) represents nonlinear stiff terms.
The solution is advanced in time using a four-stage exponential Runge-Kutta (Krogstad) scheme, with precomputed \(\psi_r\) coefficients.
- Parameters:
lin_op (np.ndarray) – Discretized linear operator \(\mathcal{L}\) in matrix or diagonal form.
nl_func (Callable[[np.ndarray], np.ndarray]) – Nonlinear functional \(\mathcal{N}[\mathbf{U}]\).
etd_config (ETDConfig, optional) – Configuration for contour integration and cutoff parameters.
Notes
This solver is designed for PDEs discretized in space, e.g. after applying a Fourier spectral or finite-difference transform.
- __init__(lin_op, nl_func, etd_config=ETDConfig(), loglevel='WARNING')[source]
Initialize the ETD4 solver.
- evolve(u, t0, tf, h, store_data=True, store_freq=1)
Integrate the system from \(t_0\) to \(t_f\) using fixed step size.
Repeatedly applies
step()with constant \(h\) until the final time is reached.- Parameters:
u (np.ndarray) – Initial solution vector at \(t_0\).
t0 (float) – Initial time.
tf (float) – Final time (integration stops when
t ≥ tf).h (float) – Constant step size \(\Delta t\).
store_data (bool, default=True) – Whether to store intermediate results in
tandu.store_freq (int, default=1) – Frequency of storing data; every
store_freqsteps.
- Returns:
Final solution vector at \(t_f\).
- Return type:
np.ndarray
- Raises:
ValueError – If
hexceeds the total time spantf - t0.
Notes
The time grid is uniformly spaced with spacing \(h\).
Stored data can be accessed through
tandu.
Example
>>> solver = ETD4(lin_op, nl_func) >>> u_final = solver.evolve(u0, t0=0.0, tf=10.0, h=0.05) >>> len(solver.t) 200
- set_loglevel(loglevel)
Adjust the solver’s logging verbosity at runtime.
- Parameters:
loglevel (str or int) – New logging level. Accepts standard string levels or numeric constants from
logging.- Return type:
Examples
>>> solver.set_loglevel("INFO") >>> solver.set_loglevel(logging.DEBUG)
- property solver_type: SolverType
Return the solver type for constant-step solvers.
- Returns:
Always returns
SolverType.CONSTANT_STEP.- Return type:
SolverType
Examples
>>> from rkstiff.if4 import IF4 >>> solver = IF4(lin_op, nl_func) >>> solver.solver_type == SolverType.CONSTANT_STEP True
- step(u, h)
Perform a single constant-step propagation.
- Parameters:
u (np.ndarray) – Current solution vector.
h (float) – Constant step size (must be non-negative).
- Returns:
Updated solution after one full time step.
- Return type:
np.ndarray
Notes
This method simply wraps
_update_stages()and performs minimal validation and logging.