コード例 #1
0
ファイル: test_transmuters.py プロジェクト: pyne/pyne
def test_transmuters_cram():
    n0 = {"H3": 1.0}
    A = -cram.DECAY_MATRIX * data.half_life("H3")
    n1 = transmuters.cram(A, n0, order=16)
    assert_equal(2, len(n1))
    assert_almost_equal(0.5, n1[nucname.id("H3")])
    assert_almost_equal(0.5, n1[nucname.id("He3")])
コード例 #2
0
def get_composition_fresh(in_list, burnup):
    """ Returns a dictionary of isotope and composition (in mass fraction)
    using vision_recipes for fresh UOX

    Parameters
    ---------
    in_list: list
        list file containing vision_recipes data.
    burnup: int
        burnup

    Returns
    -------
    data_dict: dictionary
        dictionary with key: isotope, and value: composition.
    """
    data_dict = {}
    for i in range(len(in_list)):
        if i > 1:
            if burnup == 33:
                data_dict.update({nn.id(in_list[i][0]): float(in_list[i][1])})
            elif burnup == 51:
                data_dict.update({nn.id(in_list[i][0]): float(in_list[i][3])})
            else:
                data_dict.update({nn.id(in_list[i][0]): float(in_list[i][5])})
    return data_dict
コード例 #3
0
ファイル: data_source.py プロジェクト: FlanFlanagan/pyne
    def reaction(self, nuc, rx, nuc_i = None):
        """Get reaction data.

        Parameters
        ----------
        nuc : int or str
            Nuclide containing the reaction.
        rx : int or str
            Desired reaction
        nuc_i : int or str
            Nuclide containing the reaction. Defaults to nuc.
        group_bounds : tuple
            Low and high energy bounds of the new group.

        Returns
        ----------
        rxdict : dict
            Dictionary containing source group structure, energy values, cross-
            section data, and interpolation data."""
        if nuc_i is None:
            nuc_i = nuc
        nuc = nucname.id(nuc)
        rx = rxname.mt(rx)
        nuc_i = nucname.id(nuc_i)
        if (nuc, rx, nuc_i) not in self.rxcache:
            self._load_reaction(nuc, rx, nuc_i)
        return self.rxcache[nuc, rx, nuc_i]
コード例 #4
0
def get_composition_spent(in_list, burnup):
    """ Returns a dictionary of isotope and composition (in mass fraction)
    using vision_recipes for spent nuclear fuel

    Parameters
    ---------
    in_list: list
        list containing vision_recipes data
    burnup: int
        burnup

    Returns
    -------
    data_dict: dict
        dictionary with key=[isotope],
        and value=[composition]
    """
    data_dict = {}
    for i in range(len(in_list)):
        if i > 1:
            if burnup == 33:
                data_dict.update({nn.id(in_list[i][0]):
                                  float(in_list[i][2])})
            elif burnup == 51:
                data_dict.update({nn.id(in_list[i][0]):
                                  float(in_list[i][4])})
            else:
                data_dict.update({nn.id(in_list[i][0]):
                                  float(in_list[i][6])})
    return data_dict
コード例 #5
0
def test_zzllaaam_to_id():
    assert_equal(nucname.zzllaaam_to_id("94-Pu-239"), nucname.id("Pu-239"))
    assert_equal(nucname.zzllaaam_to_id("95-Am-242m"), nucname.id("Am-242m"))

    assert_equal(nucname.zzllaaam_to_id("94-Pu-239"), nucname.id("Pu-239"))
    assert_equal(nucname.zzllaaam_to_id("95-Am-242"), nucname.id("Am-242"))
    assert_equal(nucname.zzllaaam_to_id("95-Am-242m"), nucname.id("Am-242m"))
コード例 #6
0
ファイル: data_source.py プロジェクト: zxkjack123/pyne
    def reaction(self, nuc, rx, nuc_i=None):
        """Get reaction data.

        Parameters
        ----------
        nuc : int or str
            Nuclide containing the reaction.
        rx : int or str
            Desired reaction
        nuc_i : int or str
            Nuclide containing the reaction. Defaults to nuc.
        group_bounds : tuple
            Low and high energy bounds of the new group.

        Returns
        ----------
        rxdict : dict
            Dictionary containing source group structure, energy values, cross-
            section data, and interpolation data."""
        if nuc_i is None:
            nuc_i = nuc
        nuc = nucname.id(nuc)
        rx = rxname.mt(rx)
        nuc_i = nucname.id(nuc_i)
        if (nuc, rx, nuc_i) not in self.rxcache:
            self._load_reaction(nuc, rx, nuc_i)
        return self.rxcache[nuc, rx, nuc_i]
コード例 #7
0
ファイル: atomic_mass.py プロジェクト: pyne/pyne
def make_atomic_mass_table(nuc_data, build_dir=""):
    """Makes an atomic mass table in the nuc_data library.

    Parameters
    ----------
    nuc_data : str
        Path to nuclide data file.
    build_dir : str
        Directory to place html files in.
    """
    # Grab raw data
    atomic_abund = get_isotopic_abundances()
    atomic_masses = parse_atomic_mass_adjustment(build_dir)

    A = {}

    # Add normal isotopes to A
    for nuc, mass, error in atomic_masses:
        if nuc in atomic_abund:
            A[nuc] = nuc, mass, error, atomic_abund[nuc]
        else:
            A[nuc] = nuc, mass, error, 0.0

    # Add naturally occuring elements
    for element in nucname.name_zz:
        nuc = nucname.id(element)
        A[nuc] = nuc, 0.0, 0.0, 0.0

    for nuc, abund in atomic_abund.items():
        zz = nucname.znum(nuc)
        element_zz = nucname.id(zz)
        element = nucname.zz_name[zz]

        _nuc, nuc_mass, _error, _abund = A[nuc]
        elem_zz, elem_mass, _error, _abund = A[element_zz]

        new_elem_mass = elem_mass + (nuc_mass * abund)
        A[element_zz] = element_zz, new_elem_mass, 0.0, float(
            0.0 < new_elem_mass)

    A = sorted(A.values(), key=lambda x: x[0])

    # Open the HDF5 File
    kdb = tb.open_file(nuc_data, "a", filters=BASIC_FILTERS)

    # Make a new the table
    Atable = kdb.create_table(
        "/",
        "atomic_mass",
        atomic_mass_desc,
        "Atomic Mass Data [amu]",
        expectedrows=len(A),
    )
    Atable.append(A)

    # Ensure that data was written to table
    Atable.flush()

    # Close the hdf5 file
    kdb.close()
コード例 #8
0
ファイル: test_nucname.py プロジェクト: kellyrowland/pyne
def test_zzllaaam_to_id():
    assert_equal(nucname.zzllaaam_to_id("94-Pu-239"), nucname.id("Pu-239"))
    assert_equal(nucname.zzllaaam_to_id("95-Am-242m"), nucname.id("Am-242m"))

    assert_equal(nucname.zzllaaam_to_id("94-Pu-239"), nucname.id("Pu-239"))
    assert_equal(nucname.zzllaaam_to_id("95-Am-242"), nucname.id("Am-242"))
    assert_equal(nucname.zzllaaam_to_id("95-Am-242m"), nucname.id("Am-242m"))
