﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4419	Bug in simplification of rem() or div()	Henning Kiel	Lennart Ochel	"These two models behave wrong (and even differently):
{{{
model test1
  Real x(start=0,fixed=true);
  Real y1,y2;
equation
  der(x)=10;
  y1 = rem(x,2);
  y2 = rem(x+1,2);
end test1;
}}}
{{{
model test2
  Real x(start=0,fixed=true);
  Real y2;
equation
  der(x)=10;
  y2 = rem(x+1,2);
end test2;
}}}

Model test1 shows sawtooth, but not in the correct value range of 0..2, but in 1..3 for {{{y2}}}.

Model test2 does not show any sawtooth for {{{y2}}}, it is just plain ramp {{{x+1}}}.


Also the flattened code is not valid Modelica {{{x + -2.0}}}
{{{instantiateModel(test1)}}}
{{{
""class test1
  Real x(start = 0.0, fixed = true);
  Real y1;
  Real y2;
equation
  der(x) = 10.0;
  y1 = x + -2.0 * div(x, 2.0);
  y2 = 1.0 + x + -2.0 * div(1.0 + x, 2.0);
end test1;
""
}}}

I think that simplification does wrong things. The (syntactically fixed) model from instantiateModel(test1) is also simulated wrong, so maybe the problem lies within {{{div}}} simplifications."	defect	closed	blocker	1.12.0	Code Generation	v1.12.0	fixed		Martin Sjölund Adrian Pop Francesco Casella
