opencr 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opencr-0.1.0/PKG-INFO +196 -0
- opencr-0.1.0/README.md +142 -0
- opencr-0.1.0/pyproject.toml +104 -0
- opencr-0.1.0/setup.cfg +4 -0
- opencr-0.1.0/src/opencr/__init__.py +39 -0
- opencr-0.1.0/src/opencr/_profiling.py +9 -0
- opencr-0.1.0/src/opencr/analysis/__init__.py +6 -0
- opencr-0.1.0/src/opencr/analysis/emission.py +226 -0
- opencr-0.1.0/src/opencr/analysis/quantities.py +129 -0
- opencr-0.1.0/src/opencr/analysis/results.py +264 -0
- opencr-0.1.0/src/opencr/analysis/scan.py +164 -0
- opencr-0.1.0/src/opencr/analysis/transient.py +144 -0
- opencr-0.1.0/src/opencr/backends/__init__.py +27 -0
- opencr-0.1.0/src/opencr/backends/batched.py +351 -0
- opencr-0.1.0/src/opencr/backends/jax_backend.py +254 -0
- opencr-0.1.0/src/opencr/cli.py +74 -0
- opencr-0.1.0/src/opencr/constants.py +142 -0
- opencr-0.1.0/src/opencr/core/__init__.py +47 -0
- opencr-0.1.0/src/opencr/core/conditions.py +186 -0
- opencr-0.1.0/src/opencr/core/network.py +275 -0
- opencr-0.1.0/src/opencr/core/rates.py +443 -0
- opencr-0.1.0/src/opencr/core/reactions.py +179 -0
- opencr-0.1.0/src/opencr/core/species.py +212 -0
- opencr-0.1.0/src/opencr/data/__init__.py +32 -0
- opencr-0.1.0/src/opencr/data/checks.py +194 -0
- opencr-0.1.0/src/opencr/data/hydrogen.py +359 -0
- opencr-0.1.0/src/opencr/data/importers.py +201 -0
- opencr-0.1.0/src/opencr/data/molecular_hydrogen.py +137 -0
- opencr-0.1.0/src/opencr/data/native.py +187 -0
- opencr-0.1.0/src/opencr/data/provenance.py +162 -0
- opencr-0.1.0/src/opencr/inference/__init__.py +34 -0
- opencr-0.1.0/src/opencr/inference/inverse.py +222 -0
- opencr-0.1.0/src/opencr/inference/sensitivity.py +274 -0
- opencr-0.1.0/src/opencr/kinetics/__init__.py +8 -0
- opencr-0.1.0/src/opencr/kinetics/eedf.py +304 -0
- opencr-0.1.0/src/opencr/kinetics/effective.py +286 -0
- opencr-0.1.0/src/opencr/kinetics/radiation.py +240 -0
- opencr-0.1.0/src/opencr/kinetics/rates.py +728 -0
- opencr-0.1.0/src/opencr/kinetics/system.py +359 -0
- opencr-0.1.0/src/opencr/ml/__init__.py +19 -0
- opencr-0.1.0/src/opencr/ml/dataset.py +132 -0
- opencr-0.1.0/src/opencr/ml/surrogate.py +141 -0
- opencr-0.1.0/src/opencr/model.py +320 -0
- opencr-0.1.0/src/opencr/models/__init__.py +107 -0
- opencr-0.1.0/src/opencr/models/argon.py +248 -0
- opencr-0.1.0/src/opencr/models/hydrogen_atomic.py +252 -0
- opencr-0.1.0/src/opencr/models/hydrogen_molecular.py +487 -0
- opencr-0.1.0/src/opencr/py.typed +0 -0
- opencr-0.1.0/src/opencr/solvers/__init__.py +6 -0
- opencr-0.1.0/src/opencr/solvers/diagnostics.py +104 -0
- opencr-0.1.0/src/opencr/solvers/steady.py +335 -0
- opencr-0.1.0/src/opencr/solvers/transient.py +213 -0
- opencr-0.1.0/src/opencr/tables.py +211 -0
- opencr-0.1.0/src/opencr/tests/backends/__init__.py +0 -0
- opencr-0.1.0/src/opencr/tests/backends/test_batched.py +187 -0
- opencr-0.1.0/src/opencr/tests/backends/test_jax.py +186 -0
- opencr-0.1.0/src/opencr/tests/integration/__init__.py +0 -0
- opencr-0.1.0/src/opencr/tests/integration/test_analysis.py +166 -0
- opencr-0.1.0/src/opencr/tests/integration/test_argon_model.py +57 -0
- opencr-0.1.0/src/opencr/tests/integration/test_hydrogen_model.py +155 -0
- opencr-0.1.0/src/opencr/tests/integration/test_inference.py +127 -0
- opencr-0.1.0/src/opencr/tests/integration/test_ml.py +61 -0
- opencr-0.1.0/src/opencr/tests/integration/test_molecular_model.py +157 -0
- opencr-0.1.0/src/opencr/tests/integration/test_tables.py +67 -0
- opencr-0.1.0/src/opencr/tests/reference/__init__.py +0 -0
- opencr-0.1.0/src/opencr/tests/reference/test_verification.py +137 -0
- opencr-0.1.0/src/opencr/tests/unit/__init__.py +0 -0
- opencr-0.1.0/src/opencr/tests/unit/test_check_pypi_dependencies.py +158 -0
- opencr-0.1.0/src/opencr/tests/unit/test_cli.py +38 -0
- opencr-0.1.0/src/opencr/tests/unit/test_conditions.py +60 -0
- opencr-0.1.0/src/opencr/tests/unit/test_core.py +270 -0
- opencr-0.1.0/src/opencr/tests/unit/test_data.py +362 -0
- opencr-0.1.0/src/opencr/tests/unit/test_method_cards.py +5 -0
- opencr-0.1.0/src/opencr/tests/unit/test_profiling.py +74 -0
- opencr-0.1.0/src/opencr/tests/unit/test_radiation.py +192 -0
- opencr-0.1.0/src/opencr/tests/unit/test_rates.py +318 -0
- opencr-0.1.0/src/opencr/tests/unit/test_steady.py +209 -0
- opencr-0.1.0/src/opencr/tests/unit/test_system.py +245 -0
- opencr-0.1.0/src/opencr/tests/unit/test_transient.py +161 -0
- opencr-0.1.0/src/opencr/tests/unit/test_units.py +245 -0
- opencr-0.1.0/src/opencr.egg-info/PKG-INFO +196 -0
- opencr-0.1.0/src/opencr.egg-info/SOURCES.txt +84 -0
- opencr-0.1.0/src/opencr.egg-info/dependency_links.txt +1 -0
- opencr-0.1.0/src/opencr.egg-info/entry_points.txt +5 -0
- opencr-0.1.0/src/opencr.egg-info/requires.txt +42 -0
- opencr-0.1.0/src/opencr.egg-info/top_level.txt +1 -0
opencr-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opencr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Collisional-radiative models of low-temperature plasmas: reaction networks with provenance, steady and time-dependent populations, effective rates and emission.
|
|
5
|
+
Author: Max
|
|
6
|
+
Project-URL: Source, https://github.com/max-models/OpenCR
|
|
7
|
+
Keywords: atomic data,collisional-radiative,effective rates,hydrogen,plasma,spectroscopy
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Requires-Dist: methodcard
|
|
19
|
+
Requires-Dist: numpy
|
|
20
|
+
Requires-Dist: plasmacoll>=0.5.0
|
|
21
|
+
Requires-Dist: scipy>=1.10
|
|
22
|
+
Requires-Dist: scope-profiler>=0.7.5
|
|
23
|
+
Requires-Dist: xarray
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: jupyterlab; extra == "dev"
|
|
26
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
27
|
+
Requires-Dist: pyproject-fmt; extra == "dev"
|
|
28
|
+
Requires-Dist: pyright; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff; extra == "dev"
|
|
30
|
+
Requires-Dist: opencr[docs,test]; extra == "dev"
|
|
31
|
+
Provides-Extra: cunumpy
|
|
32
|
+
Requires-Dist: cunumpy>=0.7; extra == "cunumpy"
|
|
33
|
+
Provides-Extra: docs
|
|
34
|
+
Requires-Dist: griffe; extra == "docs"
|
|
35
|
+
Requires-Dist: ipykernel; extra == "docs"
|
|
36
|
+
Requires-Dist: jax; extra == "docs"
|
|
37
|
+
Requires-Dist: kaleido; extra == "docs"
|
|
38
|
+
Requires-Dist: matplotlib>=3.10.9; extra == "docs"
|
|
39
|
+
Requires-Dist: nbclient>=0.11; extra == "docs"
|
|
40
|
+
Requires-Dist: nbformat>=5.11.1; extra == "docs"
|
|
41
|
+
Requires-Dist: plasma-plots[web]; extra == "docs"
|
|
42
|
+
Requires-Dist: scikit-learn; extra == "docs"
|
|
43
|
+
Provides-Extra: jax
|
|
44
|
+
Requires-Dist: jax; extra == "jax"
|
|
45
|
+
Provides-Extra: ml
|
|
46
|
+
Requires-Dist: scikit-learn; extra == "ml"
|
|
47
|
+
Provides-Extra: test
|
|
48
|
+
Requires-Dist: astropy; extra == "test"
|
|
49
|
+
Requires-Dist: jax; extra == "test"
|
|
50
|
+
Requires-Dist: methodcard[symbolic]; extra == "test"
|
|
51
|
+
Requires-Dist: pytest; extra == "test"
|
|
52
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
53
|
+
Requires-Dist: scikit-learn; extra == "test"
|
|
54
|
+
|
|
55
|
+
# opencr
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<!-- README.md is generated from README.qmd: edit the .qmd and run `make readme`. -->
|
|
59
|
+
|
|
60
|
+
[](https://github.com/max-models/OpenCR/actions/workflows/test_pytest.yml)
|
|
61
|
+
[](https://github.com/max-models/OpenCR/actions/workflows/static_analysis.yml)
|
|
63
|
+
[](https://max-models.github.io/OpenCR/)
|
|
64
|
+
[](https://codecov.io/gh/max-models/opencr)
|
|
65
|
+
[](https://pypi.org/project/opencr/)
|
|
66
|
+
[](https://pypi.org/project/opencr/)
|
|
67
|
+
|
|
68
|
+
Collisional-radiative (CR) models of low-temperature plasmas in Python:
|
|
69
|
+
explicit states and reactions with traceable data, steady-state and
|
|
70
|
+
time-dependent population kinetics, effective ionization, recombination
|
|
71
|
+
and emission coefficients, and synthetic spectra. Atomic hydrogen first;
|
|
72
|
+
molecular hydrogen, accelerated backends (cunumpy, JAX) and surrogate
|
|
73
|
+
models are optional extensions. Cross sections and rates come from
|
|
74
|
+
[plasmacoll](https://github.com/max-models/plasmacoll).
|
|
75
|
+
|
|
76
|
+
Documentation: <https://max-models.github.io/OpenCR/>
|
|
77
|
+
|
|
78
|
+
## Example
|
|
79
|
+
|
|
80
|
+
``` python
|
|
81
|
+
import opencr
|
|
82
|
+
|
|
83
|
+
model = opencr.load_model("hydrogen/atomic/basic")
|
|
84
|
+
conditions = opencr.Conditions(
|
|
85
|
+
electron_temperature=2.0, # eV
|
|
86
|
+
electron_density=1e18, # m^-3
|
|
87
|
+
densities={"H(n=1)": 1e19, "H+": 1e18}, # the drivers, m^-3
|
|
88
|
+
)
|
|
89
|
+
result = model.solve_steady_state(conditions)
|
|
90
|
+
result.populations["H(n=3)"] # m^-3
|
|
91
|
+
result.emission().sel(line="A:3-2") # H-alpha
|
|
92
|
+
result.reduction.effective_rate("H(n=1)", "H+") # S_CR, m^3/s
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Every physical setting (temperatures, densities, lengths, times,
|
|
96
|
+
energies, masses) also takes an [astropy](https://www.astropy.org/)
|
|
97
|
+
quantity or a string such as `"300 K"`, as in a configuration file; it
|
|
98
|
+
is converted once to the documented unit (SI, temperatures as kT in eV),
|
|
99
|
+
and a bare number keeps meaning that unit:
|
|
100
|
+
|
|
101
|
+
``` python
|
|
102
|
+
import astropy.units as u
|
|
103
|
+
|
|
104
|
+
conditions = opencr.Conditions(
|
|
105
|
+
electron_temperature="23200 K", # 2.0 eV
|
|
106
|
+
electron_density=1e12 * u.cm**-3, # 1e18 m^-3
|
|
107
|
+
densities={"H(n=1)": "1e13 cm-3", "H+": 1e18}, # a bare number is in m^-3
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The physics, the closures and the units are in [The CR
|
|
112
|
+
model](https://max-models.github.io/OpenCR/guides/model/); the
|
|
113
|
+
acceptance criteria of the atomic hydrogen model in
|
|
114
|
+
[Verification](https://max-models.github.io/OpenCR/guides/verification/).
|
|
115
|
+
|
|
116
|
+
## Install
|
|
117
|
+
|
|
118
|
+
With [uv](https://docs.astral.sh/uv/):
|
|
119
|
+
|
|
120
|
+
``` bash
|
|
121
|
+
make install # uv sync --extra dev, plus the pre-commit hooks
|
|
122
|
+
uv run opencr list
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Or create and activate a Python environment (3.10 or newer):
|
|
126
|
+
|
|
127
|
+
``` bash
|
|
128
|
+
python -m venv env
|
|
129
|
+
source env/bin/activate
|
|
130
|
+
pip install --upgrade pip
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Install the code and requirements with pip:
|
|
134
|
+
|
|
135
|
+
``` bash
|
|
136
|
+
pip install -e .
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The optional extras `cunumpy`, `jax` and `ml` add the accelerated
|
|
140
|
+
backends and the surrogate models; the `test`, `docs` and `dev` extras
|
|
141
|
+
install the test runner, the documentation tooling and the linters:
|
|
142
|
+
|
|
143
|
+
``` bash
|
|
144
|
+
pip install -e ".[dev]"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
Formatting and linting use [ruff](https://docs.astral.sh/ruff/), type
|
|
150
|
+
checking [pyright](https://microsoft.github.io/pyright/), run by
|
|
151
|
+
[pre-commit](https://pre-commit.com/) and in CI:
|
|
152
|
+
|
|
153
|
+
``` bash
|
|
154
|
+
make lint # ruff check, ruff format --check, pyright
|
|
155
|
+
make test # pytest with coverage
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Commit messages follow [Conventional
|
|
159
|
+
Commits](https://www.conventionalcommits.org/); see
|
|
160
|
+
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
161
|
+
|
|
162
|
+
## Build docs
|
|
163
|
+
|
|
164
|
+
The documentation in `docs/` is an Astro + Starlight site: hand-written
|
|
165
|
+
pages, the notebooks in `tutorials/` executed and published as pages,
|
|
166
|
+
complete Python scripts in `examples/` published with their plots, and
|
|
167
|
+
the API reference generated from the docstrings with
|
|
168
|
+
[starlight-pydocs](https://ewels.github.io/starlight-pydocs/). It needs
|
|
169
|
+
Node 22 or newer.
|
|
170
|
+
|
|
171
|
+
``` bash
|
|
172
|
+
make docs-install # npm packages and the Python docs extra
|
|
173
|
+
make docs-notebooks # execute tutorials/*.ipynb and convert them to pages
|
|
174
|
+
make docs-examples # run examples/*.py and publish their plots
|
|
175
|
+
make docs-dev # live preview at http://localhost:4321/OpenCR/
|
|
176
|
+
make docs-build # the static site in docs/dist
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Build the README
|
|
180
|
+
|
|
181
|
+
`README.md` is rendered from `README.qmd` with
|
|
182
|
+
[Quarto](https://quarto.org/):
|
|
183
|
+
|
|
184
|
+
``` bash
|
|
185
|
+
make readme
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Releases
|
|
189
|
+
|
|
190
|
+
Before merging a release to `main`, update the version in
|
|
191
|
+
`pyproject.toml`, `src/opencr/__init__.py` and `CITATION.cff` (including
|
|
192
|
+
its release date), and add the release notes to `CHANGELOG.md`. The push
|
|
193
|
+
to `main` creates a GitHub release with a `vX.Y.Z` tag and publishes the
|
|
194
|
+
package to PyPI with trusted publishing (OIDC). The one-time PyPI and
|
|
195
|
+
GitHub configuration is described in the [publishing
|
|
196
|
+
tutorial](https://max-models.github.io/OpenCR/development/publishing/).
|
opencr-0.1.0/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# opencr
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<!-- README.md is generated from README.qmd: edit the .qmd and run `make readme`. -->
|
|
5
|
+
|
|
6
|
+
[](https://github.com/max-models/OpenCR/actions/workflows/test_pytest.yml)
|
|
7
|
+
[](https://github.com/max-models/OpenCR/actions/workflows/static_analysis.yml)
|
|
9
|
+
[](https://max-models.github.io/OpenCR/)
|
|
10
|
+
[](https://codecov.io/gh/max-models/opencr)
|
|
11
|
+
[](https://pypi.org/project/opencr/)
|
|
12
|
+
[](https://pypi.org/project/opencr/)
|
|
13
|
+
|
|
14
|
+
Collisional-radiative (CR) models of low-temperature plasmas in Python:
|
|
15
|
+
explicit states and reactions with traceable data, steady-state and
|
|
16
|
+
time-dependent population kinetics, effective ionization, recombination
|
|
17
|
+
and emission coefficients, and synthetic spectra. Atomic hydrogen first;
|
|
18
|
+
molecular hydrogen, accelerated backends (cunumpy, JAX) and surrogate
|
|
19
|
+
models are optional extensions. Cross sections and rates come from
|
|
20
|
+
[plasmacoll](https://github.com/max-models/plasmacoll).
|
|
21
|
+
|
|
22
|
+
Documentation: <https://max-models.github.io/OpenCR/>
|
|
23
|
+
|
|
24
|
+
## Example
|
|
25
|
+
|
|
26
|
+
``` python
|
|
27
|
+
import opencr
|
|
28
|
+
|
|
29
|
+
model = opencr.load_model("hydrogen/atomic/basic")
|
|
30
|
+
conditions = opencr.Conditions(
|
|
31
|
+
electron_temperature=2.0, # eV
|
|
32
|
+
electron_density=1e18, # m^-3
|
|
33
|
+
densities={"H(n=1)": 1e19, "H+": 1e18}, # the drivers, m^-3
|
|
34
|
+
)
|
|
35
|
+
result = model.solve_steady_state(conditions)
|
|
36
|
+
result.populations["H(n=3)"] # m^-3
|
|
37
|
+
result.emission().sel(line="A:3-2") # H-alpha
|
|
38
|
+
result.reduction.effective_rate("H(n=1)", "H+") # S_CR, m^3/s
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Every physical setting (temperatures, densities, lengths, times,
|
|
42
|
+
energies, masses) also takes an [astropy](https://www.astropy.org/)
|
|
43
|
+
quantity or a string such as `"300 K"`, as in a configuration file; it
|
|
44
|
+
is converted once to the documented unit (SI, temperatures as kT in eV),
|
|
45
|
+
and a bare number keeps meaning that unit:
|
|
46
|
+
|
|
47
|
+
``` python
|
|
48
|
+
import astropy.units as u
|
|
49
|
+
|
|
50
|
+
conditions = opencr.Conditions(
|
|
51
|
+
electron_temperature="23200 K", # 2.0 eV
|
|
52
|
+
electron_density=1e12 * u.cm**-3, # 1e18 m^-3
|
|
53
|
+
densities={"H(n=1)": "1e13 cm-3", "H+": 1e18}, # a bare number is in m^-3
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The physics, the closures and the units are in [The CR
|
|
58
|
+
model](https://max-models.github.io/OpenCR/guides/model/); the
|
|
59
|
+
acceptance criteria of the atomic hydrogen model in
|
|
60
|
+
[Verification](https://max-models.github.io/OpenCR/guides/verification/).
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
With [uv](https://docs.astral.sh/uv/):
|
|
65
|
+
|
|
66
|
+
``` bash
|
|
67
|
+
make install # uv sync --extra dev, plus the pre-commit hooks
|
|
68
|
+
uv run opencr list
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or create and activate a Python environment (3.10 or newer):
|
|
72
|
+
|
|
73
|
+
``` bash
|
|
74
|
+
python -m venv env
|
|
75
|
+
source env/bin/activate
|
|
76
|
+
pip install --upgrade pip
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Install the code and requirements with pip:
|
|
80
|
+
|
|
81
|
+
``` bash
|
|
82
|
+
pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The optional extras `cunumpy`, `jax` and `ml` add the accelerated
|
|
86
|
+
backends and the surrogate models; the `test`, `docs` and `dev` extras
|
|
87
|
+
install the test runner, the documentation tooling and the linters:
|
|
88
|
+
|
|
89
|
+
``` bash
|
|
90
|
+
pip install -e ".[dev]"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
Formatting and linting use [ruff](https://docs.astral.sh/ruff/), type
|
|
96
|
+
checking [pyright](https://microsoft.github.io/pyright/), run by
|
|
97
|
+
[pre-commit](https://pre-commit.com/) and in CI:
|
|
98
|
+
|
|
99
|
+
``` bash
|
|
100
|
+
make lint # ruff check, ruff format --check, pyright
|
|
101
|
+
make test # pytest with coverage
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Commit messages follow [Conventional
|
|
105
|
+
Commits](https://www.conventionalcommits.org/); see
|
|
106
|
+
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
107
|
+
|
|
108
|
+
## Build docs
|
|
109
|
+
|
|
110
|
+
The documentation in `docs/` is an Astro + Starlight site: hand-written
|
|
111
|
+
pages, the notebooks in `tutorials/` executed and published as pages,
|
|
112
|
+
complete Python scripts in `examples/` published with their plots, and
|
|
113
|
+
the API reference generated from the docstrings with
|
|
114
|
+
[starlight-pydocs](https://ewels.github.io/starlight-pydocs/). It needs
|
|
115
|
+
Node 22 or newer.
|
|
116
|
+
|
|
117
|
+
``` bash
|
|
118
|
+
make docs-install # npm packages and the Python docs extra
|
|
119
|
+
make docs-notebooks # execute tutorials/*.ipynb and convert them to pages
|
|
120
|
+
make docs-examples # run examples/*.py and publish their plots
|
|
121
|
+
make docs-dev # live preview at http://localhost:4321/OpenCR/
|
|
122
|
+
make docs-build # the static site in docs/dist
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Build the README
|
|
126
|
+
|
|
127
|
+
`README.md` is rendered from `README.qmd` with
|
|
128
|
+
[Quarto](https://quarto.org/):
|
|
129
|
+
|
|
130
|
+
``` bash
|
|
131
|
+
make readme
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Releases
|
|
135
|
+
|
|
136
|
+
Before merging a release to `main`, update the version in
|
|
137
|
+
`pyproject.toml`, `src/opencr/__init__.py` and `CITATION.cff` (including
|
|
138
|
+
its release date), and add the release notes to `CHANGELOG.md`. The push
|
|
139
|
+
to `main` creates a GitHub release with a `vX.Y.Z` tag and publishes the
|
|
140
|
+
package to PyPI with trusted publishing (OIDC). The one-time PyPI and
|
|
141
|
+
GitHub configuration is described in the [publishing
|
|
142
|
+
tutorial](https://max-models.github.io/OpenCR/development/publishing/).
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
build-backend = "setuptools.build_meta"
|
|
3
|
+
requires = [ "setuptools", "wheel" ]
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "opencr"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Collisional-radiative models of low-temperature plasmas: reaction networks with provenance, steady and time-dependent populations, effective rates and emission."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = [ "atomic data", "collisional-radiative", "effective rates", "hydrogen", "plasma", "spectroscopy" ]
|
|
11
|
+
authors = [ { name = "Max" } ]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
22
|
+
]
|
|
23
|
+
# PyPI rejects direct references (name @ git+...), so only version ranges go here; the
|
|
24
|
+
# max-models packages come from their devel branches through [tool.uv.sources]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"methodcard",
|
|
27
|
+
"numpy",
|
|
28
|
+
"plasmacoll>=0.5.0",
|
|
29
|
+
"scipy>=1.10",
|
|
30
|
+
"scope-profiler>=0.7.5",
|
|
31
|
+
"xarray",
|
|
32
|
+
]
|
|
33
|
+
optional-dependencies.dev = [
|
|
34
|
+
"jupyterlab",
|
|
35
|
+
"pre-commit",
|
|
36
|
+
"pyproject-fmt",
|
|
37
|
+
"pyright",
|
|
38
|
+
"ruff",
|
|
39
|
+
"opencr[docs,test]",
|
|
40
|
+
]
|
|
41
|
+
optional-dependencies.cunumpy = [ "cunumpy>=0.7" ]
|
|
42
|
+
optional-dependencies.docs = [
|
|
43
|
+
"griffe",
|
|
44
|
+
"ipykernel",
|
|
45
|
+
"jax",
|
|
46
|
+
"kaleido",
|
|
47
|
+
"matplotlib>=3.10.9",
|
|
48
|
+
"nbclient>=0.11",
|
|
49
|
+
"nbformat>=5.11.1",
|
|
50
|
+
# the figures of the tutorials and examples, as web figures
|
|
51
|
+
"plasma-plots[web]",
|
|
52
|
+
"scikit-learn",
|
|
53
|
+
]
|
|
54
|
+
optional-dependencies.jax = [ "jax" ]
|
|
55
|
+
optional-dependencies.ml = [ "scikit-learn" ]
|
|
56
|
+
optional-dependencies.test = [ "astropy", "jax", "methodcard[symbolic]", "pytest", "pytest-cov", "scikit-learn" ]
|
|
57
|
+
urls.Source = "https://github.com/max-models/OpenCR"
|
|
58
|
+
scripts.opencr = "opencr.cli:main"
|
|
59
|
+
|
|
60
|
+
[project.entry-points."scope_profiler.opt_in_tags"]
|
|
61
|
+
opencr = "opencr"
|
|
62
|
+
|
|
63
|
+
[tool.setuptools]
|
|
64
|
+
package-data."*" = [ "py.typed" ]
|
|
65
|
+
packages.find.where = [ "src" ]
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
target-version = "py310"
|
|
69
|
+
line-length = 88
|
|
70
|
+
extend-include = [ "*.ipynb" ]
|
|
71
|
+
# pycodestyle, pyflakes, isort, pyupgrade, bugbear and pydocstyle
|
|
72
|
+
lint.select = [ "B", "D", "E", "F", "I", "UP", "W" ]
|
|
73
|
+
lint.ignore = [ "E501" ] # line length is handled by the formatter
|
|
74
|
+
lint.per-file-ignores."**/tests/**" = [ "D" ]
|
|
75
|
+
lint.per-file-ignores."*.ipynb" = [ "D" ]
|
|
76
|
+
lint.per-file-ignores."docs/tools/*" = [ "D" ]
|
|
77
|
+
lint.pydocstyle.convention = "google"
|
|
78
|
+
|
|
79
|
+
[tool.pyright]
|
|
80
|
+
include = [ "src" ]
|
|
81
|
+
exclude = [ "**/tests" ]
|
|
82
|
+
pythonVersion = "3.10"
|
|
83
|
+
typeCheckingMode = "standard"
|
|
84
|
+
|
|
85
|
+
[tool.pytest]
|
|
86
|
+
ini_options.pythonpath = [ "src" ]
|
|
87
|
+
ini_options.testpaths = [ "src" ]
|
|
88
|
+
ini_options.addopts = "-ra"
|
|
89
|
+
ini_options.markers = [ "convergence: an order-of-accuracy test of a method card" ]
|
|
90
|
+
|
|
91
|
+
[tool.coverage]
|
|
92
|
+
run.omit = [ "*/tests/*" ]
|
|
93
|
+
run.source = [ "opencr" ]
|
|
94
|
+
report.show_missing = true
|
|
95
|
+
|
|
96
|
+
# PRs to devel test against the devel branches of the max-models packages (pinned in
|
|
97
|
+
# uv.lock); PRs to main and the release use PyPI only (CI sets UV_NO_SOURCES).
|
|
98
|
+
[tool.uv.sources]
|
|
99
|
+
# one entry per max-models package in [project], spelled exactly like this in every repo:
|
|
100
|
+
cunumpy = { git = "https://github.com/max-models/cunumpy", branch = "devel" }
|
|
101
|
+
methodcard = { git = "https://github.com/max-models/methodcard", branch = "devel" }
|
|
102
|
+
plasma-plots = { git = "https://github.com/max-models/plasma-plots", branch = "devel" }
|
|
103
|
+
plasmacoll = { git = "https://github.com/max-models/plasmacoll", branch = "devel" }
|
|
104
|
+
scope-profiler = { git = "https://github.com/max-models/scope-profiler", branch = "devel" }
|
opencr-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""OpenCR: collisional-radiative models of low-temperature plasmas.
|
|
2
|
+
|
|
3
|
+
OpenCR builds collisional-radiative (CR) models from explicit states and
|
|
4
|
+
reactions with traceable data, and solves their population equations: steady
|
|
5
|
+
states, quasi-static excited states with effective rate coefficients, and time
|
|
6
|
+
evolution. The physics is defined independently of the numerical backend; the
|
|
7
|
+
reference implementation uses NumPy and SciPy, cunumpy and JAX are optional.
|
|
8
|
+
Cross sections and Maxwellian rates come from `plasmacoll`.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
12
|
+
|
|
13
|
+
import scope_profiler as sp
|
|
14
|
+
|
|
15
|
+
from opencr._profiling import PROFILE_TAGS
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
__version__ = version("opencr")
|
|
19
|
+
except PackageNotFoundError: # not installed, e.g. run from a source tree
|
|
20
|
+
__version__ = "0.0.0+unknown"
|
|
21
|
+
|
|
22
|
+
from opencr.analysis.results import Result
|
|
23
|
+
from opencr.analysis.scan import scan
|
|
24
|
+
from opencr.core.conditions import Conditions, RadiationTrapping
|
|
25
|
+
from opencr.model import Model
|
|
26
|
+
from opencr.models import available_models, load_model
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"Conditions",
|
|
30
|
+
"Model",
|
|
31
|
+
"RadiationTrapping",
|
|
32
|
+
"Result",
|
|
33
|
+
"available_models",
|
|
34
|
+
"load_model",
|
|
35
|
+
"scan",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
# The decorated functions pick the tag up, so registering after the imports is in time.
|
|
39
|
+
sp.register_opt_in_tag(*PROFILE_TAGS)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""The scope-profiler tag of opencr's profiling regions.
|
|
2
|
+
|
|
3
|
+
The regions are opt-in: `opencr` registers the tag on import, so they
|
|
4
|
+
record nothing unless the application enables it, e.g. with
|
|
5
|
+
``scope_profiler.setup(enable_tags=["opencr"])``.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
#: Tags of every opencr region; the first is the opt-in tag.
|
|
9
|
+
PROFILE_TAGS = ("opencr",)
|