def fco_swu(series): """FcoSwu metric returns the separative work units required for each year in a simulation. This is written for simulations that use the Bright-lite Fuel Fab (i.e., the U235 and U238 are given separately in the FCO simulations, and the filtering is archetype-specific). """ tools.raise_no_pyne('SWU Required could not be computed', HAVE_PYNE) mass = pd.merge(series[0].reset_index(), series[1].reset_index(), on=['ResourceId'], how='inner').set_index(['ObjId', 'TimeCreated', 'NucId']) swu = [] prods = {} mass235 = {} m = mass[mass['Commodity'] == 'LWR Fuel'] for (obj, _, nuc), value in m.iterrows(): if 922320000 <= nuc <= 922390000: prods[obj] = prods.get(obj, 0.0) + value['Mass'] if nuc == 922350000: mass235[obj] = value['Mass'] x_feed = 0.0072 x_tails = 0.0025 for obj, m235 in mass235.items(): x_prod = m235 / prods[obj] swu0 = enr.swu(x_feed, x_prod, x_tails, product=prods[obj]) / 1e6 swu.append(swu0) m = m.groupby(level=['ObjId', 'TimeCreated'])['Mass'].sum() m = m.reset_index() # sum by years (12 time steps) swu = pd.DataFrame(data={'Year': m.TimeCreated.apply(lambda x: x//12), 'SWU': swu}, columns=['Year', 'SWU']) swu = swu.groupby('Year').sum() rtn = swu.reset_index() return rtn
def fco_swu(series): """FcoSwu metric returns the separative work units required for each year in a 200-yr simulation. This is written for FCO databases that use the Bright-lite (i.e., the U235 and U238 are given separately in the FCO simulations). """ tools.raise_no_pyne('SWU Required could not be computed', HAVE_PYNE) mass = pd.merge(series[0].reset_index(), series[1].reset_index(), on=['ResourceId'], how='inner').set_index(['ObjId', 'TimeCreated', 'NucId']) swu = [] prods = {} mass235 = {} m = mass[mass['Commodity'] == 'LWR Fuel'] for (obj, _, nuc), value in m.iterrows(): if 922320000 <= nuc <= 922390000: prods[obj] = prods.get(obj, 0.0) + value['Mass'] if nuc == 922350000: mass235[obj] = value['Mass'] x_feed = 0.0072 x_tails = 0.0025 for obj, m235 in mass235.items(): x_prod = m235 / prods[obj] swu0 = enr.swu(x_feed, x_prod, x_tails, product=prods[obj]) / 1e6 swu.append(swu0) m = m.groupby(level=['ObjId', 'TimeCreated'])['Mass'].sum() m = m.reset_index() # sum by years (12 time steps) swu = pd.DataFrame(data={'Year': m.TimeCreated.apply(lambda x: x//12), 'SWU': swu}, columns=['Year', 'SWU']) swu = swu.groupby('Year').sum() rtn = swu.reset_index() return rtn
def fco_u_mined(mats, trans): """FcoUMined metric returns the uranium mined in tonnes for each year in a simulation. This is written for simulations that use the Bright-lite Fuel Fab (i.e., the U235 and U238 are given separately in the FCO simulations, and the filtering is archetype-specific). """ tools.raise_no_pyne('U_Mined could not be computed', HAVE_PYNE) mass = pd.merge(mats, trans, on=['ResourceId'], how='inner') mass = mass.set_index(['ObjId', 'TimeCreated', 'NucId']) u = [] prods = {} mass235 = {} m = mass[mass['Commodity'] == 'LWR Fuel'] for (obj, _, nuc), value in m.iterrows(): if 922320000 <= nuc <= 922390000: prods[obj] = prods.get(obj, 0.0) + value['Mass'] if nuc == 922350000: mass235[obj] = value['Mass'] x_feed = 0.0072 x_tails = 0.0025 for obj, m235 in mass235.items(): x_prod = m235 / prods[obj] feed = enr.feed(x_feed, x_prod, x_tails, product=prods[obj]) / 1000 u.append(feed) m = m.groupby(level=['ObjId', 'TimeCreated'])['Mass'].sum() m = m.reset_index() # sum by years (12 time steps) u = pd.DataFrame(data={ 'Year': m.TimeCreated.apply(lambda x: x // 12), 'UMined': u }, columns=['Year', 'UMined']) u = u.groupby('Year').sum() rtn = u.reset_index() return rtn
def fco_u_mined(mats, trans): """FcoUMined metric returns the uranium mined in tonnes for each year in a simulation. This is written for simulations that use the Bright-lite Fuel Fab (i.e., the U235 and U238 are given separately in the FCO simulations, and the filtering is archetype-specific). """ tools.raise_no_pyne('U_Mined could not be computed', HAVE_PYNE) mass = pd.merge(mats, trans, on=['ResourceId'], how='inner') mass = mass.set_index(['ObjId', 'TimeCreated', 'NucId']) u = [] prods = {} mass235 = {} m = mass[mass['Commodity'] == 'LWR Fuel'] for (obj, _, nuc), value in m.iterrows(): if 922320000 <= nuc <= 922390000: prods[obj] = prods.get(obj, 0.0) + value['Mass'] if nuc==922350000: mass235[obj] = value['Mass'] x_feed = 0.0072 x_tails = 0.0025 for obj, m235 in mass235.items(): x_prod = m235 / prods[obj] feed = enr.feed(x_feed, x_prod, x_tails, product=prods[obj]) / 1000 u.append(feed) m = m.groupby(level=['ObjId', 'TimeCreated'])['Mass'].sum() m = m.reset_index() # sum by years (12 time steps) u = pd.DataFrame(data={'Year': m.TimeCreated.apply(lambda x: x//12), 'UMined': u}, columns=['Year', 'UMined']) u = u.groupby('Year').sum() rtn = u.reset_index() return rtn
def decay_heat(series): """Decay heat metric returns the instantaneous decay heat of a nuclide in a material (Q value * activity) indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId. """ tools.raise_no_pyne('DecayHeat could not be computed', HAVE_PYNE) act = series[0] dh = [] for (simid, qual, res, obj, time, nuc), a in act.iteritems(): val = (data.MeV_per_MJ * a * data.q_val(nuc)) dh.append(val) dh = pd.Series(dh, index=act.index) dh.name = 'DecayHeat' rtn = dh.reset_index() return rtn
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