mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Allow mesh domain in get_microxs_and_flux (#2700)
This commit is contained in:
parent
d4c40aa355
commit
7fdda4aa06
4 changed files with 41 additions and 6 deletions
|
|
@ -39,7 +39,7 @@ def get_microxs_and_flux(
|
|||
----------
|
||||
model : openmc.Model
|
||||
OpenMC model object. Must contain geometry, materials, and settings.
|
||||
domains : list of openmc.Material or openmc.Cell or openmc.Universe
|
||||
domains : list of openmc.Material or openmc.Cell or openmc.Universe, or openmc.MeshBase
|
||||
Domains in which to tally reaction rates.
|
||||
nuclides : list of str
|
||||
Nuclides to get cross sections for. If not specified, all burnable
|
||||
|
|
@ -92,7 +92,9 @@ def get_microxs_and_flux(
|
|||
energy_filter = openmc.EnergyFilter.from_group_structure(energies)
|
||||
else:
|
||||
energy_filter = openmc.EnergyFilter(energies)
|
||||
if isinstance(domains[0], openmc.Material):
|
||||
if isinstance(domains, openmc.MeshBase):
|
||||
domain_filter = openmc.MeshFilter(domains)
|
||||
elif isinstance(domains[0], openmc.Material):
|
||||
domain_filter = openmc.MaterialFilter(domains)
|
||||
elif isinstance(domains[0], openmc.Cell):
|
||||
domain_filter = openmc.CellFilter(domains)
|
||||
|
|
|
|||
|
|
@ -46,14 +46,22 @@ def model():
|
|||
return openmc.Model(geometry, materials, settings)
|
||||
|
||||
|
||||
def test_from_model(model):
|
||||
domains = model.materials[:1]
|
||||
@pytest.mark.parametrize("domain_type", ["materials", "mesh"])
|
||||
def test_from_model(model, domain_type):
|
||||
if domain_type == 'materials':
|
||||
domains = model.materials[:1]
|
||||
elif domain_type == 'mesh':
|
||||
mesh = openmc.RegularMesh()
|
||||
mesh.lower_left = (-0.62, -0.62)
|
||||
mesh.upper_right = (0.62, 0.62)
|
||||
mesh.dimension = (3, 3)
|
||||
domains = mesh
|
||||
nuclides = ['U234', 'U235', 'U238', 'U236', 'O16', 'O17', 'I135', 'Xe135',
|
||||
'Xe136', 'Cs135', 'Gd157', 'Gd156']
|
||||
_, test_xs = get_microxs_and_flux(model, domains, nuclides, chain_file=CHAIN_FILE)
|
||||
if config['update']:
|
||||
test_xs[0].to_csv('test_reference.csv')
|
||||
test_xs[0].to_csv(f'test_reference_{domain_type}.csv')
|
||||
|
||||
ref_xs = MicroXS.from_csv('test_reference.csv')
|
||||
ref_xs = MicroXS.from_csv(f'test_reference_{domain_type}.csv')
|
||||
|
||||
np.testing.assert_allclose(test_xs[0].data, ref_xs.data, rtol=1e-11)
|
||||
|
|
|
|||
25
tests/regression_tests/microxs/test_reference_mesh.csv
Normal file
25
tests/regression_tests/microxs/test_reference_mesh.csv
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
nuclides,reactions,groups,xs
|
||||
U234,"(n,gamma)",1,27.027171724208227
|
||||
U234,fission,1,0.04333740860093498
|
||||
U235,"(n,gamma)",1,12.683875995776193
|
||||
U235,fission,1,4.2596665957162605
|
||||
U238,"(n,gamma)",1,4.479719141496804
|
||||
U238,fission,1,0.009460665924409056
|
||||
U236,"(n,gamma)",1,8.469286849810802
|
||||
U236,fission,1,0.027373590840715795
|
||||
O16,"(n,gamma)",1,7.478160204479271e-05
|
||||
O16,fission,1,0.0
|
||||
O17,"(n,gamma)",1,0.0004743959164164789
|
||||
O17,fission,1,0.0
|
||||
I135,"(n,gamma)",1,8.33959524761822
|
||||
I135,fission,1,0.0
|
||||
Xe135,"(n,gamma)",1,282068.447252079
|
||||
Xe135,fission,1,0.0
|
||||
Xe136,"(n,gamma)",1,0.02888928065916194
|
||||
Xe136,fission,1,0.0
|
||||
Cs135,"(n,gamma)",1,2.5863526577468408
|
||||
Cs135,fission,1,0.0
|
||||
Gd157,"(n,gamma)",1,16518.24083307153
|
||||
Gd157,fission,1,0.0
|
||||
Gd156,"(n,gamma)",1,2.838514589417232
|
||||
Gd156,fission,1,0.0
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue