コード例 #1
0
    # ne on HFS and LFS should align, but grid definitions cause some misalignment
    rhop_fsa, ne_fsa, rhop_LFS, ne_LFS, rhop_HFS, ne_HFS = so.get_radial_prof(so.quants['ne'], plot=True)

    fig,ax = plt.subplots()
    ax.semilogy(rhop_LFS, neut_LFS/ne_LFS)
    ax.set_xlabel(r'$\rho_p$')
    ax.set_ylabel(r'$n_0/n_e$')

    # Obtain impurity charge state predictions from ioniz equilibrium
    imp = 'C'
    ne_cm3 = so.quants['ne'] *1e-6  #cm^-3
    n0_cm3 = so.quants['nn'] *1e-6 #cm^-3
    Te_eV = copy.deepcopy(so.quants['Te']) # eV
    Te_eV[Te_eV<1.]= 1.0
    filetypes=['acd','scd','ccd']
    atom_data = aurora.get_atom_data(imp,filetypes)

    logTe, fz = aurora.get_frac_abundances(
        atom_data,ne_cm3,Te_eV, n0_by_ne=n0_cm3/ne_cm3, plot=False)  # added n0

    frac=0.01  # 1%
    nz_cm3 = frac * ne_cm3[:,:,None] * fz  # (time,nZ,space) --> (R,nZ,Z)
    nz_cm3 = nz_cm3.transpose(0,2,1)

    # compute radiation density from each grid point
    out = aurora.compute_rad(imp,nz_cm3, ne_cm3, Te_eV, n0=n0_cm3, Ti=Te_eV,
                             prad_flag=True,thermal_cx_rad_flag=True)


    # plot total radiated power
    so.plot2d_b2(out['tot']*1e3, scale='log', label=r'$P_{rad}$ [$kW/m^3$]')
コード例 #2
0
nu_ioniz_star = aurora.atomic.plot_norm_ion_freq(S_z,
                                                 q_prof,
                                                 R_prof,
                                                 asim.A_imp,
                                                 Ti_prof,
                                                 rhop=rhop_in,
                                                 plot=True,
                                                 eps_prof=eps_prof)

# get average over charge states using fractional abundances in ionization equilibrium (no transport)
ne_avg = np.mean(kp['ne']['vals'], axis=0)  # average over time
Te_avg = np.mean(kp['Te']['vals'],
                 axis=0)  # assume on the same radial basis as ne_avg

# get fractional abundances on ne (cm^-3) and Te (eV) grid
atom_data = aurora.get_atom_data(imp, ['acd', 'scd'])
_Te, fz = aurora.atomic.get_frac_abundances(atom_data,
                                            ne_avg,
                                            Te_avg,
                                            rho=rhop)

fz_profs = np.zeros_like(S_z)
for cs in np.arange(S_z.shape[1]):
    fz_profs[:, cs] = interp1d(rhop, fz[:, cs])(rhop_in)

