示例#1
0
文件: openmc_utils.py 项目: pyne/pyne
    def __init__(
        self,
        alias=None,
        awr=None,
        location=None,
        metastable=None,
        name=None,
        path=None,
        temperature=None,
        zaid=None,
        cross_sections_path=None,
    ):
        """Parameters
        ----------
        alias : str, optional
            ace_table attribute.
        awr : str, optional
            ace_table attribute.
        location : str, optional
            ace_table attribute.
        metastable : str, optional
            ace_table attribute.
        name : str, optional
            ace_table attribute.
        path : str, optional
            ace_table attribute.
        temperature : str, optional
            ace_table attribute.
        zaid : str, optional
            ace_table attribute. If set or non-zero then the nucid attribute
            will be set.
        cross_sections_path : str, optional
            If this and path are both present then the abspath attribute will be
            set.
        """

        super(AceTable, self).__init__()
        nuc = None
        if zaid is not None or zaid != "0":
            meta = "0" if metastable is None else metastable
            nuc = nucname.zzaaam_to_id(zaid + meta)
            if nuc == 0:
                pass
            elif not nucname.isnuclide(
                    nuc):  # then it's in MCNP metastable form
                nuc = nucname.mcnp_to_id(zaid)
        self.nucid = nuc
        abspath = None
        if path is not None and cross_sections_path is not None:
            if os.path.isdir(cross_sections_path):
                d = cross_sections_path
            else:
                d = os.path.dirname(cross_sections_path)
            abspath = os.path.abspath(os.path.join(d, path))
        self.abspath = abspath
示例#2
0
 def __init__(self, alias=None, awr=None, location=None, metastable=None,
              name=None, path=None, temperature=None, zaid=None,
              cross_sections_path=None):
     """Parameters
     ----------
     alias : str, optional
         ace_table attribute.
     awr : str, optional
         ace_table attribute.
     location : str, optional
         ace_table attribute.
     metastable : str, optional
         ace_table attribute.
     name : str, optional
         ace_table attribute.
     path : str, optional
         ace_table attribute.
     temperature : str, optional
         ace_table attribute.
     zaid : str, optional
         ace_table attribute. If set or non-zero then the nucid attribute
         will be set.
     cross_sections_path : str, optional
         If this and path are both present then the abspath attribute will be
         set.
     """
     super(AceTable, self).__init__()
     nuc = None
     if zaid is not None or zaid != '0':
         meta = "0" if metastable is None else metastable
         nuc = nucname.zzaaam_to_id(zaid + meta)
         if nuc == 0:
             pass
         elif not nucname.isnuclide(nuc):  # then it's in MCNP metastable form
             nuc = nucname.mcnp_to_id(zaid)
     self.nucid = nuc
     abspath = None
     if path is not None and cross_sections_path is not None:
         if os.path.isdir(cross_sections_path):
             d = cross_sections_path
         else:
             d = os.path.dirname(cross_sections_path)
         abspath = os.path.abspath(os.path.join(d, path))
     self.abspath = abspath
core_adensity_after = np.array(f['core adensity after reproc'])
core_adensity_before = np.array(f['core adensity before reproc'])
keff_boc = np.array(f['keff_BOC'])
keff_eoc = np.array(f['keff_EOC'])
tank_adensity = np.array(f['tank adensity'])
noble_adensity = np.array([])
iso_codes = np.array(f['iso_codes'])
iso_zai = []
iso_names = []
for code in iso_codes:
    code = code.decode()
    if '.09c' in code:
        code = code.replace('.09c', '')
        code = nucname.zzzaaa_to_id(int(code))
    else:
        code = nucname.zzaaam_to_id(int(code))
    iso_zai.append(nucname.zzaaam(code))
    iso_names.append(nucname.name(code))
iso_zai = np.array(iso_zai)
iso_names = np.array(iso_names)

shape = core_adensity_after.shape


def adens_to_mass(fuel_vol, array, iso_names):
    shape = array.shape
    mass_array = np.zeros(shape)
    for num, row in enumerate(array):
        mat_dict = {}
        mass_comp = np.zeros(len(row))
        for indx, val in enumerate(row):
示例#4
0
def decay_data(t9, nlb=(1, 2, 3), nucs=None):
    """Gets decay data from a TAPE9.

    Parameters
    ----------
    t9 : dict
        A TAPE9 dict that contains the decay data.
    nlb : tuple of ints, optional
        The decay library numbers. Usually this is just (1, 2, 3).
    nucs : set or None, optional
        The known set of nuclides.

    Returns
    -------
    nucs : set
        The set of nuclide names.
    decay_consts : dict
        Mapping from nuclide names to decay constants [1/sec]
    gammas : dict
        Mapping from (i, j) nuclide name tuples to the branch ratio
        fraction. This is [unitless] and the sum over all j for a given
        i is guarenteed to sum to 1.
    """
    nucs = set() if nucs is None else nucs
    decay_consts = {}
    gammas = {}
    gammas_alphas = {}
    for n in nlb:
        decay_consts.update({
            origen_to_name(nuc): LN2 / val
            for nuc, val in t9[n]['half_life'].items() if nuc != 162500
        })
        for key in t9[n]:
            if not key.startswith('frac_') or key == 'frac_natural_abund' or  \
                                              key == 'frac_spont_fiss':
                continue
            for nuc, val in t9[n][key].items():
                if val == 0:
                    continue  # forbidden decay
                nname = origen_to_name(nuc)
                if decay_consts[nname] == 0:
                    continue  # stable nuclide
                poff = PAROFF if int(nuc) % 10 == 0 else PAROFFM
                child = nucname.zzaaam_to_id(int(nuc)) + poff[key]
                cname = nucname.name(child)
                nucs.add(nname)
                nucs.add(cname)
                gammas[nname, cname] = val
                if key == 'frac_alpha':
                    gammas_alphas[nname, "He4"] = val
    # add β- decays
    for nname, val in decay_consts.items():
        if val == 0:
            continue  # stable nuclide
        gamma_total = sum([v for (n, c), v in gammas.items() if n == nname])
        if gamma_total < 1.0:
            parid = nucname.id(nname)
            poff = PAROFF if parid % 10 == 0 else PAROFFM
            child = parid + poff['frac_beta_minus']
            cname = nucname.name(child)
            gammas[nname, cname] = 1.0 - gamma_total
            gamma_total = 1.0
            nucs.add(nname)
            nucs.add(cname)
        if gamma_total > 1.0:
            biggest_gamma = max([(i, j) for i, j in gammas if i == nname],
                                key=lambda t: gammas[t])
            gammas[biggest_gamma] = gammas[biggest_gamma] + 1 - gamma_total
    return nucs, decay_consts, gammas, gammas_alphas
示例#5
0
def origen_to_name(nuc):
    """Takes a nuclide in Origen format and returns it's human readable name."""
    return nucname.name(nucname.zzaaam_to_id(int(nuc)))
示例#6
0
def cross_section_data(t9, nlb=None, nucs=None):
    """Gets decay data from a TAPE9.

    Parameters
    ----------
    t9 : dict
        A TAPE9 dict that contains the decay data.
    nlb : tuple of ints or None, optional
        The cross section library numbers. If None, this will attempt to discover
        the numbers in the library.
    nucs : set or None, optional
        The known set of nuclides.

    Returns
    -------
    nucs : set
        The set of nuclide names.
    sigma_ij : dict
        Mapping from (i, j) nuclide name tuples to the cross section for this
        reaction. Note that this does not include the fission cross section [barns].
    sigma_fission : dict
        Mapping from fissionable nuclide names to the fission cross section [barns].
    fission_product_yields : dict
        Mapping from (i, j) nuclide name tuples to the fission product yields for
        that nuclide.
    """
    if rxname.child("Am242M", "gamma") != 952430000:
        raise RuntimeError("Pyne version too old. Need version 0.5.4 or newer")
    nlb = find_nlb(t9, nlb=nlb)
    nucs = set() if nucs is None else nucs
    sigma_ij = {}
    alpha_ij = {}
    sigma_fission = {}
    fission_product_yields = {}
    for n in nlb:
        # grab sigma_ij cross sections
        for rx in t9[n]:
            if not rx.startswith('sigma_') or rx == 'sigma_f':
                continue
            _, _, orx = rx.partition('_')
            xs_rs = ORIGEN_TO_XS[orx]
            for nuc in t9[n][rx]:
                val = t9[n][rx][nuc]
                if val == 0:
                    continue
                nname = nucname.name(int(nuc))
                try:
                    child = nucname.name(rxname.child(nname, xs_rs))
                except RuntimeError:
                    continue
                nucs.add(nname)
                nucs.add(child)
                sigma_ij[nname, child] = val
                if rx == 'sigma_alpha':
                    alpha_ij[nname, "He4"] = val
        # grab the fission cross section
        if 'sigma_f' in t9[n]:
            rx = 'sigma_f'
            for nuc in t9[n][rx]:
                val = t9[n][rx][nuc]
                if val == 0:
                    continue
                nname = nucname.name(int(nuc))
                nucs.add(nname)
                sigma_fission[nname] = val
        # grab the fission product yields
        for rx in t9[n]:
            if not rx.endswith('_fiss_yield'):
                continue
            fromnuc, *_ = rx.partition('_')
            fromnuc = nucname.name(fromnuc)
            for k, v in t9[n][rx].items():
                if v == 0:
                    continue
                tonuc = nucname.name(nucname.zzaaam_to_id(int(k)))
                # origen yields are in percent
                nucs.add(fromnuc)
                nucs.add(tonuc)
                fission_product_yields[fromnuc, tonuc] = v / 100
    return nucs, sigma_ij, sigma_fission, fission_product_yields, alpha_ij