Opened 11 years ago
Last modified 7 years ago
#2599 new defect
Handling of (tuple) = f(...) when solving non-linear — at Version 4
Reported by: | Willi Braun | Owned by: | probably noone |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Backend | Version: | trunk |
Keywords: | Cc: |
Description (last modified by )
Examples like following were handled wrong in SimCodeUtil:
model TupleNonLinear function ftest input Real a; output Real b; output Integer c; algorithm b := 0; for i in {1} loop //prevent inlining b := b + sin(a); c := integer(a); end for; end ftest; Real a; Integer c; Real x,z; equation der(x) = sin(a + time); (x,c) = ftest(a); z = if c>=1 then 10 else 0; annotation (experiment(StopTime=2)); end TupleNonLinear;
We try to solve the equation
(x,c) = ftest(a) non-linear for
{a,c} but actually only a should be solved
non-linear and c can be calculated then directly.
Change History (4)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Yes, the code we would produce is wrong, since for all
non-linear systems we assume that the iteration variables
are Real and not Integer.
follow-up: 4 comment:3 by , 11 years ago
Are you actually allowed to output both a continuous-time and discrete-time expression for the same equation?
Spec 3.8.3 says:
For an equation expr1 = expr2 where neither expression is of base type Real, both expressions must be discrete-time expressions.
Exceptions are only made for records.
comment:4 by , 11 years ago
Description: | modified (diff) |
---|
Replying to sjoelund.se:
Are you actually allowed to output both a continuous-time and discrete-time expression for the same equation?
Spec 3.8.3 says:
For an equation expr1 = expr2 where neither expression is of base type Real, both expressions must be discrete-time expressions.
Exceptions are only made for records.
That's a really good remark.
I changed the model a bit, so that the mode
has a discrete change of c while the
continues integration.
So I think you are right we need to handle
that whole equation as discrete.
Replying to wbraun:
Why? That is actually not an error. I think it is good enough to solve it non-linear.
Anyway, the model gets handled wrong. I changed the model a bit, so that OpenModelica produces wrong results: