mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
addressed smharper's comments
This commit is contained in:
parent
1f60a7fea6
commit
87aed7a0b0
6 changed files with 41 additions and 38 deletions
|
|
@ -30,8 +30,7 @@ sp = openmc.StatePoint(statepoint)
|
|||
geometry = sp.summary.geometry
|
||||
|
||||
# Close statepoint and summary files to be able to write over them
|
||||
sp.summary._f.close()
|
||||
sp._f.close()
|
||||
sp.exit()
|
||||
|
||||
# Load previous depletion results
|
||||
previous_results = openmc.deplete.ResultsList("depletion_results.h5")
|
||||
|
|
|
|||
|
|
@ -44,29 +44,29 @@ def predictor(operator, timesteps, power, print_out=True):
|
|||
chain = operator.chain
|
||||
|
||||
# Initialize time
|
||||
if operator.prev_res == None:
|
||||
if operator.prev_res is None:
|
||||
t = 0.0
|
||||
else:
|
||||
t = operator.prev_res[-1].time[-1]
|
||||
|
||||
# Initialize starting index for saving results
|
||||
if operator.prev_res == None:
|
||||
if operator.prev_res is None:
|
||||
i_res = 0
|
||||
else:
|
||||
i_res = len(operator.prev_res)
|
||||
|
||||
#TODO : Get last time step power from previous results, and run a
|
||||
# new calculation if different from power at the first time step
|
||||
# If no TH coupling, just re-scale rates by ratio of power
|
||||
i_res = len(operator.prev_res) - 1
|
||||
|
||||
for i, (dt, p) in enumerate(zip(timesteps, power)):
|
||||
# Get beginning-of-timestep concentrations
|
||||
x = [copy.deepcopy(vec)]
|
||||
|
||||
# Get beginning-of-timestep reaction rates
|
||||
# Avoid doing first run if already done in previous calculation
|
||||
if i > 0 or operator.prev_res == None:
|
||||
# Avoid doing first transport run if already done in previous
|
||||
# calculation
|
||||
if i > 0 or operator.prev_res is None:
|
||||
op_results = [operator(x[0], p)]
|
||||
|
||||
# Create results, write to disk
|
||||
Results.save(operator, x, op_results, [t, t + dt], p, i + i_res)
|
||||
else:
|
||||
power_res = operator.prev_res[-1].power
|
||||
ratio_power = p / power_res
|
||||
|
|
@ -74,9 +74,6 @@ def predictor(operator, timesteps, power, print_out=True):
|
|||
op_results = [operator.prev_res[-1]]
|
||||
op_results[0].rates = ratio_power * op_results[0].rates[0]
|
||||
|
||||
# Create results, write to disk
|
||||
Results.save(operator, x, op_results, [t, t + dt], p, i + i_res)
|
||||
|
||||
# Deplete for full timestep
|
||||
x_end = deplete(chain, x[0], op_results[0], dt, print_out)
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,9 @@ class Operator(TransportOperator):
|
|||
Path to the depletion chain XML file. Defaults to the
|
||||
:envvar:`OPENMC_DEPLETE_CHAIN` environment variable if it exists.
|
||||
prev_results : ResultsList, optional
|
||||
Results from the previous depletion calculation. Defaults to None
|
||||
Results from a previous depletion calculation. If this argument is
|
||||
specified, the depletion calculation will start from the latest state
|
||||
in the previous results.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -97,7 +99,7 @@ class Operator(TransportOperator):
|
|||
local_mats : list of str
|
||||
All burnable material IDs being managed by a single process
|
||||
prev_res : ResultsList
|
||||
Results from the previous depletion run
|
||||
Results from a previous depletion calculation
|
||||
|
||||
"""
|
||||
def __init__(self, geometry, settings, chain_file=None, prev_results=None):
|
||||
|
|
@ -108,7 +110,7 @@ class Operator(TransportOperator):
|
|||
|
||||
if prev_results != None:
|
||||
# Reload volumes into geometry
|
||||
prev_results.transfer_volumes(geometry)
|
||||
prev_results[-1].transfer_volumes(geometry)
|
||||
|
||||
# Store previous results in operator
|
||||
self.prev_res = prev_results
|
||||
|
|
@ -126,8 +128,7 @@ class Operator(TransportOperator):
|
|||
if nuc in self.chain]
|
||||
|
||||
# Extract number densities from the geometry / previous depletion run
|
||||
self._extract_number(self.local_mats, volume, nuclides, \
|
||||
self.prev_res)
|
||||
self._extract_number(self.local_mats, volume, nuclides, self.prev_res)
|
||||
|
||||
# Create reaction rates array
|
||||
self.reaction_rates = ReactionRates(
|
||||
|
|
@ -237,6 +238,8 @@ class Operator(TransportOperator):
|
|||
Volumes for the above materials in [cm^3]
|
||||
nuclides : list of str
|
||||
Nuclides to be used in the simulation.
|
||||
prev_res : ResultsList, optional
|
||||
Results from a previous depletion calculation
|
||||
|
||||
"""
|
||||
self.number = AtomNumber(local_mats, nuclides, volume, len(self.chain))
|
||||
|
|
@ -247,7 +250,7 @@ class Operator(TransportOperator):
|
|||
|
||||
# Now extract and store the number densities
|
||||
# From the geometry if no previous depletion results
|
||||
if prev_res == None:
|
||||
if prev_res is None:
|
||||
for mat in self.geometry.get_all_materials().values():
|
||||
if str(mat.id) in local_mats:
|
||||
self._set_number_from_mat(mat)
|
||||
|
|
@ -277,13 +280,15 @@ class Operator(TransportOperator):
|
|||
"""Extracts material nuclides and number densities.
|
||||
|
||||
If the nuclide concentration's evolution is tracked, the densities come
|
||||
from depletion results.
|
||||
Else, densities are extracted from the geometry in the summary.
|
||||
from depletion results. Else, densities are extracted from the geometry
|
||||
in the summary.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mat : openmc.Material
|
||||
The material to read from
|
||||
prev_res : ResultsList
|
||||
Results from a previous depletion calculation
|
||||
|
||||
"""
|
||||
mat_id = str(mat.id)
|
||||
|
|
@ -294,7 +299,7 @@ class Operator(TransportOperator):
|
|||
geom_nuc = [x[0] for x in list(geom_nuc_densities.values())]
|
||||
|
||||
# Merge lists of nuclides
|
||||
nuc_set = list(depl_nuc) + [n for n in geom_nuc if n not in depl_nuc]
|
||||
nuc_set = set(depl_nuc) | set(geom_nuc)
|
||||
|
||||
for nuclide in nuc_set:
|
||||
if nuclide in depl_nuc:
|
||||
|
|
|
|||
|
|
@ -412,3 +412,17 @@ class Results(object):
|
|||
results.power = power
|
||||
|
||||
results.export_to_hdf5("depletion_results.h5", step_ind)
|
||||
|
||||
def transfer_volumes(self, geometry):
|
||||
"""Transfers volumes from depletion results to geometry
|
||||
|
||||
Parameters
|
||||
----------
|
||||
geometry : OpenMC geometry 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)]
|
||||
|
|
|
|||
|
|
@ -103,18 +103,3 @@ class ResultsList(list):
|
|||
eigenvalue[i] = result.k[0]
|
||||
|
||||
return time, eigenvalue
|
||||
|
||||
def transfer_volumes(self, geometry):
|
||||
"""Transfers volumes from depletion results to geometry
|
||||
|
||||
Parameters
|
||||
----------
|
||||
geometry : OpenMC geometry to be used in a depletion restart
|
||||
calculation
|
||||
|
||||
"""
|
||||
cells = geometry.get_all_material_cells()
|
||||
for c in cells:
|
||||
material = next(iter(cells[c].get_all_materials().values()))
|
||||
if material.depletable == True:
|
||||
material.volume = self[-1].volume[str(material.id)]
|
||||
|
|
|
|||
|
|
@ -153,6 +153,9 @@ class StatePoint(object):
|
|||
if self._summary is not None:
|
||||
self._summary._f.close()
|
||||
|
||||
def exit(self):
|
||||
self.__exit__()
|
||||
|
||||
@property
|
||||
def cmfd_on(self):
|
||||
return self._f.attrs['cmfd_on'] > 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue