Skip to content

Commit

Permalink
Fix fmiAbs() and fmiMax()
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Oct 7, 2024
1 parent 12ec364 commit 9ae3b27
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/cosimulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion src/fmi1Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 3 additions & 1 deletion src/fmi2Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/fmi3Functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9ae3b27

Please sign in to comment.