# Question for mesh tallys and cells, very different values

**URL:** <https://openmc.discourse.group/t/question-for-mesh-tallys-and-cells-very-different-values/3152>\
**Category:** User Support\
**Created:** [June 27, 2023, 8:16am UTC](https://openmc.discourse.group/t/question-for-mesh-tallys-and-cells-very-different-values/3152 "2023-06-27T08:16:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Thomas](https://openmc.discourse.group/u/Thomas)\
**Post date:** [June 27, 2023, 8:16am UTC](https://openmc.discourse.group/t/question-for-mesh-tallys-and-cells-very-different-values/3152/1 "2023-06-27T08:16:33Z")

</div>

Hello,

Using OpenMC I’ve got some strange values on some cases.

I’ve found that OpenMC is able to give me Mesh tally values non consistant on the same space for spherical or regular Mesh

===================\> TALLY 8: DOSE G AVANT 1M \<====================

Mesh Index (1, 1, 1)  
Energy Function f([1.0e+04, …, 1.0e+10]) = [2.9e-02, …, 2.8e+02]  
Particle: photon  
Total Material  
Flux 13151.5 +/- 61.4526  
==================\> TALLY 9: DOSE G AVANT 1M R \<===================

Mesh Index (1, 1, 1)  
Energy Function f([1.0e+04, …, 1.0e+10]) = [2.9e-02, …, 2.8e+02]  
Particle: photon  
Total Material  
Flux 7.81904e+06 +/- 1591.38

Both tally have the same volume (around 64k)  
[statepoint.tally.h5](https://openmc.discourse.group/uploads/short-url/mM2FIV86NLawpeUW999FHpCxxpj.h5) (78.3 KB)  
[tally\_exemple.ipynb](https://openmc.discourse.group/uploads/short-url/7XErFVIOC2fLhmg7hFpTeQx4OW.ipynb) (1.3 MB)

But when I’ve modelised the sphere in geometry, values were consitent for the 3 tallys…

===================\> TALLY 11: DOSE G AVANT 1M \<===================

Mesh Index (1, 1, 1)  
Energy Function f([1.0e+04, …, 1.0e+10]) = [2.9e-02, …, 2.8e+02]  
Particle: photon  
Total Material  
Flux 8.00043e+06 +/- 16269.6  
==================\> TALLY 12: DOSE G AVANT 1M R \<==================

Mesh Index (1, 1, 1)  
Energy Function f([1.0e+04, …, 1.0e+10]) = [2.9e-02, …, 2.8e+02]  
Particle: photon  
Total Material  
Flux 7.82251e+06 +/- 15634.9  
================\> TALLY 13: DOSE G AVANT 1M CELL \<=================

Cell 6  
Energy Function f([1.0e+04, …, 1.0e+10]) = [2.9e-02, …, 2.8e+02]  
Particle: photon  
Total Material  
Flux 8.00513e+06 +/- 16268.7

[statepoint.tally\_and\_vol.h5](https://openmc.discourse.group/uploads/short-url/s4XLojAWjo2ixCYAoTKHJMyZZen.h5) (84.5 KB)  
[tally\_and\_vol.ipynb](https://openmc.discourse.group/uploads/short-url/o6w9K9Fnc26uGvMjHyUoszI8Tki.ipynb) (144.9 KB)

I don’t see were is my mistake or if there is some thing to avoid using tallys ?

---

<div class="post-metadata">

**Author:** ![Thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Thomas](https://openmc.discourse.group/u/Thomas)\
**Post date:** [June 30, 2023, 8:51am UTC](https://openmc.discourse.group/t/question-for-mesh-tallys-and-cells-very-different-values/3152/2 "2023-06-30T08:51:05Z")

</div>

I’ve done an orher test, with an other Spherical tally just 0.01 cm away from the cell.

The one on the cell is still adequate with the cell, the one not coincident is giving back the odd results.

Is this an identificated bug ?

---

<div class="post-metadata">

**Author:** ![M\_Zammataro](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@M\_Zammataro](https://openmc.discourse.group/u/M_Zammataro)\
**Post date:** [July 4, 2023, 4:34pm UTC](https://openmc.discourse.group/t/question-for-mesh-tallys-and-cells-very-different-values/3152/3 "2023-07-04T16:34:07Z")

</div>

Dear Thomas,

I have tried to understand your problem and test case. Please find here my thoughts.

In your fixed source simulation, you’ve created a spherical mesh and an isotropic point source located at the origin of the reference frame. The source emits particles in air, in a medium that extends almost to infinity. The spherical mesh is very simple and represents a sphere of radius of 25cm as a single shell centered at a distance of 1m from the source.

Within the spherical mesh, I’ve set two different flux tallies: the first one uses a collision estimator, while the second one uses a tracklength estimator.

The estimate of the flux obtained with the collision estimator is fine, while the one obtained with the tracklength estimator seems unphysical (orders of magnitude lower).

If the source is placed inside the sphere, both estimates are good.

If I use a Cartesian mesh instead of a spherical one, thus using a cube as a detector zone instead of a sphere, both estimates still match.

If I use a spherical volume with the same dimensions as the spherical mesh, but created with a CellFilter, as the detector zone, both estimates still match.  
An interesting fact is that, like you said, if the spherical volume created with a CellFilter matches with the spherical mesh, the tracklength and collision estimates match in the tallies set within the spherical mesh too.

I will paste my code in the comment below, since as a new user I can’t upload the file.

We are afraid that there could be a problem with the calculation of the chord length in the case of the spherical mesh. We would like to have the developers’ opinion on this matter.

Thank you very much in advance for your kind attention and support.

---

<div class="post-metadata">

**Author:** ![M\_Zammataro](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@M\_Zammataro](https://openmc.discourse.group/u/M_Zammataro)\
**Post date:** [July 4, 2023, 4:34pm UTC](https://openmc.discourse.group/t/question-for-mesh-tallys-and-cells-very-different-values/3152/4 "2023-07-04T16:34:43Z")

</div>

import openmc  
import numpy as np  
import pandas as pd

import os  
os.environ[‘OPENMC\_CROSS\_SECTIONS’] = ‘’  
openmc.config[‘cross\_sections’] = ‘’

# Materials

air=openmc.Material(name=‘air’)  
air.add\_element(‘N’,80)  
air.add\_element(‘O’,20)  
air.set\_density(‘g/cm3’,1.3e-3)

materials = openmc.Materials([air])  
materials.export\_to\_xml()

# Geometry

# Limiting Planes

Xm = openmc.XPlane( x0=-300, name=‘X-’, boundary\_type=‘vacuum’)  
Xp = openmc.XPlane( x0=+300, name=‘X+’, boundary\_type=‘vacuum’)  
Ym = openmc.YPlane( y0=-300, name=‘Y-’, boundary\_type=‘vacuum’)  
Yp = openmc.YPlane( y0=+300, name=‘Y+’, boundary\_type=‘vacuum’)  
Bottom= openmc.ZPlane(z0= 0, boundary\_type=‘vacuum’)  
Top= openmc.ZPlane(z0= 300, boundary\_type=‘vacuum’)

# Create root Universe

root\_universe = openmc.Universe(universe\_id=0, name=‘root universe’)

# Create a cell to be used as a spherical detector

detector\_sphere = openmc.Sphere(r = 25, x0 = 100, y0 = 0, z0 = 150) #Uncomment to simulate the case in which the source is outside the sphere  
#detector\_sphere = openmc.Sphere(r = 25, x0 = 0, y0 = 0, z0 = 150) #Uncomment to simulate the case in which the source is inside the sphere  
#detector\_sphere = openmc.Sphere(r = 25, x0 = 0, y0 = 100, z0 = 150) #Uncomment to simulate the effect of superimposing MeshFilter and CellFilter  
detector\_cell = openmc.Cell(fill = air, region = -detector\_sphere)

# Create Main Region

main\_cell = openmc.Cell(name=‘source et fill’)  
main\_cell.fill = air  
main\_cell.region = -Top & +Bottom & -Yp & +Xm & +Ym & -Xp & +detector\_sphere

root\_universe.add\_cells([main\_cell,detector\_cell])

# Create Geometry and set root Universe

geometry = openmc.Geometry(root\_universe)

# Export to “geometry.xml”

geometry.export\_to\_xml()

cubic\_mesh = openmc.RegularMesh()  
cubic\_mesh.dimension = [1, 1, 1]  
cubic\_mesh.lower\_left = [-20, 80, 130] #Uncomment to simulate the case in which the source is outside the sphere  
cubic\_mesh.upper\_right = [+20, 120, 170] #Uncomment to simulate the case in which the source is outside the sphere  
#cubic\_mesh.lower\_left = [-20, -20, 130] #Uncomment to simulate the case in which the source is inside the sphere  
#cubic\_mesh.upper\_right = [+20, 20, 170] #Uncomment to simulate the case in which the source is inside the sphere#  
cubic\_mesh\_filter = openmc.MeshFilter(cubic\_mesh)

spherical\_mesh = openmc.SphericalMesh()  
spherical\_mesh.origin = [0,100,150] #Uncomment to simulate the case in which the source is outside the sphere  
#spherical\_mesh.origin = [0,0,150] #Uncomment to simulate the case in which the source is inside the sphere  
spherical\_mesh.r\_grid = [0,25.]  
spherical\_mesh\_filter = openmc.MeshFilter(spherical\_mesh)

cellfilter = openmc.CellFilter(detector\_cell)

# Instantiate an empty Tallies object

tallies = openmc.Tallies()

# Flux tally - Cube Tracklength

cube\_track = openmc.Tally(name=‘Cube Tracklength’)  
cube\_track.filters = [cubic\_mesh\_filter]  
cube\_track.scores = [‘flux’]  
cube\_track.estimator = ‘tracklength’  
tallies.append(cube\_track)

# Flux tally - Sphere Tracklength

sphere\_track = openmc.Tally(name=‘Sphere Tracklength’)  
sphere\_track.filters = [spherical\_mesh\_filter]  
sphere\_track.scores = [‘flux’]  
sphere\_track.estimator = ‘tracklength’  
tallies.append(sphere\_track)

# Flux tally - Cube Collision

cube\_coll = openmc.Tally(name=‘Cube Collision’)  
cube\_coll.filters = [cubic\_mesh\_filter]  
cube\_coll.scores = [‘flux’]  
cube\_coll.estimator = ‘collision’  
tallies.append(cube\_coll)

# Flux tally - Sphere Collision

sphere\_coll = openmc.Tally(name=‘Sphere Collision’)  
sphere\_coll.filters = [spherical\_mesh\_filter]  
sphere\_coll.scores = [“flux”]  
sphere\_coll.estimator = ‘collision’  
tallies.append(sphere\_coll)  
tallies.export\_to\_xml()

# Flux tally - Spherical Cell Tracklength

cell\_track = openmc.Tally(name=‘Cell Tracklength’)  
cell\_track.filters = [cellfilter]  
cell\_track.scores = [‘flux’]  
cell\_track.estimator = ‘tracklength’  
tallies.append(cell\_track)

# Flux tally - Spherical Cell Collision

cell\_coll = openmc.Tally(name=‘Cell Collision’)  
cell\_coll.filters = [cellfilter]  
cell\_coll.scores = [“flux”]  
cell\_coll.estimator = ‘collision’  
tallies.append(cell\_coll)  
tallies.export\_to\_xml()

# Source

src = openmc.Source()  
src.space=openmc.stats.Point((0.0000, 0.0000, 150.))  
src.energy = openmc.stats.Discrete([1.3e6],1)  
src.strength = 1e10  
src.particle =‘photon’  
src.angle = openmc.stats.Isotropic()

# Settings

settings = openmc.Settings()  
settings.source = src  
settings.seed = 2  
settings.run\_mode=‘fixed source’  
settings.batches = 1000  
settings.inactive = 20  
settings.particles = 4000  
settings.export\_to\_xml()

# Run the model

openmc.run()

# post\_processing

with openmc.StatePoint(“statepoint.1000.h5”) as sp:

```
cube_track = sp.get_tally(name='Cube Tracklength')
sphere_track = sp.get_tally(name='Sphere Tracklength')
cube_coll = sp.get_tally(name='Cube Collision')
sphere_coll = sp.get_tally(name='Sphere Collision')
cell_track = sp.get_tally(name='Cell Tracklength')
cell_coll = sp.get_tally(name='Cell Collision')

```

sp.close()

print(“Tracklength Estimator - Sphere: " + str(sphere\_track.mean[0,0,0]))  
print(“Collision Estimator - Sphere: " + str(sphere\_coll.mean[0,0,0]))  
print(”\n\n”)  
print(“Tracklength Estimator - Cube: " + str(cube\_track.mean[0,0,0]))  
print(“Collision Estimator - Cube: " + str(cube\_coll.mean[0,0,0]))  
print(”\n\n”)  
print("Tracklength Estimator - Spherical Cell: " + str(cell\_track.mean[0,0,0]))  
print("Collision Estimator - Spherical Cell: " + str(cell\_coll.mean[0,0,0]))

---

<div class="post-metadata">

**Author:** ![Thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Thomas](https://openmc.discourse.group/u/Thomas)\
**Post date:** [August 2, 2023, 2:42pm UTC](https://openmc.discourse.group/t/question-for-mesh-tallys-and-cells-very-different-values/3152/5 "2023-08-02T14:42:29Z")

</div>

Is there any news on this topic ?

Seems to me to be a bug on this feature…
