MontePy: a Python Library for Reading, Editing, and Writing MCNP Input Files
Journal Article
·
· Journal of Open Source Software
- Idaho National Laboratory
The Monte Carlo N-Particle (MCNP) radiation transport code is a highly capable and accurate code with a long legacy. Its origins in the mid-twentieth century predate many modern software conventions. MCNP users provide an input file to MCNP, which then it uses to create an internal representation of the simulation problem. These input files originally had to be stored as punchcard decks, and the user manual still uses the terminology of cards and decks. MCNP predates nearly all modern human readable markup or data serialization languages, such as the extensible markup language (XML), the standard generalized markup lanuage (SGML), YAML ain't markup language (YAML), and javascript object notation (JSON). Due to this, MCNP uses an entirely custom defined syntax language for its input, making off the shelf libraries for XML, YAML, and JSON impossible to use for scripting various operations on MCNP input files. MCNP simulation problems use three-dimensional constructive solid geometry (CSG). The simulation's is composed of a series of cells. These cells have assigned densities, as well as being linked to a material definition. These materials define the relative amounts of different isotopes in the material, and can be shared between cells. The cell geometry in CSG is defined by a series of Boolean set operations of geometry primitives, which are usually quadratic surfaces. For instance a cylindrical pellet's geometry could be defined as the inside of an infinite cylinder, and being above a bottom plane, and being below a top plane. MontePy is a python library for reading, editing, and writing these MNCP input files. It provides an object-oriented programming (OOP) interface for interacting with the simulation problems. MontePy does not perform any of its own radiation transport, or neutronics calculations. MontePy uses a syntax parser built on top of the Python package for parsers: SLY. This parser builds a concrete syntax tree of the input file. This allows MontePy to parse the input file without losing any information or formatting. The MontePy objects that represent MCNP objects such as: cells, surfaces, materials, etc., crawl through this syntax tree and update their internal values to reflect this tree. These attributes will then be exposed to the user as properties. Once a file has been fully read in, all objects will be linked together. For instance a cell object will be given a "pointer" to the material object that is defined to be filled with. When the user wants to write their modified model to file this process will be reversed. The objects will crawl their syntax tree as necessary to ensure it has the correct value. If a value has changed, MontePy will try to match the rounding that the user used initially in the input file.
- Research Organization:
- Idaho National Laboratory (INL), Idaho Falls, ID (United States)
- Sponsoring Organization:
- USDOE Office of Nuclear Energy (NE); USDOE Office of Nuclear Energy (NE), Fuel Cycle Technologies (NE-5)
- Grant/Contract Number:
- AC07-05ID14517
- OSTI ID:
- 3027746
- Report Number(s):
- INL/JOU-24-77688
- Journal Information:
- Journal of Open Source Software, Journal Name: Journal of Open Source Software Journal Issue: 108 Vol. 10
- Country of Publication:
- United States
- Language:
- English
Similar Records
Going under the hood of MontePy: A python API for MCNP input files [Slides]
A Practical guide to Parsing MCNP Inputs: Lessons Learned from Implementing Context-Free Parsing in MontePy
Montepy
Technical Report
·
Wed Mar 06 19:00:00 EST 2024
·
OSTI ID:2322420
A Practical guide to Parsing MCNP Inputs: Lessons Learned from Implementing Context-Free Parsing in MontePy
Conference
·
Wed Apr 30 00:00:00 EDT 2025
·
OSTI ID:2510796
Montepy
Software
·
Sun Jan 07 19:00:00 EST 2024
·
OSTI ID:code-117498