Skip to content

Commit

Permalink
- BackendDAETransform.mo
Browse files Browse the repository at this point in the history
  - add BackendDump.
Derive.mo
  - add derivative of atan2

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7202 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Nov 26, 2010
1 parent 3de1383 commit 0a27d7e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackendDAETransform.mo
Expand Up @@ -1223,9 +1223,9 @@ algorithm
dae = makeAlgebraic(dae, state);
(m,mt) = BackendDAEUtil.updateIncidenceMatrix(dae, m, mt, changedeqns);
// print("new DAE:");
// dump(dae);
// BackendDump.dump(dae);
// print("new IM:");
// dumpIncidenceMatrix(m);
// BackendDump.dumpIncidenceMatrix(m);
then
(dae,m,mt,derivedAlgs1,derivedMultiEqn1);

Expand Down
38 changes: 38 additions & 0 deletions Compiler/Derive.mo
Expand Up @@ -413,6 +413,24 @@ algorithm
then
DAE.BINARY(e_1,DAE.DIV(DAE.ET_REAL()),DAE.BINARY(DAE.RCONST(1.0),DAE.ADD(DAE.ET_REAL()),DAE.BINARY(e,DAE.MUL(DAE.ET_REAL()),e)));

// der(arctan2(y,0)) = sign(y)
case (DAE.CALL(path = fname,expLst = {e,e1}),(timevars,functions))
equation
Builtin.isATan2(fname);
true = Expression.isZero(e1);
then
DAE.CALL(Absyn.IDENT("sign"),{e},false,true,DAE.ET_INT(),DAE.NO_INLINE());

// der(arctan2(y,x)) = der(y/x)/1+x^2
case (DAE.CALL(path = fname,expLst = {e,e1}),(timevars,functions))
equation
Builtin.isATan2(fname);
false = Expression.isZero(e1);
exp = Expression.makeDiv(e,e1);
e_1 = differentiateExpTime(exp, (timevars,functions));
then
e_1;

case (DAE.CALL(path = fname,expLst = {e}),(timevars,functions))
equation
Builtin.isExp(fname);
Expand Down Expand Up @@ -1397,6 +1415,26 @@ algorithm
then
DAE.BINARY(e_1,DAE.DIV(DAE.ET_REAL()),DAE.BINARY(DAE.RCONST(1.0),DAE.ADD(DAE.ET_REAL()),DAE.BINARY(e,DAE.MUL(DAE.ET_REAL()),e)));

// der(arctan2(y,0)) = sign(y)
case (DAE.CALL(path = fname,expLst = {e,e1}),tv,differentiateIfExp)
equation
Builtin.isATan2(fname);
true = Expression.expContains(e, DAE.CREF(tv,DAE.ET_REAL()));
true = Expression.isZero(e1);
then
DAE.CALL(Absyn.IDENT("sign"),{e},false,true,DAE.ET_INT(),DAE.NO_INLINE());

// der(arctan2(y,x)) = der(y/x)/1+x^2
case (DAE.CALL(path = fname,expLst = {e,e1}),tv,differentiateIfExp)
equation
Builtin.isATan2(fname);
true = Expression.expContains(e, DAE.CREF(tv,DAE.ET_REAL()));
false = Expression.isZero(e1);
exp = Expression.makeDiv(e,e1);
e_1 = differentiateExp(exp, tv,differentiateIfExp) ;
then
e_1;

case (DAE.CALL(path = fname,expLst = (exp :: {}),tuple_ = b,builtin = c,ty=tp,inlineType=inl),tv,differentiateIfExp)
equation
Builtin.isExp(fname) "exp(x) => x\' exp(x)" ;
Expand Down

0 comments on commit 0a27d7e

Please sign in to comment.