-
Notifications
You must be signed in to change notification settings - Fork 0
/
Schelkunoff_Model.py
147 lines (122 loc) · 4.07 KB
/
Schelkunoff_Model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#import scipy.special as sp
import numpy as np
import math
from mpmath import mp
# pip install mpmath
import matplotlib.pyplot as plt
import time as time
tim = time.time()
mu0 = 4*math.pi*10**-7; # Vs/Am
eps0 = 8.854*10**-12; # As/Vm
c0 = 299792457; # m/s
############
# Thomas numbers
############
# a = 0.25/2*10**-3; # mm
# b = 135/2*10**-3; # mm
# c = 139.7/2*10**-3; # mm
# sigma = 5.76*10**7; # 1/Ohm*m
# epsPE = 1.0;
############
# Tesche numbers
############
a = 2.5*10**-3; # mm
b = 9.345*10**-3; # mm
c = 9.945*10**-3; # mm
sigma = 5.76*10**7; # 1/Ohm*m
epsPE = 2.5;
############
# RG58 or Jans numbers
############
a = 0.4675*10**-3; # mm
b = 1.475*10**-3; # mm
c = 1.8 *10**-3; # mm
sigma = 5.8*10**7; # 1/Ohm*m
epsPE = 1.9;
f = np.logspace(5, 8, 100);
omega = 2*math.pi*f;
Lp = mu0/(2*math.pi)*mp.log(b/a); # ln(ra/ri)
Cp = 2*math.pi*eps0*epsPE/(mp.log(b/a)); # ln(ra/ri)
etac = np.sqrt(1j*omega*mu0/sigma);
gammac = np.sqrt(1j*omega*mu0*sigma);
# shortcuts
i0 = lambda x: mp.besseli(0,x)
i1 = lambda x: mp.besseli(1,x)
k0 = lambda x: mp.besselk(0,x)
k1 = lambda x: mp.besselk(1,x)
# Zap = etac/(2*math.pi*a)*(sp.iv(0,gammac*a) / sp.iv(1,gammac*a));
ZapA = etac/(2*math.pi*a)
#Zbp = etac/(2*math.pi*b)* (sp.iv(0,gammac*b) * sp.kv(1,gammac*c) + sp.kv(0,gammac*b) * sp.iv(1,gammac*c)) / (sp.iv(1,gammac*b)*sp.kv(1,gammac*b) - sp.iv(1,gammac*b)*sp.kv(1,gammac*b))
ZbpA = etac/(2*math.pi*b)
ZL = mp.matrix(f.size, 1)
YC = mp.matrix(f.size, 1)
Zap = mp.matrix(f.size, 1)
Zbp = mp.matrix(f.size, 1)
Zp = mp.matrix(f.size, 1)
Yp = mp.matrix(f.size, 1)
Zc = mp.matrix(f.size, 1)
A = np.ndarray(f.size)
R = np.ndarray(f.size)
I = np.ndarray(f.size)
Gr = np.ndarray(f.size)
Gi = np.ndarray(f.size)
for n in range(f.size):
Zap[n] = ZapA[n]*( i0(gammac[n]*a) / i1(gammac[n]*a) )
Zbp[n] = ZbpA[n] * ((i0(gammac[n]*b) * k1(gammac[n]*c) + k0(gammac[n]*b)*i1(gammac[n]*c)) / ( i1(gammac[n]*c)*k1(gammac[n]*b) - i1(gammac[n]*b)*k1(gammac[n]*c) ) )
ZL[n] = 1j*omega[n]*Lp
YC[n] = 1j*omega[n]*Cp
Zp[n] = Zap[n] + Zbp[n] + ZL[n]
Yp[n] = YC[n] # + G[n]
Zc[n] = mp.sqrt(Zp[n]/Yp[n])
A[n] = mp.fabs(Zc[n])
R[n] = mp.re(Zc[n])
I[n] = mp.im(Zc[n])
Gr[n] = mp.re(mp.sqrt(Zp[n]*Yp[n]))
Gi[n] = mp.im(mp.sqrt(Zp[n]*Yp[n]))
fig = plt.figure()
plt.plot(f/10**6, A, label='Magnitude', color='red')
plt.xlabel('Frequency [MHz]')
plt.ylabel('Magnitude of Z$_{c}$ [$\Omega$]')
plt.legend()
plt.xlim([-0.3,100])
#plt.show()
fig2 = plt.figure()
plt.plot(f/10**6, R, label='Real Part', color='red')
plt.xlabel('Frequency [MHz]')
plt.ylabel('Real Part of Z$_{c}$ [$\Omega$]')
plt.legend()
plt.xlim([-0.3,100])
#plt.show()
fig2 = plt.figure()
plt.plot(f/10**6, I, label='Imaginary Part', color='red')
plt.xlabel('Frequency [MHz]')
plt.ylabel('Imaginary Part of Z$_{c}$ [$\Omega$]')
plt.legend()
plt.xlim([-0.3,100])
print("Total duration: ", time.time() - tim, " s")
#plt.show()
fig4 = plt.figure()
plt.plot(f/10**6, A, label='Amplitude', color='red')
plt.plot(f/10**6, R, label='Real Part', color='blue')
plt.plot(f/10**6, I, label='Imaginary Part', color='green')
plt.xlabel('Frequency [MHz]')
plt.ylabel('Z$_c$ [$\Omega$]')
plt.legend()
plt.xlim([-0.3, 100])
#plt.show()
fig5 = plt.figure()
plt.semilogx(f/10**3, A, label='Magnitude', color='red')
plt.semilogx(f/10**3, R, label='Real Part', color='blue')
plt.semilogx(f/10**3, I, label='Imaginary Part', color='green')
plt.legend()
plt.xlabel('Frequency [kHz]')
plt.ylabel('Characteristic Impedance Z$_c$ [$\Omega$]')
plt.grid()
fig6 = plt.figure()
plt.loglog(f/10**6, Gr, label='Attenuation constant [1/m]', color='red')
plt.loglog(f/10**6, Gi, label='Propagation phase constant [1/m]', color='blue')
plt.xlabel('Frequency [MHz]')
plt.ylabel('Propagation constant')
plt.legend()
plt.show()
#print("Zc \n", Zc)