Skip to content

Commit 9e6d93d

Browse files
author
vruge
committed
ExpressionSolve: added additional for symEuler(dt == 0)
1 parent 29cd04e commit 9e6d93d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Compiler/BackEnd/ExpressionSolve.mo

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ algorithm
319319
then fail();
320320
end matchcontinue;
321321

322+
outExp := symEuler_helper(outExp, inExp3);
322323
(outExp,_) := ExpressionSimplify.simplify1(outExp);
323324

324325
end solve2;
@@ -651,6 +652,7 @@ preprocessing for solve1,
651652

652653
// h(x) = k(y)
653654
(h,_) := ExpressionSimplify.simplify(x);
655+
654656
/*
655657
if not Expression.expEqual(inExp1,h) then
656658
print("\nIn: ");print(ExpressionDump.printExpStr(inExp1));print(" = ");print(ExpressionDump.printExpStr(inExp2));
@@ -660,6 +662,32 @@ preprocessing for solve1,
660662
*/
661663
end preprocessingSolve;
662664

665+
protected function symEuler_helper
666+
"
667+
special case for symEuler
668+
"
669+
input DAE.Exp rhs;
670+
input DAE.Exp X;
671+
output DAE.Exp orhs = rhs;
672+
protected
673+
DAE.Type tp;
674+
DAE.Exp dt;
675+
algorithm
676+
if Flags.getConfigBool(Flags.SYM_EULER) then
677+
dt := Expression.crefExp(ComponentReference.makeCrefIdent("$TMP$OMC$DT", DAE.T_REAL_DEFAULT, {}));
678+
if expHasCref(rhs, dt) then
679+
// x = dt != 0 ? k1(y,dt) : old_x
680+
tp := Expression.typeof(X);
681+
orhs := DAE.IFEXP(Expression.makeNoEvent(DAE.RELATION(
682+
dt,
683+
DAE.EQUAL(tp),
684+
DAE.RCONST(0.0),-1,NONE())),
685+
Expression.makePureBuiltinCall("$_old", {X}, tp), rhs);
686+
end if;
687+
end if;
688+
689+
end symEuler_helper;
690+
663691
protected function preprocessingSolve2
664692
"
665693
helprer function for preprocessingSolve

0 commit comments

Comments
 (0)