Tally give no result , error sources

Hi
It was very useful to read through the posts here to build my first file, which helped me improve the file to run. However, the tally doesn’t provide results. The idea of this simulation is to construct an exercise to measure the flux absorption fraction at the detector (sphere z=100) due to a sample at z=50 cm and the source near z=0. I used a sphere for now for the sake of simplicity in their description further the sample will be change to a disc. I looked carefully into geometry and cells definition but still no result in scoring flux at detector assumed cell.
here is the file
%matplotlib inline
import openmc
import matplotlib.pyplot as plt

sample= openmc.Material(material_id=1, name=‘SAMPLE’)
sample.add_nuclide(‘Al27’,1)
sample.set_density(‘g/cm3’, 2.7)

air = openmc.Material(material_id=2, name=‘air’)
air.add_element(‘N’, .788903, ‘ao’)
air.add_nuclide(‘O16’, .211097, ‘ao’)
air.set_density(‘atom/b-cm’, 4.614e-5)

materials = openmc.Materials([ sample , air])

materials.cross_sections =‘/…/endfb71/endfb-vii.1-hdf5/cross_sections.xml’
materials.export_to_xml()

s101= openmc.Sphere(x0=0, y0=0,z0=50, r=10,boundary_type=‘transmission’)
s202= openmc.Sphere(x0=0, y0=0,z0=100, r=10,boundary_type=‘transmission’)
s303= openmc.Sphere(x0=0, y0=0,z0=80, r=70,boundary_type=‘transmission’)
s404= openmc.Sphere(x0=0, y0=0,z0=80, r=75,boundary_type=‘vacuum’)

cells

cell1 = openmc.Cell(name=‘Sample_50cm’)
cell1.fill = sample
cell1.region = -s101 # & +s202

cell2 = openmc.Cell(name=‘Detector’)
cell2.fill = air
cell2.region = -s202 # & +s101

cell3 = openmc.Cell(name=‘air’)
cell3.fill = air
cell3.region = -s303 & +s101 & +s202

cell4 = openmc.Cell(name=‘viod’)
cell4.region = -s404 & +s303 # & +s101 & +s202

universes

univ = openmc.Universe(cells=[cell1, cell2, cell3, cell4]) #
geom = openmc.Geometry(root=univ)

geom.export_to_xml(‘geometry.xml’)

geom.plot(width=(200, 300), basis=‘xz’, label=‘cell’)

Settings

settings = openmc.Settings()
settings.batches = 100
settings.inactive = 10
settings.particles = 10000
settings.run_mode = ‘fixed source’

source

source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 10))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([01.2e6], [1.0])
settings.source = source

flux tally

tallies = openmc.Tallies()
tally = openmc.Tally(name=‘flux’)
tally.filters = [openmc.CellFilter(cell2)]
tally.scores = [‘flux’]

settings.tallies = [tally]

settings.export_to_xml()

Run OpenMC!

!openmc

Any help will be appreciated
Thank you

Hi Al-Ghamdi,

Tally is not a part of settings. The last two lines of your flux tally block should be:

tallies = [tally] # not settings.tallies = [tally]
tallies.export_to_xml() # not settings.export_to_xml()

Hope this helps!

Xinyan

Hi waxinyan
Yes that was one part of the problem the other i solved regarding the definitions of cell 1 and 2.

Thank you