Canadian TV, Computing and Home Theatre Forums banner

Some NEC questions

1K views 5 replies 4 participants last post by  nikiml 
#1 ·
Hey folks! Got a few questions about the nikiml NEC program for simulating antennas that I hope I can get some answers for from the members at this site.
If this is not posted in the proper section, my apologies and hopefully a moderator/admin will place it in the more appropriate section.


I have recently started trying to learn the ins & outs of simulating antenna builds in the NEC program and of course I am having some questions.


1) I have ran a few different nec files through the optimization and I have witnesed some files are created with the name of 'bestx_xxx' & other nec files are created with the name of best-x.xxx'. all f the files that are created seem to decrease in the 'x_xxx' values, but I am wondering why some are positive values & others are negative values? Does the positive/negative naming convention indicate that something is inherently wrong with the results with one or the other named files? Will the 'bestx_xxx' named files eventually reduce to 'best-x_xxx' as they improve? Is the NEC program designed to stop running after it figures that there can be no more improvements or will it just keep running until it hits the default of 10k iterations? Is there a file name that would be created when NEC believes it has acheived the maximum potential of the simulation?


2) AGT correction - I have noticed that if I adjust an nec file wire size to show an AGT of 0.95 - 1.05 in 4nec2, after I run the optimization in NEC, the AGT in 4nec2 is no longer within the range of 0.95 - 1.05. Well normally I would just adjust the wire size again and repeat, today I can't adjust the wire size any more to get the AGT into the acceptable range of 0.95 - 1.05. Is there anything else that I can adjust to get the AGT back to the acceptable range? I think I recall that the 'EX' card is tied into it somehow, but I haven't seen what all of the 'EX' settings are for.


3) The '-F TARGET_FUNCTION, --target-function=TARGET_FUNCTION'. The 'formulas' for this I have seen, appear to try and do a smarter optimiztion. I am confused on where the numbers are coming from and what the formulas attempt to do:


For Example:


CMD--OPT --target-function=-.5*min_net_gain-.5*ave_net_gain - I have tested this one and it appears to create a gain plot that attempts to have a similar lowest/highest frequency value & in the middle of the range it is a higher value, in other words it slopes up to the middle of the frequency range & then slopes back down to the end of the frequency range.


I have also seen the following which I am confused as to where the values are coming from and what the formulas are attempting to achieve as far as plotting goes:



CMD--OPT --target-function=(2*max_ml+8*max_gain_diff)/10
CMD--OPT --target-function=5+.5*ave_max_gain_diff-.5*ave_net_gain
CMD--OPT --target-function=.2*ave_max_gain_diff+.8*ave_gain_diff


Sorry for the abundance of questions, they have been building up & I haven't been able to solve them on my own thus far.


Thank you in advance for any members that attempt to weed through those barrage of questions!
 
See less See more
#5 · (Edited)
Hey folks! Got a few questions about the nikiml NEC program for simulating antennas that I hope I can get some answers for from the members at this site.
If this is not posted in the proper section, my apologies and hopefully a moderator/admin will place it in the more appropriate section.


I have recently started trying to learn the ins & outs of simulating antenna builds in the NEC program and of course I am having some questions.


1) I have ran a few different nec files through the optimization and I have witnessed some files are created with the name of 'bestx_xxx' & other nec files are created with the name of best-x.xxx'. all f the files that are created seem to decrease in the 'x_xxx' values, but I am wondering why some are positive values & others are negative values? Does the positive/negative naming convention indicate that something is inherently wrong with the results with one or the other named files? Will the 'bestx_xxx' named files eventually reduce to 'best-x_xxx' as they improve? Is the NEC program designed to stop running after it figures that there can be no more improvements or will it just keep running until it hits the default of 10k iterations? Is there a file name that would be created when NEC believes it has achieved the maximum potential of the simulation?

