From e64fb4adecc0529e778ff4115ce6e9ac1a79dc13 Mon Sep 17 00:00:00 2001 From: schoener Date: Fri, 29 Oct 2021 18:37:36 +0200 Subject: [PATCH] FINAL Wire and winding decision --- Coil_geometry/11_Final_HH.py | 16 +- Coil_geometry/14_new_HH_coil_wire_decision.py | 26 ++- ..._new_HH_coil_iterative_winding_decision.py | 65 ++++++ Coil_geometry_AHH/08_FINAL_AHH.py | 48 +++++ Cooling/04_Power estimation.py | 19 ++ src/coil_class.py | 199 ++++++++++-------- untitled0.py | 2 +- 7 files changed, 265 insertions(+), 110 deletions(-) create mode 100644 Coil_geometry/15_new_HH_coil_iterative_winding_decision.py create mode 100644 Coil_geometry_AHH/08_FINAL_AHH.py create mode 100644 Cooling/04_Power estimation.py diff --git a/Coil_geometry/11_Final_HH.py b/Coil_geometry/11_Final_HH.py index 0b5642f..7bc11bd 100644 --- a/Coil_geometry/11_Final_HH.py +++ b/Coil_geometry/11_Final_HH.py @@ -12,8 +12,8 @@ import numpy as np from src import coil_class as BC -from IPython import get_ipython -get_ipython().run_line_magic('matplotlib', 'qt') +#from IPython import get_ipython +#get_ipython().run_line_magic('matplotlib', 'qt') #get_ipython().run_line_magic('matplotlib', 'inline') #set up axis @@ -22,10 +22,14 @@ z = np.linspace(-15, 15, 30001) #New coil -I_current = 10 -HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 2, wire_height = 2, wire_width = 1, windings_spacing=0.25, layers_spacing = 0.25) -HH_Coil.set_R_inner(44.5) -HH_Coil.set_d_min(48.8) +Wire_1 = [0.5, 0.568] +I_current = 0.94 +HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 10, windings = 9, wire_height = Wire_1[0], wire_width = Wire_1[0], insulation_thickness=(Wire_1[1] - Wire_1[0]) / 2, is_round = True, winding_scheme= 2) + +#I = 64 / HH_Coil.get_N() * 1.25 +#set radius plus distance +HH_Coil.set_R_outer(50.5 - HH_Coil.get_tot_wire_width()*1e3) +HH_Coil.set_d_min(47.15) print(f"height = {HH_Coil.get_coil_height()}") HH_Coil.print_info() diff --git a/Coil_geometry/14_new_HH_coil_wire_decision.py b/Coil_geometry/14_new_HH_coil_wire_decision.py index c10c71f..534f208 100644 --- a/Coil_geometry/14_new_HH_coil_wire_decision.py +++ b/Coil_geometry/14_new_HH_coil_wire_decision.py @@ -23,21 +23,25 @@ def mu_it(x_pos): return it -wire_radius = 0.475 +Wire_1 = [0.45, 0.6514] +for ll in range(7,11): + for ww in range(7,11) +Coil_1 = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = Wire_1[0], wire_width = Wire_1[0], insulation_thickness= (Wire_1[1] - Wire_1[0])/2, is_round = True, winding_scheme= 2) +print(Coil_1.get_tot_wire_width()) +Coil_1.set_R_outer(50.5-Coil_1.get_tot_wire_width()) +Coil_1.set_d_min(47.15) +Coil_1.print_info() -Wire_1 = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = wire_radius, wire_width = wire_radius, insulation_thickness= 0.068, is_round = True, winding_scheme= 2) -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}") -I = 64/Wire_1.get_N() *1.25 +print(Coil_1.get_coil_width() * 1e3 * Coil_1.get_coil_height() * 1e3) +print(f"H = {Coil_1.get_coil_height() * 1e3}, W = {Coil_1.get_coil_width() * 1e3}") + +I = 64 / Coil_1.get_N() * 1.25 print(f"I = {I} A") -Wire_1.cooling(I,22.5) +Coil_1.cooling(I, 22.5) -Wire_1.plot_raster(30) -Bz, Bx = Wire_1.B_field(I,x,z, raster = 10) +Coil_1.plot_raster(30) +Bz, Bx = Coil_1.B_field(I, x, z, raster = 1) Bz_curv = BC.BCoil.curv(Bz,z) zero = mu_it(0) print(z[zero]) diff --git a/Coil_geometry/15_new_HH_coil_iterative_winding_decision.py b/Coil_geometry/15_new_HH_coil_iterative_winding_decision.py new file mode 100644 index 0000000..9976f5d --- /dev/null +++ b/Coil_geometry/15_new_HH_coil_iterative_winding_decision.py @@ -0,0 +1,65 @@ +# -*- 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 + +scale = 1000 +lim = 1 +nr_points = (2 * lim) * scale + 1 +x = np.linspace(-lim,lim,nr_points) +z = np.linspace(-lim,lim,nr_points) + + +def mu_it(x_pos): + it = nr_points//2 + x_pos + return it + + +#Wire_1 = [0.45, 0.514] +#Wire_1 = [0.475, 0.543] +#Wire_1 = [0.5, 0.568] + +Wires = [[0.45, 0.514],[0.475, 0.543],[0.5, 0.568]] + +for i in range(0,2): + Wire_1 = Wires[i] + print(f"Wire core = {Wire_1[0]} mm:") + print(" ") + for ll in [8,10]: + for ww in [8,9]: + print(f"layers = {ll}, windings = {ww}") + Coil_1 = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = ll, windings = ww, wire_height = Wire_1[0], wire_width = Wire_1[0], insulation_thickness= (Wire_1[1] - Wire_1[0])/2, is_round = True, winding_scheme= 2) + + #set radius plus distance + Coil_1.set_R_outer(50.5-Coil_1.get_tot_wire_width()*1e3) + + Coil_1.set_d_min(47.15) + #Coil_1.print_info() + + + print(f" Coil crossection area = {Coil_1.get_coil_width() * 1e3 * Coil_1.get_coil_height() * 1e3} mm2") + print(f" H = {Coil_1.get_coil_height() * 1e3}, W = {Coil_1.get_coil_width() * 1e3}") + + I = 64 / Coil_1.get_N() * 1.25 + #I = 1 + print(f" Current needed for 13.8 G: I = {I} A") + Coil_1.cooling(I, 22.5) + + Bz, Bx = Coil_1.B_field(I, x, z, raster = 7) + Bz_curv = BC.BCoil.curv(Bz,z) + zero = mu_it(0) + + print(f" Curvature = {Bz_curv[zero]:.4f} G/mm^2, B(0) = {Bz[zero]:.4f}") + print(f"ratio Power/Curvature: {Coil_1.power(I,22.5) * Bz_curv[zero]}") + print(" ") + + + diff --git a/Coil_geometry_AHH/08_FINAL_AHH.py b/Coil_geometry_AHH/08_FINAL_AHH.py new file mode 100644 index 0000000..7760b0a --- /dev/null +++ b/Coil_geometry_AHH/08_FINAL_AHH.py @@ -0,0 +1,48 @@ +import matplotlib.pyplot as plt +import numpy as np +import matplotlib +#matplotlib.use('Qt5Agg') +from src import coil_class as BC + +scale = 1000 +lim = 1 +nr_points = (2 * lim) * scale + 1 +x = np.linspace(-lim,lim,nr_points) +z = np.linspace(-lim,lim,nr_points) + +def mu_it(x_pos): + it = nr_points//2 + x_pos + return it + + +Wires = [[0.45, 0.514],[0.475, 0.543],[0.5, 0.568]] + +Wire_1 = Wires[0] + +#I_current = 0.94 +HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 9, wire_height = Wire_1[0], + wire_width = Wire_1[0], insulation_thickness=(Wire_1[1] - Wire_1[0]) / 2, is_round = True, + winding_scheme= 2) + +I = 64 / HH_Coil.get_N() * 1.25 +# set radius plus distance +HH_Coil.set_R_outer(50.5 - HH_Coil.get_tot_wire_width()*1e3) +HH_Coil.set_d_min(47.15) + +HH_Coil.print_info() + +D_max = 2 * (HH_Coil.get_R_inner()*1e3 - 1) * np.tan(np.radians(41.11)) +print(D_max) + +AHH_Coil = BC.BCoil(HH = -1, distance = 54, radius = 48, layers = HH_Coil.get_layers, windings=2 * HH_Coil.get_windings, + wire_height = Wire_1[0], wire_width=Wire_1[0], insulation_thickness=(Wire_1[1] - Wire_1[0]) / 2, + is_round = True, winding_scheme= 2) + +AHH_Coil.set_R_inner(HH_Coil.get_R_inner() * 1e3) +AHH_Coil.set_d_max(D_max) + +AHH_Coil.print_info() + +#AHH_Coil.B_grad_quick_plot(I) +#Bz, Bx = AHH_Coil.B_field(I) +AHH_Coil.cooling(I, 22.5) \ No newline at end of file diff --git a/Cooling/04_Power estimation.py b/Cooling/04_Power estimation.py new file mode 100644 index 0000000..f51281b --- /dev/null +++ b/Cooling/04_Power estimation.py @@ -0,0 +1,19 @@ +import matplotlib.pyplot as plt +import numpy as np +import matplotlib +#matplotlib.use('Qt5Agg') +from src import coil_class as BC + + +Wire_1 = [0.5, 0.568] +I_current = 1.33 +HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 10, windings = 8, wire_height = Wire_1[0], wire_width = Wire_1[0], insulation_thickness=(Wire_1[1] - Wire_1[0]) / 2, is_round = True, winding_scheme= 2) + +#set radius plus distance +HH_Coil.set_R_outer(50.5 - HH_Coil.get_tot_wire_width()) +HH_Coil.set_d_min(47.15) + +I = 5 +I = 60/HH_Coil.get_N() * I +print(I) +HH_Coil.cooling(I, 25) \ No newline at end of file diff --git a/src/coil_class.py b/src/coil_class.py index 695864b..db6df5b 100644 --- a/src/coil_class.py +++ b/src/coil_class.py @@ -10,18 +10,21 @@ import logging as log from scipy import special as sp import matplotlib -#matplotlib.use('Qt5Agg') -#matplotlib.use('Agg') -#get_ipython().run_line_magic('matplotlib', 'qt') +# matplotlib.use('Qt5Agg') +# matplotlib.use('Agg') +# get_ipython().run_line_magic('matplotlib', 'qt') # get_ipython().run_line_magic('matplotlib', 'inline') import time from src import physical_constants as cs -#logger = log.getLogger('example') -#log.setLevel(log.info) -log.basicConfig(level = log.ERROR, format = '%(message)s') +# logger = log.getLogger('example') +# log.setLevel(log.info) +log.basicConfig(level=log.WARNING, format='%(message)s') + + # TODO: Docstrings for every function + # TODO: Implement conventions class BCoil: @@ -36,7 +39,7 @@ class BCoil: :param windings: number of axial (vertical) layers :param wire_width: width of conductive wire core :param wire_height: height of conductive wire core - :param insulation_thickness: thickness of wire insulation + :param insulation_thickness: thickness of wire insulation (radial increase of thickness not diameter!) :param is_round: True --> Round wire, False --> rectangular wire :param winding_scheme: 0: standard, layer on layer, 1: with offset (for round wires primarily), 2: like 1, but alternatingly 8 --> 7 windings per layer """ @@ -46,6 +49,7 @@ class BCoil: if is_round: if wire_width != wire_height: log.error('Wire is round but width != height') + raise ValueError("Wire is round but width != height") self.HH = HH self.distance = distance * 1e-3 @@ -57,6 +61,74 @@ class BCoil: self.insulation_thickness = insulation_thickness * 1e-3 self.is_round = is_round self.winding_scheme = winding_scheme +# Standard get/set functions + @property + def get_HH(self): + return self.HH + + @property + def get_distance(self): + return self.distance + + @property + def get_radius(self): + return self.radius + + @property + def get_layers(self): + return self.layers + + @property + def get_windings(self): + return self.windings + + @property + def get_wire_width(self): + return wire_width + + @property + def get_wire_height(self): + return self.wire_height + + @property + def get_insulation_thickness(self): + return self.insulation_thickness + + @property + def get_is_round(self): + return self.is_round + + @property + def get_winding_scheme(self): + return self.winding_scheme + + def get_zmin(self): + return self.distance / 2 - self.get_coil_height() / 2 + + def get_zmax(self): + return self.distance / 2 + self.get_coil_height() / 2 + + def get_R_inner(self): + return self.radius - self.get_coil_width() / 2 + + def get_R_outer(self): + return self.radius + self.get_coil_width() / 2 + + def set_R_outer(self, R_outer): + R_outer *= 1e-3 + self.radius = R_outer - self.get_coil_width() / 2 + + def set_R_inner(self, R_inner): + R_inner *= 1e-3 + self.radius = R_inner + self.get_coil_width() / 2 + + def set_d_min(self, d_min): + d_min *= 1e-3 + self.distance = d_min + self.get_coil_height() + + def set_d_max(self, d_max): + d_max *= 1e-3 + self.distance = d_max - self.get_coil_height() def get_wire_area(self): """ @@ -72,9 +144,10 @@ class BCoil: Calculates number of windings """ N = self.layers * self.windings - + log.debug(f"N = {N}") if self.winding_scheme == 2: - N -= self.windings//2 + N -= self.layers // 2 + log.debug(f"N = {N}") return N def get_wire_length(self): @@ -102,39 +175,10 @@ class BCoil: log.info("Coil width: Be aware of the fact that this is an idealized situation of coil winding (slope " "of windings changes each layer)") return self.layers * self.get_tot_wire_width() - (self.layers - 1) * ( - 2 - np.sqrt(3)) * self.get_tot_wire_width() / 2 # width is reduced due to winding offset + 2 - np.sqrt(3)) * self.get_tot_wire_width() / 2 # width is reduced due to winding offset return self.get_tot_wire_width() * self.layers - def get_zmin(self): - return self.distance / 2 - self.get_coil_height() / 2 - def get_zmax(self): - return self.distance / 2 + self.get_coil_height() / 2 - - def get_radius(self): - return self.radius - - def get_R_inner(self): - return self.radius - self.get_coil_width() / 2 - - def get_R_outer(self): - return self.radius + self.get_coil_width() / 2 - - def set_R_outer(self, R_outer): - R_outer *= 1e-3 - self.radius = R_outer - self.get_coil_width() / 2 - - def set_R_inner(self, R_inner): - R_inner *= 1e-3 - self.radius = R_inner + self.get_coil_width() / 2 - - def set_d_min(self, d_min): - d_min *= 1e-3 - self.distance = d_min + self.get_coil_height() - - def set_d_max(self, d_max): - d_max *= 1e-3 - self.distance = d_max - self.get_coil_height() def winding_raster(self): """ @@ -146,11 +190,11 @@ class BCoil: it = 0 z_start = self.get_zmin() + self.get_tot_wire_height() / 2 # (distance_coils/2 - windings * wire_height/2 + wire_height/2)*1e-3 R_start = self.get_R_inner() + self.get_tot_wire_width() / 2 # (R_inner + wire_width/2 ) - + log.debug(f"N = {self.get_N()}") for xx in range(0, self.layers): for zz in range(0, self.windings): - if self.winding_scheme == 2 and xx % 2 == 1 and zz == self.windings-1: - continue # leave out every last winding in every second layer + if self.winding_scheme == 2 and xx % 2 == 1 and zz == self.windings - 1: + continue # leave out every last winding in every second layer z_pos = z_start + zz * self.get_tot_wire_height() R_pos = R_start + xx * self.get_tot_wire_width() @@ -160,8 +204,9 @@ class BCoil: z_pos += self.get_tot_wire_height() / 2 if self.is_round: R_pos -= xx * ((2 - np.sqrt(3)) * self.get_tot_wire_width() / 2) + log.debug(f"lay = {xx}, wind = {zz}") outer_raster[it] = [z_pos, R_pos] - #print(outer_raster[it]) + # print(outer_raster[it]) it += 1 return outer_raster @@ -179,11 +224,12 @@ class BCoil: log.info("raster value is 0 increased to 1") if raster_value == 1: - return [0,0] + return [0, 0] if self.is_round & (raster_value % 2 == 0): raster_value += 1 - log.info(f"for round wire rastering works better with uneven rastering value --> rastering value set to: {raster_value}") + log.info( + f"for round wire rastering works better with uneven rastering value --> rastering value set to: {raster_value}") inner_raster = np.zeros((raster_value ** 2, 2)) it = 0 @@ -225,7 +271,7 @@ class BCoil: return full_ras - def plot_raster(self, raster_value = 100): + def plot_raster(self, raster_value=100): full_structure = self.full_raster(raster_value) * 1e3 if self.get_coil_width() > self.get_coil_height(): extension = self.get_coil_width() @@ -237,13 +283,12 @@ class BCoil: plt.scatter(full_structure[:, :, 1], full_structure[:, :, 0], linewidths=0.001) plt.xlabel("radius [mm]") plt.ylabel("z position [mm]") - plt.axvline(x=self.get_R_inner()*1e3-0.1, lw = 5,color = "red") + plt.axvline(x=self.get_R_inner() * 1e3 - 0.1, lw=5, color="red") plt.xlim(1e3 * self.get_R_inner() - 0.5, 1e3 * self.get_R_inner() + extension + 0.5) plt.ylim(1e3 * self.get_zmin() - 0.5, 1e3 * self.get_zmin() + extension + 0.5) plt.show() - def print_info(self): print(" ") # print(f"{self.get_zmin()}") @@ -426,7 +471,7 @@ class BCoil: I_current /= rastering_value # divide current into smaller currents for mapping the whole wire # start = time.time() - for el in range(0,len(x_SI)): + for el in range(0, len(x_SI)): for wire in range(0, self.get_N()): for ii in range(0, rastering_value): # extract position information out of raster @@ -486,7 +531,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 = 200): + 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: @@ -496,15 +541,14 @@ class BCoil: 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.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 B_grad_quick_plot(self, I_current, x_lim = 50, z_lim = 50, nr_points = 200): + 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) @@ -514,10 +558,10 @@ class BCoil: 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.plot(z, B_z, linestyle="solid", label=r"z grad of B_z along z-axis") + plt.plot(x, B_x, label=r"x Grad of B_x along x-axis") plt.title("Gradient of B-field") - plt.ylabel(r"B-field [G]") + plt.ylabel(r"B-field [G/cm]") plt.xlabel("x-axis / z-axis [mm]") plt.legend() plt.show() @@ -539,7 +583,6 @@ class BCoil: 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) @@ -576,6 +619,7 @@ class BCoil: plt.show() + def cooling(self, I_current, T): """ Print current density and power @@ -593,10 +637,10 @@ class BCoil: j_dens = I_current / self.get_wire_area() * 1e-6 - Power = self.resistance(T) * I_current ** 2 + Power = self.power(I_current, T) - print(f"current density = {j_dens} A/mm^2") - print(f"Power = {Power} W") + print(f" current density = {j_dens} A/mm^2") + print(f" Power = {Power} W") def power(self, I_current, T): P = self.resistance(T) * I_current ** 2 @@ -641,39 +685,10 @@ class BCoil: def main(): - HH_Coil = BCoil(HH=-1, distance=50, radius=40, layers=7, windings=7, wire_height=0.5, wire_width=0.5, - insulation_thickness=0.1, is_round = True, winding_scheme=2) - #HH_Coil.get_coil_width() - #ras = HH_Coil.full_raster(raster_value = 3) - # print(HH_Coil.is_round) - #print(HH_Coil.winding_raster()) + Coil_1 = BCoil(HH = 1, distance = 54, radius = 48, layers = 7, windings = 8, wire_height = 0.6, wire_width = 0.5, insulation_thickness= 0.05, is_round = True, winding_scheme= 2) + Coil_1.plot_raster() - - HH_Coil.plot_raster(30) - print(HH_Coil.get_N()) - # - # 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) - # if True & 1 == 1: - # print("test") - #print(ras) - # x = np.linspace(-50, 50, 300) - # z = np.linspace(-50, 50, 300) - # Bz, Bx = HH_Coil.B_tot_along_axis(1.25, x, z) - # # Bz, Bx = HH_Coil.B_tot_along_axis(1.25, x, z) - # # #print(Bx) - # # #print(Bz) - # plt.plot(x,Bx,label = "Bx") - # plt.plot(z,Bz, label = "Bz") - # plt.legend() - # plt.show() - # - # HH_Coil.plot_raster(3) - # ras = HH_Coil.full_raster(10) - #HH_Coil.plot_3d(1.25,50,50) - -#main() +# main() if __name__ == "__main__": log.info("Run main Coil class") main() diff --git a/untitled0.py b/untitled0.py index c5c5c29..ab818c5 100644 --- a/untitled0.py +++ b/untitled0.py @@ -33,4 +33,4 @@ print(30/400) print(4.3*4.8/(60*(0.475/2)**2 *np.pi)) -print(1/1.94) \ No newline at end of file +print(np.sin(np.radians(90))) \ No newline at end of file