Skip to content

Commit

Permalink
Return error if CVODE failed
Browse files Browse the repository at this point in the history
  - If integrator CVode in oms::SystemSC::doStep() fails return error
  • Loading branch information
AnHeuermann committed Apr 25, 2023
1 parent 2cd3a45 commit affd5ba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/OMSimulatorLib/SystemSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,10 @@ oms_status_enu_t oms::SystemSC::doStep()
{
double cvode_time = tlast;
int flag = CVode(solverData.cvode.mem, tnext, solverData.cvode.y, &cvode_time, CV_NORMAL);
if (flag < 0) logError("SUNDIALS_ERROR: CVode() failed with flag = " + std::to_string(flag));
if (flag < 0) {
logError("SUNDIALS_ERROR: CVode() failed with flag = " + std::to_string(flag));
return oms_status_error;
}

// set states
for (int i=0, j=0; i < fmus.size(); ++i)
Expand All @@ -626,8 +629,10 @@ oms_status_enu_t oms::SystemSC::doStep()
// set time
time = cvode_time;
}
else
else {
logError("Unknown solver method");
return oms_status_fatal;
}

// step is complete
for (int i=0; i < fmus.size(); ++i)
Expand Down

0 comments on commit affd5ba

Please sign in to comment.