OpenMC/tests/unit_tests/dagmc/test_convert_to_multigroup.py
John Tramm 54b661d39f
Some checks failed
Tests and Coverage / filter-changes (push) Has been cancelled
dockerhub-publish-develop / main (push) Has been cancelled
dockerhub-publish-develop-dagmc-libmesh / main (push) Has been cancelled
dockerhub-publish-develop-dagmc / main (push) Has been cancelled
dockerhub-publish-develop-libmesh / main (push) Has been cancelled
Tests and Coverage / Python 3.13 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Has been cancelled
Tests and Coverage / Python 3.14 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Has been cancelled
Tests and Coverage / Python 3.14t (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=n, mpi=n, dagmc=n, libmesh=n, event=n (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=n, libmesh=n, event=n (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=n, mpi=y, dagmc=n, libmesh=n, event=n (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=n, libmesh=n, event=n (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=y, event= (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=, event=y (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=y, libmesh=, event= (push) Has been cancelled
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=, libmesh=y, event= (push) Has been cancelled
Tests and Coverage / coverage (push) Has been cancelled
Tests and Coverage / Check CI status (push) Has been cancelled
MGXS Bootstrapping (#3965)
Co-authored-by: John Tramm <jtramm@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
2026-07-22 05:38:20 +00:00

53 lines
1.8 KiB
Python

"""Test that convert_to_multigroup works with DAGMC models without requiring
particles/batches to be set beforehand.
"""
from pathlib import Path
import pytest
import openmc
import openmc.lib
pytestmark = pytest.mark.skipif(
not openmc.lib._dagmc_enabled(),
reason="DAGMC CAD geometry is not enabled.")
def test_convert_to_multigroup_without_particles_batches(run_in_tmpdir):
"""Test that convert_to_multigroup works with DAGMC model without
setting particles/batches beforehand."""
openmc.reset_auto_ids()
mat = openmc.Material(name="mat")
mat.add_nuclide("Fe56", 1.0)
mat.set_density("g/cm3", 7.0)
# Use minimal tetrahedral DAGMC file
dagmc_file = Path(__file__).parent / "dagmc_tetrahedral_no_graveyard.h5m"
dagmc_univ = openmc.DAGMCUniverse(dagmc_file, auto_geom_ids=True)
bound_dagmc_univ = dagmc_univ.bounded_universe(padding_distance=1)
# Create model WITHOUT setting particles or batches
model = openmc.Model()
model.materials = openmc.Materials([mat])
model.geometry = openmc.Geometry(bound_dagmc_univ)
model.settings = openmc.Settings() # Note: no particles or batches set!
model.settings.run_mode = 'fixed source'
# Create a point source
my_source = openmc.IndependentSource()
my_source.space = openmc.stats.Point((0.25, 0.25, 0.25))
my_source.energy = openmc.stats.delta_function(14e6)
model.settings.source = my_source
# This should work without requiring particles/batches to be set
# convert_to_multigroup handles initialization internally using non-transport mode
model.convert_to_multigroup(
method='material_wise',
groups='CASMO-2',
particles=10,
overwrite_mgxs_library=True
)
# Verify the model was converted successfully
assert model.settings.energy_mode == 'multi-group'