126 lines
3.0 KiB
Python
126 lines
3.0 KiB
Python
# -*- 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
|
|
|
|
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)
|
|
# AHH_Coil.print_info()
|
|
|
|
|
|
I = 1
|
|
Max_field = HH_Coil.max_field(I)
|
|
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()*2
|
|
|
|
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
|
|
|
|
|
|
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 U_t(t, coil, U_0, I_end, scaling):
|
|
U_end = I_end * coil.resistance(22)
|
|
U = (U_0-U_end) * np.exp(-t/coil.tau() * scaling) + U_end
|
|
return U
|
|
|
|
# t = np.linspace(0, 0.005, 1000)
|
|
# plt.plot(t* 1e3,U_t(t, AHH_Coil, 15, I))
|
|
# plt.xlabel("t [ms]")
|
|
# plt.show()
|
|
# print(U_t(0, AHH_Coil, 15, I))
|
|
|
|
|
|
|
|
|
|
U_vec = np.vectorize(U_t)
|
|
|
|
|
|
def I_t_exp(time, coil, I_end, U_0, scaling):
|
|
I = U_vec(time, coil, U_0, I_end, scaling) / coil.resistance(22) * (1 - np.exp(- time/coil.tau()))
|
|
return I
|
|
|
|
def I_t_cut(time, coil, I_end, U_0):
|
|
R = 2 * coil.resistance(22)
|
|
print(f"resistance I_cut = {R} Ω")
|
|
I = U_0 / R * (1 - np.exp(- time / coil.tau()))
|
|
if I >= I_end:
|
|
I = I_end
|
|
return I
|
|
|
|
I_t_cut_vec = np.vectorize(I_t_cut)
|
|
|
|
|
|
|
|
|
|
# %%
|
|
t = np.linspace(0, 0.003, 10000)
|
|
fig, axs = plt.subplots(2, 1, figsize = (7,7.5))
|
|
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 = axs[0]
|
|
# ax.title("test")
|
|
ax.plot(t * 1e3, I_current(HH_Coil, I, t), label=f"U_0 = U_end = 1.5 V")
|
|
|
|
for U_0 in [10, 15, 28, 58]:
|
|
ax.plot(t * 1e3, I_t_cut_vec(t, HH_Coil, I, U_0), label=f"U_0 = {U_0} V, U_end = 1.5 V")
|
|
|
|
# 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("current I [A]")
|
|
ax.legend()
|
|
|
|
ax = axs[1]
|
|
|
|
ax.plot(t * 1e6, I_current(HH_Coil, I, t), label=f"U_0 = U_end = 1.5 V")
|
|
|
|
for U_0 in [10, 15, 28, 58]:
|
|
ax.plot(t * 1e6, I_t_cut_vec(t, HH_Coil, I, U_0), label=f"U_0 = {U_0} V, U_end = 1.5 V")
|
|
# 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 [μs]")
|
|
ax.set_ylabel("current I [A]")
|
|
ax.set_xlim(0,300)
|
|
ax.legend()
|
|
|
|
plt.savefig('time_response_estimation.png', dpi=400)
|
|
plt.show()
|
|
|
|
# %%
|
|
|
|
print(f"L = {HH_Coil.induct_perry() * 1e6} μH")
|
|
print(f"R = {HH_Coil.resistance(22)}")
|
|
|
|
V_max = 15
|
|
I_set = 5e-3
|
|
L = HH_Coil.induct_perry()
|
|
f_drop = V_max/(2*np.pi*L*I_set)
|
|
print(f_drop)
|