From 9b7bc898075e02e5dd6f4adaa525ec527396e142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Fri, 15 Dec 2017 21:22:33 +0100 Subject: [PATCH] solveSimpleEquations: Only update eq if solved This avoids a bug where solveSimpleEquations removes the variable it tries to solve for. --- Compiler/BackEnd/ExpressionSolve.mo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Compiler/BackEnd/ExpressionSolve.mo b/Compiler/BackEnd/ExpressionSolve.mo index 137fa1b414..d963aa62c6 100644 --- a/Compiler/BackEnd/ExpressionSolve.mo +++ b/Compiler/BackEnd/ExpressionSolve.mo @@ -91,9 +91,9 @@ DAE.eqs := list( (match syst tmpComp := comp; if BackendEquation.isEquation(eqn) then (eqn,solved) := solveSimpleEquationsWork(eqn, var, DAE.shared); - syst.orderedEqs := BackendEquation.setAtIndex(syst.orderedEqs, eindex, eqn); - - if not solved then + if solved then + syst.orderedEqs := BackendEquation.setAtIndex(syst.orderedEqs, eindex, eqn); + else tmpComp := BackendDAE.EQUATIONSYSTEM({eindex}, {vindx}, BackendDAE.EMPTY_JACOBIAN() ,BackendDAE.JAC_NONLINEAR(), false); end if; end if; // isEquation