mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Removing a few attributes on OpenMCOperator
This commit is contained in:
parent
bc4d631883
commit
8a41bac17a
6 changed files with 9 additions and 50 deletions
|
|
@ -54,7 +54,7 @@ class Settings(object):
|
|||
self._output_dir = Path(output_dir)
|
||||
|
||||
|
||||
OperatorResult = namedtuple('OperatorResult', ['k', 'rates', 'seed'])
|
||||
OperatorResult = namedtuple('OperatorResult', ['k', 'rates'])
|
||||
|
||||
|
||||
class Operator(metaclass=ABCMeta):
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ def save_results(op, x, op_results, t, step_ind):
|
|||
results[i, mat_i, :] = x[i][mat_i][:]
|
||||
|
||||
results.k = [r.k for r in op_results]
|
||||
results.seeds = [r.seed for r in op_results]
|
||||
results.rates = [r.rates for r in op_results]
|
||||
results.time = t
|
||||
|
||||
|
|
|
|||
|
|
@ -115,8 +115,6 @@ class OpenMCOperator(Operator):
|
|||
Settings object. (From Operator)
|
||||
geometry : openmc.Geometry
|
||||
The OpenMC geometry object.
|
||||
seed : int
|
||||
The RNG seed used in last OpenMC run.
|
||||
number : openmc.deplete.AtomNumber
|
||||
Total number of atoms in simulation.
|
||||
participating_nuclides : set of str
|
||||
|
|
@ -125,10 +123,6 @@ class OpenMCOperator(Operator):
|
|||
The depletion chain information necessary to form matrices and tallies.
|
||||
reaction_rates : openmc.deplete.ReactionRates
|
||||
Reaction rates from the last operator step.
|
||||
power : OrderedDict of str to float
|
||||
Material-by-Material power. Indexed by material ID.
|
||||
mat_name : OrderedDict of str to int
|
||||
The name of region each material is set to. Indexed by material ID.
|
||||
burn_mat_to_id : OrderedDict of str to int
|
||||
Dictionary mapping material ID (as a string) to an index in reaction_rates.
|
||||
burn_nuc_to_id : OrderedDict of str to int
|
||||
|
|
@ -144,12 +138,9 @@ class OpenMCOperator(Operator):
|
|||
super().__init__(settings)
|
||||
|
||||
self.geometry = geometry
|
||||
self.seed = 0
|
||||
self.number = None
|
||||
self.participating_nuclides = None
|
||||
self.reaction_rates = None
|
||||
self.power = None
|
||||
self.mat_name = OrderedDict()
|
||||
self.burn_mat_to_ind = OrderedDict()
|
||||
self.burn_nuc_to_ind = None
|
||||
|
||||
|
|
@ -196,16 +187,10 @@ class OpenMCOperator(Operator):
|
|||
|
||||
Returns
|
||||
-------
|
||||
mat : list of scipy.sparse.csr_matrix
|
||||
Matrices for the next step.
|
||||
k : float
|
||||
Eigenvalue of the problem.
|
||||
rates : openmc.deplete.ReactionRates
|
||||
Reaction rates from this simulation.
|
||||
seed : int
|
||||
Seed for this simulation.
|
||||
"""
|
||||
openmc.deplete.OperatorResult
|
||||
Eigenvalue and reaction rates resulting from transport operator
|
||||
|
||||
"""
|
||||
# Prevent OpenMC from complaining about re-creating tallies
|
||||
openmc.reset_auto_ids()
|
||||
|
||||
|
|
@ -234,7 +219,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), self.seed)
|
||||
return OperatorResult(k, copy.deepcopy(self.reaction_rates))
|
||||
|
||||
def extract_mat_ids(self):
|
||||
"""Extracts materials and assigns them to processes.
|
||||
|
|
@ -262,8 +247,6 @@ class OpenMCOperator(Operator):
|
|||
# Iterate once through the geometry to get dictionaries
|
||||
cells = self.geometry.get_all_material_cells()
|
||||
for cell in cells.values():
|
||||
name = cell.name
|
||||
|
||||
if isinstance(cell.fill, openmc.Material):
|
||||
mat = cell.fill
|
||||
for nuclide in mat.get_nuclide_densities():
|
||||
|
|
@ -273,7 +256,6 @@ class OpenMCOperator(Operator):
|
|||
volume[str(mat.id)] = mat.volume
|
||||
else:
|
||||
mat_not_burn.add(str(mat.id))
|
||||
self.mat_name[mat.id] = name
|
||||
else:
|
||||
for mat in cell.fill:
|
||||
for nuclide in mat.get_nuclide_densities():
|
||||
|
|
@ -283,7 +265,6 @@ class OpenMCOperator(Operator):
|
|||
volume[str(mat.id)] = mat.volume
|
||||
else:
|
||||
mat_not_burn.add(str(mat.id))
|
||||
self.mat_name[mat.id] = name
|
||||
|
||||
need_vol = []
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ class Results(object):
|
|||
----------
|
||||
k : list of float
|
||||
Eigenvalue for each substep.
|
||||
seeds : list of int
|
||||
Seeds for each substep.
|
||||
time : list of float
|
||||
Time at beginning, end of step, in seconds.
|
||||
n_mat : int
|
||||
|
|
@ -46,11 +44,10 @@ class Results(object):
|
|||
Number of stages in simulation.
|
||||
data : numpy.array
|
||||
Atom quantity, stored by stage, mat, then by nuclide.
|
||||
"""
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
self.k = None
|
||||
self.seeds = None
|
||||
self.time = None
|
||||
self.rates = None
|
||||
self.volume = None
|
||||
|
|
@ -227,8 +224,6 @@ class Results(object):
|
|||
handle.create_dataset("eigenvalues", (1, n_stages),
|
||||
maxshape=(None, n_stages), dtype='float64')
|
||||
|
||||
handle.create_dataset("seeds", (1, n_stages), maxshape=(None, n_stages), dtype='int64')
|
||||
|
||||
handle.create_dataset("time", (1, 2), maxshape=(None, 2), dtype='float64')
|
||||
|
||||
def to_hdf5(self, handle, index):
|
||||
|
|
@ -252,7 +247,6 @@ class Results(object):
|
|||
number_dset = handle["/number"]
|
||||
rxn_dset = handle["/reaction rates"]
|
||||
eigenvalues_dset = handle["/eigenvalues"]
|
||||
seeds_dset = handle["/seeds"]
|
||||
time_dset = handle["/time"]
|
||||
|
||||
# Get number of results stored
|
||||
|
|
@ -274,10 +268,6 @@ class Results(object):
|
|||
eigenvalues_shape[0] = new_shape
|
||||
eigenvalues_dset.resize(eigenvalues_shape)
|
||||
|
||||
seeds_shape = list(seeds_dset.shape)
|
||||
seeds_shape[0] = new_shape
|
||||
seeds_dset.resize(seeds_shape)
|
||||
|
||||
time_shape = list(time_dset.shape)
|
||||
time_shape[0] = new_shape
|
||||
time_dset.resize(time_shape)
|
||||
|
|
@ -297,7 +287,6 @@ class Results(object):
|
|||
rxn_dset[index, i, low:high+1, :, :] = self.rates[i][:, :, :]
|
||||
if comm.rank == 0:
|
||||
eigenvalues_dset[index, i] = self.k[i]
|
||||
seeds_dset[index, i] = self.seeds[i]
|
||||
if comm.rank == 0:
|
||||
time_dset[index, :] = self.time
|
||||
|
||||
|
|
@ -317,12 +306,10 @@ class Results(object):
|
|||
# Grab handles
|
||||
number_dset = handle["/number"]
|
||||
eigenvalues_dset = handle["/eigenvalues"]
|
||||
seeds_dset = handle["/seeds"]
|
||||
time_dset = handle["/time"]
|
||||
|
||||
results.data = number_dset[index, :, :, :]
|
||||
results.k = eigenvalues_dset[index, :]
|
||||
results.seeds = seeds_dset[index, :]
|
||||
results.time = time_dset[index, :]
|
||||
|
||||
# Reconstruct dictionaries
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class DummyGeometry(Operator):
|
|||
reaction_rates[0, 1, 0] = vec[0][1]
|
||||
|
||||
# Create a fake rates object
|
||||
return OperatorResult(0.0, reaction_rates, 0)
|
||||
return OperatorResult(0.0, reaction_rates)
|
||||
|
||||
@property
|
||||
def chain(self):
|
||||
|
|
|
|||
|
|
@ -66,21 +66,15 @@ def test_save_results(run_in_tmpdir):
|
|||
# Create global terms
|
||||
eigvl1 = np.random.rand(stages)
|
||||
eigvl2 = np.random.rand(stages)
|
||||
seed1 = [np.random.randint(100) for i in range(stages)]
|
||||
seed2 = [np.random.randint(100) for i in range(stages)]
|
||||
|
||||
eigvl1 = comm.bcast(eigvl1, root=0)
|
||||
eigvl2 = comm.bcast(eigvl2, root=0)
|
||||
seed1 = comm.bcast(seed1, root=0)
|
||||
seed2 = comm.bcast(seed2, root=0)
|
||||
|
||||
t1 = [0.0, 1.0]
|
||||
t2 = [1.0, 2.0]
|
||||
|
||||
op_result1 = [OperatorResult(k, rates, seed)
|
||||
for k, rates, seed in zip(eigvl1, rate1, seed1)]
|
||||
op_result2 = [OperatorResult(k, rates, seed)
|
||||
for k, rates, seed in zip(eigvl2, rate2, seed2)]
|
||||
op_result1 = [OperatorResult(k, rates) for k, rates in zip(eigvl1, rate1)]
|
||||
op_result2 = [OperatorResult(k, rates) for k, rates in zip(eigvl2, rate2)]
|
||||
integrator.save_results(op, x1, op_result1, t1, 0)
|
||||
integrator.save_results(op, x2, op_result2, t2, 1)
|
||||
|
||||
|
|
@ -98,9 +92,7 @@ def test_save_results(run_in_tmpdir):
|
|||
rate2[i][mat, nuc, :])
|
||||
|
||||
np.testing.assert_array_equal(res[0].k, eigvl1)
|
||||
np.testing.assert_array_equal(res[0].seeds, seed1)
|
||||
np.testing.assert_array_equal(res[0].time, t1)
|
||||
|
||||
np.testing.assert_array_equal(res[1].k, eigvl2)
|
||||
np.testing.assert_array_equal(res[1].seeds, seed2)
|
||||
np.testing.assert_array_equal(res[1].time, t2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue