From 0fdef55d425656548217f22d3eddf3127e16781c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 5 Aug 2019 16:08:11 -0500 Subject: [PATCH 1/4] Create ResultsList from file using from_hdf5 The new class method ResultsList.from_hdf5 should be used to load in results data, rather than passing the file name into the __init__ method. __init__ passes directly to list.__init__ now. The motivation for this is to resolve the depletion restart with MPI bug #1275. To do this, each Operator will create it's own ResultsList and distribute reaction rates and densities according to what materials are burned on this process. Rather than use a normal list, this Operator expects the various accessor methods like get_atoms to be present on self.prev_res --- openmc/deplete/results_list.py | 28 ++++++++++---- tests/regression_tests/deplete/test.py | 4 +- tests/unit_tests/test_deplete_cecm.py | 2 +- tests/unit_tests/test_deplete_celi.py | 2 +- tests/unit_tests/test_deplete_cf4.py | 2 +- tests/unit_tests/test_deplete_epc_rk4.py | 2 +- tests/unit_tests/test_deplete_integrator.py | 2 +- tests/unit_tests/test_deplete_leqi.py | 2 +- tests/unit_tests/test_deplete_predictor.py | 2 +- tests/unit_tests/test_deplete_restart.py | 40 ++++++++++---------- tests/unit_tests/test_deplete_resultslist.py | 2 +- tests/unit_tests/test_deplete_si_celi.py | 2 +- tests/unit_tests/test_deplete_si_leqi.py | 2 +- tests/unit_tests/test_transfer_volumes.py | 4 +- 14 files changed, 54 insertions(+), 42 deletions(-) diff --git a/openmc/deplete/results_list.py b/openmc/deplete/results_list.py index 0ce5b01584..8a0efcdbf1 100644 --- a/openmc/deplete/results_list.py +++ b/openmc/deplete/results_list.py @@ -8,22 +8,34 @@ from openmc.checkvalue import check_filetype_version class ResultsList(list): """A list of openmc.deplete.Results objects - Parameters - ---------- - filename : str - The filename to read from. - + It is recommended to use :meth:`from_hdf5` over + direct creation. """ - def __init__(self, filename): - super().__init__() + + @classmethod + def from_hdf5(cls, filename): + """Load in depletion results from a previous file + + Parameters + ---------- + filename : str + Path to depletion result file + + Returns + ------- + new : ResultsList + New instance of depletion results + """ with h5py.File(str(filename), "r") as fh: check_filetype_version(fh, 'depletion results', _VERSION_RESULTS[0]) + new = cls() # Get number of results stored n = fh["number"][...].shape[0] for i in range(n): - self.append(Results.from_hdf5(fh, i)) + new.append(Results.from_hdf5(fh, i)) + return new def get_atoms(self, mat, nuc): """Get number of nuclides over time from a single material diff --git a/tests/regression_tests/deplete/test.py b/tests/regression_tests/deplete/test.py index 059a44ea35..d81bf607b9 100644 --- a/tests/regression_tests/deplete/test.py +++ b/tests/regression_tests/deplete/test.py @@ -66,8 +66,8 @@ def test_full(run_in_tmpdir): return # Load the reference/test results - res_test = openmc.deplete.ResultsList(path_test) - res_ref = openmc.deplete.ResultsList(path_reference) + res_test = openmc.deplete.ResultsList.from_hdf5(path_test) + res_ref = openmc.deplete.ResultsList.from_hdf5(path_reference) # Assert same mats for mat in res_ref[0].mat_to_ind: diff --git a/tests/unit_tests/test_deplete_cecm.py b/tests/unit_tests/test_deplete_cecm.py index dd8b769fe6..f979e0b4d9 100644 --- a/tests/unit_tests/test_deplete_cecm.py +++ b/tests/unit_tests/test_deplete_cecm.py @@ -21,7 +21,7 @@ def test_cecm(run_in_tmpdir): openmc.deplete.cecm(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_celi.py b/tests/unit_tests/test_deplete_celi.py index 47d3319fdb..ffa5c304c3 100644 --- a/tests/unit_tests/test_deplete_celi.py +++ b/tests/unit_tests/test_deplete_celi.py @@ -21,7 +21,7 @@ def test_celi(run_in_tmpdir): openmc.deplete.celi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_cf4.py b/tests/unit_tests/test_deplete_cf4.py index 0c6199c3e5..aee373b406 100644 --- a/tests/unit_tests/test_deplete_cf4.py +++ b/tests/unit_tests/test_deplete_cf4.py @@ -21,7 +21,7 @@ def test_cf4(run_in_tmpdir): openmc.deplete.cf4(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_epc_rk4.py b/tests/unit_tests/test_deplete_epc_rk4.py index ea687bfd5d..1b0af0365a 100644 --- a/tests/unit_tests/test_deplete_epc_rk4.py +++ b/tests/unit_tests/test_deplete_epc_rk4.py @@ -21,7 +21,7 @@ def test_epc_rk4(run_in_tmpdir): openmc.deplete.epc_rk4(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_integrator.py b/tests/unit_tests/test_deplete_integrator.py index 40090264ae..b8429392ff 100644 --- a/tests/unit_tests/test_deplete_integrator.py +++ b/tests/unit_tests/test_deplete_integrator.py @@ -80,7 +80,7 @@ def test_results_save(run_in_tmpdir): Results.save(op, x2, op_result2, t2, 0, 1) # Load the files - res = ResultsList("depletion_results.h5") + res = ResultsList.from_hdf5("depletion_results.h5") for i in range(stages): for mat_i, mat in enumerate(burn_list): diff --git a/tests/unit_tests/test_deplete_leqi.py b/tests/unit_tests/test_deplete_leqi.py index a26329cf4a..ac477a36ec 100644 --- a/tests/unit_tests/test_deplete_leqi.py +++ b/tests/unit_tests/test_deplete_leqi.py @@ -21,7 +21,7 @@ def test_leqi(run_in_tmpdir): openmc.deplete.leqi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_predictor.py b/tests/unit_tests/test_deplete_predictor.py index 6af6f8bca4..092ebbc35e 100644 --- a/tests/unit_tests/test_deplete_predictor.py +++ b/tests/unit_tests/test_deplete_predictor.py @@ -21,7 +21,7 @@ def test_predictor(run_in_tmpdir): openmc.deplete.predictor(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_restart.py b/tests/unit_tests/test_deplete_restart.py index ec62064a4e..4c0c68a2e3 100644 --- a/tests/unit_tests/test_deplete_restart.py +++ b/tests/unit_tests/test_deplete_restart.py @@ -23,7 +23,7 @@ def test_restart_predictor(run_in_tmpdir): openmc.deplete.predictor(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -33,7 +33,7 @@ def test_restart_predictor(run_in_tmpdir): openmc.deplete.predictor(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -62,7 +62,7 @@ def test_restart_cecm(run_in_tmpdir): openmc.deplete.cecm(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -72,7 +72,7 @@ def test_restart_cecm(run_in_tmpdir): openmc.deplete.cecm(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -102,7 +102,7 @@ def test_restart_predictor_cecm(run_in_tmpdir): openmc.deplete.predictor(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -112,7 +112,7 @@ def test_restart_predictor_cecm(run_in_tmpdir): openmc.deplete.cecm(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -142,7 +142,7 @@ def test_restart_cecm_predictor(run_in_tmpdir): openmc.deplete.cecm(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -152,7 +152,7 @@ def test_restart_cecm_predictor(run_in_tmpdir): openmc.deplete.predictor(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -181,7 +181,7 @@ def test_restart_cf4(run_in_tmpdir): openmc.deplete.cf4(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -191,7 +191,7 @@ def test_restart_cf4(run_in_tmpdir): openmc.deplete.cf4(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -220,7 +220,7 @@ def test_restart_epc_rk4(run_in_tmpdir): openmc.deplete.epc_rk4(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -230,7 +230,7 @@ def test_restart_epc_rk4(run_in_tmpdir): openmc.deplete.epc_rk4(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -259,7 +259,7 @@ def test_restart_celi(run_in_tmpdir): openmc.deplete.celi(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -269,7 +269,7 @@ def test_restart_celi(run_in_tmpdir): openmc.deplete.celi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -298,7 +298,7 @@ def test_restart_leqi(run_in_tmpdir): openmc.deplete.leqi(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -308,7 +308,7 @@ def test_restart_leqi(run_in_tmpdir): openmc.deplete.leqi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -336,7 +336,7 @@ def test_restart_si_celi(run_in_tmpdir): openmc.deplete.si_celi(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -346,7 +346,7 @@ def test_restart_si_celi(run_in_tmpdir): openmc.deplete.si_celi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") @@ -375,7 +375,7 @@ def test_restart_si_leqi(run_in_tmpdir): openmc.deplete.si_leqi(op, dt, power, print_out=False) # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -385,7 +385,7 @@ def test_restart_si_leqi(run_in_tmpdir): openmc.deplete.si_leqi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_resultslist.py b/tests/unit_tests/test_deplete_resultslist.py index c4b7aceba5..c3ceda5d56 100644 --- a/tests/unit_tests/test_deplete_resultslist.py +++ b/tests/unit_tests/test_deplete_resultslist.py @@ -12,7 +12,7 @@ def res(): """Load the reference results""" filename = (Path(__file__).parents[1] / 'regression_tests' / 'deplete' / 'test_reference.h5') - return openmc.deplete.ResultsList(filename) + return openmc.deplete.ResultsList.from_hdf5(filename) def test_get_atoms(res): diff --git a/tests/unit_tests/test_deplete_si_celi.py b/tests/unit_tests/test_deplete_si_celi.py index 71679439c5..e4ea4f6acf 100644 --- a/tests/unit_tests/test_deplete_si_celi.py +++ b/tests/unit_tests/test_deplete_si_celi.py @@ -21,7 +21,7 @@ def test_si_celi(run_in_tmpdir): openmc.deplete.si_celi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_deplete_si_leqi.py b/tests/unit_tests/test_deplete_si_leqi.py index 1396065c0f..cef64fbe88 100644 --- a/tests/unit_tests/test_deplete_si_leqi.py +++ b/tests/unit_tests/test_deplete_si_leqi.py @@ -21,7 +21,7 @@ def test_si_leqi(run_in_tmpdir): openmc.deplete.si_leqi(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") _, y1 = res.get_atoms("1", "1") _, y2 = res.get_atoms("1", "2") diff --git a/tests/unit_tests/test_transfer_volumes.py b/tests/unit_tests/test_transfer_volumes.py index 9128ed9694..38520ea1e3 100644 --- a/tests/unit_tests/test_transfer_volumes.py +++ b/tests/unit_tests/test_transfer_volumes.py @@ -21,10 +21,10 @@ def test_transfer_volumes(run_in_tmpdir): openmc.deplete.predictor(op, dt, power, print_out=False) # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.ResultsList.from_hdf5(op.output_dir / "depletion_results.h5") # Create a dictionary of volumes to transfer - res[0].volume['1'] = 1.5 + res[0].volume['1'] = 1.5 res[0].volume['2'] = 2.5 # Create dummy geometry From 00095b8b7430890c7853d38b8ad7c67d1d9aa69b Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 5 Aug 2019 16:18:03 -0500 Subject: [PATCH 2/4] Distribute process-specific previous results to operator Closes #1275 by passing reaction rates and numbers from a previous result according to what materials are tracked on an operator. A new method, Results.distribute, creates a new Results object by - directly copying over "global" data, like time, keff, and maps describing where each material lives in the depletion_results hdf5 file - mapping volumes for local materials - Extracting slices of numbers and reaction rates corresponding to local material This allows the Operator to create a unique ResultsList instance containing reaction rates and compositions pertaining to the materials tracked on this process (local). This has been tested by comparing depletion_result files from restarts 1) using a serial restart run and 2) using two MPI process. A quarter PWR assembly with 71 burnable materials was used. Comparing with h5diff -r -p 0.01 where group=["eigenvalues", "number", "reaction rates"] and -p 0.01 reports errors over 0.01% revealed no differences. --- openmc/deplete/operator.py | 29 +++++++++++++++++++---------- openmc/deplete/results.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/openmc/deplete/operator.py b/openmc/deplete/operator.py index 76163f922c..88f73b9958 100644 --- a/openmc/deplete/operator.py +++ b/openmc/deplete/operator.py @@ -23,6 +23,7 @@ from . import comm from .abc import TransportOperator, OperatorResult from .atom_number import AtomNumber from .reaction_rates import ReactionRates +from .results_list import ResultsList from .helpers import DirectReactionRateHelper, ChainFissionHelper @@ -72,7 +73,8 @@ class Operator(TransportOperator): specified, the depletion calculation will start from the latest state in the previous results. diff_burnable_mats : bool, optional - Whether to differentiate burnable materials with multiple instances + Whether to differentiate burnable materials with multiple instances. + Default: False. fission_q : dict, optional Dictionary of nuclides and their fission Q values [eV]. If not given, values will be pulled from the ``chain_file``. @@ -121,19 +123,11 @@ class Operator(TransportOperator): dilute_initial=1.0e3): super().__init__(chain_file, fission_q, dilute_initial) self.round_number = False + self.prev_res = None self.settings = settings self.geometry = geometry self.diff_burnable_mats = diff_burnable_mats - if prev_results is not None: - # Reload volumes into geometry - prev_results[-1].transfer_volumes(geometry) - - # Store previous results in operator - self.prev_res = prev_results - else: - self.prev_res = None - # Differentiate burnable materials with multiple instances if self.diff_burnable_mats: self._differentiate_burnable_mats() @@ -147,6 +141,21 @@ class Operator(TransportOperator): self._mat_index_map = { lm: self.burnable_mats.index(lm) for lm in self.local_mats} + if prev_results is not None: + # Reload volumes into geometry + prev_results[-1].transfer_volumes(geometry) + + # Store previous results in operator + # Distribute reaction rates according to those tracked + # on this process + if comm.size == 1: + self.prev_res = prev_results + else: + self.prev_res = ResultsList() + mat_indexes = _distribute(range(len(self.burnable_mats))) + for res_obj in prev_results: + new_res = res_obj.distribute(self.local_mats, mat_indexes) + self.prev_res.append(new_res) # Determine which nuclides have incident neutron data self.nuclides_with_data = self._get_nuclides_with_data() diff --git a/openmc/deplete/results.py b/openmc/deplete/results.py index 3771f9683b..e05fd6bf94 100644 --- a/openmc/deplete/results.py +++ b/openmc/deplete/results.py @@ -153,6 +153,34 @@ class Results(object): # Create storage array self.data = np.zeros((stages, self.n_mat, self.n_nuc)) + def distribute(self, local_materials, ranges): + """Create a new object containing data for distributed materials + + Parameters + ---------- + local_materials : iterable of str + Materials for this process + ranges : iterable of int + + Returns + ------- + Results + - New results object + """ + new = Results() + new.volume = {lm: self.volume[lm] for lm in local_materials} + new.mat_to_ind = dict(zip( + local_materials, range(len(local_materials)))) + # Direct transfer + direct_attrs = ("time", "k", "power", "nuc_to_ind", + "mat_to_hdf5_ind", "proc_time") + for attr in direct_attrs: + setattr(new, attr, getattr(self, attr)) + # Get applicable slice of data + new.data = self.data[:, ranges] + new.rates = [r[ranges] for r in self.rates] + return new + def export_to_hdf5(self, filename, step): """Export results to an HDF5 file From 4043e02fc78a5f43fc85f62ab5e0b9252e50b4e5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 7 Aug 2019 11:20:34 -0500 Subject: [PATCH 3/4] Apply suggestions from code review Co-Authored-By: Paul Romano --- openmc/deplete/results.py | 2 +- openmc/deplete/results_list.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/deplete/results.py b/openmc/deplete/results.py index e05fd6bf94..59a25d716c 100644 --- a/openmc/deplete/results.py +++ b/openmc/deplete/results.py @@ -165,7 +165,7 @@ class Results(object): Returns ------- Results - - New results object + New results object """ new = Results() new.volume = {lm: self.volume[lm] for lm in local_materials} diff --git a/openmc/deplete/results_list.py b/openmc/deplete/results_list.py index 8a0efcdbf1..3b5166ed8a 100644 --- a/openmc/deplete/results_list.py +++ b/openmc/deplete/results_list.py @@ -24,7 +24,7 @@ class ResultsList(list): Returns ------- new : ResultsList - New instance of depletion results + New instance of depletion results """ with h5py.File(str(filename), "r") as fh: check_filetype_version(fh, 'depletion results', _VERSION_RESULTS[0]) From 144aa3a2e39221e7829a1d0ca1e9c42c245a9e7b Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 7 Aug 2019 11:32:20 -0500 Subject: [PATCH 4/4] Document purpose for ranges in Results.distribute --- openmc/deplete/results.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openmc/deplete/results.py b/openmc/deplete/results.py index 59a25d716c..19911ba7f6 100644 --- a/openmc/deplete/results.py +++ b/openmc/deplete/results.py @@ -161,6 +161,9 @@ class Results(object): local_materials : iterable of str Materials for this process ranges : iterable of int + Slice-like object indicating indicies of ``local_materials`` + in the material dimension of :attr:`data` and each element + in :attr:`rates` Returns -------