-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathdifferent_material.py
More file actions
50 lines (39 loc) · 1.77 KB
/
different_material.py
File metadata and controls
50 lines (39 loc) · 1.77 KB
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
from necpp import *
import math
def handle_nec(result):
if (result != 0):
print(nec_error_message())
def geometry(freq, base, length):
conductivity = 1.45e6 # Stainless steel
ground_conductivity = 0.002
ground_dielectric = 10
wavelength = 3e8/(1e6*freq)
n_seg = int(math.ceil(50*length/wavelength))
nec = nec_create()
'''
\brief Set the prameters of the medium (permittivity and permeability)
\param permittivity The electric permittivity of the medium (in farads per meter)
\param permeability The magnetic permeability of the medium (in henries per meter)
\remark From these parameters a speed of light is chosen.
'''
permittivity = 8.8e-12 # Farads per meter
permeability = 4*math.pi*1e-7
handle_nec(nec_medium_parameters(nec, 2.0*permittivity, permeability))
handle_nec(nec_wire(nec, 1, n_seg, 0, 0, base, 0, 0, base+length, 0.002, 1.0, 1.0))
handle_nec(nec_geometry_complete(nec, 1))
handle_nec(nec_ld_card(nec, 5, 0, 0, 0, conductivity, 0.0, 0.0))
handle_nec(nec_gn_card(nec, 0, 0, ground_dielectric, ground_conductivity, 0, 0, 0, 0))
handle_nec(nec_fr_card(nec, 0, 1, freq, 0))
# Voltage excitation one third of the way along the wire
handle_nec(nec_ex_card(nec, 0, 0, int(n_seg/3), 0, 1.0, 0, 0, 0, 0, 0))
return nec
def impedance(freq, base, length):
nec = geometry(freq, base, length)
handle_nec(nec_xq_card(nec, 0)) # Execute simulation
index = 0
z = complex(nec_impedance_real(nec,index), nec_impedance_imag(nec,index))
nec_delete(nec)
return z
if (__name__ == '__main__'):
z = impedance(freq = 134.5, base = 0.5, length = 4.0)
print("Impedance at base=%0.2f, length=%0.2f : (%6.1f,%+6.1fI) Ohms" % (0.5, 4.0, z.real, z.imag))