Skip to main content

A library for reading, editing, and writing MCNP input files

Project description

MontePy

MontePY: a cute snek on a red over white circle

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

PyPI version Docs Deployment PyPI pyversions

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")

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.

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 becuase, they do not utilize context-free parsing (as of 2024). These packages are:

The only other library that does utilize context-free parsing that we are aware is MCNP™y. MontePy differs by being:

  • On PyPI, and can be installed via pip.
  • Only requires a python interpreter, and not a Java virtual machine.
  • Allowing contributions from anyone with a public GitHub account

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

For citing MontePy in a publication a Journal of Open Source Software article is under review. In the meantime there is a DOI for the software from OSTI: DOI:10.11578/dc.20240115.1.

You can cite MontePy as:

M. Gale, T. Labossiere-Hickman, B. Carbno, A. Bascom, and MontePy contributors, "MontePy", 2024, doi: 10.11578/dc.20240115.1.

Finally: make objects, not regexes!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

montepy-0.5.2.tar.gz (193.1 kB view details)

Uploaded Source

Built Distribution

montepy-0.5.2-py3-none-any.whl (142.8 kB view details)

Uploaded Python 3

File details

Details for the file montepy-0.5.2.tar.gz.

File metadata

  • Download URL: montepy-0.5.2.tar.gz
  • Upload date:
  • Size: 193.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for montepy-0.5.2.tar.gz
Algorithm Hash digest
SHA256 9f59abf4e83fca515a6beddf6bbddec253cfc84469a2df1500d0dd4537084579
MD5 d10aff452f1c81a99d008ad6254d54f5
BLAKE2b-256 cdd69ff103aaf35bafdda4e227c2fd966361156ee05a3a759890e77960267e92

See more details on using hashes here.

Provenance

The following attestation bundles were made for montepy-0.5.2.tar.gz:

Publisher: deploy.yml on idaholab/MontePy

Attestations:

File details

Details for the file montepy-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: montepy-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 142.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for montepy-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 59ce8fbfea192c1b93c373b56097066bc0b6d6b525e7cd79e5211b1d033a1be6
MD5 b23f146b8c6b916c1ff184cb1199d91e
BLAKE2b-256 bf498ed4e082bd37f19c0ae633cab137ea981138bda68fb503913aad5c7dcfbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for montepy-0.5.2-py3-none-any.whl:

Publisher: deploy.yml on idaholab/MontePy

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page