A1: The "best" file number indicates the monotonically decreasing "goodness" of the Optimization....there is nothing significant about negative numbers other than it reflects the effect of various WEIGHTINGS (you show use of fractional weights). FWIW: Although NOT required, I normalize MY Weightings....I also use Mismatch Loss (in dB) vice SWR (a non-linear scalar number), since it allows a more meaningful Apples-to-Apples Tradeoff vs other performance factors that are also in dB. I have found that fol. CMD Statements work VERY WELL, although Gain and SWR Weights frequently need to be changed based on Preliminary Results, depending on whether you want to higher "importance" Weightings for some performance parameter (e.g. SWR) versus the other parameter(s)....there is nearly ALWAYS a tradeoff of SWR vs Raw Gain. [And I ALWAYS calculate Hi-VHF EVAL performance for UHF Antennas....just in case someone asks.] IF you want a Joint Hi-VHF and UHF Optimization, add a separate line for Hi-VHF targets and adjust relative number of SAMPLE FREQS [higher or lower Freq Increments] for Hi-VHF vs UHF to adjust relative IMPORTANCE of one versus the other....since they each can feed a DIFFERENT Total number of Data Points into the single Target Function Calculation. BTW: I've never seen a problem if num-cores is higher than ACTUAL number of Hyper-Threads:

IF NO REFLECTOR:
CMD--OPT -s(470,12,20) -t(9,11) --swr-target=2.7
CMD--OPT --target-function=(max_ml+8*max_gain_diff)/9
CMD--OPT --de-np=100 -r restart.log
CMD--OPT --auto-segmentation=13 --char-impedance=300 --num-cores=12
CMD--EVAL --auto-segmentation=0 --char-impedance=300 --num-cores=12
CMD--EVAL -s(174,6,8) -s(470,12,29) --total-gain --publish

IF REFLECTOR:
CMD--OPT -s(470,12,20) -t(13,16) --swr-target=2.7 --f2r-target=20 --f2b-target=20
CMD--OPT --target-function=(4*max_ml+8*max_gain_diff+4*max_f2r_diff+max_f2b_diff)/27
CMD--OPT --de-np=150 -r restart.log
CMD--OPT --auto-segmentation=11 --char-impedance=300 --num-cores=12
CMD--EVAL --auto-segmentation=0 --char-impedance=300 --num-cores=12
CMD--EVAL -s(174,1.5,29) -s(470,12,29) --total-gain --publish


2) AGT correction - I have noticed that if I adjust an nec file wire size to show an AGT of 0.95 - 1.05 in 4nec2, after I run the optimization in NEC, the AGT in 4nec2 is no longer within the range of 0.95 - 1.05. Well normally I would just adjust the wire size again and repeat, today I can't adjust the wire size any more to get the AGT into the acceptable range of 0.95 - 1.05. Is there anything else that I can adjust to get the AGT back to the acceptable range? I think I recall that the 'EX' card is tied into it somehow, but I haven't seen what all of the 'EX' settings are for.

