modelica / Reference-FMUs

Functional Mock-up Units for development, testing and debugging
Other
145 stars 60 forks source link

fmusim calls fmi2SetXXX before initialization for causality = "input" #511

Closed hsilm closed 3 months ago

hsilm commented 4 months ago

According to the Functional Mock-up Interface 2.0.4 standard page 50, fmi2SetXXX for causality = "input" can be called during initialization (after calling fmi2EnterInitializationMode) but not before.

However, in fmusim the inputs are applied before, e.g. or ME: https://github.com/modelica/Reference-FMUs/blob/18adfad01bd939b388313c83c0465c84c11febac/fmusim/fmusim_fmi2_me.c#L49C1-L76C45

t-sommer commented 3 months ago

Can you share an FMU to reproduce the problem?

hsilm commented 3 months ago

From the Reference-FMUs it is Feedthrough.fmu which has an input. To see the problem, a minimal input file has to be given, in this case for example

,"Float64_continuous_input",
,

and using --log-fmi-calls it shows

fmi2Instantiate(instanceName="instance1", fmuType=1, fmuGUID="{37B954F1-CC86-4D8F-B97F-C7C36F6670D2}", fmuResourceLocation="file:///C:/Users/XXX/AppData/Local/Temp/19/resources/", functions={logger=0x00007FF675975270, allocateMemory=0x00007FF675A891FC, freeMemory=0x00007FF675A89204, stepFinished=0x0000000000000000, componentEnvironment=0x000001E5D817E860}, visible=0, loggingOn=0) -> OK
fmi2SetReal(vr={7}, nvr=1, value={6.301562774380001e-310}) -> OK
fmi2SetupExperiment(toleranceDefined=0, tolerance=0, startTime=0, stopTimeDefined=0, stopTime=0) -> OK
fmi2EnterInitializationMode() -> OK
fmi2ExitInitializationMode() -> OK