225 lines
7.0 KiB
Python
225 lines
7.0 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib as mpl
|
|
from src import coil_class as BC
|
|
|
|
# %%
|
|
|
|
# % matplotlib inline
|
|
mpl.rcParams['xtick.direction'] = 'in'
|
|
mpl.rcParams['ytick.direction'] = 'in'
|
|
|
|
mpl.rcParams['xtick.top'] = True
|
|
mpl.rcParams['ytick.right'] = True
|
|
|
|
mpl.rcParams['xtick.major.size'] = 10
|
|
mpl.rcParams['xtick.major.width'] = 3
|
|
mpl.rcParams['xtick.minor.size'] = 10
|
|
mpl.rcParams['xtick.minor.width'] = 3
|
|
mpl.rcParams['ytick.major.size'] = 10
|
|
mpl.rcParams['ytick.major.width'] = 3
|
|
mpl.rcParams['ytick.minor.size'] = 10
|
|
mpl.rcParams['ytick.minor.width'] = 3
|
|
|
|
|
|
mpl.rcParams.update({'font.size': 22, 'axes.linewidth': 3, 'lines.linewidth': 3})
|
|
|
|
# %%
|
|
HH_Coil = BC.BCoil(HH=1, distance=54, radius=48, layers=8, windings=8, wire_height=0.5,
|
|
wire_width=0.5, insulation_thickness=(0.546 - 0.5) / 2, is_round=True,
|
|
winding_scheme=2)
|
|
HH_Coil.set_R_inner(45.6)
|
|
HH_Coil.set_d_min(2 * 24.075)
|
|
HH_Coil.print_info()
|
|
|
|
AHH_Coil = BC.BCoil(HH=-1, distance=54, radius=48, layers=HH_Coil.get_layers, windings=2 * HH_Coil.get_windings,
|
|
wire_height=0.5, wire_width=0.5, insulation_thickness=(0.546 - 0.5) / 2,
|
|
is_round=True, winding_scheme=2)
|
|
AHH_Coil.set_R_inner(45.6)
|
|
AHH_Coil.set_d_min(HH_Coil.get_zmax() * 2 * 1e3 + 4)
|
|
AHH_Coil.print_info()
|
|
|
|
# %%
|
|
# Calculate fields
|
|
lim = 15
|
|
x, z = np.linspace(-lim, lim, 100), np.linspace(-lim, lim, 100)
|
|
# z = np.linspace(-lim, lim, 100)
|
|
|
|
I_HH = 1
|
|
HH_B_tot_z, HH_B_tot_x = HH_Coil.B_tot_along_axis(I_HH, x, z, raster=2)
|
|
AHH_B_tot_z, AHH_B_tot_x = AHH_Coil.B_field(I_HH, x, z, raster=2)
|
|
AHH_B_grad_z, AHH_B_grad_x = BC.BCoil.grad(AHH_B_tot_z, z), BC.BCoil.grad(AHH_B_tot_x, x)
|
|
|
|
# %%
|
|
c_orange = '#FF914D'
|
|
c_blue = '#71C8F4'
|
|
|
|
c_grey = '#545454'
|
|
|
|
c_light_green = '97e144'
|
|
|
|
my_colors = {'light_green': '#97e144',
|
|
'orange': '#FF914D',
|
|
'light_grey': '#545454',
|
|
'pastel_blue': '#1b64d1',
|
|
'light_blue': '#71C8F4',
|
|
'purple': '#7c588c'}
|
|
|
|
c_field = my_colors['light_green']
|
|
c_grad = my_colors['purple']
|
|
|
|
fig, ax1 = plt.subplots(figsize=(11, 6))
|
|
|
|
ax1.set_title('Magnetic Field of inverted viewport coils', y=1.03)
|
|
|
|
ax1.set_xlabel('z-/x- axis [mm]')
|
|
ax1.set_ylabel('B-field per current [G/A]', color=c_field)
|
|
ax1.tick_params(axis='y', labelcolor=c_field)
|
|
ax1.plot(x, HH_B_tot_x, color=c_field, linestyle="dashed")
|
|
ax1.plot(z, HH_B_tot_z, color=c_field)
|
|
|
|
ax1.set_ylim(10.2, 11.01)
|
|
|
|
ax2 = ax1.twinx()
|
|
ax2.set_ylabel('Gradient per current [G/cm/A]', color=c_grad)
|
|
ax2.tick_params(axis='y', labelcolor=c_grad)
|
|
plt.plot(x, np.abs(AHH_B_grad_x), color=c_grad, linestyle="dashed")
|
|
plt.plot(z, np.abs(AHH_B_grad_z), color=c_grad)
|
|
|
|
ax2.set_ylim(2.1, 5.5)
|
|
plt.show()
|
|
|
|
# %%
|
|
I = 1
|
|
Max_field = HH_Coil.max_field(I)
|
|
|
|
def I_t_cut(time, coil, I_end, U_0):
|
|
I = U_0 / coil.resistance(22)/2 * (1 - np.exp(- time / coil.tau()))
|
|
if I >= I_end:
|
|
I = I_end
|
|
return I
|
|
|
|
def I_current(Coil, I_0, t):
|
|
L = Coil.induct_perry()
|
|
|
|
R = Coil.resistance(22.5)*2
|
|
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
|
|
|
|
I_t_cut_vec = np.vectorize(I_t_cut)
|
|
|
|
|
|
fig, ax1 = plt.subplots(figsize=(11, 8))
|
|
ylim = (0, 11.5)
|
|
t = np.linspace(0, 0.002, 10000)
|
|
i_to_B = 10.64
|
|
fig, ax = plt.subplots(figsize = (11,7))
|
|
#fig.suptitle(f"Time response HH-coil: I_max = {I} A --> Max Field = {Max_field:.2f} G \n \n I(t) = U(t) / R * (1 - exp(- R/L * t))")
|
|
ax.set_title("Expected Time Response Final Offset Coil", y = 1.05)
|
|
|
|
# ax.text(0.6, 5, r'$I(t) = \frac{U(t)}{R} - \frac{L}{R} \cdot \frac{dI(t)}{dt} $', fontsize=34)
|
|
|
|
# ax.plot(t * 1e3, i_to_B * I_current(HH_Coil, I, t), label=f"U(t) = 1.5 V", zorder=1, color=my_colors['pastel_blue'])
|
|
U_0 = 28
|
|
ax.plot(t * 1e3, i_to_B * I_t_cut_vec(t, HH_Coil, I, U_0), zorder=1, color=my_colors['pastel_blue'])
|
|
plt.vlines(6.2e-2, 0, 10.64, zorder=2, linestyles=(0, (1.5, 3.06)),color=my_colors['orange'], label='t = 60 μs')
|
|
# for scaling in np.arange(2,5,0.5):
|
|
# ax.plot(t * 1e3, I_t_exp(t, AHH_Coil, I, 15, scaling), label=f"Exponential decay U")
|
|
|
|
ax.set_xlabel("time [ms]")
|
|
ax.set_ylabel("Magnetic field [G]")
|
|
ax.set_ylim(ylim)
|
|
ax.set_xlim(-0.009,0.25)
|
|
ax.legend()
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
# %%
|
|
# Comparison different number of windings
|
|
Coil1 = BC.BCoil(HH=1, distance=54, radius=48, layers=8, windings=8, wire_height=0.5,
|
|
wire_width=0.5, insulation_thickness=(0.546 - 0.5)/2, is_round=True,
|
|
winding_scheme=0)
|
|
Coil1.set_R_inner(45.6)
|
|
Coil1.set_d_min(2 * 24.075)
|
|
Coil1.print_info()
|
|
|
|
factor = 4
|
|
Coil2 = BC.BCoil(HH=1, distance=54, radius=48, layers=8//factor, windings=8//factor, wire_height=0.5*factor,
|
|
wire_width=0.5*factor, insulation_thickness=(0.546 - 0.5)*factor/2, is_round=True,
|
|
winding_scheme=0)
|
|
Coil2.set_R_inner(45.6)
|
|
Coil2.set_d_min(2 * 24.075)
|
|
Coil2.print_info()
|
|
Coil1.plot_raster()
|
|
Coil2.plot_raster()
|
|
|
|
|
|
|
|
I = 1
|
|
Max_field = HH_Coil.max_field(I)
|
|
|
|
def I_t_cut(time, coil, I_end, U_0):
|
|
I = U_0 / coil.resistance(22) * (1 - np.exp(- time / coil.tau()))
|
|
if I >= I_end:
|
|
I = I_end
|
|
return I
|
|
|
|
def I_current(Coil, I_0, t):
|
|
L = Coil.induct_perry()
|
|
|
|
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
|
|
|
|
I_t_cut_vec = np.vectorize(I_t_cut)
|
|
|
|
|
|
fig, ax1 = plt.subplots(figsize=(11, 8))
|
|
ylim = (0, 11.5)
|
|
t = np.linspace(0, 0.002, 10000)
|
|
i_to_B = 10.64
|
|
fig, ax = plt.subplots(figsize = (11,7))
|
|
#fig.suptitle(f"Time response HH-coil: I_max = {I} A --> Max Field = {Max_field:.2f} G \n \n I(t) = U(t) / R * (1 - exp(- R/L * t))")
|
|
ax.set_title("Time Response Offset Coil", y = 1.05)
|
|
|
|
ax.text(0.6, 5, r'$I(t) = \frac{U(t)}{R} - \frac{L}{R} \cdot \frac{dI(t)}{dt} $', fontsize=34)
|
|
|
|
ax.plot(t * 1e3, i_to_B * I_current(Coil1, I, t), label=f"U(t) = 1.5 V", zorder=1, color=my_colors['pastel_blue'])
|
|
ax.plot(t * 1e3, i_to_B * I_current(Coil2, I , t), label=f"U(t) = 1.5 V", zorder=1, linestyle='- -', color=my_colors['light_green'])
|
|
U_0 = 28
|
|
#ax.plot(t * 1e3, i_to_B * I_t_cut_vec(t, AHH_Coil, I, U_0), label=f"U(t) regulated via PI feedback loop", zorder=1, color=my_colors['light_green'])
|
|
#plt.vlines(3.1e-2, 0, 10.64, zorder=2, linestyles=(0, (1.5, 3.06)),color=my_colors['orange'], label='t = 30 μs')
|
|
# for scaling in np.arange(2,5,0.5):
|
|
# ax.plot(t * 1e3, I_t_exp(t, AHH_Coil, I, 15, scaling), label=f"Exponential decay U")
|
|
|
|
ax.set_xlabel("time [ms]")
|
|
ax.set_ylabel("Magnetic field [G]")
|
|
ax.set_ylim(ylim)
|
|
ax.set_xlim(-0.09,2)
|
|
ax.legend()
|
|
|
|
plt.show()
|
|
|
|
#%%
|
|
Coil1 = BC.BCoil(HH=1, distance=54, radius=48, layers=8, windings=8, wire_height=0.5,
|
|
wire_width=0.5, insulation_thickness=(0.546 - 0.5)/2, is_round=True,
|
|
winding_scheme=2)
|
|
Coil1.set_R_inner(45.6)
|
|
Coil1.set_d_min(2 * 24.075)
|
|
Coil1.print_info()
|
|
|
|
mpl.rcParams.update(mpl.rcParamsDefault)
|
|
print(f"Cross_section = {Coil1.get_cross_section()}")
|
|
fill_factor = Coil1.get_wire_area() * Coil1.get_N()/Coil1.get_cross_section()
|
|
print(f"fill_factor = {fill_factor}")
|
|
Coil1.plot_raster() |