Metadata-Version: 2.1
Name: nemo-astro
Version: 1.4.1
Summary: Python interface to NEMO, a non-equilibrium multi-ion solver for the ionisation and thermal state of astrophysical plasmas
Author: Arun Mathew, Jonathan Mackey, Maggie Celeste Goulden
License: BSD 3-Clause License
         
         Copyright (c) 2026, Arun Mathew, Jonathan Mackey et al.
         
         Redistribution and use in source and binary forms, with or without
         modification, are permitted provided that the following conditions are met:
         
         1. Redistributions of source code must retain the above copyright notice, this
            list of conditions and the following disclaimer.
         
         2. Redistributions in binary form must reproduce the above copyright notice,
            this list of conditions and the following disclaimer in the documentation
            and/or other materials provided with the distribution.
         
         3. Neither the name of the copyright holder nor the names of its
            contributors may be used to endorse or promote products derived from
            this software without specific prior written permission.
         
         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
         AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
         IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
         FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
         DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
         SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
         CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
         OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
         OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Astronomy
Classifier: Topic :: Scientific/Engineering :: Physics
Project-URL: Homepage, https://github.com/jmackey-astro/nemo
Project-URL: Source, https://gitlab.git.nrw/jmackey1/nemo
Project-URL: Paper, https://doi.org/10.1051/0004-6361/202452373
Requires-Python: >=3.10
Requires-Dist: numpy>=1.21
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Description-Content-Type: text/markdown

# nemo-astro

Python interface to [NEMO](https://gitlab.git.nrw/jmackey1/nemo), the
Non-Equilibrium Multi-ion mOdule for ionised astrophysical plasmas.  NEMO
integrates the ionisation state of many elements and ions, and the gas
temperature, with the CVODE solver from SUNDIALS.

Method paper: Mathew, A., Mackey, J., Celeste, M., Haworth, T. J., &
Mellema, G. (2025), A&A, 695, A73,
[doi:10.1051/0004-6361/202452373](https://doi.org/10.1051/0004-6361/202452373).

## Installation

```bash
pip install nemo-astro
```

The wheels contain everything that NEMO needs (SUNDIALS is built in); no MPI
or other libraries are required.  To build from source you need a C++14
compiler; CMake and the other dependencies are downloaded during the build.

## Example

```python
import numpy as np
import nemo_astro as nemo

tracers = ["X_H", "X_He", "H", "He", "He1+"]   # elements, then ions
solver = nemo.Nemo(tracers, options=nemo.Options(cooling=False))

# density (g/cm^3), pressure (dyne/cm^2), then the tracers (mass fractions)
prim = np.array([1e-22, 1e-12, 0.72, 0.28, 0.36, 0.05, 0.1])
new = solver.update(prim, dt=1e10)       # advance by 1e10 s
print(solver.temperature(new), solver.electron_density(new))

# Many cells at once: any array of shape (..., nv_prim)
grid = np.tile(prim, (100, 100, 1))
new_grid = solver.update(grid, dt=1e10)   # shape (100, 100, 7)
```

Tracer names: elements are `X_H`, `X_He`, `X_C`, ... in order of atomic
number, followed by the ions of each element from the neutral upwards
(`H`, `He`, `He1+`, `C`, `C1+`, ...); the highest ionisation stage of each
element is not listed.  Element mass fractions must sum to 1.  See the
[NEMO README](https://gitlab.git.nrw/jmackey1/nemo) for details.

Errors (bad input, failed integration) raise `nemo_astro.NemoError`, which
has an error `code`.  `nemo_astro.set_log_level("info")` shows NEMO's log
messages.

A `Nemo` object can be used from several Python threads (calls are
serialised); for parallel work use one object per thread.  The computation
runs without the GIL.

## Tests

From a clone of the NEMO repository:

```bash
pip install ".[test]"
pytest -m "not slow"   # about 5 s
pytest                 # all tests, about 2 minutes
```

The tests in `python/tests/test_reference.py` are the Python versions of
NEMO's C++ regression tests, and compare with the same reference data
(`tests/data`) and tolerances.
