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 import subprocess from scipy import interpolate 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 # ======================= thesis_path = "/home/jonas/new_workspace/notes/katrin-plasma/docs/phd/jkellerer" output_folder = thesis_path+"/fig/Chapter2_KATRIN/ParticleInteractions/" k3_paul_10 = np.array([1.5E-28, 2.5E-28, 9.0E-28, 3.0E-27, 1.0E-26, 1.0E-26, 8.0E-27, 6.0E-27, 1.5E-27, 5.0E-28]) k3_paul_10_p = np.array([6.0E-28, 4.0E-27, 2.0E-26, 8.0E-27, 2.5E-26, 2.5E-26, 1.3E-26, 1.0E-26, 5.0E-27, 1.0E-27]) k3_paul_10_error = np.array([0.5E-28, 0.5E-28, 3.0E-28, 1.0E-27, 0.5E-26, 0.5E-26, 5E-27, 3.0E-27, 0.7E-27, 4.0E-28]) k3_paul_10_p_error = np.array([2.0E-28, 1.0E-27, 1.0E-26, 2.0E-27,1.5E-26, 1.5E-26, 0.5E-26, 0.5E-26, 3.0E-27, 0.5E-27]) kf_paul_10 = np.array([5.0E-16, 5.0E-16, 2.0E-14, 2.0E-13, 5.0E-13, 3.5E-13, 5.0E-13, 5.0E-13, 5.0E-13, 1.5E-12]) kf_paul_10_p = np.array([5.0E-16, 5.0E-16, 8.0E-14, 5.0E-13, 1.3E-12, 1.1E-12, 1.0E-12, 1.3E-13, 0.9E-13, 2.4E-12]) kf_paul_10_error = np.array([5.0E-16, 5.0E-16, 1.5E-14, 1.5E-13, 4.0E-13, 2.5E-13, 3.0E-13, 3.0E-13, 3.0E-13, 1.0E-12]) kf_paul_10_p_error = np.array([5.0E-16, 5.0E-16, 4.5E-14, 2.5E-13, 0.6E-12, 0.5E-12, 0.5E-12, 0.6E-13, 0.4E-13, 1.2E-12]) h_i = np.array([5,7,9,11,13,15,17,19,21,23]) k3_gerlich = np.array([1.2, 0.8, 6.5, 10])*1E-28 # definitions ############################################# def kf(kf_given, T_given, T_new, delta_E): kb = 8.617333262145E-5 kc = kf_given*np.exp(delta_E/(kb*T_given)) return kc*np.exp(-delta_E/(kb*T_new)) def k3(k3_given, T_given, T_new): a = k3_given*T_given return a/T_new # gerlich h3_gerlich = np.array([9E-1, 8.63E-1, 8.33E-1, 8E-1]) h5_gerlich = np.array([8E-2, 1.2E-1, 1.3E-1, 2.2E-1]) h7_gerlich = np.array([2.2E-3, 5E-3, 8E-3, 1.1E-2]) h9_gerlich = np.array([3.2E-4, 1E-3, 3E-3, 3.2E-3]) t_gerlich = np.array([0.5, 0.8, 1.2, 1.5]) import lmfit from lmfit.models import ExpressionModel mod_h3 = ExpressionModel('A *exp(k/x)') pars_h3 = mod_h3.make_params(A = 1, k=1) out_h3 = mod_h3.fit(h3_gerlich, pars_h3, x=t_gerlich) mod_h5 = ExpressionModel('A *exp(k/x)') pars_h5 = mod_h5.make_params(A = 1, k=1) out_h5 = mod_h5.fit(h5_gerlich, pars_h5, x=t_gerlich) mod_h7 = ExpressionModel('A *exp(k/x)') pars_h7 = mod_h7.make_params(A = 1, k=1) out_h7 = mod_h7.fit(h7_gerlich, pars_h7, x=t_gerlich) mod_h9 = ExpressionModel('A *exp(k/x)') pars_h9 = mod_h9.make_params(A = 1, k=1) out_h9 = mod_h9.fit(h9_gerlich, pars_h9, x=t_gerlich) def dH3_dt(t): a = out_h3.values['A'] b = out_h3.values['k'] return -a*b/t**2 * np.exp(b/t) def H3(t): a = out_h3.values['A'] b = out_h3.values['k'] return a * np.exp(b/t) def dH5_dt(t): a = out_h5.values['A'] b = out_h5.values['k'] return -a*b/t**2 * np.exp(b/t) def H5(t): a = out_h5.values['A'] b = out_h5.values['k'] return a * np.exp(b/t) def dH7_dt(t): a = out_h7.values['A'] b = out_h7.values['k'] return -a*b/t**2 * np.exp(b/t) def H7(t): a = out_h7.values['A'] b = out_h7.values['k'] return a * np.exp(b/t) def dH9_dt(t): a = out_h9.values['A'] b = out_h9.values['k'] return -a*b/t**2 * np.exp(b/t) def H9(t): a = out_h9.values['A'] b = out_h9.values['k'] return a * np.exp(b/t) n_H2 = 3.7E13 t = t_gerlich[1] f_5 = (dH3_dt(t)/n_H2 + k3_gerlich[0]*n_H2*H3(t))/H5(t) f_7 = (dH5_dt(t)/n_H2 - k3_gerlich[0]*n_H2*H3(t) + f_5*H5(t) - k3_gerlich[1]*n_H2*H5(t))/H7(t) f_9 = (dH7_dt(t)/n_H2 - k3_gerlich[1]*n_H2*H5(t) + f_7*H7(t) - k3_gerlich[2]*n_H2*H7(t))/H9(t) kf_gerlich_25 = np.array([f_5, f_7, f_9]) # calculations ############################################ kf_paul_25 = kf(kf_paul_10, 10, 25, 9E-3) kf_paul_25_errobar = kf(kf_paul_10_error, 10, 25, 9E-3) kf_paul_80 = kf(kf_paul_10, 10, 80, 9E-3) kf_paul_80_errorbar = kf(kf_paul_10_error, 10, 80, 9E-3) H2_gerlich = 3.7E13 H2_katrin = 1E15 k3_paul_25 = k3(k3_paul_10, 10, 25) k3_paul_25_errorbar = k3(k3_paul_10_error, 10, 25) k3_paul_80 = k3(k3_paul_10, 10, 80) k3_paul_80_errorbar = k3(k3_paul_10_error, 10, 80) # plots ############################################ 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*1.5)) # k3 ax.errorbar(h_i, k3_paul_10, yerr=k3_paul_10_error, linestyle='--', label=r'Paul et al. $(T=10K)$', capsize=3, fmt='.') ax.errorbar(h_i, k3_paul_25, yerr=k3_paul_25_errorbar, linestyle='--',label=r'Paul et al., scaled $(T=25K)$ ', capsize=3, fmt='.') ax.plot(h_i[0:4], k3_gerlich, 'x--', label=r'Gerlich et al. $(T=25K)$') ax.set_ylabel(r'Rate constant $k_3$ [cm$^{6}$s$^{-1}$]') ax.set_yscale('log') ax.legend(loc="lower right") ax.set_xticks(h_i) #kf ax1.errorbar(h_i, kf_paul_10, yerr=kf_paul_10_error, linestyle='--', label=r'Paul et al. $(T=10K)$', capsize=3, fmt='.') ax1.errorbar(h_i, kf_paul_25, yerr=kf_paul_25_errobar, linestyle='--', label=r'Paul et al., scaled $(T=25K)$ ', capsize=3, fmt='.') ax1.plot(h_i[0:3], kf_gerlich_25, 'x--', label=r'Gerlich et al. extrapolated $(T=25K)$') ax1.set_yscale('log') ax1.legend(loc="upper right") ax1.set_ylabel(r'Rate constant $k_f$ [cm$^{3}$s$^{-1}$]') ax1.set_xlabel(r'Cluster size H$_i$') ax1.legend(loc="lower right") ax1.set_xticks(h_i) plt.savefig(output_folder + "clustering_25k.pdf",bbox_inches='tight') plt.show() (width, height) = pltStd.set_size('thesis') fig, ax = plt.subplots(1, 1, figsize=(width, height)) # k3 ax.errorbar(h_i, k3_paul_10*H2_katrin, yerr=k3_paul_10_error*H2_katrin, linestyle='--', label=r'$k_3 \cdot [H2]$, $(T=10K)$', capsize=3, fmt='.') ax.errorbar(h_i, k3_paul_80*H2_katrin, yerr=k3_paul_80_errorbar*H2_katrin, linestyle='-.',label=r'$k_3 \cdot [H2]$, $(T=80K)$', capsize=3, fmt='.') ax.errorbar(h_i, kf_paul_10, yerr=kf_paul_10_error, linestyle='--', label=r'$k_f$, $(T=10K)$', capsize=3, fmt='.') ax.errorbar(h_i, kf_paul_80, yerr=kf_paul_80_errorbar, linestyle='-.',label=r'$k_f$, $(T=80K)$', capsize=3, fmt='.') ax.plot(h_i[0:3], kf_gerlich_25, '+:', label=r'$k_f$, Gerlich $(T=25K)$') ax.set_ylabel(r'Rate constant $k$ [cm$^{3}$s$^{-1}$]') ax.set_xlabel(r'Cluster size H$_i$') ax.set_yscale('log') ax.legend(loc="lower right") ax.set_xticks(h_i) plt.savefig(output_folder + "clustering_80k.pdf",bbox_inches='tight') plt.show()