919 KiB
919 KiB
In [1]:
import numpy as np
import pandas as pd
import os as os
import scipy.optimize as optimization
import glob as glob
import h5py as h5py
from scipy.signal import argrelextrema
pd.options.mode.chained_assignment = None In [288]:
import matplotlib
matplotlib.use('TkAgg')
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
NEJM = sns.color_palette(palette = ['#bc3c29',
'#0072bf',
'#e18727',
'#20854e',
'#7876b1',
'#6f99ad',
'#ffdc91',
'#ee4c97'])
sns.set(
context='paper',
style='white',
palette=NEJM,
font='sans-serif',
font_scale=1,
color_codes=False,
rc = {'figure.dpi' : 150,
'text.usetex' : True,
'axes.labelsize' : 10,
'xtick.labelsize' : 10,
'ytick.labelsize' : 10,
'legend.fontsize' : 10,
'xtick.bottom' : True,
'xtick.minor.bottom' : False,
'ytick.left' : True,
'ytick.minor.left' : False
})In [285]:
%run "../../mcelectron-analysis/functions/particles/plot_df_part.py"
%run "../../mcelectron-analysis/functions/populations/plot_df_pop.py"<Figure size 600x400 with 0 Axes>
In [132]:
plot_dir = '/Users/ChristianReiling/Documents/Masterarbeit/katrin-plasma/docs/vortraege/christian/colab19/tex/pics/plots/'
dpi = 150In [290]:
# Load Histograms from Analysis
df_part_e = pd.read_csv("csv_data/1e5_run_1/df_part_e.csv")
df_part_all = pd.read_csv("csv_data/1e5_run_1/df_part_all.csv")
df_part_rw = pd.read_csv("csv_data/1e5_run_1/df_part_rw.csv")
df_part_rw_zoom = pd.read_csv("csv_data/1e5_run_1/df_part_rw_zoom.csv")
df_pop = pd.read_csv("csv_data/1e5_run_1/df_pop.csv")In [291]:
# Load Data from Ference
df_fer = pd.read_csv('data/reseedfrecomb.txt', header=None, delim_whitespace=True)
df_fer.columns = ['E_pot', 'N_pot']
df_fer['E'] = pow(10, df_fer.E_pot[:-1])
df_fer['N'] = pow(10, df_fer.N_pot[:-1])/df_fer['E']In [440]:
# Define Analytic Beta Spectrum
from scipy.optimize import curve_fit
def beta_dist(E, mnu):
n = 8.279530767391265e+23 #normation
E0 = 18.574e3 # endpoint
dc = 1.2072343416696292e-47 #decay constant
me = 511e3 # electron mass
def beta(E):
gamma = 1+E/me
return np.sqrt(1 - pow(gamma,-2))
def fermi(eta):
return 2*np.pi*eta/(1-np.exp(-2*np.pi*eta))
if E > (E0-mnu):
return 0.
if E <= 0:
return 0.
eta =2/beta(E)/137
p = np.sqrt(E*E + 2 * E * me)
sqrtterm = np.sqrt(pow(E0-E,2) - mnu**2)
return n*dc*fermi(eta)*p*(E+me)*(E0-E)*sqrtterm
beta_dist = np.vectorize(beta_dist_mass, otypes=[np.float])
def beta(E, C, pot):
return C*beta_dist_mass(E, 0)*pow(E, pot)
beta = np.vectorize(beta, otypes=[np.float])
def MB(E, T, C, pot):
kb = 8.6173303e-05
return C*2*np.sqrt(E/np.pi) * pow(kb*T, -3/2) * np.exp(-E/kb/T) * pow(E, pot)
MB = np.vectorize(MB, otypes=[np.float])
def dndE_ana(E):
A = 0.045**2*np.pi
return 1e11/A*np.sqrt(511e3/2/E)*beta(E, 1, 0)/3e8
dndE_ana = np.vectorize(dndE_ana, otypes=[np.float])
def dndE_scale(E, scale):
return dndE_ana(E)*scale
dndE_scale = np.vectorize(dndE_scale, otypes=[np.float])
def dndE_scale_from_plot(E, scale):
return scale * beta(E, 56713458, -0.5)
E_beta_ana = np.linspace(1e2, 18500, 100)
dndE_beta_ana = dndE_ana(E_ana)In [449]:
# get scale of beta
df_fit = pd.DataFrame()
df_temp = df_part_e[df_part_e.Emid > 1e3]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'z':df_temp.z})
df_fit = df_fit.append(df_temp)
popt, pcov = curve_fit(lambda x, C: beta(x, C, -0.5), df_fit.E, df_fit.dndE)
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="dndE", data=df_fit, legend = 'brief')
ax.plot(df_fit.E, beta_fit(df_fit.E, popt[0]))
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel ('Electron energy (eV)')
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
my_scale = popt[0]In [451]:
# fit scale to ference data
df_temp = df_fer[df_fer.E > 1e3]
E_fit = df_temp.E
N_fit = df_temp.N
popt, pcov = curve_fit(lambda E, N: N*beta(E, my_scale, -0.5), E_fit, N_fit)
fig, ax = plt.subplots()
ax.plot(E_fit, N_fit, 'x', label = 'data')
ax.plot(E_fit, popt[0]*beta(E_fit, my_scale, -0.5), label = 'fit')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel ('electron energy (eV)')
ax.set_ylabel (r'differential density dn/dE (m$^{-3}$ eV$^{-1}$)')
ax.legend()
ax.plot()
fer_scale = 1/popt[0]
print("Scale:\t" + str(fer_scale))
#print (chisquare(N, f_exp=beta(E, *popt), ddof = 2))Scale: 3078727645296.409
In [445]:
# Comparison of Ferenc
df_plot = pd.DataFrame()
df_temp = df_part_e
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = df_temp.groupby(['Emid'], as_index = False).mean()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'mod':'Average'})
df_plot = df_plot.append(df_temp)
df_temp = df_part_e[df_part_e.z == 5]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'mod':'Mid'})
df_plot = df_plot.append(df_temp)
df_temp = pd.DataFrame({'E':df_fer.E, 'dndE':df_fer.N*fer_scale, 'mod':'Fer'})
df_plot = df_plot.append(df_temp)
#E_temp = np.linspace(1e2, 1.8e3, 100)
#df_temp = pd.DataFrame({'E':E_temp, 'dndE':dndE_ana(E_temp), 'mod':'Beta'})
#df_plot = df_plot.append(df_temp)
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="dndE", data=df_plot,
style = 'mod',
hue = 'mod',
err_style=None, legend = 'full')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel ('Electron energy (eV)')
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
fig.savefig(plot_dir + 'plot_part_e_dndE_zmid_comp_fer.png', dpi = dpi, bbox_inches='tight')In [482]:
# Comparison of Ferenc
df_plot = pd.DataFrame()
df_temp = df_part_e
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = df_temp.groupby(['Emid'], as_index = False).mean()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'mod':'Average'})
df_plot = df_plot.append(df_temp)
df_temp = df_part_e[df_part_e.z == 5]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'mod':'Mid'})
df_plot = df_plot.append(df_temp)
df_temp = pd.DataFrame({'E':df_fer.E, 'dndE':df_fer.N*fer_scale, 'mod':'Fer'})
df_plot = df_plot.append(df_temp)
df_temp = df_part_e[df_part_e.z == -3]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'mod':'Rw'})
df_plot = df_plot.append(df_temp)
df_temp = df_part_e[df_part_e.z == 10]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'mod':'End'})
df_plot = df_plot.append(df_temp)
#E_temp = np.linspace(1e2, 1.8e3, 100)
#df_temp = pd.DataFrame({'E':E_temp, 'dndE':dndE_ana(E_temp), 'mod':'Beta'})
#df_plot = df_plot.append(df_temp)
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="dndE", data=df_plot,
style = 'mod',
hue = 'mod',
err_style=None, legend = 'full')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel ('Electron energy (eV)')
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
fig.savefig(plot_dir + '/plot_part_e_dndE_z3_comp_fer.png', dpi = dpi, bbox_inches='tight')In [452]:
# Fancy tube plot
fig, ax = plt.subplots(figsize=[21/2.54, 7/2.54])
plot_part_e_dndE_hm(df_part_e, fig, ax)
fig.savefig(plot_dir + 'plot_part_e_dndE_hm.png', dpi = dpi, bbox_inches='tight')In [458]:
# Spectra Comp
df_plot = pd.DataFrame()
df_temp = df_part_e#[df_part_e.Emid > 1e2]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'z':df_temp.z, 'mod':'Barrier'})
df_plot = df_plot.append(df_temp)
t_max = np.sort(df_pop.t.unique())[-1]
df_temp = df_pop#[df_pop.Emin > 1e2]
df_temp = df_temp[(df_temp.species == 'e-') & (df_temp.t == t_max)]
df_temp['zmid'] = (df_temp['zmin']+df_temp['zmax'])/2
df_temp['Emid'] = (df_temp['Emin']+df_temp['Emax'])/2
df_temp['dndE'] = df_temp['n']/(df_temp['Emax'] - df_temp['Emin'])
df_temp = df_temp.groupby(['zmid','Emid'], as_index = False).mean()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'z':df_temp.zmid, 'mod':'Runtime'})
df_plot = df_plot.append(df_temp)
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="dndE", data=df_plot,
style = 'mod',
hue = 'mod',
legend = 'full')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel ('Electron energy (eV)')
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
fig.savefig(plot_dir + '/pop_part_comp.png', dpi = dpi, bbox_inches='tight')In [459]:
# Ana Beta Comp
df_plot = pd.DataFrame()
df_temp = df_part_e[df_part_e.Emid > 1e2]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'z':df_temp.z, 'mod':'Barrier'})
df_plot = df_plot.append(df_temp)
t_max = np.sort(df_pop.t.unique())[-1]
df_temp = df_pop[df_pop.Emin > 1e2]
df_temp = df_temp[(df_temp.species == 'e-') & (df_temp.t == t_max)]
df_temp['zmid'] = (df_temp['zmin']+df_temp['zmax'])/2
df_temp['Emid'] = (df_temp['Emin']+df_temp['Emax'])/2
df_temp['dndE'] = df_temp['n']/(df_temp['Emax'] - df_temp['Emin'])
df_temp = df_temp.groupby(['zmid','Emid'], as_index = False).mean()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'z':df_temp.zmid, 'mod':'Runtime'})
df_plot = df_plot.append(df_temp)
E_temp = pow(10, np.linspace(2, 4.2, 100))
#E_temp = np.linspace(100, 18600, 100)
df_temp = pd.DataFrame({'E':E_temp, 'dndE':dndE_ana(E_temp), 'z':0, 'mod':'Beta'})
df_plot = df_plot.append(df_temp)
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="dndE", data=df_plot,
style = 'mod',
hue = 'mod',
legend = 'full')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel ('Electron energy (eV)')
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
#fig.savefig(plot_dir + '/ana_beta_comp.png', dpi = dpi, bbox_inches='tight')In [298]:
# nT2 density
reds = np.array([5e-4, 0.033, 1, 0.034])
zs = np.array([-3, 0, 5, 10])
slopes = (reds[1:]-reds[:-1])/(zs[1:]-zs[:-1])
def get_red(z):
i = np.searchsorted(zs, z, side='right', sorter=None) - 1
if i == 3:
i = 2
return 1e21*(reds[i] + (z-zs[i])*slopes[i])
get_red = np.vectorize(get_red, otypes = [float])In [299]:
# n_e, n_T2, n_T+
df_temp = df_part_all[df_part_all.species == 'e-'].groupby(['z'], as_index = False).mean()
z = df_temp.z
nT2 = get_red(z)
df_plot = pd.DataFrame()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp.z, 'n':df_temp.n, 'species':'e-'}))
df_plot = df_plot.append(pd.DataFrame({'z':z, 'n':nT2, 'species':'T2'}))
df_temp = df_part_all[df_part_all.species != 'e-'].groupby(['z', 'species'], as_index = False).mean()
df_temp = df_temp.groupby('z', as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp.z, 'n':df_temp.n, 'species':'ions'}))
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="z", y="n", data=df_plot,
style = 'species',
hue = 'species',
legend = 'full')
ax.set_xscale('linear')
ax.set_yscale('log')
ax.set_xlabel ('Longituidinal position z (m)')
ax.set_ylabel (r'Particle density (m$^{-3}$)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
fig.savefig(plot_dir + '/ne_nions_nT2.png', dpi = dpi, bbox_inches='tight')In [528]:
df_popOut [528]:
| Unnamed: 0 | species | t | zmin | zmax | rmin | rmax | phimin | phimax | Emin | Emax | n | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | T+ | 2.000000e-11 | -3.00 | -2.35 | 0.0000 | 0.0045 | 0.000000 | 0.523583 | 0.000010 | 20000.000000 | 0.000000 |
| 1 | 1 | T+ | 2.000000e-11 | -3.00 | -2.35 | 0.0000 | 0.0045 | 0.523583 | 1.047167 | 0.000010 | 20000.000000 | 0.000000 |
| 2 | 2 | T+ | 2.000000e-11 | -3.00 | -2.35 | 0.0000 | 0.0045 | 1.047167 | 1.570750 | 0.000010 | 20000.000000 | 0.000000 |
| 3 | 3 | T+ | 2.000000e-11 | -3.00 | -2.35 | 0.0000 | 0.0045 | 1.570750 | 2.094333 | 0.000010 | 20000.000000 | 0.000000 |
| 4 | 4 | T+ | 2.000000e-11 | -3.00 | -2.35 | 0.0000 | 0.0045 | 2.094333 | 2.617917 | 0.000010 | 20000.000000 | 0.000000 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2721595 | 2519995 | e- | 9.525000e-07 | 9.35 | 10.00 | 0.0405 | 0.0450 | 5.759417 | 6.283000 | 2349.237886 | 3605.351366 | 68333.808818 |
| 2721596 | 2519996 | e- | 9.525000e-07 | 9.35 | 10.00 | 0.0405 | 0.0450 | 5.759417 | 6.283000 | 3605.351366 | 5533.095880 | 81206.596905 |
| 2721597 | 2519997 | e- | 9.525000e-07 | 9.35 | 10.00 | 0.0405 | 0.0450 | 5.759417 | 6.283000 | 5533.095880 | 8491.585677 | 86583.378417 |
| 2721598 | 2519998 | e- | 9.525000e-07 | 9.35 | 10.00 | 0.0405 | 0.0450 | 5.759417 | 6.283000 | 8491.585677 | 13031.949721 | 64669.777999 |
| 2721599 | 2519999 | e- | 9.525000e-07 | 9.35 | 10.00 | 0.0405 | 0.0450 | 5.759417 | 6.283000 | 13031.949721 | 20000.000000 | 9886.160721 |
2721600 rows × 12 columns
In [535]:
In [536]:
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="zmid", y="n", style = 'species', hue = 'species', data=df_plot, err_style=None)
ax.set_xscale('linear')
ax.set_yscale('log')
ax.set_xlabel('Longitudinal position z (m)')
ax.set_ylabel(r'Particle density n (m$^{-3}$)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])Out [536]:
<matplotlib.legend.Legend at 0x1423e1410>
In [300]:
# n_e /n_T2
df_temp = df_part_all[df_part_all.species == 'e-'].groupby(['z'], as_index = False).mean()
z = df_temp.z
nT2 = get_red(z)
n_frac = df_temp.n/nT2
df_plot = pd.DataFrame()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp.z, 'n':df_temp.n, 'species':'e-'}))
df_plot = df_plot.append(pd.DataFrame({'z':z, 'n':nT2, 'species':'T2'}))
df_plot = df_plot.append(pd.DataFrame({'z':z, 'n':n_frac, 'species':'Fraction'}))
df_plot = df_plot[df_plot.species == 'Fraction']
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="z", y="n", data=df_plot, legend = None)
ax.set_xscale('linear')
ax.set_yscale('linear')
ax.set_xlabel ('Longituidinal position z (m)')
ax.set_ylabel (r'e$^-$ density/T$_2$ density')
fig.savefig(plot_dir + '/ne_vs_nT2.png', dpi = dpi, bbox_inches='tight')In [301]:
# n_e /n_ions
df_plot = pd.DataFrame()
df_temp_e = df_part_all[df_part_all.species == 'e-'].groupby(['z'], as_index = False).mean()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp_e.z, 'n':df_temp_e.n, 'species':'e-'}))
df_temp_ions = df_part_all[df_part_all.species != 'e-'].groupby(['z', 'species'], as_index = False).mean()
df_temp_ions = df_temp_ions.groupby('z', as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp_ions.z, 'n':df_temp_ions.n, 'species':'ions'}))
n_frac = df_temp_e.n/df_temp_ions.n
df_plot = df_plot.append(pd.DataFrame({'z':df_temp_ions.z, 'n':n_frac, 'species':'Fraction'}))
df_plot = df_plot[df_plot.species == 'Fraction']
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="z", y="n", data=df_plot, legend = None)
ax.set_xscale('linear')
ax.set_yscale('log')
ax.set_xlabel ('Longituidinal position z (m)')
ax.set_ylabel (r'e$^-$ density/ion density')
fig.savefig(plot_dir + '/ne_vs_nions.png', dpi = dpi, bbox_inches='tight')In [491]:
# Longitudinal particle flux summarized
df_plot = pd.DataFrame()
df_temp = df_part_all[df_part_all.species == 'e-'].groupby(['z'], as_index = False).mean()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp.z, 'jz':df_temp.jz, 'species':'e-'}))
df_temp = df_part_all[df_part_all.species != 'e-'].groupby(['z', 'species'], as_index = False).mean()
df_temp = df_temp.groupby('z', as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp.z, 'jz':df_temp.jz, 'species':'ions'}))
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="z", y="jz", data=df_plot,
style = 'species',
hue = 'species',
legend = 'full')
ax.set_xscale('linear')
ax.set_yscale('linear')
ax.set_xlabel ('Longituidinal position z (m)')
ax.set_ylabel (r'Particle flux j$_\mathrm{z}$ (m$^{-2}$ s$^{-1}$)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
ax.axhline(0, color = 'k', linewidth = 0.3)
fig.savefig(plot_dir + '/jze_jzions.png', dpi = dpi, bbox_inches='tight')In [500]:
# Longitudinal current summarized
def get_charge(species):
return 1.602176634e-19*(species.count('+') - species.count('-'))
get_charge = np.vectorize(get_charge)
df_temp = df_part_all
df_temp['i'] = get_charge(df_temp.species)*df_temp['jz']
total_temp = df_temp.groupby(['z', 'rmin', 'rmid'], as_index = False).sum()
total_temp.insert(0,'species', 'total')
df_temp = pd.concat([total_temp, df_temp], sort=False)
df_plot = pd.DataFrame()
df_temp_e = df_temp[df_temp.species == 'e-'].groupby(['z'], as_index = False).mean()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp_e.z, 'i':df_temp_e.i, 'species':'e-'}))
df_temp_I = df_temp[df_part_all.species != 'e-'].groupby(['z', 'species'], as_index = False).mean()
df_temp_I = df_temp_I.groupby('z', as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp_I.z, 'i':df_temp_I.i, 'species':'ions'}))
df_temp_t = df_temp.groupby(['z', 'species'], as_index = False).mean()
df_temp_t = df_temp_t.groupby('z', as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'z':df_temp_t.z, 'i':df_temp_t.i, 'species':'total'}))
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="z", y="i", style = 'species', hue = 'species', data=df_plot, err_style=None)
ax.set_xscale('linear')
ax.set_yscale('linear')
ax.set_xlabel('Longitudinal position z (m)')
ax.set_ylabel('Current density i$_\mathrm{z}$ (A m$^{-2}$)')
ax.axhline(0, color = 'k', linewidth = 0.3)
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
fig.savefig(plot_dir + '/ie_iions.png', dpi = dpi, bbox_inches='tight')/usr/local/Cellar/ipython/7.8.0/libexec/vendor/lib/python3.7/site-packages/ipykernel_launcher.py:16: UserWarning: Boolean Series key will be reindexed to match DataFrame index. app.launch_new_instance()
In [508]:
df_temp = df_part_rw[df_part_rw.species != 'e-'].groupby(['E'], as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'E':df_temp.E, 'I':df_temp.I, 'species':'ions'}))In [519]:
# RW currents summarized
df_plot = pd.DataFrame()
df_temp = df_part_rw[df_part_rw.species != 'total'].groupby(['E'], as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'E':df_temp.E, 'I':df_temp.I, 'species':'total'}))
df_temp = df_part_rw[df_part_rw.species == 'e-']
df_plot = df_plot.append(pd.DataFrame({'E':df_temp.E, 'I':df_temp.I, 'species':'e-'}))
df_temp = df_part_rw[(df_part_rw.species != 'e-') & (df_part_rw.species != 'total')].groupby(['E'], as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'E':df_temp.E, 'I':df_temp.I, 'species':'ions'}))
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="I", style = 'species', hue = 'species', data=df_plot, err_style=None)
ax.set_xscale('linear')
ax.set_yscale('linear')
ax.set_xlabel('Rearwall voltage E$_\mathrm{rw}$ (V)')
ax.set_ylabel('Rearwall current I$_\mathrm{rw}$ (nA)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
ax.axhline(0, color = 'k', linewidth = 0.3)
fig.savefig(plot_dir + '/rwe_rwions.png', dpi = dpi, bbox_inches='tight')In [520]:
# RW currents zoom summarized
df_plot = pd.DataFrame()
df_temp = df_part_rw_zoom[df_part_rw_zoom.species != 'total'].groupby(['E'], as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'E':df_temp.E, 'I':df_temp.I, 'species':'total'}))
df_temp = df_part_rw_zoom[df_part_rw_zoom.species == 'e-']
df_plot = df_plot.append(pd.DataFrame({'E':df_temp.E, 'I':df_temp.I, 'species':'e-'}))
df_temp = df_part_rw_zoom[(df_part_rw_zoom.species != 'e-') & (df_part_rw_zoom.species != 'total')].groupby(['E'], as_index = False).sum()
df_plot = df_plot.append(pd.DataFrame({'E':df_temp.E, 'I':df_temp.I, 'species':'ions'}))
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="I", style = 'species', hue = 'species', data=df_plot, err_style=None)
ax.set_xscale('linear')
ax.set_yscale('linear')
ax.set_xlabel('Rearwall voltage E$_\mathrm{rw}$ (V)')
ax.set_ylabel('Rearwall current I$_\mathrm{rw}$ (nA)')
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles[1:], labels=labels[1:])
ax.axhline(0, color = 'k', linewidth = 0.3)
fig.savefig(plot_dir + '/rwe_rwions_zoom.png', dpi = dpi, bbox_inches='tight')In [349]:
#Monte Carlo Simulate 1/vz distribution
theta = np.pi/2*np.random.random(100000)
vz = np.cos(theta)
vz_inv = 1/vz
print ("vz mean:\t" + str(vz.mean()))
print ("1/vz mean:\t" + str(vz_inv.mean()))vz mean: 0.6364703440984163 1/vz mean: 10.399483459878322
In [344]:
import scipy.integrate as integrate
integrate.quad(lambda x: 1/np.cos(x), 0, np.pi/2)Out [344]:
/usr/local/Cellar/ipython/7.8.0/libexec/vendor/lib/python3.7/site-packages/ipykernel_launcher.py:2: IntegrationWarning: Extremely bad integrand behavior occurs at some points of the integration interval.
(39.28210664271506, 8.44349671255596)
In [431]:
df_fit = pd.DataFrame()
df_temp = df_part_e[df_part_e.Emid > 1e3]
df_temp = df_temp.groupby(['Emid', 'z'], as_index = False).sum()
df_temp = pd.DataFrame({'E':df_temp.Emid, 'dndE':df_temp.dndE, 'z':df_temp.z})
df_fit = df_fit.append(df_temp)
fig, ax = plt.subplots()
sns.lineplot(ax = ax, x="E", y="dndE", data=df_fit,
hue = 'z', legend = 'brief')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel ('Electron energy (eV)')
ax.set_ylabel (r'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')Out [431]:
Text(0, 0.5, 'Diff. e$^-$ density dn/dE (m$^{-3}$ eV$^{-1}$)')In [427]:
def sig(E):
return (E**(-3/4)*10**(-18))In [ ]:
df_fit = df_fit.groupby('E', as_index = False).mean()In [455]:
(1-0.03)/2Out [455]:
0.485
In [479]:
E = 1e5
mfp = 1/(sig(E)*5e20)In [480]:
sig(1e4)Out [480]:
1.0000000000000001e-21
In [481]:
mfpOut [481]:
11.24682650380698
In [541]:
df_pop[df_pop.species == 'e-'].Emin.unique()Out [541]:
array([1.00000000e-05, 1.53468978e-05, 2.35527271e-05, 3.61461295e-05,
5.54730953e-05, 8.51339923e-05, 1.30654268e-04, 2.00513769e-04,
3.07726431e-04, 4.72264607e-04, 7.24779664e-04, 1.11231194e-03,
1.70705376e-03, 2.61979796e-03, 4.02057714e-03, 6.17033863e-03,
9.46955561e-03, 1.45328302e-02, 2.23033859e-02, 3.42287783e-02,
5.25305561e-02, 8.06181074e-02, 1.23723785e-01, 1.89877628e-01,
2.91403255e-01, 4.47213595e-01, 6.86334133e-01, 1.05330998e+00,
1.61650405e+00, 2.48083224e+00, 3.80730788e+00, 5.84303647e+00,
8.96724834e+00, 1.37619443e+01, 2.11203153e+01, 3.24131319e+01,
4.97441022e+01, 7.63417651e+01, 1.17160926e+02, 1.79805676e+02,
2.75945932e+02, 4.23491401e+02, 6.49927923e+02, 9.97437739e+02,
1.53075750e+03, 2.34923789e+03, 3.60535137e+03, 5.53309588e+03,
8.49158568e+03, 1.30319497e+04])In [539]:
plt.plot()Out [539]:
[<matplotlib.lines.Line2D at 0x1434fb1d0>]
In [ ]: