# opencr.core.conditions

*module*

The plasma conditions of a solve.

`Conditions` holds everything a solve takes from outside the model:
the electron temperature (and optionally a non-Maxwellian energy
distribution), the electron density or quasi-neutrality, the densities of the
prescribed states (the drivers and backgrounds), the element totals of a
closed steady state, the heavy-particle temperatures and the radiation
trapping (escape factors given per line, or a `RadiationTrapping`
configuration they are computed from). See the guide "The CR model" for how
a solve uses them.

Every physical setting takes an astropy Quantity (``2 * u.eV``, ``1e12 *
u.cm**-3``), a string astropy reads (``"300 K"``, as in a configuration file)
or a bare number in its documented unit (SI, with temperatures as ``kT`` in
eV), and is stored as a float in that unit; temperatures in K are converted
to eV (see `plasmacoll.units`).

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

## opencr.core.conditions.ESCAPE_MODELS

*attribute* · *module attribute*

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

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

## opencr.core.conditions.Conditions

*class* · *dataclass*

```python
class Conditions
```

Plasma conditions, SI with temperatures in eV.

The temperatures and densities take quantities (see the module
docstring): ``Conditions("300 K", 1e12 * u.cm**-3)``.

**Attributes**

- `electron_temperature` (`float`) — ``kT_e`` in eV. With a non-Maxwellian ``eedf`` it is the temperature of the rates that are not cross sections and of detailed balance; `from_eedf` sets it to ``2/3 <eps>``.
- `electron_density` (`float | None`) — ``n_e`` in m^-3, or ``None`` for quasi-neutrality, ``n_e = sum z_i n_i`` over every charged state (evolving and prescribed).
- `eedf` (`Any`) — The electron energy distribution (an `opencr.kinetics.eedf.EEDF`), or ``None`` for a Maxwellian at ``electron_temperature``.
- `densities` (`Mapping[str, float]`) — Densities in m^-3 of the prescribed states, by name: the drivers of a quasi-static solve (e.g. ``H(n=1)`` and ``H+``) and fixed backgrounds (e.g. ``H2`` in an atomic model).
- `totals` (`Mapping[str, float]`) — For a closed steady state, the total density of each element in m^-3 over the evolving states, e.g. ``{"H": 1e19}``.
- `ion_temperature` (`float | None`) — ``kT_i`` in eV; the gas temperature if ``None``.
- `gas_temperature` (`float`) — ``kT`` of the neutral gas in eV (0.026 eV is 300 K).
- `escape` (`Mapping[str, float]`) — Escape factors in [0, 1] by reaction name, overriding the reactions' own and anything ``trapping`` computes.
- `trapping` (`RadiationTrapping | None`) — Compute the escape factors of the lines self-consistently from the populations (`opencr.kinetics.radiation`); ``None`` for an optically thin plasma (apart from ``escape``).

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

### opencr.core.conditions.Conditions.densities

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

```python
densities: Mapping[str, float] = unit_field('m-3', default_factory=dict)
```

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

### opencr.core.conditions.Conditions.eedf

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

```python
eedf: Any = None
```

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

### opencr.core.conditions.Conditions.electron_density

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

```python
electron_density: float | None = unit_field('m-3', None)
```

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

### opencr.core.conditions.Conditions.electron_temperature

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

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

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

### opencr.core.conditions.Conditions.escape

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

```python
escape: Mapping[str, float] = field(default_factory=dict)
```

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

### opencr.core.conditions.Conditions.gas_temperature

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

```python
gas_temperature: float = unit_field('eV', 0.026)
```

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

### opencr.core.conditions.Conditions.ion_temperature

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

```python
ion_temperature: float | None = unit_field('eV', None)
```

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

### opencr.core.conditions.Conditions.totals

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

```python
totals: Mapping[str, float] = unit_field('m-3', default_factory=dict)
```

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

### opencr.core.conditions.Conditions.trapping

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

```python
trapping: RadiationTrapping | None = None
```

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

### opencr.core.conditions.Conditions.heavy_temperature

*property*

```python
heavy_temperature: dict[str, float]
```

The temperature of each kind of rate dependence (see `opencr.core.rates`).

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

### opencr.core.conditions.Conditions.quasi_neutral

*property*

```python
quasi_neutral: bool
```

Whether ``n_e`` follows from quasi-neutrality.

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

### opencr.core.conditions.Conditions.from_eedf

*method* · *classmethod*

```python
def from_eedf(eedf: Any, **kwargs: Any) -> Conditions
```

Return conditions with ``eedf`` and its effective temperature ``2/3 <eps>``.

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

### opencr.core.conditions.Conditions.replace

*method*

```python
def replace(**changes: Any) -> Conditions
```

Return a copy with ``changes`` applied.

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

### opencr.core.conditions.Conditions.to_dict

*method*

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

Return the conditions as plain data (the EEDF by its description).

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

## opencr.core.conditions.RadiationTrapping

*class* · *dataclass*

```python
class RadiationTrapping
```

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.core.conditions.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.core.conditions.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.core.conditions.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.core.conditions.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.core.conditions.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.core.conditions.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)
