﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3497	Wrong initial system for clocked equations	Rüdiger Franke	Lennart Ochel	"Consider the following synchronous discrete-time model
{{{#!mo
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;
}}}
OpenModelica adds the clocked equation to the initial equations and solves it. See: `omc -s -d=dumpSimCode SID.mo`
{{{
initialEquations: (4)
-----------------------
1: xd=y_start[Real ]
2: $PRE.xd=xd + -0.1 * p * u[Real ]
3: $var1=$PRE.xd[Real ]
4: y=$getPart($var1)[Real ]
}}}
This is wrong because the clock does not tick during initialization. Equations 2 and 3 should read:
{{{
2: $CLKPRE.xd=xd[Real ]
3: $var1=$CLKPRE.xd[Real ]
}}}"	defect	closed	high	1.9.4	Backend		fixed		
