Skip to content

Commit

Permalink
- Modified epsilon of event hysteresis
Browse files Browse the repository at this point in the history
- Remove unnecessary counter from BackendDAE.EVENT_INFO


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23187 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Nov 4, 2014
1 parent cc239e2 commit 609a345
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 48 deletions.
1 change: 0 additions & 1 deletion Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -459,7 +459,6 @@ uniontype EventInfo
// TODO: sampleLst and relationsLst could be removed if cpp runtime is prepared to handle zero crossing conditions
list<ZeroCrossing> sampleLst "list of sample as before, used by cpp runtime";
list<ZeroCrossing> relationsLst "list of zero crossing function as before, used by cpp runtime";
Integer relationsNumber "stores the number of relation in all zero-crossings";
Integer numberMathEvents "stores the number of math function that trigger events e.g. floor, ceil, integer, ...";
end EVENT_INFO;
end EventInfo;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -128,7 +128,7 @@ algorithm
eqnarr := BackendEquation.listEquation(eqns);
reqnarr := BackendEquation.listEquation(reqns);
ieqnarr := BackendEquation.listEquation(ieqns);
einfo := BackendDAE.EVENT_INFO(timeEvents, whenclauses_1, {}, {}, {}, 0, 0);
einfo := BackendDAE.EVENT_INFO(timeEvents, whenclauses_1, {}, {}, {}, 0);
symjacs := {(NONE(), ({}, {}, ({}, {})), {}), (NONE(), ({}, {}, ({}, {})), {}), (NONE(), ({}, {}, ({}, {})), {}), (NONE(), ({}, {}, ({}, {})), {})};
outBackendDAE := BackendDAE.DAE(BackendDAE.EQSYSTEM(vars_1,
eqnarr,
Expand Down
9 changes: 3 additions & 6 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -256,14 +256,14 @@ protected
list<BackendDAE.TimeEvent> timeEvents;
list<BackendDAE.WhenClause> whenClauseLst;
list<BackendDAE.ZeroCrossing> zeroCrossingLst, sampleLst, relationsLst;
Integer relationsNumber, numberMathEvents;
Integer numberMathEvents;
algorithm
BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, relationsNumber, numberMathEvents) := iEventInfo;
BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numberMathEvents) := iEventInfo;
(whenClauseLst, outTypeA) := traverseWhenClauseExps(whenClauseLst, func, inTypeA, {});
(zeroCrossingLst, outTypeA) := traverseZeroCrossingExps(zeroCrossingLst, func, outTypeA, {});
(sampleLst, outTypeA) := traverseZeroCrossingExps(sampleLst, func, outTypeA, {});
(relationsLst, outTypeA) := traverseZeroCrossingExps(relationsLst, func, outTypeA, {});
oEventInfo := BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, relationsNumber, numberMathEvents);
oEventInfo := BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numberMathEvents);
end traverseEventInfoExps;

protected function traverseWhenClauseExps<T>
Expand Down Expand Up @@ -3861,7 +3861,6 @@ protected
list<BackendDAE.ZeroCrossing> zeroCrossingLst;
list<BackendDAE.ZeroCrossing> sampleLst;
list<BackendDAE.ZeroCrossing> relationsLst;
Integer relationsNumber;
Integer numberMathEvents;

Integer index;
Expand Down Expand Up @@ -3893,7 +3892,6 @@ algorithm
zeroCrossingLst=zeroCrossingLst,
sampleLst=sampleLst,
relationsLst=relationsLst,
relationsNumber=relationsNumber,
numberMathEvents=numberMathEvents) := eventInfo;

ht := HashTableExpToIndex.emptyHashTable();
Expand All @@ -3915,7 +3913,6 @@ algorithm
zeroCrossingLst,
sampleLst,
relationsLst,
relationsNumber,
numberMathEvents);
shared := BackendDAE.SHARED(knownVars,
externalObjects,
Expand Down
13 changes: 7 additions & 6 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -787,15 +787,16 @@ public function numberOfZeroCrossings "author: lochel"
output Integer outNumMathEventFunctions;
protected
list<BackendDAE.TimeEvent> timeEvents;
list<ZeroCrossing> zeroCrossingLst;
list<ZeroCrossing> zeroCrossingLst, relationsLst;
algorithm
BackendDAE.DAE(shared=BackendDAE.SHARED(eventInfo=BackendDAE.EVENT_INFO(timeEvents=timeEvents,
zeroCrossingLst=zeroCrossingLst,
relationsNumber=outNumRelations,
relationsLst=relationsLst,
numberMathEvents=outNumMathEventFunctions))) := inBackendDAE;

outNumTimeEvents := listLength(timeEvents);
outNumZeroCrossings := listLength(zeroCrossingLst);
outNumTimeEvents := listLength(timeEvents);
outNumRelations := listLength(relationsLst);
end numberOfZeroCrossings;

public function numberOfDiscreteVars "author: lochel"
Expand Down Expand Up @@ -2047,17 +2048,17 @@ algorithm
DAE.FunctionTree funcs;
list<BackendDAE.WhenClause> wclst,wclst1;
list<ZeroCrossing> zc, rellst, smplLst;
Integer numberOfRelations, numberOfMathEventFunctions;
Integer numberOfMathEventFunctions;
ExternalObjectClasses eoc;
BackendDAE.SymbolicJacobians symjacs;
BackendDAEType btp;
list<BackendDAE.TimeEvent> timeEvents;
BackendDAE.ExtraInfo ei;

case (_,BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst,zc,smplLst,rellst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei))
case (_,BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst,zc,smplLst,rellst,numberOfMathEventFunctions),eoc,btp,symjacs,ei))
equation
wclst1 = listAppend(wclst,inWcLst);
then BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst1,zc,smplLst,rellst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei);
then BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst1,zc,smplLst,rellst,numberOfMathEventFunctions),eoc,btp,symjacs,ei);

end match;
end whenClauseAddDAE;
Expand Down
3 changes: 1 addition & 2 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -263,7 +263,6 @@ protected
list<DAE.Constraint> constraints;
list<BackendDAE.ZeroCrossing> zeroCrossingLst, sampleLst, relationsLst;
list<BackendDAE.WhenClause> whenClauseLst;
Integer relationsNumber;
BackendDAE.ExternalObjectClasses extObjClasses;
BackendDAE.BackendDAEType backendDAEType;
BackendDAE.SymbolicJacobians symjacs;
Expand All @@ -274,7 +273,7 @@ algorithm
initialEqs=initialEqs,
removedEqs=removedEqs,
constraints=constraints,
eventInfo=BackendDAE.EVENT_INFO(relationsLst=relationsLst, zeroCrossingLst=zeroCrossingLst, sampleLst=sampleLst, whenClauseLst=whenClauseLst, relationsNumber=relationsNumber),
eventInfo=BackendDAE.EVENT_INFO(relationsLst=relationsLst, zeroCrossingLst=zeroCrossingLst, sampleLst=sampleLst, whenClauseLst=whenClauseLst),
extObjClasses=extObjClasses,
backendDAEType=backendDAEType,
symjacs=symjacs) := inShared;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/BackendInline.mo
Expand Up @@ -549,16 +549,16 @@ algorithm
Inline.Functiontuple fns;
list<BackendDAE.WhenClause> wclst, wclst_1;
list<BackendDAE.ZeroCrossing> zclst, zclst_1, relations, samples;
Integer numberOfRelations, numberOfMathEvents;
Integer numberOfMathEvents;
BackendDAE.EventInfo ev;
Boolean b1, b2, b3;
list<BackendDAE.TimeEvent> timeEvents;

case(BackendDAE.EVENT_INFO(timeEvents, wclst, zclst, samples, relations, numberOfRelations, numberOfMathEvents), fns) equation
case(BackendDAE.EVENT_INFO(timeEvents, wclst, zclst, samples, relations, numberOfMathEvents), fns) equation
(wclst_1, b1) = inlineWhenClauses(wclst, fns, {}, false);
(zclst_1, b2) = inlineZeroCrossings(zclst, fns, {}, false);
(relations, b3) = inlineZeroCrossings(relations, fns, {}, false);
ev = if b1 or b2 or b3 then BackendDAE.EVENT_INFO(timeEvents, wclst_1, zclst_1, samples, relations, numberOfRelations, numberOfMathEvents) else inEventInfo;
ev = if b1 or b2 or b3 then BackendDAE.EVENT_INFO(timeEvents, wclst_1, zclst_1, samples, relations, numberOfMathEvents) else inEventInfo;
then ev;

else
Expand Down
10 changes: 4 additions & 6 deletions Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -112,7 +112,6 @@ protected
list<BackendDAE.TimeEvent> timeEvents;
list<BackendDAE.ZeroCrossing> zero_crossings;
list<BackendDAE.ZeroCrossing> relations, sampleLst;
Integer countRelations;
Integer countMathFunctions;
Option<BackendDAE.IncidenceMatrix> m, mT;
BackendDAE.BackendDAEType btp;
Expand All @@ -128,19 +127,18 @@ algorithm
BackendDAE.EQSYSTEM(vars, eqns, m, mT, matching, stateSets, partitionKind) := inSyst;
BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs,
cache, graph, funcs, BackendDAE.EVENT_INFO(timeEvents=timeEvents, zeroCrossingLst=zero_crossings,
sampleLst=sampleLst, whenClauseLst=whenclauses, relationsLst=relations,
relationsNumber=countRelations, numberMathEvents=countMathFunctions),
sampleLst=sampleLst, whenClauseLst=whenclauses, relationsLst=relations, numberMathEvents=countMathFunctions),
eoc, btp, symjacs, ei) := inShared;

