Skip to content

Commit

Permalink
Error message if residuum iteration variable NaN (#9522)
Browse files Browse the repository at this point in the history
* Error message if residuum iteration variable NaN
  • Loading branch information
AnHeuermann committed Oct 17, 2022
1 parent 7cc2dd0 commit eb68c1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions OMCompiler/Compiler/Template/CodegenC.tpl
Expand Up @@ -3113,7 +3113,7 @@ match system
DATA *data = userData->data;
threadData_t *threadData = userData->threadData;
const int equationIndexes[2] = {1,<%nls.index%>};
int i;<% if clockIndex then <<
int i,j;<% if clockIndex then <<
const int clockIndex = <%clockIndex%>;
>> %>
<%varDecls%>
Expand All @@ -3122,9 +3122,11 @@ match system
/* iteration variables */
for (i=0; i<<%listLength(nls.crefs)%>; i++) {
if (isinf(xloc[i]) || isnan(xloc[i])) {
for (i=0; i<<%listLength(nls.crefs)%>; i++) {
res[i] = NAN;
errorStreamPrint(LOG_NLS, 0, "residualFunc<%nls.index%>: Iteration variable xloc[%i] is nan.", i);
for (j=0; j<<%listLength(nls.crefs)%>; j++) {
res[j] = NAN;
}
throwStreamPrintWithEquationIndexes(threadData, equationIndexes, "residualFunc<%nls.index%> failed at time=%.15g.\nFor more information please use -lv LOG_NLS.", data->localData[0]->timeValue);
<%if intEq(whichSet, 0) then "return;" else "return 1;"%>
}
}
Expand Down
3 changes: 3 additions & 0 deletions testsuite/simulation/modelica/tearing/dynamicTearing3.mos
Expand Up @@ -375,6 +375,9 @@ simulate(dynamicTearing3,startTime=0,stopTime=2,numberOfIntervals=500,simflags="
// 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.
// 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:
// | | | | abs(x) > 1e-12
// LOG_DT_CONS | info | The following local constraint is violated:
Expand Down

0 comments on commit eb68c1f

Please sign in to comment.