# opencr.kinetics.radiation

*module*

Radiation trapping as an escape-factor approximation.

An optically thick line ``u -> l`` is re-absorbed on its way out of the
plasma, so only a fraction of the spontaneous emission leaves: the effective
transition probability is ``g A_ul`` with the escape factor ``g`` in [0, 1].
OpenCR applies escape factors to the ``spontaneous_emission`` reactions, from
the conditions (``Conditions.escape``, per line) or computed here from the
line-centre optical depth of a Doppler-broadened line over a length ``L``,

$$
\tau_0 = \kappa_0 L, \qquad
\kappa_0 = \frac{\lambda_0^3}{8\pi^{3/2}}\,\frac{g_u}{g_l}\,\frac{A_{ul}\, n_l}{v_D},
$$

with ``v_D = (2 kT / m)^(1/2)`` the emitters' thermal speed at the gas
temperature (Mihalas 1978, eq. 9-6 with a Doppler profile). The escape factor
is then one of the usual approximations (`ESCAPE_MODELS`):

* ``"mewe"`` (default): ``g = (2 - exp(-tau_0 / 1000)) / (1 + tau_0)`` (Mewe
  1967, Brit. J. Appl. Phys. 18, 107), an interpolation that is right in both
  limits and is what most CR codes use (Yacora, Behringer's models);
* ``"holstein-slab"``: Holstein's asymptotic result for a Doppler profile,
  ``g = 1 / (tau_0 (pi ln tau_0)^(1/2))``, for an infinite slab of
  half-thickness ``L`` (Holstein 1947, Phys. Rev. 72, 1212);
* ``"holstein-cylinder"``: the same for an infinite cylinder of radius ``L``,
  ``g = 1.60 / (tau_0 (pi ln tau_0)^(1/2))``.

Holstein's forms hold for ``tau_0 >> 1``; below ``tau_0 = e`` they are set
to 1. ``L`` is the characteristic absorption length (the distance to the
wall, not the full plasma size), to be chosen by the user; this is a
zero-dimensional approximation of a transport problem and is explicit about
it: no escape factor is applied unless a `RadiationTrapping` is given.

A self-consistent solve iterates: the escape factors depend on the lower
populations, which depend on the escape factors
(`opencr.model.Model.solve_steady_state`).

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

## opencr.kinetics.radiation.ESCAPE_MODELS

*attribute* · *module attribute*

```python
ESCAPE_MODELS = ('mewe', 'holstein-slab', 'holstein-cylinder')
```

Re-exported from: `opencr.core.conditions`

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L32-L32)

## opencr.kinetics.radiation.RadiationTrapping

*class* · *dataclass*

```python
class RadiationTrapping
```

Re-exported from: `opencr.core.conditions`

The escape-factor configuration of a solve (see `opencr.kinetics.radiation`).

The length takes a quantity (see the module docstring).

**Attributes**

- `length` (`float`) — The absorption length ``L`` in m (the distance to the wall).
- `model` (`str`) — One of `ESCAPE_MODELS`.
- `lines` (`tuple[str, ...] | None`) — The names of the ``spontaneous_emission`` reactions to trap, or ``None`` for all of them.
- `tolerance` (`float`) — The self-consistent iteration stops when no escape factor changes by more than this.
- `max_iterations` (`int`) — The limit of that iteration.

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L35-L73)

### opencr.kinetics.radiation.RadiationTrapping.length

*attribute* · *class attribute* · *instance attribute*

```python
length: float = unit_field('m')
```

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L51-L51)

### opencr.kinetics.radiation.RadiationTrapping.lines

*attribute* · *class attribute* · *instance attribute*

```python
lines: tuple[str, ...] | None = None
```

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L53-L53)

### opencr.kinetics.radiation.RadiationTrapping.max_iterations

*attribute* · *class attribute* · *instance attribute*

```python
max_iterations: int = 100
```

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L55-L55)

### opencr.kinetics.radiation.RadiationTrapping.model

*attribute* · *class attribute* · *instance attribute*

```python
model: str = 'mewe'
```

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L52-L52)

### opencr.kinetics.radiation.RadiationTrapping.tolerance

*attribute* · *class attribute* · *instance attribute*

```python
tolerance: float = 1e-06
```

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L54-L54)

### opencr.kinetics.radiation.RadiationTrapping.to_dict

*method*

```python
def to_dict() -> dict[str, Any]
```

Return the configuration as plain data.

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/core/conditions.py#L67-L73)

## opencr.kinetics.radiation.escape_factor

*function*

```python
def escape_factor(optical_depth: float | np.ndarray, model: str = 'mewe') -> np.ndarray
```

Return the escape factor ``g(tau_0)`` of one of `ESCAPE_MODELS`.

