Export gradient field
This commit is contained in:
parent
c33908d833
commit
620e61e025
@ -26,12 +26,12 @@ HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8,
|
||||
|
||||
|
||||
print(f"HH N = {HH_Coil.get_N()}")
|
||||
I = 64 / HH_Coil.get_N() * 1.25
|
||||
I = 1.33 # 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"current density = {60*I/(HH_Coil.get_coil_width() * HH_Coil.get_coil_height() * 1e6)}")
|
||||
HH_Coil.B_quick_plot(I)
|
||||
HH_Coil.B_curv_quick_plot(I)
|
||||
HH_Coil.plot_raster()
|
||||
@ -66,6 +66,9 @@ AHH_Coil.cooling(I_grad, 22.5)
|
||||
#AHH_Coil.B_grad_quick_plot(I_grad)
|
||||
AHH_Coil.plot_raster(raster_value= 11)
|
||||
|
||||
|
||||
HH_Coil.cooling(4, 40)
|
||||
|
||||
# zero = mu_it(0)
|
||||
# print(f"Bz_grad({z[zero]}) = {Bz_grad[zero]} G/cm")
|
||||
# mu = mu_it(1)
|
||||
|
@ -1,54 +0,0 @@
|
||||
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
|
||||
|
||||
|
||||
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)
|
||||
|
||||
step = 1
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm/step) + 1
|
||||
ylim_mm = 30
|
||||
ylim = int(ylim_mm/step) + 1
|
||||
zlim_mm = 20
|
||||
zlim = int(zlim_mm/step) + 1
|
||||
|
||||
|
||||
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
|
||||
B_quarter = np.load('output/B_quarter.npy')
|
||||
|
||||
x_m, z_m = np.meshgrid(x, z)
|
||||
|
||||
plt.figure(34)
|
||||
|
||||
plt.quiver(x_m,z_m,np.transpose(B_quarter[0, :, :, 0]), np.transpose(B_quarter[0, :, :, 1]))
|
||||
plt.xlabel("x-axis [mm]")
|
||||
plt.ylabel("z-axis [mm]")
|
||||
plt.show()
|
||||
|
||||
x_m, y_m = np.meshgrid(x, y)
|
||||
|
||||
plt.figure(35)
|
||||
|
||||
plt.quiver(x_m, y_m, np.transpose(B_quarter[:, :, 0, 0]), np.transpose(B_quarter[:, :, 0, 1]))
|
||||
plt.xlabel("x-axis [mm]")
|
||||
plt.ylabel("y-axis [mm]")
|
||||
plt.show()
|
||||
|
||||
|
||||
# AHH_Coil.B_quick_plot(5,abs = False)
|
||||
#AHH_Coil.plot_3d(5,30,20)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,79 +0,0 @@
|
||||
"""
|
||||
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():
|
||||
step = 1
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm / step) + 1
|
||||
ylim_mm = 30
|
||||
ylim = int(ylim_mm / step) + 1
|
||||
zlim_mm = 20
|
||||
zlim = int(zlim_mm / step) + 1
|
||||
|
||||
x = np.linspace(-xlim_mm, xlim_mm, 2*xlim + 1) * 1e-3
|
||||
y = np.linspace(-ylim_mm, ylim_mm, 2*ylim+1) * 1e-3
|
||||
z = np.linspace(-zlim_mm, zlim_mm, 2*zlim+1) * 1e-3
|
||||
B_quarter = np.load('output/B_quarter.npy')
|
||||
|
||||
|
||||
# Todo: Alle werte aus B_quarter holen!!
|
||||
step = 1
|
||||
xlim_mm = 30
|
||||
xlim = 2 * int(xlim_mm/step) + 1
|
||||
ylim_mm = 30
|
||||
ylim = 2 * int(ylim_mm/step) + 1
|
||||
zlim_mm = 20
|
||||
zlim = 2 * int(zlim_mm/step) + 1
|
||||
|
||||
#B_quarter = np.zeros((xlim, ylim, zlim, 2))
|
||||
#print(B_quarter)
|
||||
x = np.linspace(-xlim_mm,xlim_mm,xlim) * 1e-3
|
||||
y = np.linspace(-ylim_mm,ylim_mm,ylim) * 1e-3
|
||||
z = np.linspace(-zlim_mm,zlim_mm,zlim) * 1e-3
|
||||
|
||||
|
||||
B_tot = np.zeros((xlim , ylim , zlim ,2))
|
||||
|
||||
# First quater half x>0,y>0,z>0
|
||||
B_tot[xlim//2: xlim, ylim//2: ylim, zlim//2 : zlim,1] = B_quarter[:,:,:,1]
|
||||
|
||||
print(B_tot)
|
||||
for xx in range(xlim//2, xlim):
|
||||
for yy in range(ylim//2,ylim):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
#AHH_Coil.B_quick_plot(5,50)
|
||||
#AHH_Coil.B_grad_quick_plot(5,50)
|
||||
|
||||
|
||||
# Bz, Bx = AHH_Coil.B_field(I_current, x, z)
|
||||
# B_tot_z, B_tot_x = AHH_Coil.B_field(I_current, x, z)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -15,16 +15,16 @@ def mu_it(x_pos):
|
||||
return it
|
||||
|
||||
|
||||
Wire_1 = [2, 0.568]
|
||||
Wire_1 = [0.5, 0.568]
|
||||
|
||||
#I_current = 0.94
|
||||
HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = Wire_1[0],
|
||||
HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 16, 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(f"HH N = {HH_Coil.get_N()}")
|
||||
I_current = 10
|
||||
I_current = 2
|
||||
|
||||
# set radius plus distance
|
||||
HH_Coil.set_R_inner(34.83)
|
||||
|
@ -27,7 +27,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 = 1
|
||||
step = 5
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm/step) + 1
|
||||
ylim_mm = 30
|
||||
@ -65,7 +65,7 @@ def main():
|
||||
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/B_quarter.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))
|
||||
|
92
Coil_geometry/Export_field/02_plotting_data.py
Normal file
92
Coil_geometry/Export_field/02_plotting_data.py
Normal file
@ -0,0 +1,92 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
from src import coil_class as BC
|
||||
from src import physical_constants as cs
|
||||
import logging as log
|
||||
|
||||
|
||||
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)
|
||||
|
||||
step = 5
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm/step) + 1
|
||||
ylim_mm = 30
|
||||
ylim = int(ylim_mm/step) + 1
|
||||
zlim_mm = 20
|
||||
zlim = int(zlim_mm/step) + 1
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
x = np.linspace(-xlim_mm, xlim_mm, 2 *xlim - 1) * 1e-3
|
||||
y = np.linspace(-ylim_mm, ylim_mm, 2 *ylim - 1) * 1e-3
|
||||
z = np.linspace(-zlim_mm, zlim_mm, 2 *zlim - 1) * 1e-3
|
||||
|
||||
|
||||
# b_plot = np.load('output/B_quarter.npy')
|
||||
b_raw = np.load('output/b_cart_1_step_5.npy')
|
||||
b_raw = np.load('output/b_full_test.npy')
|
||||
|
||||
b_plot = np.swapaxes(b_raw,0,1) # Meshgrid uses different order of axis (y,x,z)
|
||||
# x_m, z_m = np.meshgrid(x, z)
|
||||
#
|
||||
# plt.figure(34)
|
||||
#
|
||||
# plt.quiver(x_m,z_m,np.transpose(b_plot[0, :, :, 0]), np.transpose(b_plot[0, :, :, 2]))
|
||||
# plt.xlabel("x-axis [mm]")
|
||||
# plt.ylabel("z-axis [mm]")
|
||||
# plt.title("x-z plane")
|
||||
# plt.show()
|
||||
#
|
||||
# x_m, y_m = np.meshgrid(x, y)
|
||||
#
|
||||
# plt.figure(35)
|
||||
#
|
||||
# plt.quiver(x_m, y_m, b_plot[:, :, 0, 0], b_plot[:, :, 0, 1])
|
||||
# plt.xlabel("x-axis [mm]")
|
||||
# plt.ylabel("y-axis [mm]")
|
||||
# plt.title("x-y plane")
|
||||
# plt.show()
|
||||
#
|
||||
# y_m, z_m = np.meshgrid(y, z)
|
||||
#
|
||||
# plt.figure(36)
|
||||
#
|
||||
# plt.quiver(y_m, z_m, np.transpose(b_plot[0, :, :, 1]), np.transpose(b_plot[0, :, :, 2]))
|
||||
# plt.xlabel("y-axis [mm]")
|
||||
# plt.ylabel("z-axis [mm]")
|
||||
# plt.title("y-z plane")
|
||||
# plt.show()
|
||||
|
||||
x_m, y_m, z_m = np.meshgrid(x, y, z)
|
||||
|
||||
print(np.shape(x_m))
|
||||
print(np.shape(b_plot))
|
||||
fig = plt.figure(37)
|
||||
ax = fig.gca(projection = '3d')
|
||||
#print(b_plot[:, :, :, 0])
|
||||
#print(b_plot[:, 0, :, 0])
|
||||
scaling = 0.0001
|
||||
ax.quiver(x_m, y_m, z_m, scaling * b_plot[:, :, :, 0], scaling * b_plot[:, :, :, 1], scaling * b_plot[:, :, :, 2])
|
||||
plt.xlabel("x-axis [mm]")
|
||||
plt.ylabel("y-axis [mm]")
|
||||
#plt.zlabel("z-axis [mm]")
|
||||
#plt.title("full 3d")
|
||||
plt.show()
|
||||
|
||||
|
||||
# AHH_Coil.B_quick_plot(5,abs = False)
|
||||
#AHH_Coil.plot_3d(5,30,20)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
75
Coil_geometry/Export_field/03_B_quarter_to_field.py
Normal file
75
Coil_geometry/Export_field/03_B_quarter_to_field.py
Normal file
@ -0,0 +1,75 @@
|
||||
"""
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
step = 5
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm / step) + 1
|
||||
print(xlim)
|
||||
ylim_mm = 30
|
||||
ylim = int(ylim_mm / step) + 1
|
||||
zlim_mm = 20
|
||||
zlim = int(zlim_mm / step) + 1
|
||||
|
||||
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
|
||||
|
||||
b_qu_polar = np.load('output/B_quarter_step_5.npy')
|
||||
|
||||
|
||||
|
||||
# print(f"shape of B_quarter = {np.shape(b_qu_polar)}")
|
||||
shape = np.shape(b_qu_polar)
|
||||
print(shape)
|
||||
new_shape = (shape[0], shape[1], shape[2], shape[3] + 1)
|
||||
b_cart_1 = np.zeros(new_shape)
|
||||
|
||||
# add z-component
|
||||
b_cart_1[:, :, :, 2] = b_qu_polar[:, :, :, 1]
|
||||
|
||||
for xx in range(0, xlim):
|
||||
for yy in range(0, ylim):
|
||||
if xx == 0:
|
||||
phi = np.pi / 2
|
||||
else:
|
||||
phi = np.arctan(y[yy] / x[xx])
|
||||
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/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()
|
22
Coil_geometry/Export_field/04_Write_to_txt.py
Normal file
22
Coil_geometry/Export_field/04_Write_to_txt.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""
|
||||
Created on 15.11.21
|
||||
|
||||
@author: Joschka
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
def main():
|
||||
b_full = np.load('output/b_full_test.npy')
|
||||
|
||||
bx_txt = open("output/Bx.txt", "w+")
|
||||
xx = 0
|
||||
yy = 0
|
||||
str = np.array2string(b_full[xx, yy, :, 0])
|
||||
bx_txt.write(str)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
BIN
Coil_geometry/Export_field/output/B_quarter_step_5.npy
Normal file
BIN
Coil_geometry/Export_field/output/B_quarter_step_5.npy
Normal file
Binary file not shown.
BIN
Coil_geometry/Export_field/output/b_cart_1.npy
Normal file
BIN
Coil_geometry/Export_field/output/b_cart_1.npy
Normal file
Binary file not shown.
BIN
Coil_geometry/Export_field/output/b_cart_1_step_5.npy
Normal file
BIN
Coil_geometry/Export_field/output/b_cart_1_step_5.npy
Normal file
Binary file not shown.
BIN
Coil_geometry/Export_field/output/b_full_test.npy
Normal file
BIN
Coil_geometry/Export_field/output/b_full_test.npy
Normal file
Binary file not shown.
22
untitled0.py
22
untitled0.py
@ -5,29 +5,15 @@ Created on Fri Oct 1 10:42:13 2021
|
||||
@author: Joschka
|
||||
"""
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def main():
|
||||
wire_width = 0.568
|
||||
ins = 0.068
|
||||
print(2*wire_width)
|
||||
r_in = 45.92 + wire_width/2
|
||||
print(2*45.92)
|
||||
print(r_in*3)
|
||||
d_in = r_in * 2
|
||||
for ll in range(0,8):
|
||||
r = r_in + ll * wire_width
|
||||
d = 2 * r
|
||||
print(f"layer {ll+1}: d = {d} mm")
|
||||
print(d + wire_width/2)
|
||||
print(8.5*wire_width)
|
||||
res = 0.568/2
|
||||
x = np.linspace(-10, 10, 21)
|
||||
print(x)
|
||||
print(x[:0:-1])
|
||||
|
||||
|
||||
print(res)
|
||||
|
||||
print(np.pi * 2 *47.9)
|
||||
res = [322.7,367.2]
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user