Skip to content
Projects

Steady states

The equations of opencr.solvers.steady, declared on the code that implements them and checked by the tests.

constraint_rows

functionsource

Return the rows to replace, the constraint matrix and the totals.

constraint
Rie(n) → ∑icei ni−Ne=0,ie=arg⁡max⁡icei (first unused, stable order)R_{i_e}(\mathbf n) \ \to\ \sum_i c_{ei}\, n_i - N_e = 0, \qquad i_e = \arg\max_i c_{ei} \ \text{(first unused, stable order)}
Assumes
  • one row per conserved element replaced by its total NeN_e from Conditions.totals; a missing total raises UnderdeterminedError
  • for atomic hydrogen in full mode every state holds one H, so the H(n=1) row is replaced
Built from

solve_steady

functionsource

Return the steady densities of the evolving states and the report.

linear
J(0) n=−R(0)by sparse LU, one step of iterative refinementJ(\mathbf 0)\,\mathbf n = -R(\mathbf 0) \quad \text{by sparse LU, one step of iterative refinement}
quasi neutral
ln⁡∑jzjnj(ne)−ln⁡ne=0by Brent’s method in ln⁡ne, each evaluation a linear solve\ln\sum_j z_j n_j(n_e) - \ln n_e = 0 \quad \text{by Brent's method in } \ln n_e, \ \text{each evaluation a linear solve}
continuation
(FΔt−J) δn=R(n),Fi={1free row0constraint row,Δt0=1max⁡(max⁡i∣Jii∣,1)\Big(\frac{F}{\Delta t} - J\Big)\,\delta\mathbf n = R(\mathbf n), \qquad F_i = \begin{cases} 1 & \text{free row} \\ 0 & \text{constraint row} \end{cases}, \qquad \Delta t_0 = \frac{1}{\max(\max_i |J_{ii}|, 1)}
damping
f=min⁡i: ni+δni<00.9 ni−δni (≥10−6),n←max⁡(n+f δn,0)f = \min_{i:\, n_i + \delta n_i < 0} \frac{0.9\, n_i}{-\delta n_i} \ (\ge 10^{-6}), \qquad \mathbf n \leftarrow \max(\mathbf n + f\,\delta\mathbf n, 0)
relaxation
Δt←Δt clip ⁣(2∥R∥∗,old∥R∥∗,new, 0.5, 103),∥R∥∗=∥R∥2∑i∣ni∣\Delta t \leftarrow \Delta t\ \mathrm{clip}\!\left(\frac{2\|R\|_{*,\mathrm{old}}}{\|R\|_{*,\mathrm{new}}},\ 0.5,\ 10^3\right), \qquad \|R\|_* = \frac{\|R\|_2}{\sum_i |n_i|}
Assumes
  • linear systems (one evolving reactant, given nen_e): one LU solve; a zero diagonal (a state without losses) raises SingularSystemError
  • quasi-neutral and linear for given nen_e, without a start: the bracket [10−30,10] s[10^{-30}, 10]\,s (ss the total charge scale) widened by ×100\times 100 up to 20 times; a negative excess at the lower end raises
  • otherwise pseudo-transient continuation with switched evolution relaxation (no separate Newton phase); a step that raises ∥R∥∗\|R\|_* tenfold undamped is rejected with Δt←Δt/4\Delta t \leftarrow \Delta t/4, a non-finite one with Δt←Δt/10\Delta t \leftarrow \Delta t/10
  • the default start puts each total in the lowest-energy neutral holder (10% in the lowest ion when quasi-neutral), plus 10−12max⁡(N,1)10^{-12}\max(N, 1) in every state
  • negatives within 10−810^{-8} of the largest density are zeroed; only the relative residual decides failure, above max⁡(rtol,10−6)\max(\mathrm{rtol}, 10^{-6})
References
Built from