From 19f8d1968c873166b9619c707dfc7b8c1f38426b Mon Sep 17 00:00:00 2001 From: schoener Date: Fri, 8 Oct 2021 11:18:12 +0200 Subject: [PATCH] Added outer raster function --- src/coil_class.py | 61 +++++++++++++++++++++++++++++++---------------- untitled0.py | 3 ++- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/coil_class.py b/src/coil_class.py index b6c3635..e773ea5 100644 --- a/src/coil_class.py +++ b/src/coil_class.py @@ -11,12 +11,13 @@ from scipy import special as sp from src import physical_constants as cs -#TODO: Docstrings for every function -#TODO: Implement conventions + +# TODO: Docstrings for every function +# TODO: Implement conventions class BCoil: - def __init__(self, HH, distance, radius, layers, windings, wire_width, wire_height, insulation_thickness=0 - , is_round = False, winding_offset = False): + def __init__(self, HH, distance, radius, layers, windings, wire_width, wire_height, insulation_thickness=0. + , is_round=False, winding_offset=False): """ Creates object that represents a configuration of two coils, with symmetry axis = z :param HH: HH = 1 --> current in same direction, homogeneous field, HH = -1 --> current in opposite direction, quadrupole field @@ -54,13 +55,12 @@ class BCoil: :return: float """ if self.is_round: - return np.pi * (self.wire_width/2)**2 + return np.pi * (self.wire_width / 2) ** 2 return self.wire_width * self.wire_height def get_N(self): """ Calculates number of windings - :return: int """ return self.layers * self.windings @@ -73,11 +73,11 @@ class BCoil: def get_tot_wire_height(self): """ returns wire height incl. insulation""" return self.wire_height + 2 * self.insulation_thickness + def get_tot_wire_width(self): """ returns wire width incl. insulation""" return self.wire_width + 2 * self.insulation_thickness - def get_coil_height(self): if self.winding_offset: return self.get_tot_wire_height() * (self.windings + 0.5) @@ -86,9 +86,9 @@ class BCoil: def get_coil_width(self): if self.winding_offset: if self.is_round: - return self.layers * self.get_tot_wire_width() - - #Todo : continue - return self.get_tot_wire_height() * self.windings + log.info("Be aware of the fact that this is a highly idealized situation of coil winding (slope of windings change 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 + return self.get_tot_wire_width() * self.layers def get_zmin(self): return self.distance / 2 - self.get_coil_height() / 2 @@ -121,12 +121,33 @@ class BCoil: d_max *= 1e-3 self.distance = d_max - self.get_coil_height() - def raster(self,raster_value): + def winding_raster(self): """ generates raster of flowing currents :param raster_value: wire height/raster_value is distance between rastered points in one wire - :return: 2 dim array with z values in colums and R_values in rows + :return: 2 dim array [[z1,R1], [z2,R2], ...] """ + outer_raster = np.zeros((self.get_N(),2)) + 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 ) + + for xx in range(0, self.layers): + for zz in range(0, self.windings): + z_pos = z_start + zz * self.get_tot_wire_height() + R_pos = R_start + xx * self.get_tot_wire_width() + + #correct for different winding techniques and round wire + if self.winding_offset: + if xx % 2 == 1: + 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) + + outer_raster[it] = [z_pos, R_pos] + it += 1 + return outer_raster + def print_info(self): print(" ") @@ -219,7 +240,7 @@ class BCoil: R_pos = R_start + xx * ( self.wire_width + self.layers_spacing) - self.wire_width / 2 + xx_in * self.wire_width / ( raster - 1) - #TODO: fix z_pos, R_pos, either by raster or by spacing + # TODO: fix z_pos, R_pos, either by raster or by spacing 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) @@ -503,11 +524,11 @@ class BCoil: return cf.resistivity_copper(T) * self.get_wire_length() / self.get_wire_area() -HH_Coil = BCoil(HH=1, distance=54, radius=48, layers=8, windings=8, wire_height=0.4,wire_width=0.4, insulation_thickness = 0.1 ,is_round= False, winding_offset= True) -HH_Coil.set_R_outer(49.3) -HH_Coil.set_d_min(49.8) +HH_Coil = BCoil(HH=1, distance=10, radius=10, layers=2, windings=2, wire_height=1, wire_width=1, + insulation_thickness=0.25, is_round=True, winding_offset= True) + + +print(HH_Coil.winding_raster()) + + -HH_Coil.print_info() -print(HH_Coil.get_wire_area()*1e6) -print(HH_Coil.get_wire_length()) -print(HH_Coil.get_coil_height()) diff --git a/untitled0.py b/untitled0.py index 5165424..2df3ef2 100644 --- a/untitled0.py +++ b/untitled0.py @@ -4,5 +4,6 @@ Created on Fri Oct 1 10:42:13 2021 @author: Joschka """ +import numpy as np -for t \ No newline at end of file +print(np.zeros((5,2))) \ No newline at end of file