Example #1
0
    def bkg_xs(self, nuc, temp=300):
        """Calculates the background cross section for a nuclide (nuc)

        Parameters
        ----------
        nuc : int
            Nuclide id.
        temp : float, optional
            The nuclide temperature in [K].

        Returns
        -------
        sig_b : array like
            Group wise background cross sections.
        """
        e_n = self.src_group_struct
        sig_b = np.zeros(self.src_ngroups, float)
        for i, a in self.atom_dens.items():
            if i == nuc:
                continue
            rtn = self.pointwise(i, 'total', temp)
            if rtn is None:
                continue
            sig_b += a * bins.pointwise_linear_collapse(e_n, rtn[0], rtn[1])
        return sig_b / self.atom_dens.get(nuc, 0.0)
Example #2
0
    def _load_reaction(self, nuc, rx, temp=300.0):
        """Loads reaction data from ACE files indexed by OpenMC.

        Parameters
        ----------
        nuc : int
            Nuclide id.
        rx : int
            Reaction id.
        temp : float, optional
            The nuclide temperature in [K].

        """
        rx = rxname.id(rx)
        try:
            mt = rxname.mt(rx)
        except RuntimeError:
            return None
        totrx = rxname.id('total')
        absrx = rxname.id('absorption')
        ace_tables = self._rank_ace_tables(nuc, temp=temp)
        lib = ntab = None
        for atab in ace_tables:
            if atab not in self.libs:
                lib = self.libs[atab] = ace.Library(atab.abspath or atab.path)
                lib.read(atab.name)
            lib = self.libs[atab]
            ntab = lib.tables[atab.name]
            if mt in ntab.reactions or rx == totrx or rx == absrx:
                break
            lib = ntab = None
        if lib is None:
            return None  # no reaction available
        E_g = self.src_group_struct
        E_points = ntab.energy
        if rx == totrx:
            rawdata = ntab.sigma_t
        elif rx == absrx:
            rawdata = ntab.sigma_a
        else:
            ntabrx = ntab.reactions[mt]
            if ntabrx.IE is None or ntabrx.IE == 0:
                rawdata = ntabrx.sigma
            else:
                rawdata = np.empty(len(E_points), dtype='f8')
                rawdata[:ntabrx.IE] = 0.0
                rawdata[ntabrx.IE:] = ntabrx.sigma
        if (E_g[0] <= E_g[-1] and E_points[-1] <= E_points[0]) or \
           (E_g[0] >= E_g[-1] and E_points[-1] >= E_points[0]):
            E_points = E_points[::-1]
            rawdata = rawdata[::-1]
        rxdata = bins.pointwise_linear_collapse(E_g, E_points, rawdata)
        return rxdata
Example #3
0
    def _load_reaction(self, nuc, rx, temp=300.0):
        """Loads reaction data from ACE files indexed by OpenMC.

        Parameters
        ----------
        nuc : int
            Nuclide id.
        rx : int
            Reaction id.
        temp : float, optional
            The nuclide temperature in [K].

        """
        rx = rxname.id(rx)
        try:
            mt = rxname.mt(rx)
        except RuntimeError:
            return None
        totrx = rxname.id('total')
        absrx = rxname.id('absorption')
        ace_tables = self._rank_ace_tables(nuc, temp=temp)
        lib = ntab = None
        for atab in ace_tables: 
            if atab not in self.libs:
                lib = self.libs[atab] = ace.Library(atab.abspath or atab.path)
                lib.read(atab.name)
            lib = self.libs[atab]
            ntab = lib.tables[atab.name]
            if mt in ntab.reactions or rx == totrx or rx == absrx:
                break
            lib = ntab = None
        if lib is None:
            return None  # no reaction available
        E_g = self.src_group_struct
        E_points = ntab.energy
        if rx == totrx:
            rawdata = ntab.sigma_t
        elif rx == absrx:
            rawdata = ntab.sigma_a
        else:
            ntabrx = ntab.reactions[mt] 
            if ntabrx.IE is None or ntabrx.IE == 0:
                rawdata = ntabrx.sigma
            else:
                rawdata = np.empty(len(E_points), dtype='f8')
                rawdata[:ntabrx.IE] = 0.0
                rawdata[ntabrx.IE:] = ntabrx.sigma
        if (E_g[0] <= E_g[-1] and E_points[-1] <= E_points[0]) or \
           (E_g[0] >= E_g[-1] and E_points[-1] >= E_points[0]):
            E_points = E_points[::-1]
            rawdata = rawdata[::-1]
        rxdata = bins.pointwise_linear_collapse(E_g, E_points, rawdata) 
        return rxdata
Example #4
0
    def self_shield(self, nuc, rx, temp, E_points, xs_points):
        """Calculates the self shielded cross section for a given nuclide
        and reaction. This calculation uses the Bonderanko method.

        Parameters
        ----------
        nuc : int
            Nuclide id.
        rx : int
            Reaction id.
        temp : float, optional
            The nuclide temperature in [K].
        E_points : array like
            The point wise energies.
        xs_points : array like
            Point wise cross sections

        Returns
        -------
        rxdata : array like
            collapsed self shielded cross section for nuclide nuc and reaction
            rx
        """
        sigb = self.bkg_xs(nuc, temp=temp)
        e_n = self.src_group_struct
        sig_b = np.ones(len(E_points), 'f8')
        for n in range(len(sigb)):
            sig_b[(e_n[n] <= E_points) & (E_points <= e_n[n + 1])] = sigb[n]
        rtn = self.pointwise(nuc, 'total', temp)
        if rtn is None:
            sig_t = 0.0
        else:
            sig_t = rtn[1]
        numer = bins.pointwise_linear_collapse(
            self.src_group_struct, E_points,
            xs_points / (E_points * (sig_b + sig_t)))
        denom = bins.pointwise_linear_collapse(
            self.src_group_struct, E_points,
            1.0 / (E_points * (sig_b + sig_t)))
        return numer / denom
Example #5
0
    def _load_reaction(self, nuc, rx, temp=300.0):
        """Loads reaction data from ACE files indexed by OpenMC.

        Parameters
        ----------
        nuc : int
            Nuclide id.
        rx : int
            Reaction id.
        temp : float, optional
            The nuclide temperature in [K].
        """
        rtn = self.pointwise(nuc, rx, temp=temp)
        if rtn is None:
            return
        E_points, rawdata = rtn
        E_g = self.src_group_struct
        if self.atom_dens.get(
                nuc, 0.0) > 1.0E19 and rx in self.self_shield_reactions:
            rxdata = self.self_shield(nuc, rx, temp, E_points, rawdata)
        else:
            rxdata = bins.pointwise_linear_collapse(E_g, E_points, rawdata)
        return rxdata
Example #6
0
def check_pointwise_linear_collapse(x_g, x, y, exp):
    obs = bins.pointwise_linear_collapse(x_g, x, y)
    assert_equal(len(exp), len(obs))
    assert_equal(len(x_g) - 1, len(obs))
    assert_array_almost_equal(exp, obs)
Example #7
0
def check_pointwise_linear_collapse(x_g, x, y, exp):
    obs = bins.pointwise_linear_collapse(x_g, x, y)
    assert_equal(len(exp), len(obs))
    assert_equal(len(x_g) - 1, len(obs))
    assert_array_almost_equal(exp, obs)