Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Do not evaluate the residuals if xloc is inf or NaN
Browse files Browse the repository at this point in the history
This avoids generating silly error-messages saying you have division
involving Inf/NaN when it was simply the non-linear solver making an
unreasonable guess.

Belonging to [master]:
  - #1896
  - OpenModelica/OpenModelica-testsuite#811
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jan 3, 2018
1 parent eca7e56 commit 775a336
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -2673,10 +2673,19 @@ match system
DATA *data = (DATA*) ((void**)dataIn[0]);
threadData_t *threadData = (threadData_t*) ((void**)dataIn[1]);
const int equationIndexes[2] = {1,<%nls.index%>};
int i;
<%varDecls%>
<% if profileAll() then 'SIM_PROF_TICK_EQ(<%nls.index%>);' %>
<% if profileSome() then 'SIM_PROF_ADD_NCALL_EQ(modelInfoGetEquation(&data->modelData->modelDataXml,<%nls.index%>).profileBlockIndex,1);' %>
/* 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;
}
<%if intEq(whichSet, 0) then "return;" else "return 1;"%>
}
}
<%xlocs%>
/* backup outputs */
<%backupOutputs%>
Expand Down

0 comments on commit 775a336

Please sign in to comment.