Skip to content

Angular bins not handled when loading MGXS library #466

@DanShort12

Description

@DanShort12

I have an OpenMC MGXS library that has been generated with a Legendre order of 3. That setting is being used to ensure a good relationship between the total MGXS and CE cross section, and gives me a scattering matrix with shape 40 x 40 x 4 ([# groups in] x [# groups out] x [# angular bins]). However, when OpenMOC loads that library the scattering cross section is expected to have shape 40 x 40 (seemingly missing the [# angular bins] dimension). This results in an error raised from Material::setSigmaS because the expected number of energy groups (40) does not match the square root of the number of entries in the contiguous array being passed into the C++ method (in my case 80). This raises two questions to me:

  • Am I getting something wrong in my generation of the MGXS in OpenMC, or missing some intermediate processing between OpenMC and OpenMOC?
  • This error and the way the validation works in Material::setSigmaS seems to imply that OpenMOC only handles isotropic scattering - is that a correct observation, or am I missing something there? Section 3.3 of the user guide mentions isotropic concentrations, which is understandable, but does not suggest that the scattering has to be isotropic from my reading.

I've stripped down how I'm generating the MGXS and included below. It should be possible to run by extracting the OpenMC run files from openmc_run_files.zip and pointing the openmc_rundir variable to the directory that the zip has been unpacked into.

"""
Generate MGXS using existing OpenMC files.
"""

import openmc
import openmoc
import os

openmc_rundir = "."

materials = openmc.Materials.from_xml(f"{openmc_rundir}/materials.xml")
materials.cross_sections = os.environ["OPENMC_CROSS_SECTIONS"]
materials.export_to_xml(f"{openmc_rundir}/materials.xml")
geometry = openmc.Geometry.from_xml(f"{openmc_rundir}/geometry.xml", materials=materials)

mgxs_lib = openmc.mgxs.Library(geometry)
mgxs_lib.energy_groups = openmc.mgxs.EnergyGroups(openmc.mgxs.GROUP_STRUCTURES["CASMO-40"])
mgxs_lib.mgxs_types = ["total", "absorption", "nu-fission", "nu-scatter matrix"]
mgxs_lib.domain_type = "material"
mgxs_lib.domains = geometry.get_all_materials().values()
mgxs_lib.by_nuclide = False
mgxs_lib.legendre_order = 3
mgxs_lib.check_library_for_openmc_mgxs()

mgxs_lib.build_library()

openmc.run(cwd=openmc_rundir)

ce_spfile = f"{openmc_rundir}/statepoint_ce.h5"
os.rename(f"{openmc_rundir}/statepoint.10.h5", ce_spfile)
ce_sumfile = f"{openmc_rundir}/summary_ce.h5"
os.rename(f"{openmc_rundir}/summary.h5", ce_sumfile)

sp = openmc.StatePoint(ce_spfile, autolink=False)

su = openmc.Summary(ce_sumfile)
sp.link_with_summary(su)

mgxs_lib.load_from_statepoint(sp)

materials = openmoc.materialize.load_openmc_mgxs_lib(mgxs_lib)

Results in this error:

Traceback (most recent call last):
  File "examples/neutronics/openmc_mgxs_minimal.py", line 41, in <module>
    materials = openmoc.materialize.load_openmc_mgxs_lib(mgxs_lib)
  File "/home/dan/code/BLUEPRINT/.env/lib/python3.6/site-packages/openmoc/materialize.py", line 401, in load_openmc_mgxs_lib
    material.setSigmaS(sigma)
  File "/home/dan/code/BLUEPRINT/.env/lib/python3.6/site-packages/openmoc/openmoc.py", line 5517, in setSigmaS
    return _openmoc.Material_setSigmaS(self, xs)
RuntimeError: Unable to set sigma_s with 80.000000 groups for Material 1 which
...  contains 40 energy groups

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions