Skip to content

Add cell_wise MGXS generation method#3987

Open
jon-proximafusion wants to merge 1 commit into
openmc-dev:developfrom
shimwell:convert-to-multigroup-material-cell-wise
Open

Add cell_wise MGXS generation method#3987
jon-proximafusion wants to merge 1 commit into
openmc-dev:developfrom
shimwell:convert-to-multigroup-material-cell-wise

Conversation

@jon-proximafusion

@jon-proximafusion jon-proximafusion commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Add a cell_wise MGXS generation method

model.convert_to_multigroup(method="cell_wise", groups=...)

Like material_wise, but gives each cell its own multigroup cross sections, so it
captures the intra-material spatial variation that material_wise averages away
(for example a steel material reused in several cells).

Implementation

Full reuse of the material_wise path. Before generation, the material in every
material-filled cell is cloned (each clone gets a unique id via
Material.clone()). The standard per-material generation then produces and assigns
one cross section set per cell. The only new code is the per-cell cloning step in
convert_to_multigroup plus the dispatch entry (about 20 lines). material_wise
behavior is unchanged.

Works for both CSG and DAGMC. convert_to_multigroup already synchronizes DAGMC
cells before generation, so the per-cell clones become standard DAGMC per-cell
material overrides with no special handling.

Contents

  • openmc/model/model.py: the per-cell cloning step and dispatch entry.
  • tests/unit_tests/test_model.py: CSG unit test (two cells sharing a material get
    distinct macroscopics).
  • tests/unit_tests/dagmc/test_convert_to_multigroup.py: DAGMC unit test (a model
    with two fuel volumes sharing one material yields three distinct per-cell
    macroscopics).
  • docs/source/usersguide/random_ray.rst: adds cell_wise to the method
    list and to the "Comparison of Automatic MGXS Generation Methods" table.

Verification

  • CSG: a 4-shell single-material sphere produces four distinct per-cell cross
    section sets, while material_wise on the same model produces one (regression
    intact).
  • DAGMC: the 5-volume dagmc.h5m model (two fuel volumes sharing one material,
    plus water) yields three distinct per-cell macroscopics; void volumes are
    skipped.

Status

@jon-proximafusion
jon-proximafusion force-pushed the convert-to-multigroup-material-cell-wise branch from 1f966fd to 8698b76 Compare June 30, 2026 16:32
@shimwell
shimwell requested a review from jtramm June 30, 2026 16:33
Add method="cell_wise" to Model.convert_to_multigroup: like material_wise, but
gives each cell its own multigroup cross sections. The material in every
material-filled cell is cloned (each clone gets a unique id), then the standard
per-material generation runs, so per material becomes per cell. This captures the
intra-material spatial-spectrum variation that material_wise averages away when
one material spans a strong gradient.

The implementation reuses the material_wise path entirely; the only new code is
the per-cell cloning step in convert_to_multigroup plus the dispatch entry. Adds
unit tests (CSG and DAGMC: two cells sharing a material get distinct
macroscopics) and a user guide entry in the MGXS methods table.

Builds on the name+id library keying from openmc-dev#3984 (now in develop).

Co-authored-by: jon-proxima <jon@proximafusion.com>
@jon-proximafusion
jon-proximafusion force-pushed the convert-to-multigroup-material-cell-wise branch from 8698b76 to 3681d7c Compare July 1, 2026 07:42
@jon-proximafusion jon-proximafusion changed the title Add material_cell_wise MGXS generation method Add cell_wise MGXS generation method Jul 1, 2026

@jtramm jtramm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @jon-proximafusion -- thanks so much for adding it in! I think it should be a cheap way of improving fidelity vs. the current material-wise method.

Just one small comment below on adding some extra clarifying discussions to the docs.

Additionally - we currently have end-to-end testing for all the MGXS generation techniques in tests/regression_tests/random_ray_auto_convert/test.py, so you could add the new method to the @parametrize list there to test it as well.

Comment on lines +678 to +686
* Like ``material_wise``, but clones the material in each cell so every
cell gets its own cross sections (each material-filled cell is assigned a
distinct macroscopic).
- * Resolves intra-material spatial variation that ``material_wise`` averages
away, e.g. a thick shield or a steep flux gradient within a single material
* Captures spatial self shielding between cells filled with the same material
- * Most expensive (one cross section set per cell) and a larger library
* Same far-from-source limitation as ``material_wise``: a cell that is not
tallied to yields zero cross sections for that cell

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a note clarifying that it is generating unique MGXS data for each cell and not for each cell instance. Basically, it would be nice to alert the user that a cell that shows up in multiple locations of a lattice would have the same MGXS data set for all locations. If this type of discussion ends up being too wordy for the table formatting, perhaps it can be included as regular text elsewhere in the section.

  • Resolves intra-material spatial variation that material_wise averages
    away, e.g. a thick shield or a steep flux gradient within a single material
  • Captures spatial self shielding between cells filled with the same material

I don't completely agree with, as a cell may still be very large and have a steep gradient within it. A full shield wall may easily just be defined with one cell, in which case, you still are sharing the same MGXS throughout the full wall (even if you had applied a cell-under-voxel overlay to make smaller source regions). You only get an improvement if you had manually broken the shield wall down in your geometry definition into multiple cells that cover different depths of the wall. Basically, we don't want to oversell this method in terms of fidelity.

@jtramm jtramm added the MGXS label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants