121 lines
4.3 KiB
Python
121 lines
4.3 KiB
Python
import numpy as np
|
|
import pandas as pd
|
|
|
|
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' : 100,
|
|
'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
|
|
})
|
|
|
|
|
|
def plot_pop_n_t(df_pop, ax):
|
|
df_plot = df_pop.groupby(['species', 't'], as_index = False).n.mean()
|
|
df_plot['t'] = df_plot['t']*1e9
|
|
|
|
sns.lineplot(ax = ax, x="t", y="n", style = 'species', hue = 'species', data=df_plot, err_style=None)
|
|
ax.set_xscale('linear')
|
|
ax.set_yscale('log')
|
|
|
|
ax.set_xlabel('Simulation time t (ns)')
|
|
ax.set_ylabel(r'Particle density n (m$^{-3}$)')
|
|
|
|
handles, labels = ax.get_legend_handles_labels()
|
|
ax.legend(handles=handles[1:], labels=labels[1:])
|
|
|
|
|
|
def plot_pop_n_z(df_pop, ax):
|
|
t_max = np.sort(df_pop.t.unique())[-1]
|
|
df_plot = df_pop[df_pop.t == t_max]
|
|
df_plot = df_plot.groupby(['species', 'zmin', 'zmax', 'rmin', 'rmax', 'phimin', 'phimax'], as_index = False).sum()
|
|
df_plot['zmid'] = (df_plot['zmin'] + df_plot['zmax'])/2
|
|
df_plot = df_plot.groupby(['species', 'zmid'], as_index = False).n.mean()
|
|
|
|
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:])
|
|
print("plot_pop_n_z")
|
|
|
|
def plot_pop_e_dndE_z3(df_pop, ax):
|
|
t_max = np.sort(df_pop.t.unique())[-1]
|
|
df_plot = df_pop[(df_pop.species == 'e-') & (df_pop.t == t_max)]
|
|
df_plot['zmid'] = (df_plot['zmin']+df_plot['zmax'])/2
|
|
df_plot['Emid'] = (df_plot['Emin']+df_plot['Emax'])/2
|
|
#df_plot['dndE'] = df_plot['n']/(df_plot['Emax'] - df_plot['Emin'])
|
|
df_plot['dndE'] = df_plot['n']
|
|
df_plot = df_plot.groupby(['zmid','Emid'], as_index = False).dndE.mean()
|
|
df_plot = df_plot[
|
|
(abs(df_plot['zmid'] - -2.675) < 1e-1) |
|
|
(abs(df_plot['zmid'] - 5.125) < 1e-1) |
|
|
(abs(df_plot['zmid'] - 9.675) < 1e-1)]
|
|
def make_z_string(s):
|
|
rounded = "{:.1f}".format(s)
|
|
return 'z=' + rounded
|
|
make_z_string = np.vectorize(make_z_string, otypes = [str])
|
|
|
|
df_plot['zstr'] = make_z_string(df_plot['zmid'])
|
|
|
|
df_plot['zstr'][abs(df_plot['zmid'] - -2.675) < 1e-1] = 'rearwall'
|
|
df_plot['zstr'][abs(df_plot['zmid'] - 5.125) < 1e-1] = 'WGTS mid'
|
|
df_plot['zstr'][abs(df_plot['zmid'] - 9.675) < 1e-1] = 'WGTS end'
|
|
|
|
sns.lineplot(ax = ax, x="Emid", y="dndE",
|
|
style = 'zstr', style_order = ['WGTS mid', 'rearwall', 'WGTS end'],
|
|
hue = 'zstr', hue_order = ['WGTS mid', 'rearwall', 'WGTS end'],
|
|
data=df_plot, 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:])
|
|
print("plot_pop_e_dndE_z3 fertig")
|
|
|
|
def plot_pop_e_dndE_zmid(df_pop, ax):
|
|
t_max = np.sort(df_pop.t.unique())[-1]
|
|
df_plot = df_pop[(df_pop.species == 'e-') & (df_pop.t == t_max)]
|
|
df_plot['zmid'] = (df_plot['zmin']+df_plot['zmax'])/2
|
|
df_plot['Emid'] = (df_plot['Emin']+df_plot['Emax'])/2
|
|
#df_plot['dndE'] = df_plot['n']/(df_plot['Emax'] - df_plot['Emin'])
|
|
df_plot['dndE'] = df_plot['n']
|
|
df_plot = df_plot.groupby(['zmid','Emid'], as_index = False).dndE.mean()
|
|
df_plot = df_plot[abs(df_plot['zmid'] - 5.125) < 1e-1]
|
|
|
|
|
|
sns.lineplot(ax = ax, x="Emid", y="dndE", data=df_plot, err_style=None, legend=None)
|
|
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}$)')
|
|
print("plot_pop_e_dndE_zmid fertig") |