diff --git a/Coil_geometry/00_FINAL_coil_geometry.py b/Coil_geometry/00_FINAL_coil_geometry.py index 3dd7fce..836eb6a 100644 --- a/Coil_geometry/00_FINAL_coil_geometry.py +++ b/Coil_geometry/00_FINAL_coil_geometry.py @@ -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) diff --git a/Coil_geometry/AHH/10_work_with_export_data.py b/Coil_geometry/AHH/10_work_with_export_data.py deleted file mode 100644 index 16b5e07..0000000 --- a/Coil_geometry/AHH/10_work_with_export_data.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/Coil_geometry/AHH/11_B_qu_to_field.py b/Coil_geometry/AHH/11_B_qu_to_field.py deleted file mode 100644 index 4fa9e96..0000000 --- a/Coil_geometry/AHH/11_B_qu_to_field.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/Coil_geometry/Additional coils/00_Test_coil_around viewport.py b/Coil_geometry/Additional coils/00_Test_coil_around viewport.py index 20e285c..e8df969 100644 --- a/Coil_geometry/Additional coils/00_Test_coil_around viewport.py +++ b/Coil_geometry/Additional coils/00_Test_coil_around viewport.py @@ -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) diff --git a/Coil_geometry/AHH/09_Export_Gradient_field.py b/Coil_geometry/Export_field/01_Export_quarter_radial.py similarity index 97% rename from Coil_geometry/AHH/09_Export_Gradient_field.py rename to Coil_geometry/Export_field/01_Export_quarter_radial.py index a5ac9de..d42080e 100644 --- a/Coil_geometry/AHH/09_Export_Gradient_field.py +++ b/Coil_geometry/Export_field/01_Export_quarter_radial.py @@ -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)) diff --git a/Coil_geometry/Export_field/02_plotting_data.py b/Coil_geometry/Export_field/02_plotting_data.py new file mode 100644 index 0000000..601cb55 --- /dev/null +++ b/Coil_geometry/Export_field/02_plotting_data.py @@ -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() \ No newline at end of file diff --git a/Coil_geometry/Export_field/03_B_quarter_to_field.py b/Coil_geometry/Export_field/03_B_quarter_to_field.py new file mode 100644 index 0000000..719560f --- /dev/null +++ b/Coil_geometry/Export_field/03_B_quarter_to_field.py @@ -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() diff --git a/Coil_geometry/Export_field/04_Write_to_txt.py b/Coil_geometry/Export_field/04_Write_to_txt.py new file mode 100644 index 0000000..ebcfd74 --- /dev/null +++ b/Coil_geometry/Export_field/04_Write_to_txt.py @@ -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() \ No newline at end of file diff --git a/Coil_geometry/AHH/output/B_quarter.npy b/Coil_geometry/Export_field/output/B_quarter.npy similarity index 100% rename from Coil_geometry/AHH/output/B_quarter.npy rename to Coil_geometry/Export_field/output/B_quarter.npy diff --git a/Coil_geometry/Export_field/output/B_quarter_step_5.npy b/Coil_geometry/Export_field/output/B_quarter_step_5.npy new file mode 100644 index 0000000..0162186 Binary files /dev/null and b/Coil_geometry/Export_field/output/B_quarter_step_5.npy differ diff --git a/Coil_geometry/Export_field/output/b_cart_1.npy b/Coil_geometry/Export_field/output/b_cart_1.npy new file mode 100644 index 0000000..fe056fb Binary files /dev/null and b/Coil_geometry/Export_field/output/b_cart_1.npy differ diff --git a/Coil_geometry/Export_field/output/b_cart_1_step_5.npy b/Coil_geometry/Export_field/output/b_cart_1_step_5.npy new file mode 100644 index 0000000..8f73418 Binary files /dev/null and b/Coil_geometry/Export_field/output/b_cart_1_step_5.npy differ diff --git a/Coil_geometry/Export_field/output/b_full_test.npy b/Coil_geometry/Export_field/output/b_full_test.npy new file mode 100644 index 0000000..edf1c5f Binary files /dev/null and b/Coil_geometry/Export_field/output/b_full_test.npy differ diff --git a/untitled0.py b/untitled0.py index a976d5a..4e6232e 100644 --- a/untitled0.py +++ b/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]