I was trying to calculate the flux distribution of a CAD geometry. But is shows KeyError. My code is given below:
import openmc
from IPython.display import Image
from matplotlib import pyplot as plt
materials
u235 = openmc.Material(name=“fuel”)
u235.add_nuclide(‘U235’, 1.0, ‘ao’)
u235.set_density(‘g/cc’, 11)
water = openmc.Material(name=“water”)
water.add_nuclide(‘H1’, 2.0, ‘ao’)
water.add_nuclide(‘O16’, 1.0, ‘ao’)
water.set_density(‘g/cc’, 1.0)
water.add_s_alpha_beta(‘c_H_in_H2O’)
materials = openmc.Materials([u235,water])
#Importing_CAD_GEOMETRY
dagmc_univ = openmc.DAGMCUniverse(filename=‘bal4.h5m’, auto_geom_ids=True, auto_mat_ids=True)
bounding_box = openmc.model.RectangularParallelepiped(-20,20,-20,20,-20,20,boundary_type=‘vacuum’)
#Geometry
cell = openmc.Cell(region=-bounding_box, fill=dagmc_univ)
geometry = openmc.Geometry([cell])
#Settings
settings = openmc.Settings()
settings.batches = 120
settings.inactive = 2
settings.particles = 1000
model = openmc.Model(geometry=geometry, materials=materials, settings=settings)
model.export_to_model_xml()
#ploting
p = openmc.Plot()
p.width = (25.0, 25.0)
p.pixels = (400, 400)
p.color_by = ‘material’
p.colors = {u235: ‘yellow’, water:‘red’}
openmc.plot_inline(p)
#Tally
itally = openmc.Tally()
tally.filters = [openmc.DistribcellFilter(cell)]
tally.scores = [‘flux’]
tallies = openmc.Tallies([tally])
tallies.export_to_xml()
openmc.run()
with openmc.StatePoint(‘statepoint.120.h5’) as sp:
t = sp.tallies[1]
flux = t.mean.ravel()
df = t.get_pandas_dataframe()
print(df)
If someone can correct my code that how can I calculate the flux distribution or power distribution for a CAD geometry than, it would be great for me.
Thanks in advance