Exemplo n.º 1
0
    """Compute the integral sensitivity using an assumed spectrum."""
    interps = get_cross_section_interps(isos)
    E = np.logspace(np.log10(low), np.log10(high), 4e5)
    Eth = np.logspace(np.log10(low), np.log10(0.625), 4e5)
    Ef = np.logspace(np.log10(0.625), np.log10(high), 4e5)
    bot = trapz(phi.evaluate(E), E)
    bot_th = trapz(phi.evaluate(Eth), Eth)
    bot_f = trapz(phi.evaluate(Ef), Ef)
    print(bot, bot_th, bot_f)
    sens = []
    for iso in isos:
        top = trapz(interps[iso](E) * phi.evaluate(E), E)
        top_th = trapz(interps[iso](Eth) * phi.evaluate(Eth), Eth)
        top_f = trapz(interps[iso](Ef) * phi.evaluate(Ef), Ef)
        sens.append((iso, top / bot, top_th / bot_th, top_f / bot_f))
    return sorted(sens, key=lambda x: -x[1])


if __name__ == "__main__":
    import numpy as np

    from master_data import isos, isos_str
    from flux_spectrum import Flux
    pwr = Flux(7.0, 600.0)
    sens = compute_integral_sensitivities(isos, pwr)
    for s in sens:
        S = list(s)
        S[0] = isos_str[S[0]]
        S = tuple(S)
        print(r" %s & %.4f &  %.4f &  %.4f\\" % S)
Exemplo n.º 2
0
        fun = lambda x: flux(x) * interps[iso](x)
        for i in range(len(eb) - 1):
            E = sp.logspace(sp.log10(eb[i + 1]), sp.log10(eb[i]), 1e4)
            top = trapz(fun(E), E)
            responses['response'][iso][i] = top / responses['phi'][i]
    pickle.dump(responses, open(directory + '/code/' + name, 'wb'))
    return responses


if __name__ == "__main__":
    from master_data import isos, isos_str, isos_colors, img_directory
    from flux_spectrum import Flux
    from multigroup_utilities import plot_multigroup_data
    from nice_plots import init_nice_plots
    init_nice_plots()
    import matplotlib.pyplot as plt
    struct = 'wims69'
    phi = Flux(7.0, 600.0)
    resp = generate_responses(isos,
                              phi.evaluate,
                              name='test_resp.p',
                              overwrite=True)
    for iso in isos:
        x, y = plot_multigroup_data(resp['eb'], resp['response'][iso])
        plt.loglog(x, y, ls='-', label=isos_str[iso], color=isos_colors[iso])
    plt.legend(loc=0, ncol=4)
    plt.axis([1e-5, 1e7, 1e-11, 1e5])
    plt.xlabel('E (eV)')
    plt.ylabel('$\sigma_f$ (b)')
    plt.savefig(img_directory + 'fission_responses.pdf')
    #plt.show()
def generate_all_responses():

    # 2 group
    struct = 'tg0_625'
    fun = lambda x: 0 * x + 1
    resp = generate_responses(isos,
                              fun,
                              struct=struct,
                              name='tg0_625_flat_resp.p',
                              overwrite=True)
    pwr = Flux(7.0, 600.0)
    resp = generate_responses(isos,
                              pwr.evaluate,
                              struct=struct,
                              name='tg0_625_pwr_resp.p',
                              overwrite=True)
    triga = Flux(2.0, 600.0)
    resp = generate_responses(isos,
                              triga.evaluate,
                              struct=struct,
                              name='tg0_625_triga_resp.p',
                              overwrite=True)

    # 32 group
    struct = 'lwr32'
    fun = lambda x: 0 * x + 1
    resp = generate_responses(isos,
                              fun,
                              struct=struct,
                              name='lwr32_flat_resp.p',
                              overwrite=True)
    pwr = Flux(7.0, 600.0)
    resp = generate_responses(isos,
                              pwr.evaluate,
                              struct=struct,
                              name='lwr32_pwr_resp.p',
                              overwrite=True)
    triga = Flux(2.0, 600.0)
    resp = generate_responses(isos,
                              triga.evaluate,
                              struct=struct,
                              name='lwr32_triga_resp.p',
                              overwrite=True)

    # 69 group
    struct = 'wims69'
    fun = lambda x: 0 * x + 1
    resp = generate_responses(isos,
                              fun,
                              struct=struct,
                              name='wims69_flat_resp.p',
                              overwrite=True)
    pwr = Flux(7.0, 600.0)
    resp = generate_responses(isos,
                              pwr.evaluate,
                              struct=struct,
                              name='wims69_pwr_resp.p',
                              overwrite=True)
    triga = Flux(2.0, 600.0)
    resp = generate_responses(isos,
                              triga.evaluate,
                              struct=struct,
                              name='wims69_triga_resp.p',
                              overwrite=True)

    # 238 group
    struct = 'scale252'
    fun = lambda x: 0 * x + 1
    resp = generate_responses(isos,
                              fun,
                              struct=struct,
                              name='scale252_flat_resp.p',
                              overwrite=True)
    pwr = Flux(7.0, 600.0)
    resp = generate_responses(isos,
                              pwr.evaluate,
                              struct=struct,
                              name='scale252_pwr_resp.p',
                              overwrite=True)
    triga = Flux(2.0, 600.0)
    resp = generate_responses(isos,
                              triga.evaluate,
                              struct=struct,
                              name='scale252_triga_resp.p',
                              overwrite=True)
