Skip to content
Projects

opencr.tables

Effective-rate tables for the codes that use OpenCR’s results.

effective_rate_table solves a model on a grid of electron temperature and density and stores named quantities (opencr.analysis.quantities: effective rates, population and electron cooling coefficients, line emissivities) as an xarray dataset with the model’s provenance; EffectiveRateTable interpolates such a table, bilinearly in ln q against ln T_e and ln n_e (end values outside), and writes and reads it as netCDF. carafe, beamtracer and freeofcharge take their effective rates from these tables in place of fits.

Classes

NameDescription
EffectiveRateTableA table of quantities against T_e and n_e, interpolated in log space.

Functions

NameDescription
effective_rate_tableSolve model on a grid of T_e (eV) and n_e (m^-3) and tabulate outputs.

EffectiveRateTableclass#

class EffectiveRateTable(dataset: xr.Dataset)

A table of quantities against T_e and n_e, interpolated in log space.

Parameters

NameTypeDescription
datasetxr.DatasetA dataset as effective_rate_table makes it.

Numerics

bilinear

ln⁡q(x,y)=(1−u)(1−w) ln⁡qij+u(1−w) ln⁡qi+1,j+(1−u)w ln⁡qi,j+1+uw ln⁡qi+1,j+1\ln q(x, y) = (1-u)(1-w)\, \ln q_{ij} + u(1-w)\, \ln q_{i+1,j} + (1-u)w\, \ln q_{i,j+1} + uw\, \ln q_{i+1,j+1}

coordinates

x=ln⁡Te,y=ln⁡ne,u=x−xixi+1−xi,w=y−yjyj+1−yjx = \ln T_e, \quad y = \ln n_e, \qquad u = \frac{x - x_i}{x_{i+1} - x_i}, \quad w = \frac{y - y_j}{y_{j+1} - y_j}

Order of accuracy: 2.

Assumptions:

  • end values outside the table (xx and yy clipped)
  • a quantity with zero or negative values (an effective loss rate, a cooling with recombination) is interpolated in qq instead of ln⁡q\ln q
  • the order is in the table spacing in ln⁡Te\ln T_e and ln⁡ne\ln n_e

datasetattributeinstance attribute#

dataset = dataset

quantitiesproperty#

quantities: tuple[str, ...]

The tabulated quantities.

from_netcdfmethodclassmethod#

def from_netcdf(path: str | Path) -> EffectiveRateTable

Read a table written by to_netcdf.

functionmethod#

def function(name: str, electron_density: float)

Return T_e -> quantity at a fixed n_e, for codes whose rates depend on T_e only.

to_netcdfmethod#

def to_netcdf(path: str | Path) -> Path

Write the table to path (netCDF) and return the path.

effective_rate_tablefunction#

def effective_rate_table(model: Model, conditions: Conditions, outputs: Sequence[str], temperatures: Sequence[float] = tuple(np.geomspace(0.5, 100.0, 25)), densities: Sequence[float] = tuple(np.geomspace(1e+16, 1e+21, 11)), mode: str = 'quasi-static') -> EffectiveRateTable

Solve model on a grid of T_e (eV) and n_e (m^-3) and tabulate outputs.

Parameters

NameTypeDefaultDescription
modelModelrequiredThe model.
conditionsConditionsrequiredThe conditions with the driver densities (the quasi-static quantities per driver do not depend on them for a linear network).
outputsSequence[str]requiredThe quantities.
temperaturesSequence[float]tuple(np.geomspace(0.5, 100.0, 25))The electron temperatures in eV (or quantities), increasing.
densitiesSequence[float]tuple(np.geomspace(1e+16, 1e+21, 11))The electron densities in m^-3 (or quantities), increasing.
modestr'quasi-static'The steady-state mode.