# MCNP to OpenMC tool

**URL:** https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141
**Category:** Announcements
**Created:** [June 24, 2022, 1:12pm UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141 "2022-06-24T13:12:38Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [June 24, 2022, 1:12pm UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/1 "2022-06-24T13:12:39Z")

</div>

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:

> **[GitHub - openmc-dev/openmc\_mcnp\_adapter: Tool for converting MCNP input files...](https://github.com/openmc-dev/openmc_mcnp_adapter)**
>
> Tool for converting MCNP input files to OpenMC classes/XML - GitHub - openmc-dev/openmc\_mcnp\_adapter: Tool for converting MCNP input files to OpenMC classes/XML

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

> **[GitHub - makeclean/csg2csg: Tools to translate between different CSG geometry...](https://github.com/makeclean/csg2csg)**
>
> Tools to translate between different CSG geometry types - GitHub - makeclean/csg2csg: Tools to translate between different CSG geometry types

---

<div class="post-metadata">

### Author: ![yrrepy](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/yrrepy/32/2365_2.png) [@yrrepy](https://openmc.discourse.group/u/yrrepy)
#### Post date: [September 17, 2022, 12:08am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/3 "2022-09-17T00:08:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [September 18, 2022, 12:36am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/4 "2022-09-18T00:36:44Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jpayne](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jpayne](https://openmc.discourse.group/u/jpayne)
#### Post date: [February 10, 2023, 3:33pm UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/5 "2023-02-10T15:33:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [February 10, 2023, 4:00pm UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/6 "2023-02-10T16:00:24Z")

</div>

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

```plaintext
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 🙂

---

<div class="post-metadata">

### Author: ![jpayne](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jpayne](https://openmc.discourse.group/u/jpayne)
#### Post date: [February 10, 2023, 5:10pm UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/7 "2023-02-10T17:10:59Z")

</div>

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

Thanks

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [February 21, 2023, 1:00pm UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/8 "2023-02-21T13:00:59Z")

</div>

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:

> **[Enhancing Monte Carlo Workflows for Nuclear Reactor Analysis with...](https://www.tandfonline.com/doi/full/10.1080/00295639.2022.2153617)**
>
> Monte Carlo codes are essential components of many reactor physics simulation workflows as high-fidelity continuous-energy neutron transport solvers. Among Monte Carlo radiation transport codes, MC...

---

<div class="post-metadata">

### Author: ![egor1abs](https://avatars.discourse-cdn.com/v4/letter/e/ecc23a/32.png) [@egor1abs](https://openmc.discourse.group/u/egor1abs)
#### Post date: [December 6, 2023, 11:00am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/9 "2023-12-06T11:00:21Z")

</div>

Hello @paulromano!  
MCNPy was [released](https://github.rpi.edu/NuCoMP/mcnpy) a couple months ago. Have you used its model conversion functionality?  
And is there any progress with source (SDEF) conversion from MCNP?

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [December 7, 2023, 2:21am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/10 "2023-12-07T02:21:41Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [February 27, 2025, 4:46am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/11 "2025-02-27T04:46:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [March 18, 2025, 1:36pm UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/12 "2025-03-18T13:36:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [May 8, 2025, 8:24am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/13 "2025-05-08T08:24:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [May 9, 2025, 4:14am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/14 "2025-05-09T04:14:12Z")

</div>

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](https://docs.openmc.org/en/latest/releasenotes/0.15.1.html). After you upgrade, it should work fine.

---

<div class="post-metadata">

### Author: ![aktyagiprl](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aktyagiprl](https://openmc.discourse.group/u/aktyagiprl)
#### Post date: [May 9, 2025, 10:07am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/15 "2025-05-09T10:07:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![yrrepy](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/yrrepy/32/2365_2.png) [@yrrepy](https://openmc.discourse.group/u/yrrepy)
#### Post date: [May 10, 2025, 12:15am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/16 "2025-05-10T00:15:26Z")

</div>

See earlier in this chain, [MCNP to OpenMC tool - #4 by paulromano](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/4)  
No tools for SDEF

---

<div class="post-metadata">

### Author: ![yrrepy](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/yrrepy/32/2365_2.png) [@yrrepy](https://openmc.discourse.group/u/yrrepy)
#### Post date: [May 10, 2025, 12:27am UTC](https://openmc.discourse.group/t/mcnp-to-openmc-tool/2141/17 "2025-05-10T00:27:11Z")

</div>

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**

```auto
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**

```auto
  <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>

```
