# Using MCNP ADVANTG weight windows

**URL:** <https://openmc.discourse.group/t/using-mcnp-advantg-weight-windows/2088>\
**Category:** User Support\
**Created:** [May 31, 2022, 8:53pm UTC](https://openmc.discourse.group/t/using-mcnp-advantg-weight-windows/2088 "2022-05-31T20:53:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjcrs](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@sjcrs](https://openmc.discourse.group/u/sjcrs)\
**Post date:** [May 31, 2022, 8:53pm UTC](https://openmc.discourse.group/t/using-mcnp-advantg-weight-windows/2088/1 "2022-05-31T20:53:01Z")

</div>

Hi there,  
I’ve got an ADVANTG weight windows file for a MCNP model that I’m converting to OpenMC. Do you have a way that I can import this file and use it with the WeightWindows class?

---

<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 1, 2022, 11:51am UTC](https://openmc.discourse.group/t/using-mcnp-advantg-weight-windows/2088/2 "2022-06-01T11:51:13Z")

</div>

Hi @sjcrs. If you have a `wwinp` file, you can convert and use it in OpenMC as follows:

```nohighlight
wws = openmc.wwinp_to_wws('wwinp')

settings = openmc.Settings()
settings.weight_windows = wws

```

The [`wwinp_to_wws`](https://docs.openmc.org/en/latest/pythonapi/generated/openmc.wwinp_to_wws.html#openmc.wwinp_to_wws) function returns a list of `WeightWindows` objects.

---

<div class="post-metadata">

**Author:** ![sjcrs](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@sjcrs](https://openmc.discourse.group/u/sjcrs)\
**Post date:** [July 7, 2022, 9:33pm UTC](https://openmc.discourse.group/t/using-mcnp-advantg-weight-windows/2088/3 "2022-07-07T21:33:45Z")

</div>

Hi,  
I’d like to follow up on this. I’m loading a wwinp file and can see that it’s loading:

`print(wws)`

```auto
[WeightWindows
	ID =	5
	Mesh: =	RectilinearMesh
	ID =	7
	Name =	
	Dimensions =	3
	N X pnts: =	57
	X Min: =	-130.0
	X Max: =	720.0
	N Y pnts: =	57
	Y Min: =	-252.0
	Y Max: =	252.0
	N Z pnts: =	59
	Z Min: =	-315.0
	Z Max: =	285.0

	Particle Type =	neutron
	Energy Bounds =	<list of length 84>
...

```

And when I inspect the other elements of the `WeightWindows` object it all seems OK:

```auto
print(len(wws[0].energy_bounds))
print(len(wws[0].lower_ww_bounds))
print(len(wws[0].lower_ww_bounds[0]))
print(len(wws[0].lower_ww_bounds[0][0]))
print(len(wws[0].lower_ww_bounds[0][0][0]))

84
56
56
58
83

```

However when I run I see the error:

` ERROR: In weight window domain 4 the number of spatial energy/spatial bins (83) does not match the number of weight bins (0)`

In weight\_windows.cpp the number of weight bins is pulled from the size of the lower weight bin edges, `lower_ww_`. This seems inconsistent with the print statements above. Do you have any suggestions?

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:** [July 12, 2022, 8:27pm UTC](https://openmc.discourse.group/t/using-mcnp-advantg-weight-windows/2088/4 "2022-07-12T20:27:57Z")

</div>

Looks like this is a bug. Thanks for reporting! I just submitted a potential fix for it:

> <https://github.com/openmc-dev/openmc/pull/2113>
>
> A user \[ran into a problem\](https://openmc.discourse.group/t/using-mcnp-advantg-…weight-windows/2088/3) using weight windows converted from a \`wwinp\` file. It looks like the problem is that the \`WeightWindows\` class stores \`lower\_ww\_bounds\` and \`upper\_ww\_bounds\` as multidimensional arrays but when writing to XML, it doesn't account for that properly. I think the fix is as simple as flattening the array -- @pshriwise can you confirm that this will write the lower/upper bounds in the correct order accounting for both mesh and energy index?
