Atomic hydrogen
This tutorial solves the hydrogen/atomic/basic model: the populations of H(n) in a plasma of given electron temperature and density, the processes that set them, and the effective (collisional-radiative) ionization and recombination coefficients. The physics behind the solve is in The CR model.
import numpy as npimport plasma_plotsimport xarray as xr
import opencr
plasma_plots.set_backend("plotly") # interactive figures, embedded in the docsplasma_plots.set_math("latex") # formulas in the figures typeset as LaTeX'unicode'The model
Section titled “The model”load_model builds the network; its manifest lists the states, reactions, sources and assumptions.
model = opencr.load_model("hydrogen/atomic/basic", n_max=20)manifest = model.manifest()print(model)print(manifest["counts"]["by_kind"])for assumption in manifest["assumptions"][:3]: print("-", assumption)Model('hydrogen/atomic/basic', 21 states, 630 reactions){'excitation': 190, 'deexcitation': 190, 'spontaneous_emission': 190, 'ionization': 20, 'three_body_recombination': 20, 'radiative_recombination': 20}- States resolved in the principal quantum number n only; the l sub-states are statistically populated (fast l-mixing), which overestimates the 2s population at low density.- Levels above n_max are omitted (no continuum lowering, no extrapolation to n -> infinity); effective recombination at low density depends on n_max.- Electron collisions only: heavy-particle (proton, atom) excitation, ionization and l-mixing of the excited states are omitted.A quasi-static solve
Section titled “A quasi-static solve”The ground state and the proton are the drivers: their densities are inputs. The excited states are in steady state for them.
conditions = opencr.Conditions( electron_temperature=3.0, # eV electron_density=1e19, # m^-3 densities={"H(n=1)": 1e19, "H+": 1e18},)result = model.solve_steady_state(conditions)print(result.report.summary())quasi-static solve by sparse LU: converged in 1 iterations relative residual 1.26e-16, min/max density 1.12e-02The populations divided by their statistical weights, against the level energy. A Boltzmann distribution at would be a straight line of slope ; the low levels fall below it (radiative losses), the high ones approach Saha equilibrium with the ions.
energies = [s.energy for s in model.network.states[:-1]]reduced = xr.DataArray( [result.populations[s.name] / s.weight for s in model.network.states[:-1]], coords={ "energy": ("energy", energies, {"units": "eV", "long_name": "level energy"}) }, dims="energy", name="n/g", attrs={"units": "m^-3"},)with plasma_plots.figure(title="H(n) populations over the statistical weights") as fig: reduced.plasma.plot.lineout(ax=fig[0], title="", xlabel="level energy [eV]") fig[0].set_yscale("log") fig[0].set_ylabel("$n/g_n$ [m$^{-3}$]")Which processes matter
Section titled “Which processes matter”The largest gains and losses of H(n=3):
for entry in result.dominant_processes("H(n=3)", 6): print( f"{entry['equation']:28s} {entry['rate']:+.3e} m^-3/s ({entry['fraction']:.0%})" )e + H(n=1) -> e + H(n=3) +1.633e+22 m^-3/s (86%)H(n=3) -> H(n=1) + hv -7.328e+21 m^-3/s (39%)H(n=3) -> H(n=2) + hv -5.797e+21 m^-3/s (31%)e + H(n=3) -> e + H(n=4) -3.647e+21 m^-3/s (19%)e + H(n=4) -> e + H(n=3) +1.275e+21 m^-3/s (7%)e + H(n=3) -> e + e + H+ -6.447e+20 m^-3/s (3%)Effective coefficients
Section titled “Effective coefficients”Eliminating the excited states leaves effective rates between the drivers: from H(n=1) to H⁺ and back. scan computes them on a grid. At high density, stepwise ionization through excited states raises above the ground-state rate, and three-body recombination raises .
temperatures = np.geomspace(1.0, 100.0, 25)data = opencr.scan( model, conditions, lines=False, electron_temperature=temperatures, electron_density=[1e17, 1e19, 1e21],)s_cr = data["effective_rate"].sel(target="H+", source="H(n=1)")alpha_cr = data["effective_rate"].sel(target="H(n=1)", source="H+")ground = xr.DataArray( [ model.rate_coefficients(conditions.replace(electron_temperature=t))["ion:1"] for t in temperatures ], coords={"electron_temperature": temperatures}, dims="electron_temperature",)def density_label(density: float, name: str = "n_e") -> str: """A density as a legend entry, with its power of ten typeset.""" return f"${name} = 10^{{{np.log10(density):.0f}}}$ m$^{{-3}}$"
def coefficient_figure(coefficient, title, ground=None): """One coefficient against the temperature, a curve per electron density.""" with plasma_plots.figure(title=title) as fig: for ne in data["electron_density"].values: coefficient.sel(electron_density=ne).plasma.plot.lineout( ax=fig[0], title="", xlabel="$T_e$ [eV]", label=density_label(ne) ) if ground is not None: fig[0].plot(temperatures, ground, "k--", label="ground state only") fig[0].set_xscale("log") fig[0].set_yscale("log") fig[0].set_ylabel("rate coefficient [m$^3$/s]") fig[0].legend()
coefficient_figure(s_cr, r"Effective ionization $S_\mathrm{CR}$", ground)coefficient_figure(alpha_cr, r"Effective recombination $\alpha_\mathrm{CR}$")