From d25b3cb5d88c976509edd2747531348c9d48b992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joschka=20Sch=C3=B6ner?= Date: Wed, 4 May 2022 11:30:48 +0200 Subject: [PATCH] Save --- ...metry.py => 00_Pre_FINAL_coil_geometry.py} | 2 +- .../00_First tests.py | 7 ++ .../01_Coil_calculations.py | 12 ++ Coil_geometry_AHH/Optimum_distance.py | 35 ++++++ FINAL_Coil/FINAL_COIL_configuration.py | 33 ++++- FINAL_Coil/Final_Field_quality.py | 113 ++++++++++++++++++ RF_coil/frequency_response.py | 4 +- .../01_Calculate_trap_frequency.py | 40 +++++-- .../00_Try_slightly_shifted_coil.py | 48 ++++---- src/coil_class.py | 37 ++++++ 10 files changed, 291 insertions(+), 40 deletions(-) rename Coil_geometry/{00_FINAL_coil_geometry.py => 00_Pre_FINAL_coil_geometry.py} (98%) create mode 100644 Coil_geometry_AHH/Optimum_distance.py create mode 100644 FINAL_Coil/Final_Field_quality.py diff --git a/Coil_geometry/00_FINAL_coil_geometry.py b/Coil_geometry/00_Pre_FINAL_coil_geometry.py similarity index 98% rename from Coil_geometry/00_FINAL_coil_geometry.py rename to Coil_geometry/00_Pre_FINAL_coil_geometry.py index 5c74b06..fcbed74 100644 --- a/Coil_geometry/00_FINAL_coil_geometry.py +++ b/Coil_geometry/00_Pre_FINAL_coil_geometry.py @@ -68,7 +68,7 @@ AHH_Coil.cooling(I_grad, 22.5) #AHH_Coil.B_quick_plot(I_grad) #AHH_Coil.B_grad_quick_plot(I_grad) -AHH_Coil.plot_raster(raster_value= 11) +#AHH_Coil.plot_raster(raster_value= 11) HH_Coil.cooling(4, 40) diff --git a/Coil_geometry/New intermediate pair of coils/00_First tests.py b/Coil_geometry/New intermediate pair of coils/00_First tests.py index 1fdf43c..83f6dd4 100644 --- a/Coil_geometry/New intermediate pair of coils/00_First tests.py +++ b/Coil_geometry/New intermediate pair of coils/00_First tests.py @@ -65,3 +65,10 @@ AHH_Coil.max_gradient(I) HH_Coil.print_info() AHH_Coil.print_info() + + +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: {2*AHH_Coil.resistance(22)} Ω") +print(f"resistance HH: {2*HH_Coil.resistance(22)} Ω") \ No newline at end of file diff --git a/Coil_geometry/New intermediate pair of coils/01_Coil_calculations.py b/Coil_geometry/New intermediate pair of coils/01_Coil_calculations.py index ad016da..412a9b2 100644 --- a/Coil_geometry/New intermediate pair of coils/01_Coil_calculations.py +++ b/Coil_geometry/New intermediate pair of coils/01_Coil_calculations.py @@ -1,3 +1,4 @@ +#%% import matplotlib.pyplot as plt import numpy as np import matplotlib @@ -25,10 +26,21 @@ HH_Coil = BC.BCoil(HH=1, distance=79.968, radius=80.228, layers=8, windings=8, w AHH_Coil = BC.BCoil(HH=-1, distance=100.336, radius=85.016, layers=10, windings=10, wire_height=1.18, wire_width=1.18, insulation_thickness=0.06, is_round=True, winding_scheme=2) +#%% +AHH_Coil.print_basic_info() +I = 1 +AHH_Coil.max_gradient(I) +HH_Coil.max_field(I) + +# %% +HH_Coil.cooling(2, 30) +AHH_Coil.cooling(3.6,30) HH_Coil.print_basic_info() AHH_Coil.print_basic_info() +AHH_Coil.plot_raster() + I = 0.75 #HH_Coil.B_quick_plot(I) #HH_Coil.B_curv_quick_plot(I) diff --git a/Coil_geometry_AHH/Optimum_distance.py b/Coil_geometry_AHH/Optimum_distance.py new file mode 100644 index 0000000..c931d71 --- /dev/null +++ b/Coil_geometry_AHH/Optimum_distance.py @@ -0,0 +1,35 @@ +import matplotlib.pyplot as plt +import numpy as np +import matplotlib +#matplotlib.use('Qt5Agg') +from src import coil_class as BC +HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = 0.5, + wire_width = 0.5, insulation_thickness = (0.546-0.5)/2, is_round = True, + winding_scheme= 2) + +HH_Coil.set_R_inner(45.6) +HH_Coil.set_d_min(2*24.075) + + +AHH_Coil = BC.BCoil(HH = -1, distance = 54, radius = 48, layers = HH_Coil.get_layers, windings=2 * HH_Coil.get_windings, + wire_height = 0.5, wire_width=0.5, insulation_thickness=(0.546-0.5)/2, + is_round = True, winding_scheme= 2) + +AHH_Coil.set_R_inner(45.6) +AHH_Coil.set_d_min(HH_Coil.get_zmax()*2 * 1e3 + 4) + +d = AHH_Coil.get_radius() +print(d) +AHH_Coil.set_d(d + 5) + +z = np.linspace(-50,50,500) +I = 1 +Bz, Bx = AHH_Coil.B_field(I,z,z) +Bz_grad = AHH_Coil.grad(Bz,z) +Bz_curv = AHH_Coil.grad(Bz_grad, z) +Bz_4 = BC.BCoil.grad(Bz_curv, z) +plt.plot(z,Bz) +plt.plot(z,Bz_grad) +plt.plot(z, Bz_curv) +plt.plot(z, Bz_4) +plt.show() diff --git a/FINAL_Coil/FINAL_COIL_configuration.py b/FINAL_Coil/FINAL_COIL_configuration.py index d84299f..5944f3e 100644 --- a/FINAL_Coil/FINAL_COIL_configuration.py +++ b/FINAL_Coil/FINAL_COIL_configuration.py @@ -9,10 +9,10 @@ HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_width = 0.5, insulation_thickness = (0.546-0.5)/2, is_round = True, winding_scheme= 2) -print(HH_Coil.get_insulation_thickness) HH_Coil.set_R_inner(45.6) HH_Coil.set_d_min(2*24.075) HH_Coil.print_info() +print(f"inductivity = {HH_Coil.induct_perry()*2} H") AHH_Coil = BC.BCoil(HH = -1, distance = 54, radius = 48, layers = HH_Coil.get_layers, windings=2 * HH_Coil.get_windings, wire_height = 0.5, wire_width=0.5, insulation_thickness=(0.546-0.5)/2, @@ -23,4 +23,33 @@ AHH_Coil.set_d_min(HH_Coil.get_zmax()*2 * 1e3 + 4) AHH_Coil.print_info() -R = HH_Coil.resistance(25) \ No newline at end of file +R = HH_Coil.resistance(25) + +I = 5 +AHH_Coil.cooling(I, 30) + +AHH_Coil.max_gradient(I) +AHH_Coil.B_quick_plot(I) + + +HH_Coil.print_info() +AHH_Coil.print_info() + + + + +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: {2*AHH_Coil.resistance(22)} Ω") +print(f"resistance HH: {2*HH_Coil.resistance(22)} Ω") + +# %% +I = 1.3 +AHH_Coil.cooling(I,22) +AHH_Coil.max_gradient(I) + +I_HH = 1.4 +HH_Coil.cooling(I,1.2) +HH_Coil.max_field(I) + diff --git a/FINAL_Coil/Final_Field_quality.py b/FINAL_Coil/Final_Field_quality.py new file mode 100644 index 0000000..feb39e7 --- /dev/null +++ b/FINAL_Coil/Final_Field_quality.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +""" +Created on Mon Aug 23 17:40:37 2021 + +@author: Joschka +""" + + +import matplotlib.pyplot as plt +import numpy as np +#from src import B_field_calculation as bf + +from src import coil_class as BC + +#from IPython import get_ipython +#get_ipython().run_line_magic('matplotlib', 'qt') +#get_ipython().run_line_magic('matplotlib', 'inline') + +#set up axis +x = np.linspace(-15, 15, 30001) +z = np.linspace(-15, 15, 30001) + + +# New coil +Wire_1 = [0.5, 0.568] +#Wire_1 = [0.45, 0.514] +#I_current = 0.94 +HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = 0.5, + wire_width = 0.5, insulation_thickness = (0.546-0.5)/2, is_round = True, + winding_scheme= 2) + +HH_Coil.set_R_inner(45.6) +HH_Coil.set_d_min(2*24.075) +HH_Coil.print_info() +R = HH_Coil.resistance(22.5) + +print(f"U = {1 * R}") + +I_current = 64 / HH_Coil.get_N() * 1.25 + +# 0.4 to get from +-30300 +HH_Coil.print_info() + +#Bz, Bx = HH_Coil.B_field(I_current, x, z, raster = 7) + + +Bz, B_x_tot = HH_Coil.B_tot_along_axis(I_current, x, z, raster = 7) + +Bz_curv = BC.BCoil.curv(Bz, z) +#HH_Coil.cooling(I_current,28) + +print(f"Bz(0) = {Bz[15000]} G") +print(f"B_z_curvature(0) = {Bz_curv[15000]:.10f} G/cm^2") + + +#print(f"Bz(1 μm) = {Bz[15001]}") +#print(f"Bz(1 mm) = {Bz[16000]}") + +print(f"Diff B +/- 1 μm: {Bz[15001] - Bz[15000]}, relative: {(Bz[15001] - Bz[15000])/Bz[15000]}") + +print(f"Diff B +/- 0.5 mm: {Bz[15500] - Bz[15000]}, relative: {(Bz[15500] - Bz[15000])/Bz[15000]}") + +print(f"Diff B +/- 1 mm: {Bz[16000] - Bz[15000]}, relative: {(Bz[16000] - Bz[15000])/Bz[15000]}") + +#print(f"Diff B +/- 15 mm: {Bz[30000] - Bz[15000]}, relative: {(Bz[30000] - Bz[15000])/Bz[15000]}") + + + +""" +plt.figure(300) + + + + +#Field plot +########################## +plt.subplot(2,1,1) +plt.plot(z,Bz,linestyle = "solid", label = r"$Bz along z-axis") +plt.plot(z,B_tot_z, linestyle = "dashed", label = "New B_tot along z-axis") +#plt.plot(x,B_tot_x, label = "B_tot along x-axis") +#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4") + +#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$") +#plt.xlim(-0.01,0.01) +plt.title("B-field" ) + +plt.ylabel(r"$Bz$ [G]") +plt.xlabel("z-axis [mm]") +plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left') + +plt.subplot(2,1,2) +plt.plot(z,Bz_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm") +#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A") + +#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$") + +plt.ylabel(r"$\nabla_z^2 Bz [G/cm^2]$") +plt.xlabel("z-axis [mm]")#plt.xlim(-10,10) +plt.title("Curvature of B-field") +plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left') + +#plt.savefig("output/first_compensation_idea.png") + +plt.show() +""" + + + +""" +AHH ############################################################################ +############################################################################### +############################################################################### +""" diff --git a/RF_coil/frequency_response.py b/RF_coil/frequency_response.py index 4040b11..aa4e2c3 100644 --- a/RF_coil/frequency_response.py +++ b/RF_coil/frequency_response.py @@ -4,11 +4,11 @@ import matplotlib as mpl from src import coil_class as BC -RF_Coil = BC.BCoil(HH = 1, distance = 54, radius = 38.4, layers = 3, windings = 1, wire_height = 0.5, +RF_Coil = BC.BCoil(HH = 1, distance = 54, radius = 38.4, layers = 1, windings = 1, wire_height = 0.5, wire_width = 0.5, insulation_thickness = (0.546-0.5)/2, is_round = True, winding_scheme= 2) -R = RF_Coil.resistance(22.5)*2 +R = RF_Coil.resistance(22.5) # R = 10 diff --git a/Stern_gerlach_separation/01_Calculate_trap_frequency.py b/Stern_gerlach_separation/01_Calculate_trap_frequency.py index 0539ed7..fb3d60c 100644 --- a/Stern_gerlach_separation/01_Calculate_trap_frequency.py +++ b/Stern_gerlach_separation/01_Calculate_trap_frequency.py @@ -8,7 +8,7 @@ from src import physical_constants as cs import numpy as np -mu = 9.9* cs.mu_B +mu = 9.9* cs.mu_B/8 Grad_Bz = cs.m_Dy_164 * 9.81/(8*mu) @@ -16,13 +16,15 @@ print("For levitation:") print(f"dBz/dz = {Grad_Bz*1e4*1e-2:.4f} G/cm") print("") -T = 10e-6 -sigma = np.sqrt(cs.k_B*T/cs.m_Dy_164) -dz = 2*sigma * 10e-3 -print(sigma*10e-3) +T = 1e-6 +dt = 10e-3 +sigma = np.sqrt(cs.k_B*T/cs.m_Dy_164) * dt + +dz = 2 * sigma +print(f"cloud size: {sigma*1e3:.3f} mm") #dz = 250e-6 -dt = 10e-3 + Grad_Bz = 2 * dz * cs.m_Dy_164/(dt**2 * mu) @@ -32,12 +34,26 @@ print("For Stern-Gerlach separation:") print(f"dBz/dz = {Grad_Bz*1e4*1e-2:.4f} G/cm") print(" ") +def cloud_pos(mF, dt = 10e-3): + a = mF*mu*Grad_Bz/cs.m_Dy_164 - 9.81 + s = 0.5 * a *dt**2 + return s +a8 = -8*mu*Grad_Bz/cs.m_Dy_164 - 9.81 +a8_neg = 8*mu*Grad_Bz/cs.m_Dy_164 - 9.81 +a7 = -7*mu*Grad_Bz/cs.m_Dy_164 - 9.81 +s8 = 0.5 * a8 * dt**2 +s8_neg = 0.5 * a8_neg * dt**2 +s7 = 0.5 * a7 * dt**2 -a = 8*mu*2.67*1e-2/cs.m_Dy_164 + 9.81 -s = 0.5 * a * dt**2 -print(s) +for mF in np.arange(-8,9,1): + print(f"for mF = {mF}: pos = {cloud_pos(mF) * 1e3} mm") -print(0.5*9.81*dt**2) -print((2.8778-2.8775)/2.8778) -print(16*dz) \ No newline at end of file +print(f"Total fall for m8 for acceleration due to magnetic field in same direction than gravity = {s8 * 1e3}mm") +print(f"Total lift for m8 for acceleration due to magnetic field in other direction than gravity = {s8_neg * 1e3}mm") +print(f"Fall without magnetic field = {-0.5 * 9.81 * dt**2 *1e3} mm") + + +print(f"s7 = {s7 * 1e3}mm") +print(f"diff = {(s8 - s7) * 1e3} mm") + diff --git a/Winding_inhomogenities/00_Try_slightly_shifted_coil.py b/Winding_inhomogenities/00_Try_slightly_shifted_coil.py index f329c4b..6abac22 100644 --- a/Winding_inhomogenities/00_Try_slightly_shifted_coil.py +++ b/Winding_inhomogenities/00_Try_slightly_shifted_coil.py @@ -2,47 +2,50 @@ import numpy as np import matplotlib.pyplot as plt import src.coil_class as BC - I_current = 1.25 # scale = 1000 --> μm scale = 1000 lim = 5 nr_points = (2 * lim) * scale + 1 -x = np.linspace(-lim,lim,nr_points) -z = np.linspace(-lim,lim,nr_points) +x = np.linspace(-lim, lim, nr_points) +z = np.linspace(-lim, lim, nr_points) print(x) + def mu_it(x_pos): - it = nr_points//2 + x_pos + it = nr_points // 2 + x_pos return it + print(x[mu_it(-60)]) -#standard -C1 = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = 0.5, wire_width = 0.5, insulation_thickness= 0.06, is_round = True, winding_scheme= True) +# standard +C1 = BC.BCoil(HH=1, distance=54, radius=48, layers=8, windings=8, wire_height=0.5, wire_width=0.5, + insulation_thickness=0.06, is_round=True, winding_scheme=True) C1.set_R_outer(49.8) C1.set_d_min(49.8) C1.print_info() -Bz, Bx = C1.B_tot_along_axis(I_current, x, z,raster = 2) +Bz, Bx = C1.B_tot_along_axis(I_current, x, z, raster=2) # plt.figure(5) # plt.plot(z,Bz) # plt.plot(x,Bx, label = "B_tot along x-axis") # plt.show() -#plt.close(5) +# plt.close(5) -#coil is ~ 500 μm thicker -shift_radius = 1#0.125 -C_shift = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = 0.5, wire_width = 0.5, insulation_thickness= 0.06, is_round = True, winding_scheme= True) +# coil is ~ 500 μm thicker +shift_radius = 1 # 0.125 +C_shift = BC.BCoil(HH=1, distance=54, radius=48, layers=8, windings=8, wire_height=0.5, wire_width=0.5, + insulation_thickness=0.06, is_round=True, winding_scheme=True) C_shift.set_R_outer(49.8 + shift_radius) C_shift.set_d_min(49.8) -#shift_radius = 0.125 +# shift_radius = 0.125 -Bz2, By = C_shift.B_tot_along_axis(I_current+0.00082, x, z,raster = 2) +Bz2, By = C_shift.B_tot_along_axis(I_current + 0.00082, x, z, raster=2) shift_int = int(shift_radius * scale - 1) print(shift_int) @@ -50,26 +53,25 @@ By_shift = By[shift_int:] y_shift = x[:-shift_int] print(By_shift) print(y_shift) -B_sum = (By_shift + Bx[:-shift_int])/2 +B_sum = (By_shift + Bx[:-shift_int]) / 2 # shift By shift with shift radius plt.figure(6) -#plt.plot(z,Bz) -plt.plot(x,Bx, label = "B_tot along x-axis") -plt.plot(y_shift,By_shift, label = "Shiftet tot B") -plt.plot(y_shift,B_sum, label = "B_sum") +# plt.plot(z,Bz) +plt.plot(x, Bx, label="B_tot along x-axis") +plt.plot(y_shift, By_shift, label="Shiftet tot B") +plt.plot(y_shift, B_sum, label="B_sum") plt.legend() plt.show() -#plt.close(5) +# plt.close(5) it = mu_it(int(-shift_radius * 1e3 // 2)) -#it = μm_it(-60) +# it = μm_it(-60) print(it) zero = mu_it(0) print(y_shift[it]) print(y_shift[zero]) -tot_diff = B_sum[it]-B_sum[zero] - -print(f"diff {y_shift[it]} μm --> 0: {tot_diff} G, relative = {tot_diff/B_sum[it]}") +tot_diff = B_sum[it] - B_sum[zero] +print(f"diff {y_shift[it]} μm --> 0: {tot_diff} G, relative = {tot_diff / B_sum[it]}") diff --git a/src/coil_class.py b/src/coil_class.py index 9368c65..654d890 100644 --- a/src/coil_class.py +++ b/src/coil_class.py @@ -123,6 +123,10 @@ class BCoil: R_inner *= 1e-3 self.radius = R_inner + self.get_coil_width() / 2 + def set_d(self, d): + d *= 1e-3 + self.distance = d + def set_d_min(self, d_min): d_min *= 1e-3 self.distance = d_min + self.get_coil_height() @@ -467,6 +471,7 @@ class BCoil: # print(f"time = {end - start} s") return B_z, B_x + def max_field(self, I_current, raster = 7): B_z_0 = 0 calc_raster = self.full_raster(raster) @@ -489,6 +494,38 @@ class BCoil: print(f" Max Field = {B_z_0:.2f} G") return B_z_0 + def max_field_one_coil(self, I_current, raster = 7): + """ + Returns and prints max (z-) field in Gauss at center of one coil of configuration pair if second one is not powered + Args: + I_current: Current in [A] + raster: rastering value for each wire (increasing increases accuracy), 7 is fine for most cases + + Returns: + Max B-field at center position of coil + + """ + B_z_0 = 0 + calc_raster = self.full_raster(raster) + + if self.get_N() != len(calc_raster): + log.error("N is not equal length of raster") + + rastering_value = len(calc_raster[0]) + + I_current /= rastering_value # divide current into smaller currents for mapping the whole wire + + for wire in range(0, self.get_N()): + for ii in range(0, rastering_value): + # extract position information out of raster + z_pos = calc_raster[wire, ii, 0] + r_pos = calc_raster[wire, ii, 1] + + B_z_0 += BCoil.__B_z_loop(I_current, r_pos, z_pos, 0, z_pos) + + print(f" Max Field = {B_z_0:.2f} G") + return B_z_0 + def max_gradient(self, i_current, raster = 7): x, z = BCoil.make_axis(0.5, 1000) Bz, Bx = self.B_field(i_current, x, z, raster = raster)