Have unpack_tallies_and_normalize return an OperatorResult

This commit is contained in:
Paul Romano 2018-02-15 14:53:11 -06:00
parent 8a41bac17a
commit 3bbd177453
3 changed files with 16 additions and 25 deletions

View file

@ -58,7 +58,7 @@ OperatorResult = namedtuple('OperatorResult', ['k', 'rates'])
class Operator(metaclass=ABCMeta):
"""Abstract class defining all methods needed for the integrator.
"""Abstract class defining a transport operator
Attributes
----------
@ -82,12 +82,9 @@ class Operator(metaclass=ABCMeta):
Returns
-------
k : float
Eigenvalue of the problem.
rates : ReactionRates
Reaction rates from this simulation.
seed : int
Seed for this simulation.
openmc.deplete.OperatorResult
Eigenvalue and reaction rates resulting from transport operator
"""
pass

View file

@ -98,9 +98,7 @@ class OpenMCSettings(Settings):
class OpenMCOperator(Operator):
"""The OpenMC Operator class.
Provides Operator functions for OpenMC.
"""OpenMC transport operator
Parameters
----------
@ -210,7 +208,7 @@ class OpenMCOperator(Operator):
time_openmc = time.time()
# Extract results
k = self.unpack_tallies_and_normalize()
op_result = self.unpack_tallies_and_normalize()
if comm.rank == 0:
time_unpack = time.time()
@ -219,7 +217,7 @@ class OpenMCOperator(Operator):
print("Time to openmc: ", time_openmc - time_start)
print("Time to unpack: ", time_unpack - time_openmc)
return OperatorResult(k, copy.deepcopy(self.reaction_rates))
return copy.deepcopy(op_result)
def extract_mat_ids(self):
"""Extracts materials and assigns them to processes.
@ -561,23 +559,19 @@ class OpenMCOperator(Operator):
self.number.set_mat_slice(i, total_density[i])
def unpack_tallies_and_normalize(self):
"""Unpack tallies from OpenMC
"""Unpack tallies from OpenMC and return an operator result
This function reads the tallies generated by OpenMC (from the tally.xml
file generated in generate_tally_xml) normalizes them so that the total
power generated is new_power, and then stores them in the reaction rate
database.
This method uses OpenMC's C API bindings to determine the k-effective
value and reaction rates from the simulation. The reaction rates are
normalized by the user-specified power, summing the product of the
fission reaction rate times the fission Q value for each material.
Returns
-------
k : float
Eigenvalue of the last simulation.
openmc.deplete.OperatorResult
Eigenvalue and reaction rates resulting from transport operator
Todo
----
Provide units for power
"""
rates = self.reaction_rates
rates[:, :, :] = 0.0
@ -655,7 +649,7 @@ class OpenMCOperator(Operator):
# Scale reaction rates to obtain units of reactions/sec
rates[:, :, :] *= power / energy
return k_combined
return OperatorResult(k_combined, rates)
def load_participating(self):
"""Loads a cross_sections.xml file to find participating nuclides.

View file

@ -23,7 +23,7 @@ class ReactionRates(object):
Attributes
----------
mat_to_ind : OrderedDict of str to int
A dictionary mapping cell ID as string to index.
A dictionary mapping material ID as string to index.
nuc_to_ind : OrderedDict of str to int
A dictionary mapping nuclide name as string to index.
react_to_ind : OrderedDict of str to int