Skip to main content

plasmacoll

Tests Static analysis Docs codecov PyPI Python

Null-collision Monte Carlo collisions (MCC) of charged particles with neutral gases, on NumPy or CuPy arrays. It is the collision step of a particle-in-cell code, or with ZeroDReactor a homogeneous reactor for testing cross-section sets.

  • Processes: elastic, backscatter (resonant charge exchange), excitation, ionization, attachment, detachment and charge transfer, against Maxwellian neutral gases that are uniform or have a density profile.
  • Cross sections: from text tables, LXCat files or functions. Also Maxwell molecules for benchmarks, and population-weighted mixtures of level-resolved tables, e.g. H₂(v) dissociative attachment.
  • Plain arrays: markers are positions, velocities and weights. Any particle container with those plugs in, and cunumpy runs the same code on CPU (NumPy) or GPU (CuPy).
  • Validated: a 0D reactor reproduces the closed-form relaxation, growth and decay rates of Maxwell-molecule gases. The tests run on NumPy and on a CuPy stand-in, with 100 % combined coverage.

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

Electron, H₂⁺ and H⁻ densities in a 0D reactor against the analytic growth rate

Install

pip install plasmacoll

Example

import plasmacoll
from plasmacoll.constants import ATOMIC_MASS, ELECTRON_MASS, ev_to_kelvin

argon_mass = 39.95 * ATOMIC_MASS
argon_gas = plasmacoll.NeutralBackground(
    "Ar", density=1e21, temperature=300.0, mass=argon_mass
)

elastic_xs = plasmacoll.CrossSection.constant(1e-19)
ionization_xs = plasmacoll.CrossSection.constant(3e-20, threshold=15.76)
elastic = plasmacoll.CollisionProcess("elastic", "Ar", elastic_xs, energy_frame="lab")
ionization = plasmacoll.CollisionProcess(
    "ionization",
    "Ar",
    ionization_xs,
    energy_frame="lab",
    products={"electron": "e", "ion": "Ar+"},
)

mcc = plasmacoll.MonteCarloCollisions(
    species_masses={"e": ELECTRON_MASS, "Ar+": argon_mass},
    backgrounds=[argon_gas],
    processes={"e": [elastic, ionization]},
    seed=1,
)

temperature = ev_to_kelvin(10.0)
electrons = plasmacoll.ParticleArrays.maxwellian(
    100_000, ELECTRON_MASS, temperature, seed=2
)
reactor = plasmacoll.ZeroDReactor(mcc, {"e": electrons}, volume=1e-6)
history = reactor.run(dt=1e-11, num_steps=500, every=10)
print(history.density["Ar+"][-1], history.collisions["ionization:Ar"][-1])

In a particle-in-cell code, call mcc.collide(species, positions, velocities, weights, dt) on arrays, or mcc.collide_species({...}, dt) on your own particle containers. See Use in a particle-in-cell code.

plasmacoll does not ship cross-section data. Load tables from LXCat or the literature with plasmacoll.read_lxcat and CrossSection.from_table.

Development

With uv:

make install    # uv sync --extra dev, plus the pre-commit hooks
make test       # pytest with coverage on NumPy
make test-cupy  # the same tests on cunumpy's stand-in for CuPy (no GPU needed)
make coverage   # both runs combined, must be 100 %
make lint       # ruff check, ruff format --check, pyright, ty

Commit messages follow Conventional Commits.

Build docs

The documentation in docs/ is an Astro + Starlight site: hand-written guides, the notebooks in tutorials/ executed and published as pages, and the API reference generated from the docstrings. 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-dev         # live preview at http://localhost:4321/plasmacoll/
make docs-build       # the static site in docs/dist

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

Releases

Before merging a release to main, update the version in pyproject.toml and src/plasmacoll/__init__.py, 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). See the publishing guide.

Metadata

Release files for plasmacoll 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 plasmacoll 0.1.0
File Size Uploaded
plasmacoll-0.1.0.tar.gz 46.0 kB Details

Built distribution (wheel)

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

Total release size: 99.6 kB

Release files / plasmacoll-0.1.0.tar.gz

Download URL plasmacoll-0.1.0.tar.gz
Size 46.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5e12062f3214febd2b6805f9fe11f58840edbc03dbd556f8ab55d1dba095dfca
BLAKE2b-256 checksum
How to use checksums
c0ead7509903fcf98e2814ef80c18e8232c034c3df8d92f7e5cc8d002e4c50a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

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

Download URL plasmacoll-0.1.0-py3-none-any.whl
Size 53.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
416b28d01353c382aaf267856138e15678eedaa0bddc6bae160b647bca46b187
BLAKE2b-256 checksum
How to use checksums
c3336aaa4ecb3a4f58da6d04daa6e8d3e7117550fef50d6153a48802eef9f5c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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