MCNP to OpenMC tool

Some of you may be aware that I have an MCNP to OpenMC conversion tool that I’ve worked on over the years. I spent a little bit of time this week packaging it up into a separate repository and have put it out in the open here:

It’s definitely not perfect and has some flaws, but it still may be useful for some purposes. If you do use it, make sure you read the disclaimer/known limitations on the README :smile:

For those interested in this topic, I’ll also draw attention to another open-source tool written by @makeclean that does CSG model conversion (goes beyond just MCNP → OpenMC but has a different set of limitations):

9 Likes

Hi Paul,

just used your tool to convert my MCNP materials to OpenMC.
Worked great. Really didn’t want to rename all those nuclides by hand (or self-script).

You (or anyone else) wouldn’t happen to know of any SDEF MCNP → OpenMC converters/scripts out there in the wild? (regardless of their maturity)

Regards,
Perry

Hi Perry – Glad to hear the MCNP conversion tool worked well for you! Unfortunately I’m not aware of any tools out there for converting SDEF source definition cards.

Paul,

Do you know of any tools to convert OpenMC to MCNP? I really like the geometry and materials definition tools that you guys have in OpenMC but need to get things like mean generation time and a few other things out of MCNP.

I’m not aware of such a tool. It’s not too much of a stretch to imagine the following:

model = openmc.Model()
model.geometry = ...
model.settings = ...

model.export_to_mcnp(filename)

But, given limited resources and time (and money), adding such a functionality has never made it to the top of my list. Maybe someone can convince the good folks at LANL to fund such a feature :slight_smile:

I’ll ping Jerawan and the other MCNP folks I know at LANL about it!

Thanks

Just noting that I came across a paper describing another package (not yet open source, but soon to be?) that is capable of doing MCNP to OpenMC conversion:

Hello @paulromano!
MCNPy was released a couple months ago. Have you used its model conversion functionality?
And is there any progress with source (SDEF) conversion from MCNP?

Hi @egor1abs! I started playing around with it when it was first released into the open but haven’t had time to experiment with it since then. If you do try it out, one thing to be aware of is that if you are converting an MCNP model it expects the very first line in the file to start with #.

No progress that I’m aware of in converting SDEF for any of the projects out there unfortunately. Sure would be nice!

Hi,

while using the tool mcnp_to_openmc.
I get the error of importing simps

line below in /home/solps/.local/lib/python3.10/site-packages/openmc/mgxs_library.py
from scipy.integrate import simpsps

this need to be modified for the following

from scipy.integrate import simps

try:
from scipy.integrate import simps
except:
from scipy.integrate import simpson as simps

even after that I am having following problem

ImportError: cannot import name ‘OrthogonalBox’ from ‘openmc.model.surface_composite’ (/home/solps/.local/lib/python3.10/site-packages/openmc/model/surface_composite.py)

can you please help

I believe you need to update to version 0.15.1 of OpenMC, which includes the new OrthogonalBox surface.

Dear sirs (@paulromano @pshriwise @Shimwell ) I am getting following error while using the mcnp_to_openmc conversion

mcnp_to_openmc R3P175
Traceback (most recent call last):
File “/home/aktyagi/.conda/envs/openmc-mpipy3.11/bin/mcnp_to_openmc”, line 5, in
from openmc_mcnp_adapter.openmc_conversion import mcnp_to_openmc
File “/home/aktyagi/.conda/envs/openmc-mpipy3.11/lib/python3.11/site-packages/openmc_mcnp_adapter/openmc_conversion.py”, line 13, in
from openmc.model.surface_composite import (
ImportError: cannot import name ‘OrthogonalBox’ from ‘openmc.model.surface_composite’ (/home/aktyagi/.conda/envs/openmc-mpipy3.11/lib/python3.11/site-packages/openmc/model/surface_composite.py)

Requesting your help to resolve the problem.

You just need to update your install of OpenMC; the OrthogonalBox composite surface that it is looking for was introduced in version 0.15.1. After you upgrade, it should work fine.

Dear Dr. @paulromano thanks updating code to 0.15.2 solved the problem. further I need to define the source equivalent to following

sdef erg=d1 cel=110 x=d2 y=d3 z=d4 wgt=1
c Source probability function for energy sampling:
c Muir velocity Gaussian energy spectrum (DT fusion at 10 keV):
sp1 -6
c Coordinates sampling
si2 -513.2 513.2
sp2 0 1
c
si3 -513.2 513.2
sp3 0 1
c
si4 -356.00 356.00
sp4 0 1
c
mode n p
#######
Regards
Anil

See earlier in this chain, MCNP to OpenMC tool - #4 by paulromano
No tools for SDEF

I’ll continue on in using this thread, for much ado about the adapter.
Though I suppose this perhaps pertains more to the API and surface_composite.py
I’m curious why regular TRCs are getting converted to quadrics and planes.

The below input demonstrates this

  • surface 3 TRC not converted to z-plane and z-cone)
  • I understand why surface 2 RCC is converted to quadrics/planes (because of its off-axis nature)

Preferring to keep my geometry clean and close to the original (this is just a sample).
Latest versions adapter and OpenMC Python API.

MCNP Input

Toy-Geo for Adapter
c
c Cells
1 1 -1       1 : -2 : 3 :4       imp:n,p=1 $ World
2    0      -1 2 -3 -4           imp:n,p=0 $ Graveyard

c Surfaces
1 1 RCC     0    0   0   0   0  1    10
2 1 RCC     0    0   0   0   1  1    10          $ off-axis cylinder, gets planes and quadric
3 1 TRC     0    0   0   0   0 20    22    24    $ no Z-cone, or z-plane, gets planes and quadric
4 1 RPP   -30   30 -30  30 -30 30

c Data Cards
 TR1    0    0        0
*TR2    0    0        0    90 90  0   90 0 -90   180 90 90
c
M1    1001    -3.405267  

Converted to OpenMC geometry.xml

  <geometry>
    <cell id="1" material="1" region="5 | -6 | 7 | (-11 12 -13) | -18 | 19 | 17 | 21 | -20 | 23 | -22 | 25 | -24" universe="0"/>
    <cell id="2" material="void" region="-5 6 -7 (11 | -12 | 13) 18 -19 -17 -21 20 -23 22 -25 24" universe="0"/>
    <surface coeffs="0.0 0.0 10.0" id="5" type="z-cylinder"/>
    <surface coeffs="0.0" id="6" type="z-plane"/>
    <surface coeffs="1.0" id="7" type="z-plane"/>
    <surface coeffs="1.0 0.4999999999999999 0.5000000000000001 -0.0 -1.0 -0.0 0.0 0.0 0.0 -100.0" id="11" type="quadric"/>
    <surface coeffs="0.0 0.7071067811865476 0.7071067811865475 0.0" id="12" type="plane"/>
    <surface coeffs="0.0 0.7071067811865476 0.7071067811865475 1.4142135623730951" id="13" type="plane"/>
    <surface coeffs="0.9900990099009901 0.9900990099009901 -0.00990099009900991 -0.0 -0.0 -0.0 -0.0 -0.0 -4.35643564356436 -479.2079207920796" id="17" type="quadric"/>
    <surface coeffs="0.0 0.0 1.0 0.0" id="18" type="plane"/>
    <surface coeffs="0.0 0.0 1.0 20.0" id="19" type="plane"/>
    <surface coeffs="-30.0" id="20" type="x-plane"/>
    <surface coeffs="30.0" id="21" type="x-plane"/>
    <surface coeffs="-30.0" id="22" type="y-plane"/>
    <surface coeffs="30.0" id="23" type="y-plane"/>
    <surface coeffs="-30.0" id="24" type="z-plane"/>
    <surface coeffs="30.0" id="25" type="z-plane"/>
  </geometry>