updated analysis script
This commit is contained in:
@@ -202,14 +202,18 @@ def plotSpectrumAtZ(filename, path_to_species, z_position, plot_axis, output_per
|
||||
spectrum_at_z = spectrumAtZ(
|
||||
filename, path_to_species, z_position, output_period)
|
||||
E_bins = energyBinsDensityfield(filename, path_to_species)
|
||||
# included to get dn/dE
|
||||
E_bin_volumes = E_bins[1:] - E_bins[:-1]
|
||||
plot_bins, plot_datas = makeBarPlotData(
|
||||
spectrum_at_z[1:-1], E_bins[0:-1], E_bins[1:])
|
||||
spectrum_at_z[1:-1]/E_bin_volumes, E_bins[0:-1], E_bins[1:])
|
||||
plot_axis.plot(plot_bins, plot_datas, label=str(path_to_species))
|
||||
plot_axis.set_xscale("log")
|
||||
plot_axis.set_yscale("log")
|
||||
plot_axis.set_xlabel(r"Energy $E$ (eV)")
|
||||
plot_axis.set_ylabel(
|
||||
r"Diff. Density $\frac{\mathrm{d}n_e}{\mathrm{d}\log_{10}E}$ $\left(\frac{1}{\mathrm{m}^{3} \log_{10}(\mathrm{eV})}\right)$")
|
||||
r"Diff. Density $\frac{\mathrm{d}n_e}{\mathrm{d}E}$ $\left(\frac{1}{\mathrm{m}^{3} \mathrm{eV}}\right)$")
|
||||
# plot_axis.set_ylabel(
|
||||
# r"Diff. Density $\frac{\mathrm{d}n_e}{\mathrm{d}\log_{10}E}$ $\left(\frac{1}{\mathrm{m}^{3} \log_{10}(\mathrm{eV})}\right)$")
|
||||
|
||||
|
||||
def plotAllSpectrumAtZ(filename, z_position, output_period, specie_keys, output_folder):
|
||||
@@ -256,7 +260,7 @@ def plotLongitudinalParticleCurrentVsZ(filename, path_to_species, plot_axis, out
|
||||
z_bins = zBinsDensityField(filename, path_to_species)
|
||||
plot_axis.plot(z_bins, current_in_z, label=str(path_to_species))
|
||||
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
||||
plot_axis.set_ylabel(r"Particle current $j$ ($m^{-3}s^{-1}$)")
|
||||
plot_axis.set_ylabel(r"Particle current $j$ ($m^{-2}s^{-1}$)")
|
||||
|
||||
|
||||
def plotAllLongitudinalParticleCurrentVsZ(filename, output_period, specie_keys, output_folder):
|
||||
@@ -278,7 +282,7 @@ def plotLongitudinalElectricCurrentVsZ(filename, path_to_species, plot_axis, out
|
||||
z_bins = zBinsDensityField(filename, path_to_species)
|
||||
plot_axis.plot(z_bins, current_in_z)
|
||||
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
||||
plot_axis.set_ylabel(r"Electric current $I$ ($A$)")
|
||||
plot_axis.set_ylabel(r"Electric current $I$ ($A$)") # unit should be wrong, think it should be A/m^2
|
||||
|
||||
|
||||
def printDeletionLoggerStats(filename, path_to_species, output_period="LastSyncPeriod"):
|
||||
@@ -300,3 +304,50 @@ def printDeletionLoggerStats(filename, path_to_species, output_period="LastSyncP
|
||||
def printAllDeletionLoggerStats(filename, specie_keys, output_period):
|
||||
for key in specie_keys:
|
||||
printDeletionLoggerStats(filename, key, output_period)
|
||||
|
||||
def zBinsPoissonSolver(filename, path_to_poisson_solver):
|
||||
file = h5py.File(filename, 'r')
|
||||
path_to_border = path_to_poisson_solver + "/BinBorders/longitudinal"
|
||||
return np.array(file[path_to_border])
|
||||
|
||||
def rBinsPoissonSolver(filename, path_to_poisson_solver):
|
||||
file = h5py.File(filename, 'r')
|
||||
path_to_border = path_to_poisson_solver + "/BinBorders/radial"
|
||||
return np.array(file[path_to_border])
|
||||
|
||||
def potential(filename, path_to_poisson_solver, output_period):
|
||||
file = h5py.File(filename, 'r')
|
||||
path_to_density = path_to_poisson_solver + "/SimulationData" + \
|
||||
outputPeriodKey(output_period) + "/Potential"
|
||||
return np.array(file[path_to_density])
|
||||
|
||||
# returns potential averaged over r-direction; assumes only one azimuthal bin
|
||||
def potentialVsZ(filename, path_to_poisson_solver, output_period="LastSyncPeriod"):
|
||||
rbinBorders = rBinsPoissonSolver(filename, path_to_poisson_solver)
|
||||
deltar = rbinBorders[1] - rbinBorders[0] #assumption of linear binning
|
||||
weights = rbinBorders[1:]**2 - rbinBorders[:-1]**2 + deltar**2
|
||||
weights = np.append(deltar**2/4, weights)
|
||||
potentialValues = potential(filename, path_to_poisson_solver, output_period)
|
||||
weightedPotential = potentialValues*weights[:, np.newaxis, np.newaxis]
|
||||
return np.sum(weightedPotential, axis=(0,1)) / np.sum(weights)
|
||||
|
||||
def plotPotentialVsZ(filename, path_to_poisson_solver, plot_axis, output_period="LastSyncPeriod"):
|
||||
potential_ = potentialVsZ(filename, path_to_poisson_solver, output_period)
|
||||
z_bins = zBinsPoissonSolver(filename, path_to_poisson_solver)
|
||||
plot_bins, plot_datas = makeBarPlotData(
|
||||
potential_, z_bins, z_bins)
|
||||
plot_axis.plot(plot_bins, plot_datas)
|
||||
# plot_axis.set_yscale("log")
|
||||
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
||||
plot_axis.set_ylabel(r"Potential $\Phi$ ($V$)")
|
||||
|
||||
def plotAllPotentialVsZ(filename, output_period, output_folder):
|
||||
pst.setRcParams()
|
||||
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
|
||||
key = "PoissonSolver"
|
||||
plotPotentialVsZ(filename, key, ax, output_period)
|
||||
|
||||
ax.set_facecolor('#e7e7e7ff')
|
||||
ax.grid(color='white')
|
||||
fig.savefig(output_folder + "/potential_vs_z_at_period={}.pdf".format(output_period),
|
||||
format='pdf', bbox_inches='tight')
|
||||
Reference in New Issue
Block a user