Skip to content

Commit 40393aa

Browse files
committed
More informative error message. (#419)
### TL;DR - Added more descriptive error message for `JACOBIAN_75_TIMES_BAD` which now explains that this indicates self-intersecting flux surfaces - Simplified the `VmecStatus` enum in `util.h` by removing several unused status codes ### Why make this change? The previous error messages were terse and didn't provide enough context to understand what went wrong during VMEC execution. These improvements make debugging failed VMEC runs easier by providing more descriptive information about the nature of the failures, especially for common issues like overly shaped boundaries causing self-intersecting flux surfaces.
1 parent 2eec4eb commit 40393aa

3 files changed

Lines changed: 9 additions & 24 deletions

File tree

src/vmecpp/cpp/vmecpp/common/util/util.cc

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,19 @@ std::string VmecStatusAsString(const VmecStatus vmec_status) {
2727
return "NORMAL_TERMINATION";
2828
case VmecStatus::BAD_JACOBIAN:
2929
return "BAD_JACOBIAN";
30-
case VmecStatus::NCURR_NE_1_BLOAT_NE_1:
31-
return "NCURR_NE_1_BLOAT_NE_1";
3230
case VmecStatus::JACOBIAN_75_TIMES_BAD:
33-
return "JACOBIAN_75_TIMES_BAD";
34-
case VmecStatus::INPUT_PARSING_ERROR:
35-
return "INPUT_PARSING_ERROR";
36-
case VmecStatus::PHIEDGE_WRONG_SIGN:
37-
return "PHIEDGE_WRONG_SIGN";
38-
case VmecStatus::NS_ERROR:
39-
return "NS_ERROR";
40-
case VmecStatus::MISC_ERROR:
41-
return "MISC_ERROR";
42-
case VmecStatus::VAC_VMEC_ITOR_MISMATCH:
43-
return "VAC_VMEC_ITOR_MISMATCH";
31+
return "JACOBIAN_75_TIMES_BAD The jacobian factor of the geometry "
32+
"repeatedly "
33+
"became negative, indicating that flux surfaces become "
34+
"self-intersecting. This "
35+
"can mean that your prescribed boundary is too shaped for VMEC to "
36+
"resolve ";
4437
case VmecStatus::SUCCESSFUL_TERMINATION:
4538
return "SUCCESSFUL_TERMINATION";
4639
}
4740

4841
// never reached
49-
return "UNKNOWN??";
42+
return "UNKNOWN??" + std::to_string(static_cast<int>(vmec_status));
5043
}
5144

5245
// -1 if x<0, 0 if x==0, +1 if x>0

src/vmecpp/cpp/vmecpp/common/util/util.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,7 @@ enum class VmecStatus : std::uint8_t {
149149
// no fatal error but convergence was not reached
150150
NORMAL_TERMINATION = 0,
151151
BAD_JACOBIAN = 1,
152-
// 2 TODO(jons): not used anymore?
153-
NCURR_NE_1_BLOAT_NE_1 = 3,
154152
JACOBIAN_75_TIMES_BAD = 4,
155-
INPUT_PARSING_ERROR = 5,
156-
// 6 TODO(jons): not used anymore?
157-
PHIEDGE_WRONG_SIGN = 7,
158-
NS_ERROR = 8, // NS ARRAY MUST NOT BE ALL ZEROES
159-
MISC_ERROR = 9, // can happen in mgrid_mod
160-
VAC_VMEC_ITOR_MISMATCH = 10,
161153
// everything went well, VMEC++ converged
162154
SUCCESSFUL_TERMINATION = 11
163155
};

src/vmecpp/cpp/vmecpp/vmec/vmec/vmec.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ absl::StatusOr<bool> Vmec::run(const VmecCheckpoint& checkpoint,
325325
if (status_ != VmecStatus::NORMAL_TERMINATION &&
326326
status_ != VmecStatus::SUCCESSFUL_TERMINATION) {
327327
const auto msg = absl::StrFormat(
328-
"FATAL ERROR in SolveEquilibrium.\nVmec status "
329-
"code: %s\nVmecINDATA had these contents:\n%s",
328+
"FATAL ERROR in SolveEquilibrium: %s\n"
329+
"VmecINDATA had these contents:\n%s",
330330
VmecStatusAsString(status_), *indata_.ToJson());
331331

332332
return absl::InternalError(msg);

0 commit comments

Comments
 (0)