Opened 11 years ago

Last modified 7 years ago

#2494 accepted defect

Derivative annotation handling broken — at Version 2

Reported by: Christoph Höger Owned by: Willi Braun
Priority: high Milestone: Future
Component: Code Generation Version: trunk
Keywords: Cc:

Description (last modified by Martin Sjölund)

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 (2)

comment:1 by Christoph Höger, 11 years ago

Weird copy and paste behavior by emacs, pasting menu bars, but leaving out the annotations. The annotations are:

annotation(derivative=equation1_der2);

and

annotation(derivative(order=2)=equation1_der1);

respectively.

comment:2 by Martin Sjölund, 11 years ago

Description: modified (diff)
Owner: changed from Lennart Ochel to Willi Braun
Status: newassigned

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
Note: See TracTickets for help on using tickets.