# Can't see the result after running the code

**URL:** <https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483>\
**Category:** User Support\
**Created:** [November 16, 2022, 10:05pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483 "2022-11-16T22:05:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 16, 2022, 10:05pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/1 "2022-11-16T22:05:46Z")

</div>

Hello everyone,

I’m trying to get the tritium production and the code runs sucessfully but I can’t read the result, I try to print it using this line: print('The tritium breeding by lithium 6 is ', tally.scores), it gives a result of zero.

But it doesn’t give me the value. Here’s my script and a screenshot of the result:

import openmc  
%matplotlib inline  
from IPython.display import Image  
import numpy as np  
import matplotlib.pyplot as plt  
!rm summary.h5  
!rm statepoint._.h5  
settings = openmc.Settings()  
settings.particles = 500  
settings.batches = 10  
settings.inactive = 0  
energy\_dist = openmc.stats.Discrete([14.5e6], [1.0]) # energies, probabilities  
source = openmc.Source(energy=energy\_dist)  
source = openmc.Source()  
source.space = openmc.stats.Point((0, 0, 0))  
source.angle = openmc.stats.Isotropic()  
source.energy = openmc.stats.Discrete([14.5e6], [1.0])  
settings.source = source  
settings.source = source  
settings.run\_mode = ‘fixed source’  
settings.export\_to\_xml()  
lithium = openmc.Material(1, “lithium”)  
lithium.add\_element(‘Li’, 6.0)  
lithium.set\_density(‘g/cm3’, 0.534)  
mats = openmc.Materials([lithium])  
mats.export\_to\_xml()  
sph = openmc.Sphere(r=16, boundary\_type=‘reflective’)  
inside\_sph = -sph  
outside\_sph = +sph  
sph\_2 = openmc.Sphere(r=15, boundary\_type=‘reflective’)  
inside\_sph\_2 = -sph\_2  
outside\_sph\_2 = +sph\_2  
spherical\_shell = -sph & +sph\_2  
cell = openmc.Cell(region=spherical\_shell)  
cell.fill = lithium  
outside\_sph = openmc.Sphere(r=17, boundary\_type=‘vacuum’)  
universe = openmc.Universe(cells=[cell, empty\_cell])  
empty\_cell = openmc.Cell(region=-sph\_2)  
universe.plot(width = (40.0, 40.0), colors={cell: ‘green’})  
geometry = openmc.Geometry(universe)  
geometry.export\_to\_xml()  
cell\_filter = openmc.CellFilter([cell])  
energy\_filter = openmc.EnergyFilter([14.5e6])  
tally = openmc.Tally(name=‘breeding’)  
tally.filters = [cell\_filter, energy\_filter]  
tallies\_file = openmc.Tallies()  
tallies\_file.append(tally)  
tally.scores = [‘H3-production’]  
tallies\_file.export\_to\_xml()  
model = openmc.model.Model(geometry, mats, settings, tallies\_file)  
!rm summary.h5  
!rm statepoint._.h5  
sp\_filename = model.run()  
print('The tritium breeding by lithium 6 is ', tally.scores)  
with openmc.StatePoint(“statepoint.10.h5”) as sp:  
k\_eff = sp.keff

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/5/553dc6e1f5e694b82d4fac327d2bdfe3ac49739c.png)

Thank you so much for your help!

---

<div class="post-metadata">

**Author:** ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)\
**Post date:** [November 16, 2022, 11:27pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/2 "2022-11-16T23:27:53Z")

</div>

Thanks for posting

I would be tempted to remove the reflective surface on the spheres.

sph\_2 = openmc.Sphere(r=15, boundary\_type=‘reflective’)

Could be changed to

sph\_2 = openmc.Sphere(r=15)

---

<div class="post-metadata">

**Author:** ![Jiankai](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiankai/32/1070_2.png) [@Jiankai](https://openmc.discourse.group/u/Jiankai)\
**Post date:** [November 17, 2022, 2:54am UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/3 "2022-11-17T02:54:54Z")

</div>

I think you have not extracted tally results from statepoint file before printing it out.  
This line "print('The tritium breeding by lithium 6 is ', tally.scores) " will never tell the value but the string “H3-production” itself.

A brief example could be like:

sp = openmc.StatePoint(sp\_filename)  
tbr\_tally = sp.get\_tally(name=‘breeding’)  
df = tbr\_tally.get\_pandas\_dataframe()  
tbr\_tally\_result = (df[‘mean’].sum())  
print('The tritium breeding by lithium 6 is ', tbr\_tally\_result)

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 6:23am UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/4 "2022-11-17T06:23:22Z")

</div>

Thank you a lot for pointing this out, I actually only put it because I get this error, is there another way to fix it?

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/e/e620d421cec61b9598840d73739f65e38375fa45.png)

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 6:29am UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/5 "2022-11-17T06:29:36Z")

</div>

Thank you so much for your help! I used the lines you suggested and I got this error:

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/a/a9b818f7be7c153da6d6f65e55e5b0b7628d0d48.png)

---

<div class="post-metadata">

**Author:** ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)\
**Post date:** [November 17, 2022, 8:55am UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/6 "2022-11-17T08:55:11Z")

</div>

The outermost surface could be assigned a vacuum boundary to fix the no boundary conditions found error

sph = openmc.Sphere(r=16, boundary\_type=‘vacuum’)

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 11:33am UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/7 "2022-11-17T11:33:56Z")

</div>

I tried it and it gave me this error, I tied refreshing the kernal but it kept showing this error:

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/1/1a7b5f01e20671374cff582d713a6745b5acbbf5.png)

---

<div class="post-metadata">

**Author:** ![Jiankai](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiankai/32/1070_2.png) [@Jiankai](https://openmc.discourse.group/u/Jiankai)\
**Post date:** [November 17, 2022, 5:30pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/8 "2022-11-17T17:30:22Z")

</div>

I guess there is something wrong in the modeling. Here is the script that I can run for your reference.

```auto
import openmc
#%matplotlib inline
#from IPython.display import Image
import numpy as np
import matplotlib.pyplot as plt
#!rm summary.h5
#!rm statepoint..h5
settings = openmc.Settings()
settings.particles = 1000
settings.batches = 15
settings.inactive = 5
energy_dist = openmc.stats.Discrete([14.5e6], [1.0]) # energies, probabilities
source = openmc.Source(energy=energy_dist)
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14.5e6], [1.0])
settings.source = source
settings.run_mode = 'fixed source'
settings.export_to_xml()
#
lithium = openmc.Material(1, "lithium")
lithium.add_element("Li", 6.0)
lithium.set_density("g/cm3", 0.534)
mats = openmc.Materials([lithium])
mats.export_to_xml()
#
sph = openmc.Sphere(r=16, boundary_type="reflective")
cell = openmc.Cell()
cell.region=-sph
cell.fill = lithium
universe = openmc.Universe(cells=[cell])
#universe.plot(width = (40.0, 40.0), colors={cell: "green"})
geometry = openmc.Geometry(universe)
geometry.export_to_xml()
cell_filter = openmc.CellFilter([cell])
energy_filter = openmc.EnergyFilter([14.5e6])
tally = openmc.Tally(name="breeding")
tally.filters = [cell_filter]
tallies_file = openmc.Tallies()
tallies_file.append(tally)
tally.scores = ["H3-production"]
tallies_file.export_to_xml()
#
model = openmc.model.Model(geometry, mats, settings, tallies_file)
#!rm summary.h5
#!rm statepoint..h5
sp_filename = model.run()
#
sp = openmc.StatePoint(sp_filename)
#
# access the tally using pandas dataframes
tbr_tally = sp.get_tally(name='breeding')
df = tbr_tally.get_pandas_dataframe()

tbr_tally_result = (df['mean'].sum())
tbr_tally_std_dev = df['std. dev.'].sum()/df['mean'].sum()
    
print('The tritium breeding by lithium 6 is ', tbr_tally_result)

```

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 9:29pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/9 "2022-11-17T21:29:38Z")

</div>

Thank you so much for your help! It did work for me and I got the tritum ratio, I’m trying to create a spherical shell and I added a smaller sphere and an empty cell to represent the vacuum and I get this error, here’s the script, too:

import openmc  
#%matplotlib inline  
#from IPython.display import Image  
import numpy as np  
import matplotlib.pyplot as plt  
#!rm summary.h5  
#!rm statepoint..h5  
settings = openmc.Settings()  
settings.particles = 1000  
settings.batches = 15  
settings.inactive = 5  
energy\_dist = openmc.stats.Discrete([14.5e6], [1.0]) # energies, probabilities  
source = openmc.Source(energy=energy\_dist)  
source = openmc.Source()  
[source.space](http://source.space/) = openmc.stats.Point((0, 0, 0))  
source.angle = openmc.stats.Isotropic()  
source.energy = openmc.stats.Discrete([14.5e6], [1.0])  
settings.source = source  
settings.run\_mode = ‘fixed source’  
settings.export\_to\_xml()

# 

lithium = openmc.Material(1, “lithium”)  
lithium.add\_element(“Li”, 6.0)  
lithium.set\_density(“g/cm3”, 0.534)  
mats = openmc.Materials([lithium])  
mats.export\_to\_xml()

# 

sph = openmc.Sphere(r=16, boundary\_type=“reflective”)  
sph\_2 = openmc.Sphere(r=15, boundary\_type=“reflective”)  
space = openmc.Sphere(r=17, boundary\_type=“vacuum”)

cell.region=-sph & +sph\_2  
cell.fill = lithium  
universe = openmc.Universe(cells=[cell])  
#universe.plot(width = (40.0, 40.0), colors={cell: “green”})  
geometry = openmc.Geometry(universe)  
geometry.export\_to\_xml()  
cell\_filter = openmc.CellFilter([cell])  
energy\_filter = openmc.EnergyFilter([14.5e6])  
tally = openmc.Tally(name=“breeding”)  
tally.filters = [cell\_filter]  
tallies\_file = openmc.Tallies()  
tallies\_file.append(tally)  
tally.scores = [“H3-production”]  
tallies\_file.export\_to\_xml()

# 

model = openmc.model.Model(geometry, mats, settings, tallies\_file)  
#!rm summary.h5  
#!rm statepoint..h5  
sp\_filename = model.run()

# 

sp = openmc.StatePoint(sp\_filename)

# 

# access the tally using pandas dataframes

tbr\_tally = sp.get\_tally(name=‘breeding’)  
df = tbr\_tally.get\_pandas\_dataframe()

tbr\_tally\_result = (df[‘mean’].sum())  
tbr\_tally\_std\_dev = df[‘std. dev.’].sum()/df[‘mean’].sum()

print('The tritium breeding by lithium 6 is ', tbr\_tally\_result)  
with openmc.StatePoint(‘statepoint.15.h5’) as sp:  
k\_eff = sp.keff

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/7/7fa36a831eb390d09399863cf43a261058388e4b.png)

Thank you so much for your help!

---

<div class="post-metadata">

**Author:** ![Jiankai](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiankai/32/1070_2.png) [@Jiankai](https://openmc.discourse.group/u/Jiankai)\
**Post date:** [November 17, 2022, 10:01pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/10 "2022-11-17T22:01:16Z")

</div>

It does not make any sense to create a geometry like this:  
a sphere with reflective boundary condition and surrounded by another sphere with reflective boundary condition and then surrounded by vacuum sphere. A neutron will never across the surface with reflective boundary condition.

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 10:10pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/11 "2022-11-17T22:10:36Z")

</div>

How can I define the vacuum outside of the shell? I edited the geometry to this but still you mean I should define the vacuum differently?

sph = openmc.Sphere(r=16)  
sph\_2 = openmc.Sphere(r=15)  
space = openmc.Sphere(r=17, boundary\_type=“vacuum”)

shell =-sph & +sph  
shell = openmc.Cell(region=shell)  
shell.fill = lithium  
universe = openmc.Universe(cells=[shell])

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 10:13pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/12 "2022-11-17T22:13:15Z")

</div>

This is the error I get when I don’t define the reflective boundary condition:

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/b/be00949584c2c3349e58120b9d10452362091129.png)

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 10:27pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/13 "2022-11-17T22:27:33Z")

</div>

I edited to this and I get this error:  
sph = openmc.Sphere(r=16,boundary\_type=“vacuum”)  
sph\_2 = openmc.Sphere(r=15)

shell =-sph & +sph\_2  
outside\_shell = +shell & -sph\_2  
shell = openmc.Cell(region=shell)  
shell.fill = lithium  
universe = openmc.Universe(cells=[shell])  
empty\_cell = openmc.Cell(region=outside\_shell)  
#universe.plot(width = (40.0, 40.0), colors={cell: “green”})  
geometry = openmc.Geometry(universe)  
geometry.export\_to\_xml()

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/c/c07e8e35108f386943c8d721fd649fc13b156534.png)