**Numerics**

*mewe*

$$
g_{\mathrm{mewe}} = \frac{2 - e^{-\tau_0/1000}}{1 + \tau_0}
$$

*holstein slab*

$$
g_{\mathrm{slab}} = \frac{1}{\tau_0\sqrt{\pi\ln\tau_0}} \quad (\tau_0 > e), \qquad 1 \ \text{below}
$$

*holstein cylinder*

$$
g_{\mathrm{cyl}} = \frac{1.60}{\tau_0\sqrt{\pi\ln\tau_0}} \quad (\tau_0 > e), \qquad 1 \ \text{below}
$$

Assumptions:

- Mewe (the default): 1 at $\tau_0 = 0$, about $1/\tau_0$ for $1 \ll \tau_0 \ll 1000$, $2/\tau_0$ for $\tau_0 \gg 1000$
- Holstein: asymptotic forms for $\tau_0 \gg 1$, an infinite slab of half-thickness $L$ or a cylinder of radius $L$; at $\tau_0 = e$ they jump from 1 to 0.207 (slab) and 0.332 (cylinder)

References:

- R. Mewe, Brit. J. Appl. Phys. 18, 107 (1967)
- [Holstein, Phys. Rev. 72, 1212 (1947)](https://doi.org/10.1103/PhysRev.72.1212)

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/kinetics/radiation.py#L155-L184)

## opencr.kinetics.radiation.escape_factors

*function*

```python
def escape_factors(network: ReactionNetwork, populations: Mapping[str, float], trapping: RadiationTrapping, temperature: float) -> dict[str, float]
```

Return the escape factor of every trapped line, by reaction name.

**Parameters**

- `network` (`ReactionNetwork`) — The network.
- `populations` (`Mapping[str, float]`) — The density of every state in m^-3.
- `trapping` (`RadiationTrapping`) — The configuration.
- `temperature` (`float`) — The gas (emitter) temperature in eV.

**Numerics**

*line*

$$
\lambda_0 = \frac{hc}{E_u - E_l}, \qquad g = g(\tau_0), \qquad \tau_0 = \tau_0(\lambda_0, A_{ul}, g_u/g_l, n_l, L, T_{\mathrm{gas}}, m)
$$

Assumptions:

- every `spontaneous_emission` of `RadiationTrapping.lines` (all by default)
- $A_{ul}$ the untrapped `Constant` coefficient (another rate model raises); $m$ the emitter's mass

Built from:

- `opencr.kinetics.radiation.line_centre_optical_depth`
- `opencr.kinetics.radiation.escape_factor`

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/kinetics/radiation.py#L187-L240)

## opencr.kinetics.radiation.line_centre_optical_depth

*function*

```python
def line_centre_optical_depth(wavelength: float | np.ndarray, einstein_a: float | np.ndarray, weight_ratio: float | np.ndarray, lower_density: float | np.ndarray, length: float, temperature: float, mass: float) -> np.ndarray
```

Return ``tau_0`` of a Doppler-broadened line over ``length``.

**Parameters**

- `wavelength` (`float | np.ndarray`) — The line's vacuum wavelength in nm.
- `einstein_a` (`float | np.ndarray`) — ``A_ul`` in s^-1 (without any escape factor).
- `weight_ratio` (`float | np.ndarray`) — ``g_u / g_l``.
- `lower_density` (`float | np.ndarray`) — ``n_l`` in m^-3.
- `length` (`float`) — The absorption length ``L`` in m.
- `temperature` (`float`) — The emitters' ``kT`` in eV.
- `mass` (`float`) — The emitters' mass in kg.

**Numerics**

*optical depth*

$$
\tau_0 = \kappa_0 L, \qquad \kappa_0 = \frac{\lambda_0^3}{8\pi^{3/2}}\,\frac{g_u}{g_l}\,\frac{A_{ul}\, n_l}{v_D}, \qquad v_D = \sqrt{\frac{2kT}{m}}
$$

*cross section*

$$
\kappa_0 = \underbrace{\frac{\lambda_0^2}{8\pi}\,\frac{g_u}{g_l}\,A_{ul}}_{\text{integrated absorption}}\ \underbrace{\frac{\lambda_0}{\sqrt\pi\,v_D}}_{\phi(0)}\ n_l
$$

Assumptions:

- a Doppler-broadened line at the emitters' temperature; no stimulated emission
- $L$ the absorption length (the distance to the wall), chosen by the user

References:

- D. Mihalas, Stellar Atmospheres, 2nd ed., W. H. Freeman (1978), eq. 9-6

[View source](https://github.com/max-models/OpenCR/blob/devel/src/opencr/kinetics/radiation.py#L109-L152)