コード例 #9
0
ファイル: data_source.py プロジェクト: terrence1666/pyne
    def _load_reactions(self, num_dens, phi_tot):
        """Loads the group structure from a tally in openMC. It is
        assumed that all tallies have the same group structure

        Parameters
        ----------
        state_point: openMC statepoint file
            The statepoint file that will be used to load the reaction
            rates to determine the microscopic cross sections for the
            statepoint.
        num_dens: map of int to float
            A map containing the number densities of the nuclides in the
            material used in the statepoint.
        phi_tot: array of floats
            The total flux within the reactor
        """
        for tally in self.tallies:
            sp = self.state_point.tallies[tally]
            for nuclide in sp.nuclides:
                for score in sp.scores:
                    self.reactions[nucname.id(nuclide.name),
                                   score] = sp.get_values([score], [], [], [
                                       nuclide.name
                                   ]).flatten() * self.particles
                    weight = 1.0E24 / abs(
                        phi_tot * num_dens[nucname.id(nuclide.name)])
                    self.reactions[nucname.id(nuclide.name), score] *= weight
コード例 #10
0
ファイル: atomic_mass.py プロジェクト: FlanFlanagan/pyne
def make_atomic_mass_table(nuc_data, build_dir=""):
    """Makes an atomic mass table in the nuc_data library.

    Parameters
    ----------
    nuc_data : str
        Path to nuclide data file.
    build_dir : str
        Directory to place html files in.
    """
    # Grab raw data
    atomic_abund = get_isotopic_abundances()
    atomic_masses = parse_atomic_mass_adjustment(build_dir)

    A = {}

    # Add normal isotopes to A
    for nuc, mass, error in atomic_masses:
        if nuc in atomic_abund:
            A[nuc] = nuc, mass, error, atomic_abund[nuc]
        else:
            A[nuc] = nuc, mass, error, 0.0

    # Add naturally occuring elements
    for element in nucname.name_zz:
        nuc = nucname.id(element)
        A[nuc] = nuc, 0.0, 0.0, 0.0

    for nuc, abund in atomic_abund.items():
        zz = nucname.znum(nuc)
        element_zz = nucname.id(zz)
        element = nucname.zz_name[zz]

        _nuc, nuc_mass, _error, _abund = A[nuc]
        elem_zz, elem_mass, _error, _abund = A[element_zz]

        new_elem_mass = elem_mass + (nuc_mass * abund)
        A[element_zz] = element_zz, new_elem_mass, 0.0, float(0.0 < new_elem_mass)

    A = sorted(A.values(), key=lambda x: x[0])

    # Open the HDF5 File
    kdb = tb.openFile(nuc_data, 'a', filters=BASIC_FILTERS)

    # Make a new the table
    Atable = kdb.createTable("/", "atomic_mass", atomic_mass_desc,
                             "Atomic Mass Data [amu]", expectedrows=len(A))
    Atable.append(A)

    # Ensure that data was written to table
    Atable.flush()

    # Close the hdf5 file
    kdb.close()
コード例 #11
0
ファイル: wimsdfpy.py プロジェクト: kellyrowland/pyne
 def handle_endtag(self, tag):
     if tag == "tr":
         row = self._currrow
         self._currrow = []
         if len(row) == 7 and row[0] == "Fission" and row[1] == "product":
             self._fromnucs = [nucname.id(x) for x in row[-4:]]
             return
         if len(row) != 6:
             return
         if row[0].endswith("FP"):
             return
         tonuc = nucname.id(row[0].split("-", 1)[1])
         self.fission_product_yields += zip(self._fromnucs, [tonuc] * 4, map(float, row[-4:]))
コード例 #12
0
ファイル: pre.py プロジェクト: bright-dev/bright
    def _ensure_nl(self, rc):
        # Make nuclide lists
        if isinstance(rc.core_load_nucs, basestring):
            core_load = load_nuc_file(rc.core_load_nucs)
        else:
            core_load = [nucname.id(nuc) for nuc in rc.core_load_nucs]
        rc.core_load = sorted(set(core_load))

        if isinstance(rc.core_transmute_nucs, basestring):
            core_transmute = load_nuc_file(rc.core_transmute_nucs)
        else:
            core_transmute = [nucname.id(nuc) for nuc in rc.core_transmute_nucs]
        rc.core_transmute = sorted(set(core_transmute))
コード例 #13
0
 def handle_endtag(self, tag):
     if tag == 'tr':
         row = self._currrow
         self._currrow = []
         if len(row) == 7 and row[0] == 'Fission' and row[1] == 'product':
             self._fromnucs = [nucname.id(x) for x in row[-4:]]
             return
         if len(row) != 6:
             return
         if row[0].endswith('FP'):
             return
         tonuc = nucname.id(row[0].split('-', 1)[1])
         self.fission_product_yields += zip(self._fromnucs, [tonuc] * 4,
                                            map(float, row[-4:]))
コード例 #14
0
 def handle_endtag(self, tag):
     if tag == "tr":
         row = self._currrow
         self._currrow = []
         if len(row) == 7 and row[0] == "Fission" and row[1] == "product":
             self._fromnucs = [nucname.id(x) for x in row[-4:]]
             return
         if len(row) != 6:
             return
         if row[0].endswith("FP"):
             return
         tonuc = nucname.id(row[0].split("-", 1)[1])
         self.fission_product_yields += zip(self._fromnucs, [tonuc] * 4,
                                            map(float, row[-4:]))
コード例 #15
0
ファイル: wimsdfpy.py プロジェクト: FlanFlanagan/pyne
 def handle_endtag(self, tag):
     if tag == 'tr':
         row = self._currrow
         self._currrow = []
         if len(row) == 7 and row[0] == 'Fission' and row[1] == 'product':
             self._fromnucs = [nucname.id(x) for x in row[-4:]]
             return
         if len(row) != 6:
             return
         if row[0].endswith('FP'):
             return
         tonuc = nucname.id(row[0].split('-', 1)[1])
         self.fission_product_yields += zip(self._fromnucs, [tonuc]*4, 
                                            map(float, row[-4:]))
コード例 #16
0
    def _copy_radio_abundances(self):
        """Copies the radioactive isotopes onto the corresponding stable
        elements. This routine is intended for uses of the mapper during which
        the decay is neglected

        Notes
        -----
        Must be called after _remap_abundances.

        Raises
        ------
        AttributeError if called before _remap_abundances
        """
        try:
            self.radio_abundances_interp
        except AttributeError:
            logger.critical("Abundances must be remapped before radioactive:"
                            " isotopes are copied onto the stable elements")
            raise AttributeError("no radio_abundances_interp; call"
                                 " _remap_abundances first")

        for ident in self.radio_abundances_interp.keys():
            elemid = nucname.id(ident)
            z = nucname.znum(elemid)
            self.abundances_interp[z] = \
                self.abundances_interp[z] + self.radio_abundances_interp[ident]
