A tool to translate common Monte Carlo geometry formats between each other.
Right now the code is petty rough.
Install the latest version released on PyPi using pip
bash
pip3 install csg2csg --user
Install the latest version on the repository using pip
bash
pip install git+https://github.com/makeclean/csg2csg.git --user
Run from the terminal with csg2csg -i filename -f format
where filename is the input filename and format is the file format of the input file. Options for the file format include several neutronics codes [mcnp, serpent, openmc, phits, fluka] each is at a different level of completeness.
The default is to attempt to translate the input file into all neutronics codes but users can specify which codes with the -o
flag.
To see all the run options type csg2csg -h
in the terminal
Several! Right now only MCNP can be read, and then written to MCNP, Serpent and OpenMC. When the file can be read only a subset of MCNP surfaces can be read
MCNP Surfaces Supported - P,PX,PY,PZ - S SO SX SY SZ - CX CY CZ C/X C/Y C/Z - SQ - GQ - KX, KY, KZ - TX TY TZ - Macrobodies - RPP, SPH and RCC - X, Y, Z - one and two coefficent only
MCNP Surfaces Not Yet Supported - X, Y, Z - three coefficient - Macrobodies - BOX, RHP, HEX, REC, TRC, ELL, WEB, ARB
Transforms - Are read and interpretted, but nothing is done with them, in the future codes that support cell transformations will use it, but right now MCNP is the only code that does surface transformations
Was attempting to convert an MCNP file, which had the word 'implicit' in one of the tally comment cards. This broke the _get_importances function in MCNPInputs so fixed with a startswith operation on the string.
I have added capability to retain xs library data from mcnp and serpent input files, which is invoked by a new command line argument, -xs.
I'm trying to convert this material file from Serpent to OpenMC:
mat fuel -4.69
.
.
.
120230 -0.00000000000000E+00
.
.
.
The dotted lines are filled in with other nuclides.
Running csg2csg -i test_mat.ini -f serpent -o openmc
gives me the following error:
File "/home/ooblack/miniconda3/envs/saltproc-env/lib/python3.9/site-packages/csg2csg/OpenMCMaterial.py", line 41, in zaid_to1_name
name = name_zaid[zz]
KeyError: 120
Using pdb
to get the state before the exception gets thrown, I find that zaid_string
is 120230
.
Now, the serpent input file syntax for the material card specifies:
The nuclide identifier for nuclides with associated cross-sections corresponds to ZZAAA.ID and, for nuclides without associated cross-sections, e.g., decay nuclides, to ZZAAAI. The identifiers include Z, the atomic number; A, the mass number of the nuclide; I, the isomeric state (0 = ground state, 1 = metastable state); and ID, the library identifier. For nuclides without associated cross-sections, include the fix option to indicate the library and temperature of the given nuclides.
There are many more decay-only nuclides in my material file, and I believe many of them are processed incorrectly but no error is thrown because the (potentially incorrect) element numbers that get sent as a key to the name_zaid
dictionary have associated values.
I think this issue could be fixed by adding some lines to SerpentInput.__get_material_card
to detect nuclides in this format.
Hi @makeclean,
Noticed that csg2csg master doesn't like $ comments on MCNP files if the are not preceded by any text, for example: ' $The outer cell' is commonly found in MCNP files generated using SuperMC. This is acceptable MCNP syntax but not so in csg2csg. I have been resolving this manually by commenting out the line, e.g: 'c $The outer cell', however hopefully this could be easily resolved in csg2csg. I have also noticed that it doesn't seem to like IMP:N=0 cells which are not at the end of the cell list - for most models this is fine however I had a failure for models that contain multiple universes, which have an IMP:N=0 at the end of each set of universe cells.
Cheers,
sbradnam
This is an initial attempt to add some additional functionality to parsing MCNP inputs. Additions include: - Changes to importance regex - Support for read cards - Support for & line continuations - Reads lattices, cell tmp and cell vol - Reads and generalizes thermal scattering inputs
Remaining work includes: - Adding test cases - Improvements in thermal scattering data management (the thermal scattering is appended to the material, which then requires the material card is input prior to the MT card in the MCNP input file). - Missing function to write MT cards (only reads) - Perhaps better generalization of lattice fill data. No specific Lattice class was made as lattices are essentially cells in MCNP
A similar extension to write this new data to OpenMC is in-progress and will be submitted as a separate future pull request.
Let me know if you have any comments / feedback as I work to address the remaining to-do items.
This adds a github action that will upload the package to pypi whenever a github release is made
the version number from the release will be automatically used in the python package version
for this to work a new github secret called PYPI_API_TOKEN
will need adding