CAD geometry compilation error

My OpenMC code is given below:

import urllib.request

fuel_pin_url = 'https://tinyurl.com/y3ugwz6w' # 1.2 MB
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())

%matplotlib inline
from IPython.display import Image
import openmc
import os
os.environ['OPENMC_CROSS_SECTIONS']='/home/dresden/endfb-viii.0-hdf5/cross_sections.xml'

 # materials
uo2=openmc.Material()
uo2.add_nuclide('U235', 0.03)
uo2.add_nuclide('U238', 0.97)
uo2.add_nuclide('O16', 2.0)
uo2.set_density('g/cm3', 10.0)

water = openmc.Material(name="h2o")
water.add_nuclide('H1', 2.0)
water.add_nuclide('O16', 1.0)
water.set_density('g/cm3', 1.0)

water.add_s_alpha_beta('c_H_in_H2O')

materials = openmc.Materials([uo2, water])

materials.export_to_xml()

download(fuel_pin_url)

settings = openmc.Settings()
settings.dagmc = True
settings.batches = 10
settings.inactive = 2
settings.particles = 5000
settings.export_to_xml()

p = openmc.Plot()
p.width = (25.0, 25.0)
p.pixels = (400, 400)
p.color_by = 'material'
p.colors = {uo2: 'yellow', water: 'blue'}
openmc.plot_inline(p)

this code is similar to an example of a model given in the openMC documentation. But it shows a compilation error

RuntimeError: Geometry XML file ‘geometry.xml’ does not exist!

Can anyone help me to generate xml file for CAD geometry in openMC?

The following lines should be what’s needed (you may need to change the filename passed to DAGMCUniverse depending on your model):

dagmc_univ = openmc.DAGMCUniverse("dagmc.h5m")
geometry = openmc.Geometry(dagmc_univ)
geometry.export_to_xml()

Hi Paul
how can I install DAGMC for OpenMC?

DAGMC installation instructions can be found here. With DAGMC installed, you can find details on how to build OpenMC with DAGMC support here (scroll down to the blue “Optional” box and there’s a bullet point about DAGMC).

1 Like

Paul, how can I produce CAD geometry to run in openMC using DAGMC tool? Does there any mesh generating tool remain which can generate mesh which is directly convertible in h5m file?

There are several tools for making DAGMC geometry

The available tools are at different levels of maturity.
some are licensed and some open source.

We maintain a list of DAGMC tools here and it includes some geometry creation tools

1 Like