A2) AGT is also dependent on selection of number of Segments in the Simulated Balun SOURCE Wire (i.e. Wire number in EX Statement) and overall Segmentation. I frequently use MANUAL Segmentation where I set number of segments in SOURCE Wire to ONE, and then adjust all other Wire Segmentations are ABOUT = Wire-Length/SOURCE-Wire-Length, hence all SEGMENTS are roughly EQUAL. 4nec2 also has AUTOSEG Feature, but you have to GUESS a Segmentation value (start with 7 and increase to say 11, 15, 21, 31, 41, etc until no more AGT "convergence" problems". The EASIEST is to TRY choosing 1 (or 3 or 5) for the number of Segments in the SOURCE and then let nikiml's OPT do the Segmentation (labeled as PythonSeg in my 4nec2 Files). When OPT completes, I usually open the "Output*.nec" file and Copy/Paste the GW Segmentations (one-by-one), EX Statement changes [if any] and COMMENTS into the ORIGINAL 4nec2 File (cuz OPT kills all of my Comments and Formatting Tabs). It is also possible that the 4nec2 model is more complicated (too many SMALL Wires) than it needs to be and can benefit from DELETING extraneous wires (e.g. 91XG model) and/or try something DIFFERENT...and try to KEEP IT SIMPLE....don't try to use NEC2 Engine to do what NEC4 Engine was designed to do. FAT Wire Models fall into this category....try to minimize the WARNINGS (and NO ERRORS)....and frequently will NOT work with excessively SMALL Simulated SOURCE Wire Sizes....so you might have to simply accept residual Errors on the order of (if you are lucky) under 0.5 dB.]


3) The '-F TARGET_FUNCTION, --target-function=TARGET_FUNCTION'. The 'formulas' for this I have seen, appear to try and do a smarter optimization. I am confused on where the numbers are coming from and what the formulas attempt to do:

A3: It would take me quite some time to dig up what nikiml has to say about HIS Target Functions.....mine are MUCH BETTER...."believe me"....and I have posted literally HUNDREDS of SUCCESSFULLY Optimized Antennas to prove it. When SWR is excessive, I reduce the "Weighting" of "max_gain" relative to "max_ml" where ml=SWR mismatch loss. And if I want to see if I can squeeze out a bit higher F/B and/or F/R Ratio at the expense of SWR and/or Gain, I can increase their "Weightings". It is all an ITERATIVE Process that typically takes 4-10+ runs before I'm convinced I have truly stumbled onto the "BEST" Optimized Tradeoff between various performance parameters.

For Example:


CMD--OPT --target-function=-.5*min_net_gain-.5*ave_net_gain - I have tested this one and it appears to create a gain plot that attempts to have a similar lowest/highest frequency value & in the middle of the range it is a higher value, in other words it slopes up to the middle of the frequency range & then slopes back down to the end of the frequency range.


I have also seen the following which I am confused as to where the values are coming from and what the formulas are attempting to achieve as far as plotting goes:



CMD--OPT --target-function=(2*max_ml+8*max_gain_diff)/10
CMD--OPT --target-function=5+.5*ave_max_gain_diff-.5*ave_net_gain
CMD--OPT --target-function=.2*ave_max_gain_diff+.8*ave_gain_diff


Sorry for the abundance of questions, they have been building up & I haven't been able to solve them on my own thus far.


Thank you in advance for any members that attempt to weed through those barrage of questions!
See embedded comments.
 
#6 ·
I think that one should come up with a function based on the antenna.
Canned functions are generally good only for initial optimizations.

Lately I like to start with a simple -F "-ave_net_gain" (see the tutorial) for an antenna with a single sweep.
Generally one cannot achieve more gain than that. and it already minimizes the SWR because high SWR leads to gain losses which reduce the net gain. But...

If I don't like the curve this produces, I would try to control it by putting a target curve (with -t(target_gain1,target_gain2,...))
and a target function of the kind -F "w1*max_gain_diff+w2*ave_gain_diff" (here w1,w2 are weights of importance between 0 and 1 with sum 1)
if I don't like the SWR I would add a token in the function controlling it --swr-target=2 -F "w1*max_gain_diff+w2*ave_gain_diff + w3*max_swr_diff" .
If the F/B is insufficient I'd add a target and a function token for it, etc

And again, forcing things numerically closer to desired targets will produce lower average net gain compared to the simple -F -ave_net_gain

For multiple sweeps things are more complicated and more experimentation is needed. But the relative performance of the multiple sweeps is controlled with different target curves and using target dependent function tokens (***_gain_diff)

The initial runs can be done with relatively small --de-np, autosegmentation and sweep sampling, sacrificing accuracy for speed. Once there is a good feel for how the antenna behaves those can be increased.

I know this is too general explanation, but the generality allows flexibility.
 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top