backup save
This commit is contained in:
+104
@@ -0,0 +1,104 @@
|
||||
import numpy as np
|
||||
import os
|
||||
import sys
|
||||
from astropy import units as u
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
import subprocess
|
||||
|
||||
import matplotlib.colors
|
||||
|
||||
homebase = os.getenv('HOMEBASE')
|
||||
if homebase == None:
|
||||
homebase = "/home/jonas/new_workspace/Coding/ACRONYM/acronym"
|
||||
|
||||
includes = homebase + "/src/grpic/boundaries_3d"
|
||||
|
||||
sys.path.append(includes)
|
||||
|
||||
import precalculation.functions.plasmaFunctions as plasmaFuncs
|
||||
import analysis.plotDataFromAcronym.plot_standards as pltStd
|
||||
|
||||
|
||||
# Input
|
||||
# =======================
|
||||
|
||||
rearwall_bin = homebase + "/src/grpic/boundaries_3d/bin/grpic-Linux-amd64-corei7-rearwallPotential"
|
||||
|
||||
thesis_path = "/home/jonas/new_workspace/notes/katrin-plasma/docs/phd/jkellerer"
|
||||
output_folder = thesis_path+"/fig/Chapter2_KATRIN/ElectricBackgroundField/"
|
||||
|
||||
radius = 45
|
||||
height_cyl = 180
|
||||
dx = 0.1
|
||||
potential = 1.
|
||||
|
||||
output_filename = thesis_path + "/figCode/Chapter2_KATRIN/ElectricBackgroundField/"
|
||||
filename_potential = thesis_path + "/figCode/Chapter2_KATRIN/ElectricBackgroundField/rearwall_potential.dat"
|
||||
filename_Er = thesis_path + "/figCode/Chapter2_KATRIN/ElectricBackgroundField/rearwall_Er.dat"
|
||||
filename_Ez = thesis_path + "/figCode/Chapter2_KATRIN/ElectricBackgroundField/rearwall_Ez.dat"
|
||||
|
||||
# Calculation
|
||||
# =======================
|
||||
"""
|
||||
output = subprocess.run([rearwall_bin,\
|
||||
str(dx),\
|
||||
str(radius),\
|
||||
str(height),\
|
||||
str(potential),\
|
||||
str(output_filename) ], \
|
||||
stdout = subprocess.PIPE, universal_newlines = True).stdout
|
||||
"""
|
||||
potential = np.genfromtxt(filename_potential, dtype=float,delimiter=",")
|
||||
Er = np.genfromtxt(filename_Er, dtype=float,delimiter=",")
|
||||
Ez = np.genfromtxt(filename_Ez, dtype=float,delimiter=",")
|
||||
|
||||
z = np.linspace(0,height_cyl*dx,height_cyl+2)
|
||||
|
||||
# Plot
|
||||
# =======================
|
||||
|
||||
pltStd.setRcParams()
|
||||
prop_cycle = plt.rcParams['axes.prop_cycle']
|
||||
colors = prop_cycle.by_key()['color']
|
||||
|
||||
(width, height) = pltStd.set_size('thesis')
|
||||
print(width)
|
||||
print(height)
|
||||
fig, (ax, ax1) = plt.subplots(2, 1, figsize=(width, height),sharex=True)
|
||||
|
||||
ax1.set_xlabel(r'Length $z$ [cm]')
|
||||
ax1.plot(z, Er[20],"--", label=r'$E_r$', color=colors[1])
|
||||
ax1.plot(z, Ez[20],"-.", label=r'$E_z$',color=colors[2])
|
||||
ax1.set_ylabel(r'Eletric Field $E$ [V/cm]')
|
||||
ax1.set_xlabel(r'Height $z$ [cm]')
|
||||
ax1.legend()
|
||||
|
||||
ax.plot(z,potential[20],label=r'$\phi$')
|
||||
ax.set_ylabel(r'Potential $U$ [V]')
|
||||
|
||||
plt.savefig(output_folder+"potential_Er_Ez_vs_z.pdf",bbox_inches='tight')
|
||||
plt.show()
|
||||
|
||||
|
||||
(width, height) = pltStd.set_size('thesis')
|
||||
fig, ax = plt.subplots(1, 1, figsize=(width, height))
|
||||
|
||||
len_x = np.size(potential,0)
|
||||
len_y = np.size(potential,1)
|
||||
|
||||
y = np.linspace(0, radius*dx, len_x)
|
||||
x = np.linspace(0, height_cyl*dx, len_y)
|
||||
X, Y = np.meshgrid(x, y)
|
||||
|
||||
cs = ax.contourf(X,Y,potential,cmap=plt.get_cmap('Purples'),levels=10)
|
||||
cbar = fig.colorbar(cs, ax=ax)
|
||||
|
||||
cbar.ax.set_ylabel(r'Potential $U$ [V]')
|
||||
|
||||
ax.set_ylim((0,4.5))
|
||||
ax.set_xlim((0,6))
|
||||
ax.set_ylabel(r'Radius $r$ [cm]')
|
||||
ax.set_xlabel(r'Height $z$ [cm]')
|
||||
plt.savefig(output_folder+"potential_2d.pdf",bbox_inches='tight')
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user