132 lines
3.8 KiB
Python
132 lines
3.8 KiB
Python
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')
|
|
fig, (ax, ax1) = plt.subplots(2, 1, figsize=(width, height),sharex=True)
|
|
|
|
ax1.set_xlabel(r'Distance to rear wall $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'Distance to rear wall $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*0.5))
|
|
|
|
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'Distance to rear wall $z$ (cm)')
|
|
plt.savefig(output_folder+"potential_2d.pdf",bbox_inches='tight')
|
|
plt.show()
|
|
|
|
(width, height) = pltStd.set_size('thesis')
|
|
fig, (ax0, ax1, ax2) = plt.subplots(3, 1, figsize=(width, height*1.4))
|
|
|
|
ax2.set_xlabel(r'Distance to rear wall $z$ (cm)')
|
|
ax2.plot(z, Er[20],"--", label=r'$E_r$', color=colors[1])
|
|
ax2.plot(z, Ez[20],"-.", label=r'$E_z$',color=colors[2])
|
|
ax2.set_ylabel(r'Eletric Field $E$ (V/cm)')
|
|
ax2.set_xlabel(r'Distance to rear wall $z$ (cm)')
|
|
ax2.legend()
|
|
ax2.set_xlim((0,18))
|
|
|
|
ax2.set_facecolor('#e7e7e7ff')
|
|
ax2.grid(color='white')
|
|
|
|
ax1.plot(z,potential[20],label=r'$\phi$')
|
|
ax1.set_ylabel(r'Potential $U$ (V)')
|
|
ax1.set_xlim((0,18))
|
|
|
|
ax1.set_facecolor('#e7e7e7ff')
|
|
ax1.grid(color='white')
|
|
|
|
cs = ax0.contourf(X,Y,potential,cmap=plt.get_cmap('Purples'),levels=10)
|
|
ax0.set_xlim((0,14))
|
|
ax0.set_ylabel(r'Radius $r$ (cm)')
|
|
cbar = fig.colorbar(cs, ax=ax0)
|
|
|
|
cbar.ax.set_ylabel(r'Potential $U$ (V)')
|
|
plt.savefig(output_folder+"potential_Er_Ez_combined.pdf",bbox_inches='tight')
|
|
plt.show() |