Opened 11 years ago
Last modified 7 years ago
#2494 accepted defect
Derivative annotation handling broken
Reported by: | Christoph Höger | Owned by: | Willi Braun |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Code Generation | Version: | trunk |
Keywords: | Cc: |
Description (last modified by )
The following model does not compile with omc 1.9.0:
within ; model pendulumDer function equation1 input Real x; input Real y; output Real r = x^2 + y^2 - 1; annotation(...); end equation1; function equation1_der1 input Real x; input Real y; input Real dx; input Real dy; output Real r = 2*(x*dx + y*dy); annotation(...); end equation1_der1; function equation1_der2 input Real x; input Real y; input Real dx; input Real dy; input Real ddx; input Real ddy; output Real r = 2*(x * ddx + dx^2 + y * ddy + dy^2); end equation1_der2; Real x(start=0.1), y(start=-0.9, fixed=true), vx, vy, F; equation equation1(x, y) = 0; der(x) = vx; der(y) = vy; der(vx) = F*x; der(vy) = F*y - 9.81; end pendulumDer;
output:
2 choeger@gimli ~/test % make -f pendulumDer.makefile :( gcc -falign-functions -march=native -mfpmath=sse -fPIC -I"/usr/include/omc" -I. -L"/home/choeger/test" -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o pendulumDer.o pendulumDer.c pendulumDer.c: In function ‘eqFunction_2’: pendulumDer.c:1228:3: error: too many arguments to function ‘omc_pendulumDer_equation1__der2’ pendulumDer_functions.c:74:37: note: declared here pendulumDer.c:1237:3: error: too many arguments to function ‘omc_pendulumDer_equation1__der2’ pendulumDer_functions.c:74:37: note: declared here make: *** [pendulumDer.o] Error 1
Change History (12)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Description: | modified (diff) |
---|---|
Owner: | changed from | to
Status: | new → assigned |
The trunk version gives totally different errors, related to differentiation of functions from what I can tell (defining the same variable twice in the function prototype).
pendulumDer_functions.h:31: error: redefinition of parameter ‘_$funDERx’ pendulumDer_functions.h:31: note: previous definition of ‘_$funDERx’ was here pendulumDer_functions.h:31: error: redefinition of parameter ‘_$funDERy’ pendulumDer_functions.h:31: note: previous definition of ‘_$funDERy’ was here
comment:3 by , 11 years ago
Status: | assigned → accepted |
---|
Fixed code generation issue in r18526, but for some reasons the annotation aren't considered.
Will investigate further.
comment:4 by , 11 years ago
While we're at it. It seems that the noDerivative option from the annotation is being ignored as well. See for example Modelica.Mechanics.MultiBody.Frames.resolve2:
function resolve2 "Transform vector from frame 1 to frame 2" extends Modelica.Icons.Function; input Orientation R "Orientation object to rotate frame 1 into frame 2"; input Real v1[3] "Vector in frame 1"; output Real v2[3] "Vector in frame 2"; algorithm v2 := R.T*v1; annotation (derivative(noDerivative=R) = Internal.resolve2_der, InlineAfterIndexReduction=true); end resolve2;
The option noDerivative=R should prevent him from differentiating R. Nevertheless, R.T is being differentiated and becomes a dummy state for no reason.
This shouldn't break anything, but is very ineffective.
comment:5 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:6 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:11 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:12 by , 7 years ago
Milestone: | 1.12.0 → Future |
---|
The milestone of this ticket has been reassigned to "Future".
If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.
If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".
In both cases, a short informative comment would be welcome.
Weird copy and paste behavior by emacs, pasting menu bars, but leaving out the annotations. The annotations are:
and
respectively.