Multi-group problem throws "ERROR: Error processing cross_sections.xml file."

So I’m new to using OpenMC and simply want to run some simple multigroup reference calculations to compare to a deterministic transport code. To this end I’m trying to start by making the simple Godiva benchmark problem for use with OpenMC. I tried to follow along with the multigroup C5G7 example and make something similar. When I try and run this problem, I get to
Reading cross sections XML file...
and then…

ERROR: Error processing cross_sections.xml file.

Now since this is a multigroup problem it shouldn’t even be trying to read a cross_sections.xml and I’m not sure why it is. When I check my materials.xml file, it seems to correctly state <cross_sections>godivaxs.h5</cross_sections>. So I’m not sure what the issue is here?
For reference, here is my code (I can’t upload because I’m a new user apparently…):

import numpy as np
import openmc

# Create a 6-group structure with arbitrary boundaries (the specific boundaries are unimportant)
groups = openmc.mgxs.EnergyGroups(np.logspace(-5, 7, 7))
heu_xsdata = openmc.XSdata('heu', groups)
heu_xsdata.order = 0
# When setting the data let the object know you are setting the data for a temperature of 294K.
heu_xsdata.set_total([2.03390E-01, 2.15776E-01, 2.22849E-01, 2.49764E-01, 3.80023E-01,
                            5.75572E-01], temperature=294.)
heu_xsdata.set_absorption([5.87124E-02, 6.04511E-02, 6.08140E-02, 6.17109E-02, 7.58514E-02,
                            1.34638E-01], temperature=294.)
heu_xsdata.set_fission([1.66071E-01, 1.48354E-01, 1.40571E-01, 1.35796E-01, 1.59883E-01,
                            2.59502E-01], temperature=294.)
heu_xsdata.set_nu_fission([1.66071E-01, 1.48354E-01, 1.40571E-01, 1.35796E-01, 1.59883E-01,
                            2.59502E-01], temperature=294.)
heu_xsdata.set_chi([2.04000E-01, 3.44000E-01, 1.68000E-01, 1.80000E-01, 9.00000E-02,
                            1.40000E-02], temperature=294.)
# The scattering matrix is ordered with incoming groups as rows and outgoing groups as columns
# (i.e., below the diagonal is up-scattering).
scatter_matrix = \
    [[[5.77466E-02, 1.31155E-02, 1.79930E-02, 3.15630E-02, 2.13535E-02, 2.90602E-03],
      [0.00000E+00, 8.51132E-02, 1.18033E-02, 3.29071E-02, 2.20896E-02, 3.41169E-03],
      [0.00000E+00, 0.00000E+00, 1.11967E-01, 2.70439E-02, 1.95868E-02, 3.43729E-03],
      [0.00000E+00, 0.00000E+00, 0.00000E+00, 1.67026E-01, 1.71865E-02, 3.84056E-03],
      [0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 3.00331E-01, 3.84056E-03],
      [0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 4.40934E-01]]]
scatter_matrix = np.array(scatter_matrix)
scatter_matrix = np.rollaxis(scatter_matrix, 0, 3)
heu_xsdata.set_scatter_matrix(scatter_matrix, temperature=294.)
# Initialize the library
mg_cross_sections_file = openmc.MGXSLibrary(groups)
# Add the UO2 data to it
# And write to disk
# For every cross section data set in the library, assign an openmc.Macroscopic object to a material
heu_mat = openmc.Material(name='heu')
heu_mat.set_density('macro', 1.)

# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials([heu_mat])
# Set the location of the cross sections file to our pre-written set
materials_file.cross_sections = 'godivaxs.h5'

#create the godiva sphere surface
godiva_surf = openmc.Sphere(r=8.7407,boundary_type='vacuum')

#create the godiva cell
godiva_cell = openmc.Cell(name='godiva',region=-godiva_surf,fill=heu_mat)

#create the problem universe
root_universe = openmc.Universe(cells=[godiva_cell])

geometry = openmc.Geometry(root_universe)

# Create a starting point source
point = openmc.stats.Point((0, 0, 0))
source = openmc.Source(space=point)

settings = openmc.Settings()
settings.source = source
settings.batches = 100
settings.inactive = 10
settings.particles = 1000


Nevermind. I just realized that I need to specify that the problem is multigroup and that OpenMC doesn’t assume that for h5 xs files. I just added settings.energy_mode = 'multi-group' before settings.export_to_xml() and now it works.

1 Like