PyNEC 1.7.3.6__tar.gz → 1.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. pynec-1.8.1/PKG-INFO +117 -0
  2. pynec-1.8.1/PyNEC.egg-info/PKG-INFO +117 -0
  3. pynec-1.8.1/PyNEC.egg-info/SOURCES.txt +79 -0
  4. pynec-1.8.1/PyNEC.egg-info/requires.txt +1 -0
  5. pynec-1.8.1/PyNEC.py +615 -0
  6. pynec-1.8.1/PyNEC_wrap.cxx +12984 -0
  7. {PyNEC-1.7.3.6 → pynec-1.8.1}/README.md +3 -5
  8. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/antenna_util.py +7 -2
  9. pynec-1.8.1/example/basic_usage.py +135 -0
  10. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/context_clean.py +166 -35
  11. pynec-1.8.1/necpp_src/config.h +70 -0
  12. pynec-1.8.1/necpp_src/src/AntennaInput.h +114 -0
  13. pynec-1.8.1/necpp_src/src/BaseInput.h +107 -0
  14. pynec-1.8.1/necpp_src/src/CurrentInput.h +120 -0
  15. pynec-1.8.1/necpp_src/src/PowerBudget.h +120 -0
  16. pynec-1.8.1/necpp_src/src/RadiationInput.h +132 -0
  17. pynec-1.8.1/necpp_src/src/XGetopt.cpp +195 -0
  18. pynec-1.8.1/necpp_src/src/XGetopt.h +23 -0
  19. pynec-1.8.1/necpp_src/src/c_evlcom.cpp +843 -0
  20. pynec-1.8.1/necpp_src/src/c_evlcom.h +63 -0
  21. pynec-1.8.1/necpp_src/src/c_geometry.cpp +3225 -0
  22. pynec-1.8.1/necpp_src/src/c_geometry.h +256 -0
  23. pynec-1.8.1/necpp_src/src/c_ggrid.cpp +432 -0
  24. pynec-1.8.1/necpp_src/src/c_ggrid.h +91 -0
  25. pynec-1.8.1/necpp_src/src/c_plot_card.cpp +240 -0
  26. pynec-1.8.1/necpp_src/src/c_plot_card.h +91 -0
  27. pynec-1.8.1/necpp_src/src/common.h +77 -0
  28. pynec-1.8.1/necpp_src/src/electromag.cpp +48 -0
  29. pynec-1.8.1/necpp_src/src/electromag.h +64 -0
  30. pynec-1.8.1/necpp_src/src/libNEC.cpp +275 -0
  31. pynec-1.8.1/necpp_src/src/libnecpp.h +604 -0
  32. pynec-1.8.1/necpp_src/src/math_util.h +186 -0
  33. pynec-1.8.1/necpp_src/src/matrix_algebra.cpp +747 -0
  34. pynec-1.8.1/necpp_src/src/matrix_algebra.h +57 -0
  35. pynec-1.8.1/necpp_src/src/misc.cpp +128 -0
  36. pynec-1.8.1/necpp_src/src/misc.h +28 -0
  37. pynec-1.8.1/necpp_src/src/nec2cpp.h +12 -0
  38. pynec-1.8.1/necpp_src/src/nec_card_parser.h +131 -0
  39. pynec-1.8.1/necpp_src/src/nec_context.cpp +6841 -0
  40. pynec-1.8.1/necpp_src/src/nec_context.h +1033 -0
  41. pynec-1.8.1/necpp_src/src/nec_debug.h +40 -0
  42. pynec-1.8.1/necpp_src/src/nec_exception.cpp +108 -0
  43. pynec-1.8.1/necpp_src/src/nec_exception.h +83 -0
  44. pynec-1.8.1/necpp_src/src/nec_ground.cpp +264 -0
  45. pynec-1.8.1/necpp_src/src/nec_ground.h +280 -0
  46. pynec-1.8.1/necpp_src/src/nec_output.cpp +227 -0
  47. pynec-1.8.1/necpp_src/src/nec_output.h +117 -0
  48. pynec-1.8.1/necpp_src/src/nec_radiation_pattern.cpp +525 -0
  49. pynec-1.8.1/necpp_src/src/nec_radiation_pattern.h +464 -0
  50. pynec-1.8.1/necpp_src/src/nec_results.cpp +55 -0
  51. pynec-1.8.1/necpp_src/src/nec_results.h +787 -0
  52. pynec-1.8.1/necpp_src/src/nec_structure_currents.cpp +406 -0
  53. pynec-1.8.1/necpp_src/src/nec_structure_currents.h +241 -0
  54. pynec-1.8.1/necpp_src/src/nec_wire.h +265 -0
  55. pynec-1.8.1/necpp_src/src/safe_array.h +267 -0
  56. pynec-1.8.1/necpp_src/src/typesafe_stdint.h +60 -0
  57. pynec-1.8.1/pyproject.toml +31 -0
  58. pynec-1.8.1/setup.py +61 -0
  59. pynec-1.8.1/tests/test_examples.py +197 -0
  60. pynec-1.8.1/tests/test_get_gain.py +57 -0
  61. PyNEC-1.7.3.6/PKG-INFO +0 -118
  62. PyNEC-1.7.3.6/PyNEC.egg-info/PKG-INFO +0 -118
  63. PyNEC-1.7.3.6/PyNEC.egg-info/SOURCES.txt +0 -26
  64. PyNEC-1.7.3.6/setup.py +0 -73
  65. {PyNEC-1.7.3.6 → pynec-1.8.1}/LICENCE.txt +0 -0
  66. {PyNEC-1.7.3.6 → pynec-1.8.1}/MANIFEST.in +0 -0
  67. {PyNEC-1.7.3.6 → pynec-1.8.1}/PyNEC.egg-info/dependency_links.txt +0 -0
  68. {PyNEC-1.7.3.6 → pynec-1.8.1}/PyNEC.egg-info/top_level.txt +0 -0
  69. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/dipole.py +0 -0
  70. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/impedance_plot.py +0 -0
  71. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/logperiodic_opt.py +0 -0
  72. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/monopole.py +0 -0
  73. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/monopole_realistic_ground_plane.py +0 -0
  74. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/optimized.py +0 -0
  75. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/radiation_pattern.py +0 -0
  76. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_ai.py +0 -0
  77. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_charge_densities.py +0 -0
  78. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_ne_nh.py +0 -0
  79. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_nrp.py +0 -0
  80. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_rp.py +0 -0
  81. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_rp2.py +0 -0
  82. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_se.py +0 -0
  83. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_structure_currents.py +0 -0
  84. {PyNEC-1.7.3.6 → pynec-1.8.1}/example/test_surface_patch_currents.py +0 -0
  85. {PyNEC-1.7.3.6 → pynec-1.8.1}/setup.cfg +0 -0
pynec-1.8.1/PKG-INFO ADDED
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyNEC
3
+ Version: 1.8.1
4
+ Summary: Python Antenna Simulation Module (nec2++) object-oriented interface
5
+ Author-email: Tim Molteno <tim@physics.otago.ac.nz>
6
+ License-Expression: GPL-3.0-only
7
+ Project-URL: Homepage, http://github.com/tmolteno/python-necpp
8
+ Project-URL: Repository, http://github.com/tmolteno/python-necpp
9
+ Keywords: nec2,nec2++,antenna,electromagnetism,radio
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Classifier: Topic :: Communications :: Ham Radio
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Intended Audience :: Science/Research
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENCE.txt
18
+ Requires-Dist: numpy
19
+ Dynamic: license-file
20
+
21
+ # Python NEC2++ Module
22
+
23
+ This module wraps the C++ API for antenna simulation of nec2++. It is easier to work with, and more powerful than the C-style API wrapper. Works with Python 2.7 and 3+.
24
+
25
+
26
+ ## Usage
27
+
28
+ Here is an example that plots a radiation pattern.
29
+
30
+ from PyNEC import *
31
+ import numpy as np
32
+
33
+ #creation of a nec context
34
+ context=nec_context()
35
+
36
+ #get the associated geometry
37
+ geo = context.get_geometry()
38
+
39
+ #add wires to the geometry
40
+ geo.wire(0, 36, 0, 0, 0, -0.042, 0.008, 0.017, 0.001, 1.0, 1.0)
41
+ context.geometry_complete(0)
42
+
43
+ context.gn_card(-1, 0, 0, 0, 0, 0, 0, 0)
44
+
45
+ #add a "ex" card to specify an excitation
46
+ context.ex_card(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0)
47
+
48
+ #add a "fr" card to specify the frequency
49
+ context.fr_card(0, 2, 2400.0e6, 100.0e6)
50
+
51
+ #add a "rp" card to specify radiation pattern sampling parameters and to cause program execution
52
+ context.rp_card(0, 91, 1, 0, 5, 0, 0, 0.0, 45.0, 4.0, 2.0, 1.0, 0.0)
53
+
54
+ #get the radiation_pattern
55
+ rp = context.get_radiation_pattern(0)
56
+
57
+ # Gains are in decibels
58
+ gains_db = rp.get_gain()
59
+ gains = 10.0**(gains_db / 10.0)
60
+ thetas = rp.get_theta_angles() * 3.1415 / 180.0
61
+ phis = rp.get_phi_angles() * 3.1415 / 180.0
62
+
63
+
64
+ # Plot stuff
65
+ import matplotlib.pyplot as plt
66
+
67
+ ax = plt.subplot(111, polar=True)
68
+ ax.plot(thetas, gains[:,0], color='r', linewidth=3)
69
+ ax.grid(True)
70
+
71
+ ax.set_title("Gain at an elevation of 45 degrees", va='bottom')
72
+ plt.savefig('RadiationPattern.png')
73
+ plt.show()
74
+
75
+ ## Manual Build & install
76
+
77
+ Requirements
78
+
79
+ * [Swig](http://www.swig.org/download.html)
80
+ * For Windows: [C/C++ compilers](https://wiki.python.org/moin/WindowsCompilers).
81
+ * Git bash (for running build.sh script)
82
+ * [uv](https://github.com/astral-sh/uv) (recommended) or pip + setuptools + numpy + wheel
83
+
84
+ *Note: Download and extract swigwin.zip and add the path to swig.exe to environment.*
85
+
86
+ Then do following:
87
+
88
+ $ git clone --recursive https://github.com/tmolteno/python-necpp.git
89
+ $ cd python-necpp
90
+ $ cd PyNEC
91
+ $ ./build.sh
92
+ $ uv build # Modern, fast build
93
+ $ uv pip install . # Or: pip install .
94
+
95
+ *Note: 'sudo' is not required in windows.*
96
+
97
+ ## Install from PyPI
98
+
99
+ $ sudo pip install pynec
100
+
101
+ *Note: 'sudo' is not required in windows.*
102
+
103
+ ## Testing
104
+
105
+ Requirements
106
+
107
+ * python package: matplotlib
108
+
109
+ $ python example/test_rp.py
110
+
111
+ The example directory contains the following additional examples (that are inspired by excercises from a course on antennas):
112
+
113
+ * logperiodic_opt.py is an example on how to combine PyNECPP with scipy.optimize to use a genetic algorithm to **optimize an antenna for multiple frequency bands** at the same time (which I thin is not possible in 4nec2). The resulting gains and VSWR are plotted over the frequency range of interest. This requires scipy >= 0.15.0 due to the usage of scipy.optimize.differential_evolution.
114
+ * monopole_realistic_ground_plane.py plots the vertical gain pattern of a monopole antenna. Its dimensions are optimized with a local search, and the path through the search space is visualized with a heat map.
115
+ * dipole.py does a very simple optimization of a dipole, and plots the VSWR over a given frequency range for different system impedances to file.
116
+
117
+
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyNEC
3
+ Version: 1.8.1
4
+ Summary: Python Antenna Simulation Module (nec2++) object-oriented interface
5
+ Author-email: Tim Molteno <tim@physics.otago.ac.nz>
6
+ License-Expression: GPL-3.0-only
7
+ Project-URL: Homepage, http://github.com/tmolteno/python-necpp
8
+ Project-URL: Repository, http://github.com/tmolteno/python-necpp
9
+ Keywords: nec2,nec2++,antenna,electromagnetism,radio
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Classifier: Topic :: Communications :: Ham Radio
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Intended Audience :: Science/Research
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENCE.txt
18
+ Requires-Dist: numpy
19
+ Dynamic: license-file
20
+
21
+ # Python NEC2++ Module
22
+
23
+ This module wraps the C++ API for antenna simulation of nec2++. It is easier to work with, and more powerful than the C-style API wrapper. Works with Python 2.7 and 3+.
24
+
25
+
26
+ ## Usage
27
+
28
+ Here is an example that plots a radiation pattern.
29
+
30
+ from PyNEC import *
31
+ import numpy as np
32
+
33
+ #creation of a nec context
34
+ context=nec_context()
35
+
36
+ #get the associated geometry
37
+ geo = context.get_geometry()
38
+
39
+ #add wires to the geometry
40
+ geo.wire(0, 36, 0, 0, 0, -0.042, 0.008, 0.017, 0.001, 1.0, 1.0)
41
+ context.geometry_complete(0)
42
+
43
+ context.gn_card(-1, 0, 0, 0, 0, 0, 0, 0)
44
+
45
+ #add a "ex" card to specify an excitation
46
+ context.ex_card(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0)
47
+
48
+ #add a "fr" card to specify the frequency
49
+ context.fr_card(0, 2, 2400.0e6, 100.0e6)
50
+
51
+ #add a "rp" card to specify radiation pattern sampling parameters and to cause program execution
52
+ context.rp_card(0, 91, 1, 0, 5, 0, 0, 0.0, 45.0, 4.0, 2.0, 1.0, 0.0)
53
+
54
+ #get the radiation_pattern
55
+ rp = context.get_radiation_pattern(0)
56
+
57
+ # Gains are in decibels
58
+ gains_db = rp.get_gain()
59
+ gains = 10.0**(gains_db / 10.0)
60
+ thetas = rp.get_theta_angles() * 3.1415 / 180.0
61
+ phis = rp.get_phi_angles() * 3.1415 / 180.0
62
+
63
+
64
+ # Plot stuff
65
+ import matplotlib.pyplot as plt
66
+
67
+ ax = plt.subplot(111, polar=True)
68
+ ax.plot(thetas, gains[:,0], color='r', linewidth=3)
69
+ ax.grid(True)
70
+
71
+ ax.set_title("Gain at an elevation of 45 degrees", va='bottom')
72
+ plt.savefig('RadiationPattern.png')
73
+ plt.show()
74
+
75
+ ## Manual Build & install
76
+
77
+ Requirements
78
+
79
+ * [Swig](http://www.swig.org/download.html)
80
+ * For Windows: [C/C++ compilers](https://wiki.python.org/moin/WindowsCompilers).
81
+ * Git bash (for running build.sh script)
82
+ * [uv](https://github.com/astral-sh/uv) (recommended) or pip + setuptools + numpy + wheel
83
+
84
+ *Note: Download and extract swigwin.zip and add the path to swig.exe to environment.*
85
+
86
+ Then do following:
87
+
88
+ $ git clone --recursive https://github.com/tmolteno/python-necpp.git
89
+ $ cd python-necpp
90
+ $ cd PyNEC
91
+ $ ./build.sh
92
+ $ uv build # Modern, fast build
93
+ $ uv pip install . # Or: pip install .
94
+
95
+ *Note: 'sudo' is not required in windows.*
96
+
97
+ ## Install from PyPI
98
+
99
+ $ sudo pip install pynec
100
+
101
+ *Note: 'sudo' is not required in windows.*
102
+
103
+ ## Testing
104
+
105
+ Requirements
106
+
107
+ * python package: matplotlib
108
+
109
+ $ python example/test_rp.py
110
+
111
+ The example directory contains the following additional examples (that are inspired by excercises from a course on antennas):
112
+
113
+ * logperiodic_opt.py is an example on how to combine PyNECPP with scipy.optimize to use a genetic algorithm to **optimize an antenna for multiple frequency bands** at the same time (which I thin is not possible in 4nec2). The resulting gains and VSWR are plotted over the frequency range of interest. This requires scipy >= 0.15.0 due to the usage of scipy.optimize.differential_evolution.
114
+ * monopole_realistic_ground_plane.py plots the vertical gain pattern of a monopole antenna. Its dimensions are optimized with a local search, and the path through the search space is visualized with a heat map.
115
+ * dipole.py does a very simple optimization of a dipole, and plots the VSWR over a given frequency range for different system impedances to file.
116
+
117
+
@@ -0,0 +1,79 @@
1
+ LICENCE.txt
2
+ MANIFEST.in
3
+ PyNEC.py
4
+ PyNEC_wrap.cxx
5
+ README.md
6
+ pyproject.toml
7
+ setup.py
8
+ PyNEC.egg-info/PKG-INFO
9
+ PyNEC.egg-info/SOURCES.txt
10
+ PyNEC.egg-info/dependency_links.txt
11
+ PyNEC.egg-info/requires.txt
12
+ PyNEC.egg-info/top_level.txt
13
+ example/antenna_util.py
14
+ example/basic_usage.py
15
+ example/context_clean.py
16
+ example/dipole.py
17
+ example/impedance_plot.py
18
+ example/logperiodic_opt.py
19
+ example/monopole.py
20
+ example/monopole_realistic_ground_plane.py
21
+ example/optimized.py
22
+ example/radiation_pattern.py
23
+ example/test_ai.py
24
+ example/test_charge_densities.py
25
+ example/test_ne_nh.py
26
+ example/test_nrp.py
27
+ example/test_rp.py
28
+ example/test_rp2.py
29
+ example/test_se.py
30
+ example/test_structure_currents.py
31
+ example/test_surface_patch_currents.py
32
+ necpp_src/config.h
33
+ necpp_src/src/AntennaInput.h
34
+ necpp_src/src/BaseInput.h
35
+ necpp_src/src/CurrentInput.h
36
+ necpp_src/src/PowerBudget.h
37
+ necpp_src/src/RadiationInput.h
38
+ necpp_src/src/XGetopt.cpp
39
+ necpp_src/src/XGetopt.h
40
+ necpp_src/src/c_evlcom.cpp
41
+ necpp_src/src/c_evlcom.h
42
+ necpp_src/src/c_geometry.cpp
43
+ necpp_src/src/c_geometry.h
44
+ necpp_src/src/c_ggrid.cpp
45
+ necpp_src/src/c_ggrid.h
46
+ necpp_src/src/c_plot_card.cpp
47
+ necpp_src/src/c_plot_card.h
48
+ necpp_src/src/common.h
49
+ necpp_src/src/electromag.cpp
50
+ necpp_src/src/electromag.h
51
+ necpp_src/src/libNEC.cpp
52
+ necpp_src/src/libnecpp.h
53
+ necpp_src/src/math_util.h
54
+ necpp_src/src/matrix_algebra.cpp
55
+ necpp_src/src/matrix_algebra.h
56
+ necpp_src/src/misc.cpp
57
+ necpp_src/src/misc.h
58
+ necpp_src/src/nec2cpp.h
59
+ necpp_src/src/nec_card_parser.h
60
+ necpp_src/src/nec_context.cpp
61
+ necpp_src/src/nec_context.h
62
+ necpp_src/src/nec_debug.h
63
+ necpp_src/src/nec_exception.cpp
64
+ necpp_src/src/nec_exception.h
65
+ necpp_src/src/nec_ground.cpp
66
+ necpp_src/src/nec_ground.h
67
+ necpp_src/src/nec_output.cpp
68
+ necpp_src/src/nec_output.h
69
+ necpp_src/src/nec_radiation_pattern.cpp
70
+ necpp_src/src/nec_radiation_pattern.h
71
+ necpp_src/src/nec_results.cpp
72
+ necpp_src/src/nec_results.h
73
+ necpp_src/src/nec_structure_currents.cpp
74
+ necpp_src/src/nec_structure_currents.h
75
+ necpp_src/src/nec_wire.h
76
+ necpp_src/src/safe_array.h
77
+ necpp_src/src/typesafe_stdint.h
78
+ tests/test_examples.py
79
+ tests/test_get_gain.py
@@ -0,0 +1 @@
1
+ numpy