示例#1
0
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))
示例#2
0
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))
示例#3
0
    def convertF0(self):
        onlyfiles = [ f for f in os.listdir(self.csdir) if (os.path.isfile(os.path.join(self.csdir,f)) & f.endswith(self.ending)) ]
        for datafile in onlyfiles:
            print "====== Loading JENDL (alpha,n) File: " + datafile
            endfeval = eva(os.path.join(self.csdir, datafile), verbose = False)
            endfeval.read()
            nuc = nucname.zzzaaa_to_id(endfeval.target['ZA'])
            elname = elements[nucname.znum(nuc)].name
            elname = elname.capitalize()
            nuclidefilename = str(nucname.znum(nuc)) + "_" + str(nucname.anum(nuc)) + "_" + elname
            if (endfeval.target['isomeric_state'] != 0):
                print "Found nuclide in exited state, will add _<state> to filename"
                nuclidefilename = nuclidefilename + "_" + str(endfeval.target['isomeric_state'])

            mf3data = {}
            fullfilename = "Inelastic/F01/" + nuclidefilename
            fullfilename = self.outputdir + fullfilename
            if not os.path.exists(os.path.dirname(fullfilename)):
                os.makedirs(os.path.dirname(fullfilename))
                print os.path.dirname(fullfilename) + " has been created (did not exist before)."
            outf = open(fullfilename, 'w')
            for mt in [4] + range(50, 92):
                if(mt in endfeval.reactions):
                    mf3data[mt] = endfeval.reactions[mt]
                    if(mf3data[mt].xs.nbt[0] != len(mf3data[mt].xs.x)):
                       print("Problem with interpolation")
                    #print mf3data[mt].xs.interp
                    outf.write("  {:12d}".format(1))
                    outf.write("\n")
                    outf.write("  {:12d}".format(3))
                    outf.write("\n")
                    outf.write("  {:12d}".format(mt)) 
                    outf.write("  {:12d}".format(0))
                    outf.write("\n")
                    outf.write("  {:12d}".format(int(mf3data[mt].Q_reaction)))
                    outf.write("  {:12d}".format(0))
                    outf.write("  {:12d}".format(len(mf3data[mt].xs.x)))
                    outf.write("\n")
                    writeline = ""
                    zippedxs = zip(mf3data[mt].xs.x, mf3data[mt].xs.y)
                    count = 0
                    for se, sxs in zippedxs:
                        count += 1
                        writeline += "  {:8.6e}  {:8.6e}".format(se, sxs)
                        if (count == 3):
                            writeline += "\n"
                            count = 0
                    if(count != 0):
                        writeline += "\n"
                    outf.write(writeline)

            outf.close()
示例#4
0
文件: depcode.py 项目: arfc/saltproc
    def get_nuc_name(self, nuc_code):
        """Returns nuclide name in human-readable notation: chemical symbol
        (one or two characters), dash, and the atomic weight. Lastly, if the
        nuclide is in metastable state, the letter `m` is concatenated with
        number of excited state. For example, `Am-242m1`.

        Parameters
        ----------
        nuc_code : str
            Name of nuclide in Serpent2 form. For instance, `Am-242m`.

        Returns
        -------
        nuc_name : str
            Name of nuclide in human-readable notation (`Am-242m1`).
        nuc_zzaaam : str
            Name of nuclide in `zzaaam` form (`952421`).

        """

        if '.' in str(nuc_code):
            nuc_code = pyname.zzzaaa_to_id(int(nuc_code.split('.')[0]))
            zz = pyname.znum(nuc_code)
            aa = pyname.anum(nuc_code)
            aa_str = str(aa)
            # at_mass = pydata.atomic_mass(nuc_code_id)
            if aa > 300:
                if zz > 76:
                    aa_str = str(aa - 100) + 'm1'
                    aa = aa - 100
                else:
                    aa_str = str(aa - 200) + 'm1'
                    aa = aa - 200
                nuc_zzaaam = str(zz) + str(aa) + '1'
            elif aa == 0:
                aa_str = 'nat'
            nuc_name = pyname.zz_name[zz] + aa_str
        else:
            meta_flag = pyname.snum(nuc_code)
            if meta_flag:
                nuc_name = pyname.name(nuc_code)[:-1] + 'm' + str(meta_flag)
            else:
                nuc_name = pyname.name(nuc_code)
        nuc_zzaaam = \
            self.convert_nuclide_name_serpent_to_zam(pyname.zzaaam(nuc_code))
        return nuc_name, nuc_zzaaam
示例#5
0
文件: endl.py 项目: opotowsky/pyne
    def _read_headers(self):
        """Read all the table headers from an ENDL file."""
        opened_here = False
        if isinstance(self.fh, basestring):
            fh = open(self.fh, 'rU')
            opened_here = True
        else:
            fh = self.fh

        while True:
            # get header lines
            line1 = fh.readline()
            line2 = fh.readline()

            # EOF?
            if len(line2) == 0:
                break

            # store the start of the table
            start = fh.tell()

            # parse the first header line
            nuc_zzzaaa = int(line1[0:6].strip())
            yi = int(line1[7:9].strip() or -1)
            yo = int(line1[10:12].strip() or -1)
            aw_str = line1[13:24]
            aw = utils.endftod(aw_str) if aw_str else np.float64(-1.)
            date = line1[25:31].strip()
            iflag = int(line1[31].strip() or 0)

            # parse the second header line
            rdesc = int(line2[0:2].strip() or -1)
            rprop = int(line2[2:5].strip() or -1)
            rmod = int(line2[5:8].strip() or -1)
            x1_str = line2[21:32]
            x1 = int(utils.endftod(x1_str or -1.))

            # convert to Pyne native formats
            nuc = nucname.zzzaaa_to_id(nuc_zzzaaa)

            # skip to the end of the table
            read_eot = False
            while not read_eot:
                stop = fh.tell()
                line = fh.readline()
                read_eot = (len(line) == 0 or END_OF_TABLE_RE.match(line))

            # insert the table in the self.structure dictionary
            self.structure[nuc]['pin'].add(yi)
            self.structure[nuc]['rdesc'].add(rdesc)
            self.structure[nuc]['rprop'].add(rprop)

            pdp_dict = self.structure[nuc]['pin_rdesc_rprop']
            table_dict = pdp_dict[yi, rdesc, rprop]
            table_dict['rmod'] = rmod

            x1_in_tuple = x1 if rmod != 0 else None
            data_tuple = DataTuple(x1=x1_in_tuple, yo=yo, limits=(start, stop))
            table_dict['data_tuples'].append(data_tuple)

        # close the file if it was opened here
        if opened_here:
            fh.close()
th_tank_adensity = np.array(f['Th tank adensity'])
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 = {}