A library for reading, editing, and writing MCNP input files
Project description
MontePy
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
- Handles almost all MCNP input syntax.
- Parses Cells, Surfaces, Materials, and Transforms very well.
- Can parse all surface types except macrobody facets (Issue #354).
- Can read and write out all other MCNP inputs, even if it doesn't not understand them
- Attempts to write out the MCNP problem verbatim, even matching the original user formatting. (See some of the open issues.)
- Can quickly access cells, surfaces, and materials by their numbers. For example:
cell = problem.cells[105]
. - Can quickly update cell parameters, such as importances. For example
cell.importance.neutron = 2.0
. - Can easily create universes, and fill other cells with universes.
- Currently has over 430 test cases.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file montepy-0.5.1.tar.gz
.
File metadata
- Download URL: montepy-0.5.1.tar.gz
- Upload date:
- Size: 190.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74c3ae98bc7e699c6e8fa3f4f0895d2db798022535341a914cc5a0b910834859 |
|
MD5 | 0ebd63fd36215ebd7e18c2bb72ac766f |
|
BLAKE2b-256 | 36c614b7e28e765f149cd7fc1e1d36962015491ae1d985b91234277ee4554606 |
Provenance
The following attestation bundles were made for montepy-0.5.1.tar.gz
:
Publisher:
deploy.yml
on idaholab/MontePy
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
montepy-0.5.1.tar.gz
- Subject digest:
74c3ae98bc7e699c6e8fa3f4f0895d2db798022535341a914cc5a0b910834859
- Sigstore transparency entry: 145200253
- Sigstore integration time:
- Predicate type:
File details
Details for the file montepy-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: montepy-0.5.1-py3-none-any.whl
- Upload date:
- Size: 140.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d791e94200f0bad18685350e5a333bace58af7315a5903b7eb08b924b1a91414 |
|
MD5 | 4bf925fdb633b72248a24c5650c25ba5 |
|
BLAKE2b-256 | b17ab263dcc10d64ae25f075ba548b073a388eb8e0d81f3615b4a4e53cb97c0f |
Provenance
The following attestation bundles were made for montepy-0.5.1-py3-none-any.whl
:
Publisher:
deploy.yml
on idaholab/MontePy
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
montepy-0.5.1-py3-none-any.whl
- Subject digest:
d791e94200f0bad18685350e5a333bace58af7315a5903b7eb08b924b1a91414
- Sigstore transparency entry: 145200255
- Sigstore integration time:
- Predicate type: