Skip to content
Projects

Solvers and troubleshooting

  • Linear systems (each reaction has at most one evolving reactant and nen_e 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 nen_e (atomic hydrogen with electron_density=None) solve quasi-neutrality as a one-dimensional root: for each trial nen_e a sparse linear solve gives the populations and their charge, and Brent’s method finds the nen_e that equals it, in log⁡ne\log n_e. A root exists between a vanishing nen_e 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. Pass initial={...} 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.

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 10−610^{-6}) and atol (default 10−1210^{-12} 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.

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.

ErrorMeaningWhat to do
UnderdeterminedErrorthe evolving states conserve an element without a totalgive Conditions.totals, or prescribe a state’s density
MissingDensityErrora prescribed state has no densityadd it to Conditions.densities
ValueError: ... needs the densities of the driversquasi-static solve without the driversgive them, or use mode="full"
SingularSystemError: ... no loss processa state can only be filledprescribe it, or add its losses
SingularSystemError: ... singulara group of states has no path outcheck the network for missing reactions
ConvergenceErrora nonlinear solve did not reach the tolerancestart from initial=, raise rtol, or check that a positive steady state exists (a source with no loss diverges)
ConvergenceError: ... escape factorsthe radiation-trapping iteration did not settleraise tolerance or max_iterations in RadiationTrapping
RuntimeError: the transient solve failedthe integrator stopped (its message is in the report)loosen or tighten the tolerances, shorten the time span, try "Radau"