Skip to content

Commit

Permalink
- added a flag for changeable parameters to *_init.xml file.
Browse files Browse the repository at this point in the history
   - parameters that are not evaluated before and constant are changeable.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18060 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Willi Braun committed Nov 8, 2013
1 parent 84ef2c3 commit 176924e
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 72 deletions.
35 changes: 35 additions & 0 deletions Compiler/BackEnd/BackendVariable.mo
Expand Up @@ -494,6 +494,19 @@ algorithm
end match;
end varBindExp;

public function varHasConstantBindExp
"Returns the true if the bindExp is constant otherwise false."
input BackendDAE.Var v;
output Boolean out;
algorithm
out := match(v)
local DAE.Exp e;
case (BackendDAE.VAR(bindExp = SOME(e)))
then Expression.isConst(e);
else false;
end match;
end varHasConstantBindExp;

public function varBindExpStartValue
"author: Frenkel TUD 2010-12
Returns the bindExp or the start value if no bind is there of a variable."
Expand Down Expand Up @@ -1611,6 +1624,28 @@ algorithm
prot := DAEUtil.getProtectedAttr(attr);
end isProtectedVar;

public function hasVarEvaluateAnnotationOrFinal
input BackendDAE.Var inVar;
output Boolean select;
algorithm
select := isFinalVar(inVar) or hasVarEvaluateAnnotation(inVar);
end hasVarEvaluateAnnotationOrFinal;

public function hasVarEvaluateAnnotation
input BackendDAE.Var inVar;
output Boolean select;
algorithm
select := match(inVar)
local
SCode.Annotation anno;
// Parameter with evaluate=true
case BackendDAE.VAR(comment=SOME(SCode.COMMENT(annotation_=SOME(anno))))
then SCode.hasBooleanNamedAnnotation({anno},"Evaluate");
else then false;
end match;
end hasVarEvaluateAnnotation;


public function createpDerVar "author: wbraun
Create variable with $pDER.v as cref for jacobian variables."
input BackendDAE.Var inVar;
Expand Down
29 changes: 4 additions & 25 deletions Compiler/BackEnd/EvaluateParameter.mo
Expand Up @@ -119,7 +119,7 @@ public function evaluateEvaluateParameters
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
algorithm
(outDAE,_ ) := evaluateParameters(inDAE,hasEvaluateAnnotation);
(outDAE,_ ) := evaluateParameters(inDAE,BackendVariable.hasVarEvaluateAnnotation);
end evaluateEvaluateParameters;

public function evaluateFinalEvaluateParameters
Expand All @@ -128,7 +128,7 @@ public function evaluateFinalEvaluateParameters
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
algorithm
(outDAE,_ ) := evaluateParameters(inDAE,hasEvaluateAnnotationOrFinal);
(outDAE,_ ) := evaluateParameters(inDAE,BackendVariable.hasVarEvaluateAnnotationOrFinal);
end evaluateFinalEvaluateParameters;

public function evaluateReplaceFinalParameters
Expand All @@ -151,7 +151,7 @@ public function evaluateReplaceEvaluateParameters
protected
BackendVarTransform.VariableReplacements repl;
algorithm
(outDAE,repl) := evaluateParameters(inDAE,hasEvaluateAnnotation);
(outDAE,repl) := evaluateParameters(inDAE,BackendVariable.hasVarEvaluateAnnotation);
outDAE := replaceEvaluatedParametersEqns(BackendVarTransform.replacementEmpty(repl),outDAE,repl);
end evaluateReplaceEvaluateParameters;

Expand All @@ -162,7 +162,7 @@ public function evaluateReplaceFinalEvaluateParameters "author: Frenkel TUD
protected
BackendVarTransform.VariableReplacements repl;
algorithm
(outDAE,repl) := evaluateParameters(inDAE,hasEvaluateAnnotationOrFinal);
(outDAE,repl) := evaluateParameters(inDAE,BackendVariable.hasVarEvaluateAnnotationOrFinal);
outDAE := replaceEvaluatedParametersEqns(BackendVarTransform.replacementEmpty(repl),outDAE,repl);
end evaluateReplaceFinalEvaluateParameters;

Expand Down Expand Up @@ -232,27 +232,6 @@ algorithm
end evaluateParameters;


protected function hasEvaluateAnnotationOrFinal
input BackendDAE.Var inVar;
output Boolean select;
algorithm
select := BackendVariable.isFinalVar(inVar) or hasEvaluateAnnotation(inVar);
end hasEvaluateAnnotationOrFinal;

protected function hasEvaluateAnnotation
input BackendDAE.Var inVar;
output Boolean select;
algorithm
select := match(inVar)
local
SCode.Annotation anno;
// Parameter with evaluate=true
case BackendDAE.VAR(comment=SOME(SCode.COMMENT(annotation_=SOME(anno))))
then SCode.hasBooleanNamedAnnotation({anno},"Evaluate");
else then false;
end match;
end hasEvaluateAnnotation;

protected function getParameterIncidenceMatrix
input tuple<BackendDAE.Var,tuple<BackendDAE.Variables,Integer,selectParameterFunc,list<Integer>,Integer,array<Integer>,BackendDAE.IncidenceMatrix,BackendDAE.IncidenceMatrixT>> inTp;
output tuple<BackendDAE.Var,tuple<BackendDAE.Variables,Integer,selectParameterFunc,list<Integer>,Integer,array<Integer>,BackendDAE.IncidenceMatrix,BackendDAE.IncidenceMatrixT>> outTpl;
Expand Down
1 change: 1 addition & 0 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -251,6 +251,7 @@ uniontype SimVar "Information about a variable in a Modelica model."
Causality causality;
Option<Integer> variable_index;
list<String> numArrayElement;
Boolean isValueChangeable;
end SIMVAR;
end SimVar;

Expand Down

0 comments on commit 176924e

Please sign in to comment.