Opened 9 years ago

Last modified 7 years ago

#3498 reopened defect

Wrong generation of base partitions

Reported by: Rüdiger Franke Owned by: Lennart Ochel
Priority: high Milestone: Future
Component: Backend Version:
Keywords: Cpp run-time Cc:

Description

The code generated for the following model does not compile due to the attempt to access the not existing previous(dt).

model SID "Single Integrator Discrete-time"
  parameter Real dt = 0.1 "sample time" annotation(Evaluate=true);
  parameter Real p = 1 "gain for input";
  parameter Real y_start = 0 "start value for state";
  Real xd(start = y_start);
  input Real u(start = -2);
  output Real y;
equation
  when Clock(dt) then
    xd = previous(xd) + p * u * dt;
  end when;
  y = hold(previous(xd));
end SID;

The sample rate dt should be constant. Instead omc -s -d=dumpSynchronous SID.mo gives

Base clocks (1)
========================================
1: Clock(previous(dt))[1]

Change History (14)

comment:1 by Lennart Ochel, 9 years ago

Owner: changed from somebody to Lennart Ochel
Status: newassigned

comment:2 by Lennart Ochel, 9 years ago

see also #3482

comment:3 by Lennart Ochel, 9 years ago

Status: assignedaccepted

comment:4 by Lennart Ochel, 9 years ago

The example is now compiling. Can one check if the results are correct?

comment:5 by Lennart Ochel, 9 years ago

Please note: I didn't touched the evaluation of dt. The generated base clock is now defined as follows:

Base partitions (1)
========================================
1: Clock(dt)[1]

comment:6 by Lennart Ochel, 9 years ago

The results seem to be wrong for the c runtime since xd is zero.
The results are correct for the Cpp runtime.

Last edited 9 years ago by Lennart Ochel (previous) (diff)

comment:7 by Rüdiger Franke, 9 years ago

That's as expected. Thank you!

comment:8 by Lennart Ochel, 9 years ago

Keywords: Cpp run-time added
Resolution: fixed
Status: acceptedclosed
Summary: Wrong sim code due to ignored annotation(Evaluate=true)Wrong generation of base partitions

comment:9 by Rüdiger Franke, 9 years ago

Resolution: fixed
Status: closedreopened

The clock parameter is not evaluated -- see initial title of this ticket. Take the example:

https://github.com/OpenModelica/OpenModelica-testsuite/commit/68309ab43da673674cb9a89bccc6e3d8f83c066e

The test declares dt constant. The clock interval must not disappear from modelDescription.xml if changed to a parameter with annotation(Evaluate=true) -- the generation of modelDescription.xml expects an RCONST.

Last edited 9 years ago by Rüdiger Franke (previous) (diff)

comment:10 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:11 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:12 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:13 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:14 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

The milestone of this ticket has been reassigned to "Future".

If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.

If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".

In both cases, a short informative comment would be welcome.

Note: See TracTickets for help on using tickets.