Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Only mark states as changeable if the start attribute is constant
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Nov 4, 2016
1 parent db9157b commit 95bc481
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Compiler/BackEnd/BackendVariable.mo
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,21 @@ algorithm
end match;
end varHasConstantBindExp;

public function varHasConstantStartExp
"Returns the true if the binding/start value is constant otherwise false."
input BackendDAE.Var v;
output Boolean out;
protected
DAE.Exp e;
algorithm
try
e := varStartValueFail(v);
out := Expression.isConst(e);
else
out := true;
end try;
end varHasConstantStartExp;

public function varHasBindExp
"Returns the true if a bindExp exists otherwise false."
input BackendDAE.Var v;
Expand Down
5 changes: 3 additions & 2 deletions Compiler/SimCode/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8514,10 +8514,11 @@ algorithm
aliasvar = getAliasVar(dlowVar, optAliasVars);
caus = getCausality(dlowVar, vars);
numArrayElement = List.map(inst_dims, ExpressionDump.dimensionIntString);
isValueChangeable = BackendVariable.varHasConstantStartExp(dlowVar);
// print("name: " + ComponentReference.printComponentRefStr(cr) + "indx: " + intString(indx) + "\n");
then
SimCodeVar.SIMVAR(cr, kind, commentStr, unit, displayUnit, -1 /* use -1 to get an error in simulation if something failed */,
minValue, maxValue, initVal, nomVal, isFixed, type_, isDiscrete, arrayCref, aliasvar, source, caus, NONE(), numArrayElement, true, isProtected, hideResult, NONE());
minValue, maxValue, initVal, nomVal, isFixed, type_, isDiscrete, arrayCref, aliasvar, source, caus, NONE(), numArrayElement, isValueChangeable, isProtected, hideResult, NONE());

case ((BackendDAE.VAR(varName = cr,
varKind = kind,
Expand Down Expand Up @@ -12797,7 +12798,7 @@ algorithm

for param in inParamSimVars loop
// take for now only parameters that are changeable and topLevel
if param.isValueChangeable == true and ComponentReference.crefIsIdent(param.name) then
if param.isValueChangeable and ComponentReference.crefIsIdent(param.name) then
countSensitivityParams := countSensitivityParams+1;
sensitivityParams := param::sensitivityParams;
for state in inStateSimVars loop
Expand Down

0 comments on commit 95bc481

Please sign in to comment.