Skip to content

Commit

Permalink
Revert r14982 (breaks 4 tests; 3 of them badly, 1 of them spins forever)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14983 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 29, 2013
1 parent e797d75 commit 199fb49
Show file tree
Hide file tree
Showing 22 changed files with 1,489 additions and 445 deletions.
42 changes: 30 additions & 12 deletions Compiler/BackEnd/BackendQSS.mo
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ algorithm
list<SimCode.SimEqSystem> eqs;
list<list<Integer>> s;
list<DAE.ComponentRef> states,disc,algs;
list<SimCode.SampleCondition> sampleConditions;
BackendDAE.EquationArray eqsdae;
BackendDAE.Shared shared;
list<BackendDAE.ZeroCrossing> zeroCrossings;
Expand All @@ -100,7 +101,7 @@ algorithm
SimCode.SimCode sc;
Integer offset;

case (dlow as BackendDAE.DAE({BackendDAE.EQSYSTEM(orderedEqs=eqsdae)},shared), sc as SimCode.SIMCODE(odeEquations={eqs},zeroCrossings=zeroCrossings))
case (dlow as BackendDAE.DAE({BackendDAE.EQSYSTEM(orderedEqs=eqsdae)},shared), sc as SimCode.SIMCODE(odeEquations={eqs},sampleConditions=sampleConditions,zeroCrossings=zeroCrossings))
equation
print("\n ----------------------------\n");
print("BackEndQSS analysis initialized");
Expand All @@ -109,6 +110,7 @@ algorithm
stateVarsList = List.filterOnTrue(orderedVarsList,BackendVariable.isStateVar);
discVarsLst = List.filterOnTrue(orderedVarsList,isDiscreteVar);
disc = List.map(discVarsLst,BackendVariable.varCref);
disc = listAppend(disc, createDummyVars(listLength(sampleConditions)));
(eqsindex,zc_exps) = getEquationsWithDiscont(zeroCrossings);
offset = listLength(disc);
disc = listAppend(disc, newDiscreteVariables(getEquations(eqsdae,eqsindex),0));
Expand Down Expand Up @@ -728,42 +730,56 @@ algorithm
end matchcontinue;
end getInitExp;

function getStartTime
input SimCode.SampleCondition cond;
output String s;
algorithm
s:=
match (cond)
local
DAE.Exp start;
// lochel: first argument of sample becomes an unique index in BackendDAECreate
case ((DAE.CALL(path=Absyn.IDENT(name="sample"), expLst=(_::start:: _)),_) )
then ExpressionDump.printExpStr(replaceVars(start,{},{},{}));
end match;
end getStartTime;

public function generateDInit
input list<DAE.ComponentRef> disc;
//input list<SimCode.SampleCondition> sample;
input list<SimCode.SampleCondition> sample;
input SimCode.SimVars vars;
input Integer acc;
input Integer total;
input Integer nWhenClause;
output String out;
algorithm
out:=matchcontinue(disc,vars,acc,total,nWhenClause)
out:=matchcontinue(disc,sample,vars,acc,total,nWhenClause)
local
list<DAE.ComponentRef> tail;
DAE.ComponentRef cref;
String s;
list<SimCode.SimVar> intAlgVars;
list<SimCode.SimVar> boolAlgVars;
list<SimCode.SimVar> algVars;
case ({},_,_,_,_) then "";
case (cref::tail,_,_,_,_)
case ({},_,_,_,_,_) then "";
case (cref::tail,_,_,_,_,_)
equation
true = total - acc -1 < nWhenClause;
s=stringAppend("","d[");
s=stringAppend(s,intString(acc+1));
s=stringAppend(s,"]:=");
//s=stringAppend(s,getStartTime(listNth({},total-acc-2)));
s=stringAppend(s,getStartTime(listNth(sample,total-acc-2)));
s=stringAppend(s,";\n");
then stringAppend(s,generateDInit(tail,vars,acc+1,total,nWhenClause));
then stringAppend(s,generateDInit(tail,sample,vars,acc+1,total,nWhenClause));

case (cref::tail,SimCode.SIMVARS(intAlgVars=intAlgVars,boolAlgVars=boolAlgVars,algVars=algVars),_,_,_)
case (cref::tail,_,SimCode.SIMVARS(intAlgVars=intAlgVars,boolAlgVars=boolAlgVars,algVars=algVars),_,_,_)
equation
s=stringAppend("","d[");
s=stringAppend(s,intString(acc+1));
s=stringAppend(s,"]:=");
s=stringAppend(s,getInitExp(listAppend(algVars,listAppend(intAlgVars,boolAlgVars)),cref));
s=stringAppend(s,"\n");
then stringAppend(s,generateDInit(tail,vars,acc+1,total,nWhenClause));
then stringAppend(s,generateDInit(tail,sample,vars,acc+1,total,nWhenClause));

