Opened 9 years ago

Last modified 9 years ago

#3770 closed defect

event clocks error — at Version 2

Reported by: Niklas Worschech Owned by: Lennart Ochel
Priority: blocker Milestone: Future
Component: Backend Version:
Keywords: Modelica_Synchronous, synchronous features, cpp runtime Cc: Rüdiger Franke, Bernhard Thiele, Volker Waurich, Martin.Otter@…

Description (last modified by Lennart Ochel)

For the following model from the cpp runtime tests suite, it appears a wrong clock equation is generated.

model SolverMethod "Continuous PI controller in a clocked partition;
  see Modelica 3.3 spec, section 16.8.3 Associating a Solver to a Partition"
  parameter Real Ti = 200/1000, k = 2;
  parameter Real ref = 1;
  Real x(start = 0, fixed = true);
  Real xd(start = 0);
  Real vd, e, u;
equation
  // controller
  vd = sample(x, Clock(Clock(50,1000), solverMethod = "ImplicitEuler"));
  e = ref-vd;
  der(xd) = e/Ti;
  u = k*(e + xd);
  // physical model
  0.2*der(x) = hold(u);
end SolverMethod;

For the variable xd this equation is generated:

xd = DIVISION(e, Ti) * interval() + previous(xd)

I think this equation is not correct, because xd starts with an incorrect value. It starts with 0.25 but it should start with 0

Change History (2)

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

See ModelicaSpec33, section 16.4 Discrete States: "The previous value of a clocked variable can be accessed with the previous operator. Such a variable is called a clocked state variable."

previous(xd) starts at 0

comment:2 by Lennart Ochel, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.