Incomplete class modifications for round wire --> Must be continued
This commit is contained in:
parent
d110a85f37
commit
b40cc80a1f
@ -10,15 +10,33 @@ import logging as log
|
||||
from scipy import special as sp
|
||||
|
||||
from src import physical_constants as cs
|
||||
from src import coil_class_add_functions as cf
|
||||
|
||||
#TODO: Docstrings for every function
|
||||
#TODO: Implement conventions
|
||||
|
||||
class BCoil:
|
||||
def __init__(self, HH, distance, radius, layers, windings, wire_width, wire_height, layers_spacing=0,
|
||||
windings_spacing=0, is_round = 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
|
||||
:param distance: distance between center of coils
|
||||
:param radius: radius to center of coil
|
||||
:param layers: number of radial (horizontal) layers
|
||||
: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 is_round: True --> Round wire, False --> rectangular wire
|
||||
:param winding_offset: layer offset by half winding (especially for round wires)
|
||||
"""
|
||||
if not is_round:
|
||||
if winding_offset:
|
||||
log.warning('Is there a reason you want to wind a not round wire like that?')
|
||||
if is_round:
|
||||
if wire_width != wire_height:
|
||||
log.error('Wire is round but width != height')
|
||||
|
||||
self.HH = HH
|
||||
self.distance = distance * 1e-3
|
||||
self.radius = radius * 1e-3
|
||||
@ -26,26 +44,51 @@ class BCoil:
|
||||
self.windings = windings
|
||||
self.wire_width = wire_width * 1e-3
|
||||
self.wire_height = wire_height * 1e-3
|
||||
self.layers_spacing = layers_spacing * 1e-3
|
||||
self.windings_spacing = windings_spacing * 1e-3
|
||||
self.insulation_thickness = insulation_thickness * 1e-3
|
||||
self.is_round = is_round
|
||||
self.winding_offset = winding_offset
|
||||
|
||||
def get_wire_area(self):
|
||||
"""
|
||||
calculates wire area in m^2
|
||||
:return: float
|
||||
"""
|
||||
if self.is_round:
|
||||
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
|
||||
|
||||
def get_wire_length(self):
|
||||
"""
|
||||
:return: Approximate length of wire per coil (m)
|
||||
"""
|
||||
return self.get_N() * 2 * self.radius * np.pi
|
||||
|
||||
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):
|
||||
return self.windings * self.wire_height + (self.windings - 1) * self.windings_spacing
|
||||
if self.winding_offset:
|
||||
return self.get_tot_wire_height() * (self.windings + 0.5)
|
||||
return self.get_tot_wire_height() * self.windings
|
||||
|
||||
def get_coil_width(self):
|
||||
return self.layers * self.wire_width + (self.layers - 1) * self.layers_spacing
|
||||
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
|
||||
|
||||
def get_zmin(self):
|
||||
return self.distance / 2 - self.get_coil_height() / 2
|
||||
@ -78,6 +121,13 @@ class BCoil:
|
||||
d_max *= 1e-3
|
||||
self.distance = d_max - self.get_coil_height()
|
||||
|
||||
def raster(self,raster_value):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
def print_info(self):
|
||||
print(" ")
|
||||
# print(f"{self.get_zmin()}")
|
||||
@ -87,12 +137,12 @@ class BCoil:
|
||||
print(
|
||||
f"Radius = {self.radius * 1e3} mm, Radius_inner = {self.get_R_inner() * 1e3} mm, Radius_outer = {self.get_R_outer() * 1e3:.2f} mm")
|
||||
print(
|
||||
f"layers = {self.layers}, windings = {self.windings}, wire_width = {self.wire_width * 1e3}, wire_height = {self.wire_height * 1e3} mm ")
|
||||
f"layers = {self.layers}, windings = {self.windings}, wire_width = {self.wire_width * 1e3}, wire_height = {self.wire_height * 1e3} mm, round wire = {self.is_round} ")
|
||||
print(" ")
|
||||
|
||||
def print_basic_info(self):
|
||||
print(
|
||||
f"HH = {self.HH}, Distance = {self.distance * 1e3} mm, Radius = {self.radius * 1e3} mm,layers = {self.layers}, windings = {self.windings}")
|
||||
f"HH = {self.HH}, Distance = {self.distance * 1e3} mm, Radius = {self.radius * 1e3} mm,layers = {self.layers}, windings = {self.windings}, round wire = {self.is_round}")
|
||||
|
||||
def B_field_ideal_z(self, I_current, z_arg):
|
||||
"""
|
||||
@ -109,10 +159,12 @@ class BCoil:
|
||||
B *= 1e4 # conversion Gauss
|
||||
return B
|
||||
|
||||
@staticmethod
|
||||
def k_sq(R_loop, z_loc, r, z):
|
||||
""" Argument for elliptic integrals"""
|
||||
return (4 * R_loop * r) / ((R_loop + r) ** 2 + (z - z_loc) ** 2)
|
||||
|
||||
@staticmethod
|
||||
def B_z_loop(I_current, R_loop, z_loc, r, z):
|
||||
"""calculate z-component of B-field at position r and z for each individual loop"""
|
||||
B_z = 2e-7 * I_current * 1 / ((R_loop + r) ** 2 + (z - z_loc) ** 2) ** (1 / 2) * (
|
||||
@ -121,6 +173,7 @@ class BCoil:
|
||||
B_z *= 1e4 # conversion to gauss
|
||||
return B_z
|
||||
|
||||
@staticmethod
|
||||
def B_r_loop(I_current, R_loop, z_loc, r, z):
|
||||
"""calculate r-component of B-field at position r and z for each individual loop"""
|
||||
B_r = 2e-7 * I_current / r * (z - z_loc) / ((R_loop + r) ** 2 + (z - z_loc) ** 2) ** (1 / 2) * (
|
||||
@ -166,6 +219,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
|
||||
|
||||
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)
|
||||
@ -218,6 +272,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
|
||||
|
||||
# z-field along z-axis (x-Field always zero)
|
||||
B_tot_z += BCoil.B_z_loop(I_current, R_pos, z_pos, 0, z_SI) + BCoil.B_z_loop(
|
||||
@ -264,6 +319,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
|
||||
|
||||
# compute z-value of field
|
||||
B[:, el, 1] += BCoil.B_z_loop(I_current, R_pos, z_pos, np.abs(x_SI[el]),
|
||||
@ -421,9 +477,17 @@ class BCoil:
|
||||
0.2317 * 100 * self.radius + 0.44 * 100 * self.get_coil_height() + 0.39 * 100 * self.get_coil_width())
|
||||
return L * 1e-9
|
||||
|
||||
@staticmethod
|
||||
def resistivity_copper(T):
|
||||
R_ref = cs.rho_copper_20
|
||||
T_ref = 20 # degree celsius
|
||||
alpha = 0.00393
|
||||
R = R_ref * (1 + alpha * (T - T_ref))
|
||||
return R
|
||||
|
||||
def resistance(self, T):
|
||||
"""
|
||||
Calculates resistance of coil configuration in series
|
||||
Calculates resistance of one coil of configuration
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -436,14 +500,14 @@ class BCoil:
|
||||
resistance in Ohm
|
||||
|
||||
"""
|
||||
return 2 * cf.resistivity_copper(T) * self.get_wire_length() / self.get_wire_area()
|
||||
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, windings_spacing=0.2,
|
||||
layers_spacing=0.2,is_round= False)
|
||||
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.print_info()
|
||||
print(HH_Coil.get_wire_area()*1e6)
|
||||
print(HH_Coil.get_wire_length())
|
||||
print(HH_Coil.get_coil_height())
|
||||
|
@ -8,11 +8,6 @@ import numpy as np
|
||||
|
||||
from src import physical_constants as cs
|
||||
|
||||
def resistivity_copper(T):
|
||||
R_ref = cs.rho_copper_20
|
||||
T_ref = 20 #degree celsius
|
||||
alpha = 0.00393
|
||||
R = R_ref *(1 + alpha * (T-T_ref))
|
||||
return R
|
||||
|
||||
|
||||
print(resistivity_copper(30))
|
Loading…
Reference in New Issue
Block a user