From a03c6019956b095b611d401c80499e88ba9d107c Mon Sep 17 00:00:00 2001 From: schoener Date: Tue, 26 Oct 2021 14:33:07 +0200 Subject: [PATCH] HH configuration added --- ...=> 13_new_HH_coil_comp_different_wires.py} | 0 Coil_geometry/14_new_HH_coil_wire_decision.py | 35 ++++++++++++ .../00_Try_slightly_shifted_coil.py | 0 src/coil_class.py | 54 +++++++++++-------- untitled0.py | 4 +- 5 files changed, 70 insertions(+), 23 deletions(-) rename Coil_geometry/{13_Properties_new_HH_coil_incr_N.py => 13_new_HH_coil_comp_different_wires.py} (100%) create mode 100644 Coil_geometry/14_new_HH_coil_wire_decision.py create mode 100644 Winding_inhomogenities/00_Try_slightly_shifted_coil.py diff --git a/Coil_geometry/13_Properties_new_HH_coil_incr_N.py b/Coil_geometry/13_new_HH_coil_comp_different_wires.py similarity index 100% rename from Coil_geometry/13_Properties_new_HH_coil_incr_N.py rename to Coil_geometry/13_new_HH_coil_comp_different_wires.py diff --git a/Coil_geometry/14_new_HH_coil_wire_decision.py b/Coil_geometry/14_new_HH_coil_wire_decision.py new file mode 100644 index 0000000..81718c7 --- /dev/null +++ b/Coil_geometry/14_new_HH_coil_wire_decision.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +""" +Created on Tue Sep 7 13:18:18 2021 + +@author: Joschka +""" + +import matplotlib.pyplot as plt +import numpy as np +import matplotlib +matplotlib.use('Qt5Agg') +from src import coil_class as BC + +from IPython import get_ipython +#get_ipython().run_line_magic('matplotlib', 'qt') + +I = 10/8 +print(I) + +Wire_1 = 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_offset= True) +Wire_1.set_R_outer(49.8) +Wire_1.set_d_min(49.8) +Wire_1.print_info() +print(Wire_1.get_coil_width() * 1e3 * Wire_1.get_coil_height() * 1e3) +print(f"H = {Wire_1.get_coil_height() * 1e3}, W = {Wire_1.get_coil_width()*1e3}") + + +Wire_1.cooling(I,22.5) + +Wire_1.plot_raster(30) + +Wire_1.B_quick_plot(I) +Wire_1.B_curv_quick_plot(I) + + diff --git a/Winding_inhomogenities/00_Try_slightly_shifted_coil.py b/Winding_inhomogenities/00_Try_slightly_shifted_coil.py new file mode 100644 index 0000000..e69de29 diff --git a/src/coil_class.py b/src/coil_class.py index b14a980..234156d 100644 --- a/src/coil_class.py +++ b/src/coil_class.py @@ -9,6 +9,9 @@ import matplotlib.pyplot as plt import logging as log from scipy import special as sp +import matplotlib +matplotlib.use('Qt5Agg') + import time from src import physical_constants as cs @@ -218,6 +221,7 @@ class BCoil: else: extension = self.get_coil_height() extension *= 1e3 + plt.figure(77, figsize=(5, 5)) plt.scatter(full_structure[:, :, 1], full_structure[:, :, 0], linewidths=0.001) plt.xlabel("radius [mm]") @@ -226,7 +230,7 @@ class BCoil: plt.ylim(1e3 * self.get_zmin() - 0.5, 1e3 * self.get_zmin() + extension + 0.5) plt.show() - plt.close(77) + def print_info(self): print(" ") @@ -295,13 +299,14 @@ class BCoil: z_SI = z * 1e-3 if x[0] <= 0: # divide array into positive and negative values - x_neg = np.abs([el for el in x_SI if el < 0]) - x_pos = np.array([el for el in x_SI if el > 0]) + x_negative = np.abs([el for el in x_SI if el < 0]) + x_positive = np.array([el for el in x_SI if el > 0]) x_zero = np.array([el for el in x_SI if el == 0]) B_z = np.zeros(len(z)) - B_x_pos = np.zeros(len(x_pos)) - B_x_neg = np.zeros(len(x_neg)) + + B_x_pos = np.zeros(len(x_positive)) + B_x_neg = np.zeros(len(x_negative)) B_x_zero = x_zero # 0 in x-array --> field is zero at this position calc_raster = self.full_raster(raster) @@ -321,10 +326,10 @@ class BCoil: B_z += BCoil.B_z_loop(I_current, r_pos, z_pos, 0, z_SI) + BCoil.B_z_loop(self.HH * I_current, r_pos, -z_pos, 0, z_SI) - B_x_pos += BCoil.B_r_loop(I_current, r_pos, z_pos, x_pos, 0) + BCoil.B_r_loop( - self.HH * I_current, r_pos, -z_pos, x_pos, 0) - B_x_neg += BCoil.B_r_loop(I_current, r_pos, z_pos, x_neg, 0) + BCoil.B_r_loop( - self.HH * I_current, r_pos, -z_pos, x_neg, 0) + B_x_pos += BCoil.B_r_loop(I_current, r_pos, z_pos, x_positive, 0) + BCoil.B_r_loop( + self.HH * I_current, r_pos, -z_pos, x_positive, 0) + B_x_neg += BCoil.B_r_loop(I_current, r_pos, z_pos, x_negative, 0) + BCoil.B_r_loop( + self.HH * I_current, r_pos, -z_pos, x_negative, 0) B_x_neg *= -1 # B_x_neg is pointing in opposite x_direction B_x = np.concatenate((B_x_neg, B_x_zero, B_x_pos)) @@ -467,7 +472,7 @@ class BCoil: def grad(B_f, z): return np.gradient(B_f, z) * 1e1 - def B_quick_plot(self, I_current, abs = True, x_lim = 50, z_lim = 50, nr_points = 500): + def B_quick_plot(self, I_current, abs = True, x_lim = 50, z_lim = 50, nr_points = 200): x = np.linspace(-x_lim, x_lim, nr_points) z = np.linspace(-z_lim, z_lim, nr_points) if abs: @@ -475,6 +480,7 @@ class BCoil: else: B_z, B_x = self.B_field(I_current, x, z) + plt.figure(11) 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") @@ -483,7 +489,8 @@ class BCoil: plt.legend() plt.show() - def B_grad_quick_plot(self, I_current, x_lim = 50, z_lim = 50, nr_points = 500): + + def B_grad_quick_plot(self, I_current, x_lim = 50, z_lim = 50, nr_points = 200): x = np.linspace(-x_lim, x_lim, nr_points) z = np.linspace(-z_lim, z_lim, nr_points) @@ -492,6 +499,7 @@ class BCoil: B_z = BCoil.grad(B_z, z) B_x = BCoil.grad(B_x, x) + plt.figure(12) 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") @@ -500,7 +508,7 @@ class BCoil: plt.legend() plt.show() - def B_curv_quick_plot(self, I_current, x_lim=50, z_lim=50, nr_points=500): + def B_curv_quick_plot(self, I_current, x_lim=50, z_lim=50, nr_points=200): x = np.linspace(-x_lim, x_lim, nr_points) z = np.linspace(-z_lim, z_lim, nr_points) @@ -508,14 +516,16 @@ class BCoil: B_z = BCoil.curv(B_z, z) B_x = BCoil.curv(B_x, x) + plt.figure(13) 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.title("Curvature of B-field") + plt.ylabel(r"Curv. B-field [G/cm$^2$]") plt.xlabel("x-axis / z-axis [mm]") plt.legend() plt.show() + def Bz_plot_HH_comp(self, Coil2, I_current, x, z): B_z, B_x = self.B_field(I_current, x, z) B_z_2, B_x_2 = Coil2.B_field(I_current, x, z) @@ -617,15 +627,15 @@ class BCoil: def main(): - HH_Coil = BCoil(HH=-1, distance=50, radius=40, layers=8, windings=8, wire_height=0.4, wire_width=0.4, + HH_Coil = BCoil(HH=-1, distance=50, radius=40, layers=8, windings=8, wire_height=0.5, 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(10) - HH_Coil.B_quick_plot(1.25, abs = True) + HH_Coil.B_quick_plot(1.25, abs = False) HH_Coil.B_grad_quick_plot(1.25) - #HH_Coil.B_curv_quick_plot(1.25) + HH_Coil.B_curv_quick_plot(1.25) # if True & 1 == 1: # print("test") #print(ras) @@ -644,7 +654,7 @@ def main(): # ras = HH_Coil.full_raster(10) #HH_Coil.plot_3d(1.25,50,50) -main() -# if __name__ == "__main__": -# print("g") -# main() +#main() +if __name__ == "__main__": + print("g") + main() diff --git a/untitled0.py b/untitled0.py index 2df3ef2..87ed634 100644 --- a/untitled0.py +++ b/untitled0.py @@ -6,4 +6,6 @@ Created on Fri Oct 1 10:42:13 2021 """ import numpy as np -print(np.zeros((5,2))) \ No newline at end of file +print(np.sqrt(0.2)) + +print(0.56*8+ 0.1*4.48) \ No newline at end of file