eqs_lst := BackendEquation.equationList(eqns);
(zero_crossings, eqs_lst1, _, countRelations, countMathFunctions, relations, sampleLst) := findZeroCrossings2(vars, knvars, eqs_lst, 0, {}, 0, countRelations, countMathFunctions, zero_crossings, relations, sampleLst, {}, {});
(zero_crossings, eqs_lst1, _, _, countMathFunctions, relations, sampleLst) := findZeroCrossings2(vars, knvars, eqs_lst, 0, {}, 0, listLength(relations), countMathFunctions, zero_crossings, relations, sampleLst, {}, {});
eqs_lst1 := listReverse(eqs_lst1);
if Flags.isSet(Flags.RELIDX) then
print("findZeroCrossings1 number of relations: " + intString(countRelations) + "\n");
print("findZeroCrossings1 number of relations: " + intString(listLength(relations)) + "\n");
print("findZeroCrossings1 sample index: " + intString(listLength(sampleLst)) + "\n");
end if;
eqns1 := BackendEquation.listEquation(eqs_lst1);
einfo1 := BackendDAE.EVENT_INFO(timeEvents, whenclauses, zero_crossings, sampleLst, relations, countRelations, countMathFunctions);
einfo1 := BackendDAE.EVENT_INFO(timeEvents, whenclauses, zero_crossings, sampleLst, relations, countMathFunctions);
outSyst := BackendDAE.EQSYSTEM(vars, eqns1, m, mT, matching, stateSets, partitionKind);
outShared := BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs, cache, graph, funcs, einfo1, eoc, btp, symjacs, ei);
end findZeroCrossings1;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/IndexReduction.mo
Expand Up @@ -4347,12 +4347,12 @@ algorithm
BackendDAE.SymbolicJacobians symjacs;
list<BackendDAE.WhenClause> whenClauseLst,whenClauseLst1;
list<BackendDAE.ZeroCrossing> zeroCrossingLst, relationsLst, sampleLst;
Integer numberOfRelations, numberOfMathEventFunctions;
Integer numberOfMathEventFunctions;
BackendDAE.BackendDAEType btp;
list<BackendDAE.TimeEvent> timeEvents;
BackendDAE.ExtraInfo ei;

case (BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,BackendDAE.EVENT_INFO(timeEvents,whenClauseLst,zeroCrossingLst,sampleLst,relationsLst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei),_)
case (BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,BackendDAE.EVENT_INFO(timeEvents,whenClauseLst,zeroCrossingLst,sampleLst,relationsLst,numberOfMathEventFunctions),eoc,btp,symjacs,ei),_)
equation
// replace dummy_derivatives in knvars,aliases,ineqns,remeqns
(aliasVars,_) = BackendVariable.traverseBackendDAEVarsWithUpdate(aliasVars,replaceDummyDerivativesVar,ht);
Expand All @@ -4361,7 +4361,7 @@ algorithm
_ = BackendDAEUtil.traverseBackendDAEExpsEqnsWithUpdate(remeqns,Expression.traverseSubexpressionsHelper,(replaceDummyDerivativesExp,ht));
(whenClauseLst1,_) = BackendDAETransform.traverseBackendDAEExpsWhenClauseLst(whenClauseLst,Expression.traverseSubexpressionsHelper,(replaceDummyDerivativesExp,ht));
then
BackendDAE.SHARED(knvars1,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,BackendDAE.EVENT_INFO(timeEvents,whenClauseLst1,zeroCrossingLst,sampleLst,relationsLst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei);
BackendDAE.SHARED(knvars1,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,BackendDAE.EVENT_INFO(timeEvents,whenClauseLst1,zeroCrossingLst,sampleLst,relationsLst,numberOfMathEventFunctions),eoc,btp,symjacs,ei);

end match;
end replaceDummyDerivativesShared;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Initialization.mo
Expand Up @@ -159,7 +159,7 @@ algorithm
cache,
graph,
functionTree,
BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0, 0),
BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0),
{},
BackendDAE.INITIALSYSTEM(),
{},
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/RemoveSimpleEquations.mo
Expand Up @@ -3388,7 +3388,7 @@ algorithm
BackendDAE.SymbolicJacobians symjacs;
list<BackendDAE.WhenClause> whenClauseLst, whenClauseLst1;
list<BackendDAE.ZeroCrossing> zeroCrossingLst, relationsLst, sampleLst;
Integer numberOfRelations, numMathFunctions;
Integer numMathFunctions;
BackendDAE.BackendDAEType btp;
BackendDAE.EqSystems systs, systs1;
list<BackendDAE.Equation> eqnslst;
Expand All @@ -3398,7 +3398,7 @@ algorithm
BackendDAE.ExtraInfo ei;

