# Setting an array to "UniverseBase" data type issue

**URL:** <https://openmc.discourse.group/t/setting-an-array-to-universebase-data-type-issue/4729>\
**Category:** User Support\
**Created:** [August 26, 2024, 8:46am UTC](https://openmc.discourse.group/t/setting-an-array-to-universebase-data-type-issue/4729 "2024-08-26T08:46:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bushnag](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Bushnag](https://openmc.discourse.group/u/Bushnag)\
**Post date:** [August 26, 2024, 8:46am UTC](https://openmc.discourse.group/t/setting-an-array-to-universebase-data-type-issue/4729/1 "2024-08-26T08:46:14Z")

</div>

Greetings,

I’ve encountered an issue while trying to assign universes to an array using np. functions.

the issue is as following:  
I’ve defined universes and i want to create a lattice, therefore i used the following according to the openmc website manual;

lattice\_arr.universes = np.empty ((m,1,1), dtype = openmc.Universe)

however, i got the error:

"Error setting lattice universes: items must be of type “UniverseBase”, but item at [0,0,0] is of type “NoneType”

could someone please guide me through this issue and how to solve it?

---

<div class="post-metadata">

**Author:** ![wahidluthfi](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/wahidluthfi/32/3375_2.png) [@wahidluthfi](https://openmc.discourse.group/u/wahidluthfi)\
**Post date:** [August 26, 2024, 9:49am UTC](https://openmc.discourse.group/t/setting-an-array-to-universebase-data-type-issue/4729/2 "2024-08-26T09:49:33Z")

</div>

Hi Bushnag,  
I think this example notebook about BWR fuel assembly modeling could help you understand how to assign universes

> **[Jupyter Notebook Viewer](https://nbviewer.org/github/mit-crpg/openmc-reactor-examples/blob/main/BWR.ipynb)**
>
> Check out this Jupyter notebook!

Here other examples

> **[Example Jupyter Notebooks](https://github.com/openmc-dev/openmc/wiki/Example-Jupyter-Notebooks)**
>
> OpenMC Monte Carlo Code. Contribute to openmc-dev/openmc development by creating an account on GitHub.

I am not a fan of using numpy to create a universe, but if you really want to use numpy to make your configuration, let’s say you have an openmc.Universe consists of a fuel rod and its surrounding water named FuelPinUniverse and you want it to form a 17×17 in the rectangular lattice, then I think `.universes = np. tile(FuelPinUniverse, (17, 17))` should work.

Also if you want to recreate the example for 3D lattice from this section  
[https://docs.openmc.org/en/latest/usersguide/geometry.html?highlight=lat3D#rectangular-lattices](https://docs.openmc.org/en/latest/usersguide/geometry.html?highlight=lat3D#rectangular-lattices)  
I think you can create a separate parameter with np.empty + dtype, and then use that parameter as input to your 3D lattice universes [3Dlat.ipynb](https://openmc.discourse.group/uploads/short-url/dJD8ta0XTYphSBsBtnbYtMiIquh.ipynb) (90.4 KB)

```auto
universe3D = np.empty((3, 3, 3), dtype=openmc.Universe)
universe3D[0, ...] = u
universe3D[1, ...] = q
universe3D[2, ...] = z
lat3d.universes = universe3D

```

---

<div class="post-metadata">

**Author:** ![Bushnag](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Bushnag](https://openmc.discourse.group/u/Bushnag)\
**Post date:** [August 26, 2024, 10:30am UTC](https://openmc.discourse.group/t/setting-an-array-to-universebase-data-type-issue/4729/3 "2024-08-26T10:30:05Z")

</div>

I’ll try them. Thank you!

---

<div class="post-metadata">

**Author:** ![Bushnag](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Bushnag](https://openmc.discourse.group/u/Bushnag)\
**Post date:** [August 27, 2024, 6:35am UTC](https://openmc.discourse.group/t/setting-an-array-to-universebase-data-type-issue/4729/4 "2024-08-27T06:35:00Z")

</div>

unfortunately didn’t find what i’m looking for.

I need to define np.empty() with a data type that is accepted as the example shown in the OpenMC documents

lat3d.universes = np.empty((3, 3, 3), dtype=openmc.Universe)  
lat3d.universes[0, …] = u  
lat3d.universes[1, …] = q  
lat3d.universes[2, …] = z

however i got the error mentioned above

@paulromano I would really appreciate the help in this matter
