more stuff

This commit is contained in:
schoener 2021-10-01 14:37:07 +02:00
parent 1b7cd031ee
commit def9355f18
90 changed files with 6296 additions and 20 deletions

Binary file not shown.

3
Benchmarking/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

12
Benchmarking/.idea/Spyder.iml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
Benchmarking/.idea/misc.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>

8
Benchmarking/.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Spyder.iml" filepath="$PROJECT_DIR$/.idea/Spyder.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,8 @@
[codestyle]
indentation = True
edge_line = True
edge_line_columns = 79
[main]
version = 0.2.0

View File

@ -0,0 +1,5 @@
[codestyle]
indentation = True
edge_line = True
edge_line_columns = 79

View File

@ -0,0 +1,3 @@
[encoding]
text_encoding = utf-8

View File

@ -0,0 +1,4 @@
[vcs]
use_version_control = False
version_control_system =

View File

@ -0,0 +1,6 @@
[workspace]
restore_data_on_startup = True
save_data_on_exit = True
save_history = True
save_non_project_files = False

View File

@ -0,0 +1,6 @@
[encoding]
text_encoding = utf-8
[main]
version = 0.2.0

View File

@ -0,0 +1,7 @@
[vcs]
use_version_control = False
version_control_system =
[main]
version = 0.2.0

View File

@ -0,0 +1,10 @@
[workspace]
restore_data_on_startup = True
save_data_on_exit = True
save_history = True
save_non_project_files = False
[main]
version = 0.2.0
recent_files = ['comparison_HH_increased_resolution.py']

View File

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 13:45:56 2021
@author: Joschka
"""
import numpy as np
import matplotlib_inline as plt
x =

View File

@ -0,0 +1,182 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x_m = np.linspace(-0.05, 0.05, 51)
z_m = np.linspace(-0.05, 0.05, 201)
z = z_m*1e3
x = x_m*1e3 #for plotting in mm
#Import Values from simulation
B_z_sim = np.loadtxt('data/B_z_HH2.txt')
B_x_sim = np.loadtxt('data/B_x_HH2.txt')
################# My simulation #########################
I = 5
HH = 1
d_coils = 44
R_inner = 44-3*1.7
layers = 6
windings = 2
wire_width = 1.7
wire_height = 2.6
B_z, B_x = bf.B_multiple_raster_test(I,HH,R_inner,d_coils,layers,windings,wire_width, wire_height, x_m,z_m)
#B_test = B_field_ideal_AHH(layers*windings,I,R_inner*1e-3,d_coils*1e-3,z_m)
#B_x = np.concatenate((-np.flip(B_r),B_r[1:len(B_r)]))
#Calculate gradients/curvature
B_z_sim_grad = np.gradient(np.gradient(B_z_sim,z_m),z_m)/1e4
B_x_sim_grad = np.gradient(B_x_sim,x_m)/100
B_z_grad = np.gradient(np.gradient(B_z,z_m),z_m)/1e4
B_x_grad = np.gradient(B_x,x_m)/100
#Calculate relative differences in permille
rel_diff_Bz = (B_z-B_z_sim)/B_z
rel_diff_Bx = (B_x-B_x_sim)/B_x
rel_diff_Bz_grad = (B_z_grad-B_z_sim_grad)/B_z_grad
rel_diff_Bz_grad_mean = (B_z_grad-B_z_sim_grad)/np.mean(B_z_grad)
rel_diff_Bx_grad = (B_x_grad-B_x_sim_grad)/B_x_grad
#Plotting
plt.figure(1,figsize=(20,18))
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_z along z-axis, comparison of simulations", fontsize=30)
#Field plot
##########################
plt.subplot(3,2,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim,linestyle = "dashdot", label = r"$B_{z, sim}$: Numerical Matlab simulation")
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,3)
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
plt.ylabel("absolute deviation [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,5)
plt.plot(z,1000*rel_diff_Bz, label = "$(B_z - B_{z, sim}) / B_z$")
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
######################Gradient plot############################
################
plt.subplot(3,2,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z^2 B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim_grad,linestyle = "dashdot", label = r"$\nabla_z^2 B_{z, sim}$: Numerical Matlab sim.")
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.title("Curvature of B-field",fontsize = 30)
plt.legend(loc='lower right')
#################
plt.subplot(3,2,4)
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"absolute deviation $[G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.legend()
#####################
plt.subplot(3,2,6)
plt.plot(z,1000*rel_diff_Bz_grad, label = r"$(\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}) / \nabla_z^2 B_z$")
#plt.ylim(-57,10)
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.savefig("output/HH_benchmark_5A_6x2.pdf")
plt.show()
############### relative deviation with averaging by the mean not the individual value ########################################
plt.figure(2)
plt.plot(z,1000*rel_diff_Bz_grad_mean, label = r"$(\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}) / mean(\nabla_z^2 B_z)$")
#plt.ylim(-57,10)
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.savefig("output/HH_benchmark_5A_6x2_rel_deviation_via_mean.pdf")
plt.show()
##################### x-Axis #########################################################
plt.figure(3)
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_x along x-axis, comparison of simulations", fontsize=30)
#Field plot
##########################
plt.plot(x,B_x,linestyle = "solid", label = r"$B_x$: Result via elliptic integrals")
plt.plot(x,B_x_sim,linestyle = "dashdot", label = r"$B_{x, sim}$: Numerical Matlab simulation")
plt.plot(x,(B_x-B_x_sim), label = r"$B_x - B_{x, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_x$ [G]")
plt.xlabel("x-axis [mm]")
plt.legend()
#################
plt.savefig("output/HH_benchmark_5A_6x2_x-axis.pdf")
plt.show()

View File

@ -0,0 +1,153 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
import B_field_calculation as bf
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x_m = np.linspace(-0.05,0.05,51)
z_m = np.linspace(-0.05,0.05,201)
z_m_2 = np.linspace(-0.05,0.05,1001)
z_2 = z_m_2*1e3
z = z_m*1e3
x = x_m*1e3 #for plotting in mm
#Import Values from simulation
B_z_sim = np.loadtxt('data/B_z_HH2.txt')
B_x_sim = np.loadtxt('data/B_x_HH2.txt')
################# My simulation #########################
I = 5
HH = 1
d_coils = 78
R_inner = 44-3*1.7
layers = 6
windings = 2
wire_width = 1.7
wire_height = 2.6
B_z, B_x = bf.B_multiple_raster_test(I,HH,R_inner,d_coils,layers,windings,wire_width, wire_height, x_m,z_m_2)
#B_test = B_field_ideal_AHH(layers*windings,I,R_inner*1e-3,d_coils*1e-3,z_m)
#B_x = np.concatenate((-np.flip(B_r),B_r[1:len(B_r)]))
#Calculate gradients/curvature
B_z_sim_grad = np.gradient(np.gradient(B_z_sim,z_m),z_m)/1e4
B_x_sim_grad = np.gradient(B_x_sim,x_m)/100
B_z_grad = np.gradient(np.gradient(B_z,z_m_2),z_m_2)/1e4
B_x_grad = np.gradient(B_x,x_m)/100
#try plot
plt.figure(1)
plt.plot(z_2,B_z,linestyle = "solid", label = r"$B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim,linestyle = "dashdot", label = r"$B_{z, sim}$: Numerical Matlab simulation")
#plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.show()
plt.figure(2)
plt.plot(z_2,B_z_grad,linestyle = "solid", label = r"$\nabla_z^2 B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim_grad,linestyle = "dashdot", label = r"$\nabla_z^2 B_{z, sim}$: Numerical Matlab sim.")
#plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.title("Curvature of B-field",fontsize = 30)
plt.legend(loc='lower right')
plt.show()
#Calculate relative differences in permille
rel_diff_Bz = (B_z-B_z_sim)/B_z
rel_diff_Bx = (B_x-B_x_sim)/B_x
rel_diff_Bz_grad = (B_z_grad-B_z_sim_grad)/B_z_grad
rel_diff_Bx_grad = (B_x_grad-B_x_sim_grad)/B_x_grad
#Plotting
plt.figure(figsize=(20,18))
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_z along z-axis, comparison of simulations", fontsize=30)
#Field plot
##########################
plt.subplot(3,2,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim,linestyle = "dashdot", label = r"$B_{z, sim}$: Numerical Matlab simulation")
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,3)
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
plt.ylabel("absolute deviation [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,5)
plt.plot(z,1000*rel_diff_Bz, label = "$(B_z - B_{z, sim}) / B_z$")
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
######################Gradient plot############################
################
plt.subplot(3,2,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z^2 B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim_grad,linestyle = "dashdot", label = r"$\nabla_z^2 B_{z, sim}$: Numerical Matlab sim.")
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.title("Curvature of B-field",fontsize = 30)
plt.legend(loc='lower right')
#################
plt.subplot(3,2,4)
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"absolute deviation $[G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.legend()
#####################
plt.subplot(3,2,6)
plt.plot(z,1000*rel_diff_Bz_grad, label = r"$(\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}) / \nabla_z^2 B_z$")
plt.ylim(-57,10)
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.show()

View File

@ -0,0 +1,153 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
import B_field_calculation as bf
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x_m = np.linspace(-0.05,0.05,51)
z_m = np.linspace(-0.05,0.05,201)
z_m_2 = np.linspace(-0.05,0.05,1001)
z_2 = z_m_2*1e3
z = z_m*1e3
x = x_m*1e3 #for plotting in mm
#Import Values from simulation
B_z_sim = np.loadtxt('data/B_z_HH2.txt')
B_x_sim = np.loadtxt('data/B_x_HH2.txt')
################# My simulation #########################
I = 5
HH = 1
d_coils = 44
R_inner = 44-3*1.7
layers = 6
windings = 2
wire_width = 1.7
wire_height = 2.6
B_z, B_x = bf.B_multiple_raster_test(I,HH,R_inner,d_coils,layers,windings,wire_width, wire_height, x_m,z_m_2)
#B_test = B_field_ideal_AHH(layers*windings,I,R_inner*1e-3,d_coils*1e-3,z_m)
#B_x = np.concatenate((-np.flip(B_r),B_r[1:len(B_r)]))
#Calculate gradients/curvature
B_z_sim_grad = np.gradient(np.gradient(B_z_sim,z_m),z_m)/1e4
B_x_sim_grad = np.gradient(B_x_sim,x_m)/100
B_z_grad = np.gradient(np.gradient(B_z,z_m_2),z_m_2)/1e4
B_x_grad = np.gradient(B_x,x_m)/100
#try plot
plt.figure(1)
plt.plot(z_2,B_z,linestyle = "solid", label = r"$B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim,linestyle = "dashdot", label = r"$B_{z, sim}$: Numerical Matlab simulation")
#plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.show()
plt.figure(2)
plt.plot(z_2,B_z_grad,linestyle = "solid", label = r"$\nabla_z^2 B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim_grad,linestyle = "dashdot", label = r"$\nabla_z^2 B_{z, sim}$: Numerical Matlab sim.")
#plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.title("Curvature of B-field",fontsize = 30)
plt.legend(loc='lower right')
plt.show()
#Calculate relative differences in permille
rel_diff_Bz = (B_z-B_z_sim)/B_z
rel_diff_Bx = (B_x-B_x_sim)/B_x
rel_diff_Bz_grad = (B_z_grad-B_z_sim_grad)/B_z_grad
rel_diff_Bx_grad = (B_x_grad-B_x_sim_grad)/B_x_grad
#Plotting
plt.figure(figsize=(20,18))
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_z along z-axis, comparison of simulations", fontsize=30)
#Field plot
##########################
plt.subplot(3,2,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim,linestyle = "dashdot", label = r"$B_{z, sim}$: Numerical Matlab simulation")
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,3)
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
plt.ylabel("absolute deviation [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,5)
plt.plot(z,1000*rel_diff_Bz, label = "$(B_z - B_{z, sim}) / B_z$")
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
######################Gradient plot############################
################
plt.subplot(3,2,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z^2 B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim_grad,linestyle = "dashdot", label = r"$\nabla_z^2 B_{z, sim}$: Numerical Matlab sim.")
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.title("Curvature of B-field",fontsize = 30)
plt.legend(loc='lower right')
#################
plt.subplot(3,2,4)
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"absolute deviation $[G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.legend()
#####################
plt.subplot(3,2,6)
plt.plot(z,1000*rel_diff_Bz_grad, label = r"$(\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}) / \nabla_z^2 B_z$")
plt.ylim(-57,10)
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.show()

View File

@ -0,0 +1,126 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
import B_field_calculation as bf
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x_m = np.linspace(-0.05,0.05,51)
z_m = np.linspace(-0.05,0.05,51)
z = z_m*1e3
x = x_m*1e3 #for plotting in mm
#Import Values from simulation
B_z_sim = np.loadtxt('data/B_z_HH.txt')
B_x_sim = np.loadtxt('data/B_x_HH.txt')
################# My simulation #########################
I = 5
HH = 1
d_coils = 44
R_inner = 44
layers = 10
windings = 2
wire_width = 1
wire_height = 2.6
B_z, B_x = bf.B_multiple(I,HH,R_inner,d_coils,layers,windings,wire_width, wire_height, x_m,z_m)
#B_test = B_field_ideal_AHH(layers*windings,I,R_inner*1e-3,d_coils*1e-3,z_m)
#B_x = np.concatenate((-np.flip(B_r),B_r[1:len(B_r)]))
#Calculate gradients/curvature
B_z_sim_grad = np.gradient(np.gradient(B_z_sim,z_m),z_m)/1e4
B_x_sim_grad = np.gradient(B_x_sim,x_m)/100
B_z_grad = np.gradient(np.gradient(B_z,z_m),z_m)/1e4
B_x_grad = np.gradient(B_x,x_m)/100
#Calculate relative differences in permille
rel_diff_Bz = (B_z-B_z_sim)/B_z
rel_diff_Bx = (B_x-B_x_sim)/B_x
rel_diff_Bz_grad = (B_z_grad-B_z_sim_grad)/B_z_grad
rel_diff_Bx_grad = (B_x_grad-B_x_sim_grad)/B_x_grad
#Plotting
plt.figure(figsize=(20,18))
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_z along z-axis, comparison of simulations", fontsize=30)
#Field plot
##########################
plt.subplot(3,2,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim,linestyle = "dashdot", label = r"$B_{z, sim}$: Numerical Matlab simulation")
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,3)
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
plt.ylabel("absolute deviation [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,5)
plt.plot(z,1000*rel_diff_Bz, label = "$(B_z - B_{z, sim}) / B_z$")
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
######################Gradient plot############################
################
plt.subplot(3,2,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z^2 B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim_grad,linestyle = "dashdot", label = r"$\nabla_z^2 B_{z, sim}$: Numerical Matlab sim.")
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.title("Curvature of B-field",fontsize = 30)
plt.legend(loc='lower right')
#################
plt.subplot(3,2,4)
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"absolute deviation $[G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.legend()
#####################
plt.subplot(3,2,6)
plt.plot(z,1000*rel_diff_Bz_grad, label = r"$(\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}) / \nabla_z^2 B_z$")
plt.ylim(-57,10)
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.show()

51
Benchmarking/data/B_x.txt Normal file
View File

@ -0,0 +1,51 @@
2.58228909714096
2.62974538222051
2.65944955784724
2.67018023408114
2.66129310777269
2.63274636464909
2.58507635240118
2.51932891811042
2.43695775772549
2.33970435103465
2.22947425589503
2.10822224575473
1.97785501967328
1.84015609055015
1.69673381785331
1.5489908693351
1.39811178932252
1.24506469044685
1.09061312356843
0.935334651061495
0.779643326178502
0.623814004093807
0.468007079187523
0.312292808736715
0.156674829998973
0.00111281003184087
-0.154455601231865
-0.310093199262038
-0.465841648637876
-0.621699513490636
-0.777599570919756
-0.933385222755551
-1.08878604652763
-1.24339285381046
-1.39663306776149
-1.54774779802038
-1.69577266767607
-1.83952518780893
-1.97760218416845
-2.1083912972814
-2.23010067296318
-2.34081035784062
-2.43854734635146
-2.52138353563691
-2.58755212369357
-2.63557369709183
-2.66437927197459
-2.67341503397356
-2.66271358255533
-2.63291973763518
-2.58526513884324

View File

@ -0,0 +1,51 @@
-3.16996429106098e-16
2.12281581202234e-16
2.90868024110935e-16
-1.52549847753924e-16
-4.48460713009524e-17
1.78201203793193e-16
-1.79897763352699e-16
-2.26367535827165e-16
4.43187153642555e-17
-2.69312350198447e-16
2.23189522419176e-17
-1.08999614889527e-16
-9.00043928275807e-17
-3.54577478489659e-17
-2.1298587893348e-16
-3.95274091236075e-17
-7.6369466306403e-17
4.99322805325164e-17
-8.50014503228636e-18
-3.11972669919669e-17
-1.72431513512095e-17
-1.660477311205e-17
-2.46330733588707e-18
2.02615701994091e-18
-1.6153745008296e-17
8.46545056276682e-19
2.2065682614425e-17
2.901845430614e-17
6.85562717706034e-18
-1.47798440153224e-17
4.8919202022546e-17
9.30089338879725e-17
-8.02691246803988e-17
3.22797344409764e-17
-5.15143483426073e-17
1.49547041417009e-16
-3.49720252756924e-17
1.31672450720544e-16
9.14823772291129e-17
-5.1680881796301e-17
4.92383911421257e-17
2.1582735598713e-16
8.57092175010621e-17
2.96096480667529e-16
8.26005930321116e-17
1.85185200507476e-16
2.05613304160579e-16
-1.51212375953946e-16
-1.57651669496772e-16
-2.41140440948584e-16
-1.97619698383278e-17

View File

@ -0,0 +1,51 @@
-1.77967016123937e-16
2.64285121565067e-16
2.19350579366839e-16
2.34326447134947e-16
3.81500386836819e-17
-2.26797747249208e-17
-3.0069696732582e-17
8.47620584831788e-17
2.58543186859583e-17
-3.27862736959617e-18
-2.45480719085478e-16
-3.4198685550102e-16
4.26082780169423e-17
5.10598507919013e-17
-1.19383669616724e-17
-4.75106065600528e-17
-4.11268241684581e-17
-2.01873240346373e-16
-2.31967223207619e-17
4.16680578929629e-17
-3.89480114826313e-17
-1.30312427515378e-17
5.24996712769621e-17
3.12250225675825e-19
-1.79023462720806e-18
-6.9111383282916e-18
6.35602681597902e-18
-3.19744231092045e-17
3.92741394961149e-17
4.92661467177413e-18
-2.87270207621759e-17
1.2490009027033e-18
-7.52176099183544e-18
-8.22675261247241e-17
7.24420523567915e-18
-1.27509114378199e-16
-1.56485935320916e-16
-1.87849735766576e-16
7.32747196252603e-17
1.85962356624714e-17
4.34097202628436e-17
-6.32827124036339e-18
1.46660461552983e-16
-4.40758540776187e-17
2.40030217923959e-16
4.31876756579186e-17
7.31636973227978e-16
-1.86517468137026e-16
1.27453603226968e-16
-1.07469588783715e-16
6.30606677987089e-17

View File

@ -0,0 +1,51 @@
-1.24750904051396e-16
2.93279289742543e-16
2.26136817604861e-16
3.56503021547994e-17
-1.22107185474007e-16
-2.02709377061794e-16
-2.22426244089746e-17
2.23689122780257e-16
-1.11324144347336e-16
-1.87964227515991e-16
9.9704966505243e-17
5.02584085460001e-17
-1.34052491329584e-16
9.60863333343553e-17
1.57263091438153e-16
5.76830250231808e-17
7.78335729201274e-17
5.30478438953708e-17
-3.31262794972531e-17
-7.1352646013878e-17
3.41671135828392e-17
-2.4980018054066e-19
-1.02834407655905e-17
5.13478148889135e-19
3.49442697000768e-17
-2.0122792321331e-18
-1.21430643318376e-17
-5.13478148889135e-19
8.451572774959e-18
1.85407245112401e-17
2.6256774532385e-17
4.37705427458468e-17
2.32869279415127e-17
-5.21527265817667e-17
-9.9253938401489e-17
8.98170426921752e-17
1.01585406753202e-17
-1.25455201782643e-17
-9.28701560098943e-17
-1.48658862997308e-16
-9.35918009759007e-17
-7.8381745538536e-17
1.90625293328139e-16
-2.665645482125e-16
1.59205981731247e-16
-1.37223565843669e-16
2.35367281220533e-16
1.01918473660589e-16
9.99200722162641e-17
7.39408534400354e-17
-8.88178419700125e-17

View File

@ -0,0 +1,51 @@
0.315870252483617
0.255751600481404
0.186566907419062
0.109579894595394
0.0265188340157648
-0.0605131846806727
-0.149172561144372
-0.237039624364386
-0.321792991214021
-0.401371661996773
-0.474105051893869
-0.538797228405318
-0.594759769626575
-0.641795860096254
-0.680144730243721
-0.710399274104225
-0.733410476873435
-0.750190699147325
-0.761824833391987
-0.769394839059607
-0.773919932063492
-0.776312195414932
-0.777345741324315
-0.777636734525558
-0.7776314177094
-0.777599570919756
-0.777631417709401
-0.777636734525557
-0.777345741324316
-0.776312195414932
-0.773919932063492
-0.769394839059607
-0.761824833391987
-0.750190699147325
-0.733410476873435
-0.710399274104225
-0.68014473024372
-0.641795860096254
-0.594759769626576
-0.538797228405317
-0.474105051893868
-0.401371661996773
-0.32179299121402
-0.237039624364387
-0.149172561144371
-0.0605131846806727
0.0265188340157647
0.109579894595394
0.186566907419063
0.255751600481404
0.315870252483617

View File

@ -0,0 +1,51 @@
0.838336941886738
0.704528329101358
0.540869156075738
0.35046355927954
0.138717140535653
-0.0869617178249859
-0.317812922539589
-0.544633260253625
-0.758773254273728
-0.953026552475999
-1.12224822987221
-1.26361615688701
-1.37654277003895
-1.46232024454193
-1.52361931467383
-1.56395876595001
-1.58723193850584
-1.59733657523226
-1.59791936470777
-1.59222336048851
-1.58301538123973
-1.57256834273773
-1.56267637311523
-1.55468543867366
-1.5495271744476
-1.54774779802038
-1.5495271744476
-1.55468543867366
-1.56267637311523
-1.57256834273773
-1.58301538123973
-1.59222336048851
-1.59791936470777
-1.59733657523226
-1.58723193850584
-1.56395876595
-1.52361931467383
-1.46232024454193
-1.37654277003895
-1.26361615688701
-1.1222482298722
-0.953026552475999
-0.758773254273728
-0.544633260253624
-0.31781292253959
-0.0869617178249862
0.138717140535653
0.350463559279539
0.54086915607574
0.704528329101358
0.838336941886739

51
Benchmarking/data/B_z.txt Normal file
View File

@ -0,0 +1,51 @@
-4.48637597842307
-4.59077060562329
-4.67041322168728
-4.72240325284354
-4.74436993663005
-4.73459770750829
-4.69211662587652
-4.61674838668992
-4.50910292358247
-4.37052591912355
-4.20300278459966
-4.00902903659917
-3.79145982624433
-3.55335235560578
-3.29781410027413
-3.02786751635909
-2.74633880333963
-2.45577492365425
-2.15838996506787
-1.85603942975685
-1.55021931502741
-1.24208591874369
-0.932492042829694
-0.622035500630058
-0.311116360833961
2.24015250793741e-16
0.311116360833964
0.622035500630061
0.932492042829691
1.24208591874369
1.55021931502741
1.85603942975685
2.15838996506787
2.45577492365425
2.74633880333963
3.02786751635908
3.29781410027412
3.55335235560578
3.79145982624433
4.00902903659918
4.20300278459966
4.37052591912355
4.50910292358246
4.61674838668993
4.69211662587652
4.73459770750829
4.74436993663004
4.72240325284354
4.67041322168726
4.59077060562329
4.48637597842307

View File

@ -0,0 +1,51 @@
10.6536698262602
11.2355834431335
11.8308215916294
12.4354708668342
13.0449371679322
13.6539956497498
14.256886633848
14.8474615439352
15.4193788084015
15.9663442568647
16.4823843046589
16.9621339792356
17.4011166569334
17.7959893766068
18.1447277134393
18.446727900502
18.7028109839925
18.9151233996802
19.0869390335573
19.2223779319734
19.3260648763817
19.4027560509914
19.4569636870496
19.4926071771896
19.5127154666301
19.5192004530879
19.5127154666301
19.4926071771896
19.4569636870496
19.4027560509914
19.3260648763817
19.2223779319735
19.0869390335574
18.9151233996802
18.7028109839925
18.446727900502
18.1447277134393
17.7959893766068
17.4011166569334
16.9621339792356
16.4823843046588
15.9663442568647
15.4193788084015
14.8474615439352
14.256886633848
13.6539956497498
13.0449371679322
12.4354708668342
11.8308215916294
11.2355834431335
10.6536698262602

View File

@ -0,0 +1,51 @@
10.6538828816951
11.2391166045421
11.8379555109104
12.4464506538621
13.0599583946471
13.6731901710357
14.2803092432835
14.8750786818901
15.4510606469831
16.0018614545581
16.5214105175275
17.0042548219564
17.4458452446815
17.842787903183
18.1930338192903
18.4959839616112
18.7524940110866
18.9647730529274
19.1361813633915
19.2709428334617
19.3737958295774
19.4496114219081
19.503009586584
19.5380025365883
19.5576905341118
19.5640303243012
19.5576905341118
19.5380025365883
19.503009586584
19.4496114219081
19.3737958295773
19.2709428334617
19.1361813633914
18.9647730529273
18.7524940110866
18.4959839616113
18.1930338192903
17.842787903183
17.4458452446815
17.0042548219564
16.5214105175274
16.0018614545581
15.4510606469831
14.8750786818901
14.2803092432835
13.6731901710357
13.0599583946472
12.4464506538621
11.8379555109104
11.2391166045421
10.6538828816952

View File

@ -0,0 +1,201 @@
6.35230852280449
6.4508404083403
6.55032694040873
6.65073600052855
6.75203292053272
6.85418042559495
6.95713858264096
7.06086475482941
7.16531356281123
7.27043685349534
7.37618367706448
7.48250027299654
7.58933006585217
7.69661367158946
7.80428891515866
7.9122908601168
8.02055185097904
8.12900156899261
8.23756710197996
8.34617302884779
8.45474151929828
8.56319244921063
8.67144353207914
8.7794104668038
8.88700710202646
8.99414561709644
9.10073671962339
9.20668985944886
9.31191345872284
9.4163151576292
9.51980207514593
9.62228108406875
9.72365909936482
9.82384337875673
9.92274183427497
10.0202633533537
10.1163181278882
10.2108179895191
10.3036767492719
10.3948105395441
10.4841381563195
10.5715813993897
10.6570654082766
10.740518991493
10.8218749467367
10.9010703695959
10.9780469483554
11.0527512425267
11.1251349427846
11.1951551100819
11.2627743918266
11.3279612131427
11.3906899414002
11.4509410223839
11.508701086677
11.5639630250551
11.6167260319326
11.6669956161455
11.7147835786247
11.7601079567699
11.8029929356148
11.8434687261295
11.8815714112786
11.9173427607038
11.9508300151448
11.9820856419403
12.0111670631667
12.0381363581637
12.0630599423685
12.0860082245301
12.1070552445024
12.126278293915
12.1437575220962
12.1595755296775
12.1738169523319
12.1865680371067
12.1979162137912
12.2079496637226
12.2167568883724
12.2244262799889
12.2310456964749
12.2367020425831
12.2414808593984
12.2454659239598
12.2487388607456
12.2513787666209
12.2534618507152
12.2550610905695
12.2562459057626
12.257081850107
12.2576303233832
12.257948303467
12.2580880996032
12.2580971274749
12.2580177066298
12.2578868807377
12.2577362610823
12.2575918936138
12.2574741498309
12.257397641705
12.2573711608007
12.257397641705
12.2574741498309
12.2575918936137
12.2577362610824
12.2578868807377
12.2580177066298
12.2580971274749
12.2580880996032
12.257948303467
12.2576303233832
12.257081850107
12.2562459057626
12.2550610905695
12.2534618507152
12.2513787666209
12.2487388607456
12.2454659239598
12.2414808593984
12.2367020425831
12.2310456964749
12.2244262799889
12.2167568883724
12.2079496637226
12.1979162137912
12.1865680371067
12.1738169523319
12.1595755296775
12.1437575220962
12.126278293915
12.1070552445024
12.0860082245301
12.0630599423685
12.0381363581637
12.0111670631667
11.9820856419403
11.9508300151448
11.9173427607038
11.8815714112786
11.8434687261295
11.8029929356148
11.7601079567699
11.7147835786247
11.6669956161455
11.6167260319326
11.5639630250551
11.508701086677
11.4509410223839
11.3906899414002
11.3279612131427
11.2627743918267
11.1951551100818
11.1251349427846
11.0527512425267
10.9780469483554
10.9010703695959
10.8218749467367
10.740518991493
10.6570654082766
10.5715813993897
10.4841381563195
10.394810539544
10.303676749272
10.2108179895191
10.1163181278882
10.0202633533537
9.92274183427498
9.82384337875673
9.72365909936482
9.62228108406874
9.51980207514592
9.41631515762922
9.31191345872284
9.20668985944886
9.10073671962338
8.99414561709644
8.88700710202646
8.77941046680378
8.67144353207915
8.56319244921062
8.45474151929827
8.34617302884779
8.23756710197996
8.12900156899261
8.02055185097905
7.9122908601168
7.80428891515865
7.69661367158947
7.58933006585217
7.48250027299655
7.37618367706448
7.27043685349534
7.16531356281123
7.0608647548294
6.95713858264096
6.85418042559495
6.75203292053272
6.65073600052855
6.55032694040873
6.4508404083403
6.35230852280447

View File

@ -0,0 +1,51 @@
-4.62220979364239
-4.74863218780255
-4.84784741265534
-4.91588977139334
-4.94947398459438
-4.94621885573329
-4.90481363458011
-4.82510443951719
-4.7080884377943
-4.55581648023133
-4.37121773974612
-4.15786985177972
-3.91974320619201
-3.66094785676015
-3.38550680956306
-3.0971719531533
-2.7992906009947
-2.49472321949395
-2.18580745356457
-1.87436037319072
-1.56170973764641
-1.24874549123272
-0.935984066240782
-0.623639845575013
-0.311699938210173
3.06477065947774e-16
0.311699938210175
0.623639845575016
0.935984066240784
1.24874549123273
1.56170973764642
1.87436037319072
2.18580745356457
2.49472321949396
2.7992906009947
3.09717195315329
3.38550680956306
3.66094785676015
3.91974320619202
4.15786985177971
4.37121773974612
4.55581648023133
4.7080884377943
4.8251044395172
4.90481363458011
4.94621885573329
4.94947398459438
4.91588977139334
4.84784741265535
4.74863218780255
4.62220979364239

View File

@ -0,0 +1,51 @@
-5.05333952991992
-5.2710697587335
-5.4538224324177
-5.59176900495866
-5.67627228666901
-5.70088154813024
-5.66214168699473
-5.56003717220652
-5.39796618146884
-5.18225073408282
-4.92129699201981
-4.62458945768248
-4.30171384112198
-3.96156065061021
-3.61178911392315
-3.2585583414038
-2.90648100201777
-2.55873130299066
-2.21723908837497
-1.88291554820721
-1.55587406801886
-1.2356261677816
-0.921244732301142
-0.611494601598914
-0.304934960273855
1.29882216093336e-16
0.304934960273854
0.611494601598912
0.921244732301141
1.23562616778161
1.55587406801886
1.88291554820721
2.21723908837497
2.55873130299066
2.90648100201777
3.2585583414038
3.61178911392315
3.96156065061021
4.30171384112198
4.62458945768248
4.92129699201981
5.18225073408281
5.39796618146885
5.56003717220652
5.66214168699473
5.70088154813023
5.67627228666901
5.59176900495865
5.4538224324177
5.27106975873349
5.05333952991991

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 31 09:28:25 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
x = np.linspace(-10, 10, 3001)
z = np.linspace(-10, 10, 3001)
print(3001//2)
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 4, wire_height = 1, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
percentage = 0.05
absolut = 5
diff = percentage*0.01*5+ absolut *1e-3
print(diff)
Bz1, Bx = HH_Coil.B_multiple(5, x, z)
Bz2, Bx = HH_Coil.B_multiple(5+ diff, x, z)
print(Bz2[1500]-Bz1[1500])
print(" ")
percentage = 0 #.02
absolut = 2
diff = percentage*0.01*5+ absolut *1e-3
print(diff)
Bz2, Bx = HH_Coil.B_multiple(5+ diff, x, z)
print(Bz2[1500]-Bz1[1500])
print((Bz2[1500]-Bz1[1500])/Bz2[1500])
#Power = cs.rho_copper_20 *wire_length* I_current**2 /(self.get_wire_area())

View File

@ -0,0 +1,151 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-50, 50, 301)
z = np.linspace(-50, 50, 301)
I = 5
HH = 1
d_coils = 44
R_mid = 44
layers = 6
windings = 2
wire_width = 1.7
wire_height = 2.6
#reference coil
HH_Coil_44 = BC.BCoil(HH, 44 ,44, 6, 2, wire_width = 1.7, wire_height= 2.6)
#Coil from first sketch
HH_Coil_y = BC.BCoil(HH, 55.2 ,44, 6, 2, wire_width = 1.7, wire_height= 2.6)
B_z_y, B_x_y = HH_Coil_y.B_multiple(6.5,x,z)
B_z_y_curv = BC.BCoil.curv(B_z_y, z)
d_coils_2 = 55.2
#New coil
HH_Coil_54 = BC.BCoil(HH, 54 ,48.8, 4, 4, 1,1)
HH_Coil_54.cooling(5)
#Compensation Coil
HH_Coil_78 = BC.BCoil(1,54,37,4, 4, 1,1)
#HH_Coil_44.Bz_plot_HH(I,x,z)
#HH_Coil_44.Bz_plot_HH_comp(HH_Coil_54,I,x,z)
B_z, B_x = HH_Coil_44.B_multiple(I,x,z)
B_z_2, B_x_2 = HH_Coil_54.B_multiple(I,x,z)
B_z_3,B_x_3 = HH_Coil_78.B_multiple(-0.72,x,z)
B_z_curvature = np.gradient(np.gradient(B_z,z),z)*1e2
B_z_curvature_2 = BC.BCoil.curv(B_z_2, z)
B_z_curv_3 = BC.BCoil.curv(B_z_3, z)
B_tot = B_z_2 + B_z_3
B_tot_curv = BC.BCoil.curv(B_tot, z)
plt.figure(300)
plt.suptitle("Helmholtz coil field B_z along z-axis, comparison to field yesterday")
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z_y,linestyle = "solid", label = r"$B_{sketch}$, B-field according to current solidworks sketch, d = 55.2 mm, R = 44 mm, 6 x 2")
plt.plot(z,B_z_2,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_y_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{sketch}$, d = 55.2 mm, R = 44 mm, 6 x 2")
plt.plot(z,B_z_curvature_2,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_z_curv_3,linestyle = "solid", label = r"$\nabla_z^2 B_{z,2}$, d = 54 mm, R = 37 mm, I = -0.7 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend(loc='lower right')
plt.show()
plt.figure(200,figsize=(15,13))
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_z along z-axis")
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_{ref}$, reference, optimal HH-configuration d = 44 mm, R = 44 mm")
plt.plot(z,B_z_2,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
plt.plot(z,B_z_3,linestyle = "solid", label = r"$B_{z,2}$, d = 54 mm, R = 37 mm, I = -0.7 A, 4 x 4")
plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,B_z_curvature,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
plt.plot(z,B_z_curvature_2,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
plt.plot(z,B_z_curv_3,linestyle = "solid", label = r"$\nabla_z^2 B_{z,2}$, d = 54 mm, R = 37 mm, I = -0.7 A")
plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
plt.close()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

View File

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-50, 50, 300)
z = np.linspace(-50, 50, 301)
HH_Coil_78 = BC.BCoil(-1,54,37,4, 4, 1,1)
B_z,B_x = HH_Coil_78.B_multiple(1,x,z)
#B_x = np.concatenate((-np.flip(B_x),B_x))
#x = np.concatenate((-np.flip(r),r))
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
#plt.rcParams.update({'font.size': 15})
plt.suptitle("Anti Helmholtz coil field, I = 1 A, d = 54 mm, R = 37 mm ", fontsize = 30)
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_z$, d = 54 mm, R = 37 mm")
plt.plot(x,B_x, label = r"$B_x$, d = 54 mm, R = 37 mm")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z B_z$, d = 54 mm, R = 37 mm")
plt.plot(x,B_x_grad,linestyle = "solid", label = r"$\nabla_x B_x$, d = 54 mm, R = 37 mm")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()
plt.show()

View File

@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 24 16:24:52 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
x = np.linspace(-1, 1, 11)
z = np.linspace(-1, 1, 11)
I_current = 5*16
HH_Coil = HH_Coil_comp = BC.BCoil(HH = 1, distance = 54 ,radius = 37,layers = 1, windings = 1,wire_width = 8, wire_height = 8)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 50)
Bz_curv = BC.BCoil.curv(Bz, z)
HH_Coil.cooling(I_current,30)
print(f"B_z(0) = {Bz[1]:.2f} G")
print(f"B_z_curvature(0) = {Bz_curv[1]:.4f} G/cm^2")
B = []
Curv = []
array_width = np.arange(0.2,11,0.1)
#array_width = [5.7]
for width in array_width:
height = 20/width
HH_Coil = HH_Coil_comp = BC.BCoil(HH = 1, distance = 54 ,radius = 37,layers = 1, windings = 1,wire_width = width, wire_height = height)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
#HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 30)
Bz_curv = BC.BCoil.curv(Bz, z)
HH_Coil.cooling(I_current,30)
B.append(Bz[5])
Curv.append(Bz_curv[5])
print(f"width = {width}mm, height = {height}mm")
print(f"B_z(0) = {Bz[5]:.2f} G")
print(f"B_z_curvature(0) = {Bz_curv[5]:.4f} G/cm^2")
plt.plot(array_width,Curv)
#plt.plot(array_width,B)
plt.ylabel("curvature")
plt.xlabel("total width [mm]")
plt.show()

View File

@ -0,0 +1,120 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-15, 15, 30000)
z = np.linspace(-15, 15, 30000)
#New coil
I_current = 5
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 4, wire_height = 1, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
Bz_curv = BC.BCoil.curv(Bz, z)
HH_Coil.cooling(I_current)
print(f"B_z(0) = {Bz[150]:.2f} G")
print(f"B_z_curvature(0) = {Bz_curv[150]:.4f} G/cm^2")
print(x[500])
# I_current = 5*16
# HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 1, windings = 1, wire_height = 10, wire_width = 6)
# HH_Coil.set_R_outer(49.3)
# HH_Coil.set_d_min(49.8)
# HH_Coil.print_info()
# Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 50)
# Bz_curv = BC.BCoil.curv(Bz, z)
# HH_Coil.cooling(I_current)
# print(f"B_z(0) = {Bz[150]:.2f} G")
# print(f"B_z_curvature(0) = {Bz_curv[150]:.4f} G/cm^2")
#Compensation Coil
HH_Coil_comp = BC.BCoil(HH = 1, distance = 54 ,radius = 37, layers = 4, windings = 4,wire_height = 1, wire_width = 1)
#HH_Coil_44.Bz_plot_HH(I,x,z)
#HH_Coil_44.Bz_plot_HH_comp(HH_Coil_54,I,x,z)
I_HH = 5
I_comp = -1.4
#calculate field
B_z, B_x = HH_Coil.B_multiple(I_HH,x,z)
B_z_comp,B_x_comp = HH_Coil_comp.B_multiple(I_comp,x,z)
#Calculate curvature
B_z_curv = BC.BCoil.curv(B_z, z)
B_z_comp_curv = BC.BCoil.curv(B_z_comp, z)
B_tot = B_z + B_z_comp
B_tot_curv = BC.BCoil.curv(B_tot, z)
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_{ref}$, reference, optimal HH-configuration d = 44 mm, R = 44 mm")
plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,B_z_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

View File

@ -0,0 +1,94 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-50, 50, 301)
z = np.linspace(-50, 50, 301)
AHH_Coil = BC.BCoil(-1,54,37,4, 4, 1,1)
AHH_Coil.set_R_outer(49.3)
#AHH_Coil.print_info()
#B_z,B_x = AHH_Coil.B_multiple(1,x,z)
#B_z_grad = BC.BCoil.Bgrad(B_z, z)
#B_x_grad = BC.BCoil.Bgrad(B_x,x)
plt.figure(1,figsize=(10,13))
#plt.rcParams.update({'font.size': 15})
plt.suptitle("Anti Helmholtz coil field, I = 2 A, d = 82 mm, R_inner = 46.3 mm ", fontsize = 13)
#Field plot
##########################
d=82
AHH_Coil = BC.BCoil(-1,d,47.3,4, 4, 1,1)
#AHH_Coil.set_R_outer(49.3)
AHH_Coil.print_info()
#B = AHH_Coil.B_multiple_3d(10, x,z,raster=2)
AHH_Coil.cooling(10)
B_z,B_x = AHH_Coil.B_multiple(10,x,z)
#B_z = B[:,150,1]
#B_x = B[150,:,0]
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = f"$B_z$, d = {d} mm")
plt.plot(x,B_x, label = f"$B_x$, d = {d} mm")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
#plt.ylim(-0.5,0.4)
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z B_z$")
plt.plot(x,B_x_grad,linestyle = "solid", label = r"$\nabla_x B_x$")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()
plt.savefig("output/AHH_field.pdf")
plt.show()
#AHH_Coil.plot_3d(2, 80, 80)
"""
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")
print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")
"""

View File

@ -0,0 +1,114 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
axis = 30001 #30001 for -15 to 15 = 1μm
x = np.linspace(-15, 15, axis)
z = np.linspace(-15, 15, axis)
#New coil
I_current = 5
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 4, wire_height = 1, wire_width = 1, windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
#Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
B_tot_z, B_tot_x = HH_Coil.B_tot_along_axis(I_current, x, z,raster = 8)
Bz_curv = BC.BCoil.curv(B_tot_z, z)
Bx_curv = BC.BCoil.curv(B_tot_x, x)
HH_Coil.cooling(I_current,25)
B_0 = B_tot_z[axis//2]
print(f"B_tot(0,0) = {B_0} G")
print(f"B_tot_x = {B_tot_x[15000]}")
print(f"B_z_curvature(0) = {Bz_curv[axis//2]:.5f} G/cm^2")
print(f"B_x_curvature(0) = {Bx_curv[axis//2]:.5f} G/cm^2")
print("")
print("Differences along z-axis:")
print(f"B_tot_z(1 μm) = {B_tot_z[15001]}")
print(f"B_tot_z(1 mm) = {B_tot_z[16000]}")
print(f"Diff B 1 μm: {B_tot_z[15001] - B_0}, relative: {(B_tot_z[15001] - B_0)/B_0}")
print(f"Diff B 1 mm: {B_tot_z[16000] - B_0}, relative: {(B_tot_z[16000] - B_0)/B_0}")
print(f"Diff B 0.5 mm: {B_tot_z[15500] - B_0}, relative: {(B_tot_z[15500] - B_0)/B_0}")
print(" ")
print("Differences along x-axis:")
print(f"B_tot_x(1 μm) = {B_tot_x[15001]}")
print(f"B_tot_x(1 mm) = {B_tot_x[16000]}")
print(f"Diff B 1 μm: {B_tot_x[15001] - B_0}, relative: {(B_tot_x[15001] - B_0)/B_0}")
print(f"Diff B 1 mm: {B_tot_x[16000] - B_0}, relative: {(B_tot_x[16000] - B_0)/B_0}")
print(f"Diff B 0.5 mm: {B_tot_x[15500] - B_0}, relative: {(B_tot_x[15500] - B_0)/B_0}")
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
#plt.plot(z,B_totz,linestyle = "solid", label = r"$B_z along z-axis")
#plt.plot(x,Bx,label = "B_x along x")
plt.plot(z,B_tot_z, label = "New B_tot along z-axis")
plt.plot(x,B_tot_x, label = "B_tot along x-axis")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,Bz_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
plt.plot(x,Bx_curv,label = "B_x_curv")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

View File

@ -0,0 +1,86 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-50, 50, 3001)
z = np.linspace(-50, 50, 3001)
#New coil
I_current = 5
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 4, wire_height = 1, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
Bz_curv = BC.BCoil.curv(Bz, z)
HH_Coil.cooling(I_current)
I_HH = 5
#calculate field
B_z, B_x = HH_Coil.B_multiple(I_HH,x,z)
#Calculate curvature
B_z_curv = BC.BCoil.curv(B_z, z)
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_{ref}$, reference, optimal HH-configuration d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,B_z_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

View File

@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.arange(-50, 50, 0.5)
print(len(x)//2)
z = np.arange(-50, 50, 0.5)
#New coil
I_current = 5
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 4, wire_height = 1, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 4)
Bz_curv = BC.BCoil.curv(Bz, z)
B = HH_Coil.B_multiple_3d(I_current, x, z,raster = 2)
B_tot = BC.BCoil.B_tot_3d(B)
HH_Coil.cooling(I_current)
HH_Coil.plot_3d(I_current, 80, 80)
"""
print(f"B_z(0) = {Bz[15000]} G")
print(f"B_z_curvature(0) = {Bz_curv[15000]:.4f} G/cm^2")
print(f"B_z(1 μm) = {Bz[15001]}")
print(f"B_z(1 mm) = {Bz[16000]}")
print(f"Diff B 1 μm: {Bz[15001] - Bz[15000]}, relative: {(Bz[15001] - Bz[15000])/Bz[15000]}")
print(f"Diff B 1 mm: {Bz[16000] - Bz[15000]}, relative: {(Bz[16000] - Bz[15000])/Bz[15000]}")
"""
I_HH = 5
#calculate field
B_z, B_x = HH_Coil.B_multiple(I_HH,x,z)
#Calculate curvature
B_z_curv = BC.BCoil.curv(B_z, z)
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_{ref}$, reference, optimal HH-configuration d = 44 mm, R = 44 mm")
plt.plot(z,B_tot[:,len(x)//2], label = "B_tot_z")
plt.plot(x,B_x,label = "B_x")
plt.plot(x,B_tot[len(z)//2,:],label = "B_tot_x")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,B_z_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

View File

@ -0,0 +1,102 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-15, 15, 30001)
z = np.linspace(-15, 15, 30001)
#New coil
I_current = 10
HH_Coil = BC.BCoil(HH = 1, distance = 70 ,radius = 40.5 , layers = 1, windings = 1, wire_height = 1, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_inner(40.5)
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
Bz_curv = BC.BCoil.curv(Bz, z)
HH_Coil.cooling(I_current)
print(f"B_z(0) = {Bz[15000]} G")
print(f"B_z_curvature(0) = {Bz_curv[15000]:.4f} G/cm^2")
print(f"B_z(1 μm) = {Bz[15001]}")
print(f"B_z(1 mm) = {Bz[16000]}")
print(f"Diff B 1 μm: {Bz[15001] - Bz[15000]}, relative: {(Bz[15001] - Bz[15000])/Bz[15000]}")
print(f"Diff B 1 mm: {Bz[16000] - Bz[15000]}, relative: {(Bz[16000] - Bz[15000])/Bz[15000]}")
print(f"Diff B 0.5 mm: {Bz[15500] - Bz[15000]}, relative: {(Bz[15500] - Bz[15000])/Bz[15000]}")
I_HH = 5
#calculate field
B_z, B_x = HH_Coil.B_multiple(I_HH,x,z)
#Calculate curvature
B_z_curv = BC.BCoil.curv(B_z, z)
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_{ref}$, reference, optimal HH-configuration d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,B_z_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

View File

@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-15, 15, 30001)
z = np.linspace(-15, 15, 30001)
#New coil
I_current = 10
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 2, wire_height = 2, wire_width = 1, windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_inner(44.5)
HH_Coil.set_d_min(48.8)
print(f"height = {HH_Coil.get_coil_height()}")
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
B_tot_z, B_tot_x = HH_Coil.B_multiple(I_current, x, z,raster = 10)
Bz_curv = BC.BCoil.curv(Bz, z)
HH_Coil.cooling(I_current,28)
print(f"B_z(0) = {Bz[15000]} G")
print(f"B_z_curvature(0) = {Bz_curv[15000]:.10f} G/cm^2")
print(f"B_z(1 μm) = {Bz[15001]}")
print(f"B_z(1 mm) = {Bz[16000]}")
print(f"Diff B 1 μm: {Bz[15001] - Bz[15000]}, relative: {(Bz[15001] - Bz[15000])/Bz[15000]}")
print(f"Diff B 1 mm: {Bz[16000] - Bz[15000]}, relative: {(Bz[16000] - Bz[15000])/Bz[15000]}")
print(f"Diff B 0.5 mm: {Bz[15500] - Bz[15000]}, relative: {(Bz[15500] - Bz[15000])/Bz[15000]}")
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,Bz,linestyle = "solid", label = r"$B_z along z-axis")
plt.plot(z,B_tot_z, linestyle = "dashed", label = "New B_tot along z-axis")
#plt.plot(x,B_tot_x, label = "B_tot along x-axis")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,Bz_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

View File

@ -0,0 +1,89 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
axis = 3001 #30001 for -15 to 15 = 1μm
x = np.linspace(-5, 5, axis)
z = np.linspace(-5, 5, axis)
#New coil
I_current = 10
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 2, wire_height = 2, wire_width = 1, windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_inner(44.5)
HH_Coil.set_d_min(48.8)
print(HH_Coil.resistance(22))
print(HH_Coil.induct_perry())
HH_Coil.print_info()
#Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
B_tot_z, B_tot_x = HH_Coil.B_tot_along_axis(I_current, x, z,raster = 8)
Bz_curv = BC.BCoil.curv(B_tot_z, z)
Bx_curv = BC.BCoil.curv(B_tot_x, x)
B_0 = B_tot_z[axis//2]
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
#plt.plot(z,B_totz,linestyle = "solid", label = r"$B_z along z-axis")
#plt.plot(x,Bx,label = "B_x along x")
plt.plot(z,B_tot_z, label = r"$B_{{tot}}$ along z-axis")
plt.plot(x,B_tot_x, label = r"$B_{{tot}}$ along x-axis")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B$ [G]")
plt.xlabel("z / x -axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,Bz_curv,linestyle = "solid", label = r"$B_{curvature}$ along z-axis")
plt.plot(x,Bx_curv,label = r"$B_{curvature}$ along x-axis")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_{z,x}^2 B_tot [G/cm^2]$")
plt.xlabel("z / x -axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

View File

@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 31 09:28:25 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
print(10/2.7)
x = np.linspace(-10, 10, 3001)
z = np.linspace(-10, 10, 3001)
print(3001//2)
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 4, wire_height = 1, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
percentage = 0.05
absolut = 5
diff = percentage*0.01*5+ absolut *1e-3
print(diff)
Bz1, Bx = HH_Coil.B_multiple(5, x, z)
Bz2, Bx = HH_Coil.B_multiple(5+ diff, x, z)
print(Bz2[1500]-Bz1[1500])
print(" ")
percentage = 0 #.02
absolut = 2
diff = percentage*0.01*5+ absolut *1e-3
print(diff)
Bz2, Bx = HH_Coil.B_multiple(5+ diff, x, z)
print(Bz2[1500]-Bz1[1500])
print((Bz2[1500]-Bz1[1500])/Bz2[1500])
#Power = cs.rho_copper_20 *wire_length* I_current**2 /(self.get_wire_area())

View File

@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-50, 50, 10001)
z = np.linspace(-50, 50, 10001)
d=82
AHH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 47.3 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
AHH_Coil.set_R_inner(44.5)
print(f"height = {AHH_Coil.get_coil_height()*1e3}mm")
#AHH_Coil.set_R_outer(49.3)
I = 10
AHH_Coil.print_info()
R = AHH_Coil.resistance(30)
print(f"R = {R} ")
#B = AHH_Coil.B_multiple_3d(10, x,z,raster=2)
AHH_Coil.cooling(I,30)
B_z,B_x = AHH_Coil.B_multiple(I,x,z)
#B_z = B[:,150,1]
#B_x = B[150,:,0]
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
lim = 7000
B_0 = B_z_grad[5000]
print((B_0- B_z_grad[6700]))
print((B_0- B_z_grad[6700])/B_0)
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = f"$B_z$, d = {d} mm")
plt.plot(z,B_tot_z, label = "B_tot_z")
plt.plot(x,B_x, label = f"$B_x$, d = {d} mm")
plt.plot(z,B_tot_x, label = "B_tot_x")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
#plt.ylim(-0.5,0.4)
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z B_z$")
plt.plot(x,B_x_grad,linestyle = "solid", label = r"$\nabla_x B_x$")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()
plt.savefig("output/AHH_field.pdf")
plt.show()
#AHH_Coil.plot_3d(I, 80, 80)
#print(B_z_grad[1500])
#print(2*B_x_grad[1500])
"""
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")
print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")
"""

View File

@ -0,0 +1,130 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-50, 50, 1001)
z = np.linspace(-50, 50, 1001)
#Field plot
##########################
d=82
AHH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
AHH_Coil.set_R_inner(44.5)
I = 10
AHH_Coil.print_info()
R = AHH_Coil.resistance(30)
print(f"R = {R} ")
#B = AHH_Coil.B_multiple_3d(10, x,z,raster=2)
AHH_Coil.cooling(I,30)
B_z,B_x = AHH_Coil.B_multiple(I,x,z)
#B_z = B[:,150,1]
#B_x = B[150,:,0]
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
# lim = 7000
# B_0 = B_z_grad[5000]
# print((B_0- B_z_grad[6700]))
# print((B_0- B_z_grad[6700])/B_0)
distance = np.arange(80,95,2)
for d in distance:
print(d)
AHH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
B_z,B_x = AHH_Coil.B_multiple(I,x,z)
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
B_z_curv = BC.BCoil.Bgrad(B_z_grad, z)
B_x_curv = BC.BCoil.Bgrad(B_z_grad, z)
B_z_3rd = BC.BCoil.Bgrad(B_z_curv, z)
B_x_3rd = BC.BCoil.Bgrad(B_z_curv, z)
plt.subplot(2,2,1)
plt.plot(z,B_z,linestyle = "solid", label = f"d = {d} mm")
#plt.plot(x,B_x, label = f"$B_x$, d = {d} mm")
plt.title("B-field" )
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,2,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = f"$d = {d} mm")
#plt.plot(x,B_x_grad,linestyle = "solid", label = f"$Grad_x B_x$, d = {d} mm")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()
plt.subplot(2,2,3)
plt.title("Curvature")
plt.plot(z,B_z_curv,linestyle = "solid", label = f"$ d = {d} mm")
#plt.plot(x,B_x_curv, label = f"Curv. $B_x$, d = {d} mm")
plt.title("B-field" )
plt.ylabel(r"$B$ [G/cm^2]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,2,4)
plt.title("3rd derivative")
plt.plot(z,B_z_3rd,linestyle = "dashed", label = f"d = {d} mm")
plt.plot(x,B_x_3rd, label = f"3rd der. $B_x$, d = {d} mm")
plt.ylabel(r"$B$ [G/cm^3]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
#plt.savefig("output/AHH_field.pdf")
plt.show()
#AHH_Coil.plot_3d(I, 80, 80)
#print(B_z_grad[1500])
#print(2*B_x_grad[1500])
"""
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")
print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")
"""

View File

@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
res = 1001
zr = res//2
x = np.linspace(-5, 5, res)
z = np.linspace(-5, 5, res)
#Field plot
##########################
I = 10
AHH_Coil = BC.BCoil(HH = -1, distance = 81.8 ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
AHH_Coil.print_info()
AHH_Coil.cooling(I, 30)
print(f"R (30 degree C)= {AHH_Coil.resistance(30)}")
B_z,B_x = AHH_Coil.B_multiple(I,x,z)
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
B_z_curv = BC.BCoil.Bgrad(B_z_grad, z)
B_x_curv = BC.BCoil.Bgrad(B_z_grad, z)
B_z_3rd = BC.BCoil.Bgrad(B_z_curv, z)
B_x_3rd = BC.BCoil.Bgrad(B_z_curv, z)
"""
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")
print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")
"""

View File

@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
#set up axis
x = np.linspace(-50, 50, 10001)
z = np.linspace(-50, 50, 10001)
d=81.8
AHH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
print(AHH_Coil.power(10, 25))
h =AHH_Coil.get_coil_height()
w = AHH_Coil.get_coil_width()
vert_surf = h * 46.875*1e-3 *2 *np.pi
hor_surf = np.pi*(AHH_Coil.get_R_outer()**2-AHH_Coil.get_R_inner()**2)
tot = 2*vert_surf + 2*hor_surf
print(f"Surface area = {tot}")
print(AHH_Coil.get_coil_height())
print(AHH_Coil.get_coil_width())
I = 10
AHH_Coil.print_info()
R = AHH_Coil.resistance(30)
print(f"R = {R} ")
#B = AHH_Coil.B_multiple_3d(10, x,z,raster=2)
AHH_Coil.cooling(I,30)
B_z,B_x = AHH_Coil.B_multiple(I,x,z)
#B_z = B[:,150,1]
#B_x = B[150,:,0]
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
lim = 7000
B_0 = B_z_grad[5000]
print((B_0- B_z_grad[6700]))
print((B_0- B_z_grad[6700])/B_0)
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = f"$B_z$, d = {d} mm")
#plt.plot(z,B_tot_z, label = "B_tot_z")
plt.plot(x,B_x, label = f"$B_x$, d = {d} mm")
#plt.plot(z,B_tot_x, label = "B_tot_x")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
#plt.ylim(-0.5,0.4)
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z B_z$")
plt.plot(x,B_x_grad,linestyle = "solid", label = r"$\nabla_x B_x$")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()
plt.savefig("output/AHH_field.pdf")
plt.show()
#AHH_Coil.plot_3d(I, 80, 80)
#print(B_z_grad[1500])
#print(2*B_x_grad[1500])
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")
print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")

View File

@ -0,0 +1,133 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
#set up axis
lim = 10001
zr = lim//2
x = np.linspace(-50, 50, lim)
z = np.linspace(-50, 50, lim)
d_opt=81.8
d_comp = 69.4
AHH_opt = BC.BCoil(HH = -1, distance = d_opt ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
AHH_opt = BC.BCoil(HH = -1, distance = d_opt ,radius = 46.875 ,layers = 8, windings = 2 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
AHH_opt.set_R_outer(49.25)
AHH_comp = BC.BCoil(HH = -1, distance = d_comp ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
I = 10
print("Optimum configuration:")
AHH_opt.print_info()
print("Not cutting optical axis:")
AHH_comp.print_info()
Bz_opt, Bx_opt = AHH_opt.B_multiple(I,x,z)
Bz_comp, Bx_comp = AHH_comp.B_multiple(I, x, z)
#B_z = B[:,150,1]
#B_x = B[150,:,0]
#B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
Bz_grad_opt = BC.BCoil.Bgrad(Bz_opt, z)
Bx_grad_opt = BC.BCoil.Bgrad(Bx_opt,x)
Bz_grad_comp = BC.BCoil.Bgrad(Bz_comp, z)
Bx_grad_comp = BC.BCoil.Bgrad(Bx_comp,x)
Bz_rel_opt = (Bz_grad_opt[zr]- Bz_grad_opt)/Bz_grad_opt[zr]*100
Bx_rel_opt = (Bx_grad_opt[zr]- Bx_grad_opt)/Bx_grad_opt[zr]*100
Bz_rel_comp = (Bz_grad_comp[zr]- Bz_grad_comp)/Bz_grad_comp[zr]*100
Bx_rel_comp = (Bx_grad_comp[zr]- Bx_grad_comp)/Bx_grad_comp[zr]*100
plt.figure(figsize = (10,30))
plt.tight_layout()
plt.subplot(3,1,1)
plt.plot(z,Bz_opt,linestyle = "solid", color = "orange", label = f"$B_z$, d = {d_opt} mm")
plt.plot(z,Bz_comp,linestyle = "solid",color = "blue", label = f"$B_z$, d = {d_comp} mm")
plt.plot(x,Bx_opt, linestyle = "dashed", color = "orange", label = f"$B_x$, d = {d_opt} mm")
plt.plot(x,Bx_comp,linestyle = "dashed", color = "blue", label = f"$B_x$, d = {d_comp} mm")
#plt.plot(z,B_tot_x, label = "B_tot_x")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(3,1,2)
plt.plot(z,Bz_grad_opt,linestyle = "solid", color = "orange",label = f"$B_z$, d = {d_opt} mm")
plt.plot(z,Bz_grad_comp,linestyle = "solid",color = "blue", label = f"$B_z$, d = {d_comp} mm")
plt.plot(x,Bx_grad_opt,linestyle = "dashed",color = "orange", label = f"$B_x$, d = {d_opt} mm")
plt.plot(x,Bx_grad_comp, linestyle = "dashed",color = "blue", label = f"$B_x$, d = {d_comp} mm")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
#plt.title("Gradient of B-field")
plt.legend()
plt.subplot(3,1,3)
plt.plot(z,Bz_rel_opt,linestyle = "solid", color = "orange",label = f"$B_z$, d = {d_opt} mm")
plt.plot(z,Bz_rel_comp,linestyle = "solid",color = "blue", label = f"$B_z$, d = {d_comp} mm")
plt.plot(x,Bx_rel_opt,linestyle = "dashed",color = "orange", label = f"$B_x$, d = {d_opt} mm")
plt.plot(x,Bx_rel_comp, linestyle = "dashed",color = "blue", label = f"$B_x$, d = {d_comp} mm")
plt.ylabel(r"rel. Deviation from Grad to center [%]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
#plt.title(r"$\nabla_i B_i")
#plt.ylim(-0.05,0.05)
plt.xlim(-10,10)
plt.legend()
plt.savefig("output/AHH_field.pdf")
plt.show()
print("")
print(" 10 μm")
print(f"Optimum: Dev. of gradient (z) +- 10μm to center: {Bz_rel_opt[zr+1]:.8f} %")
print(f"Not cutting opt. axis: Dev. of gradient (z) +- 10μm to center: {Bz_rel_comp[zr+1]:.8f} %")
print("")
print(" 1mm ")
print(f"Optimum: Dev. of gradient (z) +- 1 mm to center: {Bz_rel_opt[zr+100]:.6f} %")
print(f"Not cutting opt. axis: Dev. of gradient (z) +- 1 mm to center: {Bz_rel_comp[zr+100]:.3f} %")
print("")
print(" 10mm ")
print(f"Optimum: Dev. of gradient (z) +- to center: {Bz_rel_opt[zr+1000]:.2f} %")
print(f"Not cutting opt. axis: Dev. of gradient (z) to center: {Bz_rel_comp[zr+1000]:.2f} %")
print("")
print(" 17mm ")
print(f"Optimum: Dev. of gradient (z) +- 1 mm to center: {Bz_rel_opt[zr+1700]:.2f} %")
print(f"Not cutting opt. axis: Dev. of gradient (z) +- 1 mm to center: {Bz_rel_comp[zr+1700]:.2f} %")

View File

@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
#set up axis
x = np.linspace(-50, 50, 10001)
z = np.linspace(-50, 50, 10001)
d=81.8
AHH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
h =AHH_Coil.get_coil_height()
w = AHH_Coil.get_coil_width()
vert_surf = h * 46.875*1e-3 *2 *np.pi
hor_surf = np.pi*(AHH_Coil.get_R_outer()**2-AHH_Coil.get_R_inner()**2)
tot = 2*vert_surf + 2*hor_surf
print(f"Surface area = {tot}")
print(AHH_Coil.get_coil_height())
print(AHH_Coil.get_coil_width())
I = 10
AHH_Coil.print_info()
R = AHH_Coil.resistance(30)
print(f"R = {R} ")
#B = AHH_Coil.B_multiple_3d(10, x,z,raster=2)
AHH_Coil.cooling(I,30)
B_z,B_x = AHH_Coil.B_multiple(I,x,z)
#B_z = B[:,150,1]
#B_x = B[150,:,0]
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
lim = 7000
B_0 = B_z_grad[5000]
print((B_0- B_z_grad[6700]))
print((B_0- B_z_grad[6700])/B_0)
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = f"$B_z$, d = {d} mm")
#plt.plot(z,B_tot_z, label = "B_tot_z")
plt.plot(x,B_x, label = f"$B_x$, d = {d} mm")
#plt.plot(z,B_tot_x, label = "B_tot_x")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
#plt.ylim(-0.5,0.4)
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z B_z$")
plt.plot(x,B_x_grad,linestyle = "solid", label = r"$\nabla_x B_x$")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()
plt.savefig("output/AHH_field.pdf")
plt.show()
#AHH_Coil.plot_3d(I, 80, 80)
#print(B_z_grad[1500])
#print(2*B_x_grad[1500])
"""
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")
print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")
"""

View File

@ -0,0 +1,107 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
#set up axis
x = np.linspace(-5, 5, 10001)
z = np.linspace(-5, 5, 10001)
d=69.4
AHH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
print(AHH_Coil.power(10, 25))
h =AHH_Coil.get_coil_height()
w = AHH_Coil.get_coil_width()
vert_surf = h * 46.875*1e-3 *2 *np.pi
hor_surf = np.pi*(AHH_Coil.get_R_outer()**2-AHH_Coil.get_R_inner()**2)
tot = 2*vert_surf + 2*hor_surf
print(f"Surface area = {tot}")
print(AHH_Coil.get_coil_height())
print(AHH_Coil.get_coil_width())
I = 10
AHH_Coil.print_info()
R = AHH_Coil.resistance(30)
print(f"R = {R} ")
#B = AHH_Coil.B_multiple_3d(10, x,z,raster=2)
AHH_Coil.cooling(I,30)
B_z,B_x = AHH_Coil.B_multiple(I,x,z)
#B_z = B[:,150,1]
#B_x = B[150,:,0]
B_tot_z, B_tot_x = AHH_Coil.B_tot_along_axis(I, x, z)
B_z_grad = BC.BCoil.Bgrad(B_z, z)
B_x_grad = BC.BCoil.Bgrad(B_x,x)
lim = 7000
B_0 = B_z_grad[5000]
print((B_0- B_z_grad[6700]))
print((B_0- B_z_grad[6700])/B_0)
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_{{tot}}$ along z-axis")
#plt.plot(z,B_tot_z, label = "B_tot_z")
plt.plot(x,B_x, label = r"$B_{{tot}}$ along x-axis")
#plt.plot(z,B_tot_x, label = "B_tot_x")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
#plt.ylim(-0.5,0.4)
plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z B_{tot}$ along z-axis")
plt.plot(x,B_x_grad,linestyle = "solid", label = r"$\nabla_x B_{tot}$ along x-axis")
plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()
plt.savefig("output/AHH_field.pdf")
plt.show()
#AHH_Coil.plot_3d(I, 80, 80)
#print(B_z_grad[1500])
#print(2*B_x_grad[1500])
"""
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")
print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")
"""
print(AHH_Coil.resistance(22))
print(AHH_Coil.induct_perry())
print(AHH_Coil.power(10, 22))

View File

@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-20, 20, 40001)
z = np.linspace(-20, 20, 40001)
#New coil
I_current = 10
d=69.4
HH_Coil = BC.BCoil(HH = -1, distance = d ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
B_tot_z, B_tot_x = HH_Coil.B_multiple(I_current, x, z,raster = 10)
Bz = BC.BCoil.Bgrad(Bz, z)
HH_Coil.cooling(I_current,28)
print(f"B_z(0) = {Bz[15000]} G")
#print(f"B_z_curvature(0) = {Bz_curv[15000]:.10f} G/cm^2")
print(f"B_z(1 μm) = {Bz[15001]}")
print(f"B_z(1 mm) = {Bz[16000]}")
print(f"Diff B 1 μm: {Bz[15001] - Bz[15000]}, relative: {(Bz[15001] - Bz[15000])/Bz[15000]}")
print(f"Diff B 0.5 mm: {Bz[15500] - Bz[15000]}, relative: {(Bz[15500] - Bz[15000])/Bz[15000]}")
print(f"Diff B 1 mm: {Bz[25000] - Bz[15000]}, relative: {(Bz[25000] - Bz[15000])/Bz[15000]}")
print(f"Diff B 1 mm: {Bz[32000] - Bz[15000]}, relative: {(Bz[32000] - Bz[15000])/Bz[15000]}")
print(z[32000])
print(z[15000])
plt.figure(300)
"""
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,Bz,linestyle = "solid", label = r"$B_z along z-axis")
plt.plot(z,B_tot_z, linestyle = "dashed", label = "New B_tot along z-axis")
#plt.plot(x,B_tot_x, label = "B_tot along x-axis")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,Bz_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

