Opened 15 years ago
Last modified 7 years ago
#1211 assigned defect
Nested der-expressions generates invalid simulation code
Reported by: | Per Östlund | Owned by: | somebody |
---|---|---|---|
Priority: | normal | Milestone: | Future |
Component: | Backend | Version: | trunk |
Keywords: | Cc: | Lennart Ochel, Willi Braun, Martin Sjölund |
Description
Nested der-expressions seems to cause Exp.solve to fail, which causes generation of simulation code that doesn't compile. Example model:
class MyRealEquation Real x(start=0); equation 100 - 20*der(x) + der(x)*der(x) = 40*der(der(x)); end MyRealEquation;
Change History (5)
comment:1 by , 10 years ago
Cc: | added; removed |
---|---|
Component: | → Backend |
Milestone: | → Future |
Version: | → trunk |
comment:2 by , 10 years ago
It should be possible to handle this (compile it), but not without getting a warning that some introduced dummy variable der_x not having specified initial conditions.
comment:3 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | accepted → assigned |
comment:4 by , 7 years ago
Just another note: if you change der(der(x))
to something like der(x*der(x))
the nested der
is not detected, i.e. the internal error is not raised. Compilation, of course, still fails.
comment:5 by , 7 years ago
Cc: | added |
---|
Changing BackendDAEOptimize.expandDerExp
to use match
instead of matchcontinue
makes omc stop compilation at this error, but I cannot estimate the impact on other working models. Shall I create a PR?
Still an issue, although the compiler now gives an internal error saying that derivates of order > 1 is unsupported. It still continues to generate simulation code though, which of course does not compile. Dymola doesn't support derivates of order > 1 either, so it's probably fine to not support it. Maybe it's not even allowed in Modelica, I don't know. But the compiler should show a proper error in that case, and stop the compilation.