Opened 10 years ago
Closed 10 years ago
#3243 closed defect (fixed)
FMI 2.0 tests Windows - Linux differences
Reported by: | Adeel Asghar | Owned by: | Adrian Pop |
---|---|---|---|
Priority: | high | Milestone: | 1.9.3 |
Component: | FMI | Version: | trunk |
Keywords: | Cc: | Willi Braun |
Description
FMI tests on Windows gives different results when compared to results on Linux Hudson.
Attachments (1)
Change History (17)
comment:1 by , 10 years ago
Component: | Unknown → FMI |
---|---|
Status: | new → accepted |
by , 10 years ago
Attachment: | valgrind-HelloFMI20WorldEvent_me_FMU-trace.txt added |
---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
I think the problem might be the time
variable:
tmp1030 = LessZC($PnextEventTime, time, data->simulationInfo.storedRelations[2]);
In an usual model we define:
#define time data->localData[0]->timeValue
but in the case of the FMU i guess this is not updated to store the FMU time
comment:4 by , 10 years ago
Cc: | added |
---|
Willi or Adeel, any idea on how the time
variable is handled in the FMU?
comment:6 by , 10 years ago
I know that fmi2SetTime will set the FMI instance time.
The question is where is this time variable stored in the FMI instance and how is it connected (if at all) with the one used in our runtime: data->localData[0]->timeValue
.
comment:7 by , 10 years ago
What I found until now is that in FMIL set time does:
fmi2_status_t fmi2_import_set_time(fmi2_import_t* fmu, fmi2_real_t time) { return fmi2_capi_set_time(fmu -> capi, time); }
comment:8 by , 10 years ago
Which then calls:
fmi2_status_t fmi2_capi_set_time(fmi2_capi_t* fmu, fmi2_real_t time) { assert(fmu); jm_log_debug(fmu->callbacks, FMI_CAPI_MODULE_NAME, "Calling fmi2SetTime"); return fmu->fmi2SetTime(fmu->c, time); }
comment:9 by , 10 years ago
yes we call it from /SimulationRuntime/c/fmi/FMI2ModelExchange.c::fmi2SetTime_OMC,
void fmi2SetTime_OMC(void* in_fmi2me, double time) { FMI2ModelExchange* FMI2ME = (FMI2ModelExchange*)in_fmi2me; if (FMI2ME->FMISolvingMode == fmi2_instantiated_mode || FMI2ME->FMISolvingMode == fmi2_event_mode || FMI2ME->FMISolvingMode == fmi2_continuousTime_mode) { fmi2_status_t status = fmi2_import_set_time(FMI2ME->FMIImportInstance, time); if (status != fmi1_status_ok && status != fmi1_status_warning) { ModelicaFormatError("fmi2SetTime failed with status : %s\n", fmi2_status_to_string(status)); } } }
comment:10 by , 10 years ago
FMU 2.0 works in states. We don't update the time variable in all states. Try commenting lines 765 & 766 in SimulationRuntime/fmi/export/fmi2/fmu2_model_interface.c
comment:11 by , 10 years ago
At the end we then reach back to our own export implementation:
fmi2Status fmi2SetTime(fmi2Component c, fmi2Real time) { ModelInstance *comp = (ModelInstance *)c; if (invalidState(comp, "fmi2SetTime", modelInstantiated|modelEventMode|modelContinuousTimeMode)) return fmi2Error; FILTERED_LOG(comp, fmi2OK, LOG_FMI2_CALL, "fmi2SetTime: time=%.16g", time) comp->fmuData->localData[0]->timeValue = time; return fmi2OK; }
The question now is how is the time of the OMC model wrapper used for the FMI import connected to the time in the fmu instance.
follow-up: 13 comment:12 by , 10 years ago
Adeel, you changed this line recently:
if (FMI2ME->FMISolvingMode == fmi2_instantiated_mode || FMI2ME->FMISolvingMode == fmi2_event_mode || FMI2ME->FMISolvingMode == fmi2_continuousTime_mode)
before it was only:
if (FMI2ME->FMISolvingMode != fmi2_initialization_mode)
This means that if FMI2ME->FMISolvingMode
is not any of
fmi2_instantiated_mode
fmi2_event_mode
fmi2_continuousTime_mode
we don't set the time which leads to an uninitialized time value for other solving modes, i guess during initialization.
comment:13 by , 10 years ago
Replying to adrpo:
Adeel, you changed this line recently:
if (FMI2ME->FMISolvingMode == fmi2_instantiated_mode || FMI2ME->FMISolvingMode == fmi2_event_mode || FMI2ME->FMISolvingMode == fmi2_continuousTime_mode)before it was only:
if (FMI2ME->FMISolvingMode != fmi2_initialization_mode)This means that if
FMI2ME->FMISolvingMode
is not any of
fmi2_instantiated_mode
fmi2_event_mode
fmi2_continuousTime_mode
we don't set the time which leads to an uninitialized time value for other solving modes, i guess during initialization.
Yes that true. See FMI 2 specs page 84.
comment:14 by , 10 years ago
What I mean is that fmi2SetTime_OMC links the time in our Model_FMU.mo wrapper and the time in the actual fmu. And you changed quite a lot in the way the Model_FMU.mo wrapper is generated and I think that affects the way fmi2SetTime_OMC is called.
I suggest you try to use the previous way you generated the wrapper model with an algorithm section, not equation section and see if that fixes the issue. Of course you should keep the other fixes.
comment:15 by , 10 years ago
The failing tests are fixed in r25236.
I am keeping this ticket open because the difference between Windows - Linux is still there. For example, try running the /testsuite/openmodelica/fmi/ModelExchange/2.0/testAssert.mos
comment:16 by , 10 years ago
Milestone: | Future → 1.9.3 |
---|---|
Resolution: | → fixed |
Status: | accepted → closed |
Fixed in r25599.
There are some issues with uninitialized values used in zero crossings.
I'll see if I can find out where this originates from.