new calculations
This commit is contained in:
parent
620e61e025
commit
7dc0bf1c78
@ -24,6 +24,9 @@ HH_Coil = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8,
|
||||
wire_width = Wire_1[0], insulation_thickness=(Wire_1[1] - Wire_1[0]) / 2, is_round = True,
|
||||
winding_scheme= 2)
|
||||
|
||||
R = HH_Coil.resistance(150)
|
||||
R = HH_Coil.resistance(25)
|
||||
|
||||
print(2400/R)
|
||||
I = 2
|
||||
print(f"U ={I*R*2}")
|
||||
|
||||
print(f"resistance {R}")
|
@ -8,6 +8,7 @@ import matplotlib.pyplot as plt
|
||||
from src import coil_class as BC
|
||||
from src import physical_constants as cs
|
||||
import logging as log
|
||||
import time
|
||||
|
||||
log.basicConfig(level=log.DEBUG, format='%(message)s')
|
||||
|
||||
@ -18,7 +19,7 @@ def main():
|
||||
|
||||
x, z = BC.BCoil.make_axis(50, 5)
|
||||
|
||||
I_current = 5
|
||||
I_current = 0.3804
|
||||
|
||||
|
||||
# print(BC.BCoil._BCoil__B_z_loop(I_current = I, r_loop = 1, z_loop = 1, r_pos = 0, z_pos = 0.1)
|
||||
@ -27,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 = 5
|
||||
step = 0.05
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm/step) + 1
|
||||
ylim_mm = 30
|
||||
@ -35,37 +36,39 @@ def main():
|
||||
zlim_mm = 20
|
||||
zlim = int(zlim_mm/step) + 1
|
||||
|
||||
B_quarter = np.zeros((xlim, ylim, zlim, 2))
|
||||
B_quarter = np.zeros((xlim, ylim, zlim, 2),dtype= np.float32)
|
||||
print(np.shape(B_quarter))
|
||||
#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()):
|
||||
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):
|
||||
print(f"time = {(time.time()-start)/60} min")
|
||||
print(f"wire = {wire} of {AHH_Coil.get_N()}")
|
||||
|
||||
r = np.sqrt(x[xx]**2 + y[yy]**2)
|
||||
# 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):
|
||||
|
||||
# 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)
|
||||
r = np.sqrt(x[xx]**2 + y[yy]**2)
|
||||
|
||||
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)
|
||||
# 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)
|
||||
|
||||
np.save('output/B_quarter_step_5.npy', B_quarter)
|
||||
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_1Gcm.npy', B_quarter)
|
||||
|
||||
#B_tot = np.zeros(((2 * xlim) - 1, (2 * ylim) - 1, (2 * zlim)-1, 2))
|
||||
|
||||
|
@ -11,7 +11,7 @@ def main():
|
||||
wire_height=0.5, wire_width=0.5, insulation_thickness=0.068 / 2,
|
||||
is_round=True, winding_scheme=2)
|
||||
|
||||
step = 5
|
||||
step = 0.03
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm/step) + 1
|
||||
ylim_mm = 30
|
||||
@ -29,9 +29,10 @@ def main():
|
||||
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.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)
|
||||
|
@ -13,7 +13,7 @@ import logging as log
|
||||
|
||||
|
||||
def main():
|
||||
step = 5
|
||||
step = 0.05
|
||||
xlim_mm = 30
|
||||
xlim = int(xlim_mm / step) + 1
|
||||
print(xlim)
|
||||
@ -26,7 +26,7 @@ def main():
|
||||
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')
|
||||
b_qu_polar = np.load('output/final/B_quarter_1Gcm.npy')
|
||||
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ def main():
|
||||
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)
|
||||
b_cart_1 = np.zeros(new_shape,dtype = np.float32)
|
||||
|
||||
# add z-component
|
||||
b_cart_1[:, :, :, 2] = b_qu_polar[:, :, :, 1]
|
||||
@ -48,28 +48,10 @@ 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/b_cart_1_step_5.npy', b_cart_1)
|
||||
np.save('output/final/b_cart_1Gcm.npy', b_cart_1)
|
||||
del b_qu_polar
|
||||
del 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()
|
||||
|
56
Coil_geometry/Export_field/04_B_cart_to_B_field.py
Normal file
56
Coil_geometry/Export_field/04_B_cart_to_B_field.py
Normal file
@ -0,0 +1,56 @@
|
||||
"""
|
||||
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 = 0.05
|
||||
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_cart_1 = np.load('output/final/b_cart_1Gcm.npy')
|
||||
|
||||
new_shape = np.shape(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, dtype= np.float32)
|
||||
|
||||
# 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/final/b_full.npy', b_full)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,22 +0,0 @@
|
||||
"""
|
||||
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()
|
30
Coil_geometry/Export_field/05_Write_to_txt.py
Normal file
30
Coil_geometry/Export_field/05_Write_to_txt.py
Normal file
@ -0,0 +1,30 @@
|
||||
"""
|
||||
Created on 15.11.21
|
||||
|
||||
@author: Joschka
|
||||
"""
|
||||
import numpy as np
|
||||
from scipy.io import savemat
|
||||
|
||||
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)
|
||||
b_full = np.load('output/final/b_full.npy')
|
||||
# mdic = {"B": b_full}
|
||||
# del b_full
|
||||
|
||||
# savemat("b_full_matlab.mat",b_full)
|
||||
|
||||
np.savetxt("b_x.csv", b_full[:,:,0,0])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -9,9 +9,8 @@ import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def main():
|
||||
x = np.linspace(-10, 10, 21)
|
||||
print(x)
|
||||
print(x[:0:-1])
|
||||
print(2e8/4.9e-3)
|
||||
#print(zlim*35921/(1024)**2)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user