# -*- 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 = 1 # 0.4 to get from +-30300 #Bz, Bx = AHH_Coil.B_field(I_current, x, z, raster = 7) Bz, B_x_tot = HH_Coil.B_field(I_current, x, z, raster = 7) Bz_as, B_x_as = HH_Coil.B_field_asym(I_current, x, z, raster = 7) Bz_curv = BC.BCoil.curv(Bz, z) Bz_curv_as = BC.BCoil.curv(Bz_as, z) #AHH_Coil.cooling(I_current,28) # %% print("Symmetric coil configuration") 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("") print("Asymmetric coil configuration (one with 200 μm smaller diameter)") print(f"Bz(0) = {Bz_as[15000]} G") print(f"B_z_curvature(0) = {Bz_curv_as[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_as[15001] - Bz_as[15000]}, relative: {(Bz_as[15001] - Bz_as[15000])/Bz_as[15000]}") print(f"Diff B - 1 μm: {Bz_as[14999] - Bz_as[15000]}, relative: {(Bz_as[14999] - Bz_as[15000])/Bz_as[15000]}") print("") print(f"Diff B + 0.5 mm: {Bz_as[15500] - Bz_as[15000]}, relative: {(Bz_as[15500] - Bz_as[15000])/Bz_as[15000]}") print(f"Diff B - 0.5 mm: {Bz_as[14500] - Bz_as[15000]}, relative: {(Bz_as[14500] - Bz_as[15000])/Bz_as[15000]}") print("") print(f"Diff B + 1 mm: {Bz_as[16000] - Bz_as[15000]}, relative: {(Bz_as[16000] - Bz_as[15000])/Bz_as[15000]}") print(f"Diff B - 1 mm: {Bz_as[14000] - Bz_as[15000]}, relative: {(Bz_as[14000] - Bz_as[15000])/Bz_as[15000]}") print("") print("Comparison Bx") print(f"Symmetric Bx = {B_x_tot[15001]}") print(f"Bx(0) = {B_x_as[15001]}") print(f"Diff B - 1 mm: {B_x_as[14000] - B_x_as[15000]}, relative: {(B_x_as[14000] - B_x_as[15000])/B_x_as[15000]}") #print(f"Diff B +/- 15 mm: {Bz[30000] - Bz[15000]}, relative: {(Bz[30000] - Bz[15000])/Bz[15000]}") _ # %% 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-0.1) HH_Coil.set_d_min(2*24.075) HH_Coil.print_info() # %% I_current = 1 # 0.4 to get from +-30300 #Bz, Bx = AHH_Coil.B_field(I_current, x, z, raster = 7) Bz_2, B_x_2 = HH_Coil.B_field(I_current, x, z, raster = 7) Bz_curv_2 = BC.BCoil.curv(Bz_2, z) print("") print(f"Diff B +/- 1 mm: {Bz_2[16000] - Bz_2[15000]}, relative: {(Bz_2[16000] - Bz_2[15000])/Bz_2[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 ############################################################################ ############################################################################### ############################################################################### """