From 8bfb1889b972ed31ab48da6b5c88810c8ddc38c2 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 28 Apr 2022 17:20:55 -0500 Subject: [PATCH] Rename deplete.ResultsList -> deplete.Results --- docs/source/pythonapi/deplete.rst | 2 +- docs/source/usersguide/depletion.rst | 4 ++-- examples/pincell_depletion/restart_depletion.py | 4 ++-- examples/pincell_depletion/run_depletion.py | 2 +- openmc/deplete/abc.py | 8 ++++---- openmc/deplete/operator.py | 12 ++++++------ openmc/deplete/results_list.py | 10 +++++----- tests/regression_tests/deplete/test.py | 6 +++--- tests/unit_tests/test_deplete_activation.py | 4 ++-- tests/unit_tests/test_deplete_integrator.py | 6 +++--- tests/unit_tests/test_deplete_restart.py | 8 ++++---- tests/unit_tests/test_deplete_resultslist.py | 8 ++++---- tests/unit_tests/test_transfer_volumes.py | 4 ++-- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/docs/source/pythonapi/deplete.rst b/docs/source/pythonapi/deplete.rst index 41be2d88a..9f7d8c447 100644 --- a/docs/source/pythonapi/deplete.rst +++ b/docs/source/pythonapi/deplete.rst @@ -133,7 +133,7 @@ data, such as number densities and reaction rates for each material. AtomNumber OperatorResult ReactionRates - ResultsList + Results StepResult The following class and functions are used to solve the depletion equations, diff --git a/docs/source/usersguide/depletion.rst b/docs/source/usersguide/depletion.rst index e3f4017f2..57619611f 100644 --- a/docs/source/usersguide/depletion.rst +++ b/docs/source/usersguide/depletion.rst @@ -49,11 +49,11 @@ one of these functions along with the timesteps and power level:: The coupled transport-depletion problem is executed, and once it is done a ``depletion_results.h5`` file is written. The results can be analyzed using the -:class:`openmc.deplete.ResultsList` class. This class has methods that allow for +:class:`openmc.deplete.Results` class. This class has methods that allow for easy retrieval of k-effective, nuclide concentrations, and reaction rates over time:: - results = openmc.deplete.ResultsList("depletion_results.h5") + results = openmc.deplete.Results("depletion_results.h5") time, keff = results.get_keff() Note that the coupling between the transport solver and the transmutation solver diff --git a/examples/pincell_depletion/restart_depletion.py b/examples/pincell_depletion/restart_depletion.py index 45bb4343d..95bbb9954 100644 --- a/examples/pincell_depletion/restart_depletion.py +++ b/examples/pincell_depletion/restart_depletion.py @@ -12,7 +12,7 @@ with openmc.StatePoint(statepoint) as sp: geometry = sp.summary.geometry # Load previous depletion results -previous_results = openmc.deplete.ResultsList("depletion_results.h5") +previous_results = openmc.deplete.Results("depletion_results.h5") ############################################################################### # Transport calculation settings @@ -56,7 +56,7 @@ integrator.integrate() ############################################################################### # Open results file -results = openmc.deplete.ResultsList("depletion_results.h5") +results = openmc.deplete.Results("depletion_results.h5") # Obtain K_eff as a function of time time, keff = results.get_keff(time_units='d') diff --git a/examples/pincell_depletion/run_depletion.py b/examples/pincell_depletion/run_depletion.py index 727039a29..ae069334e 100644 --- a/examples/pincell_depletion/run_depletion.py +++ b/examples/pincell_depletion/run_depletion.py @@ -101,7 +101,7 @@ integrator.integrate() ############################################################################### # Open results file -results = openmc.deplete.ResultsList("depletion_results.h5") +results = openmc.deplete.Results("depletion_results.h5") # Obtain K_eff as a function of time time, keff = results.get_keff(time_units='d') diff --git a/openmc/deplete/abc.py b/openmc/deplete/abc.py index 7d6e33924..9ba70af37 100644 --- a/openmc/deplete/abc.py +++ b/openmc/deplete/abc.py @@ -24,7 +24,7 @@ from openmc.checkvalue import check_type, check_greater_than from openmc.mpi import comm from .results import StepResult from .chain import Chain -from .results_list import ResultsList +from .results_list import Results from .pool import deplete @@ -79,7 +79,7 @@ class TransportOperator(ABC): in initial condition to ensure they exist in the decay chain. Only done for nuclides with reaction rates. Defaults to 1.0e3. - prev_results : ResultsList, optional + prev_results : Results, optional Results from a previous depletion calculation. Attributes @@ -88,7 +88,7 @@ class TransportOperator(ABC): Initial atom density [atoms/cm^3] to add for nuclides that are zero in initial condition to ensure they exist in the decay chain. Only done for nuclides with reaction rates. - prev_res : ResultsList or None + prev_res : Results or None Results from a previous depletion calculation. ``None`` if no results are to be used. """ @@ -102,7 +102,7 @@ class TransportOperator(ABC): if prev_results is None: self.prev_res = None else: - check_type("previous results", prev_results, ResultsList) + check_type("previous results", prev_results, Results) self.prev_res = prev_results @property diff --git a/openmc/deplete/operator.py b/openmc/deplete/operator.py index 1f31a22b6..da9588b87 100644 --- a/openmc/deplete/operator.py +++ b/openmc/deplete/operator.py @@ -25,7 +25,7 @@ from .abc import TransportOperator, OperatorResult from .atom_number import AtomNumber from .chain import _find_chain_file from .reaction_rates import ReactionRates -from .results_list import ResultsList +from .results_list import Results from .helpers import ( DirectReactionRateHelper, ChainFissionHelper, ConstantFissionYieldHelper, FissionYieldCutoffHelper, AveragedFissionYieldHelper, EnergyScoreHelper, @@ -94,7 +94,7 @@ class Operator(TransportOperator): Path to the depletion chain XML file. Defaults to the file listed under ``depletion_chain`` in :envvar:`OPENMC_CROSS_SECTIONS` environment variable. - prev_results : ResultsList, optional + prev_results : Results, optional Results from a previous depletion calculation. If this argument is specified, the depletion calculation will start from the latest state in the previous results. @@ -192,7 +192,7 @@ class Operator(TransportOperator): Initial heavy metal inventory [g] local_mats : list of str All burnable material IDs being managed by a single process - prev_res : ResultsList or None + prev_res : Results or None Results from a previous depletion calculation. ``None`` if no results are to be used. cleanup_when_done : bool @@ -284,7 +284,7 @@ class Operator(TransportOperator): if comm.size == 1: self.prev_res = prev_results else: - self.prev_res = ResultsList() + self.prev_res = Results() mat_indexes = _distribute(range(len(self.burnable_mats))) for res_obj in prev_results: new_res = res_obj.distribute(self.local_mats, mat_indexes) @@ -494,7 +494,7 @@ 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 + prev_res : Results, optional Results from a previous depletion calculation """ @@ -543,7 +543,7 @@ class Operator(TransportOperator): ---------- mat : openmc.Material The material to read from - prev_res : ResultsList + prev_res : Results Results from a previous depletion calculation """ diff --git a/openmc/deplete/results_list.py b/openmc/deplete/results_list.py index 97170f226..fb45792f6 100644 --- a/openmc/deplete/results_list.py +++ b/openmc/deplete/results_list.py @@ -12,7 +12,7 @@ from openmc.data.library import DataLibrary from openmc.material import Material, Materials from openmc.exceptions import DataError, InvalidArgumentError -__all__ = ["ResultsList"] +__all__ = ["Results"] def _get_time_as(seconds, units): @@ -26,10 +26,10 @@ def _get_time_as(seconds, units): return seconds -class ResultsList(list): +class Results(list): """Results from a depletion simulation - The :class:`ResultsList` class acts as a list that stores the results from + The :class:`Results` class acts as a list that stores the results from each depletion step and provides extra methods for interrogating these results. @@ -63,13 +63,13 @@ class ResultsList(list): Returns ------- - ResultsList + Results New instance of depletion results """ warn( "The from_hdf5(...) method is no longer necessary and will be removed " - "in a future version of OpenMC. Use ResultsList(...) instead.", + "in a future version of OpenMC. Use Results(...) instead.", FutureWarning ) return cls(filename) diff --git a/tests/regression_tests/deplete/test.py b/tests/regression_tests/deplete/test.py index 91f18667e..6c431fb33 100644 --- a/tests/regression_tests/deplete/test.py +++ b/tests/regression_tests/deplete/test.py @@ -77,8 +77,8 @@ def test_full(run_in_tmpdir, problem, multiproc): return # Load the reference/test results - res_test = openmc.deplete.ResultsList(path_test) - res_ref = openmc.deplete.ResultsList(path_reference) + res_test = openmc.deplete.Results(path_test) + res_ref = openmc.deplete.Results(path_reference) # Assert same mats for mat in res_ref[0].mat_to_ind: @@ -139,7 +139,7 @@ def test_depletion_results_to_material(run_in_tmpdir, problem): """Checks openmc.Materials objects can be created from depletion results""" # Load the reference/test results path_reference = Path(__file__).with_name('test_reference.h5') - res_ref = openmc.deplete.ResultsList(path_reference) + res_ref = openmc.deplete.Results(path_reference) # Firstly need to export materials.xml file for the initial simulation state geometry, lower_left, upper_right = problem diff --git a/tests/unit_tests/test_deplete_activation.py b/tests/unit_tests/test_deplete_activation.py index 2c3e0c053..0b82a5fbc 100644 --- a/tests/unit_tests/test_deplete_activation.py +++ b/tests/unit_tests/test_deplete_activation.py @@ -107,7 +107,7 @@ def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts integrator.integrate() # Get resulting number of atoms - results = openmc.deplete.ResultsList('depletion_results.h5') + results = openmc.deplete.Results('depletion_results.h5') _, atoms = results.get_atoms(w, "W186") assert atoms[0] == pytest.approx(n0) @@ -155,7 +155,7 @@ def test_decay(run_in_tmpdir): integrator.integrate() # Get resulting number of atoms - results = openmc.deplete.ResultsList('depletion_results.h5') + results = openmc.deplete.Results('depletion_results.h5') _, atoms = results.get_atoms(mat, "Sr89") # Ensure density goes down by a factor of 2 after each half-life diff --git a/tests/unit_tests/test_deplete_integrator.py b/tests/unit_tests/test_deplete_integrator.py index 4348b8c34..cb6374152 100644 --- a/tests/unit_tests/test_deplete_integrator.py +++ b/tests/unit_tests/test_deplete_integrator.py @@ -16,7 +16,7 @@ import pytest from openmc.mpi import comm from openmc.deplete import ( - ReactionRates, StepResult, ResultsList, OperatorResult, PredictorIntegrator, + ReactionRates, StepResult, Results, OperatorResult, PredictorIntegrator, CECMIntegrator, CF4Integrator, CELIIntegrator, EPCRK4Integrator, LEQIIntegrator, SICELIIntegrator, SILEQIIntegrator, cram) @@ -103,7 +103,7 @@ def test_results_save(run_in_tmpdir): StepResult.save(op, x2, op_result2, t2, 0, 1) # Load the files - res = ResultsList("depletion_results.h5") + res = Results("depletion_results.h5") for i in range(stages): for mat_i, mat in enumerate(burn_list): @@ -176,7 +176,7 @@ def test_integrator(run_in_tmpdir, scheme): # get expected results - res = ResultsList(operator.output_dir / "depletion_results.h5") + res = Results(operator.output_dir / "depletion_results.h5") t1, y1 = res.get_atoms("1", "1") t2, 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 2bfcfea7d..e8bfc062a 100644 --- a/tests/unit_tests/test_deplete_restart.py +++ b/tests/unit_tests/test_deplete_restart.py @@ -24,7 +24,7 @@ def test_restart_predictor_cecm(run_in_tmpdir): openmc.deplete.PredictorIntegrator(op, dt, power).integrate() # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.Results(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -50,7 +50,7 @@ def test_restart_cecm_predictor(run_in_tmpdir): cecm.integrate() # Load the files - prev_res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + prev_res = openmc.deplete.Results(op.output_dir / "depletion_results.h5") # Re-create depletion operator and load previous results op = dummy_operator.DummyOperator(prev_res) @@ -73,7 +73,7 @@ def test_restart(run_in_tmpdir, scheme): bundle.solver(operator, [0.75], 1.0).integrate() # restart - prev_res = openmc.deplete.ResultsList( + prev_res = openmc.deplete.Results( operator.output_dir / "depletion_results.h5") operator = dummy_operator.DummyOperator(prev_res) @@ -82,7 +82,7 @@ def test_restart(run_in_tmpdir, scheme): # compare results - results = openmc.deplete.ResultsList( + results = openmc.deplete.Results( operator.output_dir / "depletion_results.h5") _t, y1 = results.get_atoms("1", "1") diff --git a/tests/unit_tests/test_deplete_resultslist.py b/tests/unit_tests/test_deplete_resultslist.py index 2a2669920..6ce15601f 100644 --- a/tests/unit_tests/test_deplete_resultslist.py +++ b/tests/unit_tests/test_deplete_resultslist.py @@ -1,4 +1,4 @@ -"""Tests the ResultsList class""" +"""Tests the Results class""" from pathlib import Path from math import inf @@ -13,7 +13,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.Results(filename) def test_get_atoms(res): @@ -72,9 +72,9 @@ def test_get_keff(res): @pytest.mark.parametrize("unit", ("s", "d", "min", "h")) def test_get_steps(unit): - # Make a ResultsList full of near-empty Result instances + # Make a Results full of near-empty Result instances # Just fill out a time schedule - results = openmc.deplete.ResultsList() + results = openmc.deplete.Results() # Time in units of unit times = np.linspace(0, 100, num=5) if unit == "d": diff --git a/tests/unit_tests/test_transfer_volumes.py b/tests/unit_tests/test_transfer_volumes.py index 50e222b95..b768bc88a 100644 --- a/tests/unit_tests/test_transfer_volumes.py +++ b/tests/unit_tests/test_transfer_volumes.py @@ -2,7 +2,7 @@ from pytest import approx import openmc -from openmc.deplete import PredictorIntegrator, ResultsList +from openmc.deplete import PredictorIntegrator, Results from tests import dummy_operator @@ -19,7 +19,7 @@ def test_transfer_volumes(run_in_tmpdir): PredictorIntegrator(op, dt, power).integrate() # Load the files - res = openmc.deplete.ResultsList(op.output_dir / "depletion_results.h5") + res = openmc.deplete.Results(op.output_dir / "depletion_results.h5") # Create a dictionary of volumes to transfer res[0].volume['1'] = 1.5