nu_ioniz_star = aurora.atomic.plot_norm_ion_freq(S_z,
                                                 q_prof,
                                                 R_prof,
                                                 asim.A_imp,
                                                 Ti_prof,
                                                 nz_profs=fz_profs,
コード例 #3
0
    raise ValueError('Specify PEC files for this ion!')

Te_eV = 3.5e3
ne_cm3 = 1e14

fig = plt.figure()
fig.set_size_inches(9, 6, forward=True)
ax1 = plt.subplot2grid((10, 1), (0, 0), rowspan=1, colspan=1, fig=fig)
ax2 = plt.subplot2grid((10, 1), (1, 0),
                       rowspan=9,
                       colspan=1,
                       fig=fig,
                       sharex=ax1)

# Find fractional abundances
atom_data = aurora.get_atom_data(ion, ['scd', 'acd'])

# always include charge exchange, although n0_cm3 may be 0
logTe, fz = aurora.get_frac_abundances(atom_data,
                                       np.array([
                                           ne_cm3,
                                       ]),
                                       np.array([
                                           Te_eV,
                                       ]),
                                       plot=False)

dlam_A = 0.00015

# now add spectra
out = aurora.get_local_spectrum(
コード例 #4
0
# inverse aspect ratio profile
eps_prof = (Rlfs - geqdsk["RMAXIS"]) / geqdsk[
    "RMAXIS"]  # use LFS radius for considerations on trapped particles
nu_ioniz_star = aurora.atomic.plot_norm_ion_freq(
    Sne_z,
    q_prof,
    R_prof,
    asim.A_imp,
    Ti_prof,
    rhop=rhop_in,
    plot=True,
    eps_prof=eps_prof,
)

# get fractional abundances on ne (cm^-3) and Te (eV) grid
atom_data = aurora.get_atom_data(imp, ["acd", "scd"])
_Te, fz = aurora.atomic.get_frac_abundances(atom_data, ne_cm3, Te_eV, rho=rhop)

fz_profs = np.zeros_like(Sne_z)
for cs in np.arange(Sne_z.shape[1]):
    fz_profs[:, cs] = interp1d(rhop, fz[:, cs])(rhop_in)

nu_ioniz_star = aurora.atomic.plot_norm_ion_freq(
    Sne_z,
    q_prof,
    R_prof,
    asim.A_imp,
    Ti_prof,
    nz_profs=fz_profs,
    rhop=rhop_in,
    plot=True,
コード例 #5
0
# load some kinetic profiles
examples_dir = '/home/sciortino/Aurora/examples'
geqdsk = omfit_eqdsk.OMFITgeqdsk(examples_dir + '/example.gfile')
profs = omfit_gapy.OMFITgacode(examples_dir + '/example.input.gacode')

# save kinetic profiles on a rhop (sqrt of norm. pol. flux) grid
kp = {'Te': {}, 'ne': {}}
kp['Te']['rhop'] = kp['ne']['rhop'] = np.sqrt(profs['polflux'] /
                                              profs['polflux'][-1])
kp['ne']['vals'] = profs['ne'] * 1e13  # 1e19 m^-3 --> cm^-3
kp['Te']['vals'] = profs['Te'] * 1e3  # keV --> eV

####
imp = 'Ca'

atom_data = aurora.get_atom_data(imp)
R_rates = aurora.interp_atom_prof(atom_data['acd'],
                                  np.log10(kp['ne']['vals']),
                                  np.log10(kp['Te']['vals']),
                                  x_multiply=True)

fig, ax = plt.subplots()
ls_cycle = aurora.get_ls_cycle()
for cs in np.arange(1, 10):  #R_rates.shape[1]):
    lss = next(ls_cycle)
    zz = R_rates.shape[1] - cs + 1
    ax.semilogy(kp['ne']['rhop'], R_rates[:, -cs], lss, label=f'{imp}{zz}+')
ax.legend(loc='best').set_draggable(True)
ax.set_xlabel(r'$\rho_p$')
ax.set_ylabel(r'R')
コード例 #6
0
    rates_label]  # default SCD file for chosen species

# this file can be provided by the user, or fetched/downloaded by Aurora using the following:
filepath = aurora.get_adas_file_loc(filename)

# now, load the file:
atomdat = aurora.adas_file(filepath)

# visualize content of specific ADAS file
atomdat.plot()

# now get multiple data files
atom_data = aurora.get_atom_data(
    ion,
    files=[
        'acd',  # recom
        'scd',  # ioniz
        'ccd'  # CX
    ])

# atom_data[rates_label][0] <-- density grid
# atom_data[rates_label][1] <-- temperature grid
# atom_data[rates_label][2] <-- data for each charge state

# ------------------------------------------------------- #
# interpolate on arbitrary ne and Te grid on the 2D plane
# load an example gEQDSK from the Aurora examples directory
from omfit_classes.omfit_eqdsk import OMFITgeqdsk

geqdsk = OMFITgeqdsk(
    os.path.expanduser('~') + os.sep + 'Aurora/examples/example.gfile')
コード例 #7
0
ls_cycle = aurora.get_ls_cycle()
for imp in ions_list:

    ls = next(ls_cycle)

    # read atomic data, interpolate and plot cooling factors
    line_rad_tot, cont_rad_tot = aurora.get_cooling_factors(
        imp,
        ne_cm3,
        Te_eV,
        show_components=False,
        plot=False,  #ax=ax1,
        line_rad_file=pue_base + f'plt_caic_mix_{imp}.dat',
        cont_rad_file=pue_base + f'prb_{imp}.dat')

    atom_data = aurora.get_atom_data(
        imp, {'plt': pue_base + f'plt_caic_mix_{imp}.dat'})
    #print(f'Temperature range of validity for {imp}: [{10**np.min(atom_data["plt"][1]):.1f}, {10**np.max(atom_data["plt"][1]):.1f}] eV')

    # total radiation (includes hard X-ray, visible, UV, etc.)
    a_plot.loglog(Te_eV / 1e3, cont_rad_tot + line_rad_tot, ls)
    a_legend.plot([], [], ls, label=f'{imp}')

a_legend.legend(loc='best').set_draggable(True)
a_plot.grid('on', which='both')
a_plot.set_xlabel('T$_e$ [keV]')
a_plot.set_ylabel('$L_z$ [$W$ $m^3$]')
plt.tight_layout()

######
# Can use the following for other ions:
# for imp in ['O','N','Ne']:
コード例 #8
0
files = {#'ca8': 'mglike_lfm14#ca8.dat',
         #'ca9': 'nalike_lgy09#ca9.dat',
         #'ca10': 'nelike_lgy09#ca10.dat',
         #'ca11': 'flike_mcw06#ca11.dat',
         #'ca14': 'clike_jm19#ca14.dat',  # unknown source; issue with format?
         #'ca15': 'blike_lgy12#ca15.dat',
         #'ca16': 'belike_lfm14#ca16.dat',
         #'ca17': 'lilike_lgy10#ca17.dat',
         'ca18': 'helike_adw05#ca18.dat',  # Whiteford, R-matrix 2005: https://open.adas.ac.uk/detail/adf04/copaw][he/helike_adw05][ca18.dat
         #'ca19': 'copha#h_bn#97ca.dat', # O'Mullane, 2015: https://open.adas.ac.uk/detail/adf04/copha][h/copha][h_bn][97ca.dat
         }

#colors = cm.rainbow(np.linspace(0, 1, len(files)))
#fig, ax = plt.subplots()

res = {}
for ii,cs in enumerate(files.keys()):
    res[cs] = colradpy(filepath+files[cs],[0],Te_grid,ne_grid,use_recombination=False,  # use_rec has issue with ca8 file
                       use_recombination_three_body=True, temp_dens_pair=True)
    
    res[cs].make_ioniz_from_reduced_ionizrates()
    res[cs].suppliment_with_ecip()
    res[cs].make_electron_excitation_rates()
    res[cs].populate_cr_matrix()
    res[cs].solve_quasi_static()


print(res['ca18'].data['processed']['acd'])

adas_data = aurora.get_atom_data('Ca',filetypes=['acd','scd'])
コード例 #9
0
'''

import numpy as np
import matplotlib.pyplot as plt
plt.ion()
import aurora

# load neutral H ADF15 file
filename = 'pec96#h_pju#h0.dat'
filepath = aurora.get_adas_file_loc(filename, filetype='adf15')
trs = aurora.read_adf15(filepath)

Te_eV = 80.  # eV
ne_cm3 = 1e14  # cm^-3

atom_data = aurora.get_atom_data('H', ['scd', 'acd'])

# always include charge exchange, although n0_cm3 may be 0
logTe, fz = aurora.get_frac_abundances(atom_data,
                                       np.array([
                                           ne_cm3,
                                       ]),
                                       np.array([
                                           Te_eV,
                                       ]),
                                       plot=False)

# now add spectra
out = aurora.get_local_spectrum(
    filepath,
    'H',