case (false, _, _) then inDAE;
case (true, BackendDAE.DAE(systs, BackendDAE.SHARED(knvars, exobj, aliasVars, inieqns, remeqns, constraintsLst, clsAttrsLst, cache, graph, funcTree, BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numberOfRelations, numMathFunctions), eoc, btp, symjacs, ei)), _)
case (true, BackendDAE.DAE(systs, BackendDAE.SHARED(knvars, exobj, aliasVars, inieqns, remeqns, constraintsLst, clsAttrsLst, cache, graph, funcTree, BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numMathFunctions), eoc, btp, symjacs, ei)), _)
equation
if Flags.isSet(Flags.DUMP_REPL) then
BackendVarTransform.dumpReplacements(repl);
Expand All @@ -3420,7 +3420,7 @@ algorithm
// remove asserts with condition=true from removed equations
remeqns1 = BackendEquation.listEquation(List.select(BackendEquation.equationList(remeqns1), assertWithCondTrue));
then
BackendDAE.DAE(systs1, BackendDAE.SHARED(knvars1, exobj, aliasVars, inieqns, remeqns1, constraintsLst, clsAttrsLst, cache, graph, funcTree, BackendDAE.EVENT_INFO(timeEvents, whenClauseLst1, zeroCrossingLst, sampleLst, relationsLst, numberOfRelations, numMathFunctions), eoc, btp, symjacs, ei));
BackendDAE.DAE(systs1, BackendDAE.SHARED(knvars1, exobj, aliasVars, inieqns, remeqns1, constraintsLst, clsAttrsLst, cache, graph, funcTree, BackendDAE.EVENT_INFO(timeEvents, whenClauseLst1, zeroCrossingLst, sampleLst, relationsLst, numMathFunctions), eoc, btp, symjacs, ei));
end match;
end removeSimpleEquationsShared;

Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -1532,7 +1532,7 @@ algorithm
jacRemovedEqs = BackendEquation.emptyEqns();
jacInitialEqs = BackendEquation.emptyEqns();
functions = DAEUtil.avlTreeNew();
jacEventInfo = BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0, 0);
jacEventInfo = BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0);
jacExtObjClasses = {};

jacobian = BackendDAE.DAE({BackendDAE.EQSYSTEM(jacOrderedVars, jacOrderedEqs, NONE(), NONE(), BackendDAE.NO_MATCHING(), {}, BackendDAE.UNKNOWN_PARTITION())}, BackendDAE.SHARED(jacKnownVars, jacExternalObjects, jacAliasVars, jacInitialEqs, jacRemovedEqs, {}, {}, cache, graph, functions, jacEventInfo, jacExtObjClasses,BackendDAE.JACOBIAN(),{},ei));
Expand Down Expand Up @@ -1580,7 +1580,7 @@ algorithm
jacOrderedEqs = BackendEquation.listEquation(derivedEquations);
jacRemovedEqs = BackendEquation.emptyEqns();
jacInitialEqs = BackendEquation.emptyEqns();
jacEventInfo = BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0, 0);
jacEventInfo = BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0);
jacExtObjClasses = {};

jacobian = BackendDAE.DAE(BackendDAE.EQSYSTEM(jacOrderedVars, jacOrderedEqs, NONE(), NONE(), BackendDAE.NO_MATCHING(), {}, BackendDAE.UNKNOWN_PARTITION())::{}, BackendDAE.SHARED(jacKnownVars, jacExternalObjects, jacAliasVars, jacInitialEqs, jacRemovedEqs, {}, {}, cache, graph, DAE.emptyFuncTree, jacEventInfo, jacExtObjClasses, BackendDAE.JACOBIAN(),{}, ei));
Expand Down Expand Up @@ -2151,7 +2151,7 @@ algorithm
backendDAE = BackendDAE.DAE({BackendDAE.EQSYSTEM(dependentVars, eqns, NONE(), NONE(), BackendDAE.NO_MATCHING(), {}, BackendDAE.UNKNOWN_PARTITION())},
BackendDAE.SHARED(knvars, emptyVars, emptyVars,
emptyEqns, emptyEqns, {}, {},
cache, graph, funcs, BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0, 0),
cache, graph, funcs, BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0),
{}, BackendDAE.ALGEQSYSTEM(), {}, einfo));

backendDAE = BackendDAEUtil.transformBackendDAE(backendDAE, SOME((BackendDAE.NO_INDEX_REDUCTION(), BackendDAE.EXACT())), NONE(), NONE());
Expand Down

0 comments on commit 609a345

Please sign in to comment.