Skip to content

Add material_cell_wise MGXS generation method - #119

Closed
jon-proximafusion wants to merge 1 commit into
developfrom
convert-to-multigroup-material-cell-wise
Closed

jon-proximafusion wants to merge 1 commit into
developfrom
convert-to-multigroup-material-cell-wise

Conversation

@jon-proximafusion

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

Copy link
Copy Markdown
Collaborator

Add a material_cell_wise MGXS generation method

model.convert_to_multigroup(method="material_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 thick shield modeled as a single material, or a steep flux gradient
within one material).

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 material_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 b33becb to a971b58 Compare June 30, 2026 14:47
@jon-proximafusion
jon-proximafusion changed the base branch from convert-mgxs-preserve-material-names to develop June 30, 2026 14:47
@jon-proximafusion jon-proximafusion changed the title Add material_cell_wise MGXS generation method (draft, stacked on #3984) Add material_cell_wise MGXS generation method Jun 30, 2026
@jon-proximafusion
jon-proximafusion force-pushed the convert-to-multigroup-material-cell-wise branch 4 times, most recently from 1f966fd to 8698b76 Compare June 30, 2026 16:32
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
@shimwell shimwell closed this Jul 1, 2026
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

Successfully merging this pull request may close these issues.

2 participants