# opencr.kinetics.eedf

*module*

Electron energy distribution functions.

An EEDF is given as the energy probability function ``F0(eps)`` in eV^-3/2,
normalised by ``int eps^1/2 F0 deps = 1`` (the convention of BOLSIG+ and of
`plasmacoll.solve_eedf`), so that ``eps^1/2 F0`` is the probability
density of the energy. Rate coefficients are
``k = (2 e / m_e)^1/2 int eps sigma F0 deps``.

* `Maxwellian`: ``F0 = 2 / sqrt(pi) T^-3/2 exp(-eps / T)``.
* `Generalized`: ``F0 ~ exp(-(eps / eps0)^x)``, Maxwellian for ``x = 1``
  and Druyvesteyn for ``x = 2``, at a given mean energy.
* `TabulatedEEDF`: any distribution on an energy grid, for example from
  a probe or from plasmacoll's two-term Boltzmann solver
  (`TabulatedEEDF.from_boltzmann`).

OpenCR does not compute EEDFs; they are inputs (see the guide "The CR model").
Their energies and temperatures take an astropy Quantity or a string such as
``"3 eV"`` or ``"30000 K"`` as well as a number in eV (see `plasmacoll.units`).

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

## opencr.kinetics.eedf.EEDF

*class*

```python
class EEDF
```

Base class: a normalised electron energy probability function.

**Numerics**

*normalisation*

$$
\int_0^\infty \varepsilon^{1/2} F_0(\varepsilon)\, d\varepsilon = 1, \qquad F_0 \ \text{in eV}^{-3/2}
$$

*mean*

$$
\langle\varepsilon\rangle = \int_0^\infty \varepsilon^{3/2} F_0\, d\varepsilon, \qquad T_{\mathrm{eff}} = \tfrac23 \langle\varepsilon\rangle
$$

*rate*

$$
k = \sqrt{\frac{2e}{m_e}} \int_0^\infty \varepsilon\,\sigma(\varepsilon)\,F_0(\varepsilon)\,d\varepsilon
$$

*grid*

$$
\varepsilon \in \{0\} \cup \mathrm{geomspace}\big(10^{-4}\varepsilon_{\max},\ \varepsilon_{\max}\big), \qquad \varepsilon_{\max} = 60\, T_{\mathrm{eff}}
$$

Assumptions:

- the EEDF is an input: OpenCR does not compute it
- the rate integral is `plasmacoll.eedf_rate_coefficient`: trapezoid on the union of the EEDF grid, the table energies and the threshold, each interval refined 4 times, $\ln F_0$ linear between points, $F_0 = 0$ beyond the grid
- only the electron cross-section rates (and their Klein-Rosseland inverses) see a non-Maxwellian EEDF; every other rate uses $T_{\mathrm{eff}}$

References:

- [Hagelaar and Pitchford, Plasma Sources Sci. Technol. 14, 722 (2005)](https://doi.org/10.1088/0963-0252/14/4/011)

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

### opencr.kinetics.eedf.EEDF.effective_temperature

*property*

```python
effective_temperature: float
```

``2/3 <eps>`` in eV, the temperature of a Maxwellian of the same mean energy.

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

### opencr.kinetics.eedf.EEDF.is_maxwellian

*property*

```python
is_maxwellian: bool
```

Whether the distribution is exactly Maxwellian.

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

### opencr.kinetics.eedf.EEDF.mean_energy

*property*

```python
mean_energy: float
```

``<eps> = int eps^3/2 F0 deps`` in eV.

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

### opencr.kinetics.eedf.EEDF.eepf

*method*

```python
def eepf(energy: np.ndarray) -> np.ndarray
```

Return ``F0`` in eV^-3/2 at ``energy`` (eV).

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

### opencr.kinetics.eedf.EEDF.grid

*method*

```python
def grid(num: int = 2000) -> np.ndarray
```

Return an energy grid (eV) that resolves the distribution and its tail.

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

### opencr.kinetics.eedf.EEDF.tabulate

*method*

```python
def tabulate(num: int = 2000) -> TabulatedEEDF
```

Return the distribution on `grid`.

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

## opencr.kinetics.eedf.Generalized

*class* · *dataclass*

```python
class Generalized(EEDF)
```

Bases: `opencr.kinetics.eedf.EEDF`

``F0 = c exp(-(eps / eps0)^shape)`` with the given mean energy.

``shape = 1`` is a Maxwellian, ``shape = 2`` a Druyvesteyn distribution
(elastic collisions with a constant cross section in a field). With
``eps0 = <eps> Gamma(3/(2x)) / Gamma(5/(2x))`` and
``c = x / (eps0^3/2 Gamma(3/(2x)))``. The mean energy is in eV (or a
quantity).

**Numerics**

*eepf*

$$
F_0(\varepsilon) = c\, e^{-(\varepsilon/\varepsilon_0)^x}, \qquad \varepsilon_0 = \langle\varepsilon\rangle\,\frac{\Gamma(3/2x)}{\Gamma(5/2x)}, \qquad c = \frac{x}{\varepsilon_0^{3/2}\,\Gamma(3/2x)}
$$

*grid*

$$
\varepsilon_{\max} = \varepsilon_0\, 60^{1/x}
$$

Assumptions:

- $x = 1$ Maxwellian, $x = 2$ Druyvesteyn (elastic collisions with a constant cross section in a field)
- normalised with the mean $\langle\varepsilon\rangle$ given

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

### opencr.kinetics.eedf.Generalized.mean

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

```python
mean: float = unit_field('eV')
```

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

### opencr.kinetics.eedf.Generalized.shape

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

```python
shape: float = 2.0
```

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

### opencr.kinetics.eedf.Generalized.is_maxwellian

*property*

```python
is_maxwellian: bool
```

Whether ``shape`` is 1.

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

### opencr.kinetics.eedf.Generalized.mean_energy

*property*

```python
mean_energy: float
```

The mean energy.

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

### opencr.kinetics.eedf.Generalized.effective_temperature

*property*

```python
effective_temperature: float
```

Inherited from: `opencr.kinetics.eedf.EEDF`

``2/3 <eps>`` in eV, the temperature of a Maxwellian of the same mean energy.

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

### opencr.kinetics.eedf.Generalized.eepf

*method*

```python
def eepf(energy: np.ndarray) -> np.ndarray
```

Return ``F0`` at ``energy``.

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

### opencr.kinetics.eedf.Generalized.grid

*method*

```python
def grid(num: int = 2000) -> np.ndarray
```

A grid to where ``(eps/eps0)^x`` reaches 60.

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

### opencr.kinetics.eedf.Generalized.tabulate

*method*

```python
def tabulate(num: int = 2000) -> TabulatedEEDF
```

Inherited from: `opencr.kinetics.eedf.EEDF`

Return the distribution on `grid`.

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

## opencr.kinetics.eedf.Maxwellian

*class* · *dataclass*

```python
class Maxwellian(EEDF)
```

Bases: `opencr.kinetics.eedf.EEDF`

A Maxwellian at ``temperature`` (``kT`` in eV, or a quantity).

**Numerics**

*eepf*

$$
F_0(\varepsilon) = \frac{2}{\sqrt\pi}\, T^{-3/2}\, e^{-\varepsilon/T}
$$

*mean*

$$
\langle\varepsilon\rangle = \tfrac32 T
$$

Assumptions:

- detected by `is_maxwellian`: the rates then take the closed-form Maxwellian path

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

### opencr.kinetics.eedf.Maxwellian.temperature

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

```python
temperature: float = unit_field('eV')
```

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

### opencr.kinetics.eedf.Maxwellian.is_maxwellian

*property*

```python
is_maxwellian: bool
```

True.

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

### opencr.kinetics.eedf.Maxwellian.mean_energy

*property*

```python
mean_energy: float
```

``3/2 T``.

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

### opencr.kinetics.eedf.Maxwellian.effective_temperature

*property*

```python
effective_temperature: float
```

Inherited from: `opencr.kinetics.eedf.EEDF`

``2/3 <eps>`` in eV, the temperature of a Maxwellian of the same mean energy.

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

### opencr.kinetics.eedf.Maxwellian.eepf

*method*

```python
def eepf(energy: np.ndarray) -> np.ndarray
```

Return ``2 / sqrt(pi) T^-3/2 exp(-eps / T)``.

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

### opencr.kinetics.eedf.Maxwellian.grid

*method*

```python
def grid(num: int = 2000) -> np.ndarray
```

Inherited from: `opencr.kinetics.eedf.EEDF`

Return an energy grid (eV) that resolves the distribution and its tail.

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

### opencr.kinetics.eedf.Maxwellian.tabulate

*method*

```python
def tabulate(num: int = 2000) -> TabulatedEEDF
```

Inherited from: `opencr.kinetics.eedf.EEDF`

Return the distribution on `grid`.

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

## opencr.kinetics.eedf.TabulatedEEDF

*class*

```python
class TabulatedEEDF(EEDF)
```

Bases: `opencr.kinetics.eedf.EEDF`

A distribution tabulated on an energy grid, normalised on construction.

Between the points ``log F0`` is interpolated linearly (``F0`` where it is
zero); beyond the last point ``F0`` is zero.

**Parameters**

- `energy` (`np.ndarray`) — The grid in eV (or a quantity), increasing, ``>= 0``.
- `eepf` (`np.ndarray`) — ``F0`` at ``energy``, non-negative, in any normalisation.

**Numerics**

*normalisation*

$$
F_0 \leftarrow \frac{F_0}{\sum_i \tfrac12 \big(\varepsilon_i^{1/2} F_{0,i} + \varepsilon_{i+1}^{1/2} F_{0,i+1}\big)(\varepsilon_{i+1} - \varepsilon_i)}
$$

*interpolation*

$$
\ln F_0 \ \text{linear between the points} \ (F_0 \text{ itself next to a zero}), \qquad F_0 = 0 \ \text{beyond the last}
$$

*mean*

$$
\langle\varepsilon\rangle = \sum_i \tfrac12 \big(\varepsilon_i^{3/2} F_{0,i} + \varepsilon_{i+1}^{3/2} F_{0,i+1}\big)(\varepsilon_{i+1} - \varepsilon_i)
$$

Assumptions:

- any distribution on an energy grid: a probe, or plasmacoll's two-term Boltzmann solver
- normalised by the trapezoidal rule on construction

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

### opencr.kinetics.eedf.TabulatedEEDF.energy

*attribute* · *instance attribute*

```python
energy = energy
```

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

### opencr.kinetics.eedf.TabulatedEEDF.values

*attribute* · *instance attribute*

```python
values = eepf / norm
```

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

### opencr.kinetics.eedf.TabulatedEEDF.mean_energy

*property*

```python
mean_energy: float
```

``int eps^3/2 F0 deps`` on the table.

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

### opencr.kinetics.eedf.TabulatedEEDF.effective_temperature

*property*

```python
effective_temperature: float
```

Inherited from: `opencr.kinetics.eedf.EEDF`

``2/3 <eps>`` in eV, the temperature of a Maxwellian of the same mean energy.

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

### opencr.kinetics.eedf.TabulatedEEDF.is_maxwellian

*property*

```python
is_maxwellian: bool
```

Inherited from: `opencr.kinetics.eedf.EEDF`

Whether the distribution is exactly Maxwellian.

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

### opencr.kinetics.eedf.TabulatedEEDF.eepf

*method*

```python
def eepf(energy: np.ndarray) -> np.ndarray
```

Return ``F0`` at ``energy``, interpolated.

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

### opencr.kinetics.eedf.TabulatedEEDF.from_boltzmann

*method* · *classmethod*

```python
def from_boltzmann(solution: Any) -> TabulatedEEDF
```

Return the distribution of a `plasmacoll.BoltzmannSolution`.

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

### opencr.kinetics.eedf.TabulatedEEDF.grid

*method*

```python
def grid(num: int = 2000) -> np.ndarray
```

The table's own grid.

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

### opencr.kinetics.eedf.TabulatedEEDF.tabulate

*method*

```python
def tabulate(num: int = 2000) -> TabulatedEEDF
```

Itself.

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