Skip to content

Commit

Permalink
- switch to symbolic initialization
Browse files Browse the repository at this point in the history
- Bugfix dynamic state selection code generation, allocate enough memory

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14569 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Dec 29, 2012
1 parent 913366c commit 4b6c9f4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/Initialization.mo
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ algorithm
DAE.ElementSource source;
case ({},_,_,_,_,_) then (listReverse(inAcc),iEqns,iVars);
// single inactive when equation during initialization
case ((stmt as DAE.STMT_WHEN(exp=condition, source=source))::{},true,_,_,_,_)
case ((stmt as DAE.STMT_WHEN(exp=condition, source=source, elseWhen=NONE()))::{},true,_,_,_,_)
equation
false = Expression.containsInitialCall(condition, false);
crefLst = CheckModel.algorithmStatementListOutputs({stmt});
Expand Down Expand Up @@ -715,7 +715,7 @@ algorithm
cache=cache,
env=env,
functionTree=functionTree)), _, _, _) equation
true = Flags.isSet(Flags.SOLVE_INITIAL_SYSTEM);
// true = Flags.isSet(Flags.SOLVE_INITIAL_SYSTEM);

// collect vars and eqns for initial system
vars = BackendVariable.emptyVars();
Expand Down
3 changes: 2 additions & 1 deletion Compiler/BackEnd/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6966,7 +6966,7 @@ algorithm
shared as BackendDAE.SHARED(knownVars=knvars,
aliasVars=aliasVars,
removedEqs=removedEqs))), _, _, _) equation
true = Flags.isSet(Flags.SOLVE_INITIAL_SYSTEM);
// true = Flags.isSet(Flags.SOLVE_INITIAL_SYSTEM);

// generate equations from the solved systems
(uniqueEqIndex, _, _, allEquations, tempvars) = createEquationsForSystems(systs, shared, helpVarInfo, iuniqueEqIndex, {}, {}, {}, itempvars);
Expand All @@ -6989,6 +6989,7 @@ algorithm
(initialEqs_lst, numberOfInitialEquations, numberOfInitialAlgorithms) = BackendDAEOptimize.collectInitialEquations(inDAE);
(residual_equations, uniqueEqIndex, tempvars) = createNonlinearResidualEquations(initialEqs_lst, iuniqueEqIndex, itempvars);
Debug.fcall(Flags.SOLVE_INITIAL_SYSTEM, Error.addCompilerWarning, "No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead.");
Error.addCompilerWarning("No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead.");
//Error.addCompilerWarning("No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead.");
then (residual_equations, {}, numberOfInitialEquations, numberOfInitialAlgorithms, uniqueEqIndex, tempvars, false);

Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ template functionInitialStateSets(list<StateSet> stateSets)
statesetData[<%i1%>].A = &<%cref(crA)%>__varInfo;
statesetData[<%i1%>].rowPivot = (modelica_integer*) calloc(<%nCandidates%>-<%nStates%>,sizeof(modelica_integer));
statesetData[<%i1%>].colPivot = (modelica_integer*) calloc(<%nCandidates%>,sizeof(modelica_integer));
statesetData[<%i1%>].J = (modelica_real*) calloc(<%nCandidates%>*<%nStates%>,sizeof(modelica_real));
statesetData[<%i1%>].J = (modelica_real*) calloc(<%nCandidates%>*(<%nCandidates%>-<%nStates%>),sizeof(modelica_real));
statesetData[<%i1%>].analyticalJacobianColumn = <%generatedJac%>;
statesetData[<%i1%>].initialAnalyticalJacobian = <%initialJac%>;
statesetData[<%i1%>].jacobianIndex = <%jacIndex%>;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ constant ConfigFlag POST_OPT_MODULES = CONFIG_FLAG(16, "postOptModules",
"inputDerivativesUsed",
"detectJacobianSparsePattern",
// "generateSymbolicJacobian",
"removeConstants",
"optimizeInitialSystem"
"removeConstants"
// "optimizeInitialSystem"
}),
SOME(STRING_DESC_OPTION({
("lateInlineFunction", Util.gettext("perform function inlining for function with annotation LateInline=true")),
Expand Down

0 comments on commit 4b6c9f4

Please sign in to comment.