MontePy Scope

This document defines the scope of MontePy so it easier to decide if a feature should live in MontePy or possibly another repository. This isn’t meant to be fully static and is subject to change. This is less focused on defining a strict scope and more-so on providing guidelines.

Mission

MontePy’s mission is to improve the user experience for working with MCNP input files through the power of python automation?

Principles

Here are the guiding principles of what MontePy should be, and what it aspires to be.

MontePy should be:

  1. Easy to install.

    1. It should be on PyPi.

    2. Install with pip for most conceivable platforms.

  2. Lightweight. It should only include the code that all users need, and only the bare essentials for dependencies.

  3. Well documented. All public functions must have documentation.

  4. Pythonic.

  5. Idiomatic.

  6. Consistently designed.

  7. General. New features shouldn’t be only useful for a specific problem, or class of problems.

  8. Quick to fail and do so in a verbose helpful manner.

  9. Reliable.

  10. Thorough in its validation. If it MontePy finds more issues than MCNP does, that’s ok.

  11. Easy to contribute to.

  12. Able to support the full (public) MCNP manual, except when it doesn’t.

    1. For features that aren’t supported yet an UnsuportedFeature error should be raised.

    2. The developers reserve the right to decide a feature is not worth ever supporting.

MontePy shouldn’t be:

  1. A collection of scripts for every use case.

  2. A linking code to other software.

  3. Written in other languages*

Design Philosophy

  1. Do Not Repeat Yourself (DRY)

  2. If it’s worth doing, it’s worth doing well.

  3. Use abstraction and inheritance smartly.

  4. Use _private fields mostly. Use __private for very private things that should never be touched.

  5. Use @property getters, and if needed setters. Setters must verify and clean user inputs. For the most part use make_prop_val_node(), and make_prop_pointer().

  6. Fail early and politely. If there’s something that might be bad: the user should get a helpful error as soon as the error is apparent.

  7. Test. test. test. The goal is to achieve 100% test coverage. Unit test first, then do integration testing. A new feature merge request will ideally have around a dozen new test cases.

  8. Do it right the first time.

  9. Document all functions.

  10. Expect everything to mutate at any time.

  11. Avoid relative imports when possible. Use top level ones instead: e.g., import montepy.cell.Cell.

  12. Defer to vanilla python, and only use the standard library. Currently the only dependencies are numpy and sly. There must be good justification for breaking from this convention and complicating things for the user.

Style Guide

  1. Use black to autoformat all code.

  2. Spaces for indentation, tabs for alignment. Use spaces to build python syntax (4 spaces per level), and tabs for aligning text inside of docstrings.

  3. Follow PEP 8.

Support of MCNP Output Files

This is a common question: “Will MontePy support MCNP output files?” The short answer is no. This is due to a few reasons:

  1. MCNP is export controlled, and none of the public manuals document the formatting of the output files. So out of an abundance of caution we treat the format of MCNP output files as being export controlled.

  2. The output format is not documented. This makes it hard to robustly handle, and also means that the format may change.

  3. MCNPtools exists and may be a better tool than what we can implement.

Note on use of other languages

The use of another language in the code base goes against the principle that it should be easy to contribute. However, there could be cases where the advantages of another language could justify this violation. Here are guidelines for when it could be appropriate:

  1. There needs to be a clear and significant benefit.

  2. The rewrite needs to be limited in scope to a module that few developers will modify.

  1. Only the input parser seems to meet this criteria.

  1. There must be a dependable build system that allows deployment to PyPI.