Exemplo n.º 4
0
###############################################################################

rc('font', **{'family': 'serif'})
rcParams['xtick.direction'] = 'out'
rcParams['ytick.direction'] = 'out'
rcParams['xtick.labelsize'] = 12
rcParams['ytick.labelsize'] = 12
rcParams['lines.linewidth'] = 1.85
rcParams['axes.labelsize'] = 15
rcParams.update({'figure.autolayout': True})

###############################################################################
#                               flux
###############################################################################
# flux
flux = Flux(1/0.833)
phi = flux.evaluate

#
total_phi = 0
e = np.logspace(-5, 9, 100)
for i in range(len(e) - 1):
    total_phi += quad(phi, e[i], e[i+1])[0]


fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.set_xlabel('Energy (eV)')
ax.set_ylabel('$\Phi$ $cm^{-2}s{-1}$')
ax.set_xscale('log')
ax.set_yscale('log')
Exemplo n.º 5
0
def activity_calc(foil,
                  m,
                  P,
                  t_i,
                  t_ci,
                  t_cf,
                  t_f,
                  cd_covered=False,
                  cd_thickness=0.05,
                  plotname='decay.png'):
    '''
    Stuff.
    '''
    reaction_list = list(foil['reactions'].values())
    reaction_names = list(foil['reactions'].keys())
    num_reactions = len(reaction_list)

    # facts of life
    Na = 6.0221409E23  # atoms / mol

    # set up N_i
    N_i = np.zeros(num_reactions + 1)
    N_i[0] = (m * 1E-3 * Na) / foil['M']

    # calculate decay constants with halflifes
    half_lives = np.ones(num_reactions + 1)
    for i, reaction in enumerate(reaction_list):
        half_lives[i + 1] = reaction['halflife']
    decay_constants = np.log(2) / half_lives
    decay_constants[0] = 0

    # find normalized reaction rates
    # load in spectrum
    phi = Flux(1 / 0.833)

    def reaction_rate(e, phi, sigma, cd_fun):
        return (sigma(e) * 1E-24) * phi.evaluate(e) * cd_fun(e)

    if cd_covered:

        def cd(e):
            term = ((Cd['rho'] * Na) / Cd['M']) * cd_thickness * 1E-24
            cd_xs = Cd['reactions']['n,tot']['func']
            factor = np.exp(-term * cd_xs(e) * 5)
            return factor
    else:

        def cd(e):
            return 1

    R = np.zeros(num_reactions + 1)
    R[0] = 1
    total_phi = 0
    e = np.logspace(-5, 9, 100)
    for i in range(len(e) - 1):
        total_phi += quad(phi.evaluate, e[i], e[i + 1])[0]
        for j, reaction in enumerate(reaction_list):
            R[j + 1] += quad(reaction_rate,
                             e[i],
                             e[i + 1],
                             args=(phi, reaction['func'], cd))[0]
    R = R / total_phi
    R[0] = 0

    # plot xs
    plot_xs(reaction_names, reaction_list, phi.evaluate, cd)

    def decay(N, t, lam, t_i, R, P, num_reactions):
        '''
        Radioactive decay.
        '''
        phi_i = (1 / 100) * 4E12 * (1 +
                                    1 / 0.833) * P  # flux at a certain power

        # flux info
        if t < t_i:
            phi_0 = phi_i
        else:
            phi_0 = 0

        A = np.diag(-lam)
        A[:, 0] = R * phi_0
        return A.dot(N)

    # solve
    times = np.linspace(0, t_f, 10000)
    N = odeint(decay,
               N_i,
               times,
               args=(decay_constants, t_i, R, P, num_reactions))
    activities = decay_constants * N

    # counting
    counts = list(np.zeros(num_reactions))  # fix this this is garbage wow
    for i, reaction in enumerate(reaction_list):
        act_fun = interp1d(times,
                           activities[:, i + 1],
                           bounds_error=False,
                           fill_value=0)
        counts[i] = (reaction['erg'], quad(act_fun, t_ci, t_cf)[0])

    # Bq to uCi
    activities *= (1 / 3.7E10) * 1E6
    total_activity = np.sum(activities, axis=1)

    # print some info
    total_act_fun = interp1d(times,
                             total_activity,
                             bounds_error=False,
                             fill_value=0)
    scram_act = total_act_fun(t_i)
    count_act = total_act_fun(t_ci)
    print('Counting Activity:  {:4.2e} uCi'.format(float(count_act)))

    # plotting
    if plotname:
        plot_activities(plotname, reaction_list, times, activities,
                        total_activity, t_i, t_ci, t_cf, False)

    return counts, scram_act