update validation, B,n variation and stastistics
This commit is contained in:
+100
@@ -0,0 +1,100 @@
|
||||
#!/bin/python3
|
||||
import numpy as np
|
||||
import os
|
||||
import sys
|
||||
from astropy import units as u
|
||||
from astropy import constants as const
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Specific includes
|
||||
# =======================
|
||||
|
||||
homebase = os.getenv('HOMEBASE')
|
||||
if homebase is None:
|
||||
homebase = "/home/jonas/new_workspace/Coding/KARL/karl"
|
||||
sys.path.append(homebase+"/src/tools/analysis_jkellerer")
|
||||
|
||||
|
||||
from functions.calculate_density_from_karl import *
|
||||
import functions.plot_standards as pst
|
||||
|
||||
|
||||
# inputs
|
||||
# =====================
|
||||
|
||||
paper_path = "/home/jonas/new_workspace/notes/paper/docs/paper/monte-carlo-electron-spectrum/"
|
||||
output_folder = paper_path+"/figures/"
|
||||
|
||||
filename_Nastoyashchii = paper_path + "/calculations/ComparisonNastoyashchii/data_Nastoyashchii.txt"
|
||||
folder_karl = "/home/jonas/new_workspace/Coding/Output/LRZ/SCRATCH/KARL/ComparisonNastoyashchii/parameter_20210509_1/"
|
||||
filename_karl = folder_karl + "mc_electron_out_1391.h5"
|
||||
|
||||
z_pos_1 = 8
|
||||
z_pos_2 = 0
|
||||
# calculation
|
||||
# ======================
|
||||
|
||||
|
||||
# data from karl
|
||||
key = "/Populations/e-/e-"
|
||||
density_karl = getDensities(filename_karl, key)
|
||||
|
||||
zmins = getZBinsMin(filename_karl, key)
|
||||
zmaxs = getZBinsMax(filename_karl, key)
|
||||
Emins = getEBinsMin(filename_karl, key)
|
||||
Emaxs = getEBinsMax(filename_karl, key)
|
||||
|
||||
z_index_1 = np.where(zmins <= z_pos_1)[-1][-1]
|
||||
|
||||
|
||||
density_karl_plot_1 = np.mean(density_karl[z_index_1,0,:,:],0) / 1E6
|
||||
plot_bins = np.dstack((Emins,Emaxs)).flatten()
|
||||
plot_datas_1 = np.dstack((density_karl_plot_1,density_karl_plot_1)).flatten()
|
||||
|
||||
z_index_2 = np.where(zmins <= z_pos_2)[-1][-1]
|
||||
density_karl_plot_2 = np.mean(density_karl[z_index_2,0,:,:],0) / 1E6
|
||||
plot_datas_2 = np.dstack((density_karl_plot_2,density_karl_plot_2)).flatten()
|
||||
|
||||
# data from Nastoyashchii
|
||||
data_Nastoyashchii = np.genfromtxt(filename_Nastoyashchii)
|
||||
energy_Nastoyashchii = 10**data_Nastoyashchii[:,0]
|
||||
denisty_Nastoyashchii = 10**data_Nastoyashchii[:,1]
|
||||
denisty_Nastoyashchii = denisty_Nastoyashchii/denisty_Nastoyashchii.max() * 2E4
|
||||
|
||||
# plots
|
||||
# ======================
|
||||
|
||||
pst.setRcParams()
|
||||
prop_cycle = plt.rcParams['axes.prop_cycle']
|
||||
colors = prop_cycle.by_key()['color']
|
||||
|
||||
(width, height) = pst.set_size('thesis')
|
||||
fig, ax = plt.subplots(1, 1, figsize=(width, height*1.0),sharex=True)
|
||||
|
||||
ax.set_facecolor('#e7e7e7ff')
|
||||
ax.grid(color='white')
|
||||
ax.set_axisbelow(True)
|
||||
|
||||
ax.plot(plot_bins, plot_datas_1, '-', label="KARL, inlet")
|
||||
ax.plot(plot_bins, plot_datas_2, '--', label="KARL, rear wall")
|
||||
|
||||
ax.plot(energy_Nastoyashchii[1:], denisty_Nastoyashchii[1:], '-.', label='Nastoyashchii')
|
||||
|
||||
ax.set_ylim(1E-3, density_karl_plot_1.max()*1.2)
|
||||
ax.set_xlim(1E-5, 18.3E3)
|
||||
|
||||
ax.set_yscale('log')
|
||||
ax.set_xscale('log')
|
||||
ax.legend()
|
||||
|
||||
|
||||
ax.set_xlabel(r'Energy $E$ [eV]')
|
||||
ax.set_ylabel(r'Density $n$ [1/cm$^{3}$]')
|
||||
|
||||
|
||||
plt.savefig(output_folder+"comprarison_ndE_Nastoyashchii.pdf",bbox_inches='tight')
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user