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
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):
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.
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
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!
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)
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)
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
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