NEC2/MP source code - Page 1
Forum section: electronics / rf-microwave

author: rhb
author_rank: Super Contributor
timestamp: September 02, 2018, 05:18:28 pm
content: Does anyone have it? It was released in 2012, but the author's web page is gone. I'd like to pick where he left off if that's possible.

author: rf+tech
author_rank: Frequent Contributor
timestamp: September 03, 2018, 11:59:14 am
content: rhb,Thanks to site capture by Archive dot org on 02 May 2013, NEC2/MP v1.5 download is still available.https://web.archive.org/web/20130502013310/http://users.otenet.gr/~jmsp/Look for the download link in the right-hand sidebar, near the bottom of the page.RF+ Tech

author: rhb
author_rank: Super Contributor
timestamp: September 03, 2018, 04:20:24 pm
content: sigh... No source code :-(

author: hagster
author_rank: Frequent Contributor
timestamp: September 04, 2018, 11:45:56 am
content: Shame, I use 4NEC2 a fair bit and with the NEC2/MP code, so any enhancements would be great. What sort of thing did you want it to do that currently it can't?

author: mariush
author_rank: Super Contributor
timestamp: September 04, 2018, 11:50:53 am
content: See the bottom of that page that's archived ... you have there an email address for the guy who had the website. Maybe contact him and ask him if he has the source code?I also looked for the download link and found the file was called nec2mp.zip so i googled for that but not sure if this zip contains the source code or not :https://www.google.com/search?q=nec2mp.zip&ie=utf-8&oe=utf-8&client=firefox-bAnyway, point is if you can figure out what the source code file name was, you can search for the specific file name and if you're lucky you may find it somewhere. Also use other search engines than google, some are better than Google at searching for file names and stuff like this, compared to Google.

author: rhb
author_rank: Super Contributor
timestamp: September 04, 2018, 01:10:22 pm
content: The zip file was just Windows executables.I'm a retired oil industry research scientist/programmer. I've gotten very interested in the design of a multiband HF dipole. The current state of the art in the ham community has not even made it to the work of Robert Whitman in ECOM-3333 written in 1970.I've maintained about 1 million lines of dusty deck FORTRAN codes and am very familiar with the wave equation, optimization, parallel programming, etc. It's obvious from my reading that NEC2 and NEC4 are not highly optimized for modern shared memory machines.I've not yet looked at the NEC2 source code, so I'm not sure if it is worth keeping or not. It may well be easier to simply rewrite most of it. Should I choose that route I'll retain the NEC2/4 card deck input syntax and semantics. I've been reading the HOBBIES book by Zhang, Sarkar et al and the use of higher order basis functions, in particular the one they use is very attractive as it greatly reduces the number of segments required and is very quick to evaluate.NEC2 does not handle insulated wire nor does it handle radials which are buried or close to the ground. With the restrictions on NEC4 I'm a bit reluctant to optimize it. It seems more sensible to simply add the features to NEC2 or a clone of NEC2. My focus is wire antennas, so I probably would not go beyond that if I do a major rewrite.I sent an email and it does not seem to have bounced. So maybe I'll get a response.

author: tsman
author_rank: Frequent Contributor
timestamp: September 04, 2018, 02:27:43 pm
content: Was the source ever released for NEC2/MP? It doesn't look like it from that archived webpage.

author: rf+tech
author_rank: Frequent Contributor
timestamp: September 05, 2018, 03:48:35 am
content: For all interested, NEC2 has already been translated from FORTRAN into C and C++.nec2c:https://www.qsl.net/5b4az/pages/nec2.htmlnec2++:https://github.com/tmolteno/necppThere's even cocoaNEC for Mac OSX, written in Objective-C:http://www.w7ay.net/site/Applications/cocoaNEC/index.htmlSource code for all three projects seem to be available.RF+ Tech

author: rhb
author_rank: Super Contributor
timestamp: September 05, 2018, 11:54:18 am
content: The C version was an f2c translation. That's not really useful. f2c has the distinction of being the first implementation of F77.From some comments by the creator of NEC2/MP, I'm beginning to suspect that it is easier to rewrite NEC2 than to use it as a base. Just keep the input and output code. I was playing around with HOBBIES yesterday and not very happy with the GUI. Conceptually, HOBBIES looks quite attractive.I'll unpack the original FORTRAN and have a look at how difficult it would be to use modern linear algebra libraries.Edit: Gack!!! Column 7 code with labeled go to, abundant common and very few comments. It is certainly a contender for worst FORTRAN code I've ever seen in over a million lines of old code. I would expect to find a lot of latent bugs. I found 4 NAMED COMMON bugs in a couple of minutes in the nec81.tar file.Not no, but HELL NO!It would be easier and quicker to just start over using the NEC4 manual as a guide. code like this is rife with weird obscure bugs that take a ridiculous amount of time find.

author: hagster
author_rank: Frequent Contributor
timestamp: September 05, 2018, 05:38:20 pm
content: Has anyone used Em-HOBBIES? It looks like it could be quite good, but i'm not clear waht the licence restrictions are. You can download an acedemic version which I think has some model size restrictions. Or buy the book for about $220 USD, noting that the first review says that the licence key does not work.

author: rhb
author_rank: Super Contributor
timestamp: September 05, 2018, 06:23:10 pm
content: The book is the software manual for HOBBIES. Theory is 80 of the 540 pages. The rest is examples you can't run with the supplied version. I just posted a review and am returning the book. The UI is maddening.It appears that it will run in evaluation mode without a license. I suggest downloading it and then trying to do the first tutorial under the help menu.At the moment you cannot contact em-hobbies.com because their mailbox quotas are full.

author: rf+tech
author_rank: Frequent Contributor
timestamp: September 05, 2018, 06:39:00 pm
content: rhb,Fair enough, here's one more.The author of GNU-NEC mentions the same shortcomings of NEC2C and NEC++. He has therefore chosen to "directly implement the mathematical methodology outlined in the NEC2 Program Description manual in C++."http://users.tpg.com.au/micksw012/gnu-nec.htmlThis project appears to be active, svn repository last updated 18 March, 2018.https://sourceforge.net/p/gnu-nec/code/HEAD/tree/trunk/As I'm not a programmer, I cannot comment on the author's code or whether it may be of value.RF+ Tech

author: rhb
author_rank: Super Contributor
timestamp: September 05, 2018, 07:51:51 pm
content: Interesting. I wish he had used the NEC4 manual and hadn't used C++ though.I've ordered a couple of books on MoM. The original by Harrington and a more recent treatment. So to save on the cost of buying a commercial antenna I'll probably wind up spending about $1000 just on books.It's increasingly looking as if I may write my own MoM code following the card format of NEC4. In particular, NEC2 does not handle insulated wires and I'll be mounting my antennas in tall pine trees. So I need that, but I don't want to pay $300 for code this crude.It turns out that there are a lot of variants of the NEC2 source code. I'm going to build ftnchek and make a cleanup pass over whichever looks to be the best version.Unfortunately, it doesn't look as if one could use much from the LLNL code. But all the heavy lifting will be done by the linear algebra libraries, so it's really just define the input, create the matrix problem Ax=y and solve for x. If I do that cleanly it will be easy to add features later.HOBBIES just uses a basis which is s**i-1 for i even and s**i-s for i odd instead of the constant value traditionally used. So you can use longer segments as the basis is a much better approximation to a sinusoid. That in turn reduces the size of the A matrix needed to solve for the currents.

author: hagster
author_rank: Frequent Contributor
timestamp: September 05, 2018, 08:27:13 pm
content: I havent tried it, but I thought 4nec2 did support insulated wires.https://www.google.co.uk/amp/s/kk7s.net/2012/07/12/modeling-insulation-and-other-tricks-in-4nec2-4/amp/

author: rhb
author_rank: Super Contributor
timestamp: September 05, 2018, 10:27:32 pm
content: News to me. But thanks. That gives me some impetus to look more closely at NEC2 if I ever get to where I can download Arie Voors' sources.I've been running various NEC2 variants through ftnchek. Most of it is noise about promotions, but there are some argument passing messages that will need examination.Having worked on over a million lines of old FORTRAN code I make a point of doing a series of PM measures:Declare "IMPLICIT NONE" and declare all variables. This catches typos where an assignment is made to a variable that is then never referenced.Move all NAMED COMMON into include files. This fixes transposed elements or different size blocks.Cleanup up all compiler and static analyzer warnings. NEC2 is fairly small at only about 10,000 lines. I'm used to dealing with 100,000 line programs.NEC2 is too ugly to add features to, but I don't mind doing a bit of bug hunting for something which is so widely used.

author: hagster
author_rank: Frequent Contributor
timestamp: September 06, 2018, 06:18:40 am
content: Have you looked at OpenEMS?

author: rhb
author_rank: Super Contributor
timestamp: September 06, 2018, 11:58:46 am
content: I have now. Thanks!!I have experience with FDTD for elastic waves. The only problem is it's quite compute intensive. In the oil industry it's used extensively for high end imaging problems. 10-20,000 x86_64 nodes running for 7-10 days. For that it's actually done in two directions forward and backwards time. So it's twice the work.

author: hagster
author_rank: Frequent Contributor
timestamp: September 06, 2018, 01:18:23 pm
content: I haven't tried OpenEMS in anger(because it has a steep learning curve). But have tried some of the commercial codes in the past. As you say, they are much slower than NEC2. On a modern PC with NEC2/MP I have very few models that take more than 30seconds per frequency. I guess for a similar model it would take about 5-10minutes on HFSS per frequency.However, there are many models that can not be simulated at all in NEC2 and that is the bigger issue for me.

author: rhb
author_rank: Super Contributor
timestamp: September 06, 2018, 02:49:21 pm
content: What is the obstacle in NEC2?There seem to be a rather large assortment of MoM codes available in source form. I think it would probably take a month or more full time just to try them all out with a common dipole over ground model. And a similar number of codes using other methods.

author: hagster
author_rank: Frequent Contributor
timestamp: September 06, 2018, 04:05:10 pm
content: You can only model wires. No way to model dielectrics with different permitivity or permiability. So for instance you can model a patch antenna on a high permitivity substrate or a wifi antenna within its plastic case.

author: rhb
author_rank: Super Contributor
timestamp: September 06, 2018, 08:30:52 pm
content: HOBBIES will do a patch antenna over a PEC with a dielectric between. It's the last demo. They compute the directivity for 4 zero thickness patches 14 mm x 9.6 mm with a 0.8 mm substrate.If it just had a better thought out UI it would be pretty good.

author: hagster
author_rank: Frequent Contributor
timestamp: September 06, 2018, 09:16:10 pm
content: Looking forward to giving HOBBIES a try. I honestly had never heard of it before. Thanks for bringing it to my attention. The UI didnt look that bad from my 5 minute test today.

author: rhb
author_rank: Super Contributor
timestamp: September 06, 2018, 09:49:42 pm
content: I just spent several hours trying to get the feed wires for the patch example to appear. I *did* finally figure it out, but I'm not sure I'll be able to do it next time.It actually looks to be pretty well thought out and implemented on the physics side. Perhaps they'll open source the Tcl/Tk UI. As an example of the issues. Once you get into zoom, rotate, pan or similar modes there is no obvious way to get out of it except to quit the program! In the right mouse menu for those options, "quit" doesn't get you out of that mode, it exits the program. And it does some input project updates without telling you at other points in the program. So the only safe way to modify some prior work is to make a copy and work on the copy.As an example of the UI issues, if you get a plot of Z(f) and you zoom in, you no longer have any scales. And you do not have any control over the scales so far as I can tell. However, at least some of the output can be exported in ASCII so you can make publication quality figures with gnuplot.I'm a science and systems guy. I worked with a guy who was *really* good at UI design. He couldn't touch me on the systems side, but I couldn't touch him on the UI side. Working with him for 3 years was very educational.Your comment about needing to do a patch antenna model made me go look at HOBBIES again. I'd already requested and been granted a return by Amazon. But I'm beginning to reconsider the return.

author: hagster
author_rank: Frequent Contributor
timestamp: September 07, 2018, 03:34:02 pm
content: I have had a quick go with Hobbies and I see what you mean about the UI. Im sure its nust a learning curve kind of thing though.I have seen some second hand copies of the book on amazon. Do you recon the licence key would still work with the codes from these?I also have seen some slides to suggest there was a more professional HOBBIES EM-SUITE 2016. This seems to have vanished into the ether now though. Shame the UI looks much improved.

author: rhb
author_rank: Super Contributor
timestamp: September 07, 2018, 03:52:42 pm
content: If and only if the license was tied to a USB drive which is supplied will a used copy work.It explicitly states that additional copies of the software can only be obtained by buying additional copies of the book. I specifically bought a new SanDisk drive for the license. It uses a hash of the USB information as the key.There is certainly a professional version, but the "company" is not very organized. As of yesterday, mail to contact@em-hobbies.com still bounced with a "mailbox quota exceeded" error. I have not seen any information about professional versions.