KJ7LNW / xnec2c

Xnec2c is a high-performance multi-threaded electromagnetic simulation package to model antenna near- and far-field radiation patterns for Linux and UNIX operating systems.
https://www.xnec2c.org/
GNU General Public License v3.0
77 stars 16 forks source link

Segment tag number error #47

Closed roberthadow closed 3 months ago

roberthadow commented 4 months ago

Update docs with troubleshooting hints for "Segment tag number error."

While the underlying user error may be common to all NEC2 applications, the error message appears to be unique. A sentence or two in the user manual is easy; a hint in the application error message might be more work.

In the mean time, the user is prevented from saving his or her work, which may be substantial.

KJ7LNW commented 4 months ago

Can you provide the .NEC file which generated this error?

KJ7LNW commented 4 months ago

In the mean time, the user is prevented from saving his or her work, which may be substantial.

Calculations cannot run unless the .NEC file has been saved. Thus, as far as I can tell, it is not possible to get this error unless the file has been saved. If you believe this assessment is incorrect, then please provide a step-by-step procedure to generate the error in such way that the file on disk differs from the file in the editor.

roberthadow commented 4 months ago

This file, generated within the application, produces "Segment tag number error": Moxon240503.nec. [attached with ".txt" extension. Apparently, it did save, even though when I clicked the Save icon, I got the error, implying that the command had not completed. If I had looked at the file characteristics, I would have seen that the OS knew it had been recently modified.

Another file, created outside the application, produces "Segment data error, zero-length line? See console." Moxon240504.nec

If we can capture this class of issue--stupid user tricks and obscure error messages--we can add text to the user manual written once/read many until the app or the error message changes. This is work I for which I would respond to a Help Wanted ad.

Moxon240504.nec.txt Moxon240503.nec.txt

KJ7LNW commented 4 months ago

Unfortunately NEC2 tries to parse your input and then calculates segment sizes, so it cannot always produce a meaningful error (this is an NEC2 problem, not an xnec2c problem per se). If you run xnec2c from the command line it may provide more information about the error that is not show in the pop-up window (like tag number).

Additionally, you have two excitations (EX) defined. I believe that this is acceptable, for example you might have expectations on multiple segments at different phases in some antenna geometries. However, if you are just getting started that I recommend sticking to a single excitation line. The console output shows the following:

[err] no segment has an itag of 1
[err] Stop: Segment tag number error

The official an EC to documentation is available here:

These are the references that I used to diagnose the errors that your geometry generated:

You are correct in that the graphical error could be more meaningful by also displaying the console errors in graphical output. If the Stop() function were to be refactored to support variable length arguments, then console warnings could be merged into graphical warnings, and thus be slightly more verbose at the UI. If you have some background in C programming then it would be pretty easy to convert Stop() into something that supports variable length arguments:

https://github.com/KJ7LNW/xnec2c/blob/994927d50effc745924c15bd259989700c71df22/src/utils.c#L91-L93

I opened issue #48 if that is something that you would like to tackle with a pull request, as I do not know when I will get to that. I am of course open to any means of making this program more accessible to users and improvements are welcome.