Skip to content

Commit

Permalink
Remove bad simlification e1/tanh(e2) --> e1*cosh(e1)/sinh(e2)
Browse files Browse the repository at this point in the history
This avoids two instead of one calls to builtin functions. It also
avoids potential numerical overflows for large values of e2 when sinh returns inf.
See: PowerSystems.Examples.AC3ph.Inverters.InverterToLoad
See also issue OpenModelica#8005.
  • Loading branch information
rfranke committed Oct 23, 2021
1 parent 8996052 commit fc4adba
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions OMCompiler/Compiler/FrontEnd/ExpressionSimplify.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4783,13 +4783,6 @@ algorithm
equation
true = Expression.expEqual(e1,e2);
then Expression.makePureBuiltinCall("tanh",{e1},ty);
// e1/tanh(e2) => e1*cos(e2)/sin(e2)
case(_,op2 as DAE.DIV(ty),e1,DAE.CALL(path=Absyn.IDENT("tanh"),expLst={e2}),_,_)
equation
e3 = Expression.makePureBuiltinCall("sinh",{e2},ty);
e4 = Expression.makePureBuiltinCall("cosh",{e2},ty);
e = DAE.BINARY(e4,op2,e3);
then DAE.BINARY(e1,DAE.MUL(ty), e);
// tanh(e2)/sinh(e2) => 1.0/cosh(e2)
case(_,op2 as DAE.DIV(ty),DAE.CALL(path=Absyn.IDENT("tanh"),expLst={e1}),DAE.CALL(path=Absyn.IDENT("sinh"),expLst={e2}),_,_)
equation
Expand Down

0 comments on commit fc4adba

Please sign in to comment.