HH configuration added

This commit is contained in:
schoener 2021-10-26 14:33:07 +02:00
parent 21bba55091
commit a03c601995
5 changed files with 70 additions and 23 deletions

View File

@ -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)

View File

@ -9,6 +9,9 @@ import matplotlib.pyplot as plt
import logging as log import logging as log
from scipy import special as sp from scipy import special as sp
import matplotlib
matplotlib.use('Qt5Agg')
import time import time
from src import physical_constants as cs from src import physical_constants as cs
@ -218,6 +221,7 @@ class BCoil:
else: else:
extension = self.get_coil_height() extension = self.get_coil_height()
extension *= 1e3 extension *= 1e3
plt.figure(77, figsize=(5, 5)) plt.figure(77, figsize=(5, 5))
plt.scatter(full_structure[:, :, 1], full_structure[:, :, 0], linewidths=0.001) plt.scatter(full_structure[:, :, 1], full_structure[:, :, 0], linewidths=0.001)
plt.xlabel("radius [mm]") 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.ylim(1e3 * self.get_zmin() - 0.5, 1e3 * self.get_zmin() + extension + 0.5)
plt.show() plt.show()
plt.close(77)
def print_info(self): def print_info(self):
print(" ") print(" ")
@ -295,13 +299,14 @@ class BCoil:
z_SI = z * 1e-3 z_SI = z * 1e-3
if x[0] <= 0: # divide array into positive and negative values 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_negative = 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_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]) x_zero = np.array([el for el in x_SI if el == 0])
B_z = np.zeros(len(z)) 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 B_x_zero = x_zero # 0 in x-array --> field is zero at this position
calc_raster = self.full_raster(raster) 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, 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) 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( 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_pos, 0) 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_neg, 0) + BCoil.B_r_loop( 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_neg, 0) 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_neg *= -1 # B_x_neg is pointing in opposite x_direction
B_x = np.concatenate((B_x_neg, B_x_zero, B_x_pos)) B_x = np.concatenate((B_x_neg, B_x_zero, B_x_pos))
@ -467,7 +472,7 @@ class BCoil:
def grad(B_f, z): def grad(B_f, z):
return np.gradient(B_f, z) * 1e1 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) x = np.linspace(-x_lim, x_lim, nr_points)
z = np.linspace(-z_lim, z_lim, nr_points) z = np.linspace(-z_lim, z_lim, nr_points)
if abs: if abs:
@ -475,6 +480,7 @@ class BCoil:
else: else:
B_z, B_x = self.B_field(I_current, x, z) 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(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.title("B-field")
@ -483,7 +489,8 @@ class BCoil:
plt.legend() plt.legend()
plt.show() 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) x = np.linspace(-x_lim, x_lim, nr_points)
z = np.linspace(-z_lim, z_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_z = BCoil.grad(B_z, z)
B_x = BCoil.grad(B_x, x) 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(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("Gradient of B-field") plt.title("Gradient of B-field")
@ -500,7 +508,7 @@ class BCoil:
plt.legend() plt.legend()
plt.show() 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) x = np.linspace(-x_lim, x_lim, nr_points)
z = np.linspace(-z_lim, z_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_z = BCoil.curv(B_z, z)
B_x = BCoil.curv(B_x, x) 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(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.title("Curvature of B-field")
plt.ylabel(r"B-field [G]") plt.ylabel(r"Curv. B-field [G/cm$^2$]")
plt.xlabel("x-axis / z-axis [mm]") plt.xlabel("x-axis / z-axis [mm]")
plt.legend() plt.legend()
plt.show() plt.show()
def Bz_plot_HH_comp(self, Coil2, I_current, x, z): def Bz_plot_HH_comp(self, Coil2, I_current, x, z):
B_z, B_x = self.B_field(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) B_z_2, B_x_2 = Coil2.B_field(I_current, x, z)
@ -617,15 +627,15 @@ class BCoil:
def main(): 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) insulation_thickness=0.2, is_round = True, winding_offset=True)
#ras = HH_Coil.full_raster(raster_value = 3) #ras = HH_Coil.full_raster(raster_value = 3)
# print(HH_Coil.is_round) # 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_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: # if True & 1 == 1:
# print("test") # print("test")
#print(ras) #print(ras)
@ -644,7 +654,7 @@ def main():
# ras = HH_Coil.full_raster(10) # ras = HH_Coil.full_raster(10)
#HH_Coil.plot_3d(1.25,50,50) #HH_Coil.plot_3d(1.25,50,50)
main() #main()
# if __name__ == "__main__": if __name__ == "__main__":
# print("g") print("g")
# main() main()

View File

@ -6,4 +6,6 @@ Created on Fri Oct 1 10:42:13 2021
""" """
import numpy as np import numpy as np
print(np.zeros((5,2))) print(np.sqrt(0.2))
print(0.56*8+ 0.1*4.48)