Skip to content

Commit

Permalink
Print true name of iteration variable when inf/nan (#12195)
Browse files Browse the repository at this point in the history
Fixes #12191
  • Loading branch information
phannebohm committed Apr 4, 2024
1 parent bc6c961 commit 1cb1c69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion OMCompiler/Compiler/Template/CodegenC.tpl
Expand Up @@ -3160,7 +3160,8 @@ match system
/* iteration variables */
for (i=0; i<<%listLength(nls.crefs)%>; i++) {
if (isinf(xloc[i]) || isnan(xloc[i])) {
errorStreamPrint(LOG_NLS, 0, "residualFunc<%nls.index%>: Iteration variable xloc[%i] is nan.", i);
errorStreamPrint(LOG_NLS, 0, "residualFunc<%nls.index%>: Iteration variable `%s` is inf or nan.",
modelInfoGetEquation(&data->modelData->modelDataXml, <%nls.index%>).vars[i]);
for (j=0; j<<%listLength(nls.crefs)%>; j++) {
res[j] = NAN;
}
Expand Down
2 changes: 1 addition & 1 deletion testsuite/openmodelica/dataReconciliation/TSP_Pipe3.mos
Expand Up @@ -2258,7 +2258,7 @@ getErrorString();
// LOG_STDOUT | info | DataReconciliation Starting!
// LOG_STDOUT | info | NewDataReconciliationSimpleTests.TSP_Pipe3
// LOG_STDOUT | warning | The default linear solver fails, the fallback solver with total pivoting is started at time 1.000000. That might raise performance issues, for more information use -lv LOG_LS.
// LOG_NLS | error | residualFunc76: Iteration variable xloc[0] is nan.
// LOG_NLS | error | residualFunc76: Iteration variable `singularPressureLoss3.Pm` is inf or nan.
// LOG_ASSERT | debug | residualFunc76 failed at time=1.
// | | | | For more information please use -lv LOG_NLS.
// LOG_ASSERT | debug | Solving non-linear system 76 failed at time=1.
Expand Down
8 changes: 4 additions & 4 deletions testsuite/simulation/modelica/tearing/dynamicTearing3.mos
Expand Up @@ -130,7 +130,7 @@ simulate(dynamicTearing3,startTime=0,stopTime=2,numberOfIntervals=500,simflags="
// Forced selection of Tearing Variables:
// ========================================
// Unsolvables as tVars: 3
// Variables with annotation attribute 'always' as tVars:
// Variables with annotation attribute 'always' as tVars:
//
// Matching
// ========================================
Expand Down Expand Up @@ -265,7 +265,7 @@ simulate(dynamicTearing3,startTime=0,stopTime=2,numberOfIntervals=500,simflags="
// Forced selection of Tearing Variables:
// ========================================
// Unsolvables as tVars: 4
// Variables with annotation attribute 'always' as tVars:
// Variables with annotation attribute 'always' as tVars:
//
// Matching
// ========================================
Expand Down Expand Up @@ -369,13 +369,13 @@ simulate(dynamicTearing3,startTime=0,stopTime=2,numberOfIntervals=500,simflags="
//
// record SimulationResult
// resultFile = "dynamicTearing3_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'dynamicTearing3', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv=LOG_DT_CONS'",
// simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'dynamicTearing3', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv=LOG_DT_CONS'",
// messages = "LOG_DT_CONS | info | The following local constraint is violated:
// | | | | abs(x) > 1e-12
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_DT_CONS | info | The following local constraint is violated:
// | | | | abs(x) > 1e-12
// LOG_NLS | error | residualFunc10: Iteration variable xloc[0] is nan.
// LOG_NLS | error | residualFunc10: Iteration variable `z` is inf or nan.
// LOG_ASSERT | debug | residualFunc10 failed at time=0.004.
// | | | | For more information please use -lv LOG_NLS.
// LOG_DT_CONS | info | The following local constraint is violated:
Expand Down

0 comments on commit 1cb1c69

Please sign in to comment.