Checked class until line 552
Added plot functions
This commit is contained in:
parent
2c6a29906e
commit
21bba55091
@ -53,7 +53,7 @@ HH_Coil_54.cooling(5)
|
||||
#Compensation Coil
|
||||
HH_Coil_78 = BC.BCoil(1,54,37,4, 4, 1,1)
|
||||
|
||||
#HH_Coil_44.Bz_plot_HH(I,x,z)
|
||||
#HH_Coil_44.B_quick_plot(I,x,z)
|
||||
|
||||
|
||||
#HH_Coil_44.Bz_plot_HH_comp(HH_Coil_54,I,x,z)
|
||||
|
@ -32,8 +32,8 @@ B_z,B_x = HH_Coil_78.B_field(1, x, z)
|
||||
#x = np.concatenate((-np.flip(r),r))
|
||||
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
#plt.rcParams.update({'font.size': 15})
|
||||
plt.suptitle("Anti Helmholtz coil field, I = 1 A, d = 54 mm, R = 37 mm ", fontsize = 30)
|
||||
|
@ -57,7 +57,7 @@ HH_Coil_comp = BC.BCoil(HH = 1, distance = 54 ,radius = 37, layers = 4, windings
|
||||
|
||||
|
||||
|
||||
#HH_Coil_44.Bz_plot_HH(I,x,z)
|
||||
#HH_Coil_44.B_quick_plot(I,x,z)
|
||||
|
||||
|
||||
#HH_Coil_44.Bz_plot_HH_comp(HH_Coil_54,I,x,z)
|
||||
|
@ -30,8 +30,8 @@ AHH_Coil.set_R_outer(49.3)
|
||||
|
||||
#B_z,B_x = AHH_Coil.B_field(1,x,z)
|
||||
|
||||
#B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
#B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
#B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
#B_x_grad = BC.BCoil.grad(B_x,x)
|
||||
|
||||
plt.figure(1,figsize=(10,13))
|
||||
#plt.rcParams.update({'font.size': 15})
|
||||
@ -53,8 +53,8 @@ B_z,B_x = AHH_Coil.B_field(10, x, z)
|
||||
#B_z = B[:,150,1]
|
||||
#B_x = B[150,:,0]
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
plt.subplot(2,1,1)
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"#HH_Coil_44.Bz_plot_HH(I,x,z)\n"
|
||||
"#HH_Coil_44.B_quick_plot(I,x,z)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -41,8 +41,8 @@ B_z,B_x = AHH_Coil.B_field(I, x, z)
|
||||
|
||||
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
lim = 7000
|
||||
B_0 = B_z_grad[5000]
|
||||
|
@ -44,8 +44,8 @@ B_z,B_x = AHH_Coil.B_field(I, x, z)
|
||||
|
||||
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
# lim = 7000
|
||||
# B_0 = B_z_grad[5000]
|
||||
@ -58,14 +58,14 @@ for d in distance:
|
||||
print(d)
|
||||
AHH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
|
||||
B_z,B_x = AHH_Coil.B_field(I, x, z)
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
B_z_curv = BC.BCoil.Bgrad(B_z_grad, z)
|
||||
B_x_curv = BC.BCoil.Bgrad(B_z_grad, z)
|
||||
B_z_curv = BC.BCoil.grad(B_z_grad, z)
|
||||
B_x_curv = BC.BCoil.grad(B_z_grad, z)
|
||||
|
||||
B_z_3rd = BC.BCoil.Bgrad(B_z_curv, z)
|
||||
B_x_3rd = BC.BCoil.Bgrad(B_z_curv, z)
|
||||
B_z_3rd = BC.BCoil.grad(B_z_curv, z)
|
||||
B_x_3rd = BC.BCoil.grad(B_z_curv, z)
|
||||
|
||||
|
||||
plt.subplot(2,2,1)
|
||||
@ -89,7 +89,7 @@ for d in distance:
|
||||
plt.subplot(2,2,3)
|
||||
plt.title("Curvature")
|
||||
plt.plot(z,B_z_curv,linestyle = "solid", label = f"$ d = {d} mm")
|
||||
#plt.plot(x,B_x_curv, label = f"Curv. $B_x$, d = {d} mm")
|
||||
#plt.plot(x,B_x_curv, label = f"curv. $B_x$, d = {d} mm")
|
||||
|
||||
plt.title("B-field" )
|
||||
plt.ylabel(r"$B$ [G/cm^2]")
|
||||
|
@ -38,14 +38,14 @@ print(f"R (30 degree C)= {AHH_Coil.resistance(30)}")
|
||||
|
||||
B_z,B_x = AHH_Coil.B_field(I, x, z)
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
B_z_curv = BC.BCoil.Bgrad(B_z_grad, z)
|
||||
B_x_curv = BC.BCoil.Bgrad(B_z_grad, z)
|
||||
B_z_curv = BC.BCoil.grad(B_z_grad, z)
|
||||
B_x_curv = BC.BCoil.grad(B_z_grad, z)
|
||||
|
||||
B_z_3rd = BC.BCoil.Bgrad(B_z_curv, z)
|
||||
B_x_3rd = BC.BCoil.Bgrad(B_z_curv, z)
|
||||
B_z_3rd = BC.BCoil.grad(B_z_curv, z)
|
||||
B_x_3rd = BC.BCoil.grad(B_z_curv, z)
|
||||
|
||||
|
||||
|
||||
|
@ -54,8 +54,8 @@ B_z,B_x = AHH_Coil.B_field(I, x, z)
|
||||
|
||||
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
lim = 7000
|
||||
B_0 = B_z_grad[5000]
|
||||
|
@ -53,11 +53,11 @@ Bz_comp, Bx_comp = AHH_comp.B_field(I, x, z)
|
||||
#B_x = B[150,:,0]
|
||||
#B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
|
||||
|
||||
Bz_grad_opt = BC.BCoil.Bgrad(Bz_opt, z)
|
||||
Bx_grad_opt = BC.BCoil.Bgrad(Bx_opt,x)
|
||||
Bz_grad_opt = BC.BCoil.grad(Bz_opt, z)
|
||||
Bx_grad_opt = BC.BCoil.grad(Bx_opt, x)
|
||||
|
||||
Bz_grad_comp = BC.BCoil.Bgrad(Bz_comp, z)
|
||||
Bx_grad_comp = BC.BCoil.Bgrad(Bx_comp,x)
|
||||
Bz_grad_comp = BC.BCoil.grad(Bz_comp, z)
|
||||
Bx_grad_comp = BC.BCoil.grad(Bx_comp, x)
|
||||
|
||||
Bz_rel_opt = (Bz_grad_opt[zr]- Bz_grad_opt)/Bz_grad_opt[zr]*100
|
||||
Bx_rel_opt = (Bx_grad_opt[zr]- Bx_grad_opt)/Bx_grad_opt[zr]*100
|
||||
@ -103,7 +103,7 @@ plt.plot(z,Bz_rel_comp,linestyle = "solid",color = "blue", label = f"$B_z$, d =
|
||||
plt.plot(x,Bx_rel_opt,linestyle = "dashed",color = "orange", label = f"$B_x$, d = {d_opt} mm")
|
||||
plt.plot(x,Bx_rel_comp, linestyle = "dashed",color = "blue", label = f"$B_x$, d = {d_comp} mm")
|
||||
|
||||
plt.ylabel(r"rel. Deviation from Grad to center [%]$")
|
||||
plt.ylabel(r"rel. Deviation from grad to center [%]$")
|
||||
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
|
||||
#plt.title(r"$\nabla_i B_i")
|
||||
#plt.ylim(-0.05,0.05)
|
||||
|
@ -54,8 +54,8 @@ B_z,B_x = AHH_Coil.B_field(I, x, z)
|
||||
|
||||
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
lim = 7000
|
||||
B_0 = B_z_grad[5000]
|
||||
|
@ -54,8 +54,8 @@ B_z,B_x = AHH_Coil.B_field(I, x, z)
|
||||
|
||||
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
|
||||
|
||||
B_z_grad = BC.BCoil.Bgrad(B_z, z)
|
||||
B_x_grad = BC.BCoil.Bgrad(B_x,x)
|
||||
B_z_grad = BC.BCoil.grad(B_z, z)
|
||||
B_x_grad = BC.BCoil.grad(B_x, x)
|
||||
|
||||
lim = 7000
|
||||
B_0 = B_z_grad[5000]
|
||||
|
@ -33,7 +33,7 @@ Bz, Bx = HH_Coil.B_field(I_current, x, z, raster = 10)
|
||||
|
||||
B_tot_z, B_tot_x = HH_Coil.B_field(I_current, x, z, raster = 10)
|
||||
|
||||
Bz = BC.BCoil.Bgrad(Bz, z)
|
||||
Bz = BC.BCoil.grad(Bz, z)
|
||||
HH_Coil.cooling(I_current,28)
|
||||
|
||||
print(f"B_z(0) = {Bz[15000]} G")
|
||||
|
@ -45,7 +45,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"#HH_Coil_44.Bz_plot_HH(I,x,z)\n"
|
||||
"#HH_Coil_44.B_quick_plot(I,x,z)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ HH_Coil1 = BC.BCoil(HH, d_coils ,R_mid, layers, windings, wire_width, wire_heigh
|
||||
#B_x = np.concatenate((-np.flip(B_r),B_r[1:len(B_r)]))
|
||||
|
||||
|
||||
HH_Coil1.Bz_plot_HH(I,x,z)
|
||||
HH_Coil1.B_quick_plot(I, x, z)
|
||||
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ HH_Coil_44 = BC.BCoil(HH, d_coils ,R_mid, layers, windings, wire_width, wire_hei
|
||||
d_coils_2 = 55.2
|
||||
HH_Coil_54 = BC.BCoil(HH, d_coils_2 ,R_mid, layers, windings, wire_width, wire_height)
|
||||
|
||||
#HH_Coil_44.Bz_plot_HH(I,x,z)
|
||||
#HH_Coil_44.B_quick_plot(I,x,z)
|
||||
|
||||
|
||||
#HH_Coil_44.Bz_plot_HH_comp(HH_Coil_54,I,x,z)
|
||||
|
@ -461,43 +461,59 @@ class BCoil:
|
||||
plt.ylabel("z-axis [mm]")
|
||||
plt.show()
|
||||
|
||||
def curv(B_field, z):
|
||||
return np.gradient(np.gradient(B_field, z), z) * 1e2
|
||||
def curv(B_f, z):
|
||||
return np.gradient(np.gradient(B_f, z), z) * 1e2
|
||||
|
||||
def Bgrad(B_field, z):
|
||||
return np.gradient(B_field, z) * 1e1
|
||||
def grad(B_f, z):
|
||||
return np.gradient(B_f, z) * 1e1
|
||||
|
||||
def Bz_plot_HH(self, I_current, x, z):
|
||||
B_z, B_x = self.B_field(I_current, x, z)
|
||||
def B_quick_plot(self, I_current, abs = True, x_lim = 50, z_lim = 50, nr_points = 500):
|
||||
x = np.linspace(-x_lim, x_lim, nr_points)
|
||||
z = np.linspace(-z_lim, z_lim, nr_points)
|
||||
if abs:
|
||||
B_z, B_x = self.B_tot_along_axis(I_current, x, z)
|
||||
else:
|
||||
B_z, B_x = self.B_field(I_current, x, z)
|
||||
|
||||
B_z_curvature = np.gradient(np.gradient(B_z, z), z)
|
||||
|
||||
plt.figure(100, figsize=(13, 10))
|
||||
|
||||
# plt.rcParams.update({'font.size': 15})
|
||||
plt.suptitle("Helmholtz coil field B_z along z-axis")
|
||||
|
||||
# Field plot
|
||||
##########################
|
||||
plt.subplot(2, 1, 1)
|
||||
plt.plot(z, B_z, linestyle="solid", label=r"$B_z$: Result via elliptic integrals")
|
||||
|
||||
# plt.xlim(-0.01,0.01)
|
||||
plt.plot(z, B_z, linestyle="solid", label=r"$B_{tot}$ along z-axis")
|
||||
plt.plot(x, B_x, label = r"$B_{tot}$ along x-axis")
|
||||
plt.title("B-field")
|
||||
|
||||
plt.ylabel(r"$B_z$ [G]")
|
||||
plt.xlabel("z-axis [mm]")
|
||||
plt.ylabel(r"B-field [G]")
|
||||
plt.xlabel("x-axis / z-axis [mm]")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
plt.subplot(2, 1, 2)
|
||||
plt.plot(z, B_z_curvature, linestyle="solid", label=r"$\nabla_z^2 B_z$: Result via elliptic integrals")
|
||||
def B_grad_quick_plot(self, I_current, x_lim = 50, z_lim = 50, nr_points = 500):
|
||||
x = np.linspace(-x_lim, x_lim, nr_points)
|
||||
z = np.linspace(-z_lim, z_lim, nr_points)
|
||||
|
||||
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
|
||||
plt.xlabel("z-axis [mm]")
|
||||
plt.xlim(-10, 10)
|
||||
plt.title("Curvature of B-field")
|
||||
plt.legend(loc='lower right')
|
||||
B_z, B_x = self.B_field(I_current, x, z)
|
||||
# TODO: Think about Gradient calculation of tot B_field
|
||||
B_z = BCoil.grad(B_z, z)
|
||||
B_x = BCoil.grad(B_x, x)
|
||||
|
||||
plt.plot(z, B_z, linestyle="solid", label=r"$B_{tot}$ along z-axis")
|
||||
plt.plot(x, B_x, label=r"$B_{tot}$ along x-axis")
|
||||
plt.title("Gradient of B-field")
|
||||
plt.ylabel(r"B-field [G]")
|
||||
plt.xlabel("x-axis / z-axis [mm]")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
def B_curv_quick_plot(self, I_current, x_lim=50, z_lim=50, nr_points=500):
|
||||
x = np.linspace(-x_lim, x_lim, nr_points)
|
||||
z = np.linspace(-z_lim, z_lim, nr_points)
|
||||
|
||||
B_z, B_x = self.B_field(I_current, x, z)
|
||||
B_z = BCoil.curv(B_z, z)
|
||||
B_x = BCoil.curv(B_x, x)
|
||||
|
||||
plt.plot(z, B_z, linestyle="solid", label=r"$B_{tot}$ along z-axis")
|
||||
plt.plot(x, B_x, label=r"$B_{tot}$ along x-axis")
|
||||
plt.title("B-field")
|
||||
plt.ylabel(r"B-field [G]")
|
||||
plt.xlabel("x-axis / z-axis [mm]")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
def Bz_plot_HH_comp(self, Coil2, I_current, x, z):
|
||||
@ -601,11 +617,15 @@ class BCoil:
|
||||
|
||||
|
||||
def main():
|
||||
HH_Coil = BCoil(HH=1, distance=50, radius=40, layers=8, windings=3, wire_height=0.4, wire_width=0.4,
|
||||
HH_Coil = BCoil(HH=-1, distance=50, radius=40, layers=8, windings=8, wire_height=0.4, wire_width=0.4,
|
||||
insulation_thickness=0.2, is_round = True, winding_offset=True)
|
||||
#ras = HH_Coil.full_raster(raster_value = 3)
|
||||
# print(HH_Coil.is_round)
|
||||
HH_Coil.plot_raster(4)
|
||||
#HH_Coil.plot_raster(4)
|
||||
|
||||
HH_Coil.B_quick_plot(1.25, abs = True)
|
||||
HH_Coil.B_grad_quick_plot(1.25)
|
||||
#HH_Coil.B_curv_quick_plot(1.25)
|
||||
# if True & 1 == 1:
|
||||
# print("test")
|
||||
#print(ras)
|
||||
@ -622,7 +642,7 @@ def main():
|
||||
#
|
||||
# HH_Coil.plot_raster(3)
|
||||
# ras = HH_Coil.full_raster(10)
|
||||
HH_Coil.plot_3d(1.25,50,50)
|
||||
#HH_Coil.plot_3d(1.25,50,50)
|
||||
|
||||
main()
|
||||
# if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user