@@ -1068,7 +1068,7 @@ protected
10681068 Integer maxDelayedExpIndex;
10691069 Integer uniqueEqIndex = 1 ;
10701070 Integer nStates;
1071- Integer numberofEqns, numStateSets, numberofLinearSys, numberofNonLinearSys,
1071+ Integer numberofEqns, numberofLinearSys, numberofNonLinearSys,
10721072 numberofMixedSys, numberOfJacobians, numberofFixedParameters;
10731073 Boolean tmpB;
10741074
@@ -1086,9 +1086,9 @@ protected
10861086 Option < SimCode . JacobianMatrix > daeModeSP;
10871087 Option < SimCode . DaeModeData > daeModeData;
10881088 SimCode . DaeModeConfig daeModeConf;
1089- list< SimCode . SimEqSystem > daeEquations, removedEquations;
1089+
1090+ list< list< SimCode . SimEqSystem >> daeEquations;
10901091 list< SimCodeVar . SimVar > residualVars, algebraicStateVars, auxiliaryVars;
1091- list< SimCode . StateSet > stateSets;
10921092
10931093 tuple< Option < BackendDAE . SymbolicJacobian > , BackendDAE . SparsePattern , BackendDAE . SparseColoring > daeModeJac;
10941094 SimCode . JacobianMatrix symDAESparsPattern;
@@ -1155,19 +1155,8 @@ algorithm
11551155
11561156 discreteModelVars := BackendDAEUtil . foldEqSystem(inBackendDAE, SimCodeUtil . extractDiscreteModelVars, {});
11571157
1158- // prepare DAEmode stuff
1159- eqnsLst := BackendEquation . equationSystemsEqnsLst(inBackendDAE. eqs);
1160- varsLst := BackendVariable . equationSystemsVarsLst(inBackendDAE. eqs);
1161- daeVars := BackendVariable . listVar(varsLst);
1162- daeEqns := BackendEquation . listEquation(eqnsLst);
1163- // create SimCode residual equation
1164- (daeEquations, uniqueEqIndex, tempVars) := SimCodeUtil . createEquationsfromList(listReverse(eqnsLst), varsLst, uniqueEqIndex, tempVars, inBackendDAE. shared . info, true , true );
1165-
1166- (uniqueEqIndex, removedEquations) := BackendEquation . traverseEquationArray(BackendDAEUtil . collapseRemovedEqs(inBackendDAE), SimCodeUtil . traversedlowEqToSimEqSystem, (uniqueEqIndex, {}));
1167- daeEquations := listAppend(daeEquations, removedEquations);
1168- // state set stuff
1169- (_, stateSets, uniqueEqIndex, tempVars, numStateSets) := SimCodeUtil . createStateSets(inBackendDAE, {}, uniqueEqIndex, tempVars);
1170- if debug then ExecStat . execStat("simCode: createStateSets" ); end if ;
1158+ // create DAEmode equations
1159+ (daeEquations, uniqueEqIndex, tempVars) := SimCodeUtil . createEquationsfromBackendDAE(inBackendDAE, uniqueEqIndex, tempVars, true , true );
11711160
11721161 // create model info
11731162 // create dummy system where all original variables are created
@@ -1177,14 +1166,12 @@ algorithm
11771166 // disable start value calculation, it's only helpful in case of algebraic loops
11781167 // and they are not present in DAEmode
11791168 tmpB := Flags . set(Flags . NO_START_CALC , true );
1180- modelInfo := SimCodeUtil . createModelInfo(className, p, emptyBDAE, inInitDAE, functions, {}, numStateSets , fileDir, 0 , tempVars);
1169+ modelInfo := SimCodeUtil . createModelInfo(className, p, emptyBDAE, inInitDAE, functions, {}, 0 , fileDir, 0 , tempVars);
11811170 Flags . set(Flags . NO_START_CALC , tmpB);
11821171
11831172 // create hash table
11841173 crefToSimVarHT := SimCodeUtil . createCrefToSimVarHT(modelInfo);
11851174
1186- // collect symbolic jacobians from state selection
1187- (stateSets, modelInfo, SymbolicJacsStateSelect ) := SimCodeUtil . addAlgebraicLoopsModelInfoStateSets(stateSets, modelInfo);
11881175 // collect symbolic jacobians in initialization loops of the overall jacobians
11891176 SymbolicJacsNLS := {};
11901177 (initialEquations, modelInfo, SymbolicJacsTemp ) := SimCodeUtil . addAlgebraicLoopsModelInfo(initialEquations, modelInfo);
@@ -1193,7 +1180,7 @@ algorithm
11931180 SymbolicJacsNLS := listAppend(SymbolicJacsTemp , SymbolicJacsNLS );
11941181 (symJacs, uniqueEqIndex) := SimCodeUtil . createSymbolicJacobianssSimCode({}, crefToSimVarHT, uniqueEqIndex, {"A" , "B" , "C" , "D" }, {});
11951182 (SymbolicJacs , modelInfo, SymbolicJacsTemp ) := SimCodeUtil . addAlgebraicLoopsModelInfoSymJacs(symJacs, modelInfo);
1196- SymbolicJacs : = listAppend( SymbolicJacs , SymbolicJacsStateSelect );
1183+
11971184 // collect jacobian equation only for equantion info file
11981185 jacobianEquations := SimCodeUtil . collectAllJacobianEquations(SymbolicJacs );
11991186 if debug then ExecStat . execStat("simCode: create Jacobian linear code" ); end if ;
@@ -1205,8 +1192,10 @@ algorithm
12051192 seedVars := SimCodeUtil . collectAllSeedVars(SymbolicJacs );
12061193 modelInfo := SimCodeUtil . setSeedVars(seedVars, modelInfo);
12071194
1208-
12091195 // create dae SimVars: residual and algebraic
1196+ varsLst := BackendVariable . equationSystemsVarsLst(inBackendDAE. eqs);
1197+ daeVars := BackendVariable . listVar(varsLst);
1198+
12101199 // create residual variables, set index and push them SimCode HashTable
12111200 ((_, resVars)) := BackendVariable . traverseBackendDAEVars(daeVars, BackendVariable . collectVarKindVarinVariables, (BackendVariable . isDAEmodeResVar, BackendVariable . emptyVars()));
12121201 ((residualVars, _)) := BackendVariable . traverseBackendDAEVars(resVars, SimCodeUtil . traversingdlowvarToSimvar, ({}, BackendVariable . emptyVars()));
@@ -1237,7 +1226,7 @@ algorithm
12371226 ({symDAESparsPattern}, uniqueEqIndex) := SimCodeUtil . createSymbolicJacobianssSimCode({daeModeJac}, crefToSimVarHT, uniqueEqIndex, {"daeMode" }, {});
12381227 daeModeSP := SOME (symDAESparsPattern);
12391228 daeModeConf := SimCode . ALL_EQUATIONS ();
1240- daeModeData := SOME (SimCode . DAEMODEDATA ({ daeEquations} , daeModeSP, residualVars, algebraicStateVars, auxiliaryVars, daeModeConf));
1229+ daeModeData := SOME (SimCode . DAEMODEDATA (daeEquations, daeModeSP, residualVars, algebraicStateVars, auxiliaryVars, daeModeConf));
12411230
12421231 /* This is a *much* better estimate than the guessed number of equations */
12431232 modelInfo := SimCodeUtil . addNumEqns(modelInfo, uniqueEqIndex- listLength(jacobianEquations));
@@ -1262,11 +1251,11 @@ algorithm
12621251 minValueEquations,
12631252 maxValueEquations,
12641253 parameterEquations,
1265- removedEquations,
12661254 {},
12671255 {},
12681256 {},
1269- stateSets,
1257+ {},
1258+ {},
12701259 {},
12711260 {},
12721261 zeroCrossings,
0 commit comments