Esempio n. 1
0
class CompxsLibrary(_XSLibrary):
    """
    Library object used in reading/writing COMPXS files.

    Contains macroscopic cross sections for homogenized regions.

    See Also
    --------
    :py:class:`IsotxsLibrary`
    :py:func:`armi.nuclearDataIO.compxs.readBinary`

    Examples
    --------
    >>> lib = compxs.readBinary('COMPXS')
    >>> lib.regions
    """
    def __init__(self):
        _XSLibrary.__init__(self)
        self._regions = {}
        self.compxsMetadata = RegionXSMetadata()

    def __setitem__(self, key, value):
        _XSLibrary.__setitem__(self, key, value)
        self._regions[key] = value

    def __getitem__(self, key):
        return self._regions[key]

    def __delitem__(self, key):
        _XSLibrary.__delitem__(self, key)
        del self._regions[key]

    @property
    def regions(self):
        return [self[name] for name in self._orderedNuclideLabels]

    @property
    def regionLabels(self):
        return list(self._orderedNuclideLabels)

    def merge(self, other):
        """Merge two ``COMPXS`` libraries."""
        self._mergeProperties(other)
        self.compxsMetadata = self.compxsMetadata.merge(
            other.compxsMetadata, self, other, "COMPXS", CompxsError)
        self._appendRegions(other)

    def _mergeProperties(self, other):
        properties.unlockImmutableProperties(other)
        try:
            self._mergeNeutronEnergies(other)
        finally:
            properties.lockImmutableProperties(other)

    def _appendRegions(self, other):
        offset = len(self.regions)
        for region in other.regions:
            newNumber = region.regionNumber + offset
            self[newNumber] = region
        self.compxsMetadata["numComps"] = len(self.regions)
Esempio n. 2
0
    def _getMetadata(self):
        specs = RegionXSMetadata()
        chiFlag = specs["fileWideChiFlag"] = self._getFileMetadata(
        )["fileWideChiFlag"]
        if chiFlag:
            self.macros.chi = specs["fileWideChi"] = self._getFileMetadata(
            )["fileWideChi"]
        compFamiliesWithPrecursors = self._getFileMetadata(
        )["compFamiliesWithPrecursors"]
        if compFamiliesWithPrecursors is not None and compFamiliesWithPrecursors.size:
            specs["numPrecursorFamilies"] = compFamiliesWithPrecursors[
                self.regionNumber]
        else:
            specs["numPrecursorFamilies"] = 0

        return specs
Esempio n. 3
0
 def __init__(self):
     _XSLibrary.__init__(self)
     self._regions = {}
     self.compxsMetadata = RegionXSMetadata()