Skip to main content

Documentation Status PyPI version pre-commit

PyMCNP

PyMCNP supports running Monte Carlo N-Particle (MCNP) simulations. It parses MCNP files, enabling automation such as parameter scans, creates MCNP geometry visualization using pyvista. PyMCNP provides a Python API for MCNP input and output files and a command line interface for interacting with MCNP and MCNP files.

Find more information on ReadTheDocs.

Installation

PyMCNP is available on PyPI and can be "pip installed":

pip install pymcnp

PyMCNP supports MCNP 6.1 to 6.3 and Python 3.11 to 3.15. MCNP itself is not included: get it from RSICC. pymcnp run starts it as mcnp6 from your PATH (-c names another command), and MCNP finds its nuclear data through DATAPATH. Everything except running MCNP works without it.

PyMCNP reads MCNP input files (INP), output files (OUTP), mesh tally files (MESHTAL), and ASCII particle track files (PTRAC, written with PTRAC FILE=ASC). It does not read MCTAL files or binary PTRAC files.

New to PyMCNP? Getting Started walks through checking, editing, visualizing, and running an input and reading its results.

Example

Read an input file, scan the radius of a sphere, and write one input file per radius; then read the output of a run:

import pymcnp

inp, rest = pymcnp.Inp.from_file('example_00.inp')
assert rest == ''  # The remainder is the text PyMCNP could not parse.
for i, copy in enumerate(inp.scan_with([500, 600, 700], lambda inp, r: setattr(inp.surface_cards(99)[0], 'r', r))):
    copy.to_file(f'sphere-{i}.inp')

outp, _ = pymcnp.Outp.from_file('example_00.outp')
print(outp.summary.ok, outp.summary.checks_passed)  # Did MCNP finish, and did the tallies pass the statistical checks?
print(outp.tally(1))  # Tally 1 as a pandas dataframe

The command line interface checks, runs, converts, plots, and visualizes MCNP files, e.g.:

pymcnp check example_00.inp
pymcnp run --command=mcnp6 sphere-*.inp
pymcnp convert outp --csv example_00.outp
pymcnp visualize example_00.inp

The files are in the examples directory, which has many more examples.

Automation with AI Coding Agents

PyMCNP ships a skill file, SKILL.md, that describes the API, the parsing contract, and the common pitfalls to an AI coding agent such as Claude Code. With the skill installed, an agent can write, scan, run, and plot MCNP models for you from a short description, so automating MCNP becomes easy even for complex geometries. For Claude Code, save it as ~/.claude/skills/pymcnp/SKILL.md (all your projects) or .claude/skills/pymcnp/SKILL.md (one project), taking the version that matches your installed PyMCNP:

v=$(pymcnp --version | cut -d' ' -f2)
mkdir -p ~/.claude/skills/pymcnp
curl -fsSL "https://raw.githubusercontent.com/FSIBT/PyMCNP/v$v/SKILL.md" -o ~/.claude/skills/pymcnp/SKILL.md

Using PyMCNP with AI agents explains how to check that it loaded, how to use it with other agents, and what to ask. The example on ReadTheDocs, 441 iron discs over a rough concrete floor with a flux plot, was created this way from a short prompt. Always review generated models and results before relying on them.

Contributing

PyMCNP welcomes contributions, including issues, pull requests, and MCNP files that PyMCNP fails to parse or visualize.

For more information, see the CONTRIBUTING.md file.

For copyright and license information, see the COPYRIGHT and LICENSE files.

Metadata

Release files for pymcnp 1.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 pymcnp 1.1.0
File Size Uploaded Provenance Actions
pymcnp-1.1.0.tar.gz 5.4 MB With provenance Details for pymcnp-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 5.9 MB

Release files / pymcnp-1.1.0.tar.gz

Download URL pymcnp-1.1.0.tar.gz
Size 5.4 MB
Tags Source
SHA-256 checksum
How to use checksums
25e2fa71c964aa7fb8fd210048938bd9ff0f98957080483e4e6e71a7dd76cf4a
BLAKE2b-256 checksum
How to use checksums
95bc16efef2cc3e151a28c8e0c964dc1bccfe155e6f64238f40cfe69f4925f70
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 27, 2026.

Transparency log

Release files / pymcnp-1.1.0-py3-none-any.whl

Download URL pymcnp-1.1.0-py3-none-any.whl
Size 431.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
392223d047f56f8229af51b4b2e61ac8da29b46fdce07f512234fc666e2692e0
BLAKE2b-256 checksum
How to use checksums
8e6a23e122d49191b8595403440eeb432b7de2f2acb7c6fa3dfbfdc2c07ca069
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 27, 2026.

Transparency log

Security for pymcnp 1.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 pymcnp-1.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 27, 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.

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