View File

@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 20 11:41:53 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from src import physical_constants as cs
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up constants
#h_air =10 #Heat transfer with air W/m^2 K
e_cu = 3e-2 #emissivity copper, polished
rho_cu = 1.7*1e-8
I = 10 #A
#set up axis
x = np.linspace(-50, 50, 10001)
z = np.linspace(-50, 50, 10001)
AHH_opt = BC.BCoil(HH = -1, distance = 81.8 ,radius = 46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
h = AHH_opt.get_coil_height()
w = AHH_opt.get_coil_width()
print(h)
print(w)
vert_surf = h * AHH_opt.radius * 2 *np.pi
hor_surf = np.pi*(AHH_opt.get_R_outer()**2-AHH_opt.get_R_inner()**2)
S_coil = 2*vert_surf + 2*hor_surf
#S_coil = S_coil/2
print(f"Surface area = {S_coil}")
def power_bal(T,h_air):
T_0 = 22.5
f = h_air * S_coil *(T-T_0) - 0.5*AHH_opt.power(I, T)
return f
print(e_cu * S_coil * cs.sigma_B**4 * (50**4 - 22.5**4))
T = np.linspace(20,120,500)
T_calc = np.linspace(20,2200,1000)
for h_air in [2.5,10,25]:
pos_min = np.argmin(np.abs(power_bal(T_calc,h_air)))
T_SS = T_calc[pos_min]
print(f"T_ss = {T_SS} °C")
plt.plot(T,power_bal(T,h_air),label = f"$h_{{air}} = {h_air} \; W/m^2 K$ , $T_{{SS}}$ = {T_SS:.2f}°C")
plt.ylabel("Power balance [W]")
plt.xlabel("temparature [°C]")
plt.title(f"Power balance, free convection, AHH coil, I = {I} A, windings: 4 x 4")
plt.legend()
plt.show()
print(AHH_opt.power(I, 25)/2)

View File

@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 20 18:01:04 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from src import physical_constants as cs
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
AHH_opt = BC.BCoil(HH = 1, distance = 70, radius = 60, layers = 2, windings = 10, wire_height = 1, wire_width = np.pi/4)
I = 5
AHH_opt.cooling(I, 36)
print(f"res = {AHH_opt.resistance(36)/2:.2f} Ohm")
h = AHH_opt.get_coil_height()
w = AHH_opt.get_coil_width()
vert_surf = h * AHH_opt.radius * 2 *np.pi
hor_surf = np.pi*(AHH_opt.get_R_outer()**2-AHH_opt.get_R_inner()**2)
S_coil = 2*vert_surf + 2*hor_surf #+5e-3
#S_coil = S_coil/2
print(f"Surface area = {S_coil}")
def power_bal(T,h_air):
T_0 = 22.5
f = h_air * S_coil *(T-T_0) - 0.5*AHH_opt.power(I, T)
return f
#print(e_cu * S_coil * cs.sigma_B**4 * (50**4 - 22.5**4))
T = np.linspace(20,120,500)
T_calc = np.linspace(20,2200,1000)
for h_air in [2.5,10,25]:
pos_min = np.argmin(np.abs(power_bal(T_calc,h_air)))
T_SS = T_calc[pos_min]
print(f"T_ss = {T_SS} °C")
plt.plot(T,power_bal(T,h_air),label = f"$h_{{air}} = {h_air} \; W/m^2 K$ , $T_{{SS}}$ = {T_SS:.2f}°C")
plt.ylabel("Power balance [W]")
plt.xlabel("temparature [°C]")
plt.title(f"Power balance, free convection, Weidemüller Coil, I = {I} A, windings: 2 x 10")
plt.legend()
plt.show()
print(AHH_opt.power(I, 940)/2)

View File

@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import physical_constants as cs
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x_m = np.linspace(-0.05, 0.05, 51)
z_m = np.linspace(-0.05, 0.05, 201)
z = z_m*1e3
x = x_m*1e3 #for plotting in mm
################# My simulation #########################
I = 5
HH = 1
d_coils = 54
R_radius = 48.8
R_inner = R_radius-3*1.7
layers = 4
windings = 4
wire_width = 1
wire_height = 1
B_z, B_x = bf.B_multiple_raster(I,HH,R_inner,d_coils,layers,windings,wire_width, wire_height, x_m,z_m)
#Calculate gradients/curvature
B_z_grad = np.gradient(np.gradient(B_z,z_m),z_m)/1e4
B_x_grad = np.gradient(B_x,x_m)/100
wire_area = wire_height * wire_width
wire_length = layers*windings*2*R_radius*np.pi
j_dens = I/wire_area #[A/mm^2]
Power = cs.rho_copper_20 *wire_length*1e-3* I**2 /(wire_area* 1e-6)
print(f"current density = {j_dens} A/mm^2")
print(f"Power = {Power} W")

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,34 @@
# -*- 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
m = 2.69e-25
k = 2*0.2097*9.9*cs.mu_B
omega = np.sqrt(k/m)
f = omega/(2*np.pi)
T = 1/f
T_exp = T/4
#print(T_exp)
start_z = 1e-6
d_t = 1e-3
def force(z):
return 2*0.248*z*9.9*cs.mu_B
z = start_z
v = 0
for t in np.arange(0,T_exp,d_t):
v = v + force(z)/m * d_t
#print(v)
z = z + v * d_t
print(z)
print(omega)
print(omega*1000e-3)
print(700*20e-3*2*np.pi)

View File

@ -0,0 +1,34 @@
# -*- 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
m = 2.69e-25
k = 2*0.2097*9.9*cs.mu_B
omega = np.sqrt(k/m)
f = omega/(2*np.pi)
T = 1/f
T_exp = T/4
#print(T_exp)
start_z = 1e-6
d_t = 1e-3
def force(z):
return 2*0.248*z*9.9*cs.mu_B
z = start_z
v = 0
for t in np.arange(0,T_exp,d_t):
v = v + force(z)/m * d_t
#print(v)
z = z + v * d_t
print(z)
print(omega)
print(omega*1000e-3)
print(700*20e-3*2*np.pi)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 31 09:28:25 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
x = np.linspace(-10, 10, 3001)
z = np.linspace(-10, 10, 3001)
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 6, windings = 4, wire_height = 1, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
I = 5
"""
percentage = 0.05
absolut = 5
diff = percentage*0.01*5+ absolut *1e-3
print(diff)
Bz2, Bx = HH_Coil.B_multiple(I+ diff, x, z)
print(Bz2[1500]-Bz1[1500])
print(" ")
"""
percentage = 0 #.02
absolut = 0.125
diff = percentage*0.01*5+ absolut *1e-3
print(diff)
Bz1, Bx = HH_Coil.B_multiple(I, x, z)
Bz2, Bx = HH_Coil.B_multiple(I+ diff, x, z)
print(Bz2[1500]-Bz1[1500])
print((Bz2[1500]-Bz1[1500])/Bz2[1500])
#print(100e-6/10)
#Power = cs.rho_copper_20 *wire_length* I_current**2 /(self.get_wire_area())

99
Noise/01_HH_noise.py Normal file
View File

@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-15, 15, 30001)
z = np.linspace(-15, 15, 30001)
#New coil
I_current = 10
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 2, windings = 6, wire_height = 2, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
Bz, Bx = HH_Coil.B_multiple(I_current,x,z,raster = 10)
Bz_curv = BC.BCoil.curv(Bz, z)
HH_Coil.cooling(I_current)
print(f"B_z(0) = {Bz[15000]} G")
print(f"B_z_curvature(0) = {Bz_curv[15000]:.4f} G/cm^2")
print(f"B_z(1 μm) = {Bz[15001]}")
print(f"B_z(1 mm) = {Bz[16000]}")
print(f"Diff B 1 μm: {Bz[15001] - Bz[15000]}, relative: {(Bz[15001] - Bz[15000])/Bz[15000]}")
print(f"Diff B 1 mm: {Bz[16000] - Bz[15000]}, relative: {(Bz[16000] - Bz[15000])/Bz[15000]}")
print(f"Diff B 0.5 mm: {Bz[15500] - Bz[15000]}, relative: {(Bz[15500] - Bz[15000])/Bz[15000]}")
I_HH = I_current
#calculate field
B_z, B_x = HH_Coil.B_multiple(I_HH,x,z)
#Calculate curvature
B_z_curv = BC.BCoil.curv(B_z, z)
plt.figure(300)
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_{ref}$, reference, optimal HH-configuration d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp,linestyle = "solid", label = r"$B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A, 4 x 4")
#plt.plot(z,B_tot,linestyle = "solid", label = r"$B_{z,1} + B_{z,2}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
plt.subplot(2,1,2)
plt.plot(z,B_z_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{ref}$, d = 44 mm, R = 44 mm")
#plt.plot(z,B_z_comp_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1}$, d = 54 mm, R = 48.8 mm, I = 5 A")
#plt.plot(z,B_tot_curv,linestyle = "solid", label = r"$\nabla_z^2 B_{z,1} + B_{z,2}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend()#bbox_to_anchor=(1.05, 1), loc='upper left')
#plt.savefig("output/first_compensation_idea.png")
plt.show()
"""
AHH ############################################################################
###############################################################################
###############################################################################
"""

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,34 @@
# -*- 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
m = 2.69e-25
k = 2*0.2097*9.9*cs.mu_B
omega = np.sqrt(k/m)
f = omega/(2*np.pi)
T = 1/f
T_exp = T/4
#print(T_exp)
start_z = 1e-6
d_t = 1e-3
def force(z):
return 2*0.248*z*9.9*cs.mu_B
z = start_z
v = 0
for t in np.arange(0,T_exp,d_t):
v = v + force(z)/m * d_t
#print(v)
z = z + v * d_t
print(z)
print(omega)
print(omega*1000e-3)
print(700*20e-3*2*np.pi)

View File

@ -0,0 +1,43 @@
# -*- 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
mu = 9.9* cs.mu_B
Grad_Bz = cs.m_Dy_164 * 9.81/(8*mu)
print("For levitation:")
print(f"dBz/dz = {Grad_Bz*1e4*1e-2:.4f} G/cm")
print("")
T = 10e-6
sigma = np.sqrt(cs.k_B*T/cs.m_Dy_164)
dz = 2*sigma * 10e-3
print(sigma*10e-3)
#dz = 250e-6
dt = 10e-3
Grad_Bz = 2 * dz * cs.m_Dy_164/(dt**2 * mu)
print(" ")
print("For Stern-Gerlach separation:")
print(f"dBz/dz = {Grad_Bz*1e4*1e-2:.4f} G/cm")
print(" ")
a = 8*mu*2.67*1e-2/cs.m_Dy_164 + 9.81
s = 0.5 * a * dt**2
print(s)
print(0.5*9.81*dt**2)
print((2.8778-2.8775)/2.8778)
print(16*dz)

File diff suppressed because one or more lines are too long

186
Test_class.py Normal file
View File

@ -0,0 +1,186 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x_m = np.linspace(-0.05, 0.05, 101)
z_m = np.linspace(-0.05, 0.05, 101)
z = z_m*1e3
x = x_m*1e3 #for plotting in mm
#Import Values from simulation
################# My simulation #########################
I = 5
HH = 1
d_coils = 44
R_mid = 44
R_inner = 44-3*1.7
layers = 6
windings = 2
wire_width = 1.7
wire_height = 2.6
HH_Coil1 = BC.BCoil(HH, d_coils ,R_mid, layers, windings, wire_width, wire_height)
#HH_Coil1.print_info()
#B_z_sim, B_x_sim = HH_Coil1.B_multiple(5, x, z)
#B_z, B_x = bf.B_multiple_raster(I,HH,R_inner,d_coils,layers,windings,wire_width, wire_height, x_m,z_m)
#B_test = B_field_ideal_AHH(layers*windings,I,R_inner*1e-3,d_coils*1e-3,z_m)
#B_x = np.concatenate((-np.flip(B_r),B_r[1:len(B_r)]))
HH_Coil1.Bz_plot_HH(I,x,z)
#Calculate gradients/curvature
B_z_sim_grad = np.gradient(np.gradient(B_z_sim,z_m),z_m)/1e4
B_x_sim_grad = np.gradient(B_x_sim,x_m)/100
#B_z_grad = np.gradient(np.gradient(B_z,z_m),z_m)/1e4
B_z_grad = np.gradient(B_z,z_m)/100
B_z_sim_grad = np.gradient(B_z_grad,z_m)/100
B_x_grad = np.gradient(B_x,x_m)/100
#Calculate relative differences in permille
rel_diff_Bz = (B_z-B_z_sim)/np.mean(B_z)
#rel_diff_Bx = (B_x-B_x_sim)/np.mean(B_x)
rel_diff_Bz_grad = (B_z_grad-B_z_sim_grad)/np.mean(B_z_grad)
rel_diff_Bz_grad_mean = (B_z_grad-B_z_sim_grad)/np.mean(B_z_grad)
#rel_diff_Bx_grad = (B_x_grad-B_x_sim_grad)/np.mean(B_x_grad)
#Plotting
plt.figure(1,figsize=(20,18))
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_z along z-axis, comparison of simulations", fontsize=30)
#Field plot
##########################
plt.subplot(3,2,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim,linestyle = "dashdot", label = r"$B_{z, sim}$: Numerical Matlab simulation")
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,3)
plt.plot(z,(B_z-B_z_sim), label = r"$B_z - B_{z, sim}$")
plt.ylabel("absolute deviation [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
#############################
plt.subplot(3,2,5)
plt.plot(z,1000*rel_diff_Bz, label = "$(B_z - B_{z, sim}) / B_z$")
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
######################Gradient plot############################
################
plt.subplot(3,2,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z^2 B_z$: Result via elliptic integrals")
plt.plot(z,B_z_sim_grad,linestyle = "dashdot", label = r"$\nabla_z^2 B_{z, sim}$: Numerical Matlab sim.")
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.title("Curvature of B-field",fontsize = 30)
plt.legend(loc='lower right')
#################
plt.subplot(3,2,4)
plt.plot(z,(B_z_grad-B_z_sim_grad), label = r"$\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}$")
plt.ylabel(r"absolute deviation $[G/cm^2]$")
plt.xlabel("z-axis [mm]")
plt.legend()
#####################
plt.subplot(3,2,6)
plt.plot(z,1000*rel_diff_Bz_grad, label = r"$(\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}) / \nabla_z^2 B_z$")
#plt.ylim(-57,10)
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.savefig("output/HH_benchmark_5A_6x2.pdf")
plt.show()
############### relative deviation with averaging by the mean not the individual value ########################################
plt.figure(2)
plt.plot(z,1000*rel_diff_Bz_grad_mean, label = r"$(\nabla_z^2 B_z - \nabla_z^2 B_{z, sim}) / mean(\nabla_z^2 B_z)$")
#plt.ylim(-57,10)
plt.ylabel("relative deviation [‰]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.savefig("output/HH_benchmark_5A_6x2_rel_deviation_via_mean.pdf")
plt.show()
##################### x-Axis #########################################################
plt.figure(3)
plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_x along x-axis, comparison of simulations", fontsize=30)
#Field plot
##########################
plt.plot(x,B_x,linestyle = "solid", label = r"$B_x$: Result via elliptic integrals")
plt.plot(x,B_x_sim,linestyle = "dashdot", label = r"$B_{x, sim}$: Numerical Matlab simulation")
plt.plot(x,(B_x-B_x_sim), label = r"$B_x - B_{x, sim}$")
#plt.xlim(-0.01,0.01)
plt.title("B-field" ,fontsize = 30)
plt.ylabel(r"$B_x$ [G]")
plt.xlabel("x-axis [mm]")
plt.legend()
#################
plt.savefig("output/HH_benchmark_5A_6x2_x-axis.pdf")
plt.show()

81
Test_class1.py Normal file
View File

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import B_field_calculation as bf
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')
#set up axis
x = np.linspace(-50, 50, 101)
z = np.linspace(-50, 50, 101)
################# My simulation #########################
I = 5
HH = 1
d_coils = 44
R_mid = 44
layers = 6
windings = 2
wire_width = 1.7
wire_height = 2.6
HH_Coil_44 = BC.BCoil(HH, d_coils ,R_mid, layers, windings, wire_width, wire_height)
d_coils_2 = 55.2
HH_Coil_54 = BC.BCoil(HH, d_coils_2 ,R_mid, layers, windings, wire_width, wire_height)
#HH_Coil_44.Bz_plot_HH(I,x,z)
#HH_Coil_44.Bz_plot_HH_comp(HH_Coil_54,I,x,z)
B_z, B_x = HH_Coil_44.B_multiple(I,x,z)
B_z_2, B_x_2 = HH_Coil_54.B_multiple(I,x,z)
B_z_curvature = np.gradient(np.gradient(B_z,z),z)*1e2
B_z_curvature_2 = np.gradient(np.gradient(B_z_2,z),z)*1e2
plt.figure(100,figsize=(13,10))
#plt.rcParams.update({'font.size': 15})
plt.suptitle("Helmholtz coil field B_z along z-axis")
#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$B_z$, d = 44 mm")
plt.plot(z,B_z_2,linestyle = "solid", label = r"$B_{z,2}$, d = 55.2 mm")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )
plt.ylabel(r"$B_z$ [G]")
plt.xlabel("z-axis [mm]")
plt.legend()
plt.subplot(2,1,2)
plt.plot(z,B_z_curvature,linestyle = "solid", label = r"$\nabla_z^2 B_z$, d = 44 mm")
plt.plot(z,B_z_curvature_2,linestyle = "solid", label = r"$\nabla_z^2 B_{z,2}, d = 55.2 mm$")
plt.ylabel(r"$\nabla_z^2 B_z [G/cm^2]$")
plt.xlabel("z-axis [mm]")#plt.xlim(-10,10)
plt.title("Curvature of B-field")
plt.legend(loc='lower right')
plt.show()

BIN
output/AHH_field.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -278,6 +278,7 @@ class BCoil:
return B
@staticmethod
def B_tot_3d(B):
return np.sqrt(B[:, :, 0] ** 2 + B[:, :, 1] ** 2)
@ -300,7 +301,7 @@ class BCoil:
plt.ylabel("z-axis [mm]")
plt.show()
def Bcurv(B_field, z):
def curv(B_field, z):
return np.gradient(np.gradient(B_field, z), z) * 1e2
def Bgrad(B_field, z):

View File

@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 7 13:18:18 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import coil_class as BC
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
I = 10
HH_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 4, windings = 2, wire_height = 2, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
HH_Coil.cooling(I,20)
print(f"length = {HH_Coil.get_wire_length()}")
Fast_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 8, windings = 8, wire_height =0.5, wire_width = 0.5,windings_spacing=0, layers_spacing = 0)
Fast_Coil.set_R_outer(49.3)
Fast_Coil.set_d_min(49.8)
Ilz_Coil = BC.BCoil(HH = 1, distance = 70 ,radius = 40.5 , layers = 6, windings = 1, wire_height = 2.7, wire_width = 1,windings_spacing=0.25, layers_spacing = 0.25)
Ilz_Coil.set_R_inner(40.5)
Ilz_Coil.print_info()
L = HH_Coil.inductivity()
R = HH_Coil.resistance(20)
HH_Coil.cooling(I,22)
#AHH_Coil = BC.BCoil(-1, 82 , 47.3 , 4, 6, wire_width= 1, wire_height= 1.5 ,layers_spacing = 0.25, windings_spacing= 0.25)
def I_current(Coil, I_0, t):
L = Coil.induct_perry()
#L = Coil.inductivity()
R = Coil.resistance(22.5)
print(f"L={L}")
print(f" R= {R}")
tau = L/R
print(f" τ = {tau}")
I = I_0 * (1-np.exp(-R/L * t))
return I
def I_current_exp(I_0,R,L,t):
print("")
print(L/R)
I = I_0* (1-np.exp(-R/L * t))
return I
t = np.linspace(0,0.005,1000)
plt.title("time response")
plt.plot(t*1e3,I_current(HH_Coil,I,t),label = "I_max = 10 A, 2 x 4")
plt.plot(t*1e3,8*I_current(Fast_Coil,10/8,t),label = "I_max = 10/8 A, 8 x 8")
#plt.plot(t*1e3,I_current(Ilz_Coil,I,t),label = "Ilz theo")
#plt.plot(t*1e3,I_current_exp(I,42e-3,14e-6,t),label = "Ilz exp")
#plt.plot(t*1e3,I_current_exp(I,0.85,3.75e-3,t),label = "Paper: Fast switching")
plt.xlabel("time [ms]")
plt.ylabel("current I [A]")
plt.legend()
plt.show()
print(Fast_Coil.power(10/8,22))
print(Fast_Coil.resistance(22))

128
time_response/R_test.py Normal file
View File

@ -0,0 +1,128 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 7 13:18:18 2021
@author: Joschka
"""
import matplotlib.pyplot as plt
import numpy as np
from src import coil_class as BC
from IPython import get_ipython
# get_ipython().run_line_magic('matplotlib', 'qt')
I = 1.25
HH_Coil = BC.BCoil(HH=1, distance=54, radius=48, layers=8, windings=8, wire_height=0.5, wire_width=0.5,
windings_spacing=0.25, layers_spacing=0.25)
HH_Coil.set_R_outer(49.3)
HH_Coil.set_d_min(49.8)
HH_Coil.print_info()
# todo: asdkjflö
# Fast_Coil = BC.BCoil(HH = 1, distance = 54 ,radius = 48 , layers = 8, windings = 8, wire_height =0.5, wire_width = 0.5,windings_spacing=0, layers_spacing = 0)
# Fast_Coil.set_R_outer(49.3)
# Fast_Coil.set_d_min(49.8)
# AHH_Coil = BC.BCoil(-1, 82 , 47.3 , 4, 6, wire_width= 1, wire_height= 1.5 ,layers_spacing = 0.25, windings_spacing= 0.25)
def I_t(Coil, I_0, t):
L = Coil.induct_perry()
# L = Coil.inductivity()
R = Coil.resistance(22.5)
print(f"L={L}")
print(f" R= {R}")
tau = L / R
print(f" τ = {tau}")
I = I_0 * (1 - np.exp(-R / L * t))
return I
def I_t_2(Coil, I_0, t):
L = Coil.induct_perry()
# L = Coil.inductivity()
R = 2 * Coil.resistance(22.5)
print(f"L={L}")
print(f" R= {R}")
tau = L / R
print(f" τ = {tau}")
I = I_0 * (1 - np.exp(-R / L * t))
return I
def U_t(t, U_0, t_f):
if t < t_f:
U = 2 * U_0 - U_0 / t_f * t
else:
U = U_0
return U
test = np.vectorize(U_t)
def I_t_3(Coil, I_0, t_f, t):
L = Coil.induct_perry()
# L = Coil.inductivity()
R = Coil.resistance(22.5)
# print(f"L={L}")
# print(f" R= {R}")
# tau = L/R
# print(f" τ = {tau}")
# print(R*I_0)
I = test(t, R * I_0, t_f * 1e-3) / R * (1 - np.exp(-R / L * t))
return I
def I_current_exp(I_0, R, L, t):
print("")
print(L / R)
I = I_0 * (1 - np.exp(-R / L * t))
return I
def main():
# execute some code here
t = np.linspace(0, 0.002, 1000)
# set up color
color = iter(plt.cm.rainbow(np.linspace(0, 1, 5)))
plt.figure(1)
plt.subplot(2, 1, 1)
plt.title("time response")
plt.plot(t * 1e3, I_t(HH_Coil, I, t), label="R = R_coil, U = const. = 10 V ")
plt.plot(t * 1e3, I_t_2(HH_Coil, I, t), label="R = 2 * R_coil, U = const. = 20 V")
for t_f in np.arange(0.2, 1.2, 0.3):
print(t_f)
plt.plot(t * 1e3, I_t_3(HH_Coil, I, t_f, t), c=next(color), label=f"U overshoot, t_f = {t_f:.1f} ms")
plt.xlabel("time [ms]")
plt.ylabel("current I [A]")
plt.legend()
plt.show()
color = iter(plt.cm.rainbow(np.linspace(0, 1, 5)))
plt.subplot(2, 1, 2)
for t_f in np.arange(0.2, 1.2, 0.3):
plt.plot(t * 1e3, test(t, 10, t_f * 1e-3), c=next(color), label=f"U overshoot, t_f = {t_f:.1f} ms")
plt.xlabel("time [ms]")
plt.ylabel("voltage U [V]")
plt.legend()
plt.show()
if __name__ == "__main__":
print("g")
main()

5
time_response/test.py Normal file
View File

@ -0,0 +1,5 @@
import time_response.R_test as R
print("hi")
print(R.I_current_exp(1, 1, 1, 4))
print(R.HH_Coil)

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 7 13:26:18 2021
@author: Joschka
"""
import numpy as np
from src import physical_constants as cs
L = 4*np.pi*1e-7*16**2 *0.046925**2 * np.pi/4.75e-3
r = 0.046925
R = cs.rho_copper_20 * 16* 2*r * np.pi/1e-6
print(R)

8
untitled0.py Normal file
View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 1 10:42:13 2021
@author: Joschka
"""
for t