Hi,
I’m looking to extract the neutron heating or the deposited neutron energy spatially within a component. Currently, I am trying to modify the ‘Using CAD-Based Geometries’ to extract the neutron heating through the heating-local tally score. When doing this I can extract the flux at each point in space and the heating score, but the heating-local tally is always zero. I am running this in a docker container taken from GitHub - fusion-energy/neutronics-workshop: A workshop covering a range of fusion relevant analysis and simulations with OpenMC, DAGMC, Paramak and other open source fusion neutronics tools and I will include the script below that I am running.
#From https://nbviewer.org/github/openmc-dev/openmc-notebooks/blob/main/cad-based-geometry.ipynb
import urllib.request
import openmc
# from matplotlib import pyplot as plt
openmc.data.IncidentNeutron.from_njoy
##################
# DEFINE MATERIALS
##################
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') Have to remove due to issue in new docker container - see OmniFlow doc 03/01/23
water.id = 41
iron = openmc.Material(name="iron")
iron.add_nuclide("Fe54", 0.0564555822608)
iron.add_nuclide("Fe56", 0.919015287728)
iron.add_nuclide("Fe57", 0.0216036861685)
iron.add_nuclide("Fe58", 0.00292544384231)
iron.set_density("g/cm3", 7.874)
mats = openmc.Materials([iron, water])
mats.export_to_xml()
##################
# DEFINE GEOMETRY
##################
teapot_url = 'https://tinyurl.com/y4mcmc3u' # 29 MB
def download(url):
"""
Helper function for retrieving dagmc models
"""
u = urllib.request.urlopen(url)
if u.status != 200:
raise RuntimeError("Failed to download file.")
# save file as dagmc.h5m
with open("dagmc.h5m", 'wb') as f:
f.write(u.read())
download(teapot_url)
dagmc_univ = openmc.DAGMCUniverse(filename="dagmc.h5m")
geometry = openmc.Geometry(root=dagmc_univ)
geometry.export_to_xml()
##################
# DEFINE SETTINGS
##################
settings = openmc.Settings()
settings.batches = 5
settings.particles = 50000
settings.run_mode = "fixed source"
src_locations = ((-4.0, 0.0, -2.0),
( 4.0, 0.0, -2.0),
( 4.0, 0.0, -6.0),
(-4.0, 0.0, -6.0),
(10.0, 0.0, -4.0),
(-8.0, 0.0, -4.0))
# we'll use the same energy for each source
src_e = openmc.stats.Discrete(x=[12.0,], p=[1.0,])
# create source for each location
sources = []
for loc in src_locations:
src_pnt = openmc.stats.Point(xyz=loc)
src = openmc.Source(space=src_pnt, energy=src_e)
sources.append(src)
src_str = 1.0 / len(sources)
for source in sources:
source.strength = src_str
settings.source = sources
settings.export_to_xml()
mesh = openmc.RegularMesh()
mesh.dimension = (120, 1, 40)
mesh.lower_left = (-20.0, 0.0, -10.0)
mesh.upper_right = (20.0, 1.0, 4.0)
mesh_filter = openmc.MeshFilter(mesh)
pot_filter = openmc.CellFilter([1])
pot_tally = openmc.Tally()
pot_tally.filters = [mesh_filter, pot_filter]
pot_tally.scores = ['flux', 'heating-local', 'heating']
water_filter = openmc.CellFilter([5])
water_tally = openmc.Tally()
water_tally.filters = [mesh_filter, water_filter]
water_tally.scores = ['flux', 'heating-local', 'heating']
tallies = openmc.Tallies([pot_tally, water_tally])
tallies.export_to_xml()
openmc.run(tracks=True) # Run in tracking mode for visualisation of tracks through CAD
Apologies if this is very basic to resolve, as I am still new to OpenMC.
Thanks,
Will