コード例 #17
0
ファイル: test_serpent.py プロジェクト: pyne/pyne
def test_parse_dep1():
    """
    Tests the parse_dep function with a serpent 1 _dep.m
    file.  In this, the _VOLUME variable is a float.
    """
    dep = serpent.parse_dep("sample1_dep.m")
    nuc_set = set([nucname.id(int(nuc)) for nuc in dep["ZAI"][:-2]])
    shape = (len(dep["ZAI"]), len(dep["DAYS"]))
    for key in dep:
        if key.endswith("_VOLUME"):
            assert_true(isinstance(dep[key], float))
        elif key.endswith("_MATERIAL"):
            assert_equal(len(dep[key]), shape[1])
            for n in range(shape[1]):
                assert_equal(nuc_set, set(dep[key][n].comp.keys()))
        elif key.startswith("MAT_") and key.endswith("_BURNUP"):
            assert_equal(dep[key].shape, (1, shape[1]))
        elif key.startswith("MAT_") or key.startswith("TOT_"):
            assert_equal(dep[key].shape, shape)

    # Check values
    assert_array_equal(dep["BU"], [0.00000e00, 8.40000e01, 1.68000e02])
    assert_equal(dep["i952421"], 123)
    assert_array_equal(dep["MAT_fuelp1r2_H"][3],
                       [0.00000e00, 5.56191e-11, 3.22483e-10])
コード例 #18
0
    def _decay_abundances(self):
        """Determines the decay of all radioactive isotopes. Afterwards their
        mass fractions are added to the stable elements.

        Notes
        -----
        Must be called after _remap_abundances.

        Raises
        ------
        AttributeError if called before _remap_abundances
        """
        try:
            self.radio_abundances_interp
        except AttributeError:
            logger.critical("Abundances must be remapped before decay is"
                            " handled")
            raise AttributeError("no radio_abundances_interp; call "
                                 "_remap_abundances first")

        for i in xrange(self.N_interp):
            comp = {}
            mass = 0
            for ident in self.radio_abundances_interp.keys():
                Xi = self.radio_abundances_interp[ident][i]
                mass += Xi
                comp[nucname.id(ident)] = Xi
            inp = material.Material(comp, mass=mass)
            res = inp.decay(
                (self.t - self.orig.t).to("s").value).mult_by_mass()

            for item in res.items():
                z = nucname.znum(item[0])
                self.abundances_interp[z][i] = \
                    self.abundances_interp[z][i] + item[1]
コード例 #19
0
ファイル: test_openmc.py プロジェクト: smpark7/pyne
def test_ace_table_init():
    atab = openmc_utils.AceTable(zaid='92235', path='U235.ace',
                           cross_sections_path='/tmp/cross_sections.xml')
    assert_equal('92235', atab.zaid)
    assert_equal('U235.ace', atab.path)
    assert_equal('/tmp/U235.ace', atab.abspath)
    assert_equal(nucname.id('U235'), atab.nucid)
コード例 #20
0
def test_parse_dep2():
    '''
    Tests the parse_dep function with a simple _dep.m file,
    sample2_dep.m, which was generated using the 2d pin burnup
    example from the serpent wiki, changed to have fewer depsteps.
    In this, the _VOLUME variable is a numpy array.
    http://serpent.vtt.fi/mediawiki/index.php/2D_PWR_pin-cell_burnup_example
    '''
    dep = serpent.parse_dep('sample2_dep.m')
    nuc_set = set([nucname.id(int(nuc)) for nuc in dep['ZAI'][:-2]])
    shape = (len(dep['ZAI']), len(dep['DAYS']))
    for key in dep:
        if key.endswith('_VOLUME'):
            assert_equal(len(dep[key]), shape[1])
        elif key.endswith('_vol'):
            assert_equal(len(dep[key]), shape[1])
        elif key.endswith('_MATERIAL'):
            assert_equal(len(dep[key]), shape[1])
            for n in range(shape[1]):
                assert_equal(nuc_set, set(dep[key][n].comp.keys()))
        elif key.endswith('_BURNUP'):
            assert_equal(len(dep[key]), shape[1])
        elif key.startswith('MAT_') or key.startswith('TOT_'):
            assert_equal(len(dep[key]), shape[0])
            assert_equal(len(dep[key][0]), shape[1])

    # Check values
    assert_array_equal(dep['BU'], [ 0.00000E+00, 1.00000E-01, 1.00000E+00 ])
    assert_equal(dep['i621510'], 22)
    assert_array_equal(dep['MAT_fuel_A'][6], [0.00000E+00, 1.73176E+05, 4.96485E+06])
コード例 #21
0
ファイル: data_source.py プロジェクト: FlanFlanagan/pyne
    def _load_reaction(self, nuc, rx, nuc_i, src_phi_g=None, temp=300.0):
        """Note: ENDF data does not use temperature information (temp)

        Parameters
        ----------
        nuc : int
            Nuclide in id form.
        rx : int or str
            Reaction MT # in nnnm form.
            OR:
            Reaction key: 'gamma', 'alpha', 'p', etc.
        nuc_i: : int
            Isotope in id form (optional). Default is None.

        Returns
        -------
        rxdata: ndarray of floats, len ngroups
        """
        nuc = nucname.id(nuc)
        rx = rxname.mt(rx)
        if nuc_i not in self.library.structure[nuc]['data']:
            self.library._read_res(nuc)
        rxdict = self.library.get_xs(nuc, rx, nuc_i)[0]
        rxdict['_src_phi_g'] = src_phi_g
        self.rxcache[nuc, rx, nuc_i] = rxdict
        self._load_group_structure(nuc, rx, nuc_i)
        return rxdict
コード例 #22
0
ファイル: data_source.py プロジェクト: FlanFlanagan/pyne
    def reaction(self, nuc, rx, temp=300.0):
        """Gets the cross section data for this reaction channel either directly
        from the data source or from the rxcache.

        Parameters
        ----------
        nuc : int or str
            A nuclide.
        rx : int or str
            Reaction id or name.
        temp : float, optional
            Temperature [K] of material, defaults to 300.0.

        Returns
        -------
        rxdata : ndarray
            Source cross section data, length src_ngroups.

        """
        nuc = nucname.id(nuc)
        rx = rxname.id(rx)
        rxkey = (nuc, rx, temp) if self._USES_TEMP else (nuc, rx)
        if rxkey not in self.rxcache:
            self.rxcache[rxkey] = None if self.fullyloaded \
                                       else self._load_reaction(nuc, rx, temp)
        return self.rxcache[rxkey]
コード例 #23
0
ファイル: test_serpent.py プロジェクト: pyne/pyne
def test_parse_dep2():
    """
    Tests the parse_dep function with a simple _dep.m file,
    sample2_dep.m, which was generated using the 2d pin burnup
    example from the serpent wiki, changed to have fewer depsteps.
    In this, the _VOLUME variable is a numpy array.
    http://serpent.vtt.fi/mediawiki/index.php/2D_PWR_pin-cell_burnup_example
    """
    dep = serpent.parse_dep("sample2_dep.m")
    nuc_set = set([nucname.id(int(nuc)) for nuc in dep["ZAI"][:-2]])
    shape = (len(dep["ZAI"]), len(dep["DAYS"]))
    for key in dep:
        if key.endswith("_VOLUME"):
            assert_equal(len(dep[key]), shape[1])
        elif key.endswith("_vol"):
            assert_equal(len(dep[key]), shape[1])
        elif key.endswith("_MATERIAL"):
            assert_equal(len(dep[key]), shape[1])
            for n in range(shape[1]):
                assert_equal(nuc_set, set(dep[key][n].comp.keys()))
        elif key.endswith("_BURNUP"):
            assert_equal(len(dep[key]), shape[1])
        elif key.startswith("MAT_") or key.startswith("TOT_"):
            assert_equal(len(dep[key]), shape[0])
            assert_equal(len(dep[key][0]), shape[1])

    # Check values
    assert_array_equal(dep["BU"], [0.00000e00, 1.00000e-01, 1.00000e00])
    assert_equal(dep["i621510"], 22)
    assert_array_equal(dep["MAT_fuel_A"][6],
                       [0.00000e00, 1.73176e05, 4.96485e06])
コード例 #24
0
ファイル: ensdf.py プロジェクト: NukespudWork/pyne
def _to_id(nuc):
    if not 'NN' in nuc:
        nucid = nucname.id(nuc.strip())
    else:
        warn('Neutron data not supported!')
        return 0
    return nucid
コード例 #25
0
def _build_matrix(N):
    """This function  builds burnup matrix, A. Decay only."""

    A = np.zeros((len(N), len(N)))

    # convert N to id form
    N_id = []
    for i in range(len(N)):
        if isinstance(N[i], str):
            ID = nucname.id(N[i])
        else:
            ID = N[i]
        N_id.append(ID)

    sds = SimpleDataSource()

    # Decay
    for i in range(len(N)):
        A[i, i] -= decay_const(N_id[i])

        # Find decay parents
        for k in range(len(N)):
            if N_id[i] in decay_children(N_id[k]):
                A[i,
                  k] += branch_ratio(N_id[k], N_id[i]) * decay_const(N_id[k])
    return A
コード例 #26
0
ファイル: q_val.py プロジェクト: terrence1666/pyne
def read_row(row):
    """Returns a list of the format [int, float, float] for each nuclide.

    Parameters
    ----------
    row : tuple
        One entry in a q_val file.
    """

    # Create tuple
    entry = ()

    # Evaluate each component of the given row
    if row[0] == 'Nuclide' or len(row[0].strip()) == 0:
        return
    nuclide = nucname.id(''.join(row[0:2]).replace(' ', ''))
    if len(row[2]) == 0:
        q_val = 0.0
    else:
        q_val = float(row[2])
    if len(row[3]) == 0:
        gamma_frac = 0.0
    else:
        gamma_frac = float(row[3])
    entry = (nuclide, q_val, gamma_frac)

    return entry
コード例 #27
0
ファイル: test_openmc.py プロジェクト: FlanFlanagan/pyne
def test_ace_table_init():
    atab = openmc.AceTable(zaid='92235', path='U235.ace',
                           cross_sections_path='/tmp/cross_sections.xml')
    assert_equal('92235', atab.zaid)
    assert_equal('U235.ace', atab.path)
    assert_equal('/tmp/U235.ace', atab.abspath)
    assert_equal(nucname.id('U235'), atab.nucid)
コード例 #28
0
ファイル: q_val.py プロジェクト: NukespudWork/pyne
def read_row(row):
    """Returns a list of the format [int, float, float] for each nuclide.
    
    Parameters
    ----------
    row : list
        One entry in a q_val file.
    """

    # Create tuple
    entry = ()

    # Evaluate each component of the given row
    if row[0] == 'Nuclide' or len(row[0].strip()) == 0:
        return
    nuclide = nucname.id(''.join(row[0:2]).replace(' ', ''))
    if len(row[2]) == 0:
        q_val = 0.0
    else:
        q_val = float(row[2])
    if len(row[3]) == 0:
        gamma_frac = 0.0
    else:   
        gamma_frac = float(row[3])
    entry = (nuclide, q_val, gamma_frac)

    return entry
コード例 #29
0
ファイル: data_source.py プロジェクト: zxkjack123/pyne
    def reaction(self, nuc, rx, temp=300.0):
        """Gets the cross section data for this reaction channel either directly
        from the data source or from the rxcache.

        Parameters
        ----------
        nuc : int or str
            A nuclide.
        rx : int or str
            Reaction id or name.
        temp : float, optional
            Temperature [K] of material, defaults to 300.0.

        Returns
        -------
        rxdata : ndarray
            Source cross section data, length src_ngroups.

        """
        nuc = nucname.id(nuc)
        rx = rxname.id(rx)
        rxkey = (nuc, rx, temp) if self._USES_TEMP else (nuc, rx)
        if rxkey not in self.rxcache:
            self.rxcache[rxkey] = None if self.fullyloaded \
                                       else self._load_reaction(nuc, rx, temp)
        return self.rxcache[rxkey]
コード例 #30
0
ファイル: data_source.py プロジェクト: zxkjack123/pyne
    def _load_reaction(self, nuc, rx, nuc_i, src_phi_g=None, temp=300.0):
        """Note: ENDF data does not use temperature information (temp)

        Parameters
        ----------
        nuc : int
            Nuclide in id form.
        rx : int or str
            Reaction MT # in nnnm form.
            OR:
            Reaction key: 'gamma', 'alpha', 'p', etc.
        nuc_i: : int
            Isotope in id form (optional). Default is None.

        Returns
        -------
        rxdata: ndarray of floats, len ngroups
        """
        nuc = nucname.id(nuc)
        rx = rxname.mt(rx)
        if nuc_i not in self.library.structure[nuc]['data']:
            self.library._read_res(nuc)
        rxdict = self.library.get_xs(nuc, rx, nuc_i)[0]
        rxdict['_src_phi_g'] = src_phi_g
        self.rxcache[nuc, rx, nuc_i] = rxdict
        self._load_group_structure(nuc, rx, nuc_i)
        return rxdict
コード例 #31
0
def _to_id(nuc):
    if not 'NN' in nuc:
        nucid = nucname.id(nuc.strip())
    else:
        warn('Neutron data not supported!')
        return 0
    return nucid
コード例 #32
0
ファイル: endl.py プロジェクト: opotowsky/pyne
    def get_rx(self, nuc, p_in, rdesc, rprop, x1=None, p_out=None):
        """get_rx(nuc, p_in, rdesc, rprop, x1=None, p_out=None)
        Grab the data for one reaction type.

        Parameters
        ----------
        nuc : int
            id form of nucleus to read from.
        p_in : int
            ENDL incident particle designator
        rdesc : int
            ENDL reaction descriptor
        rprop : int
            ENDL reaction property
        x1 : int or None
            ENDL atomic subshell indicator (if applicable)
        yo : int or None
            ENDL outgoing particle designator (if applicable)

        Returns
        -------
        data : NumPy array
            Contains the reaction data in a n-by-m-dimensional array. The
            values of n and m depend on the reaction property rprop.
        """
        nuc = nucname.id(nuc)
        if nuc in self.structure:
            return self._read_nuc_pin_rdesc_rprop(nuc, p_in, rdesc, rprop, x1,
                                                  p_out)
        else:
            raise ValueError('Nucleus {} does not exist.'.format(nuc))
コード例 #33
0
    def _copy_radio_abundances(self):
        """Copies the radioactive isotopes onto the corresponding stable
        elements. This routine is intended for uses of the mapper during which
        the decay is neglected

        Notes
        -----
        Must be called after _remap_abundances.

        Raises
        ------
        AttributeError if called before _remap_abundances
        """
        try:
            self.radio_abundances_interp
        except AttributeError:
            logger.critical("Abundances must be remapped before radioactive:"
                            " isotopes are copied onto the stable elements")
            raise AttributeError("no radio_abundances_interp; call"
                                 " _remap_abundances first")

        for ident in self.radio_abundances_interp.keys():
            elemid = nucname.id(ident)
            z = nucname.znum(elemid)
            self.abundances_interp[z] = \
                self.abundances_interp[z] + self.radio_abundances_interp[ident]
コード例 #34
0
    def _decay_abundances(self):
        """Determines the decay of all radioactive isotopes. Afterwards their
        mass fractions are added to the stable elements.

        Notes
        -----
        Must be called after _remap_abundances.

        Raises
        ------
        AttributeError if called before _remap_abundances
        """
        try:
            self.radio_abundances_interp
        except AttributeError:
            logger.critical("Abundances must be remapped before decay is"
                            " handled")
            raise AttributeError("no radio_abundances_interp; call "
                                 "_remap_abundances first")

        for i in xrange(self.N_interp):
            comp = {}
            mass = 0
            for ident in self.radio_abundances_interp.keys():
                Xi = self.radio_abundances_interp[ident][i]
                mass += Xi
                comp[nucname.id(ident)] = Xi
            inp = material.Material(comp, mass=mass)
            res = inp.decay(
                (self.t - self.orig.t).to("s").value).mult_by_mass()

            for item in res.items():
                z = nucname.znum(item[0])
                self.abundances_interp[z][i] = \
                    self.abundances_interp[z][i] + item[1]
コード例 #35
0
ファイル: test_nucname.py プロジェクト: WireROP/pyne-omg
def test_zzzaaa_to_id():

    assert_equal(nucname.zzzaaa_to_id(2004), nucname.id(20040))
    assert_equal(nucname.zzzaaa_to_id(96244), nucname.id("Cm-244"))
    assert_equal(nucname.zzzaaa_to_id(94239), nucname.id("PU239"))

    assert_equal(nucname.zzzaaa_to_id(95242), nucname.id(95642))
    # Added /10*10 to remove the state information from id (ZZZAAA carries no state
    # information, defaults to zero when converting ZZZAAA back to ID)
    assert_equal(nucname.zzzaaa_to_id(95242), (nucname.id(95942)//10)*10)
    assert_equal(nucname.zzzaaa_to_id(95242), (nucname.id("AM-242m")//10)*10)

    assert_equal(nucname.zzzaaa_to_id(2000), nucname.id("he"))
    assert_equal(nucname.zzzaaa_to_id(92000), nucname.id("U"))
    assert_equal(nucname.zzzaaa_to_id(93000), nucname.id("Np"))

    assert_equal(nucname.zzzaaa_to_id(2004), nucname.id(40020))
コード例 #36
0
ファイル: test_nucname.py プロジェクト: kellyrowland/pyne
def test_zzzaaa_to_id():

    assert_equal(nucname.zzzaaa_to_id(2004), nucname.id(20040))
    assert_equal(nucname.zzzaaa_to_id(96244), nucname.id("Cm-244"))
    assert_equal(nucname.zzzaaa_to_id(94239), nucname.id("PU239"))

    assert_equal(nucname.zzzaaa_to_id(95242), nucname.id(95642))
    # Added /10*10 to remove the state information from id (ZZZAAA carries no state
    # information, defaults to zero when converting ZZZAAA back to ID)
    assert_equal(nucname.zzzaaa_to_id(95242), (nucname.id(95942) // 10) * 10)
    assert_equal(nucname.zzzaaa_to_id(95242), (nucname.id("AM-242m") // 10) * 10)

    assert_equal(nucname.zzzaaa_to_id(2000), nucname.id("he"))
    assert_equal(nucname.zzzaaa_to_id(92000), nucname.id("U"))
    assert_equal(nucname.zzzaaa_to_id(93000), nucname.id("Np"))

    assert_equal(nucname.zzzaaa_to_id(2004), nucname.id(40020))
コード例 #37
0
ファイル: test_openmc_utils.py プロジェクト: pyne/pyne
def test_ace_table_init():
    atab = openmc_utils.AceTable(zaid="92235",
                                 path="U235.ace",
                                 cross_sections_path="/tmp/cross_sections.xml")
    assert_equal("92235", atab.zaid)
    assert_equal("U235.ace", atab.path)
    assert_equal("/tmp/U235.ace", atab.abspath)
    assert_equal(nucname.id("U235"), atab.nucid)
コード例 #38
0
ファイル: kaeri.py プロジェクト: NukespudWork/pyne
def parse_for_all_isotopes(htmlfile):
    """Parses an elemental html file, returning a set of all occuring isotopes."""
    isos = set()
    with open(htmlfile, 'r') as f:
        for line in f:
            m = all_iso_regex.search(line)
            if m is not None:
                isos.add(nucname.id(m.group(1)))
    return isos
コード例 #39
0
ファイル: kaeri.py プロジェクト: pyne/pyne
def parse_for_natural_isotopes(htmlfile):
    """Parses an elemental html file, returning a set of naturally occuring isotopes."""
    nat_isos = set()
    with open(htmlfile, "r") as f:
        for line in f:
            m = nat_iso_regex.search(line)
            if m is not None:
                nat_isos.add(nucname.id(m.group(1)))
    return nat_isos
コード例 #40
0
def parse_for_all_isotopes(htmlfile):
    """Parses an elemental html file, returning a set of all occuring isotopes."""
    isos = set()
    with open(htmlfile, 'r') as f:
        for line in f:
            m = all_iso_regex.search(line)
            if m is not None:
                isos.add(nucname.id(m.group(1)))
    return isos
コード例 #41
0
def format_nucs(nucs):
    """
    format the nuclide  provided by the users into a standard format:
    ZZAASSSS.

    Parameters
    ----------
    nucs :  of nuclides
    """
    raise_no_pyne('Unable to format nuclide !', HAVE_PYNE)

    return [nucname.id(nuc) for nuc in nucs]
コード例 #42
0
ファイル: tools.py プロジェクト: cyclus/cymetric
def format_nucs(nucs):
    """
    format the nuclide  provided by the users into a standard format:
    ZZAASSSS.

    Parameters
    ----------
    nucs :  of nuclides
    """
    raise_no_pyne('Unable to format nuclide !', HAVE_PYNE)

    return [nucname.id(nuc) for nuc in nucs]
コード例 #43
0
ファイル: pre.py プロジェクト: FlanFlanagan/xsgen
    def _ensure_nl(self, rc):
        "Validate the tracked nuclides in the run control."
        if isinstance(rc.track_nucs, basestring):
            track_nucs = self.load_nuc_file(rc.track_nucs)
        else:
            track_nucs = [nucname.id(nuc) for nuc in rc.track_nucs]

        avg_timestep = 60*60*24*np.mean(rc.burn_times[1:]-rc.burn_times[:-1])
        min_halflife = rc.track_nuc_threshold * avg_timestep
        track_nucs = [nucid for nucid in track_nucs
                      if half_life(nucid) > min_halflife]
        rc.track_nucs = sorted(set(track_nucs))
コード例 #44
0
ファイル: data_source.py プロジェクト: zxkjack123/pyne
    def discretize(self, nuc, rx, temp=300.0, src_phi_g=None, dst_phi_g=None):
        """Discretizes the reaction channel from the source group structure to that
        of the destination weighted by the group fluxes.

        Parameters
        ----------
        nuc : int or str
            A nuclide.
        rx : int or str
            Reaction id or name.
        temp : float, optional
            Temperature [K] of material, defaults to 300.0.
        src_phi_g : array-like, optional
            Group fluxes for this data source, length src_ngroups.
        dst_phi_g : array-like, optional
            Group fluxes for the destiniation structure, length dst_ngroups.

        Returns
        -------
        dst_sigma : ndarray
            Destination cross section data, length dst_ngroups.
        """
        nuc = nucname.id(nuc)
        nuc_i = nucname.id(nuc)
        rx = rxname.mt(rx)
        rxdata = self.reaction(nuc, rx, nuc_i=nuc_i)
        xs = rxdata['xs']
        dst_group_struct = rxdata['dst_group_struct']
        intpoints = [intpt for intpt in rxdata['intpoints'][::-1]]
        intschemes = rxdata['intschemes'][::-1]
        e_int = rxdata["e_int"]

        src_bounds = [e_int[intpoint - 1] for intpoint in intpoints]
        src_dict = dict(zip(src_bounds, intschemes))
        dst_bounds = zip(dst_group_struct[1:], dst_group_struct[:-1])
        dst_sigma = [
            self.integrate_dst_group(dst_bound, src_bounds, src_dict, e_int,
                                     xs) for dst_bound in dst_bounds
        ]
        return dst_sigma
コード例 #45
0
def test_tree_log():
    "Tests corret implementation of the _log_tree() function"
    filename = 'log.txt'
    tm.log = open(filename, 'w')
    d0 = 0
    d1 = 1
    d2 = 2
    d11 = 1
    d20 = 0
    nuc0 = nn.id('O16')
    nuc1 = nn.id('O17')
    nuc2 = nn.id('O18')
    nuc11 = nn.id('He4')
    nuc20 = nn.id('C12')
    N0 = 123.456
    N1 = 12.3456
    N2 = 1.23456
    N11 = 1111.
    N20 = 12.
    exp = ('--> O16 123.456\n'
           '   |--> O17 12.3456\n'
           '   |   |--> O18 1.23456\n'
           '   |--> He4 1111.0\n'
           '--> C12 12.0\n')
    with open(filename, 'w') as tree:
        tm._log_tree(d0, nuc0, N0)
        tm._log_tree(d1, nuc1, N1)
        tm._log_tree(d2, nuc2, N2)
        tm._log_tree(d11, nuc11, N11)
        tm._log_tree(d20, nuc20, N20)
    tm.log.close()
    tm.log = None
    with open(filename, 'r') as f:
        obs = f.read()
    #print repr(exp)
    #print repr(obs)
    #print obs == exp
    assert_equal(exp, obs)
コード例 #46
0
ファイル: data_source.py プロジェクト: FlanFlanagan/pyne
    def discretize(self, nuc, rx, temp=300.0, src_phi_g=None, dst_phi_g=None):
        """Discretizes the reaction channel from the source group structure to that
        of the destination weighted by the group fluxes.

        Parameters
        ----------
        nuc : int or str
            A nuclide.
        rx : int or str
            Reaction id or name.
        temp : float, optional
            Temperature [K] of material, defaults to 300.0.
        src_phi_g : array-like, optional
            Group fluxes for this data source, length src_ngroups.
        dst_phi_g : array-like, optional
            Group fluxes for the destiniation structure, length dst_ngroups.

        Returns
        -------
        dst_sigma : ndarray
            Destination cross section data, length dst_ngroups.
        """
        nuc = nucname.id(nuc)
        nuc_i = nucname.id(nuc)
        rx = rxname.mt(rx)
        rxdata = self.reaction(nuc, rx, nuc_i = nuc_i)
        xs = rxdata['xs']
        dst_group_struct = rxdata['dst_group_struct']
        intpoints = [intpt for intpt in rxdata['intpoints'][::-1]]
        intschemes = rxdata['intschemes'][::-1]
        e_int = rxdata["e_int"]

        src_bounds = [e_int[intpoint-1] for intpoint in intpoints]
        src_dict = dict(zip(src_bounds, intschemes))
        dst_bounds = zip(dst_group_struct[1:], dst_group_struct[:-1])
        dst_sigma = [self.integrate_dst_group(dst_bound, src_bounds, src_dict, e_int, xs)
                     for dst_bound in dst_bounds]
        return dst_sigma
コード例 #47
0
ファイル: test_chainsolve.py プロジェクト: FlanFlanagan/pyne
def test_tree_log():
    "Tests corret implementation of the _log_tree() function"
    filename = 'log.txt'
    tm.log = open(filename, 'w')
    d0 = 0
    d1 = 1
    d2 = 2
    d11 = 1
    d20 = 0
    nuc0 = nn.id('O16')
    nuc1 = nn.id('O17')
    nuc2 = nn.id('O18')
    nuc11 = nn.id('He4')
    nuc20 = nn.id('C12')
    N0 = 123.456
    N1 = 12.3456
    N2 = 1.23456
    N11 = 1111.
    N20 = 12.
    exp = ('--> O16 123.456\n'
           '   |--> O17 12.3456\n'
           '   |   |--> O18 1.23456\n'
           '   |--> He4 1111.0\n'
           '--> C12 12.0\n')
    with open(filename, 'w') as tree:
        tm._log_tree(d0, nuc0, N0)
        tm._log_tree(d1, nuc1, N1)
        tm._log_tree(d2, nuc2, N2)
        tm._log_tree(d11, nuc11, N11)
        tm._log_tree(d20, nuc20, N20)
    tm.log.close()
    tm.log = None
    with open(filename, 'r') as f:
        obs = f.read()
    #print repr(exp)
    #print repr(obs)
    #print obs == exp
    assert_equal(exp, obs)
コード例 #48
0
def test_tree_log():
    "Tests corret implementation of the _log_tree() function"
    filename = "log.txt"
    tm.log = open(filename, "w")
    d0 = 0
    d1 = 1
    d2 = 2
    d11 = 1
    d20 = 0
    nuc0 = nn.id("O16")
    nuc1 = nn.id("O17")
    nuc2 = nn.id("O18")
    nuc11 = nn.id("He4")
    nuc20 = nn.id("C12")
    N0 = 123.456
    N1 = 12.3456
    N2 = 1.23456
    N11 = 1111.0
    N20 = 12.0
    exp = ("--> O16 123.456\n"
           "   |--> O17 12.3456\n"
           "   |   |--> O18 1.23456\n"
           "   |--> He4 1111.0\n"
           "--> C12 12.0\n")
    with open(filename, "w") as tree:
        tm._log_tree(d0, nuc0, N0)
        tm._log_tree(d1, nuc1, N1)
        tm._log_tree(d2, nuc2, N2)
        tm._log_tree(d11, nuc11, N11)
        tm._log_tree(d20, nuc20, N20)
    tm.log.close()
    tm.log = None
    with open(filename, "r") as f:
        obs = f.read()
    # print repr(exp)
    # print repr(obs)
    # print obs == exp
    assert_equal(exp, obs)
コード例 #49
0
ファイル: dosefactors.py プロジェクト: pyne/pyne
def read_row(row):
    """Returns a list for each nuclide. Form varies based on type of dose rate factor:
    1. External DF in Air: [int, float, float]
    2. External DF in Soil: [int, float, float, float]
    3. Ingestion DF: [int, float, float, float, float]
    4. Inhalation DF: [int, string, float, float, float]

    Parameters
    ----------
    row : tuple
        One entry in a dose factor file.
    """

    # Create list
    entry = []

    # Evaluate each component of the given row
    if row[0].endswith("+D"):
        row[0] = row[0][:-2]
    nuclide = nucname.id(row[0])

    # Case 1: DF from External Air
    if len(row) == 3:
        dose_air = float(row[1])
        if len(row[2]) == 0:
            ratio = None
        else:
            ratio = float(row[2])
        entry = [nuclide, dose_air, ratio]
    # Case 2: DF from External Soil
    elif len(row) == 6:
        genii = float(row[1])
        epa = float(row[2])
        doe = float(row[3])
        entry = [nuclide, genii, epa, doe]
    # Case 4: DF from Inhalation
    elif len(row) == 7 and row[1].isalpha():
        lungmodel = row[1]
        genii = float(row[2])
        epa = float(row[3])
        doe = float(row[4])
        entry = [nuclide, genii, epa, doe, lungmodel]
    # Case 4: DF from Ingestion
    else:
        f1 = float(row[1])
        genii = float(row[2])
        epa = float(row[3])
        doe = float(row[4])
        entry = [nuclide, genii, epa, doe, f1]
    return entry
コード例 #50
0
ファイル: dosefactors.py プロジェクト: FlanFlanagan/pyne
def read_row(row):
    """Returns a list for each nuclide. Form varies based on type of dose rate factor:
    1. External DF in Air: [int, float, float]
    2. External DF in Soil: [int, float, float, float]
    3. Ingestion DF: [int, float, float, float, float]
    4. Inhalation DF: [int, string, float, float, float]
    
    Parameters
    ----------
    row : tuple
        One entry in a dose factor file.
    """

    # Create list
    entry = []
    
    # Evaluate each component of the given row
    if row[0].endswith('+D'):
        row[0] = row[0][:-2]
    nuclide = nucname.id(row[0])

    # Case 1: DF from External Air
    if len(row) == 3:
        dose_air = float(row[1])
        if len(row[2]) == 0:
            ratio = None
        else:
            ratio = float(row[2])
        entry = [nuclide, dose_air, ratio]
    # Case 2: DF from External Soil
    elif len(row) == 6:
        genii = float(row[1])
        epa = float(row[2])
        doe = float(row[3])
        entry = [nuclide, genii, epa, doe]
    # Case 4: DF from Inhalation
    elif len(row) == 7 and row[1].isalpha():
        lungmodel = row[1]
        genii = float(row[2])
        epa = float(row[3])
        doe = float(row[4])
        entry = [nuclide, genii, epa, doe, lungmodel]
    # Case 4: DF from Ingestion
    else:
        f1 = float(row[1])
        genii = float(row[2])
        epa = float(row[3])
        doe = float(row[4])
        entry = [nuclide, genii, epa, doe, f1]
    return entry
コード例 #51
0
ファイル: pre.py プロジェクト: FlanFlanagan/xsgen
    def load_nuc_file(self, path):
        """Load list nucs from a file. Should be a file containing just a Python list.

        Parameters
        ----------
        path : str
            The path to the nuc file.

        Returns
        -------
        nucs : list of ints
            The nuclides listed in the file, in nuc ID form.
        """
        with open(path, 'r') as f:
            text = f.read()
            if text[0] == "[" and text[-1] == "]":
                nucs = exec(text)
        nucs = [nucname.id(nuc) for nuc in nucs]
        return nucs
コード例 #52
0
ファイル: test_serpent.py プロジェクト: walshjon/pyne
def test_parse_dep1():
    dep = serpent.parse_dep("sample_dep.m")
    nuc_set = set([nucname.id(int(nuc)) for nuc in dep["ZAI"][:-2]])
    shape = (len(dep["ZAI"]), len(dep["DAYS"]))
    for key in dep:
        if key.endswith("_VOLUME"):
            assert_true(isinstance(dep[key], float))
        elif key.endswith("_MATERIAL"):
            assert_equal(len(dep[key]), shape[1])
            for n in range(shape[1]):
                assert_equal(nuc_set, set(dep[key][n].comp.keys()))
        elif key.startswith("MAT_") and key.endswith("_BURNUP"):
            assert_equal(dep[key].shape, (1, shape[1]))
        elif key.startswith("MAT_") or key.startswith("TOT_"):
            assert_equal(dep[key].shape, shape)

    # Check values
    assert_array_equal(dep["BU"], [0.00000e00, 8.40000e01, 1.68000e02])
    assert_equal(dep["i952421"], 123)
    assert_array_equal(dep["MAT_fuelp1r2_H"][3], [0.00000e00, 5.56191e-11, 3.22483e-10])
コード例 #53
0
ファイル: alara.py プロジェクト: mzweig/pyne
def _build_matrix(N):
    """ This function  builds burnup matrix, A. Decay only.
    """
    
    A = np.zeros((len(N), len(N)))
    
    # convert N to id form
    N_id = []
    for i in xrange(len(N)):
        ID = id(N[i])
        N_id.append(ID)
        
    sds = SimpleDataSource()

    # Decay
    for i in xrange(len(N)):
        A[i, i] -= decay_const(N_id[i])
        
        # Find decay parents
        for k in xrange(len(N)):
            if N_id[i] in decay_children(N_id[k]):
                A[k, i] += decay_const(N_id[k])
            
    return A
コード例 #54
0
ファイル: ndsfpy.py プロジェクト: FlanFlanagan/pyne
def conv_to_id(nuc):
    """Converts html nuclide names to nuclide ids
    """
    parts = nuc.split('-')
    return nucname.id(parts[1] + parts[2])
コード例 #55
0
ファイル: tape9.py プロジェクト: NukespudWork/pyne
def gendecay(decays, branches, metastable_cutoff=1.0):
    """This computes ORIGEN TAPE9 decay data based on ENSDF data.

    Parameters
    ----------
    decays : list
        decay list from parse_ensdf()
    branches : list
        branches list from parse_ensdf()
    metastable_cutoff : float, optional
        minimum lifetime of metastable state (in seconds) to be included.

    Returns
    -------
    t9 : dict
        a TAPE9 dictionary for the decay library
    """
    t9 = {1: {'_type': 'decay', 'title': 'PyNE Decay Data for Activation Products'}, 
          2: {'_type': 'decay', 'title': 'PyNE Decay Data for Actinides & Daughters'}, 
          3: {'_type': 'decay', 'title': 'PyNE Decay Data for Fission Products'}, 
          }
    for nlb, lib in t9.items():
        for field in origen22.DECAY_FIELDS:
            lib[field] = {}

    longest = {}
    longest2 = {}
    for item in decays:
        nuc = nucname.id(item[0])
        key = nucname.zzaaam(nuc)
        if _is_metastable_beta_decay_0(item, metastable_cutoff):
            if 'B-' in item[5]:
                _plus_eq_decay_t9(t9, 'frac_beta_minus_x', nuc, key, item[6]/100.0)
            if 'B+' in item[5] or "EC" in item[5]:
                _plus_eq_decay_t9(t9, 'frac_beta_plus_or_electron_capture_x', nuc, 
                                  key, item[6]/100.0)
        if _is_metastable_beta_decay_x(item, metastable_cutoff):
            key += 1
            longest2[key] = longest2.get(key, 0)
            if item[1] == longest2[key]:
                if 'B-' in item[5]:
                    _plus_eq_decay_t9(t9, 'frac_beta_minus_x', nuc, key, 
                                      item[6]/100.0)
                                      #item[6]*item[8]/100.0)
                if 'B+' in item[5] or "EC" in item[5]:
                    _plus_eq_decay_t9(t9, 'frac_beta_plus_or_electron_capture_x', nuc,
                                      key, item[6]/100.0)
                                      #key, item[6]*item[8]/100.0)
            elif item[1] > longest2[key]:
                longest2[key] = item[1]
                if 'B-' in item[5]:
                    #_eq_decay_t9(t9, 'frac_beta_minus_x', nuc, key, item[6]*item[8]/100.0)
                    _eq_decay_t9(t9, 'frac_beta_minus_x', nuc, key, item[6]/100.0)
                if 'B+' in item[5] or "EC" in item[5]:
                    _eq_decay_t9(t9, 'frac_beta_plus_or_electron_capture_x', nuc,
                                      key, item[6]/100.0)
                                      #key, item[6]*item[8]/100.0)
    for item in branches:
        nuc = nucname.id(item[0])
        key = nucname.zzaaam(nuc)
        if (item[1] == 0) and (item[2] > metastable_cutoff):
            _set_branch_item(t9, nuc, key, item)
        if (item[1] != 0) and (item[2] > metastable_cutoff):
            key += 1
            longest[key] = longest.get(key, 0)
            if (item[2] <= longest[key]):
                continue 
            _set_branch_item(t9, nuc, key, item)
    for nucs, hl in zip([origen22.ACTIVATION_PRODUCT_NUCS, 
                         origen22.ACTINIDE_AND_DAUGHTER_NUCS, 
                         origen22.FISSION_PRODUCT_NUCS], 
                        [t9[i]['half_life'] for i in range(1, 4)]):
        for nuc in nucs:
            key = nucname.zzaaam(nuc)
            if key not in hl:
                hl[key] = data.half_life(nuc)
    return t9
コード例 #56
0
import os
import shutil
from pyne import nucname
dirname = "JENDL-AN-2005-linux-patched"
zaiddirname = dirname + "-ZAID/"
if not os.path.exists(zaiddirname):
    os.makedirs(zaiddirname)
files = [ f for f in os.listdir(dirname) if (os.path.isfile(os.path.join(dirname,f)) & f.endswith(".dat")) ]
for file in files:
    nucid = nucname.id(os.path.splitext(file)[0])
    zaid = nucname.zzzaaa(nucid)
    zaidfile = str(zaid) + ".dat"
    shutil.copyfile(os.path.join(dirname , file), os.path.join(zaiddirname, zaidfile ))
コード例 #57
0
ファイル: test_nucname.py プロジェクト: kellyrowland/pyne
def test_id():
    assert_equal(nucname.id(20040), 20040000)

    assert_equal(nucname.id("he4"), 20040000)
    assert_equal(nucname.id("Cm-244"), 962440000)
    assert_equal(nucname.id("PU239"), 942390000)
    assert_equal(nucname.id("AM242M"), 952420001)

    assert_equal(nucname.id(2004), 20040000)
    assert_equal(nucname.id(95642), 952420000)
    assert_equal(nucname.id(95242), 952420001)
    assert_equal(nucname.id(92636), 922360001)
    assert_equal(nucname.id(95942), 952420004)

    assert_equal(nucname.id("Am-242m"), 952420001)

    assert_equal(nucname.id("he"), 20000000)
    assert_equal(nucname.id("U"), 920000000)
    assert_equal(nucname.id("Np"), 930000000)
    assert_equal(nucname.id("Cl"), 170000000)

    assert_equal(nucname.id("4he"), 20040000)
    assert_equal(nucname.id("244CM"), 962440000)
    assert_equal(nucname.id("239Pu"), 942390000)
    assert_equal(nucname.id("242AM"), 952420000)

    assert_equal(nucname.id(40020), 20040000)
    assert_equal(nucname.id(2440961), 962440001)
    assert_equal(nucname.id(2390940), 942390000)
    assert_equal(nucname.id(2420950), 952420000)
    assert_equal(nucname.id(92), 920000000)

    assert_equal(nucname.id("94-Pu-239"), nucname.id("Pu-239"))
    assert_equal(nucname.id("95-Am-242m"), nucname.id("Am-242m"))
    assert_equal(nucname.id("94-Pu-239"), nucname.id("Pu-239"))
    assert_equal(nucname.id("95-Am-242"), nucname.id("Am-242"))
コード例 #58
0
ファイル: pre.py プロジェクト: FlanFlanagan/xsgen
    def _ensure_mats(self, rc):
        "Ensure we have a fuel material, clad material, and cooling material."

        if 'fuel_material'in rc:
            rc.fuel_material = ensure_mat(rc.fuel_material)
        elif 'fuel_chemical_form' in rc and 'initial_heavy_metal' in rc:
            ihm_mat = Material(rc.initial_heavy_metal)
            atom_frac = {nucname.id(k): v for k, v in
                         rc.fuel_chemical_form.items() if k != "IHM"}
            atom_frac[ihm_mat] = rc.fuel_chemical_form.get("IHM", 0.0)
            rc.fuel_material = from_atom_frac(atom_frac)
        else:
            raise ValueError("Please specify a fuel.")

        if 'clad_material' in rc:
            rc.clad_material = ensure_mat(rc.clad_material)
        else:
            rc.clad_material = Material({
                # Natural Zirconium
                400900: 0.98135 * 0.5145,
                400910: 0.98135 * 0.1122,
                400920: 0.98135 * 0.1715,
                400940: 0.98135 * 0.1738,
                400960: 0.98135 * 0.0280,
                # The plastic is all melted and the natural Chromium too..
                240500: 0.00100 * 0.04345,
                240520: 0.00100 * 0.83789,
                240530: 0.00100 * 0.09501,
                240540: 0.00100 * 0.02365,
                # Natural Iron
                260540: 0.00135 * 0.05845,
                260560: 0.00135 * 0.91754,
                260570: 0.00135 * 0.02119,
                260580: 0.00135 * 0.00282,
                # Natural Nickel
                280580: 0.00055 * 0.68077,
                280600: 0.00055 * 0.26223,
                280610: 0.00055 * 0.01140,
                280620: 0.00055 * 0.03634,
                280640: 0.00055 * 0.00926,
                # Natural Tin
                501120: 0.01450 * 0.0097,
                501140: 0.01450 * 0.0065,
                501150: 0.01450 * 0.0034,
                501160: 0.01450 * 0.1454,
                501170: 0.01450 * 0.0768,
                501180: 0.01450 * 0.2422,
                501190: 0.01450 * 0.0858,
                501200: 0.01450 * 0.3259,
                501220: 0.01450 * 0.0463,
                501240: 0.01450 * 0.0579,
                # We Need Oxygen!
                80160:  0.00125,
                })

        if 'cool_material' in rc:
            rc.cool_material = ensure_mat(rc.cool_material)
        else:
            MW = (2 * 1.0) + (1 * 16.0) + (0.199 * 550 * 10.0**-6 * 10.0) + \
                                          (0.801 * 550 * 10.0**-6 * 11.0)
            rc.cool_material = Material({
                10010: (2 * 1.0) / MW,
                80160: (1 * 16.0) / MW,
                50100: (0.199 * 550 * 10.0**-6 * 10.0) / MW,
                50110: (0.801 * 550 * 10.0**-6 * 11.0) / MW,
                })