Solvers and troubleshooting
How a steady state is found
Section titled “How a steady state is found”- Linear systems (each reaction has at most one evolving reactant and is given, the case of every quasi-static hydrogen solve) are solved directly with a sparse LU factorisation and one step of iterative refinement.
- Closed systems: for each element the evolving states conserve, one equation is replaced
by the element’s total from
Conditions.totals. - Quasi-neutral systems that are linear for a given (atomic hydrogen with
electron_density=None) solve quasi-neutrality as a one-dimensional root: for each trial a sparse linear solve gives the populations and their charge, and Brent’s method finds the that equals it, in . A root exists between a vanishing and the largest possible charge, so this does not depend on a starting point. - Other nonlinear systems (reactions between two evolving states, or a given
initial) start with pseudo-transient continuation — implicit-Euler steps whose time step grows as the residual falls — which follows the physical relaxation and keeps the totals, and end in Newton’s method. Densities are kept non-negative by damping the steps. Passinitial={...}to start elsewhere.
Rates are evaluated exactly for Maxwellian electrons: plasmacoll’s cross sections are linear
between their table points, so the Maxwellian average is a sum of closed-form integrals. Any
other energy distribution (Conditions.from_eedf) is integrated on its own energy grid.
Time dependence
Section titled “Time dependence”Model.solve_transient integrates the population equations with scipy.integrate.solve_ivp
and the sparse analytic Jacobian: method="BDF" (default), "Radau" or "LSODA"; explicit
methods are refused because the problem is stiff. rtol (default ) and atol
(default of the largest initial density) are the integrator’s tolerances. The
output times set the resolution of the result, not the steps. With conditions a function of
time, the rate coefficients are re-evaluated whenever the integrator asks for a new time, which
costs one rate evaluation per step; the prescribed states must be the same at every time. A
transient that should end in a steady state can be checked against solve_steady_state, and
history.at(-1).report.residual says how far it still is from one.
The report
Section titled “The report”Every result has result.report (SolverReport): the method, iterations, the relative
residual (the largest net rate of a state divided by its gross gain-plus-loss rate), the
relative error of every conserved total, the smallest density relative to the largest, and any
round-off negatives set to zero. report.summary() prints it.
When a solve fails
Section titled “When a solve fails”| Error | Meaning | What to do |
|---|---|---|
UnderdeterminedError | the evolving states conserve an element without a total | give Conditions.totals, or prescribe a state’s density |
MissingDensityError | a prescribed state has no density | add it to Conditions.densities |
ValueError: ... needs the densities of the drivers | quasi-static solve without the drivers | give them, or use mode="full" |
SingularSystemError: ... no loss process | a state can only be filled | prescribe it, or add its losses |
SingularSystemError: ... singular | a group of states has no path out | check the network for missing reactions |
ConvergenceError | a nonlinear solve did not reach the tolerance | start from initial=, raise rtol, or check that a positive steady state exists (a source with no loss diverges) |
ConvergenceError: ... escape factors | the radiation-trapping iteration did not settle | raise tolerance or max_iterations in RadiationTrapping |
RuntimeError: the transient solve failed | the integrator stopped (its message is in the report) | loosen or tighten the tolerances, shorten the time span, try "Radau" |