Save
This commit is contained in:
parent
d25b3cb5d8
commit
dd2a0f93b3
@ -137,3 +137,87 @@ ax.set_xlim(-0.09,2)
|
||||
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, HH_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, HH_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()
|
247
Plots_Erlangen/Plots_midterm_presentation.py
Normal file
247
Plots_Erlangen/Plots_midterm_presentation.py
Normal file
@ -0,0 +1,247 @@
|
||||
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) * (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(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), 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, HH_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()
|
||||
|
||||
# %%
|
||||
# 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=2)
|
||||
Coil1.set_R_inner(45.6)
|
||||
Coil1.set_d_min(2 * 24.075)
|
||||
Coil1.print_info()
|
||||
|
||||
factor = 2
|
||||
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=1)
|
||||
Coil2.set_R_inner(45.6)
|
||||
Coil2.set_d_min(2 * 24.075)
|
||||
Coil2.print_info()
|
||||
|
||||
|
||||
|
||||
|
||||
full_structure = Coil1.full_raster(100) * 1e3
|
||||
if Coil1.get_coil_width() > Coil1.get_coil_height():
|
||||
extension = Coil1.get_coil_width()
|
||||
else:
|
||||
extension = Coil1.get_coil_height()
|
||||
extension *= 1e3
|
||||
|
||||
plt.figure(77, figsize=(8, 8))
|
||||
mpl.rcParams['font.size'] = 28
|
||||
plt.scatter(full_structure[:, :, 1], full_structure[:, :, 0], linewidths=0.001)
|
||||
plt.xlabel("radius [mm]")
|
||||
plt.ylabel("z position [mm]")
|
||||
plt.axvline(x=Coil1.get_R_inner() * 1e3 - 0.1, lw=5, color="red")
|
||||
plt.xlim(45, 50.4)
|
||||
plt.ylim(23.5, 28.9)
|
||||
|
||||
plt.show()
|
||||
|
||||
# %%
|
||||
Coil2.plot_raster()
|
||||
|
||||
factor = Coil1.get_N()//Coil2.get_N()
|
||||
|
||||
|
||||
I = 1
|
||||
I2 = I * factor
|
||||
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 = Max_field/I
|
||||
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", y = 1.05)
|
||||
|
||||
# ax.text(0.4, 4, r"$ I(t) = \frac{U_{0}}{R} (1 - e^{-\frac{R}{L} t})$", fontsize=34)
|
||||
|
||||
ax.plot(t * 1e3, i_to_B * I_current(Coil1, I, t), label=f"N = {Coil1.get_N()}, I$_{{end}}$ = {I} A", zorder=1, color=my_colors['pastel_blue'])
|
||||
ax.plot(t * 1e3, i_to_B/factor * I_current(Coil2, I2 , t), label=f"N = {Coil2.get_N()}, I$_{{end}}$ = {I2} A", zorder=1, linestyle=(0, (4, 4)), color=my_colors['light_green'])
|
||||
U_0 = 28
|
||||
#ax.plot(t * 1e3, i_to_B * I_t_cut_vec(t, HH_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, HH_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()
|
@ -183,6 +183,9 @@ class BCoil:
|
||||
2 - np.sqrt(3)) * self.get_tot_wire_width() / 2 # width is reduced due to winding offset
|
||||
return self.get_tot_wire_width() * self.layers
|
||||
|
||||
def get_cross_section(self):
|
||||
return self.get_coil_height() * self.get_coil_width()
|
||||
|
||||
def winding_raster(self):
|
||||
"""
|
||||
generates raster of flowing currents
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 400 KiB After Width: | Height: | Size: 401 KiB |
Loading…
Reference in New Issue
Block a user