Add calculations for intermediate pair of coils

This commit is contained in:
schoener 2022-02-07 20:31:11 +01:00
parent e8169286b9
commit 894c27ee12
12 changed files with 199 additions and 34 deletions

View File

@ -0,0 +1,35 @@
"""
Created on 11.11.21
@author: Joschka
"""
import numpy as np
import matplotlib.pyplot as plt
from src import coil_class as BC
from src import physical_constants as cs
import logging as log
log.basicConfig(level=log.DEBUG, format='%(message)s')
def main():
AHH_Coil = BC.BCoil(HH=-1, distance=69.313, radius=47, layers=8, windings=16,
wire_height=0.5, wire_width=0.5, insulation_thickness=0.068/2,
is_round=True, winding_scheme=2)
# for I_current in np.arange(0.38,1,0.0001):
# print(I_current)
# Bx = AHH_Coil.max_gradient(I_current)
# if np.abs(Bx) >= 1:
# print(I_current)
# break
I = 0.3804
AHH_Coil.max_gradient(0.9 * I)
AHH_Coil.max_gradient(I)
AHH_Coil.max_gradient(1.1 * I)
AHH_Coil.max_gradient(1.2 * I)
if __name__ == '__main__':
main()

View File

@ -28,7 +28,7 @@ def main():
# - BC.BCoil._BCoil__B_z_loop(I_current=I, r_loop=1, z_loop=-1, r_pos=0, z_pos=-0.1))
step = 0.3
step = 5
xlim_mm = 30
xlim = int(xlim_mm/step) + 1
ylim_mm = 30
@ -36,39 +36,37 @@ def main():
zlim_mm = 20
zlim = int(zlim_mm/step) + 1
B_quarter = np.zeros((xlim, ylim, zlim, 2),dtype= np.float32)
print(np.shape(B_quarter))
B_quarter = np.zeros((xlim, ylim, zlim, 2))
#print(B_quarter)
x = np.linspace(0,xlim_mm,xlim) * 1e-3
y = np.linspace(0,ylim_mm,ylim) * 1e-3
z = np.linspace(0,zlim_mm,zlim) * 1e-3
calc_raster = AHH_Coil.full_raster(1)
rastering_value = len(calc_raster[0])
I_current /= rastering_value
start = time.time()
for wire in range(0,AHH_Coil.get_N()):
print(f"time = {(time.time()-start)/60} min")
print(f"wire = {wire} of {AHH_Coil.get_N()}")
for ii in range(0,rastering_value):
# extract position information out of raster
z_pos = calc_raster[wire, ii, 0]
r_pos = calc_raster[wire, ii, 1]
for xx in range(0,xlim):
for yy in range(0,ylim):
# extract position information out of raster
z_pos = calc_raster[wire, 0, 0]
r_pos = calc_raster[wire, 0, 1]
for xx in range(0, xlim):
for yy in range(0, ylim):
r = np.sqrt(x[xx]**2 + y[yy]**2)
r = np.sqrt(x[xx]**2 + y[yy]**2)
# calculate z-component at x,y
B_quarter[xx, yy, :, 1] += BC.BCoil._BCoil__B_z_loop(I_current, r_pos, z_pos, r, z) \
+ BC.BCoil._BCoil__B_z_loop(AHH_Coil.HH * I_current, r_pos, -z_pos, r, z)
# calculate z-component at x,y
B_quarter[xx, yy, :, 1] += BC.BCoil._BCoil__B_z_loop(I_current, r_pos, z_pos, r, z) \
+ BC.BCoil._BCoil__B_z_loop(AHH_Coil.HH * I_current, r_pos, -z_pos, r, z)
if r == 0:
continue
# calculate r-component at x, y
B_quarter[xx, yy, :, 0] += BC.BCoil._BCoil__B_r_loop(I_current, r_pos, z_pos, r, z) \
+ BC.BCoil._BCoil__B_r_loop(AHH_Coil.HH * I_current, r_pos, -z_pos, r, z)
if r == 0:
continue
# calculate r-component at x, y
B_quarter[xx, yy, :, 0] += BC.BCoil._BCoil__B_r_loop(I_current, r_pos, z_pos, r, z) \
+ BC.BCoil._BCoil__B_r_loop(AHH_Coil.HH * I_current, r_pos, -z_pos, r, z)
np.save('output/final/B_quarter_step_300_1Gcm.npy', B_quarter)
np.save('output/B_quarter_step_5.npy', B_quarter)
#B_tot = np.zeros(((2 * xlim) - 1, (2 * ylim) - 1, (2 * zlim)-1, 2))

View File

@ -13,7 +13,7 @@ import logging as log
def main():
step = 0.3
step = 5
xlim_mm = 30
xlim = int(xlim_mm / step) + 1
print(xlim)
@ -48,10 +48,28 @@ def main():
b_cart_1[xx, yy, :, 0] = b_qu_polar[xx, yy, :, 0] * np.cos(phi)
b_cart_1[xx, yy, :, 1] = b_qu_polar[xx, yy, :, 0] * np.sin(phi)
np.save('output/final/b_cart_step_300_1Gcm.npy', b_cart_1)
del b_qu_polar
del b_cart_1
np.save('output/b_cart_1_step_5.npy', b_cart_1)
full_shape = (new_shape[0]*2 - 1, new_shape[1] * 2 - 1, new_shape[2] * 2 - 1, new_shape[3])
b_full = np.zeros(full_shape)
# fill first quarter
b_full[xlim-1:, ylim-1:, zlim-1:, :] = b_cart_1
print(xlim-1)
# mirror along y - z plane
b_full[:xlim-1, ylim-1:, zlim-1:, :] = b_cart_1[:0:-1, :, :, :]
b_full[:xlim-1, :, :, 0] *= - 1
# mirror along x - z plane
b_full[:, :ylim-1, zlim - 1:, :] = b_full[:, :ylim-1:-1 , zlim-1:, :]
b_full[:, :ylim-1, :, 1] *= -1
# mirror along x - y plane
b_full[:, :, :zlim-1, :] = b_full[:, :, :zlim-1 : -1, :]
b_full[:, :, :zlim-1, 2] *= -1
np.save('output/b_full_test.npy', b_full)
if __name__ == '__main__':
main()

View File

Binary file not shown.

View File

@ -0,0 +1,2 @@
[60.38439885 47.83581121 40.63613729 36.88246491 35.71293376 36.88246491
40.63613729 47.83581121 60.38439885]

View File

@ -0,0 +1,53 @@
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
#matplotlib.use('Qt5Agg')
from src import coil_class as BC
scale = 10
lim = 20
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 = [0.5, 0.546]
scale = 10
#I_current = 0.94
HH_Coil = BC.BCoil(HH = 1, distance = 80, radius = 80, 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)
HH_Coil.set_R_inner(83.3)
HH_Coil.set_d_min(70.6 + 4)
print(HH_Coil.get_wire_length())
HH_Coil.print_info()
I = 0.67
# HH_Coil.B_quick_plot(I,nr_points=scale)
# HH_Coil.B_curv_quick_plot(I,nr_points = scale)
HH_Coil.cooling(I,23)
AHH_Coil = BC.BCoil(HH = -1, distance = 80, radius = 80, layers = 10, windings = 16, 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(AHH_Coil.get_wire_length())
print(HH_Coil.get_R_inner()*1e3)
AHH_Coil.set_R_inner(HH_Coil.get_R_inner()*1e3)
AHH_Coil.set_d_min(HH_Coil.get_zmax()*2 * 1e3 + 4)
AHH_Coil.print_info()
I = 2
AHH_Coil.B_quick_plot(I)
AHH_Coil.B_grad_quick_plot(I, nr_points = 200)
#AHH_Coil.B_curv_quick_plot(I, nr_points = scale)
AHH_Coil.cooling(I,23)

View File

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 27 15:14:48 2021
@author: Joschka
"""
from src import physical_constants as cs
import numpy as np
ge = 1.29
gg = 1.24
Me = 9
Mg = 8
mu_eff = (ge*Me- gg*Mg) * cs.mu_B
detuning = 2 * np.pi * 2.4e6 #Hz
dG = 2.26e-4 #T/cm
z = 1
D_loc = detuning - mu_eff/cs.h_bar * dG * z
print(f"D_loc @ D = 2 pi * 2 MHz = {D_loc/(2*np.pi*1e6)} ")
detuning = 2 * np.pi * 2e6 #Hz
#G/cm
z = 0.75
D_loc = detuning - mu_eff/cs.h_bar * dG * z
print(f"D_loc @ D = 2 pi * 2 MHz = {D_loc/(2*np.pi*1e6)} ")
detuning = 2 * np.pi * 1e6 #Hz
#G/cm
z = 0.5
D_loc = detuning - mu_eff/cs.h_bar * dG * z
print(f"D_loc @ D = 2 pi * 2 MHz = {D_loc/(2*np.pi*1e6)} ")
dE = mu_eff/cs.h_bar * dG * 0.5
print(dE/(2*np.pi*1e6))

View File

@ -335,11 +335,13 @@ class BCoil:
"""
nr_points = (2 * lim) * precision + 1
nr_points = int(nr_points)
z = np.linspace(-lim, lim, nr_points)
if two_axis:
x = np.linspace(-lim, lim, nr_points)
return x, z
return x, z
return z
@staticmethod
def mm_it(x, x_pos):
@ -473,6 +475,17 @@ class BCoil:
-z_pos, 0, 0)
return B_z_0
def max_gradient(self, i_current, raster = 7):
x, z = BCoil.make_axis(0.5, 1000)
Bz, Bx = self.B_field(i_current, x, z, raster = raster)
bz_grad = BCoil.grad(Bz, z)
bx_grad = BCoil.grad(Bx, x)
print(f"Max z Gradient = {bz_grad[len(z)//2]} G/cm")
print(f"Max x Gradient = {bx_grad[len(x)//2]} G/cm")
#return bx_grad[len(x)//2]
def B_tot_along_axis(self, I_current, x, z, raster=10):
"""
@ -703,7 +716,7 @@ class BCoil:
def cooling(self, I_current, T):
"""
Print current density and power
Print current density and power for one coil
Parameters
----------
@ -729,6 +742,9 @@ class BCoil:
print(f" U = {Voltage} V")
def power(self, I_current, T):
"""
Power for one coil
"""
P = self.resistance(T) * I_current ** 2
return P

View File

@ -9,12 +9,9 @@ import matplotlib.pyplot as plt
def main():
r = 45.92e-3
d = 2*r
d_w = 0.569e-3
a = 51.52 * d**(-0.41) + 11.31 * d**(-0.33) * np.log(d_w)
print(a)
print(8.96 * 5)
x = np.linspace(-10, 10, 21)
print(x)
print(x[:0:-1])