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, optionally in an electric field, for testing cross-section sets.

  • Processes: elastic, backscatter (resonant charge exchange), excitation, ionization (electron and ion impact), attachment, detachment, charge transfer, dissociation, dissociative attachment and dissociative ionization. Isotropic or forward-peaked (Vahedi–Surendra, Okhrimovskyy) scattering, and equal, uniform or Opal–Peterson–Beaty energy sharing. Fast neutrals and fragments can be tracked as species.
  • Neutral gases: drifting Maxwellians with density and temperature profiles, replaceable between steps for gas heating or depletion.
  • Cross sections: from text tables, LXCat files (with EFFECTIVE sets converted to elastic) 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). Markers can be merged and split, conserving weight, momentum and energy.
  • Validated: a 0D reactor reproduces the closed-form relaxation, growth and decay rates of Maxwell-molecule gases, and the drift velocity and Wannier energy of a swarm in a field. The tests run on NumPy and on a CuPy stand-in, with 100 % combined coverage.

Collisions between charged particles (Coulomb collisions, recombination) are out of scope: the collision partners are always neutral gases.

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.2.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.2.0
File Size Uploaded Provenance
plasmacoll-0.2.0.tar.gz 71.2 kB With provenance Details

Built distribution (wheel)

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

Total release size: 156.7 kB

Release files / plasmacoll-0.2.0.tar.gz

Download URL plasmacoll-0.2.0.tar.gz
Size 71.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0dc4b3bfc1ef720b5d1aa1e6590ed8bca3eebbca2d3888da1a95f341c771a19a
BLAKE2b-256 checksum
How to use checksums
4f9ed0b809c569e0d33a124b21df7492ea1c22b32ff0f65327a9013481d1bc8d
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 20, 2026.

Transparency log

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

Download URL plasmacoll-0.2.0-py3-none-any.whl
Size 85.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c90da42b37af61ceacd761e9ee18e63f260ac9fdaebeec0360256347a7fe80e
BLAKE2b-256 checksum
How to use checksums
75f4a5e2164ce962d05059bc78e00f369f8605f874227b8558d3fdddea03e8eb
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 20, 2026.

Transparency log

Security for plasmacoll 0.2.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for plasmacoll-0.2.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 Oct 20, 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.

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