From a326aff9053f9b0b57e0e3da1424aa6773a747cb Mon Sep 17 00:00:00 2001 From: Rounak Singh Date: Mon, 3 Oct 2016 15:11:24 -0400 Subject: [PATCH 01/44] Showing permission error while git submodule update --remote. Changed the git ssh to git https necpp module for public use. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 08e0e53..affaabc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "necpp_src"] path = necpp_src - url = git@github.com:tmolteno/necpp + url = https://github.com/tmolteno/necpp.git \ No newline at end of file From 0dad60b8cf2fbc91116b1d13d6fc3be13704b84d Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 20:19:07 +1200 Subject: [PATCH 02/44] Update to version 1.7.3 --- INSTALL.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 18e1ba9..fc0b5e7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -43,4 +43,4 @@ This will run SWIG a source distribution tarball http://peterdowns.com/posts/first-time-with-pypi.html - python setup.py sdist upload -r pypitest \ No newline at end of file + python setup.py sdist upload -r pypitest diff --git a/setup.py b/setup.py index b307b47..64368c7 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup (name = 'necpp', - version = '1.7.0.3', + version = '1.7.3', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/necpp", From 86ace26bfcdb29386ea6aeb018020548e45c87a8 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 20:41:25 +1200 Subject: [PATCH 03/44] Bump version correctly --- PyNECPP/setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PyNECPP/setup.py b/PyNECPP/setup.py index 0e53092..bd7cf46 100644 --- a/PyNECPP/setup.py +++ b/PyNECPP/setup.py @@ -46,8 +46,8 @@ ) -<<<<<<< HEAD:setup.py -setup (name = 'necpp', + +setup (name = 'PyNEC', version = '1.7.3', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", @@ -65,4 +65,4 @@ "Topic :: Communications :: Ham Radio", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Intended Audience :: Science/Research"] - ) +) From 990445baab43bff382c20727a2e5aa730b7bbc94 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 21:04:21 +1200 Subject: [PATCH 04/44] Moved comments to this README from the global one --- PyNECPP/LICENSE.txt | 340 +++++++++++++++++++++ PyNECPP/README.md | 7 + {PyNEC => necpp}/INSTALL.md | 0 necpp/LICENSE.txt | 340 +++++++++++++++++++++ {PyNEC => necpp}/MANIFEST.in | 0 {PyNEC => necpp}/README.md | 0 {PyNEC => necpp}/build.sh | 0 {PyNEC => necpp}/example/.gitignore | 0 {PyNEC => necpp}/example/Makefile | 0 {PyNEC => necpp}/example/README.md | 0 {PyNEC => necpp}/example/antenna_util.py | 0 {PyNEC => necpp}/example/impedance_plot.py | 0 {PyNEC => necpp}/example/monopole.py | 0 {PyNEC => necpp}/example/optimized.py | 0 {PyNEC => necpp}/necpp.i | 0 {PyNEC => necpp}/setup.cfg | 0 {PyNEC => necpp}/setup.py | 0 17 files changed, 687 insertions(+) create mode 100644 PyNECPP/LICENSE.txt rename {PyNEC => necpp}/INSTALL.md (100%) create mode 100644 necpp/LICENSE.txt rename {PyNEC => necpp}/MANIFEST.in (100%) rename {PyNEC => necpp}/README.md (100%) rename {PyNEC => necpp}/build.sh (100%) rename {PyNEC => necpp}/example/.gitignore (100%) rename {PyNEC => necpp}/example/Makefile (100%) rename {PyNEC => necpp}/example/README.md (100%) rename {PyNEC => necpp}/example/antenna_util.py (100%) rename {PyNEC => necpp}/example/impedance_plot.py (100%) rename {PyNEC => necpp}/example/monopole.py (100%) rename {PyNEC => necpp}/example/optimized.py (100%) rename {PyNEC => necpp}/necpp.i (100%) rename {PyNEC => necpp}/setup.cfg (100%) rename {PyNEC => necpp}/setup.py (100%) diff --git a/PyNECPP/LICENSE.txt b/PyNECPP/LICENSE.txt new file mode 100644 index 0000000..d6a9326 --- /dev/null +++ b/PyNECPP/LICENSE.txt @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/PyNECPP/README.md b/PyNECPP/README.md index 4449822..4e1a92f 100644 --- a/PyNECPP/README.md +++ b/PyNECPP/README.md @@ -4,6 +4,13 @@ This module wraps the C++ API for antenna simulation of nec2++. It is easier to than the C-style API wrapper. +The example directory contains the following additional examples (that are inspired by excercises from a course on antennas): + +* 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. +* 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. +* 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. + + ## Usage Here is an example that plots a radiation pattern. diff --git a/PyNEC/INSTALL.md b/necpp/INSTALL.md similarity index 100% rename from PyNEC/INSTALL.md rename to necpp/INSTALL.md diff --git a/necpp/LICENSE.txt b/necpp/LICENSE.txt new file mode 100644 index 0000000..d6a9326 --- /dev/null +++ b/necpp/LICENSE.txt @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/PyNEC/MANIFEST.in b/necpp/MANIFEST.in similarity index 100% rename from PyNEC/MANIFEST.in rename to necpp/MANIFEST.in diff --git a/PyNEC/README.md b/necpp/README.md similarity index 100% rename from PyNEC/README.md rename to necpp/README.md diff --git a/PyNEC/build.sh b/necpp/build.sh similarity index 100% rename from PyNEC/build.sh rename to necpp/build.sh diff --git a/PyNEC/example/.gitignore b/necpp/example/.gitignore similarity index 100% rename from PyNEC/example/.gitignore rename to necpp/example/.gitignore diff --git a/PyNEC/example/Makefile b/necpp/example/Makefile similarity index 100% rename from PyNEC/example/Makefile rename to necpp/example/Makefile diff --git a/PyNEC/example/README.md b/necpp/example/README.md similarity index 100% rename from PyNEC/example/README.md rename to necpp/example/README.md diff --git a/PyNEC/example/antenna_util.py b/necpp/example/antenna_util.py similarity index 100% rename from PyNEC/example/antenna_util.py rename to necpp/example/antenna_util.py diff --git a/PyNEC/example/impedance_plot.py b/necpp/example/impedance_plot.py similarity index 100% rename from PyNEC/example/impedance_plot.py rename to necpp/example/impedance_plot.py diff --git a/PyNEC/example/monopole.py b/necpp/example/monopole.py similarity index 100% rename from PyNEC/example/monopole.py rename to necpp/example/monopole.py diff --git a/PyNEC/example/optimized.py b/necpp/example/optimized.py similarity index 100% rename from PyNEC/example/optimized.py rename to necpp/example/optimized.py diff --git a/PyNEC/necpp.i b/necpp/necpp.i similarity index 100% rename from PyNEC/necpp.i rename to necpp/necpp.i diff --git a/PyNEC/setup.cfg b/necpp/setup.cfg similarity index 100% rename from PyNEC/setup.cfg rename to necpp/setup.cfg diff --git a/PyNEC/setup.py b/necpp/setup.py similarity index 100% rename from PyNEC/setup.py rename to necpp/setup.py From 39e3b8bf99e676c32799b3dcfdaf255598d36d95 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 21:05:18 +1200 Subject: [PATCH 05/44] Changed name of PyNECPP to the module name PyNEC --- {PyNECPP => PyNEC}/.gitignore | 0 {PyNECPP => PyNEC}/LICENSE.txt | 0 {PyNECPP => PyNEC}/MANIFEST.in | 0 {PyNECPP => PyNEC}/PyNEC.i | 0 {PyNECPP => PyNEC}/README.md | 0 {PyNECPP => PyNEC}/build.sh | 0 {PyNECPP => PyNEC}/example/.gitignore | 0 {PyNECPP => PyNEC}/example/antenna_util.py | 0 {PyNECPP => PyNEC}/example/context_clean.py | 0 {PyNECPP => PyNEC}/example/dipole.py | 0 {PyNECPP => PyNEC}/example/impedance_plot.py | 0 {PyNECPP => PyNEC}/example/logperiodic_opt.py | 0 {PyNECPP => PyNEC}/example/monopole.py | 0 .../example/monopole_realistic_ground_plane.py | 0 {PyNECPP => PyNEC}/example/optimized.py | 0 {PyNECPP => PyNEC}/example/test_ai.py | 0 {PyNECPP => PyNEC}/example/test_charge_densities.py | 0 {PyNECPP => PyNEC}/example/test_ne_nh.py | 0 {PyNECPP => PyNEC}/example/test_nrp.py | 0 {PyNECPP => PyNEC}/example/test_rp.py | 0 {PyNECPP => PyNEC}/example/test_rp2.py | 0 {PyNECPP => PyNEC}/example/test_se.py | 0 .../example/test_structure_currents.py | 0 .../example/test_surface_patch_currents.py | 0 {PyNECPP => PyNEC}/interface_files/c_geometry.i | 0 {PyNECPP => PyNEC}/interface_files/math_util.i | 0 .../interface_files/nec_antenna_input.i | 0 {PyNECPP => PyNEC}/interface_files/nec_context.i | 0 {PyNECPP => PyNEC}/interface_files/nec_ground.i | 0 .../interface_files/nec_near_field_pattern.i | 0 .../interface_files/nec_norm_rx_pattern.i | 0 .../interface_files/nec_radiation_pattern.i | 0 .../interface_files/nec_structure_currents.i | 0 .../interface_files/nec_structure_excitation.i | 0 {PyNECPP => PyNEC}/interface_files/safe_array.i | 0 {PyNECPP => PyNEC}/setup.py | 0 {PyNECPP => PyNEC}/tests/.gitignore | 0 {PyNECPP => PyNEC}/tests/Makefile | 0 {PyNECPP => PyNEC}/tests/__init__.py | 0 {PyNECPP => PyNEC}/tests/test_examples.py | 0 {PyNECPP => PyNEC}/tests/test_get_gain.py | 0 {PyNECPP => PyNEC}/tests/test_multiple_sc_cards.py | 0 README.md | 13 +++---------- necpp/setup.py | 2 +- necpp_src | 2 +- 45 files changed, 5 insertions(+), 12 deletions(-) rename {PyNECPP => PyNEC}/.gitignore (100%) rename {PyNECPP => PyNEC}/LICENSE.txt (100%) rename {PyNECPP => PyNEC}/MANIFEST.in (100%) rename {PyNECPP => PyNEC}/PyNEC.i (100%) rename {PyNECPP => PyNEC}/README.md (100%) rename {PyNECPP => PyNEC}/build.sh (100%) rename {PyNECPP => PyNEC}/example/.gitignore (100%) rename {PyNECPP => PyNEC}/example/antenna_util.py (100%) rename {PyNECPP => PyNEC}/example/context_clean.py (100%) rename {PyNECPP => PyNEC}/example/dipole.py (100%) rename {PyNECPP => PyNEC}/example/impedance_plot.py (100%) rename {PyNECPP => PyNEC}/example/logperiodic_opt.py (100%) rename {PyNECPP => PyNEC}/example/monopole.py (100%) rename {PyNECPP => PyNEC}/example/monopole_realistic_ground_plane.py (100%) rename {PyNECPP => PyNEC}/example/optimized.py (100%) rename {PyNECPP => PyNEC}/example/test_ai.py (100%) rename {PyNECPP => PyNEC}/example/test_charge_densities.py (100%) rename {PyNECPP => PyNEC}/example/test_ne_nh.py (100%) rename {PyNECPP => PyNEC}/example/test_nrp.py (100%) rename {PyNECPP => PyNEC}/example/test_rp.py (100%) rename {PyNECPP => PyNEC}/example/test_rp2.py (100%) rename {PyNECPP => PyNEC}/example/test_se.py (100%) rename {PyNECPP => PyNEC}/example/test_structure_currents.py (100%) rename {PyNECPP => PyNEC}/example/test_surface_patch_currents.py (100%) rename {PyNECPP => PyNEC}/interface_files/c_geometry.i (100%) rename {PyNECPP => PyNEC}/interface_files/math_util.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_antenna_input.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_context.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_ground.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_near_field_pattern.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_norm_rx_pattern.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_radiation_pattern.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_structure_currents.i (100%) rename {PyNECPP => PyNEC}/interface_files/nec_structure_excitation.i (100%) rename {PyNECPP => PyNEC}/interface_files/safe_array.i (100%) rename {PyNECPP => PyNEC}/setup.py (100%) rename {PyNECPP => PyNEC}/tests/.gitignore (100%) rename {PyNECPP => PyNEC}/tests/Makefile (100%) rename {PyNECPP => PyNEC}/tests/__init__.py (100%) rename {PyNECPP => PyNEC}/tests/test_examples.py (100%) rename {PyNECPP => PyNEC}/tests/test_get_gain.py (100%) rename {PyNECPP => PyNEC}/tests/test_multiple_sc_cards.py (100%) diff --git a/PyNECPP/.gitignore b/PyNEC/.gitignore similarity index 100% rename from PyNECPP/.gitignore rename to PyNEC/.gitignore diff --git a/PyNECPP/LICENSE.txt b/PyNEC/LICENSE.txt similarity index 100% rename from PyNECPP/LICENSE.txt rename to PyNEC/LICENSE.txt diff --git a/PyNECPP/MANIFEST.in b/PyNEC/MANIFEST.in similarity index 100% rename from PyNECPP/MANIFEST.in rename to PyNEC/MANIFEST.in diff --git a/PyNECPP/PyNEC.i b/PyNEC/PyNEC.i similarity index 100% rename from PyNECPP/PyNEC.i rename to PyNEC/PyNEC.i diff --git a/PyNECPP/README.md b/PyNEC/README.md similarity index 100% rename from PyNECPP/README.md rename to PyNEC/README.md diff --git a/PyNECPP/build.sh b/PyNEC/build.sh similarity index 100% rename from PyNECPP/build.sh rename to PyNEC/build.sh diff --git a/PyNECPP/example/.gitignore b/PyNEC/example/.gitignore similarity index 100% rename from PyNECPP/example/.gitignore rename to PyNEC/example/.gitignore diff --git a/PyNECPP/example/antenna_util.py b/PyNEC/example/antenna_util.py similarity index 100% rename from PyNECPP/example/antenna_util.py rename to PyNEC/example/antenna_util.py diff --git a/PyNECPP/example/context_clean.py b/PyNEC/example/context_clean.py similarity index 100% rename from PyNECPP/example/context_clean.py rename to PyNEC/example/context_clean.py diff --git a/PyNECPP/example/dipole.py b/PyNEC/example/dipole.py similarity index 100% rename from PyNECPP/example/dipole.py rename to PyNEC/example/dipole.py diff --git a/PyNECPP/example/impedance_plot.py b/PyNEC/example/impedance_plot.py similarity index 100% rename from PyNECPP/example/impedance_plot.py rename to PyNEC/example/impedance_plot.py diff --git a/PyNECPP/example/logperiodic_opt.py b/PyNEC/example/logperiodic_opt.py similarity index 100% rename from PyNECPP/example/logperiodic_opt.py rename to PyNEC/example/logperiodic_opt.py diff --git a/PyNECPP/example/monopole.py b/PyNEC/example/monopole.py similarity index 100% rename from PyNECPP/example/monopole.py rename to PyNEC/example/monopole.py diff --git a/PyNECPP/example/monopole_realistic_ground_plane.py b/PyNEC/example/monopole_realistic_ground_plane.py similarity index 100% rename from PyNECPP/example/monopole_realistic_ground_plane.py rename to PyNEC/example/monopole_realistic_ground_plane.py diff --git a/PyNECPP/example/optimized.py b/PyNEC/example/optimized.py similarity index 100% rename from PyNECPP/example/optimized.py rename to PyNEC/example/optimized.py diff --git a/PyNECPP/example/test_ai.py b/PyNEC/example/test_ai.py similarity index 100% rename from PyNECPP/example/test_ai.py rename to PyNEC/example/test_ai.py diff --git a/PyNECPP/example/test_charge_densities.py b/PyNEC/example/test_charge_densities.py similarity index 100% rename from PyNECPP/example/test_charge_densities.py rename to PyNEC/example/test_charge_densities.py diff --git a/PyNECPP/example/test_ne_nh.py b/PyNEC/example/test_ne_nh.py similarity index 100% rename from PyNECPP/example/test_ne_nh.py rename to PyNEC/example/test_ne_nh.py diff --git a/PyNECPP/example/test_nrp.py b/PyNEC/example/test_nrp.py similarity index 100% rename from PyNECPP/example/test_nrp.py rename to PyNEC/example/test_nrp.py diff --git a/PyNECPP/example/test_rp.py b/PyNEC/example/test_rp.py similarity index 100% rename from PyNECPP/example/test_rp.py rename to PyNEC/example/test_rp.py diff --git a/PyNECPP/example/test_rp2.py b/PyNEC/example/test_rp2.py similarity index 100% rename from PyNECPP/example/test_rp2.py rename to PyNEC/example/test_rp2.py diff --git a/PyNECPP/example/test_se.py b/PyNEC/example/test_se.py similarity index 100% rename from PyNECPP/example/test_se.py rename to PyNEC/example/test_se.py diff --git a/PyNECPP/example/test_structure_currents.py b/PyNEC/example/test_structure_currents.py similarity index 100% rename from PyNECPP/example/test_structure_currents.py rename to PyNEC/example/test_structure_currents.py diff --git a/PyNECPP/example/test_surface_patch_currents.py b/PyNEC/example/test_surface_patch_currents.py similarity index 100% rename from PyNECPP/example/test_surface_patch_currents.py rename to PyNEC/example/test_surface_patch_currents.py diff --git a/PyNECPP/interface_files/c_geometry.i b/PyNEC/interface_files/c_geometry.i similarity index 100% rename from PyNECPP/interface_files/c_geometry.i rename to PyNEC/interface_files/c_geometry.i diff --git a/PyNECPP/interface_files/math_util.i b/PyNEC/interface_files/math_util.i similarity index 100% rename from PyNECPP/interface_files/math_util.i rename to PyNEC/interface_files/math_util.i diff --git a/PyNECPP/interface_files/nec_antenna_input.i b/PyNEC/interface_files/nec_antenna_input.i similarity index 100% rename from PyNECPP/interface_files/nec_antenna_input.i rename to PyNEC/interface_files/nec_antenna_input.i diff --git a/PyNECPP/interface_files/nec_context.i b/PyNEC/interface_files/nec_context.i similarity index 100% rename from PyNECPP/interface_files/nec_context.i rename to PyNEC/interface_files/nec_context.i diff --git a/PyNECPP/interface_files/nec_ground.i b/PyNEC/interface_files/nec_ground.i similarity index 100% rename from PyNECPP/interface_files/nec_ground.i rename to PyNEC/interface_files/nec_ground.i diff --git a/PyNECPP/interface_files/nec_near_field_pattern.i b/PyNEC/interface_files/nec_near_field_pattern.i similarity index 100% rename from PyNECPP/interface_files/nec_near_field_pattern.i rename to PyNEC/interface_files/nec_near_field_pattern.i diff --git a/PyNECPP/interface_files/nec_norm_rx_pattern.i b/PyNEC/interface_files/nec_norm_rx_pattern.i similarity index 100% rename from PyNECPP/interface_files/nec_norm_rx_pattern.i rename to PyNEC/interface_files/nec_norm_rx_pattern.i diff --git a/PyNECPP/interface_files/nec_radiation_pattern.i b/PyNEC/interface_files/nec_radiation_pattern.i similarity index 100% rename from PyNECPP/interface_files/nec_radiation_pattern.i rename to PyNEC/interface_files/nec_radiation_pattern.i diff --git a/PyNECPP/interface_files/nec_structure_currents.i b/PyNEC/interface_files/nec_structure_currents.i similarity index 100% rename from PyNECPP/interface_files/nec_structure_currents.i rename to PyNEC/interface_files/nec_structure_currents.i diff --git a/PyNECPP/interface_files/nec_structure_excitation.i b/PyNEC/interface_files/nec_structure_excitation.i similarity index 100% rename from PyNECPP/interface_files/nec_structure_excitation.i rename to PyNEC/interface_files/nec_structure_excitation.i diff --git a/PyNECPP/interface_files/safe_array.i b/PyNEC/interface_files/safe_array.i similarity index 100% rename from PyNECPP/interface_files/safe_array.i rename to PyNEC/interface_files/safe_array.i diff --git a/PyNECPP/setup.py b/PyNEC/setup.py similarity index 100% rename from PyNECPP/setup.py rename to PyNEC/setup.py diff --git a/PyNECPP/tests/.gitignore b/PyNEC/tests/.gitignore similarity index 100% rename from PyNECPP/tests/.gitignore rename to PyNEC/tests/.gitignore diff --git a/PyNECPP/tests/Makefile b/PyNEC/tests/Makefile similarity index 100% rename from PyNECPP/tests/Makefile rename to PyNEC/tests/Makefile diff --git a/PyNECPP/tests/__init__.py b/PyNEC/tests/__init__.py similarity index 100% rename from PyNECPP/tests/__init__.py rename to PyNEC/tests/__init__.py diff --git a/PyNECPP/tests/test_examples.py b/PyNEC/tests/test_examples.py similarity index 100% rename from PyNECPP/tests/test_examples.py rename to PyNEC/tests/test_examples.py diff --git a/PyNECPP/tests/test_get_gain.py b/PyNEC/tests/test_get_gain.py similarity index 100% rename from PyNECPP/tests/test_get_gain.py rename to PyNEC/tests/test_get_gain.py diff --git a/PyNECPP/tests/test_multiple_sc_cards.py b/PyNEC/tests/test_multiple_sc_cards.py similarity index 100% rename from PyNECPP/tests/test_multiple_sc_cards.py rename to PyNEC/tests/test_multiple_sc_cards.py diff --git a/README.md b/README.md index 4c4b5b3..3b597f1 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,10 @@ This repository contains two wrappers for the nec2++ antenna simulation package: -* PyNEC/ contains a wrapper using SWIG of the C interface (Python module name: necpp). -* PyNECPP/ contains a wrapper of the C++ interfaces (Python module name: PyNEC). The example/ directory furthermore contains some nicer, more readable Python wrappers that make toying around with NEC a less painful experience. +* necpp/ contains a wrapper using SWIG of the C interface (Python module name: necpp). +* PyNEC/ contains a wrapper of the C++ interfaces (Python module name: PyNEC). The example/ directory furthermore contains some nicer, more readable Python wrappers that make toying around with NEC a less painful experience. -Both are based on Tim Molteno (tim@physics.otago.ac.nz)'s code. - -Personally, I (Bart Coppens, kde@bartcoppens.be) am more interested in a slightly cleaned-up version of the C++ interface wrappers. (I might still rename the Python module names to match the directory names, or rename the directories, or both). In particular, as mentioned above, PyNECPP/example contains context_clean.py, which separates some of the NEC cards with multiple options into multiple functions (with named arguments that make sense, rather than itmp1, itmp2, etc). I've only really done this for the code I was playing around with in the example/ subdirectory, though, lots of cards (and sub-functionalities of cards) remain unwrapped/unported. Still, I found it to be nicer. - -The PyNECPP/example directory contains the following additional examples (that are inspired by excercises from a course on antennas): -* 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. -* 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. -* 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. +Both are based on Tim Molteno (tim@physics.otago.ac.nz)'s code with major cleanup by Bart Coppens. ## TODOs The cleaner API should really be **ported to C++**, so the clean wrappers get automatically generated, and C++ can use the same cleaner interface. But for now, I'm happy with the Python wrapper :) diff --git a/necpp/setup.py b/necpp/setup.py index c2de108..cfeec39 100644 --- a/necpp/setup.py +++ b/necpp/setup.py @@ -33,7 +33,7 @@ setup (name = 'necpp', - version = '1.7.0.3', + version = '1.7.3', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/necpp", diff --git a/necpp_src b/necpp_src index ebfb4d4..a033992 160000 --- a/necpp_src +++ b/necpp_src @@ -1 +1 @@ -Subproject commit ebfb4d475601288b93ccdf7b639d35eb1f0700dd +Subproject commit a0339925a6fafa29c5b6d9a04bcfd3d406ad7ea3 From cc2e87551905f9c900ab61dcf9b7d9a3eb12e1dc Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 21:27:58 +1200 Subject: [PATCH 06/44] Update syntax to be python3 compatable --- necpp/example/monopole.py | 6 +++--- necpp/example/optimized.py | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/necpp/example/monopole.py b/necpp/example/monopole.py index 725cb4d..4ccf0a8 100644 --- a/necpp/example/monopole.py +++ b/necpp/example/monopole.py @@ -7,7 +7,7 @@ def handle_nec(result): if (result != 0): - print nec_error_message() + print(nec_error_message()) def geometry(freq, base, length): @@ -24,7 +24,7 @@ def geometry(freq, base, length): 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, n_seg/3, 0, 1.0, 0, 0, 0, 0, 0)) + handle_nec(nec_ex_card(nec, 0, 0, int(n_seg/3), 0, 1.0, 0, 0, 0, 0, 0)) return nec @@ -38,4 +38,4 @@ def impedance(freq, base, length): 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) + print("Impedance at base=%0.2f, length=%0.2f : (%6.1f,%+6.1fI) Ohms" % (0.5, 4.0, z.real, z.imag)) diff --git a/necpp/example/optimized.py b/necpp/example/optimized.py index 96317eb..2d1778d 100644 --- a/necpp/example/optimized.py +++ b/necpp/example/optimized.py @@ -27,5 +27,4 @@ def target(x): base_height = np.exp(log_base) length = np.exp(log_length) -print "Optimium base_height=%fm, h=%fm, impedance=%s Ohms" % \ - (base_height, length, monopole.impedance(freq, base_height, length)) +print("Optimium base_height={}m, h={}m, impedance={} Ohms".format(base_height, length, monopole.impedance(freq, base_height, length))) From 16540e66ef6578b4773565e3388982bd07ee2ce6 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 21:31:44 +1200 Subject: [PATCH 07/44] Updated languages to show that python3 is supported --- necpp/setup.py | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/necpp/setup.py b/necpp/setup.py index cfeec39..69f8cc7 100644 --- a/necpp/setup.py +++ b/necpp/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -setup.py file for necpp Python module +setup.py file for necpp Python module. """ from distutils.core import setup, Extension @@ -33,20 +33,26 @@ setup (name = 'necpp', - version = '1.7.3', - author = "Tim Molteno", - author_email = "tim@physics.otago.ac.nz", - url = "http://github.com/tmolteno/necpp", - keywords = "nec2 nec2++ antenna electromagnetism radio", - description = "Python Antenna Simulation Module (nec2++) C-style interface", - data_files=[('examples', ['necpp_src/example/test.py'])], - ext_modules = [necpp_module], - py_modules = ["necpp"], - license='GPLv2', - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Topic :: Scientific/Engineering", - "Topic :: Communications :: Ham Radio", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Intended Audience :: Science/Research"] - ) + version = '1.7.3', + author = "Tim Molteno", + author_email = "tim@physics.otago.ac.nz", + url = "http://github.com/tmolteno/necpp", + keywords = "nec2 nec2++ antenna electromagnetism radio", + description = "Python Antenna Simulation Module (nec2++) C-style interface", + data_files=[('examples', ['../necpp_src/example/test.py'])], + ext_modules = [necpp_module], + py_modules = ["necpp"], + license='GPLv2', + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Topic :: Scientific/Engineering", + "Topic :: Communications :: Ham Radio", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + "Intended Audience :: Science/Research"] +) From 7a346aa17f95cbde53ea93d96d93132b7f23faec Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 21:54:33 +1200 Subject: [PATCH 08/44] Get long description working in PyPi. Also update manifext and install instructions. --- necpp/INSTALL.md | 4 +++- necpp/MANIFEST.in | 6 +++--- necpp/README.md | 8 ++++++-- necpp/setup.py | 5 ++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/necpp/INSTALL.md b/necpp/INSTALL.md index fc0b5e7..499cc1d 100644 --- a/necpp/INSTALL.md +++ b/necpp/INSTALL.md @@ -4,7 +4,7 @@ PyPI module for nec2++ This module allows you to do antenna simulations in Python using the nec2++ antenna simulation package. This is a wrapper using SWIG of the C interface, so the syntax is quite simple. Have a look at the file test.py, for an example of how this -library can be used. +library can be used. Other examples are in the 'examples' directory. ### Author @@ -30,6 +30,8 @@ To update the submodule to the latest necpp ### Converting from MarkDown sudo aptitude install pandoc swig + + pandoc --to=rst README.md > README.txt ### Testing diff --git a/necpp/MANIFEST.in b/necpp/MANIFEST.in index 4092210..0c11346 100644 --- a/necpp/MANIFEST.in +++ b/necpp/MANIFEST.in @@ -1,7 +1,7 @@ include LICENCE.txt -include necpp_src/src/*.h +include ../necpp_src/src/*.h -include necpp_src/config.h +include ../necpp_src/config.h -include necpp_src/example/test.py \ No newline at end of file +include ../necpp_src/example/test.py diff --git a/necpp/README.md b/necpp/README.md index 1c997e4..28ad3c9 100644 --- a/necpp/README.md +++ b/necpp/README.md @@ -1,7 +1,9 @@ # python-necpp: Antenna simulation in python This module allows you to do antenna simulations in Python using the nec2++ antenna -simulation package. This is a wrapper using SWIG of the C interface, so the syntax +simulation package. + +This is a wrapper using SWIG of the C interface, so the syntax is quite simple. Have a look at the file necpp_src/example/test.py, for an example of how this library can be used. @@ -9,9 +11,11 @@ Tim Molteno. tim@physics.otago.ac.nz ## NEWS +* Version 1.7.3 Includes Python3 support. Also some bug fixes and updating nec++ to the + latest version. +* Version 1.7.0.3 includes nec_medium_parameters(). You could simulate an antenna in seawater! * Version 1.7.0 includes support for getting elements of radiation patterns. At the moment this is just through the function nec_get_gain(). -* Version 1.7.0.3 includes nec_medium_parameters(). You could simulate an antenna in seawater! ## Install diff --git a/necpp/setup.py b/necpp/setup.py index 69f8cc7..8040245 100644 --- a/necpp/setup.py +++ b/necpp/setup.py @@ -31,14 +31,17 @@ define_macros=[('BUILD_PYTHON', '1')] ) +with open('README.txt') as f: + readme = f.read() setup (name = 'necpp', - version = '1.7.3', + version = '1.7.3.2', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/necpp", keywords = "nec2 nec2++ antenna electromagnetism radio", description = "Python Antenna Simulation Module (nec2++) C-style interface", + long_description=readme, data_files=[('examples', ['../necpp_src/example/test.py'])], ext_modules = [necpp_module], py_modules = ["necpp"], From 3f6df2caea4a799d83db468eb7de813be92a0c62 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 21:55:37 +1200 Subject: [PATCH 09/44] Update description to include long description file --- PyNEC/MANIFEST.in | 7 ++++--- PyNEC/README.md | 16 ++++++++-------- PyNEC/setup.py | 38 +++++++++++++++++++++----------------- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/PyNEC/MANIFEST.in b/PyNEC/MANIFEST.in index 4092210..5b3d3ed 100644 --- a/PyNEC/MANIFEST.in +++ b/PyNEC/MANIFEST.in @@ -1,7 +1,8 @@ include LICENCE.txt -include necpp_src/src/*.h +include ../necpp_src/src/*.h -include necpp_src/config.h +include ../necpp_src/config.h + +include example/*.py -include necpp_src/example/test.py \ No newline at end of file diff --git a/PyNEC/README.md b/PyNEC/README.md index 4e1a92f..56bc5fa 100644 --- a/PyNEC/README.md +++ b/PyNEC/README.md @@ -3,14 +3,6 @@ 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. - -The example directory contains the following additional examples (that are inspired by excercises from a course on antennas): - -* 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. -* 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. -* 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. - - ## Usage Here is an example that plots a radiation pattern. @@ -74,3 +66,11 @@ Here is an example that plots a radiation pattern. python example/test_rp.py + +The example directory contains the following additional examples (that are inspired by excercises from a course on antennas): + +* 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. +* 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. +* 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. + + diff --git a/PyNEC/setup.py b/PyNEC/setup.py index bd7cf46..dd8d0bd 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -32,6 +32,9 @@ nec_headers.extend(glob("../necpp_src/src/*.h")) nec_headers.extend(glob("../necpp_src/config.h")) +with open('README.txt') as f: + readme = f.read() + # At the moment, the config.h file is needed, and this should be generated from the ./configure # command in the parent directory. Use ./configure --without-lapack to avoid dependance on LAPACK @@ -48,21 +51,22 @@ setup (name = 'PyNEC', - version = '1.7.3', - author = "Tim Molteno", - author_email = "tim@physics.otago.ac.nz", - url = "http://github.com/tmolteno/necpp", - keywords = "nec2 nec2++ antenna electromagnetism radio", - description = "Python Antenna Simulation Module (nec2++) object-oriented interface", - data_files=[('examples', ['example/test_rp.py'])], - ext_modules = [necpp_module], - requires = ['numpy'], - py_modules = ["PyNEC"], - license='GPLv2', - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Topic :: Scientific/Engineering", - "Topic :: Communications :: Ham Radio", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Intended Audience :: Science/Research"] + version = '1.7.3.1', + author = "Tim Molteno", + author_email = "tim@physics.otago.ac.nz", + url = "http://github.com/tmolteno/necpp", + keywords = "nec2 nec2++ antenna electromagnetism radio", + description = "Python Antenna Simulation Module (nec2++) object-oriented interface", + long_description=readme, + data_files=[('examples', ['example/test_rp.py'])], + ext_modules = [necpp_module], + requires = ['numpy'], + py_modules = ["PyNEC"], + license='GPLv2', + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Topic :: Scientific/Engineering", + "Topic :: Communications :: Ham Radio", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + "Intended Audience :: Science/Research"] ) From 105a16eb651aa5609b8b03c2e4cff5507e9a304e Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 21 Aug 2017 23:10:25 +1200 Subject: [PATCH 10/44] Example showing how to get a radiation pattern --- PyNEC/example/radiation_pattern.py | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 PyNEC/example/radiation_pattern.py diff --git a/PyNEC/example/radiation_pattern.py b/PyNEC/example/radiation_pattern.py new file mode 100644 index 0000000..7f0842c --- /dev/null +++ b/PyNEC/example/radiation_pattern.py @@ -0,0 +1,53 @@ +# +# Simple vertical monopole antenna simulation using python-necpp +# pip install necpp +# +from PyNEC import * + +import math + +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 = context_clean(nec_context()) + nec = nec_context() + + geo = nec.get_geometry() + geo.wire(1, n_seg, 0, 0, base, 0, 0, base+length, 0.002, 1.0, 1.0) + nec.geometry_complete(1) + + nec.ld_card(5, 0, 0, 0, conductivity, 0.0, 0.0) + nec.gn_card(0, 0, ground_dielectric, ground_conductivity, 0, 0, 0, 0) + nec.fr_card(0, 1, freq, 0) + + # Voltage excitation one third of the way along the wire + nec.ex_card(0, 0, int(n_seg/3), 0, 1.0, 0, 0, 0, 0, 0) + + return nec + +nec = geometry(freq=123.4, base=0.5, length=4.0) +nec.rp_card(calc_mode=0, n_theta=30, n_phi=30, output_format=0, normalization=0, D=0, A=0, theta0=0, delta_theta=10, phi0=0, delta_phi=5, radial_distance=0, gain_norm=0) +nec.xq_card(0) # Execute simulation + +ipt = nec.get_input_parameters(0) +z = ipt.get_impedance() +print("Impedance is {}".format(z)) + +rpt = nec.get_radiation_pattern(0) + +complex_e_field = rpt.get_e_theta() +e = complex_e_field.reshape((30,30)) + +print(complex_e_field.size) + +for t in range(30): + for p in range(30): + pass + print e[t, p] + +print dir(rpt) From 62d6205ca18677344c9f3b994f1166b66f1e4ddc Mon Sep 17 00:00:00 2001 From: Rounak Singh Date: Mon, 4 Dec 2017 19:24:12 -0500 Subject: [PATCH 11/44] submodule necpp: updated to commit 0af22b1... --- necpp_src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/necpp_src b/necpp_src index a033992..0af22b1 160000 --- a/necpp_src +++ b/necpp_src @@ -1 +1 @@ -Subproject commit a0339925a6fafa29c5b6d9a04bcfd3d406ad7ea3 +Subproject commit 0af22b10d5b8e96da412009ef1178f1b4131cbb8 From a27ed937f79498e7ada9f73b4bd1344d6370cd56 Mon Sep 17 00:00:00 2001 From: Rounak Singh Date: Tue, 5 Dec 2017 01:15:36 -0500 Subject: [PATCH 12/44] setup.py upgraded to setuptools -- Issue #7. config.h dir added for 32-bit. Readme updated. --- PyNEC/.gitignore | 3 +++ PyNEC/README.md | 43 ++++++++++++++++++++++++++++++++----------- PyNEC/build.sh | 3 ++- PyNEC/setup.py | 27 ++++++++++++--------------- 4 files changed, 49 insertions(+), 27 deletions(-) diff --git a/PyNEC/.gitignore b/PyNEC/.gitignore index a713962..f0766ac 100644 --- a/PyNEC/.gitignore +++ b/PyNEC/.gitignore @@ -1,2 +1,5 @@ build/** *.pyc +PyNEC.py +*.cxx +*.png \ No newline at end of file diff --git a/PyNEC/README.md b/PyNEC/README.md index 56bc5fa..837a7db 100644 --- a/PyNEC/README.md +++ b/PyNEC/README.md @@ -1,7 +1,7 @@ # Python NEC2++ Module -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. +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+. + ## Usage @@ -52,21 +52,42 @@ Here is an example that plots a radiation pattern. plt.savefig('RadiationPattern.png') plt.show() +## Build + +Requirements + +* [Pandoc](https://pandoc.org/) +* [Swig](http://www.swig.org/) +* configure & make +* pip +* setuptools +* wheel +*Note: For Windows: Compling requires [C/C++ compliers](https://wiki.python.org/moin/WindowsCompilers). Also, add the path to swig.exe to environment.* + + + $ git clone --recursive https://github.com/tmolteno/python-necpp.git + $ cd python-necpp + $ cd PyNEC + $ ./build.sh + $ python setup.py bdist_wheel + $ sudo python setup.py install + + *Note: sudo is not required in windows.* + ## Install - git clone https://github.com/tmolteno/python-necpp.git - cd python-necpp - git submodule init - git submodule update --remote - cd PyNEC - ./build.sh - sudo python setup.py install + $ sudo pip install pynec + *Note: sudo is not required in windows.* ## Testing - python example/test_rp.py +Requirements - +* matplotlib + + $ python example/test_rp.py + + The example directory contains the following additional examples (that are inspired by excercises from a course on antennas): * 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. diff --git a/PyNEC/build.sh b/PyNEC/build.sh index 9712711..a6566dd 100755 --- a/PyNEC/build.sh +++ b/PyNEC/build.sh @@ -5,7 +5,8 @@ # Author. Tim Molteno. # git submodule update --remote -# + +# In windows this generates error since, the make, configure,libtoolize shows ignorable error pushd ../necpp_src make -f Makefile.git ./configure --without-lapack diff --git a/PyNEC/setup.py b/PyNEC/setup.py index dd8d0bd..ccc779c 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -6,18 +6,19 @@ Author Tim Molteno. tim@molteno.net """ -from distutils.core import setup, Extension -import distutils.sysconfig +from setuptools import setup +from setuptools.extension import Extension +#import distutils.sysconfig from glob import glob import os import numpy as np - +import io # Remove silly flags from the compilation to avoid warnings. -cfg_vars = distutils.sysconfig.get_config_vars() -for key, value in cfg_vars.items(): - if type(value) == str: - cfg_vars[key] = value.replace("-Wstrict-prototypes", "") +#cfg_vars = distutils.sysconfig.get_config_vars() +#for key, value in cfg_vars.items(): +# if type(value) == str: +# cfg_vars[key] = value.replace("-Wstrict-prototypes", "") # Generate a list of the sources. nec_sources = [] @@ -32,23 +33,19 @@ nec_headers.extend(glob("../necpp_src/src/*.h")) nec_headers.extend(glob("../necpp_src/config.h")) -with open('README.txt') as f: - readme = f.read() - +readme = io.open('README.txt').read() # At the moment, the config.h file is needed, and this should be generated from the ./configure # command in the parent directory. Use ./configure --without-lapack to avoid dependance on LAPACK # necpp_module = Extension('_PyNEC', sources=nec_sources, - include_dirs=[np.get_include(), '../necpp_src/src', '../necpp_src/'], + include_dirs=[np.get_include(), '../necpp_src/src', '../necpp_src/','../necpp_src/win32/nec2++'], extra_compile_args = ['-fPIC'], extra_link_args = ['-lstdc++'], depends=nec_headers, - define_macros=[('BUILD_PYTHON', '1'), ('NPY_NO_DEPRECATED_API','NPY_1_7_API_VERSION')] - ) - - + define_macros=[('BUILD_PYTHON', '1'), ('NPY_NO_DEPRECATED_API','NPY_1_7_API_VERSION')], +) setup (name = 'PyNEC', version = '1.7.3.1', From 542495c7244b747563cff21b2ffbcf80db8c0d85 Mon Sep 17 00:00:00 2001 From: Rounak Singh Date: Tue, 5 Dec 2017 01:32:20 -0500 Subject: [PATCH 13/44] PyNEC readme updated. --- PyNEC/README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/PyNEC/README.md b/PyNEC/README.md index 837a7db..28663c5 100644 --- a/PyNEC/README.md +++ b/PyNEC/README.md @@ -52,32 +52,33 @@ Here is an example that plots a radiation pattern. plt.savefig('RadiationPattern.png') plt.show() -## Build +## Manual Build & install Requirements -* [Pandoc](https://pandoc.org/) +* [Pandoc](https://pandoc.org/) * [Swig](http://www.swig.org/) * configure & make * pip * setuptools * wheel -*Note: For Windows: Compling requires [C/C++ compliers](https://wiki.python.org/moin/WindowsCompilers). Also, add the path to swig.exe to environment.* + +*Note: For Windows: Building requires [C/C++ compliers](https://wiki.python.org/moin/WindowsCompilers). Download and extract swigwin.zip and add the path to swig.exe to environment.* $ git clone --recursive https://github.com/tmolteno/python-necpp.git $ cd python-necpp $ cd PyNEC $ ./build.sh - $ python setup.py bdist_wheel $ sudo python setup.py install - *Note: sudo is not required in windows.* + *Note: 1) For windows: sudo is not required. 2) For generating wheels, use `$ python setup.py bdist_wheel`* -## Install +## Install from PyPI $ sudo pip install pynec - *Note: sudo is not required in windows.* + + *Note: sudo is not required in windows. * ## Testing From af9d26d4682a2d7fd38381efa00beb3b95f8855b Mon Sep 17 00:00:00 2001 From: Rounak Singh Date: Tue, 5 Dec 2017 04:40:13 -0500 Subject: [PATCH 14/44] updated Readme.md. #4, #6 and #7. Build still needs a work-around see tmolteno/necpp#51 --- PyNEC/README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/PyNEC/README.md b/PyNEC/README.md index 28663c5..1829c1d 100644 --- a/PyNEC/README.md +++ b/PyNEC/README.md @@ -56,39 +56,40 @@ Here is an example that plots a radiation pattern. Requirements -* [Pandoc](https://pandoc.org/) -* [Swig](http://www.swig.org/) -* configure & make -* pip -* setuptools -* wheel +* [Pandoc](https://pandoc.org/installing.html) +* [Swig](http://www.swig.org/download.html) +* For Windows: [C/C++ compilers](https://wiki.python.org/moin/WindowsCompilers). +* Git bash (for running build.sh script) +* Latest python packages: pip, setuptools, numpy, wheel, numpy. Run: +`$ pip install --upgrade pip setuptools wheel numpy` -*Note: For Windows: Building requires [C/C++ compliers](https://wiki.python.org/moin/WindowsCompilers). Download and extract swigwin.zip and add the path to swig.exe to environment.* +*Note: Download and extract swigwin.zip and add the path to swig.exe to environment.* +Then do following: $ git clone --recursive https://github.com/tmolteno/python-necpp.git $ cd python-necpp $ cd PyNEC $ ./build.sh + $ python setup.py bdist_wheel (For generating wheel, requires wheel package) $ sudo python setup.py install - *Note: 1) For windows: sudo is not required. 2) For generating wheels, use `$ python setup.py bdist_wheel`* +*Note: 'sudo' is not required in windows.* ## Install from PyPI $ sudo pip install pynec - *Note: sudo is not required in windows. * +*Note: 'sudo' is not required in windows.* ## Testing Requirements -* matplotlib +* python package: matplotlib $ python example/test_rp.py - The example directory contains the following additional examples (that are inspired by excercises from a course on antennas): * 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. From 8715f378514782fc3acb8ed9bcd1215ec8363413 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 27 Apr 2018 12:54:19 +1200 Subject: [PATCH 15/44] Updated to include more source files in the source distribution --- necpp/MANIFEST.in | 8 ++++---- necpp/build.sh | 4 +++- necpp/setup.py | 10 +++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/necpp/MANIFEST.in b/necpp/MANIFEST.in index 0c11346..bb7bd4c 100644 --- a/necpp/MANIFEST.in +++ b/necpp/MANIFEST.in @@ -1,7 +1,7 @@ include LICENCE.txt -include ../necpp_src/src/*.h +include necpp_src/src/*.h +include necpp_src/config.h -include ../necpp_src/config.h - -include ../necpp_src/example/test.py +include necpp_src/example/test.py +include example/*.py diff --git a/necpp/build.sh b/necpp/build.sh index 41b1359..a55abcf 100755 --- a/necpp/build.sh +++ b/necpp/build.sh @@ -1,12 +1,14 @@ #!/bin/bash # Script to build the nec2++ python module. git submodule update --remote +ln -s ../necpp_src . pushd ../necpp_src make -f Makefile.git ./configure --without-lapack popd pandoc -o README.txt README.md PYTHON=python -swig -v -I../necpp_src/src/ -python necpp.i +swig -v -Inecpp_src/src/ -python necpp.i python setup.py build +python setup.py dist #sudo python setup.py install diff --git a/necpp/setup.py b/necpp/setup.py index 8040245..9516683 100644 --- a/necpp/setup.py +++ b/necpp/setup.py @@ -9,7 +9,7 @@ import os nec_sources = [] -nec_sources.extend([fn for fn in glob('../necpp_src/src/*.cpp') +nec_sources.extend([fn for fn in glob('necpp_src/src/*.cpp') if not os.path.basename(fn).endswith('_tb.cpp') if not os.path.basename(fn).startswith('net_solve.cpp') if not os.path.basename(fn).startswith('nec2cpp.cpp') @@ -17,8 +17,8 @@ nec_sources.extend(glob("necpp_wrap.c")) nec_headers = [] -nec_headers.extend(glob("../necpp_src/src/*.h")) -nec_headers.extend(glob("../necpp_src/config.h")) +nec_headers.extend(glob("necpp_src/src/*.h")) +nec_headers.extend(glob("necpp_src/config.h")) # At the moment, the config.h file is needed, and this should be generated from the ./configure @@ -26,7 +26,7 @@ # necpp_module = Extension('_necpp', sources=nec_sources, - include_dirs=['../necpp_src/src/', '../necpp_src/'], + include_dirs=['necpp_src/src/', 'necpp_src/'], depends=nec_headers, define_macros=[('BUILD_PYTHON', '1')] ) @@ -35,7 +35,7 @@ readme = f.read() setup (name = 'necpp', - version = '1.7.3.2', + version = '1.7.3.3', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/necpp", From b5bf591bccf88748fc05dfcf53aa74b69298b691 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 27 Apr 2018 14:39:44 +1200 Subject: [PATCH 16/44] Added improved source handling - the sources werent being included in the sdist --- PyNEC/MANIFEST.in | 4 ++-- PyNEC/build.sh | 5 +++-- PyNEC/setup.py | 10 +++++----- README.md | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/PyNEC/MANIFEST.in b/PyNEC/MANIFEST.in index 5b3d3ed..181a486 100644 --- a/PyNEC/MANIFEST.in +++ b/PyNEC/MANIFEST.in @@ -1,8 +1,8 @@ include LICENCE.txt -include ../necpp_src/src/*.h +include necpp_src/src/*.h -include ../necpp_src/config.h +include necpp_src/config.h include example/*.py diff --git a/PyNEC/build.sh b/PyNEC/build.sh index 9712711..dfaed9e 100755 --- a/PyNEC/build.sh +++ b/PyNEC/build.sh @@ -6,7 +6,8 @@ # git submodule update --remote # -pushd ../necpp_src +ln -s ../necpp_src . +pushd necpp_src make -f Makefile.git ./configure --without-lapack popd @@ -16,4 +17,4 @@ pandoc -o README.txt README.md # Build PyNEC swig -Wall -v -c++ -python PyNEC.i -python setup.py build \ No newline at end of file +python setup.py build diff --git a/PyNEC/setup.py b/PyNEC/setup.py index dd8d0bd..8ce5771 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -21,7 +21,7 @@ # Generate a list of the sources. nec_sources = [] -nec_sources.extend([fn for fn in glob('../necpp_src/src/*.cpp') +nec_sources.extend([fn for fn in glob('necpp_src/src/*.cpp') if not os.path.basename(fn).endswith('_tb.cpp') if not os.path.basename(fn).startswith('net_solve.cpp') if not os.path.basename(fn).startswith('nec2cpp.cpp') @@ -29,8 +29,8 @@ nec_sources.extend(glob("PyNEC_wrap.cxx")) nec_headers = [] -nec_headers.extend(glob("../necpp_src/src/*.h")) -nec_headers.extend(glob("../necpp_src/config.h")) +nec_headers.extend(glob("necpp_src/src/*.h")) +nec_headers.extend(glob("necpp_src/config.h")) with open('README.txt') as f: readme = f.read() @@ -41,7 +41,7 @@ # necpp_module = Extension('_PyNEC', sources=nec_sources, - include_dirs=[np.get_include(), '../necpp_src/src', '../necpp_src/'], + include_dirs=[np.get_include(), 'necpp_src/src', 'necpp_src/'], extra_compile_args = ['-fPIC'], extra_link_args = ['-lstdc++'], depends=nec_headers, @@ -51,7 +51,7 @@ setup (name = 'PyNEC', - version = '1.7.3.1', + version = '1.7.3.3', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/necpp", diff --git a/README.md b/README.md index 3b597f1..9e20312 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # python-necpp: Antenna simulation in python -This repository contains two wrappers for the nec2++ antenna simulation package: +This repository contains two wrappers for the [http://github.com/tmolteno/necpp nec2++] antenna simulation package: * necpp/ contains a wrapper using SWIG of the C interface (Python module name: necpp). * PyNEC/ contains a wrapper of the C++ interfaces (Python module name: PyNEC). The example/ directory furthermore contains some nicer, more readable Python wrappers that make toying around with NEC a less painful experience. @@ -8,4 +8,5 @@ This repository contains two wrappers for the nec2++ antenna simulation package: Both are based on Tim Molteno (tim@physics.otago.ac.nz)'s code with major cleanup by Bart Coppens. ## TODOs + The cleaner API should really be **ported to C++**, so the clean wrappers get automatically generated, and C++ can use the same cleaner interface. But for now, I'm happy with the Python wrapper :) From 30158674311b3c2ddb6872196954f7e075e1866f Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 3 May 2018 16:23:27 +1200 Subject: [PATCH 17/44] Added an example that uses a different material --- necpp/example/different_material.py | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 necpp/example/different_material.py diff --git a/necpp/example/different_material.py b/necpp/example/different_material.py new file mode 100644 index 0000000..92b87c1 --- /dev/null +++ b/necpp/example/different_material.py @@ -0,0 +1,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)) From ccfefc5d3589d25e8046ac7d5bad47bf2a4d45d9 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 01:18:57 +1200 Subject: [PATCH 18/44] Update setuptools. Add install instructions --- PyNEC/INSTALL.md | 17 +++++++++++++++++ PyNEC/{LICENSE.txt => LICENCE.txt} | 0 PyNEC/build.sh | 13 ++++++------- PyNEC/setup.py | 22 ++++++++++++---------- 4 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 PyNEC/INSTALL.md rename PyNEC/{LICENSE.txt => LICENCE.txt} (100%) diff --git a/PyNEC/INSTALL.md b/PyNEC/INSTALL.md new file mode 100644 index 0000000..06059a3 --- /dev/null +++ b/PyNEC/INSTALL.md @@ -0,0 +1,17 @@ +## Building from Source + + aptitude install swig3.0 + git submodule init + git submodule update --remote + cd PyNEC + ./build.sh + sudo python setup.py install + + +## Uploading the package to pypi + +Source & Binary Distribution + python3 setup.py sdist + python3 setup.py bdist_wheel + + python3 setup.py upload diff --git a/PyNEC/LICENSE.txt b/PyNEC/LICENCE.txt similarity index 100% rename from PyNEC/LICENSE.txt rename to PyNEC/LICENCE.txt diff --git a/PyNEC/build.sh b/PyNEC/build.sh index dfaed9e..6ec0a01 100755 --- a/PyNEC/build.sh +++ b/PyNEC/build.sh @@ -4,17 +4,16 @@ # # Author. Tim Molteno. # +# FIrst have to do git submodule init git submodule update --remote # ln -s ../necpp_src . -pushd necpp_src +DIR=`pwd` +cd necpp_src make -f Makefile.git ./configure --without-lapack -popd - -# Generate a README.txt from README.md -pandoc -o README.txt README.md +cd ${DIR} # Build PyNEC -swig -Wall -v -c++ -python PyNEC.i -python setup.py build +swig3.0 -Wall -v -c++ -python PyNEC.i +python3 setup.py build diff --git a/PyNEC/setup.py b/PyNEC/setup.py index 8ce5771..0251cf8 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -6,12 +6,11 @@ Author Tim Molteno. tim@molteno.net """ -from distutils.core import setup, Extension import distutils.sysconfig from glob import glob import os import numpy as np - +import setuptools # Remove silly flags from the compilation to avoid warnings. cfg_vars = distutils.sysconfig.get_config_vars() @@ -32,14 +31,14 @@ nec_headers.extend(glob("necpp_src/src/*.h")) nec_headers.extend(glob("necpp_src/config.h")) -with open('README.txt') as f: - readme = f.read() +#with open('README.txt') as f: + #readme = f.read() # At the moment, the config.h file is needed, and this should be generated from the ./configure # command in the parent directory. Use ./configure --without-lapack to avoid dependance on LAPACK # -necpp_module = Extension('_PyNEC', +necpp_module = setuptools.Extension('_PyNEC', sources=nec_sources, include_dirs=[np.get_include(), 'necpp_src/src', 'necpp_src/'], extra_compile_args = ['-fPIC'], @@ -48,16 +47,19 @@ define_macros=[('BUILD_PYTHON', '1'), ('NPY_NO_DEPRECATED_API','NPY_1_7_API_VERSION')] ) - - -setup (name = 'PyNEC', - version = '1.7.3.3', +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup (name = 'PyNEC', + version = '1.7.3.4', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/necpp", keywords = "nec2 nec2++ antenna electromagnetism radio", description = "Python Antenna Simulation Module (nec2++) object-oriented interface", - long_description=readme, + long_description=long_description, + long_description_content_type="text/markdown", + include_package_data=True, data_files=[('examples', ['example/test_rp.py'])], ext_modules = [necpp_module], requires = ['numpy'], From 195d8be6ce1933e8b633f9e0d6dac478fcd321fb Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 01:35:08 +1200 Subject: [PATCH 19/44] Updated to 1.7.3.4. Fixed missing source files --- PyNEC/Makefile | 18 ++++++++++++++++++ PyNEC/setup.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 PyNEC/Makefile diff --git a/PyNEC/Makefile b/PyNEC/Makefile new file mode 100644 index 0000000..65b7125 --- /dev/null +++ b/PyNEC/Makefile @@ -0,0 +1,18 @@ +build: + python3 setup.py sdist + #python3 setup.py bdist_wheel + +clean: + rm -rf build + rm -rf dist + +test-upload: + python3 -m pip install --user --upgrade twine + + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + +upload: + python3 -m twine upload dist/* + +test: + python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps PyNEC diff --git a/PyNEC/setup.py b/PyNEC/setup.py index 0251cf8..a8d669e 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -54,7 +54,7 @@ version = '1.7.3.4', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", - url = "http://github.com/tmolteno/necpp", + url = "http://github.com/tmolteno/python-necpp", keywords = "nec2 nec2++ antenna electromagnetism radio", description = "Python Antenna Simulation Module (nec2++) object-oriented interface", long_description=long_description, From 9fefaa873c1a0e09f93a77bf19a8000c87660cd6 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 01:54:11 +1200 Subject: [PATCH 20/44] Version bump to 1.7.3.5. Upgrade setup to latest version. --- necpp/{LICENSE.txt => LICENCE.txt} | 0 necpp/Makefile | 20 ++++++++++++++++++++ necpp/build.sh | 13 ++++++------- necpp/setup.py | 10 ++++++---- 4 files changed, 32 insertions(+), 11 deletions(-) rename necpp/{LICENSE.txt => LICENCE.txt} (100%) create mode 100644 necpp/Makefile diff --git a/necpp/LICENSE.txt b/necpp/LICENCE.txt similarity index 100% rename from necpp/LICENSE.txt rename to necpp/LICENCE.txt diff --git a/necpp/Makefile b/necpp/Makefile new file mode 100644 index 0000000..9f1f3e5 --- /dev/null +++ b/necpp/Makefile @@ -0,0 +1,20 @@ +build: + sh build.sh + python3 setup.py sdist + #python3 setup.py bdist_wheel + +clean: + rm -rf necpp_src + rm -rf build + rm -rf dist + +test-upload: + python3 -m pip install --user --upgrade twine + + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + +upload: + python3 -m twine upload dist/* + +test-install: + python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps necpp --upgrade diff --git a/necpp/build.sh b/necpp/build.sh index a55abcf..a99d63b 100755 --- a/necpp/build.sh +++ b/necpp/build.sh @@ -2,13 +2,12 @@ # Script to build the nec2++ python module. git submodule update --remote ln -s ../necpp_src . -pushd ../necpp_src +DIR=`pwd` +cd necpp_src make -f Makefile.git ./configure --without-lapack -popd -pandoc -o README.txt README.md -PYTHON=python -swig -v -Inecpp_src/src/ -python necpp.i -python setup.py build -python setup.py dist +cd ${DIR} +PYTHON=python3 +swig3.0 -v -Inecpp_src/src/ -python necpp.i +python3 setup.py build #sudo python setup.py install diff --git a/necpp/setup.py b/necpp/setup.py index 9516683..f410e43 100644 --- a/necpp/setup.py +++ b/necpp/setup.py @@ -4,7 +4,7 @@ setup.py file for necpp Python module. """ -from distutils.core import setup, Extension +from setuptools import setup, Extension from glob import glob import os @@ -31,18 +31,20 @@ define_macros=[('BUILD_PYTHON', '1')] ) -with open('README.txt') as f: +with open('README.md') as f: readme = f.read() setup (name = 'necpp', - version = '1.7.3.3', + version = '1.7.3.5', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/necpp", keywords = "nec2 nec2++ antenna electromagnetism radio", description = "Python Antenna Simulation Module (nec2++) C-style interface", long_description=readme, - data_files=[('examples', ['../necpp_src/example/test.py'])], + long_description_content_type="text/markdown", + include_package_data=True, + data_files=[('examples', ['necpp_src/example/test.py'])], ext_modules = [necpp_module], py_modules = ["necpp"], license='GPLv2', From c40fa0668d20e42304e2015baa6455b2a44e24f3 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 02:36:39 +1200 Subject: [PATCH 21/44] Update test_get_gain to use PyNEC format --- PyNEC/tests/Makefile | 2 +- PyNEC/tests/test_get_gain.py | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/PyNEC/tests/Makefile b/PyNEC/tests/Makefile index b67626b..a3792fa 100644 --- a/PyNEC/tests/Makefile +++ b/PyNEC/tests/Makefile @@ -1,2 +1,2 @@ test: - python -m unittest discover + python3 -m unittest discover diff --git a/PyNEC/tests/test_get_gain.py b/PyNEC/tests/test_get_gain.py index dd1a4a1..054e940 100644 --- a/PyNEC/tests/test_get_gain.py +++ b/PyNEC/tests/test_get_gain.py @@ -1,4 +1,4 @@ -from PyNEC import * +import PyNEC import unittest @@ -22,15 +22,18 @@ def test_example4(self): RP 0 10 4 1001 0. 0. 10. 30. EN ''' - nec = nec_create() - nec.sp_card(0, 0.1, 0.05, 0.05, 0.0, 0.0, 0.01) - nec.sp_card(0, .05, .1, .05, 0.0, 90.0, 0.01) - nec.gx_card(0, 110) - nec.sp_card(0, 0.0, 0.0, 0.1, 90.0, 0.0, 0.04) + nec= PyNEC.nec_context() + + geo = nec.get_geometry() + + geo.sp_card(0, 0.1, 0.05, 0.05, 0.0, 0.0, 0.01) + geo.sp_card(0, .05, .1, .05, 0.0, 90.0, 0.01) + geo.gx_card(0, 110) + geo.sp_card(0, 0.0, 0.0, 0.1, 90.0, 0.0, 0.04) - nec.wire(1, 4, 0., 0.0, 0.1, 0.0, 0.0, 0.3, .001, 1.0, 1.0) - nec.wire(2, 2, 0., 0.0, 0.3, 0.15, 0.0, 0.3, .001, 1.0, 1.0) - nec.wire(3, 2, 0., 0.0, 0.3, -.15, 0.0, 0.3, .001, 1.0, 1.0) + geo.wire(1, 4, 0., 0.0, 0.1, 0.0, 0.0, 0.3, .001, 1.0, 1.0) + geo.wire(2, 2, 0., 0.0, 0.3, 0.15, 0.0, 0.3, .001, 1.0, 1.0) + geo.wire(3, 2, 0., 0.0, 0.3, -.15, 0.0, 0.3, .001, 1.0, 1.0) nec.geometry_complete(1) nec.gn_card(1, 0, 0, 0, 0, 0, 0, 0) @@ -38,18 +41,16 @@ def test_example4(self): nec.ex_card(0, 1, 1, 0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0) nec.rp_card(0,10,4,1,0,0,1,0.0,0.0,10.0,30.0, 0, 0) - self.assertAlmostEqual(nec_gain_max(nec,0),5.076,3) + self.assertAlmostEqual(nec.get_gain_max(0),5.076,3) gmax = -999.0 for theta_index in range(0,10): for phi_index in range(0,4): - g = nec_gain(nec,0,theta_index, phi_index) + g = nec.get_gain(0,theta_index, phi_index) gmax = max(g, gmax) - self.assertAlmostEqual(gmax, nec_gain_max(nec,0), 5 ) - - nec_delete(nec) + self.assertAlmostEqual(gmax, nec.get_gain_max(0), 5 ) if __name__ == '__main__': From 800ee85c454cca5501858d5c729f155125fc97b0 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 02:37:09 +1200 Subject: [PATCH 22/44] Update target names --- PyNEC/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyNEC/Makefile b/PyNEC/Makefile index 65b7125..013b78f 100644 --- a/PyNEC/Makefile +++ b/PyNEC/Makefile @@ -14,5 +14,5 @@ test-upload: upload: python3 -m twine upload dist/* -test: - python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps PyNEC +test-install: + python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps PyNEC --upgrade From abe12ad70f815c1b60ace001a072f60767c47a71 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 02:37:38 +1200 Subject: [PATCH 23/44] Fix typo from manual merge --- PyNEC/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyNEC/build.sh b/PyNEC/build.sh index 026b639..728e305 100755 --- a/PyNEC/build.sh +++ b/PyNEC/build.sh @@ -8,7 +8,7 @@ git submodule update --remote ln -s ../necpp_src . DIR=`pwd` -cd necpp_src +cd ../necpp_src make -f Makefile.git ./configure --without-lapack cd ${DIR} From 296e68ebf38b600ebf65baeb0283d7a8316cf66b Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 02:38:24 +1200 Subject: [PATCH 24/44] Add new methods to get gain statistics to the nec_context SWIG wrapper. --- PyNEC/example/monopole.py | 2 +- PyNEC/interface_files/nec_context.i | 32 +++++++++++++++++++++++++++++ PyNEC/setup.py | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/PyNEC/example/monopole.py b/PyNEC/example/monopole.py index 9cf166d..3c881a8 100644 --- a/PyNEC/example/monopole.py +++ b/PyNEC/example/monopole.py @@ -1,6 +1,6 @@ # # Simple vertical monopole antenna simulation using python-necpp -# pip install necpp +# pip install PyNEC # from PyNEC import * diff --git a/PyNEC/interface_files/nec_context.i b/PyNEC/interface_files/nec_context.i index bd1fb23..a010769 100644 --- a/PyNEC/interface_files/nec_context.i +++ b/PyNEC/interface_files/nec_context.i @@ -12,7 +12,39 @@ public: c_geometry* get_geometry(); + /*! \brief Get the maximum gain in dB. + This function requires a previous rp_card() method to have been called (with gain normalization requested) + + \return The maximum gain in dB or -999.0 if no radiation pattern had been previously requested. + */ + double get_gain(int freq_index, int theta_index, int phi_index); + + double get_gain_max(int freq_index); + double get_gain_min(int freq_index); + double get_gain_mean(int freq_index); + double get_gain_sd(int freq_index); + + /********************** RHCP ********************************/ + double get_gain_rhcp_max(int freq_index); + double get_gain_rhcp_min(int freq_index); + double get_gain_rhcp_mean(int freq_index); + double get_gain_rhcp_sd(int freq_index); + + /********************** LHCP ********************************/ + double get_gain_lhcp_max(int freq_index); + double get_gain_lhcp_min(int freq_index); + double get_gain_lhcp_mean(int freq_index); + double get_gain_lhcp_sd(int freq_index); + + /****************** IMPEDANCE CHARACTERISTICS *********************/ + + /*! \brief Impedance: Real Part */ + double get_impedance_real(int freq_index); + /*! \brief Impedance: Imaginary Part */ + double get_impedance_imag(int freq_index); + + /*! Get the result antenna_input_parameters specified by index \param index The index of the requested result. diff --git a/PyNEC/setup.py b/PyNEC/setup.py index 531304f..5306c6c 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -49,7 +49,7 @@ long_description = fh.read() setuptools.setup (name = 'PyNEC', - version = '1.7.3.4', + version = '1.7.3.5', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/python-necpp", From 4607f49e20fd046c3b3947c816737c200fad9b21 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 02:42:10 +1200 Subject: [PATCH 25/44] Update gitignore files --- PyNEC/.gitignore | 3 ++- necpp/.gitignore | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 necpp/.gitignore diff --git a/PyNEC/.gitignore b/PyNEC/.gitignore index f0766ac..fbe747b 100644 --- a/PyNEC/.gitignore +++ b/PyNEC/.gitignore @@ -2,4 +2,5 @@ build/** *.pyc PyNEC.py *.cxx -*.png \ No newline at end of file +*.png +necpp_src diff --git a/necpp/.gitignore b/necpp/.gitignore new file mode 100644 index 0000000..d66c9ee --- /dev/null +++ b/necpp/.gitignore @@ -0,0 +1,3 @@ +necpp_wrap.c +necpp_src +necpp.py From 49936e72827a186302305adab158a04b5912f1fe Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Fri, 30 Aug 2019 03:50:24 +1200 Subject: [PATCH 26/44] Added Makefile to build wheels in the root directory --- Makefile | 9 +++++++++ PyNEC/Makefile | 1 + build_wheels.sh | 22 ++++++++++++++++++++++ dev-requirements.txt | 1 + 4 files changed, 33 insertions(+) create mode 100644 Makefile create mode 100755 build_wheels.sh create mode 100644 dev-requirements.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7442de6 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +PLAT=manylinux1_x86_64 +DOCKER_IMAGE=quay.io/pypa/manylinux2010_x86_64 +PRE_CMD= +docker-wheels: + docker run --rm -e PLAT=${PLAT} -v `pwd`:/io ${DOCKER_IMAGE} ${PRE_CMD} /io/build_wheels.sh + auditwheel repair /output/mylibrary*whl -w /output + +install: + docker pull ${DOCKER_IMAGE} diff --git a/PyNEC/Makefile b/PyNEC/Makefile index 013b78f..8b45947 100644 --- a/PyNEC/Makefile +++ b/PyNEC/Makefile @@ -16,3 +16,4 @@ upload: test-install: python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps PyNEC --upgrade + diff --git a/build_wheels.sh b/build_wheels.sh new file mode 100755 index 0000000..d19092b --- /dev/null +++ b/build_wheels.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e -x + +# Install a system package required by our library +# yum install -y atlas-devel + +# Compile wheels +for PYBIN in /opt/python/*/bin; do + "${PYBIN}/pip" install -r /io/dev-requirements.txt + "${PYBIN}/pip" wheel -e /io/PyNEC/ -w wheelhouse/ +done + +# Bundle external shared libraries into the wheels +for whl in wheelhouse/*.whl; do + auditwheel repair "$whl" --plat $PLAT -w /io/wheelhouse/ +done + +# Install packages and test +for PYBIN in /opt/python/*/bin/; do + "${PYBIN}/pip" install PyNEC --no-index -f /io/wheelhouse + (cd "$HOME"; "${PYBIN}/nosetests" pymanylinuxdemo) +done diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..24ce15a --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1 @@ +numpy From 0dab594d4fc6a02743ff3790195a9fb0d75dcc23 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 30 Aug 2019 11:51:44 +1200 Subject: [PATCH 27/44] Converted to python3. Added options to optimization --- PyNEC/example/README.md | 14 +++++ PyNEC/example/context_clean.py | 2 +- PyNEC/example/dipole.py | 14 ++--- PyNEC/example/logperiodic_opt.py | 16 ++--- PyNEC/example/monopole.py | 46 +++++++------- .../monopole_realistic_ground_plane.py | 18 +++--- PyNEC/example/optimized.py | 62 ++++++++++++++----- PyNEC/example/radiation_pattern.py | 8 +-- PyNEC/example/test_ne_nh.py | 2 +- 9 files changed, 113 insertions(+), 69 deletions(-) create mode 100644 PyNEC/example/README.md diff --git a/PyNEC/example/README.md b/PyNEC/example/README.md new file mode 100644 index 0000000..6989ece --- /dev/null +++ b/PyNEC/example/README.md @@ -0,0 +1,14 @@ +# PyNEC examples + +This folder contains some examples showing the use of PyNEC antenna simulation module + +## Optimizing a Monopole + +The file monopole.py simulates a monopole antenna, printing out the impedance. To optimize this + + python3 monopole.py + +To optimize the monopole design to achieve a particular impedance, try + + python3 optimized.py --basinhopping --target-impedance=110 + diff --git a/PyNEC/example/context_clean.py b/PyNEC/example/context_clean.py index 0242073..9caaebd 100644 --- a/PyNEC/example/context_clean.py +++ b/PyNEC/example/context_clean.py @@ -19,7 +19,7 @@ def __init__(self, start, stop, count=None, delta=None): def debug(card, *args): if do_debug: stringified = " , ".join([str(a) for a in args]) - print "%s %s" % (card, stringified) + print("%s %s" % (card, stringified)) class context_clean(object): def __init__(self, context): diff --git a/PyNEC/example/dipole.py b/PyNEC/example/dipole.py index abe1c26..780c713 100644 --- a/PyNEC/example/dipole.py +++ b/PyNEC/example/dipole.py @@ -89,13 +89,13 @@ def matched_range_around(nec, count, center_freq, system_impedance): initial_length = wavelength / 2 # TODO - print "Wavelength is %0.4fm, initial length is %0.4fm" % (wavelength, initial_length) + print("Wavelength is %0.4fm, initial length is %0.4fm" % (wavelength, initial_length)) nr_segments = 101 # int(math.ceil(50*initial_length/wavelength)) z = impedance(design_freq_mhz, initial_length, nr_segments) - print "Initial impedance: (%6.1f,%+6.1fI) Ohms" % (z.real, z.imag) + print("Initial impedance: (%6.1f,%+6.1fI) Ohms" % (z.real, z.imag)) target = create_optimization_target(design_freq_mhz, nr_segments) optimized_result = scipy.optimize.minimize(target, np.array([initial_length])) @@ -103,8 +103,8 @@ def matched_range_around(nec, count, center_freq, system_impedance): z = impedance(design_freq_mhz, optimized_length, nr_segments) - print "Optimized length %6.6f m, which gives an impedance of: (%6.4f,%+6.4fI) Ohms" % (optimized_length, z.real, z.imag) - print "VSWR @ 75 Ohm is %6.6f" % vswr(z, 75) + print("Optimized length %6.6f m, which gives an impedance of: (%6.4f,%+6.4fI) Ohms" % (optimized_length, z.real, z.imag)) + print("VSWR @ 75 Ohm is %6.6f" % vswr(z, 75)) for system_impedance in [75, 50, 300]: nec = geometry(design_freq_mhz, optimized_length, nr_segments) @@ -117,10 +117,10 @@ def matched_range_around(nec, count, center_freq, system_impedance): rng = matched_range_around(nec, count, design_freq_mhz, system_impedance) if rng[0] is None or rng[1] is None: - print "VSWR is nowhere <= 2 @ %i Ohm!" % system_impedance + print("VSWR is nowhere <= 2 @ %i Ohm!" % system_impedance) else: bandwidth = 100.0 * (rng[1] - rng[0]) / design_freq_mhz - print "The fractional bandwidth @ %i Ohm is %2.2f%% - %i MHz (%i Mhz to %i MHz)" % (system_impedance, bandwidth, (rng[1] - rng[0]), rng[0], rng[1]) + print("The fractional bandwidth @ %i Ohm is %2.2f%% - %i MHz (%i Mhz to %i MHz)" % (system_impedance, bandwidth, (rng[1] - rng[0]), rng[0], rng[1])) freqs = [] vswrs = [] @@ -140,5 +140,5 @@ def matched_range_around(nec, count, center_freq, system_impedance): plt.ylabel("VSWR") plt.grid(True) filename = "vswr_%i_MHz.pdf" % system_impedance - print "Saving plot to file: %s" % filename + print("Saving plot to file: %s" % filename) plt.savefig(filename) diff --git a/PyNEC/example/logperiodic_opt.py b/PyNEC/example/logperiodic_opt.py index 5c54d67..b9617df 100644 --- a/PyNEC/example/logperiodic_opt.py +++ b/PyNEC/example/logperiodic_opt.py @@ -129,10 +129,10 @@ def target(args): result = vswr_score - gains_score except: - print "Caught exception" + print("Caught exception") return float('inf') - print result + print(result) return result return target @@ -169,8 +169,8 @@ def show_report(l1, x1, tau): z = simulate_and_get_impedance(nec) - print "Initial impedance: (%6.1f,%+6.1fI) Ohms" % (z.real, z.imag) - print "VSWR @ 50 Ohm is %6.6f" % vswr(z, 50) + print("Initial impedance: (%6.1f,%+6.1fI) Ohms" % (z.real, z.imag)) + print("VSWR @ 50 Ohm is %6.6f" % vswr(z, 50)) nec = geometry_logperiodic(l1, x1, tau) @@ -219,12 +219,12 @@ def show_report(l1, x1, tau): initial_x1 = wavelength / 2 initial_tau = 0.8 - print "Wavelength is %0.4fm, initial length is %0.4fm" % (wavelength, initial_l1) + print("Wavelength is %0.4fm, initial length is %0.4fm" % (wavelength, initial_l1)) - print "Unoptimized antenna..." + print("Unoptimized antenna...") show_report(initial_l1, initial_x1, initial_tau) - print "Optimizing antenna..." + print("Optimizing antenna...") target = create_optimization_target() # Optimize local minimum only with gradient desce @@ -238,7 +238,7 @@ def show_report(l1, x1, tau): # Basin hopping isn't so good, but could also have been an option: #optimized_result = scipy.optimize.basinhopping(target, np.array([initial_l1, initial_x1, initial_tau]), minimizer_kwargs=minimizer_kwargs, niter=5, stepsize=0.015, T=2.0, disp=True) - print "Optimized antenna..." + print("Optimized antenna...") optimized_l1, optimized_x1, optimized_tau = optimized_result.x[0], optimized_result.x[1], optimized_result.x[2] show_report(optimized_l1, optimized_x1, optimized_tau) diff --git a/PyNEC/example/monopole.py b/PyNEC/example/monopole.py index 3c881a8..cc0eb4b 100644 --- a/PyNEC/example/monopole.py +++ b/PyNEC/example/monopole.py @@ -9,40 +9,40 @@ import math def geometry(freq, base, length): - conductivity = 1.45e6 # Stainless steel - ground_conductivity = 0.002 - ground_dielectric = 10 + conductivity = 1.45e6 # Stainless steel + ground_conductivity = 0.002 + ground_dielectric = 10 - wavelength = 3e8/(1e6*freq) - n_seg = int(math.ceil(50*length/wavelength)) + wavelength = 3e8/(1e6*freq) + n_seg = int(math.ceil(50*length/wavelength)) - nec = context_clean(nec_context()) + nec = context_clean(nec_context()) - geo = nec.get_geometry() - geo.wire(1, n_seg, 0, 0, base, 0, 0, base+length, 0.002, 1.0, 1.0) - nec.geometry_complete(1) + geo = nec.get_geometry() + geo.wire(1, n_seg, 0, 0, base, 0, 0, base+length, 0.002, 1.0, 1.0) + nec.geometry_complete(1) - nec.set_all_wires_conductivity(conductivity) + nec.set_all_wires_conductivity(conductivity) - nec.set_finite_ground(ground_dielectric, ground_conductivity) - nec.set_frequency(freq) + nec.set_finite_ground(ground_dielectric, ground_conductivity) + nec.set_frequency(freq) - # Voltage excitation one third of the way along the wire - nec.voltage_excitation(wire_tag=1, segment_nr=int(n_seg/3), voltage=1.0) + # Voltage excitation one third of the way along the wire + nec.voltage_excitation(wire_tag=1, segment_nr=int(n_seg/3), voltage=1.0) - return nec + return nec def impedance(freq, base, length): - nec = geometry(freq, base, length) - nec.xq_card(0) # Execute simulation + nec = geometry(freq, base, length) + nec.xq_card(0) # Execute simulation - index = 0 + index = 0 - ipt = nec.get_input_parameters(index) - z = ipt.get_impedance() + ipt = nec.get_input_parameters(index) + z = ipt.get_impedance() - return z + 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) + 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)) diff --git a/PyNEC/example/monopole_realistic_ground_plane.py b/PyNEC/example/monopole_realistic_ground_plane.py index 2d41099..8c18713 100644 --- a/PyNEC/example/monopole_realistic_ground_plane.py +++ b/PyNEC/example/monopole_realistic_ground_plane.py @@ -92,7 +92,7 @@ def target(args): nec.xq_card(0) # Execute simulation except: - print "Caught exception" + print("Caught exception") return float('inf') for idx in range(0, count): @@ -122,7 +122,7 @@ def target(args): sampled_ground_wire_lenths.append(ground_wire_length) sampled_results.append(result) - print result + print(result) return result return target @@ -133,7 +133,7 @@ def target(args): initial_length = wavelength / 4 # quarter-wavelength monopole - print "Wavelength is %0.4fm, initial length is %0.4fm" % (wavelength, initial_length) + print("Wavelength is %0.4fm, initial length is %0.4fm" % (wavelength, initial_length)) nr_segments = 15 # int(math.ceil(50*initial_length/wavelength)) #print nr_segments @@ -141,8 +141,8 @@ def target(args): ground_wire_length = 0.02 z = simulate_and_get_impedance(geometry_monopole_ground(design_freq_mhz, initial_length, ground_wire_length, nr_segments)) - print "Initial impedance: (%6.1f,%+6.1fI) Ohms" % (z.real, z.imag) - print "VSWR @ 50 Ohm is %6.6f" % vswr(z, 50) + print("Initial impedance: (%6.1f,%+6.1fI) Ohms" % (z.real, z.imag)) + print("VSWR @ 50 Ohm is %6.6f" % vswr(z, 50)) target = create_optimization_target(design_freq_mhz, nr_segments) optimized_result = scipy.optimize.minimize(target, np.array([initial_length, ground_wire_length]), method='Nelder-Mead') @@ -152,9 +152,9 @@ def target(args): geo_opt = geometry_monopole_ground(design_freq_mhz, optimized_length, optimized_ground_wire_length, nr_segments) z = simulate_and_get_impedance(geo_opt) - print "Optimized length %6.6f m and ground screen radials of length %6.6f m, which gives an impedance of: (%6.4f,%+6.4fI) Ohms" % (optimized_length, optimized_ground_wire_length, z.real, z.imag) - print "Mismatch @ 50 Ohm is %6.6f" % mismatch(z, 50) - print "VSWR @ 50 Ohm is %6.6f" % vswr(z, 50) + print("Optimized length %6.6f m and ground screen radials of length %6.6f m, which gives an impedance of: (%6.4f,%+6.4fI) Ohms" % (optimized_length, optimized_ground_wire_length, z.real, z.imag)) + print("Mismatch @ 50 Ohm is %6.6f" % mismatch(z, 50)) + print("VSWR @ 50 Ohm is %6.6f" % vswr(z, 50)) geo_opt = geometry_monopole_ground(design_freq_mhz, optimized_length, optimized_ground_wire_length, nr_segments) geo_opt.set_frequency(design_freq_mhz) @@ -172,7 +172,7 @@ def target(args): max_gain = gains_db[max_idx] max_theta = thetas[max_idx] #print gains_db - print "Maximal gain is %2.2f dBi, at an angle of %2.2f" % (max_gain, max_theta * 180.0 / np.pi) + print("Maximal gain is %2.2f dBi, at an angle of %2.2f" % (max_gain, max_theta * 180.0 / np.pi)) # Plot stuff diff --git a/PyNEC/example/optimized.py b/PyNEC/example/optimized.py index 96317eb..3d8d33f 100644 --- a/PyNEC/example/optimized.py +++ b/PyNEC/example/optimized.py @@ -1,9 +1,11 @@ # # Automatically tune antenna # -import monopole +import argparse import scipy.optimize import numpy as np + +import monopole from antenna_util import reflection_coefficient # A function that will be minimized when the impedance is 50 Ohms @@ -11,21 +13,49 @@ # numbers using exp. because otherwise the antenna will lie # below ground and cause an error in simulation. def target(x): - global freq - base_height = np.exp(x[0]) # Make it positive - length = np.exp(x[1]) # Make it positive - z = monopole.impedance(freq, base_height, length) - return reflection_coefficient(z, z0=50.0) - + global freq, target_impedance + base_height = np.exp(x[0]) # Make it positive + length = np.exp(x[1]) # Make it positive + if (length > 10.0): + return 100 + try: + z = monopole.impedance(freq, base_height, length) + return reflection_coefficient(z, z0=target_impedance) + except RuntimeError as re: + return 100 + +def print_result(x, f, accepted): + log_base, log_length = x + base_height = np.exp(log_base) + length = np.exp(log_length) + + if accepted: + print("Optimium base_height=%fm, h=%fm, impedance=%s Ohms" % \ + (base_height, length, monopole.impedance(freq, base_height, length))) + else: + print("Local_minimum=%fm, h=%fm, impedance=%s Ohms" % \ + (base_height, length, monopole.impedance(freq, base_height, length))) -# Starting value -freq = 134.5 -x0 = [-2.0, 0.0] -# Carry out the minimization -log_base, log_length = scipy.optimize.fmin(target, x0) +if __name__=="__main__": + parser = argparse.ArgumentParser(description='Optimize a monopole antenna.') + parser.add_argument('--target-impedance', type=float, default=50.0, help='Target for the optimized impedance') + parser.add_argument('--basinhopping', action="store_true", help='Use basinhopping') + args = parser.parse_args() -base_height = np.exp(log_base) -length = np.exp(log_length) + # Starting value + freq = 134.5 + x0 = [-2.0, 1.0] + target_impedance = args.target_impedance + + # Carry out the minimization -print "Optimium base_height=%fm, h=%fm, impedance=%s Ohms" % \ - (base_height, length, monopole.impedance(freq, base_height, length)) + if args.basinhopping: + result = scipy.optimize.basinhopping(target, x0, disp=True, T=1.0, niter_success=10) + else: + result = scipy.optimize.minimize(target, x0, method='Nelder-Mead') + + print("") + print("***********************************************************************") + print("* OPTIMIZATION COMPLETED *") + print("***********************************************************************") + print_result(result.x, None, True) diff --git a/PyNEC/example/radiation_pattern.py b/PyNEC/example/radiation_pattern.py index 7f0842c..39a3084 100644 --- a/PyNEC/example/radiation_pattern.py +++ b/PyNEC/example/radiation_pattern.py @@ -36,18 +36,18 @@ def geometry(freq, base, length): ipt = nec.get_input_parameters(0) z = ipt.get_impedance() -print("Impedance is {}".format(z)) +print(("Impedance is {}".format(z))) rpt = nec.get_radiation_pattern(0) complex_e_field = rpt.get_e_theta() e = complex_e_field.reshape((30,30)) -print(complex_e_field.size) +print((complex_e_field.size)) for t in range(30): for p in range(30): pass - print e[t, p] + print(e[t, p]) -print dir(rpt) +print(dir(rpt)) diff --git a/PyNEC/example/test_ne_nh.py b/PyNEC/example/test_ne_nh.py index 4a13d21..2b08584 100644 --- a/PyNEC/example/test_ne_nh.py +++ b/PyNEC/example/test_ne_nh.py @@ -53,4 +53,4 @@ ne = context.get_near_field_pattern(0) nh = context.get_near_field_pattern(1) -print ne \ No newline at end of file +print(ne) \ No newline at end of file From 8506fce34f9cc83c507fe9a61a6ad3b5578b50da Mon Sep 17 00:00:00 2001 From: tmolteno Date: Fri, 6 Sep 2019 09:48:40 +1200 Subject: [PATCH 28/44] Minor README update --- PyNEC/example/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/PyNEC/example/README.md b/PyNEC/example/README.md index 6989ece..0b242c8 100644 --- a/PyNEC/example/README.md +++ b/PyNEC/example/README.md @@ -12,3 +12,4 @@ To optimize the monopole design to achieve a particular impedance, try python3 optimized.py --basinhopping --target-impedance=110 +This code uses standard scipy optimizers to find the best solution. From 8e20f2425b9d397b17b5a0b2d5abe2cd91249617 Mon Sep 17 00:00:00 2001 From: Ralf Schlatterbeck Date: Thu, 20 Feb 2020 10:07:00 +0100 Subject: [PATCH 29/44] Fix parameters of multiple_patch This only takes three coordinates (SM card) according to nec docs. --- PyNEC/interface_files/c_geometry.i | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/PyNEC/interface_files/c_geometry.i b/PyNEC/interface_files/c_geometry.i index 2008f7b..8c2a0b2 100644 --- a/PyNEC/interface_files/c_geometry.i +++ b/PyNEC/interface_files/c_geometry.i @@ -255,18 +255,13 @@ public: \param ax3 The x_coordinate of corner 3. \param ay3 The y_coordinate of corner 3. \param az3 The z_coordinate of corner 3. - - \param ax4 The x_coordinate of corner 4. - \param ay4 The x_coordinate of corner 4. - \param az4 The x_coordinate of corner 4. */ void multiple_patch( int nx, int ny, nec_float ax1, nec_float ay1, nec_float az1, nec_float ax2, nec_float ay2, nec_float az2, - nec_float ax3, nec_float ay3, nec_float az3, - nec_float ax4, nec_float ay4, nec_float az4 ) + nec_float ax3, nec_float ay3, nec_float az3 ) { - return self->patch( nx, ny, ax1, ay1, az1, ax2, ay2, az2, ax3, ay3, az3, ax4, ay4, az4 ); + return self->patch( nx, ny, ax1, ay1, az1, ax2, ay2, az2, ax3, ay3, az3, 0, 0, 0 ); } } From 225161c493628fa8c89b1cba707a1590ff3e9244 Mon Sep 17 00:00:00 2001 From: tmolteno Date: Thu, 14 May 2020 11:32:53 +1200 Subject: [PATCH 30/44] Update with a requested fix by user slawkory. Also fix an intger division bug introduced with the shift to python3. Closes #11, #14 --- PyNEC/example/context_clean.py | 4 ++-- PyNEC/example/logperiodic_opt.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PyNEC/example/context_clean.py b/PyNEC/example/context_clean.py index 9caaebd..4f4a3d3 100644 --- a/PyNEC/example/context_clean.py +++ b/PyNEC/example/context_clean.py @@ -101,10 +101,10 @@ def get_geometry(self): def set_extended_thin_wire_kernel(self, enable): if enable: debug ("EK", 0) - self.context.set_extended_thin_wire_kernel(1) + self.context.set_extended_thin_wire_kernel(True) else: debug ("EK", -1) - self.context.set_extended_thin_wire_kernel(0) + self.context.set_extended_thin_wire_kernel(False) def geometry_complete(self, ground_plane, current_expansion=True): no_ground_plane = 0 diff --git a/PyNEC/example/logperiodic_opt.py b/PyNEC/example/logperiodic_opt.py index b9617df..0a4ecd5 100644 --- a/PyNEC/example/logperiodic_opt.py +++ b/PyNEC/example/logperiodic_opt.py @@ -15,7 +15,7 @@ brass_conductivity = 15600000 # mhos -tl_impedance = 75 +tl_impedance = 75.0 def geometry_logperiodic(l_1, x_1, tau): """ @@ -45,7 +45,7 @@ def geometry_logperiodic(l_1, x_1, tau): nr_segments = int(math.ceil(50*l_i/wavelength)) # TODO this might vary when sweeping even! #print nr_segments - dipole_center_segs[dipole_tag] = nr_segments / 2 + 1 + dipole_center_segs[dipole_tag] = nr_segments // 2 + 1 center = np.array([x_i, 0, 0]) half_height = np.array([0 , 0, l_i/2.0]) @@ -64,7 +64,7 @@ def geometry_logperiodic(l_1, x_1, tau): # The 6th tag is the smallest tag is the source element for dipole in range(0, dipoles_count - 1): - src_tag = 1 + dipole # NEC indexing + src_tag = int(1 + dipole) # NEC indexing src_seg = dipole_center_segs[src_tag] dst_tag = src_tag + 1 From 14192582fe96d0aef093c3db51730c11877d30e4 Mon Sep 17 00:00:00 2001 From: tmolteno Date: Thu, 14 May 2020 11:35:58 +1200 Subject: [PATCH 31/44] Version bump --- PyNEC/CHANGES.md | 4 ++++ PyNEC/setup.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 PyNEC/CHANGES.md diff --git a/PyNEC/CHANGES.md b/PyNEC/CHANGES.md new file mode 100644 index 0000000..b22db73 --- /dev/null +++ b/PyNEC/CHANGES.md @@ -0,0 +1,4 @@ +### Version 1.7.3.6: + +* Update with a requested fix by user slawkory in context_clean.py +* Also fix an intger division bug introduced with the shift to python3 in logperiodic_opt.py diff --git a/PyNEC/setup.py b/PyNEC/setup.py index 5306c6c..6d2a6ed 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -49,7 +49,7 @@ long_description = fh.read() setuptools.setup (name = 'PyNEC', - version = '1.7.3.5', + version = '1.7.3.6', author = "Tim Molteno", author_email = "tim@physics.otago.ac.nz", url = "http://github.com/tmolteno/python-necpp", @@ -68,5 +68,6 @@ "Topic :: Scientific/Engineering", "Topic :: Communications :: Ham Radio", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + 'Programming Language :: Python :: 3', "Intended Audience :: Science/Research"] ) From 97c9ff79d0e035a0aaae61dc0ce2370d078a87ae Mon Sep 17 00:00:00 2001 From: Electro707 Date: Thu, 13 Jan 2022 22:53:57 -0500 Subject: [PATCH 32/44] Added pyroject --- PyNEC/pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 PyNEC/pyproject.toml diff --git a/PyNEC/pyproject.toml b/PyNEC/pyproject.toml new file mode 100644 index 0000000..4973c84 --- /dev/null +++ b/PyNEC/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel", "numpy"] +build-backend = "setuptools.build_meta" From afbb3234d539085fbb90bcc1baf458b26662b88f Mon Sep 17 00:00:00 2001 From: Benitoite Date: Wed, 15 Mar 2023 11:38:26 -0700 Subject: [PATCH 33/44] update swig command per solution https://github.com/tmolteno/python-necpp/issues/19#issuecomment-1469623955 --- PyNEC/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyNEC/build.sh b/PyNEC/build.sh index 728e305..4785138 100755 --- a/PyNEC/build.sh +++ b/PyNEC/build.sh @@ -14,5 +14,5 @@ make -f Makefile.git cd ${DIR} # Build PyNEC -swig3.0 -Wall -v -c++ -python PyNEC.i +swig -Wall -v -c++ -python PyNEC.i python3 setup.py build From e63115ca5e317be9f6137cc7d8e43257afea3fb3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 21:45:04 +0000 Subject: [PATCH 34/44] Initial plan From 8ac49636d29e1de241f671c34165609bca7ce3b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 21:51:22 +0000 Subject: [PATCH 35/44] Add GitHub Actions workflow for building wheels with cibuildwheel Co-authored-by: tmolteno <85630+tmolteno@users.noreply.github.com> --- .github/workflows/build-wheels.yml | 147 +++++++++++++++++++++++++++++ necpp/pyproject.toml | 3 + 2 files changed, 150 insertions(+) create mode 100644 .github/workflows/build-wheels.yml create mode 100644 necpp/pyproject.toml diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml new file mode 100644 index 0000000..d9491d6 --- /dev/null +++ b/.github/workflows/build-wheels.yml @@ -0,0 +1,147 @@ +name: Build and upload to PyPI + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + release: + types: + - published + +jobs: + build_wheels: + name: Build wheels for ${{ matrix.package }} on ${{ matrix.os }} + runs-on: ${{ matrix.runs-on }} + strategy: + matrix: + include: + # PyNEC builds + - package: PyNEC + os: linux + runs-on: ubuntu-latest + - package: PyNEC + os: macos-intel + runs-on: macos-13 + - package: PyNEC + os: macos-arm + runs-on: macos-latest + # necpp builds + - package: necpp + os: linux + runs-on: ubuntu-latest + - package: necpp + os: macos-intel + runs-on: macos-13 + - package: necpp + os: macos-arm + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y swig autoconf automake libtool + + - name: Install build dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install swig autoconf automake libtool + + - name: Configure necpp_src + shell: bash + run: | + cd necpp_src + make -f Makefile.git + ./configure --without-lapack + + - name: Setup package directory and generate SWIG wrapper + shell: bash + run: | + cd ${{ matrix.package }} + ln -s ../necpp_src . + if [ "${{ matrix.package }}" = "PyNEC" ]; then + swig -Wall -c++ -python PyNEC.i + else + swig -I../necpp_src/src/ -python necpp.i + fi + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.5 + env: + CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" + CIBW_SKIP: "*-musllinux_*" + CIBW_BUILD_VERBOSITY: 1 + with: + package-dir: ${{ matrix.package }} + output-dir: wheelhouse + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.package }}-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + strategy: + matrix: + package: [PyNEC, necpp] + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y swig autoconf automake libtool + + - name: Configure necpp_src + run: | + cd necpp_src + make -f Makefile.git + ./configure --without-lapack + + - name: Setup package directory and generate SWIG wrapper + run: | + cd ${{ matrix.package }} + ln -s ../necpp_src . + if [ "${{ matrix.package }}" = "PyNEC" ]; then + swig -Wall -c++ -python PyNEC.i + else + swig -I../necpp_src/src/ -python necpp.i + fi + + - name: Build sdist + run: | + cd ${{ matrix.package }} + pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist-${{ matrix.package }} + path: ${{ matrix.package }}/dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/necpp/pyproject.toml b/necpp/pyproject.toml new file mode 100644 index 0000000..9787c3b --- /dev/null +++ b/necpp/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" From 7e1220b11830ca4510afb7bcc789f908b498fb7c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 21:55:04 +0000 Subject: [PATCH 36/44] Remove Python 3.8 (EOL) and fix artifact naming Co-authored-by: tmolteno <85630+tmolteno@users.noreply.github.com> --- .github/workflows/build-wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index d9491d6..cd96d05 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -75,7 +75,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.16.5 env: - CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" CIBW_SKIP: "*-musllinux_*" CIBW_BUILD_VERBOSITY: 1 with: @@ -84,7 +84,7 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: cibw-wheels-${{ matrix.package }}-${{ matrix.os }}-${{ strategy.job-index }} + name: cibw-wheels-${{ matrix.package }}-${{ matrix.os }} path: ./wheelhouse/*.whl build_sdist: From 649b59825f5e1f6b43278a3c3e622c208cba1164 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 21:56:18 +0000 Subject: [PATCH 37/44] Add explicit permissions to workflow jobs for security Co-authored-by: tmolteno <85630+tmolteno@users.noreply.github.com> --- .github/workflows/build-wheels.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index cd96d05..bf81d64 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -14,6 +14,8 @@ jobs: build_wheels: name: Build wheels for ${{ matrix.package }} on ${{ matrix.os }} runs-on: ${{ matrix.runs-on }} + permissions: + contents: read strategy: matrix: include: @@ -90,6 +92,8 @@ jobs: build_sdist: name: Build source distribution runs-on: ubuntu-latest + permissions: + contents: read strategy: matrix: package: [PyNEC, necpp] From e52dd4f9e46726b7f25945903566e8ef27ea78bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 22:16:51 +0000 Subject: [PATCH 38/44] Split workflow into separate files for PyNEC and necpp Co-authored-by: tmolteno <85630+tmolteno@users.noreply.github.com> --- ...uild-wheels.yml => build-necpp-wheels.yml} | 55 +++----- .github/workflows/build-pynec-wheels.yml | 126 ++++++++++++++++++ 2 files changed, 141 insertions(+), 40 deletions(-) rename .github/workflows/{build-wheels.yml => build-necpp-wheels.yml} (66%) create mode 100644 .github/workflows/build-pynec-wheels.yml diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-necpp-wheels.yml similarity index 66% rename from .github/workflows/build-wheels.yml rename to .github/workflows/build-necpp-wheels.yml index bf81d64..952227e 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-necpp-wheels.yml @@ -1,4 +1,4 @@ -name: Build and upload to PyPI +name: Build and upload necpp to PyPI on: workflow_dispatch: @@ -12,32 +12,18 @@ on: jobs: build_wheels: - name: Build wheels for ${{ matrix.package }} on ${{ matrix.os }} + name: Build necpp wheels on ${{ matrix.os }} runs-on: ${{ matrix.runs-on }} permissions: contents: read strategy: matrix: include: - # PyNEC builds - - package: PyNEC - os: linux + - os: linux runs-on: ubuntu-latest - - package: PyNEC - os: macos-intel + - os: macos-intel runs-on: macos-13 - - package: PyNEC - os: macos-arm - runs-on: macos-latest - # necpp builds - - package: necpp - os: linux - runs-on: ubuntu-latest - - package: necpp - os: macos-intel - runs-on: macos-13 - - package: necpp - os: macos-arm + - os: macos-arm runs-on: macos-latest steps: @@ -66,13 +52,9 @@ jobs: - name: Setup package directory and generate SWIG wrapper shell: bash run: | - cd ${{ matrix.package }} + cd necpp ln -s ../necpp_src . - if [ "${{ matrix.package }}" = "PyNEC" ]; then - swig -Wall -c++ -python PyNEC.i - else - swig -I../necpp_src/src/ -python necpp.i - fi + swig -I../necpp_src/src/ -python necpp.i - name: Build wheels uses: pypa/cibuildwheel@v2.16.5 @@ -81,22 +63,19 @@ jobs: CIBW_SKIP: "*-musllinux_*" CIBW_BUILD_VERBOSITY: 1 with: - package-dir: ${{ matrix.package }} + package-dir: necpp output-dir: wheelhouse - uses: actions/upload-artifact@v4 with: - name: cibw-wheels-${{ matrix.package }}-${{ matrix.os }} + name: cibw-wheels-necpp-${{ matrix.os }} path: ./wheelhouse/*.whl build_sdist: - name: Build source distribution + name: Build necpp source distribution runs-on: ubuntu-latest permissions: contents: read - strategy: - matrix: - package: [PyNEC, necpp] steps: - uses: actions/checkout@v4 with: @@ -115,23 +94,19 @@ jobs: - name: Setup package directory and generate SWIG wrapper run: | - cd ${{ matrix.package }} + cd necpp ln -s ../necpp_src . - if [ "${{ matrix.package }}" = "PyNEC" ]; then - swig -Wall -c++ -python PyNEC.i - else - swig -I../necpp_src/src/ -python necpp.i - fi + swig -I../necpp_src/src/ -python necpp.i - name: Build sdist run: | - cd ${{ matrix.package }} + cd necpp pipx run build --sdist - uses: actions/upload-artifact@v4 with: - name: cibw-sdist-${{ matrix.package }} - path: ${{ matrix.package }}/dist/*.tar.gz + name: cibw-sdist-necpp + path: necpp/dist/*.tar.gz upload_pypi: needs: [build_wheels, build_sdist] diff --git a/.github/workflows/build-pynec-wheels.yml b/.github/workflows/build-pynec-wheels.yml new file mode 100644 index 0000000..b78073f --- /dev/null +++ b/.github/workflows/build-pynec-wheels.yml @@ -0,0 +1,126 @@ +name: Build and upload PyNEC to PyPI + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + release: + types: + - published + +jobs: + build_wheels: + name: Build PyNEC wheels on ${{ matrix.os }} + runs-on: ${{ matrix.runs-on }} + permissions: + contents: read + strategy: + matrix: + include: + - os: linux + runs-on: ubuntu-latest + - os: macos-intel + runs-on: macos-13 + - os: macos-arm + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y swig autoconf automake libtool + + - name: Install build dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install swig autoconf automake libtool + + - name: Configure necpp_src + shell: bash + run: | + cd necpp_src + make -f Makefile.git + ./configure --without-lapack + + - name: Setup package directory and generate SWIG wrapper + shell: bash + run: | + cd PyNEC + ln -s ../necpp_src . + swig -Wall -c++ -python PyNEC.i + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.5 + env: + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" + CIBW_SKIP: "*-musllinux_*" + CIBW_BUILD_VERBOSITY: 1 + with: + package-dir: PyNEC + output-dir: wheelhouse + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-pynec-${{ matrix.os }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build PyNEC source distribution + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y swig autoconf automake libtool + + - name: Configure necpp_src + run: | + cd necpp_src + make -f Makefile.git + ./configure --without-lapack + + - name: Setup package directory and generate SWIG wrapper + run: | + cd PyNEC + ln -s ../necpp_src . + swig -Wall -c++ -python PyNEC.i + + - name: Build sdist + run: | + cd PyNEC + pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist-pynec + path: PyNEC/dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 From b2dde1ef2539f11eda2a90ef6246e00ee9a51c96 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Tue, 6 Jan 2026 11:24:12 +1300 Subject: [PATCH 39/44] Bump to Mac-15 as 13 deprecated --- .github/workflows/build-necpp-wheels.yml | 2 +- .github/workflows/build-pynec-wheels.yml | 2 +- Makefile | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-necpp-wheels.yml b/.github/workflows/build-necpp-wheels.yml index 952227e..4f396ce 100644 --- a/.github/workflows/build-necpp-wheels.yml +++ b/.github/workflows/build-necpp-wheels.yml @@ -22,7 +22,7 @@ jobs: - os: linux runs-on: ubuntu-latest - os: macos-intel - runs-on: macos-13 + runs-on: macos-15 - os: macos-arm runs-on: macos-latest diff --git a/.github/workflows/build-pynec-wheels.yml b/.github/workflows/build-pynec-wheels.yml index b78073f..9e3e7ee 100644 --- a/.github/workflows/build-pynec-wheels.yml +++ b/.github/workflows/build-pynec-wheels.yml @@ -22,7 +22,7 @@ jobs: - os: linux runs-on: ubuntu-latest - os: macos-intel - runs-on: macos-13 + runs-on: macos-15 - os: macos-arm runs-on: macos-latest diff --git a/Makefile b/Makefile index 7442de6..dd1eb58 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -PLAT=manylinux1_x86_64 -DOCKER_IMAGE=quay.io/pypa/manylinux2010_x86_64 +PLAT=manylinux2_x86_28 +DOCKER_IMAGE=quay.io/pypa/manylinux2014_x86_64 PRE_CMD= docker-wheels: docker run --rm -e PLAT=${PLAT} -v `pwd`:/io ${DOCKER_IMAGE} ${PRE_CMD} /io/build_wheels.sh auditwheel repair /output/mylibrary*whl -w /output - + install: docker pull ${DOCKER_IMAGE} From 3c1523235414e0ad99cf45931deb18de6d6c2be5 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Tue, 6 Jan 2026 12:00:45 +1300 Subject: [PATCH 40/44] Add Python 3.13 to CI build --- .github/workflows/build-necpp-wheels.yml | 2 +- .github/workflows/build-pynec-wheels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-necpp-wheels.yml b/.github/workflows/build-necpp-wheels.yml index 4f396ce..f2ce2ba 100644 --- a/.github/workflows/build-necpp-wheels.yml +++ b/.github/workflows/build-necpp-wheels.yml @@ -59,7 +59,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.16.5 env: - CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*" CIBW_SKIP: "*-musllinux_*" CIBW_BUILD_VERBOSITY: 1 with: diff --git a/.github/workflows/build-pynec-wheels.yml b/.github/workflows/build-pynec-wheels.yml index 9e3e7ee..c5a3c63 100644 --- a/.github/workflows/build-pynec-wheels.yml +++ b/.github/workflows/build-pynec-wheels.yml @@ -59,7 +59,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.16.5 env: - CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*" CIBW_SKIP: "*-musllinux_*" CIBW_BUILD_VERBOSITY: 1 with: From aa296567a978ab2ca10a8d473bdc7aee8f9f55e9 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Tue, 6 Jan 2026 12:08:44 +1300 Subject: [PATCH 41/44] Version bump --- PyNEC/setup.py | 73 ++++++++++++++++++++++++++-------------------- necpp/setup.py | 79 ++++++++++++++++++++++++++++---------------------- 2 files changed, 86 insertions(+), 66 deletions(-) diff --git a/PyNEC/setup.py b/PyNEC/setup.py index 6d2a6ed..bc33761 100644 --- a/PyNEC/setup.py +++ b/PyNEC/setup.py @@ -7,24 +7,30 @@ """ import distutils.sysconfig -from glob import glob import os +from glob import glob + import numpy as np import setuptools # Remove silly flags from the compilation to avoid warnings. -#cfg_vars = distutils.sysconfig.get_config_vars() -#for key, value in cfg_vars.items(): +# cfg_vars = distutils.sysconfig.get_config_vars() +# for key, value in cfg_vars.items(): # if type(value) == str: # cfg_vars[key] = value.replace("-Wstrict-prototypes", "") -# Generate a list of the sources. +# Generate a list of the sources. nec_sources = [] -nec_sources.extend([fn for fn in glob('necpp_src/src/*.cpp') - if not os.path.basename(fn).endswith('_tb.cpp') - if not os.path.basename(fn).startswith('net_solve.cpp') - if not os.path.basename(fn).startswith('nec2cpp.cpp') - if not os.path.basename(fn).startswith('necDiff.cpp')]) +nec_sources.extend( + [ + fn + for fn in glob("necpp_src/src/*.cpp") + if not os.path.basename(fn).endswith("_tb.cpp") + if not os.path.basename(fn).startswith("net_solve.cpp") + if not os.path.basename(fn).startswith("nec2cpp.cpp") + if not os.path.basename(fn).startswith("necDiff.cpp") + ] +) nec_sources.extend(glob("PyNEC_wrap.cxx")) nec_headers = [] @@ -35,39 +41,44 @@ # At the moment, the config.h file is needed, and this should be generated from the ./configure # command in the parent directory. Use ./configure --without-lapack to avoid dependance on LAPACK # -necpp_module = setuptools.Extension('_PyNEC', +necpp_module = setuptools.Extension( + "_PyNEC", sources=nec_sources, - - include_dirs=[np.get_include(), 'necpp_src/src', 'necpp_src/', 'necpp_src/win32/'], - extra_compile_args = ['-fPIC'], - extra_link_args = ['-lstdc++'], + include_dirs=[np.get_include(), "necpp_src/src", "necpp_src/", "necpp_src/win32/"], + extra_compile_args=["-fPIC"], + extra_link_args=["-lstdc++"], depends=nec_headers, - define_macros=[('BUILD_PYTHON', '1'), ('NPY_NO_DEPRECATED_API','NPY_1_7_API_VERSION')] - ) + define_macros=[ + ("BUILD_PYTHON", "1"), + ("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"), + ], +) with open("README.md", "r") as fh: long_description = fh.read() - -setuptools.setup (name = 'PyNEC', - version = '1.7.3.6', - author = "Tim Molteno", - author_email = "tim@physics.otago.ac.nz", - url = "http://github.com/tmolteno/python-necpp", - keywords = "nec2 nec2++ antenna electromagnetism radio", - description = "Python Antenna Simulation Module (nec2++) object-oriented interface", + +setuptools.setup( + name="PyNEC", + version="1.7.4", + author="Tim Molteno", + author_email="tim@physics.otago.ac.nz", + url="http://github.com/tmolteno/python-necpp", + keywords="nec2 nec2++ antenna electromagnetism radio", + description="Python Antenna Simulation Module (nec2++) object-oriented interface", long_description=long_description, long_description_content_type="text/markdown", include_package_data=True, - data_files=[('examples', ['example/test_rp.py'])], - ext_modules = [necpp_module], - requires = ['numpy'], - py_modules = ["PyNEC"], - license='GPLv2', + data_files=[("examples", ["example/test_rp.py"])], + ext_modules=[necpp_module], + requires=["numpy"], + py_modules=["PyNEC"], + license="GPLv2", classifiers=[ "Development Status :: 5 - Production/Stable", "Topic :: Scientific/Engineering", "Topic :: Communications :: Ham Radio", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - 'Programming Language :: Python :: 3', - "Intended Audience :: Science/Research"] + "Programming Language :: Python :: 3", + "Intended Audience :: Science/Research", + ], ) diff --git a/necpp/setup.py b/necpp/setup.py index f410e43..896ed98 100644 --- a/necpp/setup.py +++ b/necpp/setup.py @@ -1,19 +1,25 @@ #!/usr/bin/env python """ -setup.py file for necpp Python module. +setup.py file for necpp Python module. """ -from setuptools import setup, Extension -from glob import glob import os +from glob import glob + +from setuptools import Extension, setup nec_sources = [] -nec_sources.extend([fn for fn in glob('necpp_src/src/*.cpp') - if not os.path.basename(fn).endswith('_tb.cpp') - if not os.path.basename(fn).startswith('net_solve.cpp') - if not os.path.basename(fn).startswith('nec2cpp.cpp') - if not os.path.basename(fn).startswith('necDiff.cpp')]) +nec_sources.extend( + [ + fn + for fn in glob("necpp_src/src/*.cpp") + if not os.path.basename(fn).endswith("_tb.cpp") + if not os.path.basename(fn).startswith("net_solve.cpp") + if not os.path.basename(fn).startswith("nec2cpp.cpp") + if not os.path.basename(fn).startswith("necDiff.cpp") + ] +) nec_sources.extend(glob("necpp_wrap.c")) nec_headers = [] @@ -24,40 +30,43 @@ # At the moment, the config.h file is needed, and this should be generated from the ./configure # command in the parent directory. Use ./configure --without-lapack to avoid dependance on LAPACK # -necpp_module = Extension('_necpp', +necpp_module = Extension( + "_necpp", sources=nec_sources, - include_dirs=['necpp_src/src/', 'necpp_src/'], + include_dirs=["necpp_src/src/", "necpp_src/"], depends=nec_headers, - define_macros=[('BUILD_PYTHON', '1')] - ) + define_macros=[("BUILD_PYTHON", "1")], +) -with open('README.md') as f: +with open("README.md") as f: readme = f.read() -setup (name = 'necpp', - version = '1.7.3.5', - author = "Tim Molteno", - author_email = "tim@physics.otago.ac.nz", - url = "http://github.com/tmolteno/necpp", - keywords = "nec2 nec2++ antenna electromagnetism radio", - description = "Python Antenna Simulation Module (nec2++) C-style interface", +setup( + name="necpp", + version="1.7.4", + author="Tim Molteno", + author_email="tim@physics.otago.ac.nz", + url="http://github.com/tmolteno/necpp", + keywords="nec2 nec2++ antenna electromagnetism radio", + description="Python Antenna Simulation Module (nec2++) C-style interface", long_description=readme, long_description_content_type="text/markdown", include_package_data=True, - data_files=[('examples', ['necpp_src/example/test.py'])], - ext_modules = [necpp_module], - py_modules = ["necpp"], - license='GPLv2', + data_files=[("examples", ["necpp_src/example/test.py"])], + ext_modules=[necpp_module], + py_modules=["necpp"], + license="GPLv2", classifiers=[ - "Development Status :: 5 - Production/Stable", - "Topic :: Scientific/Engineering", - "Topic :: Communications :: Ham Radio", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - "Intended Audience :: Science/Research"] + "Development Status :: 5 - Production/Stable", + "Topic :: Scientific/Engineering", + "Topic :: Communications :: Ham Radio", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Intended Audience :: Science/Research", + ], ) From db34f239b92f746682717ad021b80b2dfc8bedb2 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Tue, 6 Jan 2026 12:10:55 +1300 Subject: [PATCH 42/44] Update submodule --- necpp_src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/necpp_src b/necpp_src index 0af22b1..bc9aace 160000 --- a/necpp_src +++ b/necpp_src @@ -1 +1 @@ -Subproject commit 0af22b10d5b8e96da412009ef1178f1b4131cbb8 +Subproject commit bc9aaceedec50ac44dbed6e58a970b8007b346d3 From 5fc06f20035abc19713eed3144c01384097d08ea Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Tue, 6 Jan 2026 12:14:14 +1300 Subject: [PATCH 43/44] Add gfortran as a dependency --- .github/workflows/build-necpp-wheels.yml | 6 +++--- .github/workflows/build-pynec-wheels.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-necpp-wheels.yml b/.github/workflows/build-necpp-wheels.yml index f2ce2ba..6a42efd 100644 --- a/.github/workflows/build-necpp-wheels.yml +++ b/.github/workflows/build-necpp-wheels.yml @@ -35,12 +35,12 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool + sudo apt-get install -y swig autoconf automake libtool gfortran - name: Install build dependencies (macOS) if: runner.os == 'macOS' run: | - brew install swig autoconf automake libtool + brew install swig autoconf automake libtool gfortran - name: Configure necpp_src shell: bash @@ -84,7 +84,7 @@ jobs: - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool + sudo apt-get install -y swig autoconf automake libtool gfortran - name: Configure necpp_src run: | diff --git a/.github/workflows/build-pynec-wheels.yml b/.github/workflows/build-pynec-wheels.yml index c5a3c63..0d02d2a 100644 --- a/.github/workflows/build-pynec-wheels.yml +++ b/.github/workflows/build-pynec-wheels.yml @@ -35,12 +35,12 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool + sudo apt-get install -y swig autoconf automake libtool gfortran - name: Install build dependencies (macOS) if: runner.os == 'macOS' run: | - brew install swig autoconf automake libtool + brew install swig autoconf automake libtool gfortran - name: Configure necpp_src shell: bash @@ -84,7 +84,7 @@ jobs: - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool + sudo apt-get install -y swig autoconf automake libtool gfortran - name: Configure necpp_src run: | From 99c1533c2063a950b33254f5119e200785147c74 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Tue, 6 Jan 2026 15:54:15 +1300 Subject: [PATCH 44/44] Remove lapack and gfortran dependence --- .github/workflows/build-necpp-wheels.yml | 10 +++++----- .github/workflows/build-pynec-wheels.yml | 10 +++++----- necpp_src | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-necpp-wheels.yml b/.github/workflows/build-necpp-wheels.yml index 6a42efd..b1255a2 100644 --- a/.github/workflows/build-necpp-wheels.yml +++ b/.github/workflows/build-necpp-wheels.yml @@ -35,19 +35,19 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool gfortran + sudo apt-get install -y swig autoconf automake libtool - name: Install build dependencies (macOS) if: runner.os == 'macOS' run: | - brew install swig autoconf automake libtool gfortran + brew install swig autoconf automake libtool - name: Configure necpp_src shell: bash run: | cd necpp_src make -f Makefile.git - ./configure --without-lapack + ./configure - name: Setup package directory and generate SWIG wrapper shell: bash @@ -84,13 +84,13 @@ jobs: - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool gfortran + sudo apt-get install -y swig autoconf automake libtool - name: Configure necpp_src run: | cd necpp_src make -f Makefile.git - ./configure --without-lapack + ./configure - name: Setup package directory and generate SWIG wrapper run: | diff --git a/.github/workflows/build-pynec-wheels.yml b/.github/workflows/build-pynec-wheels.yml index 0d02d2a..bb89d90 100644 --- a/.github/workflows/build-pynec-wheels.yml +++ b/.github/workflows/build-pynec-wheels.yml @@ -35,19 +35,19 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool gfortran + sudo apt-get install -y swig autoconf automake libtool - name: Install build dependencies (macOS) if: runner.os == 'macOS' run: | - brew install swig autoconf automake libtool gfortran + brew install swig autoconf automake libtool - name: Configure necpp_src shell: bash run: | cd necpp_src make -f Makefile.git - ./configure --without-lapack + ./configure - name: Setup package directory and generate SWIG wrapper shell: bash @@ -84,13 +84,13 @@ jobs: - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y swig autoconf automake libtool gfortran + sudo apt-get install -y swig autoconf automake libtool - name: Configure necpp_src run: | cd necpp_src make -f Makefile.git - ./configure --without-lapack + ./configure - name: Setup package directory and generate SWIG wrapper run: | diff --git a/necpp_src b/necpp_src index bc9aace..049c556 160000 --- a/necpp_src +++ b/necpp_src @@ -1 +1 @@ -Subproject commit bc9aaceedec50ac44dbed6e58a970b8007b346d3 +Subproject commit 049c556cb10769410b760dcea7ef341a3e08f78b