Skip to content

Commit

Permalink
- do a bit more simplification
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5008 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Feb 19, 2010
1 parent 43e852c commit 1e41eb2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
24 changes: 22 additions & 2 deletions Compiler/DAELow.mo
Expand Up @@ -16362,8 +16362,27 @@ end findDelaySubExpressions;
public function checkEquationBecomesZero
" function checkEquationBecomesZero
autor: Frenkel TUD
check if a division by zero occurd
because of solving equations"
Check if a division by zero occurs
because of solving the equation.
The main goal is to support the user with as much
information about equations that cannot be solved
because of division by zero. Therefore the expressions of
the equation which reside below the slash have to be
inspect. The analysis is separated in to
- expressions which always be zero ( a-b, with a==b)
--> only constants and constant variables
--> ErrorMsg during compilation
- expressions which constant during simulation but depend
on parameters and bound parameters.
--> constants and parameters
--> check after parameter adjustment but before
calculation (c_runtime error msg)
- expressions which become during simulation equal zero
--> constants, parameters, time dependent variables
--> WarningMsg during compilation and the possibility
(maybe with flag inside c_runtime) to use the division
macro from c_runtime for those equations
(therefore we need maybe a new API commant \"compileModel\")"
input tuple<Equation, list<DAE.Exp>> inEqns;
input DAELow indlow;
output DAELow outdlow;
Expand All @@ -16378,6 +16397,7 @@ algorithm
equation
print(Exp.printExp2Str(exp));
print("\n");
// first seperated the expressions
outdlow = checkEquationBecomesZero((eqn,explst),indlow);
then
outdlow;
Expand Down
5 changes: 3 additions & 2 deletions Compiler/Exp.mo
Expand Up @@ -2495,7 +2495,7 @@ algorithm
matchcontinue (inExp)
local
list<Exp> e_lst,e_lst_1,e1_lst,e2_lst,e2_lst_1;
Exp res,e,e1,e2;
Exp res,res1,e,e1,e2;
Type tp;
case ((e as DAE.BINARY(exp1 = e1,operator = DAE.MUL(ty = tp),exp2 = e2)))
equation
Expand All @@ -2512,8 +2512,9 @@ algorithm
e_lst = listAppend(e1_lst, e2_lst_1);
e_lst_1 = simplifyMul(e_lst);
res = makeProductLst(e_lst_1);
res1 = simplify1(res);
then
res;
res1;
case ((e as DAE.BINARY(exp1 = e1,operator = DAE.ADD(ty = tp),exp2 = e2)))
equation
e_lst = terms(e);
Expand Down

0 comments on commit 1e41eb2

Please sign in to comment.