#3549 closed defect (fixed)
Evaluation of Clock parameters
Reported by: | Rüdiger Franke | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | high | Milestone: | 1.9.4 |
Component: | Backend | Version: | |
Keywords: | Cc: | Lennart Ochel, Adrian Pop, Bernhard Thiele, Maksimov Doe |
Description
The following model has the evaluated parameter dt to parameterize its clock (see also Modelica_Synchronous):
model SID parameter Real dt = 0.1 annotation(Evaluate=true); Real x(start = 0); input Real u(start = 1); output Real y; equation when Clock(dt) then x = previous(x) + u * interval(u); y = previous(x); end when; end SID;
Exporting it as FMU with
translateModelFMU(SID, version="2.0");
gives the Clocks section:
<Clocks> <Clock><Triggered/></Clock> </Clocks>
Triggered is used because the value of dt
is not known during code generation. It should be known due to annotation(Evaluate=true). The correct Clocks section reads (e.g. replace parameter Real dt with constant):
<Clocks> <Clock><Periodic baseInterval="0.1" /></Clock> </Clocks>
How can the evaluated value of dt
be inquired during code generation?
Change History (9)
comment:1 by , 9 years ago
Cc: | added |
---|
comment:2 by , 9 years ago
comment:3 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
It seems that parameters get not replaced within the clocks, since they were introduces recently and the eval-module does not consider clocks yet.
comment:5 by , 9 years ago
Replying to rfranke:
gives the Clocks section:
<Clocks> <Clock><Triggered/></Clock> </Clocks>Triggered is used because the value of
dt
is not known during code generation. It should be known due to annotation(Evaluate=true). The correct Clocks section reads (e.g. replace parameter Real dt with constant):
<Clocks> <Clock><Periodic baseInterval="0.1" /></Clock> </Clocks>
Where do I find this information?
comment:6 by , 9 years ago
Replying to rfranke:
I guess you are experimenting with adding clock features to FMI 2.0 since Clocks
and DiscreteStates
are not elements of FMI 2.0?
comment:7 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Super. The change works. 8847a737b601ca36fe2bbe4ff070b8bb8d83e37a/OpenModelica-testsuite updates the respective test.
Find the proposed spec in FCP-001_Clocks:
The originating time events proposal had been under discussion since 2011. FCP-001 simplifies the original proposal (minimal extension to C API, no sub-clocks in the XML description). Moreover it attempts to make the extension forward compatible with FMI 2.0 and it combines time events with discrete states that had been removed shortly before the release of FMI 2.0, lacking test implementations.
By now we have test implementations in the exporting tool OpenModelica (+simCodeTarget=Cpp) and the importing tool HQP, besides the original Dymola test implementation. Hopefully this will bring us forward in the FMI standardization, because we really need such models in our applications.
Modelica was lacking behind other simulation technologies prior to Clocks -- FMI is lacking behind until today.
I think this should get already replaced in the back end.