Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular bins not handled when loading MGXS library #466

Open
DanShort12 opened this issue Jul 3, 2020 · 3 comments
Open

Angular bins not handled when loading MGXS library #466

DanShort12 opened this issue Jul 3, 2020 · 3 comments

Comments

@DanShort12
Copy link

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
@DanShort12
Copy link
Author

I should mention I'm using v0.3.0 of OpenMOC and v0.11.0 of OpenMC

@GiudGiud
Copy link
Contributor

GiudGiud commented Jul 3, 2020

Hi Dan

The process is right but the angular dependence of group cross sections and scattering kernels are not supported in OpenMOC. I will fix the error message to make it more clear. You are right that the user's guide doesn't seem to be clear about this either, only the theory guide mentions sources are isotropic.

To model anisotropic scattering, the only supported option is the transport correction, which works really great for LWRs in the absence of control rods. I don't know how good it is for your system. This needs to be enabled before generating group cross sections in openmc, as additional tallies are required, with:
mgxs_lib.correction = 'P0'
This will modify the total group cross section (which becomes the transport group cross section) and adjust the inscatter group cross section accordingly. The current implementation uses the flux-limited approximation. If this works for you, that's great because there is no extra steps.

If not, a much better method to obtain transport group cross sections is the cumulative migration method (CMM), described in this masters or this paper
Issue openmc-dev/openmc#1541 mentions a branch that you can use to obtain the migration area of neutrons, from which you can obtain both diffusion coefficients (for diffusion calculations) and transport cross sections.

However, there is no heterogeneous tally of CMM implemented yet, so you'll have to obtain the transport correction ratio (=transport / total group cross section) for each material independently, with homogeneous medium calculations. For LWRs, it was sufficient to only do this for the water.

Guillaume

@DanShort12
Copy link
Author

Hi Guillaume,

Thanks for the detailed notes. I'll loop back with the team to see what approach we'd like to take - from a quick test the P0 correction didn't seem to give a good match between the CE cross sections and MGXS for our use case. We may take a look at the CMM implementation to see if we can make use of that.

An update to the docs and tweak to the error message seems like a reasonable approach here for now.

Thanks again,
Dan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants