Hi everyone,
I have been using the DAGMC Cubit plugin to produce some DAGMC geometries that I could load into OpenMC. It seems to work well and I was able to successfully perform some eigenvalue calculations which yield sensible results.
However when trying to plot these geometries to check that the entire process went well, I noticed some weird artifacts on the resulting images. Since I could not trace these artifacts back to any of the DAGMC/Cubit operations I performed, I tried plotting the ready-made DAGMC geometries available in the openmc-notebooks repo. In particular I plotted the teapot running the following script:
import openmc
import math
from matplotlib import pyplot as plt
import urllib.request
teapot_url = 'https://tinyurl.com/y4mcmc3u' # 29 MB
def download(url, filename="dagmc.h5m"):
"""
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(filename, 'wb') as f:
f.write(u.read())
download(teapot_url, "teapot.h5m")
dagmc_univ = openmc.DAGMCUniverse(filename="teapot.h5m")
geometry = openmc.Geometry(root=dagmc_univ)
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)
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')
water.id = 41
materials = openmc.Materials([iron, water])
settings = openmc.Settings()
settings.batches = 10
settings.particles = 5000
settings.run_mode = "fixed source"
space = openmc.stats.Box(*geometry.bounding_box)
my_source = openmc.Source(space=space, domains=[water])
my_source.energy = openmc.stats.Discrete(x=[12.0,], p=[1.0,])
settings.source = my_source
mesh = openmc.RegularMesh() # could use from_domain here to avid setting lower_left and upper_right
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']
water_filter = openmc.CellFilter([5])
water_tally = openmc.Tally()
water_tally.filters = [mesh_filter, water_filter]
water_tally.scores = ['flux']
tallies = openmc.Tallies([pot_tally, water_tally])
model = openmc.Model(materials=materials, geometry=geometry, settings=settings, tallies=tallies)
p = openmc.Plot()
p.basis = 'xy'
p.origin = (0.0, 0.0, 0.0)
p.width = (50., 50.)
p.pixels = (1000, 971)
p.color_by = 'cell'
p.colors = {iron: 'gray', water: 'blue'}
model.plots = openmc.Plots(plots=[p])
model.export_to_model_xml()
openmc.plot_geometry()
The resulting plot looks like this:
Here we can clearly see the teapot’s body, spout, and handle, as well as the DAGMC graveyard. However we also see that there is some green tea bleeding into the implicit complement filled with void, we can also see some undefined white space.
Has anyone run into these problems before? I am wondering if these artifacts come from the plotting operation, or if there are some underlying issues with the CAD geometry.
Thanks,
Nicolas