Warning
- MCIO uses CM for length and MeV for energy.
- MCIO requires STEP files to use the AP242 schema.
The MCIO CAD-to-CSG package can be installed for the end user and run via the command line.
python -m mcio decompose -i my_model.stp -m my_materials.json -t my_tallies.json --cores 20The above will convert a step file (AP242 standard) to CSG then to MCNP file, writing the output to MCNP6 input format to output/mcnp_model.i and to OpenMC XML format if installed to output/openmc.
MCIO can be installed from source using the below commands, with the dependencies installed for cad and jupyter using the extras [cad,jupyter]. The CAD and Jupyter dependencies are not required to run the non-CAD-to-CSG.
git clone https://github.com/ukaea/mcio.git
python -m pip install .[cad,jupyter]
To write OpenMC models, install its Python API, see the OpenMC installation guide.
For those wishing to contribute to development, you can install all dependencies for docs,
git clone -b dev https://github.com/ukaea/mcio.git
python -m pip install .[dev,docs,cad,jupyter]
The test suite also needs OpenMC; CI installs it with:
python -m pip install "openmc @ git+https://github.com/openmc-dev/openmc.git@83a30f6860c79fac8fd58584489cc0d1abcb0376"Running MCIO via the command line is the easiest way to produce a model with materials and some common tally types. The below example runs via 20 core multiprocess and assigns materials by RGB and some basic tally types. Materials are assigned by RGB colour or by m1 type labels, depending on the keys used in the materials JSON.
python -m mcio decompose -c 20 -i my_model.stp -m my_mats_rgb.json --tally my_tallies.json
{
"_m1_": {
"density": 0.997,
"composition": {
"H": 0.666667,
"O": 0.333333
},
"number": 100,
"reference": "https://www.pnnl.gov/main/publications/external/technical_reports/PNNL-15870Rev2.pdf",
"fraction_type": "ao",
"density_type": "g/cc",
"name": "Water, Liquid",
"mcnp": {
"sab_cards": [],
"libs": {},
"library": ""
}
}
}The open cascade based OCP modules (the CAD-to-CSG decomposer and its helpers) are loaded automatically by import mcio when OCP is installed.
This allows users who don't need the CAD-to-CSG decomposer not to need OCP installed, which can require Conda on non Windows/modern Debian systems. Without OCP, import mcio logs a warning and the non-CAD modules (surfaces, cells, materials, tallies, sources and MCNP/OpenMC output) work as normal.
import mcioWork is done on feature/<name> branches, which are the only branches that can be pushed to directly.
- Branch from
devand push your changes to afeature/branch. - Open a pull request from the feature branch into
dev. - Releases are made by a pull request from
devintomain; pull requests intomainfrom any other branch are rejected.
Pull requests need an approval and passing checks before they can be merged.
Tests are run with pytest, with coverage collected in the same run:
python -m pytest --covCode is linted and formatted with ruff. CI only blocks a pull request on real bugs (syntax errors and invalid constructs); all other findings and formatting lower the ruff score but do not fail the check. CI does not change files, so to tidy up before pushing run:
ruff format mcio testsruff check --fix mcio testsThe pylint-style score shown on the Ruff badge can be produced locally with:
python scripts/ruff_score.py mcio