montepy


Namemontepy JSON
Version 0.5.3.post1 PyPI version JSON
download
home_pageNone
SummaryA library for reading, editing, and writing MCNP input files
upload_time2024-12-12 21:33:30
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Battelle Energy Alliance, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords mcnp neutronics imcnp input file monte carlo radiation transport
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MontePy

<img src="https://raw.githubusercontent.com/idaholab/MontePy/develop/graphics/monty.svg" width="180" alt="MontePY: a cute snek on a red over white circle"/>

[![license](https://img.shields.io/github/license/idaholab/MontePy.svg)](https://github.com/idaholab/MontePy/blob/develop/LICENSE)
[![JOSS article status](https://joss.theoj.org/papers/e5b5dc8cea19605a1507dd4d420d5199/status.svg)](https://joss.theoj.org/papers/e5b5dc8cea19605a1507dd4d420d5199)
[![Coverage Status](https://coveralls.io/repos/github/idaholab/MontePy/badge.svg?branch=develop)](https://coveralls.io/github/idaholab/MontePy?branch=develop)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)


[![PyPI version](https://badge.fury.io/py/montepy.svg)](https://badge.fury.io/py/montepy)
[![Docs Deployment](https://github.com/idaholab/MontePy/actions/workflows/deploy.yml/badge.svg?branch=main)](https://www.montepy.org/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/montepy.svg)](https://pypi.org/project/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](https://www.montepy.org/starting.html#installing).


## User Documentation

MontePy has a website [documenting how to work with MCNP in python with MontePy](https://www.montepy.org/). 
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](https://github.com/idaholab/MontePy/issues/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](https://github.com/idaholab/MontePy/issues).)
* Can quickly [access cells, surfaces, and materials by their numbers](https://www.montepy.org/starting.html#collections-are-accessible-by-number). For example: `cell = problem.cells[105]`.
* Can quickly update cell parameters, [such as importances](https://www.montepy.org/starting.html#setting-cell-importances). For example `cell.importance.neutron = 2.0`.
* Can easily [create universes, and fill other cells with universes](https://www.montepy.org/starting.html#universes).
* Currently has over 550 test cases.

 
Here is a quick example showing multiple tasks in MontePy:


``` python
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](https://github.com/idaholab/MontePy/issues/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:

* [pyMCNP](https://github.com/FSIBT/PyMCNP)

* [MCNP-Input-Reader](https://github.com/ENEA-Fusion-Neutronics/MCNP-Input-Reader)

* [numjuggler](https://github.com/inr-kit/numjuggler)

The only other library that does utilize context-free parsing that we are aware is
[MCNP™y](https://github.rpi.edu/NuCoMP/mcnpy). 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.

* [Workflow and Template Toolkit for Simulation (WATTS)](https://github.com/watts-dev/watts)
* [Advanced Reactor Modeling Interface (ARMI)](https://github.com/terrapower/armi)

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](https://pyne.io/).
	
## 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](https://www.montepy.org/developing.html) for more details.
If you have any questions feel free to ask [@micahgale](mailto:mgale@montepy.org).

## Citation

For citing MontePy in a publication a [Journal of Open Source Software](https://joss.readthedocs.io/en/latest/) article is under review. 
In the meantime there is a DOI for the software from [OSTI](https://osti.gov): [DOI:10.11578/dc.20240115.1](https://doi.org/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](https://doi.org/10.11578/dc.20240115.1).


 
# Finally: make objects, not regexes!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "montepy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Micah Gale <mgale@montepy.org>",
    "keywords": "MCNP, neutronics, imcnp, input file, monte carlo, radiation transport",
    "author": null,
    "author_email": "Micah Gale <mgale@montepy.org>, Travis Labossiere-Hickman <Travis.LabossiereHickman@inl.gov>, Brenna Carbno <brenna.carbno@inl.gov>",
    "download_url": "https://files.pythonhosted.org/packages/75/b5/0ea3e364c5ddcbca9b2c97e1ac93a1f3cfec7ad24cd2a1862c595236b657/montepy-0.5.3.post1.tar.gz",
    "platform": null,
    "description": "# MontePy\n\n<img src=\"https://raw.githubusercontent.com/idaholab/MontePy/develop/graphics/monty.svg\" width=\"180\" alt=\"MontePY: a cute snek on a red over white circle\"/>\n\n[![license](https://img.shields.io/github/license/idaholab/MontePy.svg)](https://github.com/idaholab/MontePy/blob/develop/LICENSE)\n[![JOSS article status](https://joss.theoj.org/papers/e5b5dc8cea19605a1507dd4d420d5199/status.svg)](https://joss.theoj.org/papers/e5b5dc8cea19605a1507dd4d420d5199)\n[![Coverage Status](https://coveralls.io/repos/github/idaholab/MontePy/badge.svg?branch=develop)](https://coveralls.io/github/idaholab/MontePy?branch=develop)\n[![Project Status: Active \u2013 The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n\n\n[![PyPI version](https://badge.fury.io/py/montepy.svg)](https://badge.fury.io/py/montepy)\n[![Docs Deployment](https://github.com/idaholab/MontePy/actions/workflows/deploy.yml/badge.svg?branch=main)](https://www.montepy.org/)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/montepy.svg)](https://pypi.org/project/montepy/)\n\n\nMontePy is the most user friendly Python library for reading, editing, and writing MCNP input files. \n\n## Installing\n\nSimply run:\n\n```\npip install montepy\n```\n\nFor more complicated setups\nsee the [Installing section in the user guide](https://www.montepy.org/starting.html#installing).\n\n\n## User Documentation\n\nMontePy has a website [documenting how to work with MCNP in python with MontePy](https://www.montepy.org/). \nThe website contains a user's guide for getting started, \na developer's guide covering the design and approach of MontePy,\ninstructions for contributing, \nand the Python API documentation.\n\n## Features\n\t\n* Handles almost all MCNP input syntax.\n* Parses Cells, Surfaces, Materials, and Transforms very well.\t\n* Can parse all surface types except macrobody facets ([Issue #354](https://github.com/idaholab/MontePy/issues/354)).\n* Can read and write out all other MCNP inputs, even if it doesn't not understand them\t\n* Attempts to write out the MCNP problem verbatim, even matching the original user formatting. (See some of the [open issues](https://github.com/idaholab/MontePy/issues).)\n* Can quickly [access cells, surfaces, and materials by their numbers](https://www.montepy.org/starting.html#collections-are-accessible-by-number). For example: `cell = problem.cells[105]`.\n* Can quickly update cell parameters, [such as importances](https://www.montepy.org/starting.html#setting-cell-importances). For example `cell.importance.neutron = 2.0`.\n* Can easily [create universes, and fill other cells with universes](https://www.montepy.org/starting.html#universes).\n* Currently has over 550 test cases.\n\n \nHere is a quick example showing multiple tasks in MontePy:\n\n\n``` python\nimport montepy\n# read in file\nproblem = montepy.read_input(\"tests/inputs/test.imcnp\")\n  \n# set photon importance for multiple cells\nimportances = {1: 0.005,\n   2: 0.1,\n   3: 1.0,\n   99: 1.235\n}\nfor cell_num, importance in importances.items():\n   problem.cells[cell_num].importance.photon = importance\n\n#create a universe and fill another cell with it\nuniverse = montepy.Universe(123)\nproblem.universes.append(universe)\n# add all cells with numbers between 1 and 4\nuniverse.claim(problem.cells[1:5])\n# fill cell 99 with universe 123\nproblem.cells[99].fill.universe = universe\n\n# update all surfaces numbers by adding 1000 to them\nfor surface in problem.surfaces:\n   surface.number += 1000\n# all cells using these surfaces will be automatically updated as well\n\n#write out an updated file\nproblem.write_problem(\"foo_update.imcnp\")\n```\n\n## Limitations\n\nHere a few of the known bugs and limitations:\n\n\t\n* Cannot handle vertical input mode.\n* Does not support editing tallies in a user-friendly way.\n* Does not support editing source definition in a user-friendly way.\n* Cannot parse all valid material definitions. There is a known bug ([#182](https://github.com/idaholab/MontePy/issues/182)) that MontePy can only parse materials where all\n    keyword-value pairs show up after the nuclide definitions. For example:\n   * `M1 1001.80c 1.0 plib=80p` can be parsed.\n   * `M1 plib=80p 1001.80c 1.0` cannot be parsed; despite it being a valid input.\n\n## Alternatives\n\nThere are some python packages that offer some of the same features as MontePy,\n    but don't offer the same level of robustness, ease of installation, and user friendliness.\n\n\nMany of the competitors do not offer the robustness that MontePy does becuase,\n    they do not utilize context-free parsing (as of 2024). \nThese packages are:\n\n* [pyMCNP](https://github.com/FSIBT/PyMCNP)\n\n* [MCNP-Input-Reader](https://github.com/ENEA-Fusion-Neutronics/MCNP-Input-Reader)\n\n* [numjuggler](https://github.com/inr-kit/numjuggler)\n\nThe only other library that does utilize context-free parsing that we are aware is\n[MCNP\u2122y](https://github.rpi.edu/NuCoMP/mcnpy). MontePy differs by being:\n* On PyPI, and can be installed via pip.\n* Only requires a python interpreter, and not a Java virtual machine. \n* Allowing contributions from anyone with a public GitHub account\n\n\nFor only writing, or templating an input file there are also some great tools out there. \nThese packages don't provide the same functionality as MontePy inherently,\n    but could be the right tool for the job depending on the user's needs.\n\n* [Workflow and Template Toolkit for Simulation (WATTS)](https://github.com/watts-dev/watts)\n* [Advanced Reactor Modeling Interface (ARMI)](https://github.com/terrapower/armi)\n\nAnother honorable mention that doesn't replicate the features of MontePy,\n    but could be a great supplement to MontePy for defining materials, performing activations, etc.\n    is [PyNE --- the Nuclear Engineering Toolkit](https://pyne.io/).\n\t\n## Bugs, Requests and Development\n\nSo MontePy doesn't do what you want? \nAdd an issue here with the \"feature request\" tag. \nThe system is very modular and you should be able to develop it pretty quickly.\nRead the [developer's guide](https://www.montepy.org/developing.html) for more details.\nIf you have any questions feel free to ask [@micahgale](mailto:mgale@montepy.org).\n\n## Citation\n\nFor citing MontePy in a publication a [Journal of Open Source Software](https://joss.readthedocs.io/en/latest/) article is under review. \nIn the meantime there is a DOI for the software from [OSTI](https://osti.gov): [DOI:10.11578/dc.20240115.1](https://doi.org/10.11578/dc.20240115.1).\n\nYou can cite MontePy as:\n\n> M. Gale, T. Labossiere-Hickman, B. Carbno, A. Bascom, and MontePy contributors, \"MontePy\", 2024, [doi: 10.11578/dc.20240115.1](https://doi.org/10.11578/dc.20240115.1).\n\n\n \n# Finally: make objects, not regexes!\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Battelle Energy Alliance, LLC  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A library for reading, editing, and writing MCNP input files",
    "version": "0.5.3.post1",
    "project_urls": {
        "Bug Tracker": "https://github.com/idaholab/MontePy/issues",
        "Changelog": "https://www.montepy.org/changelog.html",
        "Documentation": "https://www.montepy.org/",
        "Homepage": "https://www.montepy.org/",
        "Repository": "https://github.com/idaholab/MontePy.git"
    },
    "split_keywords": [
        "mcnp",
        " neutronics",
        " imcnp",
        " input file",
        " monte carlo",
        " radiation transport"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e7dc865b211778cc25c1fc59aaca7d88b117aaef91241d61ff27c8a9291ab16",
                "md5": "d6cfbe425c5ee9b53f9e76f6dfe72b63",
                "sha256": "35ed7f8b58d7a16de1f0041c548adc7ba10e3717216571918e5f9dfea1d0eccf"
            },
            "downloads": -1,
            "filename": "montepy-0.5.3.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d6cfbe425c5ee9b53f9e76f6dfe72b63",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 142987,
            "upload_time": "2024-12-12T21:33:28",
            "upload_time_iso_8601": "2024-12-12T21:33:28.855940Z",
            "url": "https://files.pythonhosted.org/packages/3e/7d/c865b211778cc25c1fc59aaca7d88b117aaef91241d61ff27c8a9291ab16/montepy-0.5.3.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75b50ea3e364c5ddcbca9b2c97e1ac93a1f3cfec7ad24cd2a1862c595236b657",
                "md5": "7afe038ebdf0350b51d5eb827311b6d6",
                "sha256": "9ef1bde8b3459ee911315c3a4bf52f9bad4b3386f2810281b7aa2470e6c37d18"
            },
            "downloads": -1,
            "filename": "montepy-0.5.3.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "7afe038ebdf0350b51d5eb827311b6d6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 193572,
            "upload_time": "2024-12-12T21:33:30",
            "upload_time_iso_8601": "2024-12-12T21:33:30.296095Z",
            "url": "https://files.pythonhosted.org/packages/75/b5/0ea3e364c5ddcbca9b2c97e1ac93a1f3cfec7ad24cd2a1862c595236b657/montepy-0.5.3.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-12 21:33:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "idaholab",
    "github_project": "MontePy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "montepy"
}
        
Elapsed time: 0.40515s