@@ -6368,29 +6368,29 @@ protected function createInitialEquations "author: lochel"
63686368 output list<SimCodeVar.SimVar> otempvars := itempvars;
63696369 output Boolean useSymbolicInitialization := false;
63706370protected
6371- BackendDAE.EquationArray removedEqs;
6372- list<SimCodeVar.SimVar> tempvars;
6373- Integer uniqueEqIndex;
6371+ BackendDAE.EquationArray removedEqs;
6372+ list<SimCodeVar.SimVar> tempvars;
6373+ Integer uniqueEqIndex;
63746374 list<SimCode.SimEqSystem> allEquations, solvedEquations, removedEquations, aliasEquations, removedInitialEquations;
6375- BackendDAE.EqSystems systs;
6376- BackendDAE.Shared shared;
6377- BackendDAE.Variables knvars, aliasVars;
6375+ BackendDAE.EqSystems systs;
6376+ BackendDAE.Shared shared;
6377+ BackendDAE.Variables knvars, aliasVars;
63786378algorithm
63796379 try
63806380 SOME(BackendDAE.DAE(systs, shared as BackendDAE.SHARED(knownVars=knvars, aliasVars=aliasVars, removedEqs=removedEqs))) := inInitDAE;
6381- // generate equations from the known unfixed variables
6381+ // generate equations from the known unfixed variables
63826382 ((uniqueEqIndex, allEquations)) := BackendVariable.traverseBackendDAEVars(knvars, traverseKnVarsToSimEqSystem, (iuniqueEqIndex, {}));
6383- // generate equations from the solved systems
6383+ // generate equations from the solved systems
63846384 (uniqueEqIndex, _, _, solvedEquations, _, tempvars, _, _, _) := createEquationsForSystems(systs, shared, uniqueEqIndex, {}, {}, {}, {}, {}, itempvars, 0, {}, {}, SimCode.NO_MAPPING());
63856385 allEquations := listAppend(allEquations, solvedEquations);
6386- // generate equations from the removed equations
6386+ // generate equations from the removed equations
63876387 ((uniqueEqIndex, removedEquations)) := BackendEquation.traverseEquationArray(removedEqs, traversedlowEqToSimEqSystem, (uniqueEqIndex, {}));
63886388 allEquations := listAppend(allEquations, removedEquations);
6389- // generate equations from the alias variables
6389+ // generate equations from the alias variables
63906390 ((uniqueEqIndex, aliasEquations)) := BackendVariable.traverseBackendDAEVars(aliasVars, traverseAliasVarsToSimEqSystem, (uniqueEqIndex, {}));
63916391 allEquations := listAppend(allEquations, aliasEquations);
63926392
6393- // generate equations from removed initial equations
6393+ // generate equations from removed initial equations
63946394 (removedInitialEquations, uniqueEqIndex, tempvars) := createNonlinearResidualEquations(inRemovedEqnLst, uniqueEqIndex, tempvars);
63956395
63966396 // output
@@ -6400,7 +6400,7 @@ algorithm
64006400 otempvars := tempvars;
64016401 useSymbolicInitialization := true;
64026402 else
6403- Error.addCompilerError("No system for the symbolic initialization was generated.");
6403+ Error.addCompilerError("No system for the symbolic initialization was generated.");
64046404 end try;
64056405end createInitialEquations;
64066406
@@ -6981,56 +6981,6 @@ algorithm
69816981 next, ny_string, np_string, na_string, 0, 0, 0, 0, numStateSets,0,numOptimizeConstraints, numOptimizeFinalConstraints);
69826982end createVarInfo;
69836983
6984- protected function setAdditionalStartValues"sets the start value for parameters without start value if there is binding that has one"
6985- input Integer varIdx;
6986- input BackendDAE.Variables knownVarsIn;
6987- output BackendDAE.Variables knownVarsOut;
6988- algorithm
6989- knownVarsOut := matchcontinue(varIdx,knownVarsIn)
6990- local
6991- BackendDAE.Variables knownVars;
6992- DAE.Exp bind;
6993- DAE.ComponentRef bindCref;
6994- BackendDAE.Var var;
6995- case(_,_)
6996- equation
6997- var = BackendVariable.getVarAt(knownVarsIn,varIdx);
6998- true = BackendVariable.isParam(var) and not BackendVariable.varHasStartValue(var);
6999- bind = BackendVariable.varBindExp(var);
7000- (bind,_) = Expression.traverseExp(bind,evaluateParameter,knownVarsIn);
7001- bind = ExpressionSimplify.simplify(bind);
7002- true = Expression.isConst(bind);
7003- var = BackendVariable.setVarStartValue(var,bind);
7004- knownVars = BackendVariable.setVarAt(knownVarsIn,varIdx,var);
7005- then knownVars;
7006- else
7007- knownVarsIn;
7008- end matchcontinue;
7009- end setAdditionalStartValues;
7010-
7011- protected function evaluateParameter"evaluates the crefs in an expression and if there is a constant parameter, replace it.
7012- author:Waurich TUD 2014-06"
7013- input DAE.Exp expIn;
7014- input BackendDAE.Variables knownVarsIn;
7015- output DAE.Exp expOut;
7016- output BackendDAE.Variables knownVarsOut;
7017- algorithm
7018- (expOut,knownVarsOut) := matchcontinue(expIn,knownVarsIn)
7019- local
7020- DAE.ComponentRef cref;
7021- DAE.Exp bindNom;
7022- BackendDAE.Var bindVar;
7023- case(DAE.CREF(componentRef=cref),_)
7024- equation
7025- ({bindVar},_) = BackendVariable.getVar(cref,knownVarsIn);
7026- bindNom = BackendVariable.varBindExp(bindVar);
7027- true = Expression.isConst(bindNom);
7028- then (bindNom,knownVarsIn);
7029- else
7030- then(expIn,knownVarsIn);
7031- end matchcontinue;
7032- end evaluateParameter;
7033-
70346984protected function createVars
70356985 input BackendDAE.BackendDAE dlow;
70366986 output SimCodeVar.SimVars outVars;
@@ -7042,8 +6992,6 @@ protected
70426992algorithm
70436993 BackendDAE.DAE(eqs=systs, shared=BackendDAE.SHARED(knownVars=knvars, externalObjects=extvars, aliasVars=aliasVars)) := dlow;
70446994
7045- knvars := List.fold(List.intRange(BackendVariable.varsSize(knvars)),setAdditionalStartValues,knvars);
7046-
70476995 /* Extract from variable list */
70486996 ((outVars, _, _)) := List.fold1(List.map(systs, BackendVariable.daeVars), BackendVariable.traverseBackendDAEVars, extractVarsFromList, (SimCodeVar.emptySimVars, aliasVars, knvars));
70496997
@@ -7579,9 +7527,14 @@ algorithm
75797527 s = s+"\tdiscEqs:\n\t"+stringDelimitList(List.map(eqs,dumpSimEqSystem),"\t\n");
75807528 then (s);
75817529
7582- case(SimCode.SES_WHEN(index=idx))
7530+ case(SimCode.SES_WHEN(index=idx, conditions=crefs, left=left, right=right, elseWhen=elseWhen ))
75837531 equation
7584- s = intString(idx) +": "+ " (WHEN)";
7532+ s = intString(idx) +": "+ " WHEN:( ";
7533+ s = s + stringDelimitList(List.map(crefs,ComponentReference.debugPrintComponentRefTypeStr),", ") + " ) then: ";
7534+ s = s + ComponentReference.debugPrintComponentRefTypeStr(left) + " = " + ExpressionDump.printExpStr(right);
7535+ if Util.isSome(elseWhen) then
7536+ s = s + " ELSEWHEN: " + dumpSimEqSystem(Util.getOption(elseWhen));
7537+ end if;
75857538 then (s);
75867539 end match;
75877540end dumpSimEqSystem;
0 commit comments