Skip to main content

MontePy

MontePY: a cute snek on a red over white circle

license JOSS article status pyOpenSci Peer-Reviewed Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Coverage Status Testing status Docs Deployment

PyPI version Conda Version PyPI pyversions SPEC 0 — Minimum Supported Dependencies

DOI

MontePy is the most user-friendly Python library for reading, editing, and writing MCNP input files.

Installing

Simply run:

pip install montepy

For more complicated setups see the Installing section in the user guide.

User Documentation

MontePy has a website documenting how to work with MCNP in python with MontePy. The website contains a user's guide for getting started, a developer's guide covering the design and approach of MontePy, instructions for contributing, and the Python API documentation.

Features

Here is a quick example showing multiple tasks in MontePy:

import montepy
# read in file
problem = montepy.read_input("tests/inputs/test.imcnp")
  
# set photon importance for multiple cells
importances = {1: 0.005,
   2: 0.1,
   3: 1.0,
   99: 1.235
}
for cell_num, importance in importances.items():
   problem.cells[cell_num].importance.photon = importance

#create a universe and fill another cell with it
universe = montepy.Universe(123)
problem.universes.append(universe)
# add all cells with numbers between 1 and 4
universe.claim(problem.cells[1:5])
# fill cell 99 with universe 123
problem.cells[99].fill.universe = universe

# update all surfaces numbers by adding 1000 to them
for surface in problem.surfaces:
   surface.number += 1000
# all cells using these surfaces will be automatically updated as well

#write out an updated file
problem.write_problem("foo_update.imcnp")

For more examples see the getting started guide.

Use Cases

Here are some possible use cases for MontePy:

  • Automated updating of an MCNP input file, or MCNP deck, for reactor reconfiguration, fuel shuffling, etc.
  • Parameterizing an MCNP input file to check for explore the parametric space of your MCNP modeling problem
  • Updating an MCNP model with the results from another code, such as depletion results from ORIGEN.
  • To convert an MCNP model to another Monte Carlo code like OpenMC, SERPENT, etc.

Limitations

Here a few of the known bugs and limitations:

  • Cannot handle vertical input mode.
  • Does not support editing tallies in a user-friendly way.
  • Does not support editing source definition in a user-friendly way.
  • Cannot parse all valid material definitions. There is a known bug (#182) that MontePy can only parse materials where all keyword-value pairs show up after the nuclide definitions. For example:
    • M1 1001.80c 1.0 plib=80p can be parsed.
    • M1 plib=80p 1001.80c 1.0 cannot be parsed; despite it being a valid input.

Current Development Priorities

Here are the rough development priorities for adding new features to MontePy:

  1. Improve performance for the intial loading of models.
  2. Implement support for tallies.
  3. Implement support for source definitions.

If you have a specific feature priority that you would be willing to collaborate on you can open an issue or email us at mgale@montepy.org.

Alternatives

There are some python packages that offer some of the same features as MontePy, but don't offer the same level of robustness, ease of installation, and user friendliness.

Many of the competitors do not offer the robustness that MontePy does because, they do not utilize context-free parsing (as of 2024). These packages are:

The only other libraries that do utilize context-free parsing that we are aware of are:

MontePy differs from MCNPy by being:

  • On PyPI and conda-forge, and able to be installed via pip or conda
  • Only requiring a Python interpreter and not a Java virtual machine
  • Allowing contributions from anyone with a public GitHub account

MontePy differs from mckit by being:

  • Thoroughly documented
  • Object-oriented

For only writing, or templating an input file there are also some great tools out there. These packages don't provide the same functionality as MontePy inherently, but could be the right tool for the job depending on the user's needs.

Another honorable mention that doesn't replicate the features of MontePy, but could be a great supplement to MontePy for defining materials, performing activations, etc. is PyNE --- the Nuclear Engineering Toolkit.

Bugs, Requests and Development

So MontePy doesn't do what you want? Add an issue here with the "feature request" tag. The system is very modular and you should be able to develop it pretty quickly. Read the developer's guide for more details. If you have any questions feel free to ask @micahgale.

Citation

You can cite MontePy as:

Gale et al., (2025). MontePy: a Python library for reading, editing, and writing MCNP input files. Journal of Open Source Software, 10(108), 7951, https://doi.org/10.21105/joss.07951

Finally: make objects, not regexes!

Metadata

Release files for montepy 1.5.1

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

Source distribution (sdist)

Source distribution for montepy 1.5.1
File Size Uploaded Provenance Actions
montepy-1.5.1.tar.gz 283.0 kB With provenance Details for montepy-1.5.1.tar.gz

Built distribution (wheel)

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

Total release size: 475.3 kB

Release files / montepy-1.5.1.tar.gz

Download URL montepy-1.5.1.tar.gz
Size 283.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0b5b9038965649f391920321b17966b56001ed8fc8b50a6d40303947d6c87b2e
BLAKE2b-256 checksum
How to use checksums
be470c5dc09e280623f56abed7f3f657fbc6495a61b8c53eba2b89be83881844
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 15, 2026.

Transparency log

Release files / montepy-1.5.1-py3-none-any.whl

Download URL montepy-1.5.1-py3-none-any.whl
Size 192.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f18569fa155eeec01ec8e22736f739ca9dc4585e6049f6d1b8c14c7eb33bf225
BLAKE2b-256 checksum
How to use checksums
b0355659c82811651165359b0e030ab019162ce502b0c7511cf541d37dd27908
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 15, 2026.

Transparency log

Security for montepy 1.5.1

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 montepy-1.5.1.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 15, 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

1.5.1 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