@@ -2483,7 +2483,7 @@ algorithm
24832483 BackendDAE . Var tmpVar;
24842484 BackendDAE . Variables diffVars, ovars, resVars;
24852485 list< BackendDAE . Equation > reqns, otherEqnsLst;
2486- BackendDAE . EquationArray eqns, oeqns;
2486+ BackendDAE . EquationArray eqns, oeqns, resEqns ;
24872487
24882488 BackendDAE . Jacobian jacobian,jacobianCausal;
24892489
@@ -2534,20 +2534,25 @@ algorithm
25342534 onlySparsePattern = false ;
25352535 end if ;
25362536
2537- eqns = BackendEquation . listEquation(reqns);
2538- // create residual equations
2539- reqns = BackendEquation . traverseEquationArray(eqns, BackendEquation . traverseEquationToScalarResidualForm, {});
2540- reqns = listReverse(reqns);
2541- (reqns, resVarsLst) = BackendEquation . convertResidualsIntoSolvedEquations(reqns, "$res" , BackendVariable . makeVar(DAE . emptyCref), 1 );
2542- resVars = BackendVariable . listVar1(resVarsLst);
2543- eqns = BackendEquation . listEquation(reqns);
2537+ if (not onlySparsePattern) then
2538+ eqns = BackendEquation . listEquation(reqns);
2539+ // create residual equations
2540+ reqns = BackendEquation . traverseEquationArray(eqns, BackendEquation . traverseEquationToScalarResidualForm, {});
2541+ reqns = listReverse(reqns);
2542+ (reqns, resVarsLst) = BackendEquation . convertResidualsIntoSolvedEquations(reqns, "$res" , BackendVariable . makeVar(DAE . emptyCref), 1 );
2543+ resVars = BackendVariable . listVar1(resVarsLst);
2544+ resEqns = BackendEquation . listEquation(reqns);
2545+ else
2546+ resVars = diffVars;
2547+ resEqns = BackendEquation . listEquation(reqns);
2548+ end if ;
25442549
25452550 // other eqns and vars are empty
25462551 oeqns = BackendEquation . listEquation({});
25472552 ovars = BackendVariable . emptyVars();
25482553
25492554 // generate generic jacobian backend dae
2550- (jacobian, shared ) = getSymbolicJacobian(diffVars, eqns , resVars, oeqns, ovars, inShared, inVars, name, onlySparsePattern);
2555+ (jacobian, shared ) = getSymbolicJacobian(diffVars, resEqns , resVars, oeqns, ovars, inShared, inVars, name, onlySparsePattern);
25512556
25522557 then (BackendDAE . EQUATIONSYSTEM (residualequations, iterationvarsInts, jacobian, BackendDAE . JAC_GENERIC (), mixedSystem), shared );
25532558
0 commit comments