Skip to content

Commit

Permalink
- improve Pantelites algorithm to handle also not differentiable sing…
Browse files Browse the repository at this point in the history
…ulare subsets

- move Modelica.Magnetic.FluxTubes.Examples.SaturatedInductor.mos to working tests
- add flag to dump trace in HTML usage with +d=bltdump +dumpTarget=log.html
  it is a first try, shure we have to improve it but it can be quiet usefull in case of large trace files

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14101 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Nov 28, 2012
1 parent 0b5acc8 commit 143d435
Show file tree
Hide file tree
Showing 7 changed files with 1,284 additions and 391 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,10 @@ algorithm
(outVarKind) := matchcontinue (inVarKind,inType,inComponentRef,inVarDirection,inConnectorType,daeAttr)
// variable -> state if have stateSelect=StateSelect.always
case (DAE.VARIABLE(),_,_,_,_,SOME(DAE.VAR_ATTR_REAL(stateSelectOption = SOME(DAE.ALWAYS()))))
then (BackendDAE.STATE());
then (BackendDAE.STATE());
// variable -> state if have stateSelect=StateSelect.prefer
case (DAE.VARIABLE(),_,_,_,_,SOME(DAE.VAR_ATTR_REAL(stateSelectOption = SOME(DAE.PREFER()))))
then (BackendDAE.STATE());
then (BackendDAE.STATE());

case (DAE.VARIABLE(),DAE.T_BOOL(varLst = _),_,_,_,_)
equation
Expand Down
17 changes: 10 additions & 7 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ algorithm
astate = BackendVariable.isStateVar(av);
vstate = BackendVariable.isStateVar(v);
vrepl = replaceableAliasNew(v);
(av as BackendDAE.VAR(varName=acr),ia,v as BackendDAE.VAR(varName=cr),i) = switchStateAlias(astate,vstate,vrepl,av,ia,v,i);
(av as BackendDAE.VAR(varName=acr),ia,v as BackendDAE.VAR(varName=cr),i) = switchStateAlias(astate,vstate,vrepl,varskn,av,ia,v,i);
// move var to alias vars
cre = Expression.crefExp(cr);
cre = Debug.bcallret1(negate,Expression.negate,cre,cre);
Expand Down Expand Up @@ -923,6 +923,7 @@ protected function switchStateAlias
input Boolean astate;
input Boolean vstate;
input Boolean vrepl;
input Boolean varskn;
input BackendDAE.Var in_av;
input Integer in_ia;
input BackendDAE.Var in_v;
Expand All @@ -932,23 +933,25 @@ protected function switchStateAlias
output BackendDAE.Var v;
output Integer i;
algorithm
(av,ia,v,i) := match(astate,vstate,vrepl,in_av,in_ia,in_v,in_i)
(av,ia,v,i) := match(astate,vstate,vrepl,varskn,in_av,in_ia,in_v,in_i)
local
Integer s,sa;
// no state keep it like it is
case (false,_,_,_,_,_,_) then (in_av,in_ia,in_v,in_i);
case (false,_,_,_,_,_,_,_) then (in_av,in_ia,in_v,in_i);
// alias state, var no state and replaceable -> switch
case (true,false,true,_,_,_,_) then (in_v,in_i,in_av,in_ia);
case (true,false,true,_,_,_,_,_) then (in_v,in_i,in_av,in_ia);
// alias state, var state -> check StateSelect
case (true,true,_,_,_,_,_)
case (true,true,_,_,_,_,_,_)
equation
sa = BackendVariable.varStateSelectPrioAlias(in_av);
s = BackendVariable.varStateSelectPrioAlias(in_v);
((av,ia,v,i)) = Util.if_(intGt(sa,s),(in_v,in_i,in_av,in_ia),(in_av,in_ia,in_v,in_i));
then
(av,ia,v,i);
// alias state, var not replacable but known -> replace
case (true,_,false,true,_,_,_,_) then (in_av,in_ia,in_v,in_i);
// alias state, var not replacable -> do not replace
case (true,_,false,_,_,_,_) then fail();
case (true,_,false,false,_,_,_,_) then fail();
end match;
end switchStateAlias;

Expand Down Expand Up @@ -1090,7 +1093,7 @@ algorithm
BackendDAE.VarKind kind;
case BackendDAE.VAR(varKind=kind)
equation
false = BackendVariable.isStateorStateDerVar(var) "cr1 not state";
//false = BackendVariable.isStateorStateDerVar(var) "cr1 not state";
BackendVariable.isVarKindVariable(kind) "cr1 not constant";
false = BackendVariable.isVarOnTopLevelAndOutput(var);
false = BackendVariable.isVarOnTopLevelAndInput(var);
Expand Down

0 comments on commit 143d435

Please sign in to comment.