From d9787c2e1571b63697790fa0cbfc82120686687e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joschka=20Sch=C3=B6ner?= Date: Mon, 5 Sep 2022 16:09:56 +0200 Subject: [PATCH] Plots + field measurement --- Data_Coils/Data.py | 64 ------ Data_Coils/Frequ_resp.py | 116 +++++++++++ Data_Coils/Temperature_resp.py | 59 ++++++ Data_Coils/Time_resp_Data.py | 183 ++++++++++++++++++ FINAL_Coil/FINAL_COIL_configuration.py | 11 +- Magnetic field measurements/data_analysis.py | 34 ++++ .../measurement test.py | 46 +++++ Thesis_Plots/Field plots.py | 10 +- Thesis_Plots/Final_design_figs.py | 4 +- 9 files changed, 456 insertions(+), 71 deletions(-) delete mode 100644 Data_Coils/Data.py create mode 100644 Data_Coils/Frequ_resp.py create mode 100644 Data_Coils/Temperature_resp.py create mode 100644 Data_Coils/Time_resp_Data.py create mode 100644 Magnetic field measurements/data_analysis.py create mode 100644 Magnetic field measurements/measurement test.py diff --git a/Data_Coils/Data.py b/Data_Coils/Data.py deleted file mode 100644 index 8d9444e..0000000 --- a/Data_Coils/Data.py +++ /dev/null @@ -1,64 +0,0 @@ -# %% -import matplotlib.pyplot as plt -import RigolWFM.wfm as rigol - -# %% - -hhpion = 'C:/Users/Joschka/Desktop/Coil_Data/New/hhpion.wfm' -hhpioff = 'C:/Users/Joschka/Desktop/Coil_Data/New/hhpioff.wfm' -hhon = 'C:/Users/Joschka/Desktop/Coil_Data/New/hhon.wfm' -hhoff = 'C:/Users/Joschka/Desktop/Coil_Data/New/hhoff.wfm' - -scope = 'DS1104Z-S' - -# %% -hhpion = rigol.Wfm.from_file(hhpion, scope) -hhpion.plot() -plt.show() -# %% -hhpioff = rigol.Wfm.from_file(hhpioff, scope) -hhpioff.plot() -plt.show() - -# %% -hhoff = rigol.Wfm.from_file(hhoff, scope) -hhoff.plot() -plt.show() - -# %% -hhon = rigol.Wfm.from_file(hhon, scope) -hhon.plot() -plt.show() - - -# %% -print(w.channels[0].times) -print(w.channels[0].volts) - -# %% - -ahhpion = 'C:/Users/Joschka/Desktop/Coil_Data/New/ahhpion.wfm' -ahhpioff = 'C:/Users/Joschka/Desktop/Coil_Data/New/ahhpioff.wfm' -ahhon = 'C:/Users/Joschka/Desktop/Coil_Data/New/ahhon.wfm' -ahhoff = 'C:/Users/Joschka/Desktop/Coil_Data/New/ahhoff.wfm' - -scope = 'DS1104Z-S' - -# %% -ahhpion = rigol.Wfm.from_file(ahhpion, scope) -ahhpion.plot() -plt.show() -# %% -ahhpioff = rigol.Wfm.from_file(ahhpioff, scope) -ahhpioff.plot() -plt.show() - -# %% -ahhoff = rigol.Wfm.from_file(ahhoff, scope) -ahhoff.plot() -plt.show() - -# %% -ahhon = rigol.Wfm.from_file(ahhon, scope) -ahhon.plot() -plt.show() \ No newline at end of file diff --git a/Data_Coils/Frequ_resp.py b/Data_Coils/Frequ_resp.py new file mode 100644 index 0000000..d62c528 --- /dev/null +++ b/Data_Coils/Frequ_resp.py @@ -0,0 +1,116 @@ +# %% +import matplotlib.pyplot as plt +import RigolWFM.wfm as rigol +import numpy as np +import matplotlib as mpl +import scipy.optimize + +# %% +# Data import + +f = np.array( + [1, 1.83, 3.36, 6.16, 11.3, 20.7, 37.9, 69.5, 127, 234, 428, 785, 1440, 2640, 4830, 8860, 16200, 29800, 54600]) + +A_HH = np.array( + [1.13, 1.13, 1.13, 1.13, 1.13, 1.14, 1.13, 1.11, 1.03, 0.881, 0.708, 0.504, 0.334, 0.198, 0.119, 0.069, 0.046, + 0.028, 0.024]) +dA_HH = np.array( + [0.006, 0.002, 0.001, 0.002, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.002, 0.001, 0.004, 0.001, 0.001, + 0.001, 0.001, 0.001]) + +ph_HH = np.array( + [0.8, -0.8, -1.2, -0.8, 1.5, 3.7, 7.9, 11.8, 20.6, 32.0, 44.6, 54.8, 64.3, 74.0, 78.6, 82.8, 85.3, 87.4, 93.7]) +dph_HH = np.array( + [1.5, 1.5, 0.5, 1.2, 4.1, 0.001, 1.3, 0.001, 0.4, 0.001, 0.080, 0, 0.23, 0.7, 0.05, 1.6, 1.5, 2.5, 2.8]) + +A_AHH = np.array( + [1.14, 1.14, 1.14, 1.14, 1.15, 1.15, 1.13, 1.09, 0.966, 0.737, 0.539, 0.359, 0.216, 0.130, 0.0767, 0.0475]) +dA_AHH = np.array( + [0.007, 0.005, 0.002, 0.002, 0.002, 0.002, 0.001, 0.001, 0.004, 0.012, 0.001, 0.001, 0.003, 0.001, 0.0004, 0.0004]) + +ph_AHH = np.array([0.6, -0.3, 0.5, 0.3, 2.5, 4.3, 8.8, 17.2, 30.3, 45.3, 54.2, 64.4, 72.6, 77.24, 79.4, 80.14]) +dph_AHH = np.array([3.0, 2.0, 0.4, 1.2, 1.0, 0.7, 1.2, 1.2, 0.5, 2.6, 0.9, 1.4, 1.2, 1.5, 2.1, 1.2]) + +# %% +my_colors = {'light_green': '#97e144', + 'orange': '#FF914D', + 'light_grey': '#545454', + 'pastel_blue': '#1b64d1', + 'light_blue': '#71C8F4', + 'purple': '#7c588c'} + + +mpl.rcParams.update({'font.size': 11, 'axes.linewidth': 1, 'lines.linewidth': 2, 'text.usetex': False, 'font.family': 'arial'}) +mpl.rcParams['xtick.direction'] = 'in' +mpl.rcParams['ytick.direction'] = 'in' + +mpl.rcParams['xtick.top'] = True +mpl.rcParams['ytick.right'] = True +# %% Fit func + +def I_fit(f,U,tau): + omega = 2* np.pi *f + return U/np.sqrt(tau**2 + omega**2) +# %% fit HH + +fit_bound = (0,len(A_HH)) +p0 = [1,2.2e3] +popt_hh, pcov_hh = scipy.optimize.curve_fit(I_fit, f, A_HH, p0=p0, sigma=dA_HH, absolute_sigma=False) +print("U0, tau, t0") +print(popt_hh) + +# %% fit AHH + +fit_bound = (0,len(A_HH)) +p0 = [1,2.2e3] +popt_ahh, pcov_ahh = scipy.optimize.curve_fit(I_fit, f[0:len(A_AHH)], A_AHH, p0=p0) +print("U0, tau, t0") +print(popt_hh) +# %% Scaling factor +scale = 0.3/I_fit(1, *popt_hh) + +# %% +x=np.linspace(0,50000,10000) +fig, ax = plt.subplots(figsize=(5.4, 4), dpi=400) + +ax.errorbar(f, scale*A_HH, yerr=scale*dA_HH, elinewidth=2, capsize=5, linewidth=0, label='Data HH', zorder=4, marker='.',color='C0') +ax.plot(x, scale*I_fit(x, *popt_hh),label=f'fit HH, $\\tau$ = 2255(110) 1/s',color='C8') +ax.errorbar(f[0:len(A_AHH)], scale*A_AHH, yerr=scale*dA_AHH, elinewidth=2, capsize=5, linewidth=0, label='Data AHH', zorder=3, marker='^',color='C1') +ax.plot(x, scale*I_fit(x, *popt_ahh),label=f'fit AHH, $\\tau$ = 1416(56) 1/s', color='C4') + +ax.hlines(scale*I_fit(1, *popt_hh)/np.sqrt(2),0, 1e5, color='C7', linestyle=(0,(2.5,3)), label='3dB point \nHH: f = 359 Hz, AHH: 225 Hz ') +ax.grid(alpha=0.6) +ax.set_xscale('log') +ax.set_yscale('log') +ax.set_xlim(0, 1e5) +ax.set_ylabel(r'current amplitude ($\rm A_{pp}$)') +ax.set_xlabel('frequency f (Hz)') +handles, labels = ax.get_legend_handles_labels() +ax.legend(handles=[handles[3], handles[4], handles[0], handles[1], handles[2]]) + +fig.tight_layout() +fig.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final/freq_resp.png') +fig.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final_low/freq_resp.png', dpi=96) +plt.show() +# %% Find 3dB point +x=np.linspace(0,1000,10000) +for i in range(0,10000): + if I_fit(x[i], *popt_hh) < (I_fit(1, *popt_hh)/np.sqrt(2)): + print(f"Cutoff HH: {x[i]} Hz") + break + +for i in range(0, 10000): + if I_fit(x[i], *popt_ahh) < (I_fit(1, *popt_ahh) / np.sqrt(2)): + print(f"Cutoff AHH: {x[i]} Hz") + break +# %% +fig, ax = plt.subplots(figsize=(5.4, 4),dpi=400) + +ax.errorbar(f, ph_HH, yerr=dph_HH, label='Data HH') + + +ax.grid(alpha=0.6, which='minor') +ax.set_xscale('log') +#ax.set_yscale('log') + +plt.show() diff --git a/Data_Coils/Temperature_resp.py b/Data_Coils/Temperature_resp.py new file mode 100644 index 0000000..d8215f1 --- /dev/null +++ b/Data_Coils/Temperature_resp.py @@ -0,0 +1,59 @@ +# %% +import matplotlib.pyplot as plt +import numpy as np +import matplotlib as mpl +from matplotlib.ticker import AutoMinorLocator + +# %% +# Import data without water cooling + +I = np.array([0, 0.5, 1, 1.25, 1.5, 1.75, 2,2.25]) + +HH = np.array([25, 26, 30.9, 36.6, 39.8, 46.8, 53.9, 62.3]) +AHH = ([25,26.5,35.2, 42.7, 52.2]) + +# %% +# Data with water cooling + +I_w = np.arange(0,5.25,0.5) +I_w = np.append(I_w, 5.25) + +HH_w = np.array([17.8, 18.2, 18.9, 20, 21.8, 24.3, 27.3, 31.4, 36.8, 42.5, 49.3, 56.2]) +AHH_w = np.array([17.2, 17.7,19.1, 21.3, 24.7, 29.3, 35.7, 43.9, 55.6]) + +# %% +my_colors = {'light_green': '#97e144', + 'orange': '#FF914D', + 'light_grey': '#545454', + 'pastel_blue': '#1b64d1', + 'light_blue': '#71C8F4', + 'purple': '#7c588c'} + + +mpl.rcParams.update({'font.size': 11, 'axes.linewidth': 1, 'lines.linewidth': 2, 'text.usetex': False, 'font.family': 'arial'}) +mpl.rcParams['xtick.direction'] = 'in' +mpl.rcParams['ytick.direction'] = 'in' + +mpl.rcParams['xtick.top'] = True +mpl.rcParams['ytick.right'] = True + +# %% +fig, ax = plt.subplots(figsize=(5, 3.6),dpi=400) +ax.scatter(I, HH, label='HH, no water') +ax.scatter(I[0:len(AHH)], AHH, label='AHH, no water',marker='v') +ax.scatter(I_w, HH_w, label='HH, with water',marker = 's') +ax.scatter(I_w[0:len(AHH_w)], AHH_w, label='AHH, with water', marker='d') +ax.legend(fontsize=10.5) + +ax.grid(alpha = 0.2) +ax.set_xlim(-0.3, 5.7) +ax.set_ylim(11, 65) +ax.set_ylabel('temperature coil T (°C)') +ax.set_xlabel('current I (A)') + +ax.xaxis.set_minor_locator(AutoMinorLocator(2)) +ax.yaxis.set_minor_locator(AutoMinorLocator(2)) +fig.tight_layout() +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final/heating.png') +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final_low/heating.png',dpi=96) +plt.show() \ No newline at end of file diff --git a/Data_Coils/Time_resp_Data.py b/Data_Coils/Time_resp_Data.py new file mode 100644 index 0000000..015c15b --- /dev/null +++ b/Data_Coils/Time_resp_Data.py @@ -0,0 +1,183 @@ +# %% +import matplotlib.pyplot as plt +import RigolWFM.wfm as rigol +import numpy as np + +import matplotlib as mpl +# %% +import scipy.optimize + +my_colors = {'light_green': '#97e144', + 'orange': '#FF914D', + 'light_grey': '#545454', + 'pastel_blue': '#1b64d1', + 'light_blue': '#71C8F4', + 'purple': '#7c588c'} + + +mpl.rcParams.update({'font.size': 11, 'axes.linewidth': 1, 'lines.linewidth': 2, 'text.usetex': False, 'font.family': 'arial'}) +mpl.rcParams['xtick.direction'] = 'in' +mpl.rcParams['ytick.direction'] = 'in' + +mpl.rcParams['xtick.top'] = True +mpl.rcParams['ytick.right'] = True + +# %% +hhpion.channels[1].volts + +# %% + +scope = 'DS1104Z-S' + +hhpion = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/hhpion.wfm', scope) +hhpioff = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/hhpioff.wfm', scope) +hhon = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/hhon.wfm', scope) +hhoff = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/hhoff.wfm', scope) + +ahhpion = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/ahhpion.wfm', scope) +ahhpioff = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/ahhpioff.wfm', scope) +ahhoff = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/ahhoff.wfm', scope) +ahhon = rigol.Wfm.from_file('C:/Users/Joschka/Desktop/Coil_Data/New/ahhon.wfm', scope) + +# %% +print(hhon.channels[1]) + +# %% +def I(V): + return (V/1.2093 -2.47e-3) * 1.21/1.276 + +print(I(1.21)) +print(1/0.88) + + +def I_exp(t, I_0, tau, t0): + return I_0 *(1-np.exp(-tau *(t-t0))) + +def I_pi(t, tau, t0=0): + return 30/3.2 * (1 - np.exp(-tau * (t - t0))) +# %% +x = np.linspace(0,80e-6,1000) +fig, ax = plt.subplots(figsize=(5, 3.6), dpi=400) + + +ax.plot(1e6* hhpion.channels[1].times, I(hhpion.channels[1].volts), label='HH on') +ax.plot(1e6 *ahhpion.channels[1].times, I(ahhpion.channels[1].volts),label='AHH on') + +# ax.plot(1e6 *x, I_pi(x, popt_hhon[1])) + + +ax.plot(1e6* hhpioff.channels[1].times, I(hhpioff.channels[1].volts), label='HH off') +ax.plot(1e6 *ahhpioff.channels[1].times, I(ahhpioff.channels[1].volts), label='AHH off') +ax.grid(alpha=0.5) +ax.set_xlabel('time (μs)') +ax.set_ylabel('current I (A)') + +ax.set_xlim(-50, 300) +ax.legend() +fig.tight_layout() +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final/time_resp_pi.png', dpi=400) +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final_low/time_resp_pi.png',dpi=96) +plt.show() +# %% +# Fitting +# 0 at 745128 +fitx = np.array(hhon.channels[1].times) +fity = np.array(I(hhon.channels[1].volts)) + +dfity = np.array(hhon.channels[1].volts) +dfity = 0.1*200e-3 + 2e-3 + 0.001 * dfity +dfity = I(dfity) +fit_bound = (745128,len(fitx)) +p0 = [1,2.2e3,0] +popt_hhon, pcov_hhon = scipy.optimize.curve_fit(I_exp, fitx[fit_bound[0]:fit_bound[1]], fity[fit_bound[0]:fit_bound[1]], + p0=p0, sigma = dfity[fit_bound[0]:fit_bound[1]], absolute_sigma=True) +print("I0, tau, t0") +print(popt_hhon) +# %% +# Fitting +# 0 at 510128 +fitx = np.array(ahhon.channels[1].times) +fity = np.array(I(ahhon.channels[1].volts)) +fit_bound = (510128,len(fitx)) +p0 = [1,2.2e3,0] +popt_ahhon, pcov_ahhon = scipy.optimize.curve_fit(I_exp, fitx[fit_bound[0]:fit_bound[1]], fity[fit_bound[0]:fit_bound[1]], p0=p0) +print("I0, tau, t0") +print(popt_ahhon) +# %% +for i in range(0,len(fitx)): + if fitx[i]>0: + print(i) + break +# %% +x = np.linspace(0, 0.01, 1000) +fig, ax = plt.subplots(figsize=(5, 3.6)) + + +ax.scatter(1e3* fitx,fity, label='HH on', linewidth=0.01) + +ax.legend() +plt.show() +# %% +x = np.linspace(0, 0.01, 1000) +fig, ax = plt.subplots(figsize=(5, 3.6),dpi=400) + + +ax.plot(1e3* hhon.channels[1].times, I(hhon.channels[1].volts), label='HH on', color='C0') +ax.plot(1e3 *ahhon.channels[1].times, I(ahhon.channels[1].volts),label='AHH on', color='C1') + +ax.plot(1e3*x, I_exp(x, *popt_hhon)) + +ax.plot(1e3* hhoff.channels[1].times, I(hhoff.channels[1].volts), label='HH off', color='C2',zorder=0) +ax.plot(1e3 *ahhoff.channels[1].times, I(ahhoff.channels[1].volts), label='AHH off', color='C3',zorder=1) + +ax.plot(1e3*x, I_exp(x, *popt_hhon), color = 'C8', linestyle=(0,(2,)), + label=f'fit HH on, $ \\tau$ = {popt_hhon[1]:.0f} 1/s', zorder=3) +ax.plot(1e3*x, I_exp(x, *popt_ahhon), color = 'C4', linestyle=(0,(2,)), + label=f'fit AHH on, $\\tau$ = {popt_ahhon[1]:.0f} 1/s') +ax.grid(alpha=0.5) +ax.set_xlabel('time (ms)') +ax.set_ylabel('current I (A)') + +ax.legend(loc=5) +fig.tight_layout() +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final/time_resp.png') +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_measurements/Final_low/time_resp.png', dpi=96) +plt.show() + + +# %% +# Resistance HH Calculation +I = 1 +U = 3.32 +dI = 1e-3 + 0.001*I +dU = np.sqrt(5e-3**2 + (0.0005*U)**2 + (0.005*U)**2) +print(dU) +#dU = 0.05 + +R =U/I +dR = R* np.sqrt((dI/I)**2 + (dU/U)**2) +print(f"R = {R:.3f} +/- {dR:.3f} Ω") + +L = R/popt_hhon[1] +dL=dR/popt_hhon[1] +print(f"L = {L:.6f} +/-{dL:.6f} Ω") + +# %% +# Resistance AHH Calculation +I = 1 +U = 6.64 +dI = np.sqrt(1e-3**2 + (0.001*I)**2) +dU = np.sqrt(5e-3**2 + (0.0005*U)**2 + (0.005*U)**2) +print(dU) + +R =U/I +dR = R* np.sqrt((dI/I)**2 + (dU/U)**2) +print(f"R = {R:.3f} +/- {dR:.3f} Ω") + +L = R/popt_ahhon[1] +dL=dR/popt_ahhon[1] +print(f"L = {L:.5f} +/-{dL:.5f} Ω") + +# %% + + diff --git a/FINAL_Coil/FINAL_COIL_configuration.py b/FINAL_Coil/FINAL_COIL_configuration.py index 5d72ff0..2b664e8 100644 --- a/FINAL_Coil/FINAL_COIL_configuration.py +++ b/FINAL_Coil/FINAL_COIL_configuration.py @@ -24,6 +24,7 @@ AHH_Coil.set_d_max(77.6) AHH_Coil.print_info() R = HH_Coil.resistance(25) + # %% AHH_Coil.plot_raster() print(AHH_Coil.get_N()) @@ -37,7 +38,6 @@ I_2 = 0.92 HH_Coil.cooling(I_2,22.5) HH_Coil.max_field(I_2) # %% -AHH_Coil.B_quick_plot(I) HH_Coil.print_info() @@ -49,8 +49,13 @@ print("All values for pair in series") print(f"inductivity AHH: {AHH_Coil.induct_perry()*2*1e3} mH" ) print(f"inductivity HH: {HH_Coil.induct_perry() * 2*1e3} mH" ) -print(f"resistance AHH: {AHH_Coil.resistance(22.5)*2} Ω") -print(f"resistance HH: {HH_Coil.resistance(22.5)*2} Ω") +print(f"resistance AHH: {AHH_Coil.resistance(22) *2} Ω") +print(f"resistance HH: {HH_Coil.resistance(22)*2} Ω") +print(f"resistance HH: {HH_Coil.resistance(2)*2} Ω") + +print(f"rel change: {(HH_Coil.resistance(22)-HH_Coil.resistance(23))/HH_Coil.resistance(22)} Ω") + +print(f"res of 4 m copper wire: {BC.BCoil.resistivity_copper(22)*5*0.5**2 *np.pi *1e6} Ω") # %% I = 1 diff --git a/Magnetic field measurements/data_analysis.py b/Magnetic field measurements/data_analysis.py new file mode 100644 index 0000000..b86c8c5 --- /dev/null +++ b/Magnetic field measurements/data_analysis.py @@ -0,0 +1,34 @@ +import numpy as np +import matplotlib.pyplot as plt +from scipy.optimize import curve_fit +#get data from txt, usecols=0 is B_x, 1 is B_y, 2 is B_z +B=np.genfromtxt('Data.txt', usecols=1, unpack=True) + + +#just determining calibrating parameters from several tries +ratio=np.mean([0.49275,0.47778,0.48105,0.51098,0.49541,0.5094,0.4783,0.51914]) +dratio=np.std([0.49275,0.47778,0.48105,0.51098,0.49541,0.5094,0.4783,0.51914]) +offset=np.mean([7.12939,6.99607,6.8554,6.13588,7.06523,6.78745,3.4305,4.1762]) +doffset=np.std([7.12939,6.99607,6.8554,6.13588,7.06523,6.78745,3.4305,4.1762]) + + +print('ratio:',np.round(ratio,3),'+/-',np.round(dratio,3)) +print('offset:',np.round(offset,3),'+/-',np.round(doffset,3)) + +#calibrated new values +B_cal=(-1)*(ratio*B-ratio*offset) +dB_cal=np.sqrt((B*dratio-offset*dratio)**2+(ratio*1.615)**2+(ratio*doffset)**2) + +# exemplary plotting and fitting, analyse calibrated values whichever way you want +print(B_cal) +plt.errorbar(x,B_cal,dB-cal) +plt.ylabel('G') +plt.xlabel('mm') +plt.title('Gradient field z-axis 4A AHH, 1A HH') + +def linear(x,m,b): + return m*x+b +popt,pcov=curve_fit(linear,x,B_cal,sigma=dB_cal) +plt.plot(x,linear(x,*popt),label='measurement fit') +print('Gradient:',popt[0]*10,'+/-',np.sqrt(pcov[0][0])*10) +plt.show() diff --git a/Magnetic field measurements/measurement test.py b/Magnetic field measurements/measurement test.py new file mode 100644 index 0000000..87bf5a4 --- /dev/null +++ b/Magnetic field measurements/measurement test.py @@ -0,0 +1,46 @@ +import serial +import re +import matplotlib.pyplot as plt +#connect to device, check if correct port +ser =serial.Serial('COM4',19200) +Bx=[] +By=[] +Bz=[] +x=[] +i=0 +f=open('Data.txt','w') +fig, axs=plt.subplots(1,3) + +#plug in number of measurement points (here 35) +#save all data in a txt sheet +for k in range(0,35): + + a=ser.readline() + data=str(a,'utf-8') + points=re.findall(r'-?\d+\.?\d*', data) + Bx_point=float(points[0]) + By_point=float(points[1]) + Bz_point=float(points[2]) + Bx.append(Bx_point) + By.append(By_point) + Bz.append(Bz_point) + x.append(i) + i+=1 + print(Bx_point,By_point,Bz_point) + f.write(str(Bx_point)+'\t'+str(By_point)+'\t'+str(Bz_point)+'\n') + +f.close() + + +#plot to get a first look at magnetic field (not calibrated) +axs[0].errorbar(x,Bx,1.615) +axs[0].set_title('Bx') +axs[0].set(ylabel='G') +axs[1].errorbar(x,By,1.615) +axs[1].set_title('By') +axs[1].set(ylabel='G') +axs[2].errorbar(x,Bz,1.615) +axs[2].set_title('Bz') +axs[2].set(ylabel='G') +print(By) +plt.show() diff --git a/Thesis_Plots/Field plots.py b/Thesis_Plots/Field plots.py index a14549d..caf5ae5 100644 --- a/Thesis_Plots/Field plots.py +++ b/Thesis_Plots/Field plots.py @@ -55,7 +55,7 @@ Bx_grad = np.abs(BC.BCoil.grad(Bx, x)) # %% #HH plots -fig, axes = plt.subplots(2, 2, figsize=(5.8, 4), gridspec_kw={'height_ratios':[12,5]},dpi=600) +fig, axes = plt.subplots(2, 2, figsize=(5.8, 4), gridspec_kw={'height_ratios':[12,5]},dpi=400) #fig.tight_layout() lim1 = 55 @@ -116,7 +116,9 @@ for i in [0,1]: axes[i, 0].yaxis.set_label_coords(-0.19, 0.5) axes[i, 1].yaxis.set_label_coords(-0.17, 0.5) fig.tight_layout() -fig.savefig('Thesis_Plots/Coil_Design/Out/HH_field.png') + +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_design/Final_400/HH_field.png') +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_design/Final_low/HH_field.png',dpi=96) plt.show() # %% @@ -196,5 +198,7 @@ for i in [0,1]: axes[i,0].yaxis.set_label_coords(-0.15,0.5) axes[i, 1].yaxis.set_label_coords(-0.08, 0.5) fig.tight_layout() -fig.savefig('Thesis_Plots/Coil_Design/Out/AHH_field.png') +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_design/Final_400/AHH_field.png') +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_design/Final_low/AHH_field.png',dpi=96) + plt.show() \ No newline at end of file diff --git a/Thesis_Plots/Final_design_figs.py b/Thesis_Plots/Final_design_figs.py index 2f012a2..b7d39e7 100644 --- a/Thesis_Plots/Final_design_figs.py +++ b/Thesis_Plots/Final_design_figs.py @@ -61,5 +61,7 @@ ext = 0.2 ax.set_xlim(1e3 * HH_Coil.get_R_inner() - ext- 0.2, 1e3 * (HH_Coil.get_R_inner()+HH_Coil.get_coil_height() )+ ext) ax.set_ylim(1e3 * HH_Coil.get_zmin() - ext, 1e3 * HH_Coil.get_zmax() + ext) -plt.savefig('C:/Users/Joschka/Desktop/Magnetic_field_coils_project/Thesis_Plots/Coil_Design/Out/winding_scheme_2.png') +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_design/Final_400/final_winding_scheme.png',dpi=400) +plt.savefig('C:/Users/Joschka/Desktop/Master_Thesis/Figures/Coil_design/Final_low/final_winding_scheme.png',dpi=96) + plt.show()