Time dependence
Model.solve_transient integrates the population equations from initial densities with a stiff integrator (BDF by default) and the model’s sparse Jacobian. The prescribed states of the conditions stay prescribed; the rest evolve. The physics is in The CR model, the options in Solvers and troubleshooting.
import numpy as npimport plasma_plots
import opencr
plasma_plots.set_backend("plotly") # interactive figures, embedded in the docsplasma_plots.set_math("latex") # formulas in the figures typeset as LaTeX
model = opencr.load_model("hydrogen/atomic/basic", n_max=12)Ionization of a neutral gas
Section titled “Ionization of a neutral gas”A closed system (no prescribed states, the total atom density given) that starts as cold neutral gas in a plasma of given and :
conditions = opencr.Conditions(3.0, 1e18, totals={"H": 1e19})times = np.geomspace(1e-9, 1e-1, 90)history = model.solve_transient(conditions, {"H(n=1)": 1e19}, times)print(history.report.summary())transient solve by BDF: reached the final time with 510 evaluations, 1 Jacobians and 49 factorisations min/max density 0.00e+00 conservation drift 1.64e-15 (H)The excited states fill within nanoseconds (the quasi-static assumption); the ionization takes tens of milliseconds at this density and temperature:
data = history.to_dataset()with plasma_plots.figure(title="Populations against time") as fig: for state in ("H(n=1)", "H(n=2)", "H(n=3)", "H+"): data["population"].sel(state=state).plasma.plot.lineout( ax=fig[0], title="", xlabel="$t$ [s]", label=state ) fig[0].set_xscale("log") fig[0].set_yscale("log") fig[0].set_ylim(1e8, 2e19) fig[0].set_ylabel("$n$ [m$^{-3}$]") fig[0].legend()The end of the transient is the closed steady state of the same conditions, and any output time can be read like a steady-state result (history.at(index)), with the residual saying how far from steady state it is:
steady = model.solve_steady_state(conditions, mode="full")final = history.at(-1)for state in ("H(n=1)", "H(n=2)", "H+"): print( f"{state:7s} transient {final.population(state):.4e} steady {steady.population(state):.4e}" )print(f"relative residual at the last time: {final.report.residual:.1e}")print(final.dominant_processes("H(n=2)", 3))H(n=1) transient 1.1081e+16 steady 1.1081e+16H(n=2) transient 2.1644e+10 steady 2.1643e+10H+ transient 9.9889e+18 steady 9.9889e+18relative residual at the last time: 5.3e-06[{'name': 'A:2-1', 'equation': 'H(n=2) -> H(n=1) + hv', 'rate': -1.0163565124531177e+19, 'fraction': 0.998927598782816}, {'name': 'exc:1-2', 'equation': 'e + H(n=1) -> e + H(n=2)', 'rate': 8.413334239328425e+18, 'fraction': 0.8269058806231332}, {'name': 'A:3-2', 'equation': 'H(n=3) -> H(n=2) + hv', 'rate': 1.0303578215915525e+18, 'fraction': 0.10126888075328688}]Time-dependent conditions
Section titled “Time-dependent conditions”With conditions a function of time, the rate coefficients follow it. Here the drivers H(n=1) and H⁺ are prescribed, the electron temperature rises from 1 to 10 eV over 1 µs, and the H-α emission follows the n=3 population:
base = opencr.Conditions(1.0, 1e18, densities={"H(n=1)": 1e19, "H+": 1e18})
def ramp(t: float) -> opencr.Conditions: return base.replace(electron_temperature=1.0 + 9.0 * min(t / 1e-6, 1.0))
times = np.geomspace(1e-9, 1e-5, 60)heating = model.solve_transient(ramp, {}, times)h_alpha = np.array( [ heating.at(i).emission()["emissivity"].sel(line="A:3-2").item() for i in range(times.size) ])with plasma_plots.figure(title="H-α during a temperature ramp") as fig: fig[0].loglog(times, h_alpha) fig[0].set_xlabel("$t$ [s]") fig[0].set_ylabel("H-α emissivity [photons m$^{-3}$ s$^{-1}$]")