end matchcontinue;
end generateDInit;
Expand Down Expand Up @@ -1008,6 +1024,8 @@ algorithm
list<DAE.Constraint> constraints;
list<DAE.ClassAttributes> classAttributes;
list<BackendDAE.ZeroCrossing> zeroCrossings,relations;
list<SimCode.SampleCondition> sampleConditions;
list<SimCode.HelpVarInfo> helpVarInfo;
list<SimCode.SimWhenClause> whenClauses;
list<DAE.ComponentRef> discreteModelVars;
SimCode.ExtObjInfo extObjInfo;
Expand All @@ -1022,7 +1040,7 @@ algorithm
case (SimCode.SIMCODE(modelInfo,literals,recordDecls,externalFunctionIncludes,allEquations,odeEquations,
algebraicEquations,residualEquations,useSymbolicInitialization,initialEquations,startValueEquations,
parameterEquations,inlineEquations,removedEquations,algorithmAndEquationAsserts,stateSets,constraints,classAttributes,zeroCrossings,relations,
sampleLookup,whenClauses,discreteModelVars,extObjInfo,makefileParams,
sampleLookup,sampleConditions,sampleEquations,helpVarInfo,whenClauses,discreteModelVars,extObjInfo,makefileParams,
delayedExps,jacobianMatrixes,simulationSettingsOpt,fileNamePrefix,crefToSimVarHT),_)
equation
{eqs} = odeEquations;
Expand All @@ -1031,8 +1049,8 @@ algorithm
allEquations, {eqs}, algebraicEquations, residualEquations, useSymbolicInitialization,
initialEquations, startValueEquations, parameterEquations, inlineEquations,
removedEquations, algorithmAndEquationAsserts, stateSets, constraints, classAttributes,
zeroCrossings, relations, sampleLookup,
whenClauses, discreteModelVars, extObjInfo,
zeroCrossings, relations, sampleLookup, sampleConditions, sampleEquations,
helpVarInfo, whenClauses, discreteModelVars, extObjInfo,
makefileParams, delayedExps, jacobianMatrixes,
simulationSettingsOpt, fileNamePrefix, crefToSimVarHT);

Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/ResidualCmp.mo
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ algorithm
(daevars,_,allEquations,allInitEquations) = generateEquationscollectVars(elementLst,{},1,{},{});
// generate variable definitions
simvars = SimCode.SIMVARS({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});
varinfo = SimCode.VARINFO(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NONE(),NONE());
varinfo = SimCode.VARINFO(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NONE(),NONE());

modelInfo = SimCode.MODELINFO(inClassName,fileDir,varinfo,simvars,functions,{});
extObjInfo = SimCode.EXTOBJINFO({},{});
makefileParams = SimCode.MAKEFILE_PARAMS("","","","","","","","","",includeDirs,libs,"");
delayexp = SimCode.DELAYED_EXPRESSIONS({},0);
hashTable = SimCodeUtil.emptyHashTable();
rescmp = SimCode.SIMCODE(modelInfo,{},recordDecls,externalFunctionIncludes,{},{},{},allEquations,false,allInitEquations,{},{},{},{},{},{},{},{},{},{},BackendDAE.SAMPLE_LOOKUP(0,{}),{},{},extObjInfo,makefileParams,delayexp,{},NONE(),filenamePrefix,hashTable);
rescmp = SimCode.SIMCODE(modelInfo,{},recordDecls,externalFunctionIncludes,{},{},{},allEquations,false,allInitEquations,{},{},{},{},{},{},{},{},{},{},BackendDAE.SAMPLE_LOOKUP(0,{}),{},{},{},{},{},extObjInfo,makefileParams,delayexp,{},NONE(),filenamePrefix,hashTable);
then
rescmp;
else
Expand Down
6 changes: 6 additions & 0 deletions Compiler/BackEnd/SimCode.mo
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public
type ExtConstructor = tuple<DAE.ComponentRef, String, list<DAE.Exp>>;
type ExtDestructor = tuple<String, DAE.ComponentRef>;
type ExtAlias = tuple<DAE.ComponentRef, DAE.ComponentRef>;
type HelpVarInfo = tuple<Integer, DAE.Exp, Integer>; // helpvarindex, expression, whenclause index
type SampleCondition = tuple<DAE.Exp,Integer>; // helpvarindex, expression,
type JacobianColumn = tuple<list<SimEqSystem>, list<SimVar>, String>; // column equations, column vars, column length
type JacobianMatrix = tuple<list<JacobianColumn>, // column
list<SimVar>, // seed vars
Expand Down Expand Up @@ -98,6 +100,9 @@ uniontype SimCode
list<BackendDAE.ZeroCrossing> zeroCrossings;
list<BackendDAE.ZeroCrossing> relations;
BackendDAE.SampleLookup sampleLookup;
list<SampleCondition> sampleConditions;
list<SimEqSystem> sampleEquations;
list<HelpVarInfo> helpVarInfo;
list<SimWhenClause> whenClauses;
list<DAE.ComponentRef> discreteModelVars;
ExtObjInfo extObjInfo;
Expand Down Expand Up @@ -164,6 +169,7 @@ end FileInfo;
// Number of variables of various types in a Modelica model.
uniontype VarInfo
record VARINFO
Integer numHelpVars;
Integer numZeroCrossings;
Integer numTimeEvents;
Integer numRelations;
Expand Down

0 comments on commit 199fb49

Please sign in to comment.