mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Updating depletion test files. Further adjustments to how materials are identified for some utility functions.
This commit is contained in:
parent
7472e330be
commit
f1234a38b0
5 changed files with 30 additions and 17 deletions
|
|
@ -202,13 +202,15 @@ class Operator(TransportOperator):
|
|||
fission_q = None
|
||||
super().__init__(chain_file, fission_q, dilute_initial, prev_results)
|
||||
self.round_number = False
|
||||
self.model = model
|
||||
self.settings = model.settings
|
||||
self.geometry = model.geometry
|
||||
|
||||
# determine set of materials in the model
|
||||
if not model.materials:
|
||||
model.materials = openmc.Materials(model.geometry.
|
||||
get_all_materials().values())
|
||||
model.materials = openmc.Materials(
|
||||
model.geometry.get_all_materials().values()
|
||||
)
|
||||
self.materials = model.materials
|
||||
|
||||
self.diff_burnable_mats = diff_burnable_mats
|
||||
|
|
@ -239,7 +241,7 @@ class Operator(TransportOperator):
|
|||
|
||||
if self.prev_res is not None:
|
||||
# Reload volumes into geometry
|
||||
prev_results[-1].transfer_volumes(geometry)
|
||||
prev_results[-1].transfer_volumes(self.model)
|
||||
|
||||
# Store previous results in operator
|
||||
# Distribute reaction rates according to those tracked
|
||||
|
|
@ -380,7 +382,7 @@ class Operator(TransportOperator):
|
|||
|
||||
# Extract all burnable materials which have multiple instances
|
||||
distribmats = set(
|
||||
[mat for mat in self.geometry.get_all_materials().values()
|
||||
[mat for mat in self.materials
|
||||
if mat.depletable and mat.num_instances > 1])
|
||||
|
||||
for mat in distribmats:
|
||||
|
|
@ -476,7 +478,7 @@ class Operator(TransportOperator):
|
|||
|
||||
# Else from previous depletion results
|
||||
else:
|
||||
for mat in self.materials.values():
|
||||
for mat in self.materials:
|
||||
if str(mat.id) in local_mats:
|
||||
self._set_number_from_results(mat, prev_res)
|
||||
|
||||
|
|
@ -620,7 +622,7 @@ class Operator(TransportOperator):
|
|||
|
||||
# Sort nuclides according to order in AtomNumber object
|
||||
nuclides = list(self.number.nuclides)
|
||||
for mat in materials:
|
||||
for mat in self.materials:
|
||||
mat._nuclides.sort(key=lambda x: nuclides.index(x[0]))
|
||||
|
||||
# Grab the cross sections tag from the existing file
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import copy
|
|||
import h5py
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
from openmc.mpi import comm, MPI
|
||||
from .reaction_rates import ReactionRates
|
||||
|
||||
|
|
@ -496,16 +497,23 @@ class Results:
|
|||
|
||||
results.export_to_hdf5("depletion_results.h5", step_ind)
|
||||
|
||||
def transfer_volumes(self, geometry):
|
||||
def transfer_volumes(self, model):
|
||||
"""Transfers volumes from depletion results to geometry
|
||||
|
||||
Parameters
|
||||
----------
|
||||
geometry : OpenMC geometry to be used in a depletion restart
|
||||
model : OpenMC model to be used in a depletion restart
|
||||
calculation
|
||||
|
||||
"""
|
||||
for cell in geometry.get_all_material_cells().values():
|
||||
for material in cell.get_all_materials().values():
|
||||
if material.depletable:
|
||||
material.volume = self.volume[str(material.id)]
|
||||
|
||||
if not model.materials:
|
||||
materials = openmc.Materials(
|
||||
model.geometry.get_all_materials().values()
|
||||
)
|
||||
else:
|
||||
materials = model.materials
|
||||
|
||||
for material in materials:
|
||||
if material.depletable:
|
||||
material.volume = self.volume[str(material.id)]
|
||||
|
|
@ -49,9 +49,11 @@ def test_full(run_in_tmpdir, problem, multiproc):
|
|||
settings.seed = 1
|
||||
settings.verbosity = 1
|
||||
|
||||
model = openmc.Model(geometry=geometry, settings=settings)
|
||||
|
||||
# Create operator
|
||||
chain_file = Path(__file__).parents[2] / 'chain_simple.xml'
|
||||
op = openmc.deplete.Operator(geometry, settings, chain_file)
|
||||
op = openmc.deplete.Operator(model, chain_file)
|
||||
op.round_number = True
|
||||
|
||||
# Power and timesteps
|
||||
|
|
@ -170,7 +172,7 @@ def test_depletion_results_to_material(run_in_tmpdir, problem):
|
|||
diff_vs_expected = unified_diff(reference_lines, result_file_lines)
|
||||
|
||||
# Check all lines match, printing errors along the way
|
||||
success = True
|
||||
success = True
|
||||
for line in diff_vs_expected:
|
||||
success = False
|
||||
print(line.rstrip())
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts
|
|||
|
||||
# Create transport operator
|
||||
op = openmc.deplete.Operator(
|
||||
model.geometry, model.settings, 'test_chain.xml',
|
||||
model, 'test_chain.xml',
|
||||
normalization_mode="source-rate",
|
||||
reaction_rate_mode=reaction_rate_mode,
|
||||
reaction_rate_opts=reaction_rate_opts,
|
||||
|
|
@ -142,9 +142,10 @@ def test_decay(run_in_tmpdir):
|
|||
chain.add_nuclide(sr89)
|
||||
chain.export_to_xml('test_chain.xml')
|
||||
|
||||
model = openmc.Model(geometry=geometry, settings=settings)
|
||||
# Create transport operator
|
||||
op = openmc.deplete.Operator(
|
||||
geometry, settings, 'test_chain.xml', normalization_mode="source-rate"
|
||||
model, 'test_chain.xml', normalization_mode="source-rate"
|
||||
)
|
||||
|
||||
# Deplete with two decay steps
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ def test_transfer_volumes(run_in_tmpdir):
|
|||
geometry = openmc.Geometry(root)
|
||||
|
||||
# Transfer volumes
|
||||
res[0].transfer_volumes(geometry)
|
||||
res[0].transfer_volumes(openmc.Model(geometry))
|
||||
|
||||
assert mat1.volume == 1.5
|
||||
assert mat2.volume is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue