# opencr.analysis.results

*module*

The result of a steady-state solve, and what can be read from it.

A `Result` keeps the model, the conditions, the rate coefficients, the
population equations and the densities of every state, with the solver's
report. From it: the reaction fluxes and the dominant gains and losses of a
state, the lines and their photon emissivity coefficients, a synthetic
spectrum, and everything as an xarray dataset (`Result.to_dataset`) or a
NetCDF file with the model's manifest (`Result.export`).

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

## opencr.analysis.results.Result

*class*

```python
class Result
```

A steady state.

**Attributes**

- `model` — The model solved.
- `conditions` — The conditions.
- `rates` — The rate coefficient of every reaction (SI), in network order.
- `system` — The population equations.
- `evolving` — The steady densities of the evolving states (m^-3).
- `report` — The solver's report.

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

### opencr.analysis.results.Result.conditions

*attribute* · *instance attribute*

```python
conditions = conditions
```

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

### opencr.analysis.results.Result.evolving

*attribute* · *instance attribute*

```python
evolving = np.asarray(evolving, dtype=float)
```

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

### opencr.analysis.results.Result.model

*attribute* · *instance attribute*

```python
model = model
```

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

### opencr.analysis.results.Result.rates

*attribute* · *instance attribute*

```python
rates = rates
```

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

### opencr.analysis.results.Result.report

*attribute* · *instance attribute*

```python
report = report
```

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

### opencr.analysis.results.Result.system

*attribute* · *instance attribute*

```python
system = system
```

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

### opencr.analysis.results.Result.electron_density

*property*

```python
electron_density: float
```

``n_e`` in m^-3.

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

### opencr.analysis.results.Result.fluxes

*property* · *cached*

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

The rate of every reaction in m^-3 s^-1, by name.

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

### opencr.analysis.results.Result.mode

*property*

```python
mode: str
```

The solve: ``"quasi-static"`` or ``"full"``.

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

### opencr.analysis.results.Result.populations

*property* · *cached*

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

The density of every state in m^-3, by name, in network order.

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

### opencr.analysis.results.Result.reduction

*property* · *cached*

```python
reduction: QuasiStatic
```

The quasi-static reduction at these conditions (population and effective coefficients).

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

### opencr.analysis.results.Result.dominant_processes

*method*

```python
def dominant_processes(state: str, number: int = 5) -> list[dict[str, Any]]
```

Return the largest gains and losses of ``state``.

Each entry has the reaction ``name``, its ``equation``, the ``rate`` of
change of the state (m^-3 s^-1; negative for a loss) and its ``fraction``
of the state's total gain or total loss. Sorted by ``|rate|``.

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

### opencr.analysis.results.Result.emission

*method*

```python
def emission(air: bool = False) -> xr.Dataset
```

Return the lines: wavelength, emissivity and power (`line_table`).

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

### opencr.analysis.results.Result.emission_spectrum

*method*

```python
def emission_spectrum(wavelength: np.ndarray | None = None, fwhm: float = 0.0, air: bool = False, quantity: str = 'power') -> xr.DataArray
```

Return a synthetic spectrum: the lines Doppler broadened at the gas temperature.

**Parameters**

- `wavelength` (`np.ndarray | None`) (default: `None`) — The grid in nm; by default 2000 points around the visible lines (350-700 nm).
- `fwhm` (`float`) (default: `0.0`) — An instrumental FWHM in nm, added in quadrature.
- `air` (`bool`) (default: `False`) — Wavelengths in air.
- `quantity` (`str`) (default: `'power'`) — ``"power"`` or ``"emissivity"``.

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

### opencr.analysis.results.Result.export

*method*

```python
def export(path: str | Path) -> Path
```

Write `to_dataset` to a NetCDF file and return its path.

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

### opencr.analysis.results.Result.photon_emissivity_coefficients

*method*

```python
def photon_emissivity_coefficients() -> xr.DataArray
```

Return ``PEC_d`` of every line per driver in m^3/s (quasi-static only).

``emissivity = n_e sum_d PEC_d n_d``; for atomic hydrogen the ``H(n=1)``
part is the excitation component and the ``H+`` part the recombination one.

**Numerics**

*pec*

$$
\mathrm{PEC}_d = \frac{g\, A_{ul}\, C_{ud}}{n_e} \quad [\mathrm{m^3/s}], \qquad \epsilon = n_e \sum_d \mathrm{PEC}_d\, n_d
$$

Assumptions:

- a quasi-static solve: $n_u = \sum_d C_{ud} n_d$; zero for a line whose upper state is a driver
- for atomic hydrogen the H(n=1) part is the excitation component, the H$^+$ part the recombination one

References:

- [Summers et al., Plasma Phys. Control. Fusion 48, 263 (2006)](https://doi.org/10.1088/0741-3335/48/2/007)

Built from:

- `opencr.kinetics.effective.quasi_static`
- `opencr.analysis.emission.line_table`

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

### opencr.analysis.results.Result.population

*method*

```python
def population(state: str) -> float
```

Return the density of ``state`` in m^-3.

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

### opencr.analysis.results.Result.to_dataset

*method*

```python
def to_dataset() -> xr.Dataset
```

Return the populations, rates, fluxes and lines as one xarray dataset.

The conditions, the solver report and the model's manifest are in the
attributes, as JSON.

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