asim.source_rad_prof.T) ax.set_xlabel(r'$\rho_p$') ax.set_ylabel('time [s]') # set time-independent transport coefficients (flat D=1 m^2/s, V=-2 cm/s) D_z = 1e4 * np.ones(len(asim.rvol_grid)) # cm^2/s V_z = -2e2 * np.ones(len(asim.rvol_grid)) # cm/s # run Aurora forward model and plot results out = asim.run_aurora(D_z, V_z, plot=False) nz_all = out[0] # impurity charge state densities are the first element of "out" nz_init = nz_all[:,:,-1] # calculate dilution cooling rad = aurora.compute_rad( imp, out[0].transpose(2,1,0), asim.ne, asim.Te, prad_flag=True) tot_rad_dens = rad['tot'] # W/cm^3 line_rad_all = rad['line_rad'].T # W/cm^3 time_grid = copy.deepcopy(asim.time_grid) # modify background temperature and density profiles based on tot_rad_dens rhop_grid = asim.rhop_grid Erad = np.trapz(tot_rad_dens[-1*n_rep:,:],axis=0,dx=dt) * 1.6e-13 Te_eV = radiation_cooling(rhop, rhop_grid, ne_cm3, nd_cm3, nz_init, Te_eV, Erad) ne_cm3, Te_eV = dilution_cooling(rhop, rhop_grid, ne_cm3, nd_cm3, Te_eV, nz_init*0., nz_init) kp['Te']['vals'] = Te_eV kp['ne']['vals'] = ne_cm3 # update kinetic profile dependencies: asim.setup_kin_profs_depts()
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$]') if device=='CMOD': overplot_machine(shot, plt.gca()) # overplot machine tiles # plot total line radiated power so.plot2d_b2(out['line_rad'].sum(1)*1e3, scale='log', label=r'$P_{line,rad}$ [$kW/m^3$]') if device=='CMOD': overplot_machine(shot, plt.gca()) # overplot machine tiles #compare_midplane_n0_with_expt(shot, rhop_LFS, neut_LFS*1e-6)
# check time grid: _ = aurora.create_time_grid(namelist['timing'], plot=plot) # set time-independent transport coefficients (flat D=1 m^2/s, V=-2 cm/s) D_z = 1e4 * np.ones(len(asim.rvol_grid)) # cm^2/s V_z = -2e2 * np.ones(len(asim.rvol_grid)) # cm/s # run Aurora forward model and plot results out = asim.run_aurora(D_z, V_z, plot=plot) # extract densities and particle numbers in each simulation reservoir nz, N_wall, N_div, N_pump, N_ret, N_tsu, N_dsu, N_dsul, rcld_rate, rclw_rate = out # add radiation asim.rad = aurora.compute_rad(imp, nz.transpose(2,1,0), asim.ne, asim.Te, prad_flag=True, thermal_cx_rad_flag=False, spectral_brem_flag=False, sxr_flag=False) if plot: # plot radiation profiles over radius and time aurora.slider_plot(asim.rvol_grid, asim.time_out, asim.rad['line_rad'].transpose(1,2,0), xlabel=r'$r_V$ [cm]', ylabel='time [s]', zlabel=r'Line radiation [$MW/m^3$]', labels=[str(i) for i in np.arange(0,nz.shape[1])], plot_sum=True, x_line=asim.rvol_lcfs) # plot Delta-Zeff profiles over radius and time asim.calc_Zeff() if plot: # plot variation of Zeff due to simulated impurity:
nz_cxr[:, cs, -1], c=col, ls='-', label=f'{imp}{cs}+') ax.plot([], [], 'w-', label=' ') ax.plot([], [], 'k-', label='with CXR') ax.plot([], [], 'k--', label='without CXR') ax.legend(loc='best').set_draggable(True) ax.set_xlabel(r'$\rho_p$') ax.set_ylabel(r'$n_z$ [$cm^{-3}$]') ax.set_xlim([0.85, np.max(asim.rhop_grid)]) # add radiation asim.rad = aurora.compute_rad(imp, nz.transpose(2, 1, 0), asim.ne, asim.Te, prad_flag=True, thermal_cx_rad_flag=False) asim_cxr.rad = aurora.compute_rad(imp, nz_cxr.transpose(2, 1, 0), asim.ne, asim.Te, n0=asim_cxr.n0, Ti=asim_cxr.Ti, prad_flag=True, thermal_cx_rad_flag=True) c_cycle = aurora.get_color_cycle() fig, ax = plt.subplots() for cs in np.arange(nz.shape[1] - 1): # fully-stripped ions have no line radiation
# run Aurora forward model and plot results out = asim.run_aurora(D_z, V_z, plot=True) # extract densities and particle numbers in each simulation reservoir nz, N_wall, N_div, N_pump, N_ret, N_tsu, N_dsu, N_dsul, rcld_rate, rclw_rate = out # add radiation asim.rad = aurora.compute_rad( imp, nz.transpose(2, 1, 0), asim.ne, asim.Te, prad_flag=True, thermal_cx_rad_flag=False, spectral_brem_flag=False, sxr_flag=True, adas_files_sub={ 'pls': '/home/sciortino/atomlib/atomdat_master/pue2020_data/pls_Ca_9.dat', 'prs': '/home/sciortino/atomlib/atomdat_master/pue2020_data/prs_Ca_9.dat' }) # plot radiation profiles over radius and time aurora.slider_plot(asim.rhop_grid, asim.time_out, asim.rad['sxr_line_rad'].transpose(1, 2, 0), xlabel=r'$\rho_p$', ylabel='time [s]', zlabel=r'SXR Line radiation [$MW/m^3$]',
# --------------------------- # Now, let's say we want to compute the radiated power by an impurity # For simplicity, let's construct some charge state densities using fractional # abundances at ionization equilibrium. Choose ion concentration (wrt to electrons): frac = 1e-3 _Te, fz = aurora.atomic.get_frac_abundances(atom_data, ne_cm3_2d, Te_eV_2d, plot=False) # create some constant-fraction impurity charge state density spatial profiles nz_cm3 = frac * ne_cm3_2d[:, None, :] * fz.transpose(0, 2, 1) # (R,nZ,Z) # calculate radiation from chosen ion for these conditions rad = aurora.compute_rad( ion, nz_cm3, # R,nZ,Z ne_cm3_2d, Te_eV_2d, prad_flag=True) fig, axs = plt.subplots(1, 2, figsize=(10, 5)) cntr = axs[0].contourf(R, Z, nz_cm3[:, 16, :]) cbar = plt.colorbar(cntr, ax=axs[0]) cbar.set_label(fr'$n_{{{ion}17+}}$') cntr = axs[1].contourf(R, Z, rad['line_rad'][:, 16, :]) cbar = plt.colorbar(cntr, ax=axs[1]) cbar.set_label(fr'$P_{{line,{ion}17+}}$ [MW/m$^3$]')