Solver workflow
Typical call sequence
Section titled “Typical call sequence”Most DESolve runs follow the same shape:
- Construct
DESolver(). - Set the function context, including the numerical dtype.
- Call
setup()to register methods and initialize solver state. - Provide the right-hand side function.
- Set the initial solution, time interval, time step, and method.
- Call
solve(). - Read the trajectory or final state.
Core ideas
Section titled “Core ideas”Function signatures stay explicit
Section titled “Function signatures stay explicit”DESolve expects right-hand sides in the form:
(t, u, ctx) -> (f, jac)That keeps numerical data flow visible:
tis the current timeuis the state vectorctxholds user-supplied context such as dtype or coefficientsjacmay beNonewhen you do not have a Jacobian
Methods are table-driven
Section titled “Methods are table-driven”The solver registers built-in methods during setup(). Those method tables live
in the desolve/methods_*.py modules and are selected later with
set_method("...").
History is optional but useful
Section titled “History is optional but useful”Use setup(keep_history=True) when you want trajectories for diagnostics,
plotting, or convergence studies. If you only care about the terminal state,
you can turn history off to reduce storage.
Practical advice
Section titled “Practical advice”- Prefer
set_initial_solution(...)oversolve(u_ini=...)for NumPy arrays. - Keep Jacobians consistent with the dtype stored in
ctx. - Start with simple methods like
RK4before switching to implicit or split formulations. - When experimenting with new schemes, add the method table first and then wire
it into
DESolver._RegisterDefaultMethods().