I'm developing a program that should simulate FMU's, it is based on the FMU SDK. It can be found in: https://fmi-standard.org/downloads/
I've developed a simple model in SM just to test some program features. The model is attached to the post. I've exported a Co-Simulation FMU (2.0) with DASSL solver from the model and executed it in my program. The problem is when I set the step for the function DoStep to 0.1 or 0.01 the simulation gets stuck at the DoStep function.
while (time < t_end)
{
if (step > t_end - time) step = t_end - time;
fmi2Flag = fmu_sim->fmu.doStep(fmu_sim->c, time, step, fmi2True);
if (fmi2Flag == fmi2Discard) {
fmi2Boolean b;
// check if model requests to end simulation
if (fmi2OK != fmu_sim->fmu.getBooleanStatus(fmu_sim->c, fmi2Terminated, &b)) {
return error("could not complete simulation of the model. getBooleanStatus return other than fmi2OK");
}
if (b == fmi2True) {
return error("the model requested to end the simulation");
}
return error("could not complete simulation of the model - fmi2Discard");
}
if (fmi2Flag != fmi2OK) return error("could not complete simulation of the model - ERROR!");
printf("time: %.10f\n",time);
time += step;
}
I found that the error is related to the block IntegerStep1
:
The function get stuck at the time step immediately before the step start time. I tried different values, for example: if I put a start time of 7 then it gets stuck at 6.9 for a 0.1 step or gets stuck at 6.99 for a 0.01 step. if I put a start time of 10 then it gets stuck at 9.9 for a 0.1 step or gets stuck at 9.99 for a 0.01 step. Doesn't matter simulation end time. However, if I change the step value for different values than those two everything works. Also, if put something like 0.10000000001 or 0.010000001, it works fine as well.
What is strange is that for the boolean step start time in the model there is no error.
After all the test, I tried to open the FMU in SM and execute it with a 0.1 and 0.01 step and it worked well, I'm not sure what I can be missing in the program.
System information:
Product version: 12.1.0.8
Client: Model Center
Client version: 12.1.0.30
Client creation date: 2020-03-02T13:38:32.855263
Client build revisions: S:2b715d78e, J:6a53ed2a2, L:41ddb1b72
Client build type: 64 bit
Kernel version: 12.1.0.34
Kernel creation date: 2020-03-02T13:39:13.038056
Kernel build revisions: S:2b715d78e, J:6a53ed2a2, L:41ddb1b72
Platform: Ubuntu 14.04.6 LTS
Attachments: