diff --git a/docs/source/methods/energy_deposition.rst b/docs/source/methods/energy_deposition.rst index c43ee64ac4e..4694fa1407e 100644 --- a/docs/source/methods/energy_deposition.rst +++ b/docs/source/methods/energy_deposition.rst @@ -137,7 +137,7 @@ run with :math:`N918` reflecting fission heating computed from NJOY. + E_{i, \gamma, d}\right]\sigma_{i, f}(E). This modified heating data is stored as the MT=901 reaction and will be scored -if ``heating-local`` is included in :attr:`openmc.Tally.scores`. +if ``heating-local`` is included in :attr:`openmc.TallyBase.scores`. Coupled Neutron-Photon Transport -------------------------------- @@ -155,7 +155,7 @@ Let :math:`N301` represent the total heating number returned from this + \left[E_{i, fr}(E) + E_{i, \beta}(E)\right]\sigma_{i, f}(E). This modified heating data is stored as the MT=301 reaction and will be scored -if ``heating`` is included in :attr:`openmc.Tally.scores`. +if ``heating`` is included in :attr:`openmc.TallyBase.scores`. Photons and Charged Particles ----------------------------- diff --git a/docs/source/pythonapi/base.rst b/docs/source/pythonapi/base.rst index b3911c8b3ba..80c58647441 100644 --- a/docs/source/pythonapi/base.rst +++ b/docs/source/pythonapi/base.rst @@ -153,7 +153,10 @@ Constructing Tallies openmc.MeshMaterialVolumes openmc.Trigger openmc.TallyDerivative - openmc.Tally + openmc.TallyBase + openmc.VolumeTally + openmc.SurfaceTally + openmc.PulseHeightTally openmc.Tallies Meshes diff --git a/docs/source/usersguide/decay_sources.rst b/docs/source/usersguide/decay_sources.rst index 398680e7464..c53386e8fc7 100644 --- a/docs/source/usersguide/decay_sources.rst +++ b/docs/source/usersguide/decay_sources.rst @@ -100,7 +100,7 @@ create a shallow copy of the original neutron model (available as the ``neutron_model`` attribute) and store it in the ``photon_model`` attribute. We can use this to define tallies specific to the photon model:: - dose_tally = openmc.Tally() + dose_tally = openmc.VolumeTally() ... r2s.photon_model.tallies = [dose_tally] diff --git a/docs/source/usersguide/kinetics.rst b/docs/source/usersguide/kinetics.rst index 9024ff8227a..74e97f3d55e 100644 --- a/docs/source/usersguide/kinetics.rst +++ b/docs/source/usersguide/kinetics.rst @@ -78,7 +78,7 @@ Alternatively, each of the tallies can be manually defined using group-wise or total :math:`\beta_{\text{eff}}` specified by providing a 6-group :class:`openmc.DelayedGroupFilter`:: - beta_tally = openmc.Tally(name="group-beta-score") + beta_tally = openmc.VolumeTally(name="group-beta-score") beta_tally.scores = ["ifp-beta-numerator"] # Add DelayedGroupFilter to enable group-wise tallies @@ -87,7 +87,7 @@ total :math:`\beta_{\text{eff}}` specified by providing a 6-group Here is an example showing how to declare the three available IFP scores in a single tally:: - tally = openmc.Tally(name="ifp-scores") + tally = openmc.VolumeTally(name="ifp-scores") tally.scores = [ "ifp-time-numerator", "ifp-beta-numerator", diff --git a/docs/source/usersguide/processing.rst b/docs/source/usersguide/processing.rst index fe6ab0826ff..fe6c6fb3328 100644 --- a/docs/source/usersguide/processing.rst +++ b/docs/source/usersguide/processing.rst @@ -126,7 +126,7 @@ a flat array for a given dataset can be passed directly to this method. mesh.lower_left = [-5, -10, -15] mesh.upper_right = [5, 10, 15] mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter] tally.scores = ['flux'] @@ -136,10 +136,10 @@ a flat array for a given dataset can be passed directly to this method. # provide the data as-is to the method mesh.write_data_to_vtk('flux.vtk', {'flux-mean': tally.mean}) -The :class:`~openmc.Tally` object also provides a way to expand the dimensions +The :class:`~openmc.TallyBase` object also provides a way to expand the dimensions of the mesh filter into a meaningful form where indexing the mesh filter dimensions results in intuitive slicing of structured meshes by setting -``expand_dims=True`` when using :meth:`openmc.Tally.get_reshaped_data`. This +``expand_dims=True`` when using :meth:`openmc.TallyBase.get_reshaped_data`. This reshaping does cause flat indexing of the data to change, however. As noted above, provided datasets are allowed to be shaped so long as such datasets have shapes that match the mesh dimensions. The ability to pass datasets in this way @@ -158,7 +158,7 @@ demonstrates such a case for tally with both a :class:`~openmc.MeshFilter` and mesh.upper_right = [5, 10, 15] mesh_filter = openmc.MeshFilter(mesh) energy_filter = openmc.EnergyFilter([0.0, 1.0, 20.0e6]) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter, energy_filter] tally.scores = ['flux'] diff --git a/docs/source/usersguide/random_ray.rst b/docs/source/usersguide/random_ray.rst index 0c9a0402814..f689805d2ef 100644 --- a/docs/source/usersguide/random_ray.rst +++ b/docs/source/usersguide/random_ray.rst @@ -1139,7 +1139,7 @@ given below: energy_filter = openmc.EnergyFilter(group_edges) # Create tally using our two filters and add scores - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter, energy_filter] tally.scores = ['flux', 'fission', 'nu-fission'] @@ -1222,7 +1222,7 @@ given below: energy_filter = openmc.EnergyFilter(ebins) # Create tally using our two filters and add scores - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter, energy_filter] tally.scores = ['flux'] diff --git a/docs/source/usersguide/tallies.rst b/docs/source/usersguide/tallies.rst index 20a89cea7cb..fdd1bc7b640 100644 --- a/docs/source/usersguide/tallies.rst +++ b/docs/source/usersguide/tallies.rst @@ -7,7 +7,8 @@ Specifying Tallies .. currentmodule:: openmc In order to obtain estimates of physical quantities in your simulation, you need -to create one or more tallies using the :class:`openmc.Tally` class. As +to create one or more tallies using some of the :class:`openmc.TallyBase` subclasses. +The most used :class:`openmc.TallyBase` subclass is the :class:`openmc.VolumeTally` class. As explained in detail in the :ref:`theory manual `, tallies provide estimates of a scoring function times the flux integrated over some region of phase space, as in: @@ -53,8 +54,8 @@ Energies are specified in eV and need to be monotonically increasing. .. caution:: An energy bin between zero and the lowest energy specified is not included by default as it is in MCNP. -Once you have created a filter, it should be assigned to a :class:`openmc.Tally` -instance through the :attr:`Tally.filters` attribute:: +Once you have created a filter, it should be assigned to a :class:`openmc.TallyBase` +instance through the :attr:`TallyBase.filters` attribute:: tally.filters.append(cell_filter) tally.filters.append(energy_filter) @@ -74,7 +75,7 @@ Scores ------ To specify the scoring functions, a list of strings needs to be given to the -:attr:`Tally.scores` attribute. You can score the flux ('flux'), or a reaction +:attr:`TallyBase.scores` attribute. You can score the flux ('flux'), or a reaction rate ('total', 'fission', etc.). For example, to tally the elastic scattering rate and the fission neutron production, you'd assign:: @@ -82,7 +83,7 @@ rate and the fission neutron production, you'd assign:: With no further specification, you will get the total elastic scattering rate and the total fission neutron production. If you want reaction rates for a -particular nuclide or set of nuclides, you can set the :attr:`Tally.nuclides` +particular nuclide or set of nuclides, you can set the :attr:`TallyBase.nuclides` attribute to a list of strings indicating which nuclides. The nuclide names should follow the same :ref:`naming convention ` as that used for material specification. If we wanted the reaction rates only for U235 and diff --git a/examples/custom_source/build_xml.py b/examples/custom_source/build_xml.py index ff6dae2bb65..c8a5e230a94 100644 --- a/examples/custom_source/build_xml.py +++ b/examples/custom_source/build_xml.py @@ -29,7 +29,7 @@ mesh.upper_right = (5.0, 5.0) mesh.dimension = (50, 50) -tally = openmc.Tally() +tally = openmc.VolumeTally() tally.filters = [openmc.MeshFilter(mesh)] tally.scores = ['flux'] tallies = openmc.Tallies([tally]) diff --git a/examples/lattice/hexagonal/build_xml.py b/examples/lattice/hexagonal/build_xml.py index 2624e52b4d8..3929f0f3b8c 100644 --- a/examples/lattice/hexagonal/build_xml.py +++ b/examples/lattice/hexagonal/build_xml.py @@ -153,7 +153,7 @@ ############################################################################### # Instantiate a distribcell Tally -tally = openmc.Tally(tally_id=1) +tally = openmc.VolumeTally(tally_id=1) tally.filters = [openmc.DistribcellFilter(cell2)] tally.scores = ['total'] diff --git a/examples/lattice/nested/build_xml.py b/examples/lattice/nested/build_xml.py index a1d9c092dd9..d9ed42a3721 100644 --- a/examples/lattice/nested/build_xml.py +++ b/examples/lattice/nested/build_xml.py @@ -160,7 +160,7 @@ mesh_filter = openmc.MeshFilter(mesh) # Instantiate the Tally -tally = openmc.Tally(tally_id=1) +tally = openmc.VolumeTally(tally_id=1) tally.filters = [mesh_filter] tally.scores = ['total'] diff --git a/examples/lattice/simple/build_xml.py b/examples/lattice/simple/build_xml.py index 44531edd8a1..b697a4ae509 100644 --- a/examples/lattice/simple/build_xml.py +++ b/examples/lattice/simple/build_xml.py @@ -157,7 +157,7 @@ trigger.scores = ['all'] # Instantiate the Tally -tally = openmc.Tally(tally_id=1) +tally = openmc.VolumeTally(tally_id=1) tally.filters = [mesh_filter] tally.scores = ['total'] tally.triggers = [trigger] diff --git a/examples/parameterized_custom_source/build_xml.py b/examples/parameterized_custom_source/build_xml.py index 5ac6bf92870..01484567d8d 100644 --- a/examples/parameterized_custom_source/build_xml.py +++ b/examples/parameterized_custom_source/build_xml.py @@ -30,7 +30,7 @@ mesh.upper_right = (5.0, 5.0) mesh.dimension = (50, 50) -tally = openmc.Tally() +tally = openmc.VolumeTally() tally.filters = [openmc.MeshFilter(mesh)] tally.scores = ['flux'] tallies = openmc.Tallies([tally]) diff --git a/examples/pincell/build_xml.py b/examples/pincell/build_xml.py index aed0c790f10..80f835f2a29 100644 --- a/examples/pincell/build_xml.py +++ b/examples/pincell/build_xml.py @@ -93,7 +93,7 @@ mesh_filter = openmc.MeshFilter(mesh) # Now use the mesh filter in a tally and indicate what scores are desired -mesh_tally = openmc.Tally(name="Mesh tally") +mesh_tally = openmc.VolumeTally(name="Mesh tally") mesh_tally.filters = [mesh_filter] mesh_tally.scores = ['flux', 'fission', 'nu-fission'] @@ -104,7 +104,7 @@ energies = np.logspace(log10(e_min), log10(e_max), groups + 1) energy_filter = openmc.EnergyFilter(energies) -spectrum_tally = openmc.Tally(name="Flux spectrum") +spectrum_tally = openmc.VolumeTally(name="Flux spectrum") spectrum_tally.filters = [energy_filter] spectrum_tally.scores = ['flux'] diff --git a/examples/pincell_multigroup/build_xml.py b/examples/pincell_multigroup/build_xml.py index 0971e5de639..594cc69ce70 100644 --- a/examples/pincell_multigroup/build_xml.py +++ b/examples/pincell_multigroup/build_xml.py @@ -131,7 +131,7 @@ mesh_filter = openmc.MeshFilter(mesh) # Now use the mesh filter in a tally and indicate what scores are desired -mesh_tally = openmc.Tally(name="Mesh tally") +mesh_tally = openmc.VolumeTally(name="Mesh tally") mesh_tally.filters = [mesh_filter] mesh_tally.scores = ['flux', 'fission', 'nu-fission'] @@ -142,7 +142,7 @@ energies = np.logspace(log10(e_min), log10(e_max), groups + 1) energy_filter = openmc.EnergyFilter(energies) -spectrum_tally = openmc.Tally(name="Flux spectrum") +spectrum_tally = openmc.VolumeTally(name="Flux spectrum") spectrum_tally.filters = [energy_filter] spectrum_tally.scores = ['flux'] diff --git a/examples/pincell_pulsed/run_pulse.py b/examples/pincell_pulsed/run_pulse.py index b6a61ad3d81..e0222652119 100644 --- a/examples/pincell_pulsed/run_pulse.py +++ b/examples/pincell_pulsed/run_pulse.py @@ -76,7 +76,7 @@ time_filter = openmc.TimeFilter(t_grid) # Tally for total neutron density in time -density_tally = openmc.Tally(name="Density") +density_tally = openmc.VolumeTally(name="Density") density_tally.filters = [time_filter] density_tally.scores = ["inverse-velocity"] diff --git a/examples/pincell_random_ray/build_xml.py b/examples/pincell_random_ray/build_xml.py index 5ff4c0082fc..5a99314e7fe 100644 --- a/examples/pincell_random_ray/build_xml.py +++ b/examples/pincell_random_ray/build_xml.py @@ -180,7 +180,7 @@ energy_filter = openmc.EnergyFilter(group_edges) # Now use the mesh filter in a tally and indicate what scores are desired -tally = openmc.Tally(name="Mesh and Energy tally") +tally = openmc.VolumeTally(name="Mesh and Energy tally") tally.filters = [mesh_filter, energy_filter] tally.scores = ['flux', 'fission', 'nu-fission'] diff --git a/openmc/arithmetic.py b/openmc/arithmetic.py index 92c42284c01..0c40f2343e6 100644 --- a/openmc/arithmetic.py +++ b/openmc/arithmetic.py @@ -1,5 +1,6 @@ from collections.abc import Iterable import copy +from typing import Generic, TypeVar import numpy as np import pandas as pd @@ -15,8 +16,9 @@ # Acceptable tally aggregation operations _TALLY_AGGREGATE_OPS = {'sum', 'avg'} +T = TypeVar("T") -class CrossScore: +class CrossScore(Generic[T]): """A special-purpose tally score used to encapsulate all combinations of two tally's scores as an outer product for tally arithmetic. @@ -55,6 +57,10 @@ def __eq__(self, other): def __repr__(self): return f'({self.left_score} {self.binary_op} {self.right_score})' + + def __iter__(self): + yield self.left_score + yield self.right_score @property def left_score(self): @@ -87,7 +93,7 @@ def binary_op(self, binary_op): self._binary_op = binary_op -class CrossNuclide: +class CrossNuclide(Generic[T]): """A special-purpose nuclide used to encapsulate all combinations of two tally's nuclides as an outer product for tally arithmetic. @@ -126,6 +132,10 @@ def __eq__(self, other): def __repr__(self): return self.name + + def __iter__(self): + yield self.left_nuclide + yield self.right_nuclide @property def left_nuclide(self): @@ -162,7 +172,7 @@ def name(self): return f'({self.left_nuclide} {self.binary_op} {self.right_nuclide})' -class CrossFilter: +class CrossFilter(Generic[T]): """A special-purpose filter used to encapsulate all combinations of two tally's filter bins as an outer product for tally arithmetic. @@ -216,6 +226,10 @@ def __repr__(self): '{: <16}=\t{}'.format('\tBins', filter_bins) ] return '\n'.join(parts) + + def __iter__(self): + yield self.left_filter + yield self.right_filter @property def left_filter(self): @@ -296,7 +310,7 @@ def get_pandas_dataframe(self, data_size, summary=None): This method constructs a Pandas DataFrame object for the CrossFilter with columns annotated by filter bin information. This is a helper - method for the Tally.get_pandas_dataframe(...) method. This method + method for the TallyBase.get_pandas_dataframe(...) method. This method recursively builds and concatenates Pandas DataFrames for the left and right filters and crossfilters. @@ -326,7 +340,7 @@ def get_pandas_dataframe(self, data_size, summary=None): See also -------- - Tally.get_pandas_dataframe(), Filter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), Filter.get_pandas_dataframe() """ @@ -345,7 +359,7 @@ def get_pandas_dataframe(self, data_size, summary=None): return df -class AggregateScore: +class AggregateScore(Generic[T]): """A special-purpose tally score used to encapsulate an aggregate of a subset or all of tally's scores for tally aggregation. @@ -387,6 +401,9 @@ def __repr__(self): string = ', '.join(map(str, self.scores)) string = f'{self.aggregate_op}({string})' return string + + def __iter__(self): + yield from self._scores @property def scores(self): @@ -415,7 +432,7 @@ def name(self): return string -class AggregateNuclide: +class AggregateNuclide(Generic[T]): """A special-purpose tally nuclide used to encapsulate an aggregate of a subset or all of tally's nuclides for tally aggregation. @@ -455,6 +472,9 @@ def __eq__(self, other): def __repr__(self): return f'{self.aggregate_op}{self.name}' + + def __iter__(self): + yield from self._nuclides @property def nuclides(self): @@ -482,7 +502,7 @@ def name(self): return '(' + ', '.join(map(str, names)) + ')' -class AggregateFilter: +class AggregateFilter(Generic[T]): """A special-purpose tally filter used to encapsulate an aggregate of a subset or all of a tally filter's bins for tally aggregation. @@ -554,6 +574,9 @@ def __repr__(self): '{: <16}=\t{}'.format('\tBins', self.bins) ] return '\n'.join(parts) + + def __iter__(self): + yield self._aggregate_filter @property def aggregate_filter(self): @@ -645,7 +668,7 @@ def get_pandas_dataframe(self, data_size, stride, summary=None, **kwargs): This method constructs a Pandas DataFrame object for the AggregateFilter with columns annotated by filter bin information. This is a helper - method for the Tally.get_pandas_dataframe(...) method. + method for the TallyBase.get_pandas_dataframe(...) method. Parameters ---------- @@ -672,7 +695,7 @@ def get_pandas_dataframe(self, data_size, stride, summary=None, **kwargs): See also -------- - Tally.get_pandas_dataframe(), Filter.get_pandas_dataframe(), + TallyBase.get_pandas_dataframe(), Filter.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ diff --git a/openmc/checkvalue.py b/openmc/checkvalue.py index 5ff2cf9ac5a..2e04667c65b 100644 --- a/openmc/checkvalue.py +++ b/openmc/checkvalue.py @@ -1,6 +1,10 @@ import copy +import inspect import os from collections.abc import Iterable +import sys +import types +import typing import numpy as np @@ -8,6 +12,62 @@ PathLike = str | os.PathLike + +def _isinstance(obj, expected_type, _memo=None): + from openmc.tallies import (_SCORE_CLASSES, _FILTER_CLASSES, _NUCLIDE_CLASSES, _EMPTY_NUCLIDE_CLASSES, + _VOLUME_SCORE_CLASSES, _VOLUME_FILTER_CLASSES, + _SURFACE_SCORE_CLASSES, _SURFACE_FILTER_CLASSES, + _PULSEHEIGHT_SCORE_CLASSES, _PULSEHEIGHT_FILTER_CLASSES) + if _memo is None: + _memo = set() + + if isinstance(expected_type, str): + expected_type = typing.ForwardRef(expected_type) + + if isinstance(expected_type, typing.ForwardRef): + # Recursion Guard: If we've seen this (object, type) pair, assume True to break cycle + memo_key = (id(obj), id(expected_type)) + if memo_key in _memo: + return True + _memo.add(memo_key) + + # Resolve ForwardRef using caller's scope + for frame, *_ in inspect.stack()[1:]: + try: + expected_type = expected_type._evaluate(frame.f_globals, frame.f_locals, recursive_guard=frozenset()) + except NameError: + pass + else: + break + + origin = typing.get_origin(expected_type) + + # Handle Union (e.g., Union[int, str] or int | str) + if origin in (typing.Union, types.UnionType): + return any(_isinstance(obj, t, _memo) for t in typing.get_args(expected_type)) + + elif origin is typing.Literal: + return any(obj == t for t in typing.get_args(expected_type)) + + # Handle Generic Alias (e.g., list[int]) + if origin is not None: + if not _isinstance(obj, origin, _memo): + return False + + # Check inner types (e.g., the int in list[int]) + args = typing.get_args(expected_type) + if not args: + return True + + if origin is dict: + k_type, v_type = args + return all(_isinstance(k, k_type, _memo) and _isinstance(v, v_type, _memo) for k, v in obj.items()) + + if issubclass(origin, Iterable): + return all(_isinstance(item, args[0], _memo) for item in obj) + + return isinstance(obj, expected_type) + def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=False): """Ensure that an object is of an expected type. Optionally, if the object is iterable, check that each element is of a particular type. @@ -30,8 +90,8 @@ def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=F if none_ok and value is None: return - if not isinstance(value, expected_type): - if isinstance(expected_type, Iterable): + if not _isinstance(value, expected_type): + if _isinstance(expected_type, Iterable): msg = 'Unable to set "{}" to "{}" which is not one of the ' \ 'following types: "{}"'.format(name, value, ', '.join( [t.__name__ for t in expected_type])) @@ -41,7 +101,7 @@ def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=F raise TypeError(msg) if expected_iter_type: - if isinstance(value, np.ndarray): + if _isinstance(value, np.ndarray): if not issubclass(value.dtype.type, expected_iter_type): msg = (f'Unable to set "{name}" to "{value}" since each item ' f'must be of type "{expected_iter_type.__name__}"') @@ -50,8 +110,8 @@ def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=F return for item in value: - if not isinstance(item, expected_iter_type): - if isinstance(expected_iter_type, Iterable): + if not _isinstance(item, expected_iter_type): + if _isinstance(expected_iter_type, Iterable): msg = 'Unable to set "{}" to "{}" since each item must be ' \ 'one of the following types: "{}"'.format( name, value, ', '.join([t.__name__ for t in @@ -105,7 +165,7 @@ def check_iterable_type(name, value, expected_type, min_depth=1, max_depth=1): # If this item is of the expected type, then we've reached the bottom # level of this branch. - if isinstance(current_item, expected_type): + if _isinstance(current_item, expected_type): # Is this deep enough? if len(tree) < min_depth: msg = (f'Error setting "{name}": The item at {ind_str} does not ' @@ -118,7 +178,7 @@ def check_iterable_type(name, value, expected_type, min_depth=1, max_depth=1): # If this item is not of the expected type, then it's either an error or # on a deeper level of the tree. else: - if isinstance(current_item, Iterable): + if _isinstance(current_item, Iterable): # The tree goes deeper here, let's explore it. tree.append(current_item) index.append(0) @@ -324,6 +384,20 @@ def __init__(self, expected_type, name, items=None): if items is not None: for item in items: self.append(item) + + def __deepcopy__(self, memo): + import copy + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k != 'expected_type': + setattr(result, k, copy.deepcopy(v, memo)) + else: + setattr(result, k, v) + for item in self: + result.append(copy.deepcopy(item, memo)) + return result def __add__(self, other): new_instance = copy.copy(self) diff --git a/openmc/cmfd.py b/openmc/cmfd.py index 8595d1e020a..f01ce75551b 100644 --- a/openmc/cmfd.py +++ b/openmc/cmfd.py @@ -2941,9 +2941,9 @@ def _create_cmfd_tally(self): else: cmfd_tally.filters = [mesh_filter] # Set scores, type, and estimator for tally - cmfd_tally.scores = ['flux', 'total'] cmfd_tally.type = 'volume' cmfd_tally.estimator = 'analog' + cmfd_tally.scores = ['flux', 'total'] # Set attributes of CMFD neutron production tally elif i == 1: @@ -2954,9 +2954,9 @@ def _create_cmfd_tally(self): else: cmfd_tally.filters = [mesh_filter] # Set scores, type, and estimator for tally - cmfd_tally.scores = ['nu-scatter', 'nu-fission'] cmfd_tally.type = 'volume' cmfd_tally.estimator = 'analog' + cmfd_tally.scores = ['nu-scatter', 'nu-fission'] # Set attributes of CMFD surface current tally elif i == 2: @@ -2966,9 +2966,9 @@ def _create_cmfd_tally(self): else: cmfd_tally.filters = [meshsurface_filter] # Set scores, type, and estimator for tally - cmfd_tally.scores = ['current'] cmfd_tally.type = 'mesh-surface' cmfd_tally.estimator = 'analog' + cmfd_tally.scores = ['current'] # Set attributes of CMFD P1 scatter tally elif i == 3: @@ -2979,9 +2979,9 @@ def _create_cmfd_tally(self): else: cmfd_tally.filters = [mesh_filter, legendre_filter] # Set scores for tally - cmfd_tally.scores = ['scatter'] cmfd_tally.type = 'volume' cmfd_tally.estimator = 'analog' + cmfd_tally.scores = ['scatter'] # Set all tallies to be active from beginning cmfd_tally.active = True diff --git a/openmc/data/reaction.py b/openmc/data/reaction.py index ab1285b7219..2df6c45a896 100644 --- a/openmc/data/reaction.py +++ b/openmc/data/reaction.py @@ -78,6 +78,14 @@ REACTION_MT['fission'] = 18 REACTION_MT['absorption'] = 27 REACTION_MT['capture'] = 102 +REACTION_MT['n2n'] = 16 +REACTION_MT['n3n'] = 17 +REACTION_MT['n4n'] = 37 +REACTION_MT['H1-production'] = 203 +REACTION_MT['H2-production'] = 204 +REACTION_MT['H3-production'] = 205 +REACTION_MT['He3-production'] = 206 +REACTION_MT['He4-production'] = 207 FISSION_MTS = (18, 19, 20, 21, 38) diff --git a/openmc/deplete/d1s.py b/openmc/deplete/d1s.py index bc99fc42dba..9d87d58bed1 100644 --- a/openmc/deplete/d1s.py +++ b/openmc/deplete/d1s.py @@ -122,11 +122,11 @@ def time_correction_factors( def apply_time_correction( - tally: openmc.Tally, + tally: openmc.TallyBase, time_correction_factors: dict[str, np.ndarray], index: int = -1, sum_nuclides: bool = True -) -> openmc.Tally: +) -> openmc.TallyBase: """Apply time correction factors to a tally. This function applies the time correction factors at the given index to a @@ -136,8 +136,8 @@ def apply_time_correction( Parameters ---------- - tally : openmc.Tally - Tally to apply the time correction factors to + tally : openmc.TallyBase + TallyBase to apply the time correction factors to time_correction_factors : dict Time correction factors as returned by :func:`time_correction_factors` index : int, optional @@ -149,7 +149,7 @@ def apply_time_correction( Returns ------- - openmc.Tally + openmc.TallyBase Derived tally with time correction factors applied """ diff --git a/openmc/deplete/microxs.py b/openmc/deplete/microxs.py index e6e2dbce24c..375c5a4fc67 100644 --- a/openmc/deplete/microxs.py +++ b/openmc/deplete/microxs.py @@ -155,7 +155,7 @@ def get_microxs_and_flux( else: raise ValueError(f"Unsupported domain type: {type(domains[0])}") - flux_tally = openmc.Tally(name='MicroXS flux') + flux_tally = openmc.VolumeTally(name='MicroXS flux') flux_tally.filters = [domain_filter, energy_filter] flux_tally.scores = ['flux'] model.tallies = [flux_tally] @@ -179,7 +179,7 @@ def get_microxs_and_flux( # Only construct tally if both lists are non-empty if rr_nuclides and rr_reactions: - rr_tally = openmc.Tally(name='MicroXS RR') + rr_tally = openmc.VolumeTally(name='MicroXS RR') # Use 1-group energy filter for RR in flux mode if reaction_rate_mode == 'flux': rr_energy_filter = openmc.EnergyFilter( diff --git a/openmc/examples.py b/openmc/examples.py index f7f2bd48da1..a332cf63cbf 100644 --- a/openmc/examples.py +++ b/openmc/examples.py @@ -937,7 +937,7 @@ def random_ray_pin_cell(second_temp = False) -> openmc.Model: ########################################################################### # Define tallies # Now use the mesh filter in a tally and indicate what scores are desired - tally = openmc.Tally(name="Pin tally") + tally = openmc.VolumeTally(name="Pin tally") tally.scores = ['flux', 'fission', 'nu-fission'] tally.estimator = 'analog' @@ -1067,7 +1067,7 @@ def random_ray_lattice(second_temp = False) -> openmc.Model: energy_filter = openmc.EnergyFilter(group_edges) # Now use the mesh filter in a tally and indicate what scores are desired - tally = openmc.Tally(name="Mesh tally") + tally = openmc.VolumeTally(name="Mesh tally") tally.filters = [mesh_filter, energy_filter] tally.scores = ['flux', 'fission', 'nu-fission'] tally.estimator = 'analog' @@ -1281,19 +1281,19 @@ def fill_cube(N, n_1, n_2, fill_1, fill_2, fill_3): estimator = 'tracklength' absorber_filter = openmc.MaterialFilter(absorber_mat) - absorber_tally = openmc.Tally(name="Absorber Tally") + absorber_tally = openmc.VolumeTally(name="Absorber Tally") absorber_tally.filters = [absorber_filter] absorber_tally.scores = ['flux'] absorber_tally.estimator = estimator void_filter = openmc.MaterialFilter(void_mat) - void_tally = openmc.Tally(name="Void Tally") + void_tally = openmc.VolumeTally(name="Void Tally") void_tally.filters = [void_filter] void_tally.scores = ['flux'] void_tally.estimator = estimator source_filter = openmc.MaterialFilter(source_mat) - source_tally = openmc.Tally(name="Source Tally") + source_tally = openmc.VolumeTally(name="Source Tally") source_tally.filters = [source_filter] source_tally.scores = ['flux'] source_tally.estimator = estimator diff --git a/openmc/filter.py b/openmc/filter.py index 87aeb70c3a7..6601df383b6 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -381,7 +381,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -409,7 +409,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ # Initialize Pandas DataFrame @@ -650,7 +650,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -669,7 +669,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ # Repeat and tile bins as necessary to account for other filters. @@ -960,7 +960,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -983,7 +983,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ # Initialize dictionary to build Pandas Multi-index column @@ -1220,7 +1220,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -1239,7 +1239,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ # Repeat and tile bins as necessary to account for other filters. @@ -1297,7 +1297,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -1317,7 +1317,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ # Initialize Pandas DataFrame @@ -1603,7 +1603,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -1623,7 +1623,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ # Initialize Pandas DataFrame @@ -1984,7 +1984,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -2001,7 +2001,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ filter_dict = {} @@ -2216,7 +2216,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -2250,7 +2250,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ # Initialize Pandas DataFrame @@ -2813,7 +2813,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for - :meth:`Tally.get_pandas_dataframe`. + :meth:`TallyBase.get_pandas_dataframe`. Parameters ---------- @@ -2833,7 +2833,7 @@ def get_pandas_dataframe(self, data_size, stride, **kwargs): See also -------- - Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() + TallyBase.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe() """ df = pd.DataFrame() diff --git a/openmc/mesh.py b/openmc/mesh.py index 79982d78a7f..5905d0b73e0 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -480,7 +480,7 @@ def material_volumes( # In order to get mesh into model, we temporarily replace the # tallies with a single mesh tally using the current mesh original_tallies = list(model.tallies) - new_tally = openmc.Tally() + new_tally = openmc.VolumeTally() new_tally.filters = [openmc.MeshFilter(self)] new_tally.scores = ['flux'] model.tallies = [new_tally] @@ -676,7 +676,7 @@ def write_data_to_vtk(self, statepoint data without reordering/reshaping. Multidimensional datasets are expected to have the same dimensions as the mesh itself with structured indexing in "C" ordering. See the "expand_dims" flag - of :meth:`~openmc.Tally.get_reshaped_data` on reshaping tally data when using + of :meth:`~openmc.TallyBase.get_reshaped_data` on reshaping tally data when using :class:`~openmc.MeshFilter`'s. volume_normalization : bool, optional Whether or not to normalize the data by the volume of the mesh diff --git a/openmc/mgxs/mdgxs.py b/openmc/mgxs/mdgxs.py index 57cc955ba27..ccb98db2a33 100644 --- a/openmc/mgxs/mdgxs.py +++ b/openmc/mgxs/mdgxs.py @@ -92,11 +92,11 @@ class MDGXS(MGXS): The tally estimator used to compute the multi-group cross section tallies : dict OpenMC tallies needed to compute the multi-group cross section - rxn_rate_tally : openmc.Tally + rxn_rate_tally : openmc.TallyBase Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.TallyBase Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -776,7 +776,7 @@ def get_pandas_dataframe(self, groups='all', nuclides='all', delayed_groups='all'): """Build a Pandas DataFrame for the MDGXS data. - This method leverages :meth:`openmc.Tally.get_pandas_dataframe`, but + This method leverages :meth:`openmc.TallyBase.get_pandas_dataframe`, but renames the columns with terminology appropriate for cross section data. Parameters @@ -975,12 +975,12 @@ class ChiDelayed(MDGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`ChiDelayed.tally_keys` property and - values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + values are instances of :class:`openmc.TallyBase`. + rxn_rate_tally : openmc.TallyBase Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.TallyBase Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -1494,12 +1494,12 @@ class DelayedNuFissionXS(MDGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`DelayedNuFissionXS.tally_keys` property - and values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + and values are instances of :class:`openmc.TallyBase`. + rxn_rate_tally : openmc.TallyBase Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.TallyBase Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -1633,12 +1633,12 @@ class Beta(MDGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`Beta.tally_keys` property and - values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + values are instances of :class:`openmc.TallyBase`. + rxn_rate_tally : openmc.TallyBase Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.TallyBase Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -1826,12 +1826,12 @@ class DecayRate(MDGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`DecayRate.tally_keys` property and - values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + values are instances of :class:`openmc.TallyBase`. + rxn_rate_tally : openmc.TallyBase Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.TallyBase Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -2136,11 +2136,11 @@ class MatrixMDGXS(MDGXS): The tally estimator used to compute the multi-group cross section tallies : dict OpenMC tallies needed to compute the multi-group cross section - rxn_rate_tally : openmc.Tally + rxn_rate_tally : openmc.TallyBase Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.TallyBase Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -2735,12 +2735,12 @@ class DelayedNuFissionMatrixXS(MatrixMDGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`DelayedNuFissionXS.tally_keys` property - and values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + and values are instances of :class:`openmc.TallyBase`. + rxn_rate_tally : openmc.TallyBase Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.TallyBase Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 4c13c75087c..aba8e98f7e7 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -219,11 +219,11 @@ class MGXS: The tally estimator used to compute the multi-group cross section tallies : dict OpenMC tallies needed to compute the multi-group cross section - rxn_rate_tally : openmc.Tally + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -595,7 +595,10 @@ def tallies(self): tally_metadata = \ zip(self.scores, self.tally_keys, self.filters, estimators) for score, key, filters, estimator in tally_metadata: - self._tallies[key] = openmc.Tally(name=self.name) + if score != 'current': + self._tallies[key] = openmc.VolumeTally(name=self.name) + else: + self._tallies[key] = openmc.SurfaceTally(name=self.name) self._tallies[key].scores = [score] self._tallies[key].estimator = estimator if score != 'current': @@ -2034,7 +2037,7 @@ def get_pandas_dataframe(self, groups='all', nuclides='all', xs_type='macro', paths=True): """Build a Pandas DataFrame for the MGXS data. - This method leverages :meth:`openmc.Tally.get_pandas_dataframe`, but + This method leverages :meth:`openmc.TallyBase.get_pandas_dataframe`, but renames the columns with terminology appropriate for cross section data. Parameters @@ -2694,12 +2697,12 @@ class TransportXS(MGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`TransportXS.tally_keys` property and - values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + values are instances of :class:`openmc.VolumeTally`. + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -2935,12 +2938,12 @@ class DiffusionCoefficient(TransportXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`TransportXS.tally_keys` property and - values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + values are instances of :class:`openmc.VolumeTally`. + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -3398,12 +3401,12 @@ class FissionXS(MGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`FissionXS.tally_keys` property and - values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + values are instances of :class:`openmc.VolumeTally`. + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -3617,12 +3620,12 @@ class ScatterXS(MGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`ScatterXS.tally_keys` property and - values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + values are instances of :class:`openmc.VolumeTally`. + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -3927,12 +3930,12 @@ class ScatterMatrixXS(MatrixMGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`ScatterMatrixXS.tally_keys` property - and values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + and values are instances of :class:`openmc.VolumeTally`. + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -4712,7 +4715,7 @@ def get_pandas_dataframe(self, groups='all', nuclides='all', xs_type='macro', paths=False): """Build a Pandas DataFrame for the MGXS data. - This method leverages :meth:`openmc.Tally.get_pandas_dataframe`, but + This method leverages :meth:`openmc.TallyBase.get_pandas_dataframe`, but renames the columns with terminology appropriate for cross section data. Parameters @@ -5196,12 +5199,12 @@ class NuFissionMatrixXS(MatrixMGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`NuFissionMatrixXS.tally_keys` - property and values are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + property and values are instances of :class:`openmc.VolumeTally`. + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -5357,12 +5360,12 @@ class Chi(MGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`Chi.tally_keys` property and values are - instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + instances of :class:`openmc.VolumeTally`. + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -5924,11 +5927,11 @@ class MeshSurfaceMGXS(MGXS): The tally estimator used to compute the multi-group cross section tallies : dict OpenMC tallies needed to compute the multi-group cross section - rxn_rate_tally : openmc.Tally + rxn_rate_tally : openmc.VolumeTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.VolumeTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int @@ -6177,7 +6180,7 @@ def get_pandas_dataframe(self, groups='all', nuclides='all', xs_type='macro', paths=True): """Build a Pandas DataFrame for the MGXS data. - This method leverages :meth:`openmc.Tally.get_pandas_dataframe`, but + This method leverages :meth:`openmc.TallyBase.get_pandas_dataframe`, but renames the columns with terminology appropriate for cross section data. Parameters @@ -6312,12 +6315,12 @@ class Current(MeshSurfaceMGXS): tallies : dict OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the :attr:`TotalXS.tally_keys` property and values - are instances of :class:`openmc.Tally`. - rxn_rate_tally : openmc.Tally + are instances of :class:`openmc.SurfaceTally`. + rxn_rate_tally : openmc.SurfaceTally Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. - xs_tally : openmc.Tally + xs_tally : openmc.SurfaceTally Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed. num_subdomains : int diff --git a/openmc/model/model.py b/openmc/model/model.py index 884e3ff6f95..3d8a33eba8a 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -130,7 +130,7 @@ def tallies(self) -> openmc.Tallies: @tallies.setter def tallies(self, tallies): - check_type('tallies', tallies, Iterable, openmc.Tally) + check_type('tallies', tallies, Iterable, openmc.TallyBase) if isinstance(tallies, openmc.Tallies): self._tallies = tallies else: @@ -252,17 +252,17 @@ def add_kinetics_parameters_tallies(self, num_groups: int | None = None): """ if not any('ifp-time-numerator' in t.scores for t in self.tallies): - gen_time_tally = openmc.Tally(name='IFP time numerator') + gen_time_tally = openmc.VolumeTally(name='IFP time numerator') gen_time_tally.scores = ['ifp-time-numerator'] self.tallies.append(gen_time_tally) if not any('ifp-beta-numerator' in t.scores for t in self.tallies): - beta_tally = openmc.Tally(name='IFP beta numerator') + beta_tally = openmc.VolumeTally(name='IFP beta numerator') beta_tally.scores = ['ifp-beta-numerator'] if num_groups is not None: beta_tally.filters = [openmc.DelayedGroupFilter(list(range(1, num_groups + 1)))] self.tallies.append(beta_tally) if not any('ifp-denominator' in t.scores for t in self.tallies): - denom_tally = openmc.Tally(name='IFP denominator') + denom_tally = openmc.VolumeTally(name='IFP denominator') denom_tally.scores = ['ifp-denominator'] self.tallies.append(denom_tally) diff --git a/openmc/statepoint.py b/openmc/statepoint.py index a10ec3a839d..2d6c8d8bf61 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -424,9 +424,13 @@ def tallies(self): # Check if tally is internal and therefore has no data if group.attrs.get("internal"): continue + + tally_type = 'volume' + if 'type' in group: + tally_type = group['type'][()].decode() # Create Tally object and assign basic properties - tally = openmc.Tally(tally_id) + tally = {"volume": openmc.VolumeTally, "pulse-height": openmc.PulseHeightTally, "surface": openmc.SurfaceTally}[tally_type](tally_id) tally._sp_filename = Path(self._f.filename) tally.name = group['name'][()].decode() if 'name' in group else '' @@ -590,7 +594,7 @@ def get_tally(self, scores=[], filters=[], nuclides=[], Returns ------- - tally : openmc.Tally + tally : openmc.TallyBase A tally matching the specified criteria Raises diff --git a/openmc/tallies.py b/openmc/tallies.py index 151add2bee3..a51a32f9626 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -8,6 +8,7 @@ import operator from pathlib import Path import lxml.etree as ET +import typing import h5py import numpy as np @@ -16,6 +17,9 @@ import openmc import openmc.checkvalue as cv +from .data.reaction import REACTION_MT +from .lib.tally import _SCORES +from .lib.filter import _FILTER_TYPE_MAP from ._sparse_compat import lil_array from ._xml import clean_indentation, get_elem_list, get_text from .mixin import IDManagerMixin @@ -29,17 +33,48 @@ # specified axis. _PRODUCT_TYPES = ['tensor', 'entrywise'] -# The following indicate acceptable types when setting Tally.scores, -# Tally.nuclides, and Tally.filters -_SCORE_CLASSES = (str, openmc.CrossScore, openmc.AggregateScore) -_NUCLIDE_CLASSES = (str, openmc.CrossNuclide, openmc.AggregateNuclide) -_FILTER_CLASSES = (openmc.Filter, openmc.CrossFilter, openmc.AggregateFilter) +_ALL_SCORES = list(REACTION_MT)+list(_SCORES.values())+ ['scatter-1'] +_VOLUME_SCORES = [score for score in _ALL_SCORES if score not in ('pulse-height', 'current')] + +_ALL_FILTERS = [openmc.AzimuthalFilter, openmc.CellFilter, openmc.CellBornFilter, openmc.CellFromFilter, + openmc.CellInstanceFilter, openmc.CollisionFilter, openmc.DistribcellFilter, openmc.DelayedGroupFilter, + openmc.EnergyFilter, openmc.EnergyoutFilter, openmc.EnergyFunctionFilter, openmc.LegendreFilter, + openmc.MaterialFilter, openmc.MaterialFromFilter, openmc.MeshFilter, openmc.MeshBornFilter, + openmc.MeshMaterialFilter, openmc.MeshSurfaceFilter, openmc.MuFilter, openmc.MuSurfaceFilter, + openmc.ParentNuclideFilter, openmc.ParticleFilter, openmc.ParticleProductionFilter, openmc.PolarFilter, + openmc.ReactionFilter, openmc.SphericalHarmonicsFilter, openmc.SpatialLegendreFilter, + openmc.SurfaceFilter, openmc.TimeFilter, openmc.UniverseFilter, openmc.WeightFilter, openmc.ZernikeFilter, + openmc.ZernikeRadialFilter] +_VOLUME_FILTERS = [filt for filt in _ALL_FILTERS if filt not in (openmc.MeshSurfaceFilter, + openmc.SurfaceFilter, + openmc.MuSurfaceFilter, + openmc.SurfaceFilter)] +_SURFACE_FILTERS = [filt for filt in _ALL_FILTERS] +_PULSEHEIGHT_FILTERS = [openmc.CellFilter, openmc.EnergyFilter] + + +# The following indicate acceptable types when setting TallyBase.scores, +# TallyBase.nuclides, and TallyBase.filters +_SCORE_CLASSES = typing.Union[typing.Union[typing.Literal[tuple(_ALL_SCORES)], int], openmc.CrossScore['_SCORE_CLASSES'], openmc.AggregateScore['_SCORE_CLASSES']] +_FILTER_CLASSES = typing.Union[openmc.Filter, openmc.CrossFilter['_FILTER_CLASSES'], openmc.AggregateFilter['_FILTER_CLASSES']] +_NUCLIDE_CLASSES = typing.Union[str, openmc.CrossNuclide['_NUCLIDE_CLASSES'], openmc.AggregateNuclide['_NUCLIDE_CLASSES']] +_EMPTY_NUCLIDE_CLASSES = typing.Union[typing.Union[None, typing.Literal['total']], openmc.CrossNuclide['_EMPTY_NUCLIDE_CLASSES'], openmc.AggregateNuclide['_EMPTY_NUCLIDE_CLASSES']] + +_VOLUME_SCORE_CLASSES = typing.Union[typing.Union[typing.Literal[tuple(_VOLUME_SCORES)], int], openmc.CrossScore['_VOLUME_SCORE_CLASSES'], openmc.AggregateScore['_VOLUME_SCORE_CLASSES']] +_VOLUME_FILTER_CLASSES = typing.Union[typing.Union[tuple(_VOLUME_FILTERS)], openmc.CrossFilter['_VOLUME_FILTER_CLASSES'], openmc.AggregateFilter['_VOLUME_FILTER_CLASSES']] + +_SURFACE_SCORE_CLASSES = typing.Union[typing.Literal['flux', 'current'], openmc.CrossScore['_SURFACE_SCORE_CLASSES'], openmc.AggregateScore['_SURFACE_SCORE_CLASSES']] +_SURFACE_FILTER_CLASSES = typing.Union[typing.Union[tuple(_SURFACE_FILTERS)], openmc.CrossFilter['_SURFACE_FILTER_CLASSES'], openmc.AggregateFilter['_SURFACE_FILTER_CLASSES']] + +_PULSEHEIGHT_SCORE_CLASSES = typing.Union[typing.Literal['pulse-height'], openmc.CrossScore['_PULSEHEIGHT_SCORE_CLASSES'], openmc.AggregateScore['_PULSEHEIGHT_SCORE_CLASSES']] +_PULSEHEIGHT_FILTER_CLASSES = typing.Union[typing.Union[tuple(_PULSEHEIGHT_FILTERS)], openmc.CrossFilter['_PULSEHEIGHT_FILTER_CLASSES'], openmc.AggregateFilter['_PULSEHEIGHT_FILTER_CLASSES']] + # Valid types of estimators ESTIMATOR_TYPES = {'tracklength', 'collision', 'analog'} -class Tally(IDManagerMixin): +class TallyBase(IDManagerMixin): """A tally defined by a set of scores that are accumulated for a list of nuclides given a set of filters. @@ -135,6 +170,10 @@ class Tally(IDManagerMixin): next_id = 1 used_ids = set() + + FILTER_CLASSES = _FILTER_CLASSES + SCORE_CLASSES = _SCORE_CLASSES + NUCLIDE_CLASSES = _NUCLIDE_CLASSES def __init__(self, tally_id=None, name='', scores=None, filters=None, nuclides=None, estimator=None, triggers=None, @@ -142,9 +181,9 @@ def __init__(self, tally_id=None, name='', scores=None, filters=None, # Initialize Tally class attributes self.id = tally_id self.name = name - self._filters = cv.CheckedList(_FILTER_CLASSES, 'tally filters') - self._nuclides = cv.CheckedList(_NUCLIDE_CLASSES, 'tally nuclides') - self._scores = cv.CheckedList(_SCORE_CLASSES, 'tally scores') + self._filters = cv.CheckedList(self.FILTER_CLASSES, 'tally filters') + self._nuclides = cv.CheckedList(self.NUCLIDE_CLASSES, 'tally nuclides') + self._scores = cv.CheckedList(self.SCORE_CLASSES, 'tally scores') self._estimator = None self._triggers = cv.CheckedList(openmc.Trigger, 'tally triggers') self._derivative = None @@ -233,7 +272,7 @@ def ensure_results(f): Results will be loaded if appropriate based on the tally properties. Args: - f function: Tally method to wrap + f function: TallyBase method to wrap Returns: function: Wrapped function that reads tally results before calling @@ -291,7 +330,7 @@ def filters(self, filters): raise ValueError(msg) visited_filters.add(f) - self._filters = cv.CheckedList(_FILTER_CLASSES, 'tally filters', filters) + self._filters = cv.CheckedList(self.FILTER_CLASSES, 'tally filters', filters) @property @ensure_results @@ -312,7 +351,7 @@ def nuclides(self, nuclides): raise ValueError(msg) visited_nuclides.add(nuc) - self._nuclides = cv.CheckedList(_NUCLIDE_CLASSES, 'tally nuclides', + self._nuclides = cv.CheckedList(self.NUCLIDE_CLASSES, 'tally nuclides', nuclides) @property @@ -348,7 +387,7 @@ def scores(self, scores): raise ValueError(msg) scores[i] = score.strip() - self._scores = cv.CheckedList(_SCORE_CLASSES, 'tally scores', scores) + self._scores = cv.CheckedList(self.SCORE_CLASSES, 'tally scores', scores) @property def num_scores(self): @@ -1079,7 +1118,7 @@ def _can_merge_filters(self, other): Parameters ---------- - other : openmc.Tally + other : openmc.TallyBase Tally to check for mergeable filters """ @@ -1119,7 +1158,7 @@ def _can_merge_nuclides(self, other): Parameters ---------- - other : openmc.Tally + other : openmc.TallyBase Tally to check for mergeable nuclides """ @@ -1153,7 +1192,7 @@ def _can_merge_scores(self, other): Parameters ---------- - other : openmc.Tally + other : openmc.TallyBase Tally to check for mergeable scores """ @@ -1192,12 +1231,12 @@ def can_merge(self, other): Parameters ---------- - other : openmc.Tally + other : openmc.TallyBase Tally to check for merging """ - if not isinstance(other, Tally): + if not isinstance(other, TallyBase): return False # Must have same estimator @@ -1235,12 +1274,12 @@ def merge(self, other): Parameters ---------- - other : openmc.Tally + other : openmc.TallyBase Tally to merge with this one Returns ------- - merged_tally : openmc.Tally + merged_tally : openmc.TallyBase Merged tallies """ @@ -1413,6 +1452,10 @@ def to_xml_element(self): # Tally ID element.set("id", str(self.id)) + + # Tally Type + if self.tally_type != VolumeTally.tally_type: + element.set("type", self.tally_type) # Optional Tally name if self.name != '': @@ -1508,51 +1551,20 @@ def from_xml_element(cls, elem, **kwargs): Returns ------- - openmc.Tally + openmc.TallyBase Tally object """ - tally_id = int(get_text(elem, "id")) - name = get_text(elem, "name", "") - tally = cls(tally_id=tally_id, name=name) - - text = get_text(elem, 'multiply_density') - if text is not None: - tally.multiply_density = text in ('true', '1') - - # Read filters - filter_ids = get_elem_list(elem, "filters", int) - if filter_ids is not None: - tally.filters = [kwargs['filters'][uid] for uid in filter_ids] - - # Read nuclides - nuclides = get_elem_list(elem, "nuclides", str) - if nuclides is not None: - tally.nuclides = nuclides - - # Read scores - scores = get_elem_list(elem, "scores", str) - if scores is not None: - tally.scores = scores - - # Set estimator - estimator = get_text(elem, "estimator") - if estimator is not None: - tally.estimator = estimator - - # Read triggers - tally.triggers = [ - openmc.Trigger.from_xml_element(trigger_elem) - for trigger_elem in elem.findall('trigger') - ] - - # Read tally derivative - deriv = get_text(elem, "derivative") - if deriv is not None: - deriv_id = int(deriv) - tally.derivative = kwargs['derivatives'][deriv_id] - - return tally + tally_type = get_text(elem, 'type') + + if tally_type == 'volume' or tally_type is None: + return VolumeTally.from_xml_element(elem, **kwargs) + elif tally_type == 'surface': + return SurfaceTally.from_xml_element(elem, **kwargs) + elif tally_type == 'pulse-height': + return PulseHeightTally.from_xml_element(elem, **kwargs) + else: + raise ValueError(f'Unrecognized tally type "{tally_type}" found.') def contains_filter(self, filter_type): """Looks for a filter in the tally that matches a specified type @@ -1674,7 +1686,7 @@ def get_score_index(self, score): def get_filter_indices(self, filters=[], filter_bins=[]): """Get indices into the filter axis of this tally's data arrays. - This is a helper method for the Tally.get_values(...) method to + This is a helper method for the TallyBase.get_values(...) method to extract tally data. This method returns the indices into the filter axis of the tally's data array (axis=0) for particular combinations of filters and their corresponding bins. @@ -1737,7 +1749,7 @@ def get_filter_indices(self, filters=[], filter_bins=[]): def get_nuclide_indices(self, nuclides): """Get indices into the nuclide axis of this tally's data arrays. - This is a helper method for the Tally.get_values(...) method to + This is a helper method for the TallyBase.get_values(...) method to extract tally data. This method returns the indices into the nuclide axis of the tally's data array (axis=1) for one or more nuclides. @@ -1769,7 +1781,7 @@ def get_nuclide_indices(self, nuclides): def get_score_indices(self, scores): """Get indices into the score axis of this tally's data arrays. - This is a helper method for the Tally.get_values(...) method to + This is a helper method for the TallyBase.get_values(...) method to extract tally data. This method returns the indices into the score axis of the tally's data array (axis=2) for one or more scores. @@ -2042,7 +2054,7 @@ def get_reshaped_data(self, value='mean', expand_dims=False): The tally data in OpenMC is stored as a 3D array with the dimensions corresponding to filters, nuclides and scores. As a result, tally data can be opaque for a user to directly index (i.e., without use of - :meth:`openmc.Tally.get_values`) since one must know how to properly use + :meth:`openmc.TallyBase.get_values`) since one must know how to properly use the number of bins and strides for each filter to index into the first (filter) dimension. @@ -2124,7 +2136,7 @@ def hybrid_product(self, other, binary_op, filter_product=None, Parameters ---------- - other : openmc.Tally + other : openmc.TallyBase The tally on the right hand side of the hybrid product binary_op : {'+', '-', '*', '/', '^'} The binary operation in the hybrid product @@ -2146,7 +2158,7 @@ def hybrid_product(self, other, binary_op, filter_product=None, Returns ------- - openmc.Tally + openmc.TallyBase A new Tally that is the hybrid product with this one. Raises @@ -2190,7 +2202,7 @@ def hybrid_product(self, other, binary_op, filter_product=None, f'ID="{other.id}" since it does not contain any results.' raise ValueError(msg) - new_tally = Tally() + new_tally = type(self)() new_tally._derived = True new_tally.with_batch_statistics = True new_tally._num_realizations = self.num_realizations @@ -2336,7 +2348,7 @@ def _align_tally_data(self, other, filter_product, nuclide_product, Parameters ---------- - other : openmc.Tally + other : openmc.TallyBase The tally to outer product with this tally filter_product : {'entrywise'} The type of product to be performed between filter data. Currently, @@ -2489,8 +2501,8 @@ def _swap_filters(self, filter1, filter2): """ - cv.check_type('filter1', filter1, _FILTER_CLASSES) - cv.check_type('filter2', filter2, _FILTER_CLASSES) + cv.check_type('filter1', filter1, self.FILTER_CLASSES) + cv.check_type('filter2', filter2, self.FILTER_CLASSES) # Check that the filters exist in the tally and are not the same if filter1 == filter2: @@ -2582,8 +2594,8 @@ def _swap_nuclides(self, nuclide1, nuclide2): 'since it does not contain any results.' raise ValueError(msg) - cv.check_type('nuclide1', nuclide1, _NUCLIDE_CLASSES) - cv.check_type('nuclide2', nuclide2, _NUCLIDE_CLASSES) + cv.check_type('nuclide1', nuclide1, self.NUCLIDE_CLASSES) + cv.check_type('nuclide2', nuclide2, self.NUCLIDE_CLASSES) # Check that the nuclides exist in the tally and are not the same if nuclide1 == nuclide2: @@ -2709,12 +2721,12 @@ def __add__(self, other): Parameters ---------- - other : openmc.Tally or float + other : openmc.TallyBase or float The tally or scalar value to add to this tally Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally which is the sum of this tally and the other tally or scalar value in the addition. @@ -2731,7 +2743,7 @@ def __add__(self, other): 'since it does not contain any results.'.format(self.id) raise ValueError(msg) - if isinstance(other, Tally): + if isinstance(other, TallyBase): new_tally = self.hybrid_product(other, binary_op='+') # If both tally operands were sparse, sparsify the new tally @@ -2739,7 +2751,7 @@ def __add__(self, other): new_tally.sparse = True elif isinstance(other, Real): - new_tally = Tally(name='derived') + new_tally = type(self)(name='derived') new_tally._derived = True new_tally.with_batch_statistics = True new_tally.name = self.name @@ -2781,12 +2793,12 @@ def __sub__(self, other): Parameters ---------- - other : openmc.Tally or float + other : openmc.TallyBase or float The tally or scalar value to subtract from this tally Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally which is the difference of this tally and the other tally or scalar value in the subtraction. @@ -2803,7 +2815,7 @@ def __sub__(self, other): 'since it does not contain any results.'.format(self.id) raise ValueError(msg) - if isinstance(other, Tally): + if isinstance(other, TallyBase): new_tally = self.hybrid_product(other, binary_op='-') # If both tally operands were sparse, sparsify the new tally @@ -2811,7 +2823,7 @@ def __sub__(self, other): new_tally.sparse = True elif isinstance(other, Real): - new_tally = Tally(name='derived') + new_tally = type(self)(name='derived') new_tally._derived = True new_tally.name = self.name new_tally._mean = self.mean - other @@ -2852,12 +2864,12 @@ def __mul__(self, other): Parameters ---------- - other : openmc.Tally or float + other : openmc.TallyBase or float The tally or scalar value to multiply with this tally Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally which is the product of this tally and the other tally or scalar value in the multiplication. @@ -2874,7 +2886,7 @@ def __mul__(self, other): 'since it does not contain any results.'.format(self.id) raise ValueError(msg) - if isinstance(other, Tally): + if isinstance(other, TallyBase): new_tally = self.hybrid_product(other, binary_op='*') # If original tally operands were sparse, sparsify the new tally @@ -2882,7 +2894,7 @@ def __mul__(self, other): new_tally.sparse = True elif isinstance(other, Real): - new_tally = Tally(name='derived') + new_tally = type(self)(name='derived') new_tally._derived = True new_tally.name = self.name new_tally._mean = self.mean * other @@ -2923,12 +2935,12 @@ def __truediv__(self, other): Parameters ---------- - other : openmc.Tally or float + other : openmc.TallyBase or float The tally or scalar value to divide this tally by Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally which is the dividend of this tally and the other tally or scalar value in the division. @@ -2945,7 +2957,7 @@ def __truediv__(self, other): 'since it does not contain any results.'.format(self.id) raise ValueError(msg) - if isinstance(other, Tally): + if isinstance(other, TallyBase): new_tally = self.hybrid_product(other, binary_op='/') # If original tally operands were sparse, sparsify the new tally @@ -2953,7 +2965,7 @@ def __truediv__(self, other): new_tally.sparse = True elif isinstance(other, Real): - new_tally = Tally(name='derived') + new_tally = type(self)(name='derived') new_tally._derived = True new_tally.name = self.name new_tally._mean = self.mean / other @@ -2998,12 +3010,12 @@ def __pow__(self, power): Parameters ---------- - power : openmc.Tally or float + power : openmc.TallyBase or float The tally or scalar value exponent Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally which is this tally raised to the power of the other tally or scalar value in the exponentiation. @@ -3020,7 +3032,7 @@ def __pow__(self, power): 'since it does not contain any results.'.format(self.id) raise ValueError(msg) - if isinstance(power, Tally): + if isinstance(power, TallyBase): new_tally = self.hybrid_product(power, binary_op='^') # If original tally operand was sparse, sparsify the new tally @@ -3028,7 +3040,7 @@ def __pow__(self, power): new_tally.sparse = True elif isinstance(power, Real): - new_tally = Tally(name='derived') + new_tally = type(self)(name='derived') new_tally._derived = True new_tally.name = self.name new_tally._mean = self._mean ** power @@ -3063,7 +3075,7 @@ def __radd__(self, other): Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally of this tally added with the scalar value. """ @@ -3082,7 +3094,7 @@ def __rsub__(self, other): Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally of this tally subtracted from the scalar value. """ @@ -3101,7 +3113,7 @@ def __rmul__(self, other): Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally of this tally multiplied by the scalar value. """ @@ -3120,7 +3132,7 @@ def __rdiv__(self, other): Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally of the scalar value divided by this tally. """ @@ -3132,7 +3144,7 @@ def __abs__(self): Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally which is the absolute value of this tally. """ @@ -3146,7 +3158,7 @@ def __neg__(self): Returns ------- - openmc.Tally + openmc.TallyBase A new derived tally which is the negated value of this tally. """ @@ -3189,7 +3201,7 @@ def get_slice(self, scores=[], filters=[], filter_bins=[], nuclides=[], Returns ------- - openmc.Tally + openmc.TallyBase A new tally which encapsulates the subset of data requested in the order each filter, nuclide and score is listed in the parameters. @@ -3343,12 +3355,12 @@ def summation(self, scores=[], filter_type=None, Returns ------- - openmc.Tally + openmc.TallyBase A new tally which encapsulates the sum of data requested. """ # Create new derived Tally for summation - tally_sum = Tally() + tally_sum = type(self)() tally_sum._derived = True tally_sum._estimator = self.estimator tally_sum._num_realizations = self.num_realizations @@ -3495,12 +3507,12 @@ def average(self, scores=[], filter_type=None, Returns ------- - openmc.Tally + openmc.TallyBase A new tally which encapsulates the average of data requested. """ # Create new derived Tally for average - tally_avg = Tally() + tally_avg = type(self)() tally_avg._derived = True tally_avg._estimator = self.estimator tally_avg._num_realizations = self.num_realizations @@ -3636,12 +3648,12 @@ def diagonalize_filter(self, new_filter, filter_position=-1): Returns ------- - openmc.Tally + openmc.TallyBase A new derived Tally with data diagonalized along the new filter. """ - cv.check_type('new_filter', new_filter, _FILTER_CLASSES) + cv.check_type('new_filter', new_filter, self.FILTER_CLASSES) cv.check_type('filter_position', filter_position, Integral) if new_filter in self.filters: @@ -3691,29 +3703,476 @@ def diagonalize_filter(self, new_filter, filter_position=-1): return new_tally +class VolumeTally(TallyBase): + """A volume tally defined by a set of scores that are accumulated for a list of + nuclides given a set of filters. + + Parameters + ---------- + tally_id : int, optional + Unique identifier for the tally. If none is specified, an identifier + will automatically be assigned + name : str, optional + Name of the tally. If not specified, the name is the empty string. + scores : list of str, optional + List of scores, e.g. ['flux', 'fission'] + filters : list of openmc.Filter, optional + List of filters for the tally + nuclides : list of str, optional + List of nuclides to score results for + estimator : {'analog', 'tracklength', 'collision'}, optional + Type of estimator for the tally + triggers : list of openmc.Trigger, optional + List of tally triggers + derivative : openmc.TallyDerivative, optional + A material perturbation derivative to apply to all scores in the tally + + Attributes + ---------- + id : int + Unique identifier for the tally + name : str + Name of the tally + multiply_density : bool + Whether reaction rates should be multiplied by atom density + + .. versionadded:: 0.14.0 + filters : list of openmc.Filter + List of specified filters for the tally + nuclides : list of str + List of nuclides to score results for + scores : list of str + List of defined scores, e.g. 'flux', 'fission', etc. + estimator : {'analog', 'tracklength', 'collision'} + Type of estimator for the tally. If unset (None), OpenMC will automatically + select an appropriate estimator based on the tally filters and scores + with a preference for 'tracklength'. + triggers : list of openmc.Trigger + List of tally triggers + num_scores : int + Total number of scores + num_filter_bins : int + Total number of filter bins accounting for all filters + num_bins : int + Total number of bins for the tally + shape : 3-tuple of int + The shape of the tally data array ordered as the number of filter bins, + nuclide bins and score bins + filter_strides : list of int + Stride in memory for each filter + num_realizations : int + Total number of realizations + with_summary : bool + Whether or not a Summary has been linked + sum : numpy.ndarray + An array containing the sum of each independent realization for each bin + sum_sq : numpy.ndarray + An array containing the sum of each independent realization squared for + each bin + sum_third : numpy.ndarray + An array containing the sum of each independent realization to the third power for + each bin + sum_fourth : numpy.ndarray + An array containing the sum of each independent realization to the fourth power for + each bin + mean : numpy.ndarray + An array containing the sample mean for each bin + std_dev : numpy.ndarray + An array containing the sample standard deviation for each bin + vov : numpy.ndarray + An array containing the variance of the variance for each tally bin + higher_moments : bool + Whether or not the tally accumulates the sums third and fourth to compute higher-order moments + figure_of_merit : numpy.ndarray + An array containing the figure of merit for each bin + + .. versionadded:: 0.15.3 + derived : bool + Whether or not the tally is derived from one or more other tallies + sparse : bool + Whether or not the tally uses SciPy's LIL sparse matrix format for + compressed data storage + derivative : openmc.TallyDerivative + A material perturbation derivative to apply to all scores in the tally. + + """ + + tally_type = "volume" + + FILTER_CLASSES = _VOLUME_FILTER_CLASSES + SCORE_CLASSES = _VOLUME_SCORE_CLASSES + + def __init__(self, tally_id=None, name='', scores=None, filters=None, + nuclides=None, estimator=None, triggers=None, + derivative=None): + super().__init__(tally_id=tally_id, name=name, scores=scores, filters=filters, + nuclides=nuclides, estimator=estimator, triggers=triggers, + derivative=derivative) + + @classmethod + def from_xml_element(cls, elem, **kwargs): + """Generate tally object from an XML element + + + Parameters + ---------- + elem : lxml.etree._Element + XML element + + Returns + ------- + openmc.TallyBase + Tally object + + """ + tally_id = int(get_text(elem, "id")) + name = get_text(elem, "name", "") + tally = cls(tally_id=tally_id, name=name) + + text = get_text(elem, 'multiply_density') + if text is not None: + tally.multiply_density = text in ('true', '1') + + # Read filters + filter_ids = get_elem_list(elem, "filters", int) + if filter_ids is not None: + tally.filters = [kwargs['filters'][uid] for uid in filter_ids] + + # Read nuclides + nuclides = get_elem_list(elem, "nuclides", str) + if nuclides is not None: + tally.nuclides = nuclides + + # Read scores + scores = get_elem_list(elem, "scores", str) + if scores is not None: + tally.scores = scores + + # Set estimator + estimator = get_text(elem, "estimator") + if estimator is not None: + tally.estimator = estimator + + # Read triggers + tally.triggers = [ + openmc.Trigger.from_xml_element(trigger_elem) + for trigger_elem in elem.findall('trigger') + ] + + # Read tally derivative + deriv = get_text(elem, "derivative") + if deriv is not None: + deriv_id = int(deriv) + tally.derivative = kwargs['derivatives'][deriv_id] + + return tally + + +class SurfaceTally(TallyBase): + """A surface tally defined by a set of scores that are accumulated given a set of filters. + + Parameters + ---------- + tally_id : int, optional + Unique identifier for the tally. If none is specified, an identifier + will automatically be assigned + name : str, optional + Name of the tally. If not specified, the name is the empty string. + scores : list of str, optional + List of scores, e.g. ['flux', 'fission'] + filters : list of openmc.Filter, optional + List of filters for the tally + triggers : list of openmc.Trigger, optional + List of tally triggers + + Attributes + ---------- + id : int + Unique identifier for the tally + name : str + Name of the tally + + .. versionadded:: 0.14.0 + filters : list of openmc.Filter + List of specified filters for the tally + scores : list of str + List of defined scores, e.g. 'flux', 'fission', etc. + triggers : list of openmc.Trigger + List of tally triggers + num_scores : int + Total number of scores + num_filter_bins : int + Total number of filter bins accounting for all filters + num_bins : int + Total number of bins for the tally + shape : 3-tuple of int + The shape of the tally data array ordered as the number of filter bins, + nuclide bins and score bins + filter_strides : list of int + Stride in memory for each filter + num_realizations : int + Total number of realizations + with_summary : bool + Whether or not a Summary has been linked + sum : numpy.ndarray + An array containing the sum of each independent realization for each bin + sum_sq : numpy.ndarray + An array containing the sum of each independent realization squared for + each bin + sum_third : numpy.ndarray + An array containing the sum of each independent realization to the third power for + each bin + sum_fourth : numpy.ndarray + An array containing the sum of each independent realization to the fourth power for + each bin + mean : numpy.ndarray + An array containing the sample mean for each bin + std_dev : numpy.ndarray + An array containing the sample standard deviation for each bin + vov : numpy.ndarray + An array containing the variance of the variance for each tally bin + higher_moments : bool + Whether or not the tally accumulates the sums third and fourth to compute higher-order moments + figure_of_merit : numpy.ndarray + An array containing the figure of merit for each bin + + .. versionadded:: 0.15.3 + derived : bool + Whether or not the tally is derived from one or more other tallies + sparse : bool + Whether or not the tally uses SciPy's LIL sparse matrix format for + compressed data storage + + """ + + tally_type = "surface" + + FILTER_CLASSES = _SURFACE_FILTER_CLASSES + SCORE_CLASSES = _SURFACE_SCORE_CLASSES + NUCLIDE_CLASSES = _EMPTY_NUCLIDE_CLASSES + + def __init__(self, tally_id=None, name='', scores=None, filters=None, + triggers=None): + super().__init__(tally_id=tally_id, name=name, scores=scores, filters=filters, + estimator="analog", triggers=triggers) + + @classmethod + def from_xml_element(cls, elem, **kwargs): + """Generate tally object from an XML element + + + Parameters + ---------- + elem : lxml.etree._Element + XML element + + Returns + ------- + openmc.TallyBase + Tally object + + """ + tally_id = int(get_text(elem, "id")) + name = get_text(elem, "name", "") + tally = cls(tally_id=tally_id, name=name) + + # Read filters + filter_ids = get_elem_list(elem, "filters", int) + if filter_ids is not None: + tally.filters = [kwargs['filters'][uid] for uid in filter_ids] + + # Read scores + scores = get_elem_list(elem, "scores", str) + if scores is not None: + tally.scores = scores + + # Set estimator + estimator = get_text(elem, "estimator") + if estimator is not None: + tally.estimator = estimator + + # Read triggers + tally.triggers = [ + openmc.Trigger.from_xml_element(trigger_elem) + for trigger_elem in elem.findall('trigger') + ] + + return tally + + @TallyBase.derivative.setter + def derivative(self, deriv): + cv.check_type('tally derivative', deriv, {None}) + self._derivative = deriv + + @TallyBase.estimator.setter + def estimator(self, estimator): + cv.check_value('estimator', estimator, ("analog", None)) + self._estimator = estimator + + +class PulseHeightTally(TallyBase): + """A pulse height tally defined by a set of filters. + + Parameters + ---------- + tally_id : int, optional + Unique identifier for the tally. If none is specified, an identifier + will automatically be assigned + name : str, optional + Name of the tally. If not specified, the name is the empty string. + scores : list of str, optional + List of scores, e.g. ['flux', 'fission'] + filters : list of openmc.Filter, optional + List of filters for the tally + triggers : list of openmc.Trigger, optional + List of tally triggers + + Attributes + ---------- + id : int + Unique identifier for the tally + name : str + Name of the tally + multiply_density : bool + Whether reaction rates should be multiplied by atom density + + .. versionadded:: 0.14.0 + filters : list of openmc.Filter + List of specified filters for the tally + nuclides : list of str + List of nuclides to score results for + scores : list of str + List of defined scores, e.g. 'flux', 'fission', etc. + triggers : list of openmc.Trigger + List of tally triggers + num_scores : int + Total number of scores + num_filter_bins : int + Total number of filter bins accounting for all filters + num_bins : int + Total number of bins for the tally + shape : 3-tuple of int + The shape of the tally data array ordered as the number of filter bins, + nuclide bins and score bins + filter_strides : list of int + Stride in memory for each filter + num_realizations : int + Total number of realizations + with_summary : bool + Whether or not a Summary has been linked + sum : numpy.ndarray + An array containing the sum of each independent realization for each bin + sum_sq : numpy.ndarray + An array containing the sum of each independent realization squared for + each bin + sum_third : numpy.ndarray + An array containing the sum of each independent realization to the third power for + each bin + sum_fourth : numpy.ndarray + An array containing the sum of each independent realization to the fourth power for + each bin + mean : numpy.ndarray + An array containing the sample mean for each bin + std_dev : numpy.ndarray + An array containing the sample standard deviation for each bin + vov : numpy.ndarray + An array containing the variance of the variance for each tally bin + higher_moments : bool + Whether or not the tally accumulates the sums third and fourth to compute higher-order moments + figure_of_merit : numpy.ndarray + An array containing the figure of merit for each bin + + .. versionadded:: 0.15.3 + derived : bool + Whether or not the tally is derived from one or more other tallies + sparse : bool + Whether or not the tally uses SciPy's LIL sparse matrix format for + compressed data storage + + """ + + tally_type = "pulse-height" + + FILTER_CLASSES = _PULSEHEIGHT_FILTER_CLASSES + SCORE_CLASSES = _PULSEHEIGHT_SCORE_CLASSES + NUCLIDE_CLASSES = _EMPTY_NUCLIDE_CLASSES + + def __init__(self, tally_id=None, name='', filters=None, triggers=None): + super().__init__(tally_id=tally_id, name=name, scores=['pulse-height'], filters=filters, + estimator="collision", triggers=triggers) + + @classmethod + def from_xml_element(cls, elem, **kwargs): + """Generate tally object from an XML element + + + Parameters + ---------- + elem : lxml.etree._Element + XML element + + Returns + ------- + openmc.TallyBase + Tally object + + """ + tally_id = int(get_text(elem, "id")) + name = get_text(elem, "name", "") + tally = cls(tally_id=tally_id, name=name) + + # Read filters + filter_ids = get_elem_list(elem, "filters", int) + if filter_ids is not None: + tally.filters = [kwargs['filters'][uid] for uid in filter_ids] + + # Read scores + scores = get_elem_list(elem, "scores", str) + if scores is not None: + tally.scores = scores + + # Set estimator + estimator = get_text(elem, "estimator") + if estimator is not None: + tally.estimator = estimator + + # Read triggers + tally.triggers = [ + openmc.Trigger.from_xml_element(trigger_elem) + for trigger_elem in elem.findall('trigger') + ] + + return tally + + @TallyBase.derivative.setter + def derivative(self, deriv): + cv.check_value('tally derivative', deriv, None) + self._derivative = deriv + + class Tallies(cv.CheckedList): """Collection of Tallies used for an OpenMC simulation. This class corresponds directly to the tallies.xml input file. It can be - thought of as a normal Python list where each member is a :class:`Tally`. It + thought of as a normal Python list where each member is a :class:`TallyBase`. It behaves like a list as the following example demonstrates: - >>> t1 = openmc.Tally() - >>> t2 = openmc.Tally() - >>> t3 = openmc.Tally() + >>> t1 = openmc.VolumeTally() + >>> t2 = openmc.SurfaceTally() + >>> t3 = openmc.PulseHeightTally() >>> tallies = openmc.Tallies([t1]) >>> tallies.append(t2) >>> tallies += [t3] Parameters ---------- - tallies : Iterable of openmc.Tally + tallies : Iterable of openmc.TallyBase Tallies to add to the collection """ def __init__(self, tallies=None): - super().__init__(Tally, 'tallies collection') + super().__init__(TallyBase, 'tallies collection') if tallies is not None: self += tallies @@ -3722,7 +4181,7 @@ def append(self, tally, merge=False): Parameters ---------- - tally : openmc.Tally + tally : openmc.TallyBase Tally to append merge : bool Indicate whether the tally should be merged with an existing tally, @@ -3893,7 +4352,7 @@ def from_xml_element(cls, elem, meshes=None): # Read tally elements tallies = [] for e in elem.findall('tally'): - tally = openmc.Tally.from_xml_element( + tally = openmc.TallyBase.from_xml_element( e, filters=filters, derivatives=derivatives ) tallies.append(tally) diff --git a/src/state_point.cpp b/src/state_point.cpp index c0d8ab5b2fa..a174e6e102e 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -188,6 +188,13 @@ extern "C" int openmc_statepoint_write(const char* filename, bool* write_source) write_dataset(tally_group, "name", tally->name_); + if ((tally->type_ == TallyType::SURFACE) || + (tally->type_ == TallyType::MESH_SURFACE)) { + write_dataset(tally_group, "type", "surface"); + } else if (tally->type_ == TallyType::PULSE_HEIGHT) { + write_dataset(tally_group, "type", "pulse-height"); + } + if (tally->writable_) { write_attribute(tally_group, "internal", 0); } else { diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 3fe48c1b021..697d79a3759 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -102,6 +102,17 @@ Tally::Tally(pugi::xml_node node) if (check_for_node(node, "name")) name_ = get_node_value(node, "name"); + if (check_for_node(node, "type")) { + auto type_str = get_node_value(node, "type"); + if (type_str == "surface") { + type_ = TallyType::SURFACE; + } else if (type_str == "pulse-height") { + type_ = TallyType::PULSE_HEIGHT; + } else if (type_str != "volume") { + fatal_error(fmt::format("Unknown tally type {}", type_str)); + } + } + if (check_for_node(node, "multiply_density")) { multiply_density_ = get_node_value_bool(node, "multiply_density"); } @@ -568,12 +579,29 @@ void Tally::set_scores(const vector& scores) meshsurface_present = true; } } - bool surface_types_present = - (surface_present || cellfrom_present || materialfrom_present); bool non_meshsurface_types_present = (surface_present || cell_present || cellfrom_present || material_present || materialfrom_present); + if (meshsurface_present && (type_ == TallyType::SURFACE)) + type_ = TallyType::MESH_SURFACE; + + if ((type_ == TallyType::PULSE_HEIGHT) && non_cell_energy_present) + fatal_error("Pulse-height tallies are not compatible with filters " + "other than CellFilter and EnergyFilter"); + + if ((type_ == TallyType::MESH_SURFACE) && non_meshsurface_types_present) + fatal_error("Cannot tally mesh surface tally with surface type filters."); + + if ((type_ == TallyType::VOLUME) && (surface_present || meshsurface_present)) + fatal_error("Cannot use surface filters in a volume tally."); + + if ((type_ == TallyType::SURFACE) || (type_ == TallyType::MESH_SURFACE)) + estimator_ = TallyEstimator::ANALOG; + + if (type_ == TallyType::PULSE_HEIGHT) + estimator_ = TallyEstimator::COLLISION; + // Iterate over the given scores. for (auto score_str : scores) { // Make sure a delayed group filter wasn't used with an incompatible @@ -594,12 +622,8 @@ void Tally::set_scores(const vector& scores) fatal_error("Cannot tally flux for an individual nuclide."); if (energyout_present) fatal_error("Cannot tally flux with an outgoing energy filter."); - if (surface_types_present) { - if (meshsurface_present) - fatal_error("OpenMC does not support mesh surface fluxes yet"); - type_ = TallyType::SURFACE; - estimator_ = TallyEstimator::ANALOG; - } + if (type_ == TallyType::MESH_SURFACE) + fatal_error("OpenMC does not support mesh surface fluxes yet"); break; case SCORE_TOTAL: @@ -631,16 +655,9 @@ void Tally::set_scores(const vector& scores) break; case SCORE_CURRENT: - // Check which type of current is desired: mesh or surface currents. - if (meshsurface_present) { - if (non_meshsurface_types_present) - fatal_error("Cannot tally mesh surface currents in the same tally as " - "normal surface currents"); - type_ = TallyType::MESH_SURFACE; - } else { - type_ = TallyType::SURFACE; - estimator_ = TallyEstimator::ANALOG; - } + if ((type_ != TallyType::SURFACE) && (type_ != TallyType::MESH_SURFACE)) + fatal_error("Cannot tally current in non surface tallies."); + estimator_ = TallyEstimator::ANALOG; break; case HEATING: @@ -649,11 +666,9 @@ void Tally::set_scores(const vector& scores) break; case SCORE_PULSE_HEIGHT: { - if (non_cell_energy_present) { - fatal_error("Pulse-height tallies are not compatible with filters " - "other than CellFilter and EnergyFilter"); - } - type_ = TallyType::PULSE_HEIGHT; + if (type_ != TallyType::PULSE_HEIGHT) + fatal_error( + "Can only tally pulse-height score in a pulse-height tally."); // Collect all unique cell indices covered by this tally. // If no CellFilter is present, all cells in the geometry are scored. const auto* cell_filter_ptr = get_filter(); @@ -697,10 +712,10 @@ void Tally::set_scores(const vector& scores) } // Make sure mesh surface tallies contain only current score. - if (meshsurface_present) { + if (type_ == TallyType::MESH_SURFACE) { if ((scores_[0] != SCORE_CURRENT) || (scores_.size() > 1)) fatal_error("Cannot tally score other than 'current' when using a " - "mesh-surface filter."); + "mesh-surface filter in a surface tally."); } // Make sure surface tallies contain only surface type scores score. @@ -708,7 +723,14 @@ void Tally::set_scores(const vector& scores) for (auto sc : scores_) if ((sc != SCORE_CURRENT) && (sc != SCORE_FLUX)) fatal_error("Cannot tally scores other than 'current' or 'flux' " - "when using surface filters."); + "when using a surface tally."); + } + + // Make sure pulse height tallies contain only pulse height score. + if (type_ == TallyType::PULSE_HEIGHT) { + if ((scores_[0] != SCORE_PULSE_HEIGHT) || (scores_.size() > 1)) + fatal_error("Cannot tally score other than 'pulse-height' when using a " + "pulse height tally."); } } diff --git a/tests/regression_tests/asymmetric_lattice/test.py b/tests/regression_tests/asymmetric_lattice/test.py index fadf272ffd3..86108c01b3d 100644 --- a/tests/regression_tests/asymmetric_lattice/test.py +++ b/tests/regression_tests/asymmetric_lattice/test.py @@ -46,7 +46,7 @@ def __init__(self, *args, **kwargs): distrib_filter = openmc.DistribcellFilter(27) # Initialize the tallies - tally = openmc.Tally(name='distribcell tally', tally_id=27) + tally = openmc.VolumeTally(name='distribcell tally', tally_id=27) tally.filters.append(distrib_filter) tally.scores.append('nu-fission') diff --git a/tests/regression_tests/atomic_relaxation/test.py b/tests/regression_tests/atomic_relaxation/test.py index 0d2413f5908..d818b43e62e 100644 --- a/tests/regression_tests/atomic_relaxation/test.py +++ b/tests/regression_tests/atomic_relaxation/test.py @@ -29,7 +29,7 @@ def model(): model.settings.atomic_relaxation = False model.settings.run_mode = 'fixed source' - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [openmc.ParticleFilter(['photon', 'electron'])] tally.scores = ['flux', 'heating'] model.tallies = [tally] diff --git a/tests/regression_tests/create_fission_neutrons/test.py b/tests/regression_tests/create_fission_neutrons/test.py index 0ca4a48b292..ff34aa56e18 100755 --- a/tests/regression_tests/create_fission_neutrons/test.py +++ b/tests/regression_tests/create_fission_neutrons/test.py @@ -44,7 +44,7 @@ def __init__(self, *args, **kwargs): # Create tallies tallies = openmc.Tallies() - tally = openmc.Tally(1) + tally = openmc.VolumeTally(1) tally.scores = ['flux'] tallies.append(tally) self._model.tallies = tallies diff --git a/tests/regression_tests/dagmc/external/test.py b/tests/regression_tests/dagmc/external/test.py index 3580bfa11e6..0de524aef0b 100644 --- a/tests/regression_tests/dagmc/external/test.py +++ b/tests/regression_tests/dagmc/external/test.py @@ -74,7 +74,7 @@ def model(): model.geometry = openmc.Geometry(dag_univ) # Tallies - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['total'] tally.filters = [openmc.CellFilter(1)] model.tallies = [tally] diff --git a/tests/regression_tests/dagmc/legacy/test.py b/tests/regression_tests/dagmc/legacy/test.py index b6b1e376b00..0961f029997 100644 --- a/tests/regression_tests/dagmc/legacy/test.py +++ b/tests/regression_tests/dagmc/legacy/test.py @@ -35,7 +35,7 @@ def model(): model.geometry = openmc.Geometry(dag_univ) # tally - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['total'] tally.filters = [openmc.CellFilter(1)] model.tallies = [tally] @@ -104,4 +104,4 @@ def test_surf_source(model): def test_dagmc(model): harness = PyAPITestHarness('statepoint.5.h5', model) - harness.main() \ No newline at end of file + harness.main() diff --git a/tests/regression_tests/dagmc/refl/test.py b/tests/regression_tests/dagmc/refl/test.py index a13acc0256a..d7f8ce20b6e 100644 --- a/tests/regression_tests/dagmc/refl/test.py +++ b/tests/regression_tests/dagmc/refl/test.py @@ -27,7 +27,7 @@ def __init__(self, *args, **kwargs): self._model.geometry = openmc.Geometry(dag_univ) # tally - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['total'] tally.filters = [openmc.CellFilter(2)] self._model.tallies = [tally] diff --git a/tests/regression_tests/dagmc/universes/test.py b/tests/regression_tests/dagmc/universes/test.py index d68c6b11cfa..c1c55c127d9 100644 --- a/tests/regression_tests/dagmc/universes/test.py +++ b/tests/regression_tests/dagmc/universes/test.py @@ -72,7 +72,7 @@ def pin_lattice_model(): model.geometry = openmc.Geometry([bounding_cell]) # add a cell instance tally - tally = openmc.Tally(name='cell instance tally') + tally = openmc.VolumeTally(name='cell instance tally') # using scattering cell_instance_filter = openmc.CellInstanceFilter(((4, 0), (4, 1), (4, 2), (4, 3), (4, 4))) tally.filters = [cell_instance_filter] diff --git a/tests/regression_tests/dagmc/uwuw/test.py b/tests/regression_tests/dagmc/uwuw/test.py index bea464cfabc..20cb83eddb8 100644 --- a/tests/regression_tests/dagmc/uwuw/test.py +++ b/tests/regression_tests/dagmc/uwuw/test.py @@ -27,7 +27,7 @@ def __init__(self, *args, **kwargs): self._model.geometry = openmc.Geometry(root=dag_univ) # tally - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['total'] tally.filters = [openmc.CellFilter(1)] self._model.tallies = [tally] diff --git a/tests/regression_tests/diff_tally/test.py b/tests/regression_tests/diff_tally/test.py index 89460df9152..84083f28d97 100644 --- a/tests/regression_tests/diff_tally/test.py +++ b/tests/regression_tests/diff_tally/test.py @@ -55,7 +55,7 @@ def __init__(self, *args, **kwargs): # Cover the flux score. for i in range(5): - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ['flux'] t.filters = [filt_mats] t.derivative = derivs[i] @@ -63,7 +63,7 @@ def __init__(self, *args, **kwargs): # Cover supported scores with a collision estimator. for i in range(5): - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ['total', 'absorption', 'scatter', 'fission', 'nu-fission'] t.filters = [filt_mats] t.nuclides = ['total', 'U235'] @@ -72,7 +72,7 @@ def __init__(self, *args, **kwargs): # Cover an analog estimator. for i in range(5): - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ['absorption'] t.filters = [filt_mats] t.estimator = 'analog' @@ -81,7 +81,7 @@ def __init__(self, *args, **kwargs): # Energyout filter and total nuclide for the density derivatives. for i in range(2): - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ['nu-fission', 'scatter'] t.filters = [filt_mats, filt_eout] t.nuclides = ['total', 'U235'] @@ -90,7 +90,7 @@ def __init__(self, *args, **kwargs): # Energyout filter without total nuclide for other derivatives. for i in range(2, 5): - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ['nu-fission', 'scatter'] t.filters = [filt_mats, filt_eout] t.nuclides = ['U235'] diff --git a/tests/regression_tests/eigenvalue_genperbatch/test.py b/tests/regression_tests/eigenvalue_genperbatch/test.py index 17c6dff7f97..57cba0ef877 100644 --- a/tests/regression_tests/eigenvalue_genperbatch/test.py +++ b/tests/regression_tests/eigenvalue_genperbatch/test.py @@ -24,7 +24,7 @@ def model(): space = openmc.stats.Box((-4.0, -4.0, -4.0), (4.0, 4.0, 4.)) model.settings.source = openmc.IndependentSource(space=space) - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ['flux'] model.tallies.append(t) diff --git a/tests/regression_tests/electron_heating/test.py b/tests/regression_tests/electron_heating/test.py index e7a58560c49..a6986d589e6 100644 --- a/tests/regression_tests/electron_heating/test.py +++ b/tests/regression_tests/electron_heating/test.py @@ -28,7 +28,7 @@ def water_model(): settings.source = source # Define tallies - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ["heating"] tallies = openmc.Tallies([tally]) diff --git a/tests/regression_tests/energy_cutoff/test.py b/tests/regression_tests/energy_cutoff/test.py index 9aca802fa35..810fda778d5 100755 --- a/tests/regression_tests/energy_cutoff/test.py +++ b/tests/regression_tests/energy_cutoff/test.py @@ -46,7 +46,7 @@ def __init__(self, *args, **kwargs): # Tally flux under energy cutoff tallies = openmc.Tallies() - tally = openmc.Tally(1) + tally = openmc.VolumeTally(1) tally.scores = ['flux'] energy_filter = openmc.filter.EnergyFilter((0.0, energy_cutoff)) tally.filters = [energy_filter] diff --git a/tests/regression_tests/external_moab/test.py b/tests/regression_tests/external_moab/test.py index 2d64eb14bb9..05d23c6776d 100644 --- a/tests/regression_tests/external_moab/test.py +++ b/tests/regression_tests/external_moab/test.py @@ -242,7 +242,7 @@ def test_external_mesh(cpp_driver): # Tallies tallies = openmc.Tallies() - uscd_tally = openmc.Tally(name="unstructured mesh tally") + uscd_tally = openmc.VolumeTally(name="unstructured mesh tally") uscd_tally.filters = [uscd_filter] uscd_tally.scores = ['flux'] uscd_tally.estimator = 'tracklength' diff --git a/tests/regression_tests/filter_cellfrom/test.py b/tests/regression_tests/filter_cellfrom/test.py index 5559b4c8171..5c3b4f7d27e 100644 --- a/tests/regression_tests/filter_cellfrom/test.py +++ b/tests/regression_tests/filter_cellfrom/test.py @@ -160,71 +160,71 @@ def model(): from_box1_filter = openmc.CellFromFilter([box1]) from_box2_filter = openmc.CellFromFilter([box2]) - t1_1 = openmc.Tally(name="total from 1 in 1") + t1_1 = openmc.VolumeTally(name="total from 1 in 1") t1_1.filters = [from_core_filter, in_core_filter] t1_1.scores = ["total"] - t1_2 = openmc.Tally(name="total from 1 in 2") + t1_2 = openmc.VolumeTally(name="total from 1 in 2") t1_2.filters = [from_core_filter, in_outside_core_filter] t1_2.scores = ["total"] - t1_3 = openmc.Tally(name="total from 1 in 3") + t1_3 = openmc.VolumeTally(name="total from 1 in 3") t1_3.filters = [from_core_filter, in_box1_filter] t1_3.scores = ["total"] - t1_4 = openmc.Tally(name="total from 1 in 4") + t1_4 = openmc.VolumeTally(name="total from 1 in 4") t1_4.filters = [from_core_filter, in_box2_filter] t1_4.scores = ["total"] - t2_1 = openmc.Tally(name="total from 2 in 1") + t2_1 = openmc.VolumeTally(name="total from 2 in 1") t2_1.filters = [from_outside_core_filter, in_core_filter] t2_1.scores = ["total"] - t2_2 = openmc.Tally(name="total from 2 in 2") + t2_2 = openmc.VolumeTally(name="total from 2 in 2") t2_2.filters = [from_outside_core_filter, in_outside_core_filter] t2_2.scores = ["total"] - t2_3 = openmc.Tally(name="total from 2 in 3") + t2_3 = openmc.VolumeTally(name="total from 2 in 3") t2_3.filters = [from_outside_core_filter, in_box1_filter] t2_3.scores = ["total"] - t2_4 = openmc.Tally(name="total from 2 in 4") + t2_4 = openmc.VolumeTally(name="total from 2 in 4") t2_4.filters = [from_outside_core_filter, in_box2_filter] t2_4.scores = ["total"] - t3_1 = openmc.Tally(name="total from 3 in 1") + t3_1 = openmc.VolumeTally(name="total from 3 in 1") t3_1.filters = [from_box1_filter, in_core_filter] t3_1.scores = ["total"] - t3_2 = openmc.Tally(name="total from 3 in 2") + t3_2 = openmc.VolumeTally(name="total from 3 in 2") t3_2.filters = [from_box1_filter, in_outside_core_filter] t3_2.scores = ["total"] - t3_3 = openmc.Tally(name="total from 3 in 3") + t3_3 = openmc.VolumeTally(name="total from 3 in 3") t3_3.filters = [from_box1_filter, in_box1_filter] t3_3.scores = ["total"] - t3_4 = openmc.Tally(name="total from 3 in 4") + t3_4 = openmc.VolumeTally(name="total from 3 in 4") t3_4.filters = [from_box1_filter, in_box2_filter] t3_4.scores = ["total"] - t4_1 = openmc.Tally(name="total from 4 in 1") + t4_1 = openmc.VolumeTally(name="total from 4 in 1") t4_1.filters = [from_box2_filter, in_core_filter] t4_1.scores = ["total"] - t4_2 = openmc.Tally(name="total from 4 in 2") + t4_2 = openmc.VolumeTally(name="total from 4 in 2") t4_2.filters = [from_box2_filter, in_outside_core_filter] t4_2.scores = ["total"] - t4_3 = openmc.Tally(name="total from 4 in 3") + t4_3 = openmc.VolumeTally(name="total from 4 in 3") t4_3.filters = [from_box2_filter, in_box1_filter] t4_3.scores = ["total"] - t4_4 = openmc.Tally(name="total from 4 in 4") + t4_4 = openmc.VolumeTally(name="total from 4 in 4") t4_4.filters = [from_box2_filter, in_box2_filter] t4_4.scores = ["total"] - tglobal = openmc.Tally(name="total") + tglobal = openmc.VolumeTally(name="total") tglobal.scores = ["total"] model.tallies += [ diff --git a/tests/regression_tests/filter_cellinstance/test.py b/tests/regression_tests/filter_cellinstance/test.py index 61f17d88a66..39c00b64a95 100644 --- a/tests/regression_tests/filter_cellinstance/test.py +++ b/tests/regression_tests/filter_cellinstance/test.py @@ -76,10 +76,10 @@ def model(): [(c3, i) for i in range(c3.num_instances)]) f1 = openmc.CellInstanceFilter(instances) f2 = openmc.CellInstanceFilter(instances[::-1]) - t1 = openmc.Tally() + t1 = openmc.VolumeTally() t1.filters = [f1] t1.scores = ['total'] - t2 = openmc.Tally() + t2 = openmc.VolumeTally() t2.filters = [f2] t2.scores = ['total'] model.tallies += [t1, t2] diff --git a/tests/regression_tests/filter_energyfun/test.py b/tests/regression_tests/filter_energyfun/test.py index 295b8ebd8ff..9dbf96229a4 100644 --- a/tests/regression_tests/filter_energyfun/test.py +++ b/tests/regression_tests/filter_energyfun/test.py @@ -66,7 +66,7 @@ def model(): filters = [filt1, filt3, filt4, filt5, filt6, filt7, filt8, filt9] # Make tallies - tallies = [openmc.Tally() for _ in range(len(filters) + 1)] + tallies = [openmc.VolumeTally() for _ in range(len(filters) + 1)] for t in tallies: t.scores = ['(n,gamma)'] t.nuclides = ['Am241'] @@ -166,4 +166,4 @@ def _compare_results(self): def test_filter_energyfun(model): harness = FilterEnergyFunHarness('statepoint.5.h5', model) - harness.main() \ No newline at end of file + harness.main() diff --git a/tests/regression_tests/filter_mesh/inputs_true.dat b/tests/regression_tests/filter_mesh/inputs_true.dat index 10f70a720f2..ec81068bcb9 100644 --- a/tests/regression_tests/filter_mesh/inputs_true.dat +++ b/tests/regression_tests/filter_mesh/inputs_true.dat @@ -103,49 +103,55 @@ 1 total - + 7 current + analog 2 total - + 8 current + analog 3 total - + 9 current + analog 4 total - + 10 current + analog 5 total - + 11 current + analog 6 total - + 12 current + analog diff --git a/tests/regression_tests/filter_mesh/test.py b/tests/regression_tests/filter_mesh/test.py index 165ba2a0c09..bf29b6ea504 100644 --- a/tests/regression_tests/filter_mesh/test.py +++ b/tests/regression_tests/filter_mesh/test.py @@ -105,11 +105,11 @@ def model(): # Create tallies for f1, f2 in zip(reg_filters, surf_filters): - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [f1] tally.scores = ['total'] model.tallies.append(tally) - tally = openmc.Tally() + tally = openmc.SurfaceTally() tally.filters = [f2] tally.scores = ['current'] model.tallies.append(tally) diff --git a/tests/regression_tests/filter_meshborn/test.py b/tests/regression_tests/filter_meshborn/test.py index ff4adbc9f04..db952c7c544 100644 --- a/tests/regression_tests/filter_meshborn/test.py +++ b/tests/regression_tests/filter_meshborn/test.py @@ -51,19 +51,19 @@ def model(): f_1 = openmc.MeshFilter(mesh) f_2 = openmc.MeshBornFilter(mesh) - t_1 = openmc.Tally(name="scatter") + t_1 = openmc.VolumeTally(name="scatter") t_1.filters = [f_1, f_2] t_1.scores = ["scatter"] - t_2 = openmc.Tally(name="scatter-mesh") + t_2 = openmc.VolumeTally(name="scatter-mesh") t_2.filters = [f_1] t_2.scores = ["scatter"] - t_3 = openmc.Tally(name="scatter-meshborn") + t_3 = openmc.VolumeTally(name="scatter-meshborn") t_3.filters = [f_2] t_3.scores = ["scatter"] - t_4 = openmc.Tally(name="scatter-total") + t_4 = openmc.VolumeTally(name="scatter-total") t_4.scores = ["scatter"] model.tallies = [t_1, t_2, t_3, t_4] diff --git a/tests/regression_tests/filter_musurface/inputs_true.dat b/tests/regression_tests/filter_musurface/inputs_true.dat index b457f5028ec..527ba7d19aa 100644 --- a/tests/regression_tests/filter_musurface/inputs_true.dat +++ b/tests/regression_tests/filter_musurface/inputs_true.dat @@ -29,9 +29,10 @@ -1.0 -0.5 0.0 0.5 1.0 - + 1 2 current flux + analog diff --git a/tests/regression_tests/filter_musurface/test.py b/tests/regression_tests/filter_musurface/test.py index bfc12a47cd5..4141b74a99e 100644 --- a/tests/regression_tests/filter_musurface/test.py +++ b/tests/regression_tests/filter_musurface/test.py @@ -27,7 +27,7 @@ def model(): # Create a tally for current through the first surface binned by mu surf_filter = openmc.SurfaceFilter([cyl1]) mu_filter = openmc.MuSurfaceFilter([-1.0, -0.5, 0.0, 0.5, 1.0]) - tally = openmc.Tally() + tally = openmc.SurfaceTally() tally.filters = [surf_filter, mu_filter] tally.scores = ['current', 'flux'] model.tallies.append(tally) diff --git a/tests/regression_tests/filter_reaction/test.py b/tests/regression_tests/filter_reaction/test.py index 3c60fd5173e..577d1d1a703 100644 --- a/tests/regression_tests/filter_reaction/test.py +++ b/tests/regression_tests/filter_reaction/test.py @@ -16,7 +16,7 @@ def test_filter_reaction(): model.geometry = openmc.Geometry([c]) # Create a tally with reaction filter - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [openmc.ReactionFilter( ['(n,elastic)', '(n,2n)', '(n,fission)', '(n,gamma)', 'total'] )] diff --git a/tests/regression_tests/filter_rotations/test.py b/tests/regression_tests/filter_rotations/test.py index f5d63d6b44c..676a7b4b6f6 100644 --- a/tests/regression_tests/filter_rotations/test.py +++ b/tests/regression_tests/filter_rotations/test.py @@ -59,7 +59,7 @@ def model(): # Create tallies for f in filters: - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [f] tally.scores = ['total'] model.tallies.append(tally) diff --git a/tests/regression_tests/filter_translations/test.py b/tests/regression_tests/filter_translations/test.py index 4f0fe7141bf..88fcb11c63e 100644 --- a/tests/regression_tests/filter_translations/test.py +++ b/tests/regression_tests/filter_translations/test.py @@ -77,7 +77,7 @@ def model(): # Create tallies for f in filters: - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [f] tally.scores = ['total'] model.tallies.append(tally) diff --git a/tests/regression_tests/fixed_source/test.py b/tests/regression_tests/fixed_source/test.py index b9ee2512536..953549549ac 100644 --- a/tests/regression_tests/fixed_source/test.py +++ b/tests/regression_tests/fixed_source/test.py @@ -51,7 +51,7 @@ def test_fixed_source(): model.settings.source = openmc.IndependentSource(space=openmc.stats.Point(), strength=10.0) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['flux'] model.tallies.append(tally) diff --git a/tests/regression_tests/ifp/total/test.py b/tests/regression_tests/ifp/total/test.py index 18b89cfc0b7..38ab7dce321 100644 --- a/tests/regression_tests/ifp/total/test.py +++ b/tests/regression_tests/ifp/total/test.py @@ -32,7 +32,7 @@ def ifp_model(): space=space, constraints={'fissionable': True}) # Tally IFP scores - tally = openmc.Tally(name="ifp-scores") + tally = openmc.VolumeTally(name="ifp-scores") tally.scores = ["ifp-time-numerator", "ifp-beta-numerator", "ifp-denominator"] model.tallies = [tally] diff --git a/tests/regression_tests/lattice_corner_crossing/test.py b/tests/regression_tests/lattice_corner_crossing/test.py index 4684d144e1e..a1db84e2df2 100644 --- a/tests/regression_tests/lattice_corner_crossing/test.py +++ b/tests/regression_tests/lattice_corner_crossing/test.py @@ -69,7 +69,7 @@ def model(): mesh.lower_left = (-lat_size, -lat_size) mesh.upper_right = (lat_size, lat_size) mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally(tally_id=1) + tally = openmc.VolumeTally(tally_id=1) tally.filters = [mesh_filter] tally.scores = ['flux'] tally.estimator = 'tracklength' diff --git a/tests/regression_tests/mg_tallies/test.py b/tests/regression_tests/mg_tallies/test.py index f4e9693f6f8..2de0e29fb75 100644 --- a/tests/regression_tests/mg_tallies/test.py +++ b/tests/regression_tests/mg_tallies/test.py @@ -87,7 +87,7 @@ def test_mg_tallies(): for do_nuclides, scores in ((False, scores_without_nuclides), (True, scores_with_nuclides)): - t = openmc.Tally() + t = openmc.VolumeTally() t.filters = [mesh_filter] t.estimator = 'analog' t.scores = scores @@ -95,7 +95,7 @@ def test_mg_tallies(): t.nuclides = nuclides model.tallies.append(t) - t = openmc.Tally() + t = openmc.VolumeTally() t.filters = [mesh_filter] t.estimator = 'tracklength' t.scores = scores @@ -113,7 +113,7 @@ def test_mg_tallies(): e_filter = energy_filter eout_filter = energyout_filter - t = openmc.Tally() + t = openmc.VolumeTally() t.filters = [mat_filter, e_filter] t.estimator = 'analog' t.scores = scores + ['scatter', 'nu-scatter'] @@ -121,7 +121,7 @@ def test_mg_tallies(): t.nuclides = nuclides model.tallies.append(t) - t = openmc.Tally() + t = openmc.VolumeTally() t.filters = [mat_filter, e_filter] t.estimator = 'collision' t.scores = scores @@ -129,7 +129,7 @@ def test_mg_tallies(): t.nuclides = nuclides model.tallies.append(t) - t = openmc.Tally() + t = openmc.VolumeTally() t.filters = [mat_filter, e_filter] t.estimator = 'tracklength' t.scores = scores @@ -137,7 +137,7 @@ def test_mg_tallies(): t.nuclides = nuclides model.tallies.append(t) - t = openmc.Tally() + t = openmc.VolumeTally() t.filters = [mat_filter, e_filter, eout_filter] t.scores = ['scatter', 'nu-scatter', 'nu-fission'] if do_nuclides: diff --git a/tests/regression_tests/mg_temperature_multi/test.py b/tests/regression_tests/mg_temperature_multi/test.py index 3117e29ba03..1c2f3ca8f4a 100755 --- a/tests/regression_tests/mg_temperature_multi/test.py +++ b/tests/regression_tests/mg_temperature_multi/test.py @@ -147,12 +147,12 @@ def test_mg_temperature_multi(): outer_filter = openmc.CellFilter(fuel_outer) energy_filter = openmc.EnergyFilter(egroups) - inner_tally = openmc.Tally(name="inner tally") + inner_tally = openmc.VolumeTally(name="inner tally") inner_tally.filters = [energy_filter] inner_tally.filters = [inner_filter] inner_tally.scores = ['flux'] - outer_tally = openmc.Tally(name="outer tally") + outer_tally = openmc.VolumeTally(name="outer tally") outer_tally.filters = [energy_filter] outer_tally.filters = [outer_filter] outer_tally.scores = ['flux'] diff --git a/tests/regression_tests/mgxs_library_condense/inputs_true.dat b/tests/regression_tests/mgxs_library_condense/inputs_true.dat index 4451d214c47..8b252db9061 100644 --- a/tests/regression_tests/mgxs_library_condense/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_condense/inputs_true.dat @@ -416,7 +416,7 @@ prompt-nu-fission analog - + 68 2 total current diff --git a/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat b/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat index 4451d214c47..8b252db9061 100644 --- a/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_hdf5/inputs_true.dat @@ -416,7 +416,7 @@ prompt-nu-fission analog - + 68 2 total current diff --git a/tests/regression_tests/mgxs_library_mesh/inputs_true.dat b/tests/regression_tests/mgxs_library_mesh/inputs_true.dat index 5a6e8a20a95..423957bdcd7 100644 --- a/tests/regression_tests/mgxs_library_mesh/inputs_true.dat +++ b/tests/regression_tests/mgxs_library_mesh/inputs_true.dat @@ -393,7 +393,7 @@ prompt-nu-fission analog - + 68 2 total current diff --git a/tests/regression_tests/model_xml/photon_production_inputs_true.dat b/tests/regression_tests/model_xml/photon_production_inputs_true.dat index 0ae0079f412..a919f82f83c 100644 --- a/tests/regression_tests/model_xml/photon_production_inputs_true.dat +++ b/tests/regression_tests/model_xml/photon_production_inputs_true.dat @@ -51,9 +51,10 @@ neutron photon 0.0 100000.0 300000.0 500000.0 2000000.0 20000000.0 - + 1 2 current + analog 2 diff --git a/tests/regression_tests/multipole/test.py b/tests/regression_tests/multipole/test.py index 2f7369a9db5..636757a6efd 100644 --- a/tests/regression_tests/multipole/test.py +++ b/tests/regression_tests/multipole/test.py @@ -58,7 +58,7 @@ def make_model(): model.settings.temperature = {'tolerance': 1000, 'multipole': True} # Tallies - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.nuclides = ['U235', 'O16', 'total'] tally.scores = ['total', 'fission', '(n,gamma)', 'elastic', '(n,p)'] model.tallies.append(tally) diff --git a/tests/regression_tests/ncrystal/inputs_true.dat b/tests/regression_tests/ncrystal/inputs_true.dat index 81ee2e312c5..95dbdb2933d 100644 --- a/tests/regression_tests/ncrystal/inputs_true.dat +++ b/tests/regression_tests/ncrystal/inputs_true.dat @@ -36,9 +36,10 @@ 1 - + 1 2 3 current + analog diff --git a/tests/regression_tests/ncrystal/test.py b/tests/regression_tests/ncrystal/test.py index 8da05e1cfd7..efacc49d980 100644 --- a/tests/regression_tests/ncrystal/test.py +++ b/tests/regression_tests/ncrystal/test.py @@ -51,7 +51,7 @@ def pencil_beam_model(cfg, E0, N): # Tally definition - tally1 = openmc.Tally(name="angular distribution") + tally1 = openmc.SurfaceTally(name="angular distribution") tally1.scores = ["current"] filter1 = openmc.SurfaceFilter(sample_sphere) filter2 = openmc.PolarFilter(np.linspace(0, pi, 180+1)) diff --git a/tests/regression_tests/photon_production/inputs_true.dat b/tests/regression_tests/photon_production/inputs_true.dat index 0ae0079f412..a919f82f83c 100644 --- a/tests/regression_tests/photon_production/inputs_true.dat +++ b/tests/regression_tests/photon_production/inputs_true.dat @@ -51,9 +51,10 @@ neutron photon 0.0 100000.0 300000.0 500000.0 2000000.0 20000000.0 - + 1 2 current + analog 2 diff --git a/tests/regression_tests/photon_production/test.py b/tests/regression_tests/photon_production/test.py index 5ed5c5ecf02..3abb3d139ad 100644 --- a/tests/regression_tests/photon_production/test.py +++ b/tests/regression_tests/photon_production/test.py @@ -45,21 +45,21 @@ def model(): surface_filter = openmc.SurfaceFilter(cyl) particle_filter = openmc.ParticleFilter( ['neutron', 'photon', 'electron', 'positron']) - current_tally = openmc.Tally() + current_tally = openmc.SurfaceTally() current_tally.filters = [surface_filter, particle_filter] current_tally.scores = ['current'] - tally_tracklength = openmc.Tally() + tally_tracklength = openmc.VolumeTally() tally_tracklength.filters = [particle_filter] # heating doesn't work with tracklength tally_tracklength.scores = ['total', '(n,gamma)'] tally_tracklength.nuclides = ['Al27', 'total'] tally_tracklength.estimator = 'tracklength' - tally_collision = openmc.Tally() + tally_collision = openmc.VolumeTally() tally_collision.filters = [particle_filter] tally_collision.scores = ['total', 'heating', '(n,gamma)'] tally_collision.nuclides = ['Al27', 'total'] tally_collision.estimator = 'collision' - tally_analog = openmc.Tally() + tally_analog = openmc.VolumeTally() tally_analog.filters = [particle_filter] tally_analog.scores = ['total', 'heating', '(n,gamma)'] tally_analog.nuclides = ['Al27', 'total'] @@ -75,7 +75,7 @@ def model(): ['neutron', 'photon'], [0.0, 100e3, 300e3, 500e3, 2e6, 20e6]) neutron_only = openmc.ParticleFilter(['neutron']) - tally_gam_ene = openmc.Tally() + tally_gam_ene = openmc.VolumeTally() tally_gam_ene.filters = [neutron_only, ene_filter, ene2_filter] tally_gam_ene.scores = ['events'] tally_gam_ene.estimator = 'analog' diff --git a/tests/regression_tests/photon_production_fission/test.py b/tests/regression_tests/photon_production_fission/test.py index 96665b30867..99092e66db8 100644 --- a/tests/regression_tests/photon_production_fission/test.py +++ b/tests/regression_tests/photon_production_fission/test.py @@ -23,17 +23,17 @@ def model(): model.settings.source = openmc.IndependentSource(space=openmc.stats.Point((0, 0, 0))) particle_filter = openmc.ParticleFilter(['neutron', 'photon']) - tally_tracklength = openmc.Tally() + tally_tracklength = openmc.VolumeTally() tally_tracklength.filters = [particle_filter] tally_tracklength.scores = ['fission', 'heating-local'] tally_tracklength.nuclides = ['U235', 'total'] tally_tracklength.estimator = 'tracklength' - tally_collision = openmc.Tally() + tally_collision = openmc.VolumeTally() tally_collision.filters = [particle_filter] tally_collision.scores = ['fission', 'heating', 'heating-local'] tally_collision.nuclides = ['U235', 'total'] tally_collision.estimator = 'collision' - tally_analog = openmc.Tally() + tally_analog = openmc.VolumeTally() tally_analog.filters = [particle_filter] tally_analog.scores = ['fission', 'heating', 'heating-local'] tally_analog.nuclides = ['U235', 'total'] diff --git a/tests/regression_tests/photon_source/test.py b/tests/regression_tests/photon_source/test.py index c2eb1476de2..9ed17113524 100644 --- a/tests/regression_tests/photon_source/test.py +++ b/tests/regression_tests/photon_source/test.py @@ -38,7 +38,7 @@ def __init__(self, *args, **kwargs): self._model.settings = settings particle_filter = openmc.ParticleFilter('photon') - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [particle_filter] tally.scores = ['flux', '(n,gamma)'] tallies = openmc.Tallies([tally]) diff --git a/tests/regression_tests/pulse_height/inputs_true.dat b/tests/regression_tests/pulse_height/inputs_true.dat index 590928e4355..b5c232e6231 100644 --- a/tests/regression_tests/pulse_height/inputs_true.dat +++ b/tests/regression_tests/pulse_height/inputs_true.dat @@ -34,9 +34,10 @@ 0.0 10000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 110000.0 120000.0 130000.0 140000.0 150000.0 160000.0 170000.0 180000.0 190000.0 200000.0 210000.0 220000.0 230000.0 240000.0 250000.0 260000.0 270000.0 280000.0 290000.0 300000.0 310000.0 320000.0 330000.0 340000.0 350000.0 360000.0 370000.0 380000.0 390000.0 400000.0 410000.0 420000.0 430000.0 440000.0 450000.0 460000.0 470000.0 480000.0 490000.0 500000.0 510000.0 520000.0 530000.0 540000.0 550000.0 560000.0 570000.0 580000.0 590000.0 600000.0 610000.0 620000.0 630000.0 640000.0 650000.0 660000.0 670000.0 680000.0 690000.0 700000.0 710000.0 720000.0 730000.0 740000.0 750000.0 760000.0 770000.0 780000.0 790000.0 800000.0 810000.0 820000.0 830000.0 840000.0 850000.0 860000.0 870000.0 880000.0 890000.0 900000.0 910000.0 920000.0 930000.0 940000.0 950000.0 960000.0 970000.0 980000.0 990000.0 1000000.0 - + 1 2 pulse-height + collision diff --git a/tests/regression_tests/pulse_height/test.py b/tests/regression_tests/pulse_height/test.py index 90d960f6640..3462c4119ac 100644 --- a/tests/regression_tests/pulse_height/test.py +++ b/tests/regression_tests/pulse_height/test.py @@ -37,8 +37,7 @@ def sphere_model(): ) # Define tallies - tally = openmc.Tally(name="pht tally") - tally.scores = ['pulse-height'] + tally = openmc.PulseHeightTally(name="pht tally") cell_filter = openmc.CellFilter(inner_sphere) energy_filter = openmc.EnergyFilter(np.linspace(0, 1_000_000, 101)) tally.filters = [cell_filter, energy_filter] diff --git a/tests/regression_tests/random_ray_adjoint_k_eff/results_true.dat b/tests/regression_tests/random_ray_adjoint_k_eff/results_true.dat index dfef53cd2f9..429067b2212 100644 --- a/tests/regression_tests/random_ray_adjoint_k_eff/results_true.dat +++ b/tests/regression_tests/random_ray_adjoint_k_eff/results_true.dat @@ -79,7 +79,7 @@ tally 1: 0.000000E+00 0.000000E+00 0.000000E+00 -9.248400E-01 +9.248399E-01 1.710699E-01 0.000000E+00 0.000000E+00 @@ -148,7 +148,7 @@ tally 1: 9.272977E-01 1.721077E-01 3.161443E-02 -2.000179E-04 +2.000180E-04 2.002789E-07 8.027290E-15 8.778794E-01 diff --git a/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py b/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py index 6decf165a7f..2c32413a9f2 100644 --- a/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py +++ b/tests/regression_tests/random_ray_auto_convert_kappa_fission/test.py @@ -51,7 +51,7 @@ def test_random_ray_auto_convert(method): model.settings.random_ray['source_shape'] = 'linear' # Set a material tally - t = openmc.Tally(name = 'KF Tally') + t = openmc.VolumeTally(name = 'KF Tally') t.filters = [openmc.MaterialFilter(bins=1)] t.scores = ['kappa-fission'] model.tallies.append(t) diff --git a/tests/regression_tests/random_ray_halton_samples/results_true.dat b/tests/regression_tests/random_ray_halton_samples/results_true.dat index 256f8a744a3..5f39ebaeb19 100644 --- a/tests/regression_tests/random_ray_halton_samples/results_true.dat +++ b/tests/regression_tests/random_ray_halton_samples/results_true.dat @@ -24,7 +24,7 @@ tally 1: 1.707007E-02 5.933921E-05 4.154514E-02 -3.514889E-04 +3.514888E-04 1.513147E+00 4.652938E-01 1.810962E-02 @@ -34,7 +34,7 @@ tally 1: 4.347893E+00 3.798064E+00 6.851785E-03 -9.430195E-06 +9.430194E-06 1.695426E-02 5.773923E-05 2.809071E+00 @@ -152,7 +152,7 @@ tally 1: 4.036663E-02 3.323832E-04 1.516801E+00 -4.675245E-01 +4.675244E-01 1.752096E-02 6.241641E-05 4.264304E-02 diff --git a/tests/regression_tests/random_ray_k_eff/results_true.dat b/tests/regression_tests/random_ray_k_eff/results_true.dat index ace18df8cce..4e0c31988d7 100644 --- a/tests/regression_tests/random_ray_k_eff/results_true.dat +++ b/tests/regression_tests/random_ray_k_eff/results_true.dat @@ -1,5 +1,5 @@ k-combined: -8.400321E-01 8.023357E-03 +8.400321E-01 8.023358E-03 tally 1: 1.075769E+00 2.317354E-01 @@ -28,7 +28,7 @@ tally 1: 1.509054E+00 4.629325E-01 1.749679E-02 -6.226587E-05 +6.226588E-05 4.258421E-02 3.688336E-04 4.322054E+00 @@ -131,7 +131,7 @@ tally 1: 2.304093E-01 4.053505E-01 3.291277E-02 -9.865420E-01 +9.865421E-01 1.949549E-01 6.047420E-01 7.327008E-02 diff --git a/tests/regression_tests/random_ray_k_eff_mesh/results_true.dat b/tests/regression_tests/random_ray_k_eff_mesh/results_true.dat index 2ae8fad85fb..2976d169b63 100644 --- a/tests/regression_tests/random_ray_k_eff_mesh/results_true.dat +++ b/tests/regression_tests/random_ray_k_eff_mesh/results_true.dat @@ -1,5 +1,5 @@ k-combined: -8.379203E-01 8.057199E-03 +8.379203E-01 8.057198E-03 tally 1: 1.073897E+00 2.309328E-01 diff --git a/tests/regression_tests/random_ray_linear/linear_xy/results_true.dat b/tests/regression_tests/random_ray_linear/linear_xy/results_true.dat index 052608b4254..e00538f64c6 100644 --- a/tests/regression_tests/random_ray_linear/linear_xy/results_true.dat +++ b/tests/regression_tests/random_ray_linear/linear_xy/results_true.dat @@ -90,7 +90,7 @@ tally 1: 1.746692E+00 1.536860E-01 4.251098E+00 -9.103405E-01 +9.103406E-01 3.651202E+00 6.682179E-01 5.431675E-01 diff --git a/tests/regression_tests/random_ray_s2/test.py b/tests/regression_tests/random_ray_s2/test.py index 712d9c12411..de19157a74b 100644 --- a/tests/regression_tests/random_ray_s2/test.py +++ b/tests/regression_tests/random_ray_s2/test.py @@ -52,7 +52,7 @@ def test_random_ray_s2(): mesh.lower_left = (0.0, -5.0, -5.0) mesh.upper_right = (L, 5.0, 5.0) - tally = openmc.Tally(name="LR") + tally = openmc.VolumeTally(name="LR") tally.filters = [openmc.MeshFilter(mesh)] tally.scores = ['flux'] tally.estimator = 'tracklength' diff --git a/tests/regression_tests/random_ray_void/test.py b/tests/regression_tests/random_ray_void/test.py index b48a7794d7e..213a3789642 100644 --- a/tests/regression_tests/random_ray_void/test.py +++ b/tests/regression_tests/random_ray_void/test.py @@ -48,19 +48,19 @@ def test_random_ray_void(shape): # filters instead of material ones estimator = 'tracklength' absorber_filter = openmc.CellFilter(absorber_cell) - absorber_tally = openmc.Tally(name="Absorber Tally") + absorber_tally = openmc.VolumeTally(name="Absorber Tally") absorber_tally.filters = [absorber_filter] absorber_tally.scores = ['flux'] absorber_tally.estimator = estimator void_filter = openmc.CellFilter(void_cell) - void_tally = openmc.Tally(name="Void Tally") + void_tally = openmc.VolumeTally(name="Void Tally") void_tally.filters = [void_filter] void_tally.scores = ['flux'] void_tally.estimator = estimator source_filter = openmc.CellFilter(source_cell) - source_tally = openmc.Tally(name="Source Tally") + source_tally = openmc.VolumeTally(name="Source Tally") source_tally.filters = [source_filter] source_tally.scores = ['flux'] source_tally.estimator = estimator diff --git a/tests/regression_tests/score_current/inputs_true.dat b/tests/regression_tests/score_current/inputs_true.dat index 42c2d3df2e6..70684f3134d 100644 --- a/tests/regression_tests/score_current/inputs_true.dat +++ b/tests/regression_tests/score_current/inputs_true.dat @@ -42,13 +42,15 @@ 0.0 0.253 20000000.0 - + 1 current + analog - + 1 2 current + analog diff --git a/tests/regression_tests/score_current/test.py b/tests/regression_tests/score_current/test.py index a338a662669..92dc59f4e57 100644 --- a/tests/regression_tests/score_current/test.py +++ b/tests/regression_tests/score_current/test.py @@ -37,10 +37,10 @@ def model(): mesh_surface_filter = openmc.MeshSurfaceFilter(mesh) energy_filter = openmc.EnergyFilter([0.0, 0.253, 20.0e6]) - tally1 = openmc.Tally() + tally1 = openmc.SurfaceTally() tally1.filters = [mesh_surface_filter] tally1.scores = ['current'] - tally2 = openmc.Tally() + tally2 = openmc.SurfaceTally() tally2.filters = [mesh_surface_filter, energy_filter] tally2.scores = ['current'] model.tallies.extend([tally1, tally2]) diff --git a/tests/regression_tests/source_dlopen/test.py b/tests/regression_tests/source_dlopen/test.py index 0581d6deec4..ae10a29b8e0 100644 --- a/tests/regression_tests/source_dlopen/test.py +++ b/tests/regression_tests/source_dlopen/test.py @@ -61,7 +61,7 @@ def model(): model.settings.particles = 1000 model.settings.run_mode = 'fixed source' - tally = openmc.Tally() + tally = openmc.VolumeTally() mat_filter = openmc.MaterialFilter([natural_lead]) # energy filter with two bins 0 eV - 1 keV and 1 keV - 1 MeV the second bin # of the energy filter (last two entries in the tally results) should be diff --git a/tests/regression_tests/source_parameterized_dlopen/test.py b/tests/regression_tests/source_parameterized_dlopen/test.py index 151fb37356e..a8d4930fa25 100644 --- a/tests/regression_tests/source_parameterized_dlopen/test.py +++ b/tests/regression_tests/source_parameterized_dlopen/test.py @@ -61,7 +61,7 @@ def model(): model.settings.particles = 1000 model.settings.run_mode = 'fixed source' - tally = openmc.Tally() + tally = openmc.VolumeTally() mat_filter = openmc.MaterialFilter([natural_lead]) # energy filter with two bins 0 eV - 1 keV and 1 keV - 1 MeV # the second bin shouldn't have any results diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 13966b26d98..7bcf7c6f153 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -87,7 +87,7 @@ def model(request): openmc_model.settings.surf_source_read = {'path': f"surface_source_true.{file_format}"} # Tallies - tal = openmc.Tally() + tal = openmc.VolumeTally() cell_filter = openmc.CellFilter(cell_3) tal.filters = [cell_filter] tal.scores = ['flux'] diff --git a/tests/regression_tests/surface_tally/inputs_true.dat b/tests/regression_tests/surface_tally/inputs_true.dat index 2b070c5a3fd..bed2f4eee66 100644 --- a/tests/regression_tests/surface_tally/inputs_true.dat +++ b/tests/regression_tests/surface_tally/inputs_true.dat @@ -69,37 +69,45 @@ 3 - + 5 6 1 2 3 current + analog - + 5 4 1 2 3 current + analog - + 7 8 1 2 3 current + analog - + 7 4 1 2 3 current + analog - + 4 1 2 3 current + analog - + 10 1 2 3 current + analog - + 11 1 current + analog - + 11 1 current + analog diff --git a/tests/regression_tests/surface_tally/test.py b/tests/regression_tests/surface_tally/test.py index aa03a8aa2d7..ab49f7155a8 100644 --- a/tests/regression_tests/surface_tally/test.py +++ b/tests/regression_tests/surface_tally/test.py @@ -91,14 +91,14 @@ def __init__(self, *args, **kwargs): cell_filter = openmc.CellFilter(water) # Use Cell to cell filters for partial current - cell_to_cell_tally = openmc.Tally(name=str('fuel_to_water_1')) + cell_to_cell_tally = openmc.SurfaceTally(name=str('fuel_to_water_1')) cell_to_cell_tally.filters = [cell_from_filter, cell_filter, \ energy_filter, polar_filter, azimuthal_filter] cell_to_cell_tally.scores = ['current'] tallies_file.append(cell_to_cell_tally) # Use a Cell from + surface filters for partial current - cell_to_cell_tally = openmc.Tally(name=str('fuel_to_water_2')) + cell_to_cell_tally = openmc.SurfaceTally(name=str('fuel_to_water_2')) cell_to_cell_tally.filters = [cell_from_filter, surface_filter, \ energy_filter, polar_filter, azimuthal_filter] cell_to_cell_tally.scores = ['current'] @@ -110,14 +110,14 @@ def __init__(self, *args, **kwargs): cell_filter = openmc.CellFilter(fuel) # Cell to cell filters for partial current - cell_to_cell_tally = openmc.Tally(name=str('water_to_fuel_1')) + cell_to_cell_tally = openmc.SurfaceTally(name=str('water_to_fuel_1')) cell_to_cell_tally.filters = [mat_from_filter, cell_filter, \ energy_filter, polar_filter, azimuthal_filter] cell_to_cell_tally.scores = ['current'] tallies_file.append(cell_to_cell_tally) # Cell from + surface filters for partial current - cell_to_cell_tally = openmc.Tally(name=str('water_to_fuel_2')) + cell_to_cell_tally = openmc.SurfaceTally(name=str('water_to_fuel_2')) cell_to_cell_tally.filters = [mat_from_filter, surface_filter, \ energy_filter, polar_filter, azimuthal_filter] cell_to_cell_tally.scores = ['current'] @@ -125,7 +125,7 @@ def __init__(self, *args, **kwargs): # Create a net current tally on inner surface using a surface filter surface_filter = openmc.SurfaceFilter([1]) - surf_tally1 = openmc.Tally(name='net_cylinder') + surf_tally1 = openmc.SurfaceTally(name='net_cylinder') surf_tally1.filters = [surface_filter, energy_filter, polar_filter, \ azimuthal_filter] surf_tally1.scores = ['current'] @@ -134,7 +134,7 @@ def __init__(self, *args, **kwargs): # Create a net current tally on left surface using a surface filter # This surface has a vacuum boundary condition, so leakage is tallied surface_filter = openmc.SurfaceFilter([2]) - surf_tally2 = openmc.Tally(name='leakage_left') + surf_tally2 = openmc.SurfaceTally(name='leakage_left') surf_tally2.filters = [surface_filter, energy_filter, polar_filter, \ azimuthal_filter] surf_tally2.scores = ['current'] @@ -144,13 +144,13 @@ def __init__(self, *args, **kwargs): # This surface has a reflective boundary condition, so the net current # should be zero. surface_filter = openmc.SurfaceFilter([3]) - surf_tally3 = openmc.Tally(name='net_right') + surf_tally3 = openmc.SurfaceTally(name='net_right') surf_tally3.filters = [surface_filter, energy_filter] surf_tally3.scores = ['current'] tallies_file.append(surf_tally3) surface_filter = openmc.SurfaceFilter([3]) - surf_tally3 = openmc.Tally(name='net_right') + surf_tally3 = openmc.SurfaceTally(name='net_right') surf_tally3.filters = [surface_filter, energy_filter] surf_tally3.scores = ['current'] tallies_file.append(surf_tally3) diff --git a/tests/regression_tests/tallies/test.py b/tests/regression_tests/tallies/test.py index d20067ed33f..7c925f3ac35 100644 --- a/tests/regression_tests/tallies/test.py +++ b/tests/regression_tests/tallies/test.py @@ -1,6 +1,6 @@ from openmc.filter import * from openmc.filter_expansion import * -from openmc import RegularMesh, Tally +from openmc import RegularMesh, VolumeTally from tests.testing_harness import HashedPyAPITestHarness @@ -18,12 +18,12 @@ def test_tallies(): azimuthal_bins = (-3.14159, -1.8850, -0.6283, 0.6283, 1.8850, 3.14159) azimuthal_filter = AzimuthalFilter(azimuthal_bins) - azimuthal_tally1 = Tally() + azimuthal_tally1 = VolumeTally() azimuthal_tally1.filters = [azimuthal_filter] azimuthal_tally1.scores = ['flux'] azimuthal_tally1.estimator = 'tracklength' - azimuthal_tally2 = Tally() + azimuthal_tally2 = VolumeTally() azimuthal_tally2.filters = [azimuthal_filter] azimuthal_tally2.scores = ['flux'] azimuthal_tally2.estimator = 'analog' @@ -33,39 +33,39 @@ def test_tallies(): mesh_2x2.upper_right = [182.07, 182.07] mesh_2x2.dimension = [2, 2] mesh_filter = MeshFilter(mesh_2x2) - azimuthal_tally3 = Tally() + azimuthal_tally3 = VolumeTally() azimuthal_tally3.filters = [azimuthal_filter, mesh_filter] azimuthal_tally3.scores = ['flux'] azimuthal_tally3.estimator = 'tracklength' - cellborn_tally = Tally() + cellborn_tally = VolumeTally() cellborn_tally.filters = [ CellBornFilter((model.geometry.get_all_cells()[10], model.geometry.get_all_cells()[21], 22, 23))] # Test both Cell objects and ids cellborn_tally.scores = ['total'] - dg_tally = Tally() + dg_tally = VolumeTally() dg_tally.filters = [DelayedGroupFilter((1, 2, 3, 4, 5, 6))] dg_tally.scores = ['delayed-nu-fission', 'decay-rate'] dg_tally.nuclides = ['U235', 'O16', 'total'] four_groups = (0.0, 0.253, 1.0e3, 1.0e6, 20.0e6) energy_filter = EnergyFilter(four_groups) - energy_tally = Tally() + energy_tally = VolumeTally() energy_tally.filters = [energy_filter] energy_tally.scores = ['total'] energyout_filter = EnergyoutFilter(four_groups) - energyout_tally = Tally() + energyout_tally = VolumeTally() energyout_tally.filters = [energyout_filter] energyout_tally.scores = ['scatter'] - transfer_tally = Tally() + transfer_tally = VolumeTally() transfer_tally.filters = [energy_filter, energyout_filter] transfer_tally.scores = ['scatter', 'nu-fission'] - material_tally = Tally() + material_tally = VolumeTally() material_tally.filters = [ MaterialFilter((model.geometry.get_materials_by_name('UOX fuel')[0], model.geometry.get_materials_by_name('Zircaloy')[0], @@ -74,54 +74,54 @@ def test_tallies(): mu_bins = (-1.0, -0.5, 0.0, 0.5, 1.0) mu_filter = MuFilter(mu_bins) - mu_tally1 = Tally() + mu_tally1 = VolumeTally() mu_tally1.filters = [mu_filter] mu_tally1.scores = ['scatter', 'nu-scatter'] - mu_tally2 = Tally() + mu_tally2 = VolumeTally() mu_tally2.filters = [mu_filter, mesh_filter] mu_tally2.scores = ['scatter', 'nu-scatter'] polar_bins = (0.0, 0.6283, 1.2566, 1.8850, 2.5132, 3.14159) polar_filter = PolarFilter(polar_bins) - polar_tally1 = Tally() + polar_tally1 = VolumeTally() polar_tally1.filters = [polar_filter] polar_tally1.scores = ['flux'] polar_tally1.estimator = 'tracklength' - polar_tally2 = Tally() + polar_tally2 = VolumeTally() polar_tally2.filters = [polar_filter] polar_tally2.scores = ['flux'] polar_tally2.estimator = 'analog' - polar_tally3 = Tally() + polar_tally3 = VolumeTally() polar_tally3.filters = [polar_filter, mesh_filter] polar_tally3.scores = ['flux'] polar_tally3.estimator = 'tracklength' legendre_filter = LegendreFilter(order=4) - legendre_tally = Tally() + legendre_tally = VolumeTally() legendre_tally.filters = [legendre_filter] legendre_tally.scores = ['scatter', 'nu-scatter'] legendre_tally.estimator = 'analog' harmonics_filter = SphericalHarmonicsFilter(order=4) - harmonics_tally = Tally() + harmonics_tally = VolumeTally() harmonics_tally.filters = [harmonics_filter] harmonics_tally.scores = ['scatter', 'nu-scatter', 'flux', 'total'] harmonics_tally.estimator = 'analog' - harmonics_tally2 = Tally() + harmonics_tally2 = VolumeTally() harmonics_tally2.filters = [harmonics_filter] harmonics_tally2.scores = ['flux', 'total'] harmonics_tally2.estimator = 'collision' - harmonics_tally3 = Tally() + harmonics_tally3 = VolumeTally() harmonics_tally3.filters = [harmonics_filter] harmonics_tally3.scores = ['flux', 'total'] harmonics_tally3.estimator = 'tracklength' - universe_tally = Tally() + universe_tally = VolumeTally() universe_tally.filters = [ UniverseFilter((model.geometry.get_all_universes()[1], model.geometry.get_all_universes()[2], @@ -131,7 +131,7 @@ def test_tallies(): cell_filter = CellFilter((model.geometry.get_all_cells()[10], model.geometry.get_all_cells()[21], 22, 23, 60)) # Test both Cell objects and ids - score_tallies = [Tally() for i in range(6)] + score_tallies = [VolumeTally() for i in range(6)] for t in score_tallies: t.filters = [cell_filter] t.scores = ['absorption', 'delayed-nu-fission', 'events', 'fission', @@ -146,7 +146,7 @@ def test_tallies(): t.nuclides = ['U235', 'O16', 'total'] cell_filter2 = CellFilter((21, 22, 23, 27, 28, 29, 60)) - flux_tallies = [Tally() for i in range(3)] + flux_tallies = [VolumeTally() for i in range(3)] for t in flux_tallies: t.filters = [cell_filter2] t.scores = ['flux'] @@ -154,13 +154,13 @@ def test_tallies(): flux_tallies[1].estimator = 'analog' flux_tallies[2].estimator = 'collision' - fusion_tally = Tally() + fusion_tally = VolumeTally() fusion_tally.scores = ['H1-production', 'H2-production', 'H3-production', 'He3-production', 'He4-production', 'heating', 'damage-energy'] n_collision = (1, 2, 5, 3, 6) collision_filter = CollisionFilter(n_collision) - collision_tally = Tally() + collision_tally = VolumeTally() collision_tally.filters = [collision_filter] collision_tally.scores = ['scatter'] diff --git a/tests/regression_tests/tally_aggregation/test.py b/tests/regression_tests/tally_aggregation/test.py index 08d91166064..6e70940a234 100644 --- a/tests/regression_tests/tally_aggregation/test.py +++ b/tests/regression_tests/tally_aggregation/test.py @@ -43,7 +43,7 @@ def model(): energy_filter = openmc.EnergyFilter([0.0, 0.253, 1.0e3, 1.0e6, 20.0e6]) distrib_filter = openmc.DistribcellFilter(pin.cells[1]) - tally = openmc.Tally(name='distribcell tally') + tally = openmc.VolumeTally(name='distribcell tally') tally.filters = [energy_filter, distrib_filter] tally.scores = ['nu-fission', 'total'] tally.nuclides = ['U234', 'U235', 'U238'] diff --git a/tests/regression_tests/tally_arithmetic/test.py b/tests/regression_tests/tally_arithmetic/test.py index 532160a17ee..c64cc550cd9 100644 --- a/tests/regression_tests/tally_arithmetic/test.py +++ b/tests/regression_tests/tally_arithmetic/test.py @@ -41,12 +41,12 @@ def model(): material_filter = openmc.MaterialFilter((fuel, water)) mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally(name='tally 1') + tally = openmc.VolumeTally(name='tally 1') tally.filters = [material_filter, energy_filter] tally.scores = ['nu-fission', 'total'] tally.nuclides = ['U234', 'U235'] model.tallies.append(tally) - tally = openmc.Tally(name='tally 2') + tally = openmc.VolumeTally(name='tally 2') tally.filters = [energy_filter, mesh_filter] tally.scores = ['total', 'fission'] tally.nuclides = ['U238', 'U235'] diff --git a/tests/regression_tests/tally_slice_merge/test.py b/tests/regression_tests/tally_slice_merge/test.py index aec73979b91..3520bb273cb 100644 --- a/tests/regression_tests/tally_slice_merge/test.py +++ b/tests/regression_tests/tally_slice_merge/test.py @@ -39,7 +39,7 @@ def __init__(self, *args, **kwargs): for cell_filter in self.cell_filters: for nuclide in self.nuclides: for score in self.scores: - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.estimator = 'tracklength' tally.scores.append(score) tally.nuclides.append(nuclide) @@ -57,7 +57,7 @@ def __init__(self, *args, **kwargs): tallies[0].name = 'cell tally' # Initialize a distribcell tally - distribcell_tally = openmc.Tally(name='distribcell tally') + distribcell_tally = openmc.VolumeTally(name='distribcell tally') distribcell_tally.estimator = 'tracklength' distribcell_tally.filters = [distribcell_filter, merged_energies] for score in self.scores: @@ -65,7 +65,7 @@ def __init__(self, *args, **kwargs): for nuclide in self.nuclides: distribcell_tally.nuclides.append(nuclide) - mesh_tally = openmc.Tally(name='mesh tally') + mesh_tally = openmc.VolumeTally(name='mesh tally') mesh_tally.estimator = 'tracklength' mesh_tally.filters = [mesh_filter, merged_energies] mesh_tally.scores = self.scores diff --git a/tests/regression_tests/time_cutoff/test.py b/tests/regression_tests/time_cutoff/test.py index 9554a6e2a00..82e27d84d39 100755 --- a/tests/regression_tests/time_cutoff/test.py +++ b/tests/regression_tests/time_cutoff/test.py @@ -27,7 +27,7 @@ def time_model(): # Tally flux under time cutoff tallies = openmc.Tallies() - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['flux'] time_filter = openmc.TimeFilter([0, time_cutoff, 2*time_cutoff]) tally.filters = [time_filter] diff --git a/tests/regression_tests/torus/large_major/test.py b/tests/regression_tests/torus/large_major/test.py index 1ce1ab2cac8..8157f534cf8 100644 --- a/tests/regression_tests/torus/large_major/test.py +++ b/tests/regression_tests/torus/large_major/test.py @@ -30,7 +30,7 @@ def model(): model.settings.batches = 10 model.settings.source = openmc.IndependentSource(space=openmc.stats.Point((-R, 0, 0,))) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['flux'] model.tallies.append(tally) return model diff --git a/tests/regression_tests/trigger_statepoint_restart/test.py b/tests/regression_tests/trigger_statepoint_restart/test.py index b242f7f1cff..b48d0ab7752 100644 --- a/tests/regression_tests/trigger_statepoint_restart/test.py +++ b/tests/regression_tests/trigger_statepoint_restart/test.py @@ -36,7 +36,7 @@ def model(): settings.verbosity = 1 # to test that this works even with no output # Tallies - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ['flux'] tallies = openmc.Tallies([t]) diff --git a/tests/regression_tests/unstructured_mesh/test.py b/tests/regression_tests/unstructured_mesh/test.py index 7607531d8ba..538b81c3d28 100644 --- a/tests/regression_tests/unstructured_mesh/test.py +++ b/tests/regression_tests/unstructured_mesh/test.py @@ -212,7 +212,7 @@ def model(): regular_mesh.upper_right = (10.0, 10.0, 10.0) regular_mesh_filter = openmc.MeshFilter(mesh=regular_mesh) - regular_mesh_tally = openmc.Tally(name="regular mesh tally") + regular_mesh_tally = openmc.VolumeTally(name="regular mesh tally") regular_mesh_tally.filters = [regular_mesh_filter] regular_mesh_tally.scores = ['flux'] @@ -282,7 +282,7 @@ def test_unstructured_mesh_tets(model, test_opts): uscd_filter = openmc.MeshFilter(mesh=uscd_mesh) # create tallies - uscd_tally = openmc.Tally(name="unstructured mesh tally") + uscd_tally = openmc.VolumeTally(name="unstructured mesh tally") uscd_tally.filters = [uscd_filter] uscd_tally.scores = ['flux'] uscd_tally.estimator = test_opts['estimator'] @@ -313,7 +313,7 @@ def test_unstructured_mesh_hexes(model): uscd_filter = openmc.MeshFilter(mesh=uscd_mesh) # create tallies - uscd_tally = openmc.Tally(name="unstructured mesh tally") + uscd_tally = openmc.VolumeTally(name="unstructured mesh tally") uscd_tally.filters = [uscd_filter] uscd_tally.scores = ['flux'] uscd_tally.estimator = 'collision' diff --git a/tests/regression_tests/void/test.py b/tests/regression_tests/void/test.py index 76c15eb39f6..79207d1f2e7 100644 --- a/tests/regression_tests/void/test.py +++ b/tests/regression_tests/void/test.py @@ -26,7 +26,7 @@ def model(): model.settings.source = openmc.IndependentSource(space=openmc.stats.Point()) cell_filter = openmc.CellFilter(cells) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [cell_filter] tally.scores = ['total'] model.tallies.append(tally) diff --git a/tests/regression_tests/weightwindows/generators/test.py b/tests/regression_tests/weightwindows/generators/test.py index 4dc0ab80d35..bdd33b5da5f 100644 --- a/tests/regression_tests/weightwindows/generators/test.py +++ b/tests/regression_tests/weightwindows/generators/test.py @@ -30,7 +30,7 @@ def test_ww_generator(run_in_tmpdir): # include another tally to make sure user-specified tallies and those automaticaly # created by weight window generators can coexist - tally = openmc.Tally() + tally = openmc.VolumeTally() ef = openmc.EnergyFilter(energy_bounds) tally.filters = [ef] tally.scores = ['flux'] diff --git a/tests/regression_tests/weightwindows/survival_biasing/test.py b/tests/regression_tests/weightwindows/survival_biasing/test.py index 92604e3382c..79dc95b4e07 100644 --- a/tests/regression_tests/weightwindows/survival_biasing/test.py +++ b/tests/regression_tests/weightwindows/survival_biasing/test.py @@ -55,7 +55,7 @@ def model(): mesh.upper_right = (160.0, 160.0, 160.0) mesh_filter = openmc.MeshFilter(mesh) - flux_tally = openmc.Tally(name='flux') + flux_tally = openmc.VolumeTally(name='flux') flux_tally.filters = [mesh_filter] flux_tally.scores = ['flux'] tallies = openmc.Tallies([flux_tally]) diff --git a/tests/regression_tests/weightwindows/test.py b/tests/regression_tests/weightwindows/test.py index c22ca1b75d8..7fc3c9ed574 100644 --- a/tests/regression_tests/weightwindows/test.py +++ b/tests/regression_tests/weightwindows/test.py @@ -63,7 +63,7 @@ def model(): particle_filter = openmc.ParticleFilter(['neutron', 'photon']) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter, energy_filter, particle_filter] tally.scores = ['flux'] diff --git a/tests/unit_tests/cell_instances/test_hex_multilattice.py b/tests/unit_tests/cell_instances/test_hex_multilattice.py index 3f503fe9b84..f6537cc1b84 100644 --- a/tests/unit_tests/cell_instances/test_hex_multilattice.py +++ b/tests/unit_tests/cell_instances/test_hex_multilattice.py @@ -54,7 +54,7 @@ def double_hex_lattice_model(): # moderator cell = next(iter(univ.get_all_cells().values())) - tally = openmc.Tally(tally_id=1) + tally = openmc.VolumeTally(tally_id=1) filter = openmc.DistribcellFilter(cell) tally.filters = [filter] tally.scores = ['flux'] diff --git a/tests/unit_tests/cell_instances/test_rect_multilattice.py b/tests/unit_tests/cell_instances/test_rect_multilattice.py index aaecb3bdac5..f6167b69cd9 100644 --- a/tests/unit_tests/cell_instances/test_rect_multilattice.py +++ b/tests/unit_tests/cell_instances/test_rect_multilattice.py @@ -40,7 +40,7 @@ def double_rect_lattice_model(): cell_with_lattice2.translation = (2., 0., 0.) model.geometry = openmc.Geometry([cell_with_lattice1, cell_with_lattice2]) - tally = openmc.Tally(tally_id=1) + tally = openmc.VolumeTally(tally_id=1) dcell_filter = openmc.DistribcellFilter(c) tally.filters = [dcell_filter] tally.scores = ['flux'] diff --git a/tests/unit_tests/dagmc/test.py b/tests/unit_tests/dagmc/test.py index e84b5317ede..8dd6e2d996f 100644 --- a/tests/unit_tests/dagmc/test.py +++ b/tests/unit_tests/dagmc/test.py @@ -44,7 +44,7 @@ def dagmc_model(request): assert dagmc_universe.n_surfaces == 21 # tally - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['total'] tally.filters = [openmc.CellFilter(1)] model.tallies = [tally] diff --git a/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py b/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py index 366ce18efb9..aeae335001b 100644 --- a/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py +++ b/tests/unit_tests/mesh_to_vtk/test_vtk_dims.py @@ -217,7 +217,7 @@ def mesh_surf_id(param): @pytest.mark.parametrize("mesh,surface", product(MESHES, SURFS), ids=mesh_surf_id) def test_vtk_write_ordering(run_in_tmpdir, model, mesh, surface): - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['flux'] # use the mesh on the specified tally mesh_filter = openmc.MeshFilter(mesh) diff --git a/tests/unit_tests/test_cylindrical_mesh.py b/tests/unit_tests/test_cylindrical_mesh.py index 645269825a8..f324edbeded 100644 --- a/tests/unit_tests/test_cylindrical_mesh.py +++ b/tests/unit_tests/test_cylindrical_mesh.py @@ -38,7 +38,7 @@ def model(): z_grid=np.linspace(-geom_size, geom_size, 11), r_grid=np.linspace(0, geom_size, geom_size) ) - tally = openmc.Tally() + tally = openmc.VolumeTally() mesh_filter = openmc.MeshFilter(mesh) tally.filters.append(mesh_filter) @@ -138,7 +138,7 @@ def void_coincident_geom_model(): ) mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['flux'] tally.filters = [mesh_filter] @@ -199,4 +199,4 @@ def test_void_geom_boundary_src(run_in_tmpdir, void_coincident_geom_model): void_coincident_geom_model.settings.source = sources sp_filename = void_coincident_geom_model.run() - _check_void_cylindrical_tally(sp_filename) \ No newline at end of file + _check_void_cylindrical_tally(sp_filename) diff --git a/tests/unit_tests/test_d1s.py b/tests/unit_tests/test_d1s.py index 8f3b62f4000..ba1902422b9 100644 --- a/tests/unit_tests/test_d1s.py +++ b/tests/unit_tests/test_d1s.py @@ -64,7 +64,7 @@ def test_time_correction_factors(nuclide): def test_prepare_tallies(model): - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [openmc.ParticleFilter('photon')] tally.scores = ['flux'] model.tallies = [tally] @@ -104,7 +104,7 @@ def test_apply_time_correction(run_in_tmpdir): model.settings.photon_transport = True model.settings.use_decay_photons = True particle_filter = openmc.ParticleFilter('photon') - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [particle_filter] tally.scores = ['flux'] model.tallies = [tally] diff --git a/tests/unit_tests/test_deplete_activation.py b/tests/unit_tests/test_deplete_activation.py index 2f171388050..cce6654cf0c 100644 --- a/tests/unit_tests/test_deplete_activation.py +++ b/tests/unit_tests/test_deplete_activation.py @@ -33,7 +33,7 @@ def model(): ) model.settings.run_mode = 'fixed source' - rx_tally = openmc.Tally(name='activation tally') + rx_tally = openmc.VolumeTally(name='activation tally') rx_tally.scores = ['(n,gamma)'] model.tallies.append(rx_tally) diff --git a/tests/unit_tests/test_energy_cutoff.py b/tests/unit_tests/test_energy_cutoff.py index 45333f2e1dc..b8848817090 100644 --- a/tests/unit_tests/test_energy_cutoff.py +++ b/tests/unit_tests/test_energy_cutoff.py @@ -25,13 +25,13 @@ def inf_medium_model(cutoff_energy, source_energy): model.settings.batches = 10 model.settings.cutoff = {'energy_photon': cutoff_energy} - tally_flux = openmc.Tally(name='flux') + tally_flux = openmc.VolumeTally(name='flux') tally_flux.filters = [ openmc.EnergyFilter([0.0, cutoff_energy, source_energy]), openmc.ParticleFilter(['photon']) ] tally_flux.scores = ['flux'] - tally_heating = openmc.Tally(name='heating') + tally_heating = openmc.VolumeTally(name='heating') tally_heating.scores = ['heating'] model.tallies = openmc.Tallies([tally_flux, tally_heating]) diff --git a/tests/unit_tests/test_filter_distribcell.py b/tests/unit_tests/test_filter_distribcell.py index d5734a2c076..d762db58efe 100644 --- a/tests/unit_tests/test_filter_distribcell.py +++ b/tests/unit_tests/test_filter_distribcell.py @@ -27,7 +27,7 @@ def test_distribcell_filter_apply_tally_results(run_in_tmpdir): model = openmc.Model(geometry) model.settings.batches = 10 model.settings.particles = 1000 - tally = openmc.Tally() + tally = openmc.VolumeTally() distribcell_filter = openmc.DistribcellFilter(cell1) tally.filters = [distribcell_filter] tally.scores = ['flux'] diff --git a/tests/unit_tests/test_filter_mesh.py b/tests/unit_tests/test_filter_mesh.py index e26bea337bf..b307ab5b3aa 100644 --- a/tests/unit_tests/test_filter_mesh.py +++ b/tests/unit_tests/test_filter_mesh.py @@ -25,7 +25,7 @@ def test_spherical_mesh_estimators(run_in_tmpdir): sph_mesh = openmc.SphericalMesh( r_grid=np.linspace(0.0, 5.0**3, 20)**(1/3) ) - tally1 = openmc.Tally() + tally1 = openmc.VolumeTally() tally1.filters = [openmc.MeshFilter(sph_mesh)] tally1.scores = ['flux'] tally1.estimator = 'collision' @@ -33,7 +33,7 @@ def test_spherical_mesh_estimators(run_in_tmpdir): sph_mesh = openmc.SphericalMesh( r_grid=np.linspace(0.0, 5.0**3, 20)**(1/3) ) - tally2 = openmc.Tally() + tally2 = openmc.VolumeTally() tally2.filters = [openmc.MeshFilter(sph_mesh)] tally2.scores = ['flux'] tally2.estimator = 'tracklength' @@ -81,7 +81,7 @@ def test_cylindrical_mesh_estimators(run_in_tmpdir): r_grid=np.linspace(0.0, 5.0**3, 20)**(1/3), z_grid=[-5., 5.] ) - tally1 = openmc.Tally() + tally1 = openmc.VolumeTally() tally1.filters = [openmc.MeshFilter(cyl_mesh)] tally1.scores = ['flux'] tally1.estimator = 'collision' @@ -90,7 +90,7 @@ def test_cylindrical_mesh_estimators(run_in_tmpdir): r_grid=np.linspace(0.0, 5.0**3, 20)**(1/3), z_grid=[-5., 5.] ) - tally2 = openmc.Tally() + tally2 = openmc.VolumeTally() tally2.filters = [openmc.MeshFilter(cyl_mesh)] tally2.scores = ['flux'] tally2.estimator = 'tracklength' @@ -145,10 +145,10 @@ def test_cylindrical_mesh_coincident(scale, run_in_tmpdir): cyl_mesh_filter = openmc.MeshFilter(cyl_mesh) cell_filter = openmc.CellFilter([cell1]) - tally1 = openmc.Tally() + tally1 = openmc.VolumeTally() tally1.filters = [cyl_mesh_filter] tally1.scores = ['flux'] - tally2 = openmc.Tally() + tally2 = openmc.VolumeTally() tally2.filters = [cell_filter] tally2.scores = ['flux'] model.tallies = openmc.Tallies([tally1, tally2]) @@ -197,10 +197,10 @@ def test_spherical_mesh_coincident(scale, run_in_tmpdir): sph_mesh_filter = openmc.MeshFilter(sph_mesh) cell_filter = openmc.CellFilter([cell1]) - tally1 = openmc.Tally() + tally1 = openmc.VolumeTally() tally1.filters = [sph_mesh_filter] tally1.scores = ['flux'] - tally2 = openmc.Tally() + tally2 = openmc.VolumeTally() tally2.filters = [cell_filter] tally2.scores = ['flux'] model.tallies = openmc.Tallies([tally1, tally2]) @@ -239,7 +239,7 @@ def test_get_reshaped_data(run_in_tmpdir): theta_grid=np.linspace(0, math.pi, 4), phi_grid=np.linspace(0, 2*math.pi, 3) ) - tally1 = openmc.Tally() + tally1 = openmc.VolumeTally() efilter = openmc.EnergyFilter([0, 1e5, 1e8]) meshfilter = openmc.MeshFilter(sph_mesh) assert meshfilter.shape == (19, 3, 2) diff --git a/tests/unit_tests/test_filter_meshborn.py b/tests/unit_tests/test_filter_meshborn.py index 62fa1174e75..23c1f45bb15 100644 --- a/tests/unit_tests/test_filter_meshborn.py +++ b/tests/unit_tests/test_filter_meshborn.py @@ -47,12 +47,12 @@ def model(): mesh.upper_right = (r, r, r) f = openmc.MeshBornFilter(mesh) - t_1 = openmc.Tally(name="scatter-collision") + t_1 = openmc.VolumeTally(name="scatter-collision") t_1.filters = [f] t_1.scores = ["scatter"] t_1.estimator = "collision" - t_2 = openmc.Tally(name="scatter-tracklength") + t_2 = openmc.VolumeTally(name="scatter-tracklength") t_2.filters = [f] t_2.scores = ["scatter"] t_2.estimator = "tracklength" diff --git a/tests/unit_tests/test_filter_meshmaterial.py b/tests/unit_tests/test_filter_meshmaterial.py index a05ed5a1207..33886a4cf2b 100644 --- a/tests/unit_tests/test_filter_meshmaterial.py +++ b/tests/unit_tests/test_filter_meshmaterial.py @@ -40,10 +40,10 @@ def test_filter_mesh_material(run_in_tmpdir): np.testing.assert_equal(mmf.bins, expected_bins) # Create two tallies, one with a mesh filter and one with mesh-material - mesh_tally = openmc.Tally() + mesh_tally = openmc.VolumeTally() mesh_tally.filters = [openmc.MeshFilter(mesh)] mesh_tally.scores = ['flux'] - mesh_material_tally = openmc.Tally() + mesh_material_tally = openmc.VolumeTally() mesh_material_tally.filters = [mmf] mesh_material_tally.scores = ['flux'] model.tallies = [mesh_tally, mesh_material_tally] diff --git a/tests/unit_tests/test_filter_musurface.py b/tests/unit_tests/test_filter_musurface.py index ca0db71f0c6..0a0a0da84fe 100644 --- a/tests/unit_tests/test_filter_musurface.py +++ b/tests/unit_tests/test_filter_musurface.py @@ -18,7 +18,7 @@ def test_musurface(run_in_tmpdir): filter1 = openmc.MuSurfaceFilter(200) filter2 = openmc.SurfaceFilter(sphere) - tally = openmc.Tally() + tally = openmc.SurfaceTally() tally.filters = [filter1, filter2] tally.scores = ['current'] model.tallies = openmc.Tallies([tally]) diff --git a/tests/unit_tests/test_filter_weight.py b/tests/unit_tests/test_filter_weight.py index 878929ee056..6a990ca381f 100644 --- a/tests/unit_tests/test_filter_weight.py +++ b/tests/unit_tests/test_filter_weight.py @@ -26,7 +26,7 @@ def test_weightfilter(run_in_tmpdir): [0.999, 0.9999, 0.99999, 0.999999, 1.0, 1.000001 ,1.00001, 1.0001, 1.001] ) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter, weight_filter] tally.estimator = 'analog' tally.scores = ['flux'] diff --git a/tests/unit_tests/test_filters.py b/tests/unit_tests/test_filters.py index 2e7481c8767..989de082d4e 100644 --- a/tests/unit_tests/test_filters.py +++ b/tests/unit_tests/test_filters.py @@ -198,27 +198,27 @@ def test_zernike_radial(): def test_first_moment(run_in_tmpdir, box_model): - plain_tally = openmc.Tally() + plain_tally = openmc.VolumeTally() plain_tally.scores = ['flux', 'scatter'] # Create tallies with expansion filters - leg_tally = openmc.Tally() + leg_tally = openmc.VolumeTally() leg_tally.filters = [openmc.LegendreFilter(3)] leg_tally.scores = ['scatter'] - leg_sptl_tally = openmc.Tally() + leg_sptl_tally = openmc.VolumeTally() leg_sptl_tally.filters = [openmc.SpatialLegendreFilter(3, 'x', -5., 5.)] leg_sptl_tally.scores = ['scatter'] sph_scat_filter = openmc.SphericalHarmonicsFilter(5) sph_scat_filter.cosine = 'scatter' - sph_scat_tally = openmc.Tally() + sph_scat_tally = openmc.VolumeTally() sph_scat_tally.filters = [sph_scat_filter] sph_scat_tally.scores = ['scatter'] sph_flux_filter = openmc.SphericalHarmonicsFilter(5) sph_flux_filter.cosine = 'particle' - sph_flux_tally = openmc.Tally() + sph_flux_tally = openmc.VolumeTally() sph_flux_tally.filters = [sph_flux_filter] sph_flux_tally.scores = ['flux'] - zernike_tally = openmc.Tally() + zernike_tally = openmc.VolumeTally() zernike_tally.filters = [openmc.ZernikeFilter(3, r=10.)] zernike_tally.scores = ['scatter'] diff --git a/tests/unit_tests/test_heating_by_nuclide.py b/tests/unit_tests/test_heating_by_nuclide.py index b34d7dd9431..0eb73670df4 100644 --- a/tests/unit_tests/test_heating_by_nuclide.py +++ b/tests/unit_tests/test_heating_by_nuclide.py @@ -22,12 +22,12 @@ def model(): # Add two tallies, one with heating by nuclide and one with total heating particle_filter = openmc.ParticleFilter(['neutron', 'photon']) - heating_by_nuclide = openmc.Tally() + heating_by_nuclide = openmc.VolumeTally() heating_by_nuclide.filters = [particle_filter] heating_by_nuclide.nuclides = ['U235', 'H1'] heating_by_nuclide.scores = ['heating'] - heating_total = openmc.Tally() + heating_total = openmc.VolumeTally() heating_total.filters = [particle_filter] heating_total.scores = ['heating'] model.tallies.extend([heating_by_nuclide, heating_total]) diff --git a/tests/unit_tests/test_ifp.py b/tests/unit_tests/test_ifp.py index e527f162460..7e0de26dae6 100644 --- a/tests/unit_tests/test_ifp.py +++ b/tests/unit_tests/test_ifp.py @@ -42,7 +42,7 @@ def test_exceptions(options, error, run_in_tmpdir, geometry): settings = openmc.Settings(**options) settings.particles = 100 settings.batches = 15 - tally = openmc.Tally(name="ifp-scores") + tally = openmc.VolumeTally(name="ifp-scores") tally.scores = ["ifp-time-numerator", "ifp-beta-numerator", "ifp-denominator"] tallies = openmc.Tallies([tally]) model = openmc.Model(geometry=geometry, settings=settings, tallies=tallies) @@ -71,7 +71,7 @@ def test_get_kinetics_parameters(run_in_tmpdir, geometry, num_groups, use_auto_t model.add_kinetics_parameters_tallies(num_groups=num_groups) else: for score in ["ifp-time-numerator", "ifp-beta-numerator", "ifp-denominator"]: - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = [score] if score == "ifp-beta-numerator" and num_groups is not None: tally.filters = [openmc.DelayedGroupFilter(list(range(1, num_groups + 1)))] diff --git a/tests/unit_tests/test_lib.py b/tests/unit_tests/test_lib.py index 51e648dcf93..ca0c1cbfb8f 100644 --- a/tests/unit_tests/test_lib.py +++ b/tests/unit_tests/test_lib.py @@ -22,14 +22,14 @@ def pincell_model(): # Add a tally filter1 = openmc.MaterialFilter(pincell.materials) filter2 = openmc.EnergyFilter([0.0, 1.0, 1.0e3, 20.0e6]) - mat_tally = openmc.Tally() + mat_tally = openmc.VolumeTally() mat_tally.filters = [filter1, filter2] mat_tally.nuclides = ['U235', 'U238'] mat_tally.scores = ['total', 'elastic', '(n,gamma)'] pincell.tallies.append(mat_tally) # Add an expansion tally - zernike_tally = openmc.Tally() + zernike_tally = openmc.VolumeTally() filter3 = openmc.ZernikeFilter(5, r=.63) cells = pincell.geometry.root_universe.cells filter4 = openmc.CellFilter(list(cells.values())) @@ -38,7 +38,7 @@ def pincell_model(): pincell.tallies.append(zernike_tally) # Add an energy function tally - energyfunc_tally = openmc.Tally() + energyfunc_tally = openmc.VolumeTally() energyfunc_filter = openmc.EnergyFunctionFilter( [0.0, 20e6], [0.0, 20e6]) energyfunc_tally.scores = ['fission'] diff --git a/tests/unit_tests/test_mesh.py b/tests/unit_tests/test_mesh.py index 0b28bdfbe44..107f2c1abe1 100644 --- a/tests/unit_tests/test_mesh.py +++ b/tests/unit_tests/test_mesh.py @@ -375,7 +375,7 @@ def test_mesh_name_roundtrip(run_in_tmpdir): mesh.dimension = (1, 1, 1) mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter] tally.scores = ['flux'] @@ -393,7 +393,7 @@ def test_umesh_roundtrip(run_in_tmpdir, request): # create a tally using this mesh mf = openmc.MeshFilter(umesh) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mf] tally.scores = ['flux'] @@ -429,7 +429,7 @@ def simple_umesh(request): mesh_filter = openmc.MeshFilter(umesh) # Create flux mesh tally to score alpha production - mesh_tally = openmc.Tally(name="test_tally") + mesh_tally = openmc.VolumeTally(name="test_tally") mesh_tally.filters = [mesh_filter] mesh_tally.scores = ["total"] @@ -511,7 +511,7 @@ def test_write_vtkhdf(request, run_in_tmpdir): mesh_filter = openmc.MeshFilter(umesh) # Create flux mesh tally to score alpha production - mesh_tally = openmc.Tally(name="test_tally") + mesh_tally = openmc.VolumeTally(name="test_tally") mesh_tally.filters = [mesh_filter] mesh_tally.scores = ["flux"] @@ -824,7 +824,7 @@ def test_raytrace_mesh_infinite_loop(run_in_tmpdir): mesh_surface.upper_right = (30, 30, 60) mesh_surface.dimension = (1, 1, 1) reg_filter = openmc.MeshSurfaceFilter(mesh_surface) - mesh_surface_tally = openmc.Tally() + mesh_surface_tally = openmc.SurfaceTally() mesh_surface_tally.filters = [reg_filter] mesh_surface_tally.scores = ['current'] model.tallies = [mesh_surface_tally] @@ -879,11 +879,11 @@ def test_filter_time_mesh(run_in_tmpdir): time_filter = openmc.TimeFilter(time_grid) # Now use the mesh filter in a tally and indicate what scores are desired - tally1 = openmc.Tally(name="collision") + tally1 = openmc.VolumeTally(name="collision") tally1.estimator = "collision" tally1.filters = [time_filter, mesh_filter] tally1.scores = ["flux"] - tally2 = openmc.Tally(name="tracklength") + tally2 = openmc.VolumeTally(name="tracklength") tally2.estimator = "tracklength" tally2.filters = [time_filter, mesh_filter] tally2.scores = ["flux"] diff --git a/tests/unit_tests/test_model.py b/tests/unit_tests/test_model.py index 9234b2d2721..69d628ac0df 100644 --- a/tests/unit_tests/test_model.py +++ b/tests/unit_tests/test_model.py @@ -69,7 +69,7 @@ def pin_model_attributes(): settings.entropy_mesh = entropy_mesh tals = openmc.Tallies() - tal = openmc.Tally(tally_id=1, name='test') + tal = openmc.VolumeTally(tally_id=1, name='test') tal.filters = [openmc.MaterialFilter(bins=[uo2])] tal.scores = ['flux', 'fission'] tals.append(tal) @@ -934,7 +934,7 @@ def test_setter_from_list(): model = openmc.Model(materials=[mat]) assert isinstance(model.materials, openmc.Materials) - tally = openmc.Tally() + tally = openmc.VolumeTally() model = openmc.Model(tallies=[tally]) assert isinstance(model.tallies, openmc.Tallies) diff --git a/tests/unit_tests/test_no_reduce.py b/tests/unit_tests/test_no_reduce.py index 00ddb5a9590..40dad781dcf 100644 --- a/tests/unit_tests/test_no_reduce.py +++ b/tests/unit_tests/test_no_reduce.py @@ -24,7 +24,7 @@ def test_no_reduce(no_reduce, run_in_tmpdir): # Tally: surface current on vacuum boundary surf_filter = openmc.SurfaceFilter(sphere) - tally = openmc.Tally() + tally = openmc.SurfaceTally() tally.filters = [surf_filter] tally.scores = ['current'] model.tallies = [tally] diff --git a/tests/unit_tests/test_nuclide_heating.py b/tests/unit_tests/test_nuclide_heating.py index e00d57b4ff4..75ae666114c 100644 --- a/tests/unit_tests/test_nuclide_heating.py +++ b/tests/unit_tests/test_nuclide_heating.py @@ -25,10 +25,10 @@ def test_nuclide_heating(run_in_tmpdir): ) # Create two tallies, one with heating by nuclide and one with total heating - tally1 = openmc.Tally() + tally1 = openmc.VolumeTally() tally1.scores = ["heating"] tally1.nuclides = mat.get_nuclides() - tally2 = openmc.Tally() + tally2 = openmc.VolumeTally() tally2.scores = ["heating"] model.tallies = [tally1, tally2] diff --git a/tests/unit_tests/test_photon_heating.py b/tests/unit_tests/test_photon_heating.py index 05473f5c6fc..51072112806 100644 --- a/tests/unit_tests/test_photon_heating.py +++ b/tests/unit_tests/test_photon_heating.py @@ -21,7 +21,7 @@ def test_negative_positron_heating(): model.settings.electron_treatment = 'led' model.settings.seed = 513836 - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [openmc.ParticleFilter(['photon', 'electron', 'positron'])] tally.scores = ['heating'] model.tallies = openmc.Tallies([tally]) diff --git a/tests/unit_tests/test_source_mesh.py b/tests/unit_tests/test_source_mesh.py index 2550cb87ebb..a264260b3a7 100644 --- a/tests/unit_tests/test_source_mesh.py +++ b/tests/unit_tests/test_source_mesh.py @@ -269,7 +269,7 @@ def test_mesh_source_independent(run_in_tmpdir, void_model, mesh_type): # tally the flux on the mesh mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter] tally.scores = ['flux'] diff --git a/tests/unit_tests/test_spherical_mesh.py b/tests/unit_tests/test_spherical_mesh.py index a95a4151a2e..ebe9f8e61ab 100644 --- a/tests/unit_tests/test_spherical_mesh.py +++ b/tests/unit_tests/test_spherical_mesh.py @@ -38,7 +38,7 @@ def model(): theta_grid=np.linspace(0, np.pi, 7), r_grid=np.linspace(0, geom_size, geom_size), ) - tally = openmc.Tally() + tally = openmc.VolumeTally() mesh_filter = openmc.MeshFilter(mesh) tally.filters.append(mesh_filter) @@ -136,7 +136,7 @@ def void_coincident_geom_model(): mesh = openmc.SphericalMesh(r_grid=np.linspace(0, 250, 501)) mesh_filter = openmc.MeshFilter(mesh) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['flux'] tally.filters = [mesh_filter] diff --git a/tests/unit_tests/test_statepoint.py b/tests/unit_tests/test_statepoint.py index 7ffaf7ec2cc..6537f812ec0 100644 --- a/tests/unit_tests/test_statepoint.py +++ b/tests/unit_tests/test_statepoint.py @@ -18,12 +18,12 @@ def test_get_tally_filter_type(run_in_tmpdir): settings.run_mode = "fixed source" reg_mesh = openmc.RegularMesh().from_domain(cell) - tally1 = openmc.Tally(tally_id=1) + tally1 = openmc.VolumeTally(tally_id=1) mesh_filter = openmc.MeshFilter(reg_mesh) tally1.filters = [mesh_filter] tally1.scores = ["flux"] - tally2 = openmc.Tally(tally_id=2, name="heating tally") + tally2 = openmc.VolumeTally(tally_id=2, name="heating tally") cell_filter = openmc.CellFilter(cell) tally2.filters = [cell_filter] tally2.scores = ["heating"] diff --git a/tests/unit_tests/test_surface_flux.py b/tests/unit_tests/test_surface_flux.py index 4e067ffe238..6eb1fefdbba 100644 --- a/tests/unit_tests/test_surface_flux.py +++ b/tests/unit_tests/test_surface_flux.py @@ -47,7 +47,7 @@ def test_surface_filter_flux_normal_incidence(two_cell_model, run_in_tmpdir): model, xmid, *_ = two_cell_model surf_filter = openmc.SurfaceFilter([xmid]) - flux_tally = openmc.Tally() + flux_tally = openmc.SurfaceTally() flux_tally.filters = [surf_filter] flux_tally.scores = ['flux'] model.tallies = [flux_tally] @@ -64,7 +64,7 @@ def test_surface_filter_current_outward(two_cell_model, run_in_tmpdir): model, xmid, *_ = two_cell_model surf_filter = openmc.SurfaceFilter([xmid]) - current_tally = openmc.Tally() + current_tally = openmc.SurfaceTally() current_tally.filters = [surf_filter] current_tally.scores = ['current'] model.tallies = [current_tally] @@ -86,7 +86,7 @@ def test_surface_filter_flux_angled(two_cell_model, run_in_tmpdir): model.settings.source[0].angle = openmc.stats.Monodirectional((ux, uy, 0.0)) surf_filter = openmc.SurfaceFilter([xmid]) - flux_tally = openmc.Tally() + flux_tally = openmc.SurfaceTally() flux_tally.filters = [surf_filter] flux_tally.scores = ['flux'] model.tallies = [flux_tally] @@ -105,7 +105,7 @@ def test_cellfrom_filter_flux_directional(two_cell_model, run_in_tmpdir): surf_filter = openmc.SurfaceFilter([xmid]) cellfrom_filter = openmc.CellFromFilter([cell1, cell2]) - tally = openmc.Tally() + tally = openmc.SurfaceTally() tally.filters = [surf_filter, cellfrom_filter] tally.scores = ['flux'] diff --git a/tests/unit_tests/test_tallies.py b/tests/unit_tests/test_tallies.py index 7b1bf0a2fee..ebcb409375a 100644 --- a/tests/unit_tests/test_tallies.py +++ b/tests/unit_tests/test_tallies.py @@ -13,7 +13,7 @@ def test_xml_roundtrip(run_in_tmpdir): mesh.dimension = (5, 5, 5) mesh_filter = openmc.MeshFilter(mesh) meshborn_filter = openmc.MeshBornFilter(mesh) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter, meshborn_filter] tally.nuclides = ['U235', 'I135', 'Li6'] tally.scores = ['total', 'fission', 'heating'] @@ -48,8 +48,8 @@ def test_xml_roundtrip(run_in_tmpdir): def test_tally_equivalence(): - tally_a = openmc.Tally() - tally_b = openmc.Tally(tally_id=tally_a.id) + tally_a = openmc.VolumeTally() + tally_b = openmc.VolumeTally(tally_id=tally_a.id) tally_a.name = 'new name' assert tally_a != tally_b @@ -100,7 +100,7 @@ def test_tally_equivalence(): def test_figure_of_merit(sphere_model, run_in_tmpdir): # Run model with a few simple tally scores - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['total', 'absorption', 'scatter'] sphere_model.tallies = [tally] sp_path = sphere_model.run(apply_tally_results=True) @@ -116,7 +116,7 @@ def test_figure_of_merit(sphere_model, run_in_tmpdir): def test_tally_application(sphere_model, run_in_tmpdir): # Create a tally with most possible gizmos - tally = openmc.Tally(name='test tally') + tally = openmc.VolumeTally(name='test tally') ef = openmc.EnergyFilter([0.0, 0.1, 1.0, 10.0e6]) mesh = openmc.RegularMesh.from_domain(sphere_model.geometry, (2, 2, 2)) mf = openmc.MeshFilter(mesh) @@ -167,7 +167,7 @@ def test_tally_application(sphere_model, run_in_tmpdir): assert sp_tally.nuclides == tally.nuclides def _tally_from_data(x, *, higher_moments=True, normality=True): - t = openmc.Tally() + t = openmc.VolumeTally() t.scores = ["flux"] # 1 score t.nuclides = [openmc.Nuclide("H1")] # 1 nuclide t._sp_filename = "dummy.h5" # mark "results available" @@ -330,7 +330,7 @@ def test_ztests_scipy_comparison(): assert K2_1 > 2000 and k2_sp1 > 2000 def test_vov_stochastic(sphere_model, run_in_tmpdir): - tally = openmc.Tally(name="test tally") + tally = openmc.VolumeTally(name="test tally") ef = openmc.EnergyFilter([0.0, 0.1, 1.0, 10.0e6]) mesh = openmc.RegularMesh.from_domain(sphere_model.geometry, (2, 2, 2)) mf = openmc.MeshFilter(mesh) diff --git a/tests/unit_tests/test_tally.py b/tests/unit_tests/test_tally.py index 52647a36c7c..c0728661545 100644 --- a/tests/unit_tests/test_tally.py +++ b/tests/unit_tests/test_tally.py @@ -4,7 +4,7 @@ def test_tally_init_args(): """Test that Tally constructor kwargs are applied correctly.""" filter = openmc.EnergyFilter([0.0, 1.0, 20.0e6]) - tally = openmc.Tally( + tally = openmc.VolumeTally( name='my tally', scores=['flux', 'fission'], filters=[filter], diff --git a/tests/unit_tests/test_tally_multiply_density.py b/tests/unit_tests/test_tally_multiply_density.py index 552d76bd52f..40e834b6183 100644 --- a/tests/unit_tests/test_tally_multiply_density.py +++ b/tests/unit_tests/test_tally_multiply_density.py @@ -18,10 +18,10 @@ def test_micro_macro_compare(run_in_tmpdir): # Set up two reaction rate tallies, one that multplies by density and the # other that doesn't - tally_macro = openmc.Tally() + tally_macro = openmc.VolumeTally() tally_macro.nuclides = ['H1', 'H2', 'H3'] tally_macro.scores = ['total', 'elastic'] - tally_micro = openmc.Tally() + tally_micro = openmc.VolumeTally() tally_micro.nuclides = ['H1', 'H2', 'H3'] tally_micro.scores = ['total', 'elastic'] tally_micro.multiply_density = False diff --git a/tests/unit_tests/test_temp_interp.py b/tests/unit_tests/test_temp_interp.py index 4566070cfd9..8245fc082c8 100644 --- a/tests/unit_tests/test_temp_interp.py +++ b/tests/unit_tests/test_temp_interp.py @@ -162,7 +162,7 @@ def model(tmp_path_factory): model.settings.inactive = 0 model.settings.batches = 10 - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['absorption', 'fission', 'scatter', 'nu-fission'] model.tallies = [tally] diff --git a/tests/unit_tests/test_time_filter.py b/tests/unit_tests/test_time_filter.py index b57c80a9758..1a582a74e88 100644 --- a/tests/unit_tests/test_time_filter.py +++ b/tests/unit_tests/test_time_filter.py @@ -70,7 +70,7 @@ def model(request): t0 = time(particle, x - r, E) # Create tally with time filter - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [openmc.TimeFilter([0.0, t0, 2*t0])] tally.scores = ['total'] model.tallies.append(tally) @@ -111,7 +111,7 @@ def model_surf(request): t0 = time(particle, x, E) # Create tally with surface and time filters - tally = openmc.Tally() + tally = openmc.SurfaceTally() tally.filters = [ openmc.SurfaceFilter([black_surface]), openmc.TimeFilter([0.0, t0*0.999, t0*1.001, 100.0]) @@ -172,10 +172,10 @@ def test_small_time_interval(run_in_tmpdir): # Add tallies with and without a time filter that should match all particles time_filter = openmc.TimeFilter([0.0, 1.0e100]) - tally_with_filter = openmc.Tally() + tally_with_filter = openmc.VolumeTally() tally_with_filter.filters = [time_filter] tally_with_filter.scores = ['flux'] - tally_without_filter = openmc.Tally() + tally_without_filter = openmc.VolumeTally() tally_without_filter.scores = ['flux'] model.tallies.extend([tally_with_filter, tally_without_filter]) diff --git a/tests/unit_tests/test_triggers.py b/tests/unit_tests/test_triggers.py index 14bda0cceb3..aeb75785fe9 100644 --- a/tests/unit_tests/test_triggers.py +++ b/tests/unit_tests/test_triggers.py @@ -8,7 +8,7 @@ def test_tally_trigger(run_in_tmpdir): mat_filter = openmc.MaterialFilter(pincell.materials) # create a tally with triggers applied - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mat_filter] tally.scores = ['scatter'] @@ -46,7 +46,7 @@ def test_tally_trigger_null_score(run_in_tmpdir): mat_filter = openmc.MaterialFilter(pincell.materials) # apply a tally with a score that be tallied in this model - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mat_filter] tally.scores = ['pair-production'] @@ -81,7 +81,7 @@ def test_tally_trigger_zero_ignored(run_in_tmpdir): e_filter = openmc.EnergyFilter([0.0, 1e7, 2e7]) # create a tally with triggers applied - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [e_filter] tally.scores = ['(n,p)'] tally.nuclides = ["O16"] @@ -137,7 +137,7 @@ def test_trigger_he3_production(run_in_tmpdir): # Define tally with trigger trigger = openmc.Trigger(trigger_type='rel_err', threshold=0.0001) trigger.scores = ['He3-production'] - he3_production_tally = openmc.Tally() + he3_production_tally = openmc.VolumeTally() he3_production_tally.scores = ['He3-production'] he3_production_tally.triggers = [trigger] model.tallies = openmc.Tallies([he3_production_tally]) diff --git a/tests/unit_tests/test_uniform_source_sampling.py b/tests/unit_tests/test_uniform_source_sampling.py index 0d1930328b9..60b099d9ad6 100644 --- a/tests/unit_tests/test_uniform_source_sampling.py +++ b/tests/unit_tests/test_uniform_source_sampling.py @@ -28,7 +28,7 @@ def sphere_model(): "max_particles": 100, } - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['flux'] model.tallies = [tally] return model diff --git a/tests/unit_tests/test_urr_capture.py b/tests/unit_tests/test_urr_capture.py index 34b518e9de8..0d9c3660c04 100644 --- a/tests/unit_tests/test_urr_capture.py +++ b/tests/unit_tests/test_urr_capture.py @@ -21,7 +21,7 @@ def th232_model(): energies = openmc.stats.Uniform(e_min, e_max) model.settings.source = openmc.IndependentSource(energy=energies) - tally = openmc.Tally(name='rates') + tally = openmc.VolumeTally(name='rates') tally.filters = [openmc.EnergyFilter([e_min, e_max])] tally.scores = ['(n,gamma)', 'absorption', 'fission'] model.tallies.append(tally) diff --git a/tests/unit_tests/weightwindows/test.py b/tests/unit_tests/weightwindows/test.py index d6e509522fa..44994e66d84 100644 --- a/tests/unit_tests/weightwindows/test.py +++ b/tests/unit_tests/weightwindows/test.py @@ -113,7 +113,7 @@ def model(): particle_filter = openmc.ParticleFilter(['neutron', 'photon']) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mesh_filter, energy_filter, particle_filter] tally.scores = ['flux'] @@ -248,7 +248,7 @@ def test_photon_heating(run_in_tmpdir): model.settings.batches = 5 model.settings.particles = 100 - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.scores = ['heating'] tally.filters = [ openmc.ParticleFilter(['photon']), diff --git a/tests/unit_tests/weightwindows/test_ww_gen.py b/tests/unit_tests/weightwindows/test_ww_gen.py index a4456e6809a..c88c3d5cd6f 100644 --- a/tests/unit_tests/weightwindows/test_ww_gen.py +++ b/tests/unit_tests/weightwindows/test_ww_gen.py @@ -104,7 +104,7 @@ def labels(params): @pytest.mark.parametrize("filters", test_cases, ids=labels) def test_ww_gen(filters, run_in_tmpdir, model): - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = list(filters) tally.scores = ['flux'] model.tallies = openmc.Tallies([tally]) @@ -180,7 +180,7 @@ def test_ww_import_export(run_in_tmpdir, model): pf = openmc.ParticleFilter(['neutron', 'photon']) - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = [mf, ef, pf] tally.scores = ['flux'] @@ -315,7 +315,7 @@ def test_python_hdf5_roundtrip(run_in_tmpdir, model): def test_ww_bounds_set_in_memory(run_in_tmpdir, model): - tally = openmc.Tally() + tally = openmc.VolumeTally() tally.filters = filters tally.scores = ['flux'] model.tallies = [tally] diff --git a/tests/unit_tests/weightwindows/test_ww_mg.py b/tests/unit_tests/weightwindows/test_ww_mg.py index 23e09ea0c07..72e12d3b805 100644 --- a/tests/unit_tests/weightwindows/test_ww_mg.py +++ b/tests/unit_tests/weightwindows/test_ww_mg.py @@ -8,7 +8,7 @@ def test_weight_windows_mg(request, run_in_tmpdir): # create a mesh tally mesh = openmc.RegularMesh.from_domain(model.geometry, (3, 3, 3)) - mesh_tally = openmc.Tally() + mesh_tally = openmc.VolumeTally() mesh_tally.filters = [openmc.MeshFilter(mesh)] mesh_tally.scores = ['flux'] model.tallies = [mesh_tally]