diff --git a/src/cosimulation.c b/src/cosimulation.c index 7e3ad0c4..782edf1b 100644 --- a/src/cosimulation.c +++ b/src/cosimulation.c @@ -191,11 +191,11 @@ Status reset(ModelInstance* comp) { #define EPSILON (1.0e-5) -static bool fmiAbs(double v) { +static double fmiAbs(double v) { return v >= 0 ? v : -v; } -static bool fmiMax(double a, double b) { +static double fmiMax(double a, double b) { return (a < b) ? b : a; } diff --git a/src/fmi1Functions.c b/src/fmi1Functions.c index 00ffba94..d35758fa 100644 --- a/src/fmi1Functions.c +++ b/src/fmi1Functions.c @@ -322,7 +322,9 @@ fmiStatus fmiDoStep(fmiComponent c, fmiReal currentCommunicationPoint, fmiReal c while (true) { - if (instance->time > nextCommunicationPoint || isClose(instance->time, nextCommunicationPoint)) { + const fmiReal nextSolverStepTime = instance->time + FIXED_SOLVER_STEP; + + if (nextSolverStepTime > nextCommunicationPoint && !isClose(nextSolverStepTime, nextCommunicationPoint)) { break; // next communcation point reached } diff --git a/src/fmi2Functions.c b/src/fmi2Functions.c index 7fc0a3c5..64df087b 100644 --- a/src/fmi2Functions.c +++ b/src/fmi2Functions.c @@ -647,7 +647,9 @@ fmi2Status fmi2DoStep(fmi2Component c, fmi2Real currentCommunicationPoint, while (true) { - if (S->time > nextCommunicationPoint || isClose(S->time, nextCommunicationPoint)) { + const double nextSolverStepTime = S->time + FIXED_SOLVER_STEP; + + if (nextSolverStepTime > nextCommunicationPoint && !isClose(nextSolverStepTime, nextCommunicationPoint)) { break; // next communcation point reached } diff --git a/src/fmi3Functions.c b/src/fmi3Functions.c index bfb4bca3..b4ad5fbb 100644 --- a/src/fmi3Functions.c +++ b/src/fmi3Functions.c @@ -1381,7 +1381,7 @@ fmi3Status fmi3DoStep(fmi3Instance instance, const fmi3Float64 nextSolverStepTime = S->time + FIXED_SOLVER_STEP; - nextCommunicationPointReached = nextSolverStepTime > nextCommunicationPoint || isClose(nextSolverStepTime, nextCommunicationPoint); + nextCommunicationPointReached = nextSolverStepTime > nextCommunicationPoint && !isClose(nextSolverStepTime, nextCommunicationPoint); if (nextCommunicationPointReached || (*eventHandlingNeeded && S->earlyReturnAllowed)) { break;