---

<div class="post-metadata">

**Author:** ![Jiankai](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiankai/32/1070_2.png) [@Jiankai](https://openmc.discourse.group/u/Jiankai)\
**Post date:** [November 17, 2022, 10:29pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/14 "2022-11-17T22:29:13Z")

</div>

OpenMC does not need to define the vacuum outer space. So if I understood correctly, you just need to model a spherical shell without inner or outer space like this:

```auto
sph_1 = openmc.Sphere(r=15, boundary_type="reflective")
sph_2 = openmc.Sphere(r=16, boundary_type="reflective")
shell = openmc.Cell(region=+sph_1 & -sph_2 )
shell.fill = lithium
universe = openmc.Universe(cells=[shell])

```

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 10:37pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/15 "2022-11-17T22:37:47Z")

</div>

Thank you so much for your help! I tried but when I don’t define a vacuum I get this error, I saw a fix that I should define an empty cell and editted to these lines but I still get the same error:

sph\_1 = openmc.Sphere(r=15, boundary\_type=“reflective”)  
sph\_2 = openmc.Sphere(r=16, boundary\_type=“reflective”)  
shell = openmc.Cell(region=+sph\_1 & -sph\_2 )  
shell.fill = lithium  
empty\_cell = openmc.Sphere(r=17)  
empty\_cell=openmc.Cell(region=+sph\_2)  
universe = openmc.Universe(cells=[shell, empty\_cell])  
#universe.plot(width = (40.0, 40.0), colors={cell: “green”})  
geometry = openmc.Geometry(universe)  
geometry.export\_to\_xml()  
cell\_filter = openmc.CellFilter([shell, empty\_cell])

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/b/b7b94c047affd8cddc6056da3901f8c15ea7a94f.png)

---

<div class="post-metadata">

**Author:** ![Jiankai](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiankai/32/1070_2.png) [@Jiankai](https://openmc.discourse.group/u/Jiankai)\
**Post date:** [November 17, 2022, 10:44pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/16 "2022-11-17T22:44:22Z")

</div>

The source you defined is located at (0,0,0), where there is no defined geometry in this modeling. You should modify the source according to the geometry.

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 11:36pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/17 "2022-11-17T23:36:10Z")

</div>

I edited the empty\_cell to include the inside of the shell but the model got me a zero, how can I include the source in the geometry?

empty\_cell = openmc.Sphere(r=15)  
empty\_cell=openmc.Cell(region=-sph\_1)  
universe = openmc.Universe(cells=[shell, empty\_cell])

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/9/967012531d744827e16eacd2d3aefc23f8e89870.png)

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 11:41pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/18 "2022-11-17T23:41:35Z")

</div>

I finally got it after editing the lines to these:

sph\_1 = openmc.Sphere(r=15)  
sph\_2 = openmc.Sphere(r=16, boundary\_type=“vacuum”)  
shell = openmc.Cell(region=+sph\_1 & -sph\_2 )  
shell.fill = lithium  
empty\_cell = openmc.Sphere(r=15)  
empty\_cell=openmc.Cell(region=-sph\_1)  
universe = openmc.Universe(cells=[shell, empty\_cell])

Thank you so much for your help!

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/d/d751481d8f8b3df0fabf1384153a2286da7bb54d.png)

---

<div class="post-metadata">

**Author:** ![Jiankai](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/jiankai/32/1070_2.png) [@Jiankai](https://openmc.discourse.group/u/Jiankai)\
**Post date:** [November 17, 2022, 11:48pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/19 "2022-11-17T23:48:35Z")

</div>

sph\_1 is empty\_cell?  
I think there should be no problem. The very high leakage is caused by the vacuum boundary condition of sph\_2.

---

<div class="post-metadata">

**Author:** ![Dalia](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dalia](https://openmc.discourse.group/u/Dalia)\
**Post date:** [November 17, 2022, 11:56pm UTC](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483/20 "2022-11-17T23:56:48Z")

</div>

The empty cell is the empty space from the origin to sph\_1, I added it to be a geometry to the empty space inside. And the vacuum condition for sph\_2 is to avoid the no boundary error, I will make some trails to avoid this error some other way.

[Next page](https://openmc.discourse.group/t/cant-see-the-result-after-running-the-code/2483.md?page=2)
