Skip to main content

opencr

Tests Static analysis Docs codecov PyPI Python

Collisional-radiative (CR) models of low-temperature plasmas in Python: explicit states and reactions with traceable data, steady-state and time-dependent population kinetics, effective ionization, recombination and emission coefficients, and synthetic spectra. Atomic hydrogen first; molecular hydrogen, accelerated backends (cunumpy, JAX) and surrogate models are optional extensions. Cross sections and rates come from plasmacoll.

Documentation: https://max-models.github.io/OpenCR/

Example

import opencr

model = opencr.load_model("hydrogen/atomic/basic")
conditions = opencr.Conditions(
    electron_temperature=2.0,  # eV
    electron_density=1e18,  # m^-3
    densities={"H(n=1)": 1e19, "H+": 1e18},  # the drivers, m^-3
)
result = model.solve_steady_state(conditions)
result.populations["H(n=3)"]  # m^-3
result.emission().sel(line="A:3-2")  # H-alpha
result.reduction.effective_rate("H(n=1)", "H+")  # S_CR, m^3/s

Every physical setting (temperatures, densities, lengths, times, energies, masses) also takes an astropy quantity or a string such as "300 K", as in a configuration file; it is converted once to the documented unit (SI, temperatures as kT in eV), and a bare number keeps meaning that unit:

import astropy.units as u

conditions = opencr.Conditions(
    electron_temperature="23200 K",  # 2.0 eV
    electron_density=1e12 * u.cm**-3,  # 1e18 m^-3
    densities={"H(n=1)": "1e13 cm-3", "H+": 1e18},  # a bare number is in m^-3
)

The physics, the closures and the units are in The CR model; the acceptance criteria of the atomic hydrogen model in Verification.

Install

With uv:

make install    # uv sync --extra dev, plus the pre-commit hooks
uv run opencr list

Or create and activate a Python environment (3.10 or newer):

python -m venv env
source env/bin/activate
pip install --upgrade pip

Install the code and requirements with pip:

pip install -e .

The optional extras cunumpy, jax and ml add the accelerated backends and the surrogate models; the test, docs and dev extras install the test runner, the documentation tooling and the linters:

pip install -e ".[dev]"

Development

Formatting and linting use ruff, type checking pyright, run by pre-commit and in CI:

make lint     # ruff check, ruff format --check, pyright
make test     # pytest with coverage

Commit messages follow Conventional Commits; see CONTRIBUTING.md.

Build docs

The documentation in docs/ is an Astro + Starlight site: hand-written pages, the notebooks in tutorials/ executed and published as pages, complete Python scripts in examples/ published with their plots, and the API reference generated from the docstrings with starlight-pydocs. It needs Node 22 or newer.

make docs-install     # npm packages and the Python docs extra
make docs-notebooks   # execute tutorials/*.ipynb and convert them to pages
make docs-examples    # run examples/*.py and publish their plots
make docs-dev         # live preview at http://localhost:4321/OpenCR/
make docs-build       # the static site in docs/dist

Build the README

README.md is rendered from README.qmd with Quarto:

make readme

Releases

Before merging a release to main, update the version in pyproject.toml, src/opencr/__init__.py and CITATION.cff (including its release date), and add the release notes to CHANGELOG.md. The push to main creates a GitHub release with a vX.Y.Z tag and publishes the package to PyPI with trusted publishing (OIDC). The one-time PyPI and GitHub configuration is described in the publishing tutorial.

Metadata

Release files for opencr 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opencr 0.1.0
File Size Uploaded Provenance Actions
opencr-0.1.0.tar.gz 147.2 kB With provenance Details for opencr-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opencr 0.1.0
File Interpreter ABI Platform Actions
opencr-0.1.0-py3-none-any.whl Python 3 none any Details for opencr-0.1.0-py3-none-any.whl

Total release size: 330.7 kB

Release files / opencr-0.1.0.tar.gz

Download URL opencr-0.1.0.tar.gz
Size 147.2 kB
Tags Source
SHA-256 checksum
How to use checksums
228b9f24165f96d65b9633e46d4ebc942a775414d616ba989143a891138985f3
BLAKE2b-256 checksum
How to use checksums
05f06420d814e7cc87926c94de0a77ba9aeaf704a2305597598cd9334229cd78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / opencr-0.1.0-py3-none-any.whl

Download URL opencr-0.1.0-py3-none-any.whl
Size 183.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8038575d468e17b19aacec67dc59be3f426b68417808063c2e06afd65cba9b4b
BLAKE2b-256 checksum
How to use checksums
771a56a7582d51af3df4c1f64b0523ea5a82bd85ebf8c227bf4e03c11db66999
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for opencr 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opencr-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page