nec2++  1.7.0
test.py
1 import necpp
2 
3 #
4 # \brief Using the python interface to the C-style nec2++ API
5 #
6 # Documentation on the interface can be found at
7 #
8 # http://tmolteno.github.io/necpp/
9 #
10 
11 def handle_nec(result):
12  if (result != 0):
13  print nec_error_message()
14 
15 def frequency_response():
16  # Scan through frequencies from 1 to 30 MHz
17  for f in range(1,30):
18  nec = necpp.nec_create()
19  handle_nec(necpp.nec_wire(nec, 1, 17, 0, 0, 2, 0, 0, 11, 0.1, 1, 1))
20  handle_nec(necpp.nec_geometry_complete(nec, 1))
21  handle_nec(necpp.nec_gn_card(nec, 1, 0, 0, 0, 0, 0, 0, 0))
22  handle_nec(necpp.nec_fr_card(nec, 0, 1, f, 0))
23  handle_nec(necpp.nec_ex_card(nec, 0, 0, 5, 0, 1.0, 0, 0, 0, 0, 0))
24  handle_nec(necpp.nec_rp_card(nec, 0, 90, 1, 0,5,0,0, 0, 90, 1, 0, 0, 0))
25  result_index = 0
26  z = complex(necpp.nec_impedance_real(nec,result_index), necpp.nec_impedance_imag(nec,result_index))
27  print "f=%0.2fMHz \t(%6.1f,%+6.1fI) Ohms" % (f, z.real, z.imag)
28  necpp.nec_delete(nec)
29 
30 frequency_response()
31