Open scaramacai opened 2 years ago
Interesting. Could this be made interactive so 'SY' lines could be passed by stdin and responses via stdout?
The xnec2c parser could add SY support by:
Thus the python necsy code would be a co-processor for xnec2c when loading files.
Questions:
Indeed, you could help remove this comment from input.c!
case SY: /* "sy" TODO Compatibility with 4nec2.
Too difficult, may never happen :-( */
continue;
Your comment https://github.com/KJ7LNW/xnec2c/issues/9#issuecomment-1089420841 is very interesting and ambitious. In my opinion the first thing we could try is to pipe the output of necsy to the input of xnec2c. It would require xnec2c being able to read from stdin; is this already possible?
At the moment i'm still investigating the capabilities of necsy to do the translation, without aborting or showing errors. I'm not a 4nec2 user and I have not yet tested any simulation results against 4nec2. I'll try to install it on a virtual machine and start testing. As for the missing features:
Examples files are taken from 4nec2 and from a couple of other sources. I plan to test (Step 1: check only for the capability of providing an output) all the files bundled with 4nec2.
Your comment #9 (comment) is very interesting and ambitious. In my opinion the first thing we could try is to pipe the output of necsy to the input of xnec2c. It would require xnec2c being able to read from stdin; is this already possible?
It is if you disable forking because child processes expect to read the same input file. Here is a quick hack:
cat examples/airplane.nec | xnec2c -i /proc/self/fd/0 -j0
The -j0
makes it possible by disabling forking.
At the moment i'm still investigating the capabilities of necsy to do the translation, without aborting or showing errors. I'm not a 4nec2 user and I have not yet tested any simulation results against 4nec2. I'll try to install it on a virtual machine and start testing.
FYI: 4nec2 works in WINE, too.
As for the missing features:
the FIX function is still to be implemented (but it should be trivial)
AWG wire radii in mm are implemented for the standard default values in 4nec2 (awg20 to awg0). However the use of the # character in variables is not allowed in necsy and 4nec2's #0 ... #20 are replaced with AWG_0 ... AWG_20.
4nec2 allows for this syntax for measurement units and maybe in other places: number space unit. This is not possible in necsy. For example you need to write 20.5mm and not 20.5 mm
Apart from the SY card, 4nec2 allows for an extended syntax in other places. Notably the percent sign used in EX cards to locate the feed segment; necsy is able to recognize this, but, at the moment, an EX line of this kind is simply copied verbatim, without further processing. While processing the other fields of the cards should be possible with a limited effort, I think that the percent syntax should, anyway, be processed by xnec2, because it implies the knowledge of the wire IDs, the number of segments and so on.
That makes sense, it is probably somewhat simple. Can you create an example .NEC file so I can try to add that?
Examples files are taken from 4nec2 and from a couple of other sources. I plan to test (Step 1: check only for the capability of providing an output) all the files bundled with 4nec2.
There are some other pre-processing that necsy could do, like EX type 6 and LD types 6 and 7:
I'm writing a python script (necsy) to preprocess nec files containing the SY directive. The script is still disorganized and probably with bugs, but already works in many cases I tested. If you are interested, find it at https://github.com/scaramacai/necsy