mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Change names of openmc.capi classes. Hopefully fix RTD docs build.
This commit is contained in:
parent
95a4f4c0f5
commit
02b8f4ec09
14 changed files with 144 additions and 128 deletions
|
|
@ -33,7 +33,9 @@ Classes
|
|||
:nosignatures:
|
||||
:template: myclass.rst
|
||||
|
||||
openmc.capi.CellView
|
||||
openmc.capi.MaterialView
|
||||
openmc.capi.NuclideView
|
||||
openmc.capi.TallyView
|
||||
openmc.capi.Cell
|
||||
openmc.capi.EnergyFilter
|
||||
openmc.capi.MaterialFilter
|
||||
openmc.capi.Material
|
||||
openmc.capi.Nuclide
|
||||
openmc.capi.Tally
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ class CrossNuclide(object):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
left_nuclide : Nuclide or CrossNuclide
|
||||
left_nuclide : openmc.Nuclide or CrossNuclide
|
||||
The left nuclide in the outer product
|
||||
right_nuclide : Nuclide or CrossNuclide
|
||||
right_nuclide : openmc.Nuclide or CrossNuclide
|
||||
The right nuclide in the outer product
|
||||
binary_op : str
|
||||
The tally arithmetic binary operator (e.g., '+', '-', etc.) used to
|
||||
|
|
@ -118,9 +118,9 @@ class CrossNuclide(object):
|
|||
|
||||
Attributes
|
||||
----------
|
||||
left_nuclide : Nuclide or CrossNuclide
|
||||
left_nuclide : openmc.Nuclide or CrossNuclide
|
||||
The left nuclide in the outer product
|
||||
right_nuclide : Nuclide or CrossNuclide
|
||||
right_nuclide : openmc.Nuclide or CrossNuclide
|
||||
The right nuclide in the outer product
|
||||
binary_op : str
|
||||
The tally arithmetic binary operator (e.g., '+', '-', etc.) used to
|
||||
|
|
@ -510,7 +510,7 @@ class AggregateNuclide(object):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
nuclides : Iterable of str or Nuclide or CrossNuclide
|
||||
nuclides : Iterable of str or openmc.Nuclide or CrossNuclide
|
||||
The nuclides included in the aggregation
|
||||
aggregate_op : str
|
||||
The tally aggregation operator (e.g., 'sum', 'avg', etc.) used
|
||||
|
|
@ -518,7 +518,7 @@ class AggregateNuclide(object):
|
|||
|
||||
Attributes
|
||||
----------
|
||||
nuclides : Iterable of str or Nuclide or CrossNuclide
|
||||
nuclides : Iterable of str or openmc.Nuclide or CrossNuclide
|
||||
The nuclides included in the aggregation
|
||||
aggregate_op : str
|
||||
The tally aggregation operator (e.g., 'sum', 'avg', etc.) used
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ objects in the :mod:`openmc.capi` subpackage, for example:
|
|||
"""
|
||||
|
||||
from ctypes import CDLL
|
||||
import os
|
||||
import sys
|
||||
from warnings import warn
|
||||
|
||||
|
|
@ -25,10 +26,21 @@ if sys.platform == 'darwin':
|
|||
else:
|
||||
_suffix = 'so'
|
||||
|
||||
# Open shared library
|
||||
_filename = pkg_resources.resource_filename(
|
||||
__name__, 'libopenmc.{}'.format(_suffix))
|
||||
_dll = CDLL(_filename)
|
||||
if os.environ.get('READTHEDOCS', None) != 'True':
|
||||
# Open shared library
|
||||
_filename = pkg_resources.resource_filename(
|
||||
__name__, 'libopenmc.{}'.format(_suffix))
|
||||
_dll = CDLL(_filename)
|
||||
else:
|
||||
# For documentation builds, we don't actually have the shared library
|
||||
# available. Instead, we create a mock object so that when the modules
|
||||
# within the openmc.capi package try to configure arguments and return
|
||||
# values for symbols, no errors occur
|
||||
try:
|
||||
from unittest.mock import Mock
|
||||
except ImportError:
|
||||
from mock import Mock
|
||||
_dll = Mock()
|
||||
|
||||
from .error import *
|
||||
from .core import *
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import numpy as np
|
|||
from numpy.ctypeslib import as_array
|
||||
|
||||
from . import _dll
|
||||
from .core import _View
|
||||
from .core import _FortranObjectWithID
|
||||
from .error import _error_handler
|
||||
from .material import MaterialView
|
||||
from .material import Material
|
||||
|
||||
__all__ = ['CellView', 'cells']
|
||||
__all__ = ['Cell', 'cells']
|
||||
|
||||
# Cell functions
|
||||
_dll.openmc_cell_get_id.argtypes = [c_int32, POINTER(c_int32)]
|
||||
|
|
@ -31,11 +31,11 @@ _dll.openmc_get_cell_index.restype = c_int
|
|||
_dll.openmc_get_cell_index.errcheck = _error_handler
|
||||
|
||||
|
||||
class CellView(_View):
|
||||
"""View of a cell.
|
||||
class Cell(_FortranObjectWithID):
|
||||
"""Cell stored internally.
|
||||
|
||||
This class exposes a cell that is stored internally in the OpenMC solver. To
|
||||
obtain a view of a cell with a given ID, use the
|
||||
This class exposes a cell that is stored internally in the OpenMC
|
||||
library. To obtain a view of a cell with a given ID, use the
|
||||
:data:`openmc.capi.nuclides` mapping.
|
||||
|
||||
Parameters
|
||||
|
|
@ -72,9 +72,9 @@ class CellView(_View):
|
|||
|
||||
if fill_type.value == 1:
|
||||
if n.value > 1:
|
||||
return [MaterialView(i) for i in indices[:n.value]]
|
||||
return [Material(index=i) for i in indices[:n.value]]
|
||||
else:
|
||||
return MaterialView(indices[0])
|
||||
return Material(index=indices[0])
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ class CellView(_View):
|
|||
n = len(fill)
|
||||
indices = (c_int*n)(*(m._index for m in fill))
|
||||
_dll.openmc_cell_set_fill(self._index, 1, 1, indices)
|
||||
elif isinstance(fill, MaterialView):
|
||||
elif isinstance(fill, Material):
|
||||
materials = [fill]
|
||||
indices = (c_int*1)(fill._index)
|
||||
_dll.openmc_cell_set_fill(self._index, 1, 1, indices)
|
||||
|
|
@ -108,12 +108,16 @@ class CellView(_View):
|
|||
class _CellMapping(Mapping):
|
||||
def __getitem__(self, key):
|
||||
index = c_int32()
|
||||
_dll.openmc_get_cell_index(key, index)
|
||||
return CellView(index.value)
|
||||
try:
|
||||
_dll.openmc_get_cell_index(key, index)
|
||||
except (AllocationError, InvalidIDError) as e:
|
||||
# __contains__ expects a KeyError to work correctly
|
||||
raise KeyError(str(e))
|
||||
return Cell(index.value)
|
||||
|
||||
def __iter__(self):
|
||||
for i in range(len(self)):
|
||||
yield CellView(i + 1).id
|
||||
yield Cell(i + 1).id
|
||||
|
||||
def __len__(self):
|
||||
return c_int32.in_dll(_dll, 'n_cells').value
|
||||
|
|
|
|||
|
|
@ -172,12 +172,12 @@ class _DLLGlobal(object):
|
|||
self.ctype.in_dll(_dll, self.name).value = value
|
||||
|
||||
|
||||
class _View(object):
|
||||
class _FortranObject(object):
|
||||
def __repr__(self):
|
||||
return "{}[{}]".format(type(self).__name__, self._index)
|
||||
|
||||
|
||||
class _ViewWithID(_View):
|
||||
class _FortranObjectWithID(_FortranObject):
|
||||
def __init__(self, uid=None, new=True, index=None):
|
||||
# Creating the object has already been handled by __new__. In the
|
||||
# initializer, all we do is make sure that the object returned has an ID
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@ class InvalidTypeError(Error):
|
|||
"""Tried to perform an operation on the wrong type."""
|
||||
|
||||
|
||||
_errmsg = (c_char*256).in_dll(_dll, 'openmc_err_msg')
|
||||
|
||||
|
||||
def _error_handler(err, func, args):
|
||||
"""Raise exception according to error code."""
|
||||
|
||||
|
|
@ -50,7 +47,8 @@ def _error_handler(err, func, args):
|
|||
return c_int.in_dll(_dll, s).value
|
||||
|
||||
# Get error message set by OpenMC library
|
||||
msg = _errmsg.value.decode()
|
||||
errmsg = (c_char*256).in_dll(_dll, 'openmc_err_msg')
|
||||
msg = errmsg.value.decode()
|
||||
|
||||
# Raise exception type corresponding to error code
|
||||
if err == errcode('e_allocate'):
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ import numpy as np
|
|||
from numpy.ctypeslib import as_array
|
||||
|
||||
from . import _dll
|
||||
from .core import _ViewWithID
|
||||
from .core import _FortranObjectWithID
|
||||
from .error import _error_handler, AllocationError, InvalidIDError
|
||||
from .material import MaterialView
|
||||
from .material import Material
|
||||
|
||||
|
||||
__all__ = ['FilterView', 'AzimuthalFilterView', 'CellFilterView',
|
||||
'CellbornFilterView', 'CellfromFilterView', 'DistribcellFilterView',
|
||||
'DelayedGroupFilterView', 'EnergyFilterView', 'EnergyoutFilterView',
|
||||
'EnergyFunctionFilterView', 'MaterialFilterView', 'MeshFilterView',
|
||||
'MuFilterView', 'PolarFilterView', 'SurfaceFilterView',
|
||||
'UniverseFilterView', 'filters']
|
||||
__all__ = ['Filter', 'AzimuthalFilter', 'CellFilter',
|
||||
'CellbornFilter', 'CellfromFilter', 'DistribcellFilter',
|
||||
'DelayedGroupFilter', 'EnergyFilter', 'EnergyoutFilter',
|
||||
'EnergyFunctionFilter', 'MaterialFilter', 'MeshFilter',
|
||||
'MuFilter', 'PolarFilter', 'SurfaceFilter',
|
||||
'UniverseFilter', 'filters']
|
||||
|
||||
# Tally functions
|
||||
_dll.openmc_energy_filter_get_bins.argtypes = [
|
||||
|
|
@ -57,7 +57,7 @@ _dll.openmc_mesh_filter_set_mesh.restype = c_int
|
|||
_dll.openmc_mesh_filter_set_mesh.errcheck = _error_handler
|
||||
|
||||
|
||||
class FilterView(_ViewWithID):
|
||||
class Filter(_FortranObjectWithID):
|
||||
__instances = WeakValueDictionary()
|
||||
|
||||
def __new__(cls, filter_type, uid=None, new=True, index=None):
|
||||
|
|
@ -102,7 +102,7 @@ class FilterView(_ViewWithID):
|
|||
_dll.openmc_filter_set_id(self._index, filter_id)
|
||||
|
||||
|
||||
class EnergyFilterView(FilterView):
|
||||
class EnergyFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'energy', uid, new, index)
|
||||
|
||||
|
|
@ -123,47 +123,47 @@ class EnergyFilterView(FilterView):
|
|||
self._index, len(energies), energies_p)
|
||||
|
||||
|
||||
class EnergyoutFilterView(FilterView):
|
||||
class EnergyoutFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'energyout', uid, new, index)
|
||||
|
||||
|
||||
class AzimuthalFilterView(FilterView):
|
||||
class AzimuthalFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'azimuthal', uid, new, index)
|
||||
|
||||
|
||||
class CellFilterView(FilterView):
|
||||
class CellFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'cell', uid, new, index)
|
||||
|
||||
|
||||
class CellbornFilterView(FilterView):
|
||||
class CellbornFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'cellborn', uid, new, index)
|
||||
|
||||
|
||||
class CellfromFilterView(FilterView):
|
||||
class CellfromFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'cellfrom', uid, new, index)
|
||||
|
||||
|
||||
class DelayedGroupFilterView(FilterView):
|
||||
class DelayedGroupFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'delayedgroup', uid, new, index)
|
||||
|
||||
|
||||
class DistribcellFilterView(FilterView):
|
||||
class DistribcellFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'distribcell', uid, new, index)
|
||||
|
||||
|
||||
class EnergyFunctionFilterView(FilterView):
|
||||
class EnergyFunctionFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'energyfunction', uid, new, index)
|
||||
|
||||
|
||||
class MaterialFilterView(FilterView):
|
||||
class MaterialFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'material', uid, new, index)
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ class MaterialFilterView(FilterView):
|
|||
materials = POINTER(c_int32)()
|
||||
n = c_int32()
|
||||
_dll.openmc_material_filter_get_bins(self._index, materials, n)
|
||||
return [MaterialView(index=materials[i]) for i in range(n.value)]
|
||||
return [Material(index=materials[i]) for i in range(n.value)]
|
||||
|
||||
@bins.setter
|
||||
def bins(self, materials):
|
||||
|
|
@ -188,47 +188,47 @@ class MaterialFilterView(FilterView):
|
|||
_dll.openmc_material_filter_set_bins(self._index, n, bins)
|
||||
|
||||
|
||||
class MeshFilterView(FilterView):
|
||||
class MeshFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'mesh', uid, new, index)
|
||||
|
||||
|
||||
class MuFilterView(FilterView):
|
||||
class MuFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'mu', uid, new, index)
|
||||
|
||||
|
||||
class PolarFilterView(FilterView):
|
||||
class PolarFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'polar', uid, new, index)
|
||||
|
||||
|
||||
class SurfaceFilterView(FilterView):
|
||||
class SurfaceFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'surface', uid, new, index)
|
||||
|
||||
|
||||
class UniverseFilterView(FilterView):
|
||||
class UniverseFilter(Filter):
|
||||
def __new__(cls, bins=None, uid=None, new=True, index=None):
|
||||
return super().__new__(cls, b'universe', uid, new, index)
|
||||
|
||||
|
||||
_FILTER_TYPE_MAP = {
|
||||
'azimuthal': AzimuthalFilterView,
|
||||
'cell': CellFilterView,
|
||||
'cellborn': CellbornFilterView,
|
||||
'cellfrom': CellfromFilterView,
|
||||
'delayedgroup': DelayedGroupFilterView,
|
||||
'distribcell': DistribcellFilterView,
|
||||
'energy': EnergyFilterView,
|
||||
'energyout': EnergyoutFilterView,
|
||||
'energyfunction': EnergyFunctionFilterView,
|
||||
'material': MaterialFilterView,
|
||||
'mesh': MeshFilterView,
|
||||
'mu': MuFilterView,
|
||||
'polar': PolarFilterView,
|
||||
'surface': SurfaceFilterView,
|
||||
'universe': UniverseFilterView,
|
||||
'azimuthal': AzimuthalFilter,
|
||||
'cell': CellFilter,
|
||||
'cellborn': CellbornFilter,
|
||||
'cellfrom': CellfromFilter,
|
||||
'delayedgroup': DelayedGroupFilter,
|
||||
'distribcell': DistribcellFilter,
|
||||
'energy': EnergyFilter,
|
||||
'energyout': EnergyoutFilter,
|
||||
'energyfunction': EnergyFunctionFilter,
|
||||
'material': MaterialFilter,
|
||||
'mesh': MeshFilter,
|
||||
'mu': MuFilter,
|
||||
'polar': PolarFilter,
|
||||
'surface': SurfaceFilter,
|
||||
'universe': UniverseFilter,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ from weakref import WeakValueDictionary
|
|||
import numpy as np
|
||||
from numpy.ctypeslib import as_array
|
||||
|
||||
from . import _dll, NuclideView
|
||||
from .core import _ViewWithID
|
||||
from . import _dll, Nuclide
|
||||
from .core import _FortranObjectWithID
|
||||
from .error import _error_handler, AllocationError, InvalidIDError
|
||||
|
||||
|
||||
__all__ = ['MaterialView', 'materials']
|
||||
__all__ = ['Material', 'materials']
|
||||
|
||||
# Material functions
|
||||
_dll.openmc_extend_materials.argtypes = [c_int32, POINTER(c_int32), POINTER(c_int32)]
|
||||
|
|
@ -43,11 +43,11 @@ _dll.openmc_material_set_id.restype = c_int
|
|||
_dll.openmc_material_set_id.errcheck = _error_handler
|
||||
|
||||
|
||||
class MaterialView(_ViewWithID):
|
||||
"""View of a material.
|
||||
class Material(_FortranObjectWithID):
|
||||
"""Material stored internally.
|
||||
|
||||
This class exposes a material that is stored internally in the OpenMC
|
||||
solver. To obtain a view of a material with a given ID, use the
|
||||
library. To obtain a view of a material with a given ID, use the
|
||||
:data:`openmc.capi.materials` mapping.
|
||||
|
||||
Parameters
|
||||
|
|
@ -141,7 +141,7 @@ class MaterialView(_ViewWithID):
|
|||
_dll.openmc_material_get_densities(self._index, nuclides, densities, n)
|
||||
|
||||
# Convert to appropriate types and return
|
||||
nuclide_list = [NuclideView(nuclides[i]).name for i in range(n.value)]
|
||||
nuclide_list = [Nuclide(nuclides[i]).name for i in range(n.value)]
|
||||
density_array = as_array(densities, (n.value,))
|
||||
return nuclide_list, density_array
|
||||
|
||||
|
|
@ -196,14 +196,14 @@ class _MaterialMapping(Mapping):
|
|||
index = c_int32()
|
||||
try:
|
||||
_dll.openmc_get_material_index(key, index)
|
||||
except InvalidIDError as e:
|
||||
except (AllocationError, InvalidIDError) as e:
|
||||
# __contains__ expects a KeyError to work correctly
|
||||
raise KeyError(str(e))
|
||||
return MaterialView(index=index.value)
|
||||
return Material(index=index.value)
|
||||
|
||||
def __iter__(self):
|
||||
for i in range(len(self)):
|
||||
yield MaterialView(index=i + 1).id
|
||||
yield Material(index=i + 1).id
|
||||
|
||||
def __len__(self):
|
||||
return c_int32.in_dll(_dll, 'n_materials').value
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import numpy as np
|
|||
from numpy.ctypeslib import as_array
|
||||
|
||||
from . import _dll
|
||||
from .core import _View
|
||||
from .core import _FortranObject
|
||||
from .error import _error_handler, DataError, AllocationError
|
||||
|
||||
|
||||
__all__ = ['NuclideView', 'nuclides', 'load_nuclide']
|
||||
__all__ = ['Nuclide', 'nuclides', 'load_nuclide']
|
||||
|
||||
# Nuclide functions
|
||||
_dll.openmc_get_nuclide_index.argtypes = [c_char_p, POINTER(c_int)]
|
||||
|
|
@ -36,8 +36,8 @@ def load_nuclide(name):
|
|||
_dll.openmc_load_nuclide(name.encode())
|
||||
|
||||
|
||||
class NuclideView(_View):
|
||||
"""View of a nuclide.
|
||||
class Nuclide(_FortranObject):
|
||||
"""Nuclide stored internally.
|
||||
|
||||
This class exposes a nuclide that is stored internally in the OpenMC
|
||||
solver. To obtain a view of a nuclide with a given name, use the
|
||||
|
|
@ -86,11 +86,11 @@ class _NuclideMapping(Mapping):
|
|||
except (DataError, AllocationError) as e:
|
||||
# __contains__ expects a KeyError to work correctly
|
||||
raise KeyError(str(e))
|
||||
return NuclideView(index.value)
|
||||
return Nuclide(index.value)
|
||||
|
||||
def __iter__(self):
|
||||
for i in range(len(self)):
|
||||
yield NuclideView(i + 1).name
|
||||
yield Nuclide(i + 1).name
|
||||
|
||||
def __len__(self):
|
||||
return c_int.in_dll(_dll, 'n_nuclides').value
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ from weakref import WeakValueDictionary
|
|||
|
||||
from numpy.ctypeslib import as_array
|
||||
|
||||
from . import _dll, NuclideView
|
||||
from .core import _ViewWithID
|
||||
from . import _dll, Nuclide
|
||||
from .core import _FortranObjectWithID
|
||||
from .error import _error_handler, AllocationError, InvalidIDError
|
||||
from .filter import _get_filter
|
||||
|
||||
|
||||
__all__ = ['TallyView', 'tallies']
|
||||
__all__ = ['Tally', 'tallies']
|
||||
|
||||
# Tally functions
|
||||
_dll.openmc_get_tally_index.argtypes = [c_int32, POINTER(c_int32)]
|
||||
|
|
@ -51,11 +51,11 @@ _dll.openmc_tally_set_type.restype = c_int
|
|||
_dll.openmc_tally_set_type.errcheck = _error_handler
|
||||
|
||||
|
||||
class TallyView(_ViewWithID):
|
||||
"""View of a tally.
|
||||
class Tally(_FortranObjectWithID):
|
||||
"""Tally stored internally.
|
||||
|
||||
This class exposes a tally that is stored internally in the OpenMC
|
||||
solver. To obtain a view of a tally with a given ID, use the
|
||||
library. To obtain a view of a tally with a given ID, use the
|
||||
:data:`openmc.capi.tallies` mapping.
|
||||
|
||||
Parameters
|
||||
|
|
@ -64,7 +64,7 @@ class TallyView(_ViewWithID):
|
|||
Unique ID of the tally
|
||||
new : bool
|
||||
When `index` is None, this argument controls whether a new object is
|
||||
created or a view to an existing object is returned.
|
||||
created or a view of an existing object is returned.
|
||||
index : int or None
|
||||
Index in the `tallies` array.
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class TallyView(_ViewWithID):
|
|||
id : int
|
||||
ID of the tally
|
||||
filters : list
|
||||
List of views to tally filters
|
||||
List of tally filters
|
||||
nuclides : list of str
|
||||
List of nuclides to score results for
|
||||
results : numpy.ndarray
|
||||
|
|
@ -135,7 +135,7 @@ class TallyView(_ViewWithID):
|
|||
nucs = POINTER(c_int)()
|
||||
n = c_int()
|
||||
_dll.openmc_tally_get_nuclides(self._index, nucs, n)
|
||||
return [NuclideView(nucs[i]).name if nucs[i] > 0 else 'total'
|
||||
return [Nuclide(nucs[i]).name if nucs[i] > 0 else 'total'
|
||||
for i in range(n.value)]
|
||||
|
||||
@property
|
||||
|
|
@ -191,14 +191,14 @@ class _TallyMapping(Mapping):
|
|||
index = c_int32()
|
||||
try:
|
||||
_dll.openmc_get_tally_index(key, index)
|
||||
except InvalidIDError as e:
|
||||
except (AllocationError, InvalidIDError) as e:
|
||||
# __contains__ expects a KeyError to work correctly
|
||||
raise KeyError(str(e))
|
||||
return TallyView(index=index.value)
|
||||
return Tally(index=index.value)
|
||||
|
||||
def __iter__(self):
|
||||
for i in range(len(self)):
|
||||
yield TallyView(index=i + 1).id
|
||||
yield Tally(index=i + 1).id
|
||||
|
||||
def __len__(self):
|
||||
return c_int32.in_dll(_dll, 'n_tallies').value
|
||||
|
|
|
|||
|
|
@ -606,7 +606,7 @@ class Library(object):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
domain : Material or Cell or Universe or Integral
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh or Integral
|
||||
The material, cell, or universe object of interest (or its ID)
|
||||
mgxs_type : {'total', 'transport', 'nu-transport', 'absorption', 'capture', 'fission', 'nu-fission', 'kappa-fission', 'scatter', 'nu-scatter', 'scatter matrix', 'nu-scatter matrix', 'multiplicity matrix', 'nu-fission matrix', chi', 'chi-prompt', 'inverse-velocity', 'prompt-nu-fission', 'prompt-nu-fission matrix', 'delayed-nu-fission', 'delayed-nu-fission matrix', 'chi-delayed', 'beta'}
|
||||
The type of multi-group cross section object to return
|
||||
|
|
@ -668,7 +668,7 @@ class Library(object):
|
|||
|
||||
Returns
|
||||
-------
|
||||
Library
|
||||
openmc.mgxs.Library
|
||||
A new multi-group cross section library condensed to the group
|
||||
structure of interest
|
||||
|
||||
|
|
@ -880,7 +880,7 @@ class Library(object):
|
|||
|
||||
Returns
|
||||
-------
|
||||
Library
|
||||
openmc.mgxs.Library
|
||||
A Library object loaded from the pickle binary file
|
||||
|
||||
See also
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class MDGXS(MGXS):
|
|||
Reaction type (e.g., 'chi-delayed', 'beta', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -948,7 +948,7 @@ class ChiDelayed(MDGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -1462,7 +1462,7 @@ class DelayedNuFissionXS(MDGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -1598,7 +1598,7 @@ class Beta(MDGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -1782,7 +1782,7 @@ class DecayRate(MDGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -1959,7 +1959,7 @@ class MatrixMDGXS(MDGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -2551,7 +2551,7 @@ class DelayedNuFissionMatrixXS(MatrixMDGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class MGXS(object):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -2018,7 +2018,7 @@ class MatrixMGXS(MGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -2512,7 +2512,7 @@ class TotalXS(MGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -2649,7 +2649,7 @@ class TransportXS(MGXS):
|
|||
If True, the cross section data will include neutron multiplication
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -2858,7 +2858,7 @@ class AbsorptionXS(MGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -2986,7 +2986,7 @@ class CaptureXS(MGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -3140,7 +3140,7 @@ class FissionXS(MGXS):
|
|||
If true, computes cross sections which only includes prompt neutrons
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -3309,7 +3309,7 @@ class KappaFissionXS(MGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -3441,7 +3441,7 @@ class ScatterXS(MGXS):
|
|||
If True, the cross section data will include neutron multiplication
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -3658,7 +3658,7 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
If True, the cross section data will include neutron multiplication
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -4020,7 +4020,7 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
# Override the nuclides for tally arithmetic
|
||||
correction.nuclides = scatter_p1.nuclides
|
||||
self._xs_tally -= correction
|
||||
|
||||
|
||||
self._compute_xs()
|
||||
|
||||
return self._xs_tally
|
||||
|
|
@ -4749,7 +4749,7 @@ class MultiplicityMatrixXS(MatrixMGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -4915,7 +4915,7 @@ class ScatterProbabilityMatrix(MatrixMGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -5088,7 +5088,7 @@ class NuFissionMatrixXS(MatrixMGXS):
|
|||
If true, computes cross sections which only includes prompt neutrons
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -5245,7 +5245,7 @@ class Chi(MGXS):
|
|||
If true, computes cross sections which only includes prompt neutrons
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
@ -5823,7 +5823,7 @@ class InverseVelocity(MGXS):
|
|||
Reaction type (e.g., 'total', 'nu-fission', etc.)
|
||||
by_nuclide : bool
|
||||
If true, computes cross sections for each nuclide in domain
|
||||
domain : Material or Cell or Universe or Mesh
|
||||
domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh
|
||||
Domain for spatial homogenization
|
||||
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
|
||||
Domain type for spatial homogenization
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ class Tally(IDManagerMixin):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
nuclide : str, Nuclide, CrossNuclide or AggregateNuclide
|
||||
nuclide : str, openmc.Nuclide, CrossNuclide or AggregateNuclide
|
||||
Nuclide to add to the tally. The nuclide should be a Nuclide object
|
||||
when a user is adding nuclides to a Tally for input file generation.
|
||||
The nuclide is a str when a Tally is created from a StatePoint file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue