Beispiel #1
0
def main():
    # get list of nuclides
    data.atomic_mass('U235')
    nucs = set(data.atomic_mass_map.keys())
    for nuc in data.atomic_mass_map:
        nucm = nuc + 1
        if nucname.anum(nuc) == 0 or data.decay_const(nucm) < 1e-16 or \
                            data.decay_const(nuc) == data.decay_const(nucm):
            continue
        nucs.add(nucm)
    nucs = [nuc for nuc in nucs if nucname.anum(nuc) > 0]
    #and
    #                            not np.isnan(data.decay_const(nuc)) and
    #                            nuc < 200000000]
    nucs.sort()
    # get symbols
    symbols = {}
    channels = {}
    for nuc in nucs:
        add_child_decays(nuc, symbols)
        add_child_xss(nuc, channels, nucs)
    # print symbols
    ns = []
    for nuc in nucs:
        try:
            nname = nucname.name(nuc)
        except RuntimeError:
            continue
        ns.append(nname)
    nucs = ns
    d = {'symbols': symbols, 'nucs': nucs, 'channels': channels}
    s = json.dumps(d, indent=4, sort_keys=True)
    print(s)
Beispiel #2
0
def Calc_Moderating_Ratio(mats):
    # Initialize output and key list
    mr = []
    key_lst = mats.keys()

    for i in key_lst:
        rho = mats[i].density

        #Find A for elements
        try:
            A = atomic_mass(mats[i].metadata['name'])

        #Find A for compounds
        except RuntimeError as r:
            A = 0
            for k in mats[i].comp.keys():
                A += atomic_mass(k) * mats[i].comp[k]

        # Calculate Lethargy
        xi = 1 - (A - 1)**2 / (2 * A) * log((A + 1) / (A - 1))

        # Get cross-section Data (Reaction #2=elastic scattering, #4=inel scattering, #16=n,2n, #27=absorption
        sds = SimpleDataSource()
        sig_el1, sig_inl1, sig_a1 = 0, 0, 0
        sig_el14, sig_inl14, sig_a14 = 0, 0, 0
        for k in mats[i].comp.keys():
            try:
                sig_el14 += sds.reaction(k, 2)[0] * mats[i].comp[
                    k]  #Index 0 is 14 MeV, 1 is 1 MeV, 2 is thermal
                sig_inl14 += sds.reaction(k, 4)[0] * mats[i].comp[k]
                sig_a14 += sds.reaction(k, 27)[0] * mats[i].comp[k]
                sig_el1 += sds.reaction(k, 2)[1] * mats[i].comp[k]
                sig_inl1 += sds.reaction(k, 4)[1] * mats[i].comp[k]
                sig_a1 += sds.reaction(k, 27)[1] * mats[i].comp[k]
            except TypeError as t:
                module_logger.warning(
                    "{}({}) cross-section not found in EAS data.".format(i, k))

        # Calculate macroscopic cross-sections
        sig_el14 = sig_el14 * N_A * mats[i].density / A
        sig_inl14 = sig_inl14 * N_A * mats[i].density / A
        sig_a14 = sig_a14 * N_A * mats[i].density / A
        sig_el1 = sig_el1 * N_A * mats[i].density / A
        sig_inl1 = sig_inl1 * N_A * mats[i].density / A
        sig_a1 = sig_a1 * N_A * mats[i].density / A

        # Calculate moderating ratio
        try:
            mr.append(
                Moderating_Ratio(i,
                                 xi * (sig_el1 + sig_inl1) / sig_a1,
                                 xi * (sig_el14 + sig_inl14) / sig_a14))
        except ZeroDivisionError as z:
            module_logger.warning(
                "Divide by zero error.  No absorption cross section for {} in EAS data."
                .format(i))
            mr.append(Moderating_Ratio(i, 0.0, 0.0))

    return mr
Beispiel #3
0
def test_atomic_mass():
    o16 = [15.9949146196, 16.0]
    u235 = [235.04392819, 235.0]
    am242m = [242.059547428, 242.0]

    # zzaam form
    assert_in(data.atomic_mass(80160), o16)
    assert_in(data.atomic_mass(922350), u235)
    assert_in(data.atomic_mass(952421), am242m)
Beispiel #4
0
def test_atomic_mass():
    o16 = [15.99491461957, 16.0]
    u235 = [235.043930131, 235.0]
    am242m = [242.059549364, 242.0]

    # zzaam form
    assert_in(data.atomic_mass(80160), o16)
    assert_in(data.atomic_mass(922350), u235)
    assert_in(data.atomic_mass(952421), am242m)
Beispiel #5
0
def test_atomic_mass():
    o16 = [15.99491461957, 16.0]
    u235 = [235.043931368, 235.0]
    am242m = [242.059550625, 242.0]

    # zzaam form
    assert_in(data.atomic_mass(80160), o16)
    assert_in(data.atomic_mass(922350), u235)
    assert_in(data.atomic_mass(952421), am242m)
Beispiel #6
0
def test_atomic_mass():
    # set the datapath to nonsense so we call  the cpp data version
    orig = pyne_conf.NUC_DATA_PATH
    pyne_conf.NUC_DATA_PATH = b"bobbobhonkeytonk"
    o16 = [15.9949146196, 16.0]
    u235 = [235.04392819, 235.0]
    am242m = [242.059547428, 242.0]

    # zzaam form
    assert_in(data.atomic_mass(80160), o16)
    assert_in(data.atomic_mass(922350), u235)
    assert_in(data.atomic_mass(952421), am242m)
    pyne_conf.NUC_DATA_PATH = orig
Beispiel #7
0
def test_elements():
    # set the datapath to nonsense so we call, the cpp data version
    orig = pyne_conf.NUC_DATA_PATH
    pyne_conf.NUC_DATA_PATH = b'bobbobhonkeytonk'
    # initialize natural_abund_map
    # test a series of elements
    assert_almost_equal(data.atomic_mass('H'), 1.0079407540557774)
    assert_almost_equal(data.atomic_mass('Li'), 6.9400366029079965)
    assert_almost_equal(data.atomic_mass('U'), 238.02891048471406)
    # NB any elements beyond z = 92 are not natural
    # and therefore have 0.0 atomic mass
    assert_almost_equal(data.atomic_mass('Pu'), 0.0)
    # note if you use the nuc_data.h5 file it
    # has the same behaviour
    pyne_conf.NUC_DATA_PATH = orig
Beispiel #8
0
def test_elements():
    # set the datapath to nonsense so we call, the cpp data version
    orig = pyne_conf.NUC_DATA_PATH
    pyne_conf.NUC_DATA_PATH = b"bobbobhonkeytonk"
    # initialize natural_abund_map
    # test a series of elements
    assert_almost_equal(data.atomic_mass("H"), 1.007940754065775)
    assert_almost_equal(data.atomic_mass("Li"), 6.940036602972684)
    assert_almost_equal(data.atomic_mass("U"), 238.02890905398374)
    # NB any elements beyond z = 92 are not natural
    # and therefore have 0.0 atomic mass
    assert_almost_equal(data.atomic_mass("Pu"), 0.0)
    # note if you use the nuc_data.h5 file it
    # has the same behaviour
    pyne_conf.NUC_DATA_PATH = orig
Beispiel #9
0
def query(c):
    """Lists decay heats of all nuclides with respect to time for all facilities.

    Args:
        c: connection cursor to sqlite database.
    """
    # gives avogadro's number with a kg to g conversion
    ACT_CONV = 1000*6.022e23
    # converts from MeV/s to MW
    Q_CONV = 1.602e-19
    
    # SQL query returns a table with the nuclides (and their masses) transacted from reactor
    sql = ("SELECT resources.TimeCreated, compositions.NucId," 
           "compositions.MassFrac*resources.Quantity ")
    sql += ("FROM resources "
            "INNER JOIN compositions ON resources.QualId = compositions.QualId "
            "INNER JOIN transactions ON resources.TimeCreated = transactions.Time "
            "WHERE transactions.SenderId=13 "
            "GROUP BY resources.TimeCreated, compositions.NucId "
            "ORDER BY resources.TimeCreated;")
    cur = c.execute(sql)
    results = cur.fetchall()

    alldecayheats = []

    # Calculates decay heat (MW) at each timestep
    for time_step, nuc, mass in results:
        act = ACT_CONV * mass * data.decay_const(nuc) / data.atomic_mass(nuc)
        dh = Q_CONV * act * data.q_val(nuc)
        row = (time_step, nuc, dh)
        alldecayheats.append(row)

    return alldecayheats
Beispiel #10
0
def atom_to_mass_frac(atom):
    """Convert input in atomic fraction to mass fraction"""
    if type(atom) is np.ndarray:
        if len(atom) != 6:
            raise ValueError("Array has to be of len 6 (U232 to U236, U238)")
        isotopes = [f"92{i}0000" for i in range(232, 239) if i != 237]
        masses = np.array([atomic_mass(iso) for iso in isotopes])

        mass = atom * masses
        mass /= mass.sum()

        return mass

    mass = {}
    normalisation = 0
    for key, value in atom.items():
        if key > 250 or key < 1:
            raise KeyError('Keys have to be the atomic masses, ' +
                           'not NucIds or something else.')
        val = value * key
        mass[key] = val
        normalisation += val

    for key in mass.keys():
        mass[key] /= normalisation

    return mass
Beispiel #11
0
def elelib_to_nuclib(filename, outfile):
    output = ""
    with open(filename, 'r') as f:
        line = f.readline()
        while line != '':
            if len(line.split()) == 0:
                line = f.readline()
                continue

            elem_output = ''
            iso_output = ''

            elem_output += line
            l = line.split()
            ll = l[0]  # atomic symbol
            elem_mass = float(l[1])  # average atomic weight, natural element
            znum = int(l[2])
            rho = float(l[3])  # mass density
            num_isos = int(l[4])
            for _ in range(num_isos):
                isoline = f.readline()
                elem_output += isoline
                anum = int(isoline.split()[0])
                atomic_mass = data.atomic_mass("{0}{1}".format(ll, anum))
                iso_output += "{0}:{1} {2:13.5E} {3:3d} {4:13.5E} 1\n    {5} 100\n".format(
                    ll, anum, atomic_mass, znum, rho * atomic_mass / elem_mass,
                    anum)
            line = f.readline()
            output += elem_output + iso_output

    with open(outfile, 'w') as f:
        f.write(output)
Beispiel #12
0
def elelib_to_nuclib(filename, outfile):
    output=""
    with open(filename, 'r') as f:
        line = f.readline()
        while line !='':
            if len(line.split()) == 0:
                line = f.readline()
                continue

            elem_output = ''
            iso_output = ''
            
            elem_output += line
            l = line.split()
            ll = l[0] # atomic symbol
            elem_mass = float(l[1]) # average atomic weight, natural element
            znum = int(l[2])
            rho = float(l[3]) # mass density
            num_isos = int(l[4])
            for _ in range(num_isos):
                isoline = f.readline()
                elem_output += isoline
                anum = int(isoline.split()[0])
                atomic_mass = data.atomic_mass("{0}{1}".format(ll, anum))
                iso_output += "{0}:{1} {2:13.5E} {3:3d} {4:13.5E} 1\n    {5} 100\n".format(
                           ll, anum, atomic_mass, znum, rho*atomic_mass/elem_mass, anum)
            line = f.readline()
            output += elem_output + iso_output

    with open(outfile, 'w') as f:
        f.write(output)
Beispiel #13
0
def query(c):
    """Lists activities of all nuclides with respect to time for all facilities.

    Args:
        c: connection cursor to sqlite database.
    """

    # SQL query returns a table with the nuclides and their masses at each timestep
    sql = ("SELECT Resources.TimeCreated, Compositions.NucID," 
           "Compositions.MassFrac*Resources.Quantity ")
    sql += ("FROM Resources "
            "INNER JOIN Compositions ON Resources.StateID = Compositions.StateID "
            "GROUP BY Resources.TimeCreated, Compositions.NucID "
            "ORDER BY Resources.TimeCreated;")
    cur = c.execute(sql)
    results = cur.fetchall()

    # Gives avogadro's number with a kg to g conversion 
    CONV = 1000*6.022e23

    activities = []

    # Calculates activities (/s) of each nuclide at each timestep
    for time_step, nuc, mass in results:
        act = CONV * mass * data.decay_const(nuc) / data.atomic_mass(nuc)
        row = (time_step, nuc, act)
        activities.append(row)

    return activities
Beispiel #14
0
def query(c):
    """Lists decay heats of all nuclides with respect to time for all facilities.

    Args:
        c: connection cursor to sqlite database.
    """
    # gives avogadro's number with a kg to g conversion
    ACT_CONV = 1000 * 6.022e23
    # converts from MeV/s to MW
    Q_CONV = 1.602e-19

    # SQL query returns a table with the nuclides (and their masses) transacted from reactor
    sql = ("SELECT resources.TimeCreated, compositions.NucId,"
           "compositions.MassFrac*resources.Quantity ")
    sql += (
        "FROM resources "
        "INNER JOIN compositions ON resources.QualId = compositions.QualId "
        "INNER JOIN transactions ON resources.TimeCreated = transactions.Time "
        "WHERE transactions.SenderId=13 "
        "GROUP BY resources.TimeCreated, compositions.NucId "
        "ORDER BY resources.TimeCreated;")
    cur = c.execute(sql)
    results = cur.fetchall()

    alldecayheats = []

    # Calculates decay heat (MW) at each timestep
    for time_step, nuc, mass in results:
        act = ACT_CONV * mass * data.decay_const(nuc) / data.atomic_mass(nuc)
        dh = Q_CONV * act * data.q_val(nuc)
        row = (time_step, nuc, dh)
        alldecayheats.append(row)

    return alldecayheats
Beispiel #15
0
def query(c):
    """Lists activities of all nuclides with respect to time for all facilities.

    Args:
        c: connection cursor to sqlite database.
    """

    # SQL query returns a table with the nuclides and their masses at each timestep
    sql = ("SELECT resources.TimeCreated, compositions.NucID,"
           "compositions.MassFrac*resources.Quantity ")
    sql += (
        "FROM resources "
        "INNER JOIN compositions ON resources.QualId = compositions.QualId "
        "GROUP BY resources.TimeCreated, compositions.NucId "
        "ORDER BY resources.TimeCreated;")
    cur = c.execute(sql)
    results = cur.fetchall()

    # Gives avogadro's number with a kg to g conversion
    CONV = 1000 * 6.022e23

    activities = []

    # Calculates activities (/s) of each nuclide at each timestep
    for time_step, nuc, mass in results:
        act = CONV * mass * data.decay_const(nuc) / data.atomic_mass(nuc)
        row = (time_step, nuc, mass, act)
        activities.append(row)

    return activities
Beispiel #16
0
def get_isodict(loc='bu8_tot.eq', valtype="mass"):
    isodict = {}
    for line in file(loc):
        zaid, atoms = line.split()
        if valtype == "mass":  
            isodict[int(zaid)] = data.atomic_mass(int(zaid))*float(atoms)
        elif valtype == "mol":
            isodict[int(zaid)] = float(atoms)
    return isodict
def addToLists(bC, bA, bCE, bAE, bCN, bAN, bCEN, bAEN, counts, abundance, name,
               element):
    """Checks and updates all best lists.

    Args:
        bC: List of best counts for all elements.
        bA: The list of best overall abundances.
        bCE: The list of names of the best elements overall, so far.
        bAE: List of best abundances names for natural elements.
        bCN: List of best counts for natural elements.
        bAN: List of best abundances' names.
        bCEN: List of names for natural elements for counts.
        bAEN: List of names for natural elements for abundances.
        counts: number of similar intensity counts for this element.
        abundance: List of most abundant elements so far.
        name: The name of the element in question.
        element: The element in question.
    """
    if name[-1] != 'M':
        if len(bC) < 11:
            bC.append(counts)
            bA.append(abundance)
            bCE.append(name)
            bAE.append(bCE[-1])

        else:
            bC[-1] = counts
            bA[-1] = abundance
            bCE[-1] = name
            bAE[-1] = bCE[-1]

        if len(bCN) < 11:
            if data.atomic_mass(element) <= 180:
                bCN.append(counts)
                bAN.append(abundance)
                bCEN.append(name)
                bAEN.append(bCE[-1])

        elif data.atomic_mass(element) <= 180:
            bCN[-1] = counts
            bAN[-1] = abundance
            bCEN[-1] = name
            bAEN[-1] = bCE[-1]
Beispiel #18
0
def reactor_power(sp_power, particles):
    """Returns the FHR's power

    Parameters
    ----------
    sp_power: float
        specific power of reactor [W/gU]
    particles: int
        number of triso particles in each fuel stripes's y-direction

    Returns
    -------
    t_u: float
        mass of Uranium [metric tonnes]
    power: float
        power of reactor [W]
    """

    wtp_u = ((0.00227325 * data.atomic_mass('U235')) +
             (0.02269476 * data.atomic_mass('U238'))) / \
            (0.00227325 * data.atomic_mass('U235') +
             0.02269476 * data.atomic_mass('U238') +
             0.03561871 * data.atomic_mass('O16') +
             0.00979714 * data.atomic_mass('C0')) * 100  # %
    V = (101 * 210 * particles * 36 * 4 / 3 * np.pi * (2135e-5)**3)  # cm3
    density = 11  # g/cc
    grams_u = V * density * (wtp_u) / 100  # gU
    t_u = grams_u * 1e-6  # t
    power = grams_u * sp_power  # W

    return t_u, power
Beispiel #19
0
def get_activity_Ci(isodict=moldict, valtype="mol"):
    activity_Ci={}
    ci_dec_per_sec = 3.7E10 # conversion factor 1 curie = 3.7E10 decays/sec 
    if valtype=="mol":
        for iso, mols in isodict.iteritems():
            dec_per_sec = mols*constants.N_A*data.decay_const(nucname.id(iso))
            activity_Ci[nucname.name(iso)]= dec_per_sec/ci_dec_per_sec
    elif valtype=="mass":
        for iso, mass in isodict.iteritems():
            dec_per_sec = mass*data.atomic_mass(nucname.id(iso))*constants.N_A*data.decay_const(nucname.id(iso))
            activity_Ci[nucname.name(iso)]= dec_per_sec/ci_dec_per_sec
    sorted_a = sorted(activity_Ci.iteritems(), key=operator.itemgetter(0))
    print sorted_a
    return activity_Ci
Beispiel #20
0
def activity(series):
    """Activity metric returns the instantaneous activity of a nuclide 
    in a material (material mass * decay constant / atomic mass) 
    indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId.
    """
    tools.raise_no_pyne('Activity could not be computed', HAVE_PYNE)
    mass = series[0]
    act = []
    for (simid, qual, res, obj, time, nuc), m in mass.iteritems():
        val = (1000 * data.N_A * m * data.decay_const(nuc) \
              / data.atomic_mass(nuc))
        act.append(val)
    act = pd.Series(act, index=mass.index)
    act.name = 'Activity'
    rtn = act.reset_index()
    return rtn
Beispiel #21
0
def activity(series):
    """Activity metric returns the instantaneous activity of a nuclide 
    in a material (material mass * decay constant / atomic mass) 
    indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId.
    """
    tools.raise_no_pyne('Activity could not be computed', HAVE_PYNE)
    mass = series[0]
    act = []
    for (simid, qual, res, obj, time, nuc), m in mass.iteritems():
        val = (1000 * data.N_A * m * data.decay_const(nuc) \
              / data.atomic_mass(nuc))
        act.append(val)
    act = pd.Series(act, index=mass.index)
    act.name = 'Activity'
    rtn = act.reset_index()
    return rtn
def checkAbundanceLists(abundance, name, bA, bAE, bAN, element, bAEN):
    """Checks and updates the best lists of abundant elements.

    Args:
        abundance: List of most abundant elements so far.
        name: The name of the element in question.
        bA: The list of best overall abundances.
        bAE: List of best abundances names for natural elements.
        element: The element in question.
        bAEN: List of names for natural elements for abundances.
    """
    #make sure we haven't seen this element before
    isThere = False
    for e in range(len(bAE) - 1):
        if bAE[e] == bAE[-1]:
            isThere = True

    #update abundance lists

    if (abundance < 1.0 and not isThere and abundance > 0.0
            and name[-1] != 'M'):
        smaller = 0
        for a in range(len(bA) - 1):
            if bA[smaller] > bA[a]:
                smaller = a
        if bA[smaller] < abundance:
            bA[smaller] = abundance
            bAE[smaller] = bAE[-1]
            smaller = 0
        #check for natural isotopes
        if data.atomic_mass(element) <= 180:
            smaller = 0
            for d in range(len(bAN) - 1):
                if bAN[smaller] > bAN[d]:
                    smaller = d
            if bAN[smaller] < abundance:
                bAN[smaller] = abundance
                bAEN[smaller] = bAEN[-1]
Beispiel #23
0
 def get_masses(self):
     return {
         nuc_name: data.atomic_mass(nuc_id) * u_to_g
         for nuc_id, nuc_name in zip(self.keys(), self.isotopes)
     }
Beispiel #24
0
def tape9_to_sparse(tape9s,
                    phi,
                    format='csr',
                    decaylib='decay.lib',
                    include_fission=True,
                    alpha_as_He4=False):
    """Converts a TAPE9 file to a sparse matrix.

    Parameters
    ----------
    tape9s : str or list of str
        The filename(s) of the tape file(s).
    phi : float
        The neutron flux in [n / cm^2 / sec]
    format : str, optional
        Format of the sparse matrix created.
    decaylib : str, optional
        A path to TAPE9 containg the decay data libraries if the decay libraries
        are not present in tape9. If this is a relative path, it is taken
        relative to the given tape9 location.
    include_fission : bool
        Flag for whether or not the fission data should be included in the
        resultant matrix.

    Returns
    -------
    mat : scipy.sparse matrix
        A sparse matrix in the specified layout.
    nucs : list
        The list of nuclide names in canonical order.
    """
    all_decays_consts, all_gammas, all_sigma_ij, all_sigma_fission, all_fission_product_yields = [], [], [], [], []
    all_alpha_ij, all_gamma_alphas = [], []
    nucs = set()
    mats = []
    # seed initial nucs with known atomic masses
    data.atomic_mass('u235')
    for tape9 in tape9s:
        print("Getting data for", tape9)
        t9 = parse_tape9(tape9)
        decay = find_decaylib(t9, tape9, decaylib)

        for i in data.atomic_mass_map.keys():
            if nucname.iselement(i):
                continue
            try:
                nucs.add(nucname.name(i))
            except RuntimeError:
                pass

        # get the tape 9 data
        nucs, decays_consts, gammas, gammas_alphas = decay_data(decay,
                                                                nucs=nucs)
        nucs, sigma_ij, sigma_fission, fission_product_yields, alpha_ij = cross_section_data(
            t9, nucs=nucs)

        if not include_fission:
            sigma_fission = {}
            fission_product_yields = {}
        if not alpha_as_He4:
            gammas_alphas = {}
            alpha_ij = {}
        all_decays_consts.append(decays_consts)
        all_gammas.append(gammas)
        all_sigma_ij.append(sigma_ij)
        all_sigma_fission.append(sigma_fission)
        all_fission_product_yields.append(fission_product_yields)
        all_alpha_ij.append(alpha_ij)
        all_gamma_alphas.append(gammas_alphas)

    nucs = sort_nucs(nucs)
    for i in range(len(tape9s)):
        dok = create_dok(phi, nucs, all_decays_consts[i], all_gammas[i],
                         all_sigma_ij[i], all_sigma_fission[i],
                         all_fission_product_yields[i], all_alpha_ij[i],
                         all_gamma_alphas[i])
        rows, cols, vals, shape = dok_to_sparse_info(nucs, dok)
        mats.append(SPMAT_FORMATS[format]((vals, (rows, cols)), shape=shape))
    return mats, nucs
# 
# Print molecular weight 
#
########################################################################
#
#
#
####### 
#
# imports
#
from pyne.data import atomic_mass
#
########################################################################
#
#
#
#######
#
# compute atomic mass 
#
print 'Type in the isotope; i.e., h2, cs137, co60'
isotope=raw_input()
print isotope,atomic_mass(isotope)
#
########################################################################
#
# EOF
#
########################################################################
Beispiel #26
0
 def get_numbers(self):
     N = {}
     for nuc_id, nuc_name in zip(self.keys(), self.isotopes):
         mass = self.material[nuc_id] * self.mass_g
         N[nuc_name] = (1 / (data.atomic_mass(nuc_id) * u_to_g) * mass)
     return N
Beispiel #27
0
    from pyne.data import atomic_mass
except:
    print('some weird import bug in pyne that makes the first import fail')
from pyne.data import atomic_mass
lines = sys.stdin.readlines()
w = open('out.txt', 'w')
inventory = {}
for line in lines:
    line = line.split(' ')
    if line[0] == 'time':
        del (line[0])
        time = np.asarray(line)
        time.astype(np.float)
    elif line[0] == 'Inv':
        del (line[0])
        iso = line[0] + line[1]
        iso = int(float(iso))
        del (line[0:3])
        del (line[-1])
        values = np.asarray(line)
        values = values.astype(np.float)
        inventory[iso] = values
    else:
        continue
total = 0.0
for iso in inventory:
    total += inventory[iso][0] * atomic_mass(iso)
for iso in inventory:
    inventory[iso] *= atomic_mass(iso) * total
print(inventory[92238])
Beispiel #28
0
def rel_activity(c):
    """Lists activity of spent fuel from all facilities relative to natural U 
       0, 10, 100, 1000, 10000 years after the end of the simulation.

    Args:
        c: connection cursor to sqlite database.
    """

    activities = activity.query(c)
    dict_acts = {}
    sim_time = activities[-1][0]

    # Conversion of time from months to seconds
    MCONV = 3.16e7 / 12

    # Conversion of years to seconds
    YCONV = 3.16e7

    dict_acts = {}
    tot_mass = 0.0
    sim_time = activities[-1][0]
    # Get list of one activity per nuclide wrt end of sim & sum total mass
    for time_step, nuc, mass, act in activities:
        tot_mass += mass
        sec = (sim_time - time_step) * MCONV
        acts = act * math.exp(-sec * data.decay_const(nuc))
        if nuc in dict_acts.keys():
            dict_acts[nuc] += acts
        else:
            dict_acts[nuc] = acts

    # Put back into list of tuples & sort by nuclide
    act_endsim = dict_acts.items()
    act_endsim.sort()

    # calculate natural uranium activity
    CONV_235 = 0.007*1000*6.022e23
    CONV_238 = 0.993*1000*6.022e23
    actU235 = CONV_235 * tot_mass * data.decay_const('U235') / data.atomic_mass('U235')
    actU238 = CONV_238 * tot_mass * data.decay_const('U235') / data.atomic_mass('U235')
    act_U = actU235 + actU238

    # calculate relative activities to nat U after 0, 10, 100, 1000, 10000 yrs
    rel_acts = []
    for nuc, act0 in act_endsim:
        t = 10
        nuc_acts = (act0,)
        while t <= 10000:
            sec = t * YCONV
            nuc_act = act0 * math.exp(-sec * data.decay_const(nuc))
            nuc_acts += (nuc_act,)
            t = 10 * t
        rel = []
        for i in nuc_acts:
            frac = i / act_U
            rel.append(frac)
        row = (nuc,) + tuple(rel)
        rel_acts.append(row)

    # Write to csv file 
    fname = 'relative_activity.csv'
    with open(fname,'w') as out:
        csv_out=csv.writer(out)
	csv_out.writerow(['nuclide', 
                          'rel_act at 0 yrs', 
                          'rel_act at 10 yrs', 
                          'rel_act at 100 yrs', 
                          'rel_act at 1000 yrs', 
                          'rel_act at 10000 yrs'])
        for row in rel_acts:
            csv_out.writerow(row)

    print('file saved as ' + fname + '!')
Beispiel #29
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 28 20:03:14 2018

@author: janv4
"""
import numpy as np
from pyne import data as pyne_data
from pyne import ace as pyne_ace
import matplotlib.pyplot as plt
import math
import Scattering

#============================ Define Isotope and ACE file
A = pyne_data.atomic_mass('C12')
Acefile = '6000.710nc'
AcePath='/Users/janv4/Desktop/Projects/' + \
        'MCNPDATA/MCNP_DATA/DVD-3/' + \
        'MORE_DATA_620-B/xdata/endf71x/C/'
OutputFileName = 'SXS_6000.txt'
OutputPath='/Users/janv4/Desktop/Personal/' + \
           'compphysicsnotes/NeutronTransport/SXS/Groups_10A/'

OF = open(OutputPath + OutputFileName, 'w')

#============================ Define flux spectrum to use as weighting
FluxWeightOption = 'Unity'

#============================ Define Groups
G = 10  #Number of energy groups