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 PyPI version Project Status: Active – The project has reached a stable, usable state and is being actively developed.

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("foo.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.univeres.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.

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.

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.0.tar.gz (189.3 kB view details)

Uploaded Source

Built Distribution

montepy-0.5.0-py3-none-any.whl (140.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: montepy-0.5.0.tar.gz
  • Upload date:
  • Size: 189.3 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.0.tar.gz
Algorithm Hash digest
SHA256 7f1d20c670da369c8fa9a930538592b0d660b69dac7d757d30405f388fce46ca
MD5 f319241584f17ae2aeaf36fab97f48a7
BLAKE2b-256 d8184626c14c059dd2ccba1697059085fcef17508228c9fbc33ba3fdfc048044

See more details on using hashes here.

File details

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

File metadata

  • Download URL: montepy-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 140.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09c7ca5b3ab307eadcb1f7554aee3f21798ac4ecd203245f367a07568593b5b7
MD5 a9ac26de2627532470ce1dba014af693
BLAKE2b-256 fb8690883e742a41779e515158a128b5d92d83f31009d95c3c72234e56d248c1

See more details on using hashes here.

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