# opencr.analysis.quantities

*module*

Scalar quantities of a steady state, named by strings.

The surrogates (`opencr.ml`), the sensitivities and the inverse
modelling (`opencr.inference`) all ask a `Result`
for named scalars:

==========================================  ===============================================
name                                        quantity
==========================================  ===============================================
``population:<state>``                      the density of a state (m^-3)
``effective_rate:<source>><target>``        an effective rate coefficient (m^3/s), quasi-static
``emissivity:<reaction>``                   the photon emissivity of a line (photons m^-3 s^-1)
``electron_cooling:<driver>``               the electron energy loss per electron and per
                                            particle of a driver (eV m^3/s), quasi-static
``ratio:<quantity>/<quantity>``             the ratio of two of the above
==========================================  ===============================================

For example ``"effective_rate:H(n=1)>H+"`` is the CR ionization coefficient
of atomic hydrogen and ``"ratio:emissivity:A:3-2/emissivity:A:4-2"`` the
Balmer alpha to beta ratio.

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/analysis/quantities.py#L1-L1)

## opencr.analysis.quantities.KINDS

*attribute* · *module attribute*

```python
KINDS = ('population', 'effective_rate', 'emissivity', 'electron_cooling', 'ratio')
```

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/analysis/quantities.py#L34-L34)

## opencr.analysis.quantities.check_quantity

*function*

```python
def check_quantity(model: Any, name: str) -> None
```

Raise ``ValueError`` (or ``KeyError``) if ``name`` is not a quantity of ``model``.

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/analysis/quantities.py#L37-L60)

## opencr.analysis.quantities.electron_cooling

*function*

```python
def electron_cooling(result: Any, driver: str) -> float
```

Return the electron energy loss due to ``driver`` per electron and particle (eV m^3/s).

The sum over the electron-impact reactions (an electron among the
reactants, not radiative) of ``k n_e^(a-1) c_X Delta E``, where ``c_X`` is
the quasi-static population of the reaction's heavy reactant per particle
of ``driver`` (1 for the driver itself, 0 for the other drivers) and
``Delta E`` the energy the heavy particles gain: the excitation and
ionization energies, negative for de-excitation and three-body
recombination. Radiative recombination (the electron's kinetic energy) is
not counted.

**Numerics**

*cooling*

$$
L_d = \sum_r k_r\, n_e^{a_{re} - 1}\, c_{X_r, d}\, \Delta E_r \quad [\mathrm{eV\,m^3/s}]
$$

Assumptions:

- over the electron-impact, non-radiative reactions with one heavy reactant $X_r$
- $c_{X,d}$ the quasi-static population of $X$ per particle of driver $d$ (1 for $d$ itself, 0 for the other drivers)
- $\Delta E_r$ the internal energy the heavy particles gain: negative for de-excitation and three-body recombination; radiative recombination is not counted

Built from:

- `opencr.kinetics.effective.quasi_static`

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/analysis/quantities.py#L63-L105)

## opencr.analysis.quantities.quantities

*function*

```python
def quantities(result: Any, names: Sequence[str]) -> np.ndarray
```

Return the quantities ``names`` of a steady state as an array.

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/analysis/quantities.py#L127-L129)

## opencr.analysis.quantities.quantity

*function*

```python
def quantity(result: Any, name: str) -> float
```

Return the quantity ``name`` of a steady state (see the module docstring).

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/analysis/quantities.py#L108-L124)
