Skip to content

Commit

Permalink
- dump relations/zero crossings after events
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23269 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Nov 7, 2014
1 parent 0501fdf commit 74d0abd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
16 changes: 8 additions & 8 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -2892,7 +2892,7 @@ algorithm
tuple<BackendDAE.Variables, list<Integer>,Option<DAE.FunctionTree>> tpl;
Integer diffindx;

case (DAE.LBINARY(),tpl)
case (DAE.LBINARY(), tpl)
then (inExp, false, tpl);

case (DAE.RELATION(), tpl)
Expand All @@ -2918,25 +2918,25 @@ algorithm
pa = incidenceRowExp1(varslst, p, pa, 0);
then (inExp, false, (vars, pa, ofunctionTree));

case (DAE.ASUB(exp=e1, sub={DAE.ICONST(i)}),tpl) equation
case (DAE.ASUB(exp=e1, sub={DAE.ICONST(i)}), tpl) equation
e1 = Expression.nthArrayExp(e1, i);
(_, tpl) = Expression.traverseExpTopDown(e1, traversingincidenceRowExpSolvableFinder, tpl);
then (inExp, false, tpl);

// otherwise
case (DAE.ASUB(),_)
case (DAE.ASUB(), _)
then fail();

case (DAE.TSUB(exp=e1),tpl) equation
case (DAE.TSUB(exp=e1), tpl) equation
(_, tpl) = Expression.traverseExpTopDown(e1, traversingincidenceRowExpSolvableFinder, tpl);
then (inExp, false, tpl);

case (DAE.CREF(componentRef=cr),(vars, pa, ofunctionTree)) equation
case (DAE.CREF(componentRef=cr), (vars, pa, ofunctionTree)) equation
(varslst, p) = BackendVariable.getVar(cr, vars);
pa = incidenceRowExp1(varslst, p, pa, 0);
then (inExp, false,(vars, pa, ofunctionTree));

case (DAE.CALL(path=Absyn.IDENT(name="der"),expLst={DAE.CREF(componentRef=cr)}),(vars, pa, ofunctionTree)) equation
case (DAE.CALL(path=Absyn.IDENT(name="der"), expLst={DAE.CREF(componentRef=cr)}), (vars, pa, ofunctionTree)) equation
(varslst, p) = BackendVariable.getVar(cr, vars);
pa = incidenceRowExp1(varslst, p, pa, 1);
then (inExp, false,(vars, pa, ofunctionTree));
Expand Down Expand Up @@ -7769,8 +7769,8 @@ protected
Real tg,t1,t2;
algorithm
tg := System.realtimeTock(ClockIndexes.RT_PROFILER0);
t1 := getGlobalRoot(Global.profilerTime1Index);
t2 := getGlobalRoot(Global.profilerTime2Index);
t1 := profilertime1();
t2 := profilertime2();
print("Time all: "); print(realString(tg)); print("\n");
print("Time t1: "); print(realString(t1)); print("\n");
print("Time t2: "); print(realString(t2)); print("\n");
Expand Down
11 changes: 4 additions & 7 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -1852,13 +1852,10 @@ public function subscriptIsFirst
input DAE.Subscript inSubscript;
output Boolean outIsFirst;
algorithm
outIsFirst := match(inSubscript)
local

case DAE.INDEX(exp = DAE.ICONST(1)) then true;
case DAE.INDEX(exp = DAE.BCONST(false)) then true;
case DAE.INDEX(exp = DAE.ENUM_LITERAL(index = 1)) then true;

outIsFirst := match (inSubscript)
case DAE.INDEX(exp=DAE.ICONST(1)) then true;
case DAE.INDEX(exp=DAE.BCONST(false)) then true;
case DAE.INDEX(exp=DAE.ENUM_LITERAL(index=1)) then true;
end match;
end subscriptIsFirst;

Expand Down
11 changes: 8 additions & 3 deletions SimulationRuntime/c/simulation/solver/events.c
Expand Up @@ -249,12 +249,14 @@ void handleEvents(DATA* data, LIST* eventLst, double *eventTime, SOLVER_INFO* so
data->localData[0]->timeValue = *eventTime;
/* time = data->localData[0]->timeValue; */

if (useStream[LOG_EVENTS]) {
for(it = listFirstNode(eventLst); it; it = listNextNode(it)) {
if (useStream[LOG_EVENTS])
{
for(it = listFirstNode(eventLst); it; it = listNextNode(it))
{
long ix = *((long*) listNodeData(it));
int *eq_indexes;
const char *exp_str = data->callback->zeroCrossingDescription(ix,&eq_indexes);
infoStreamPrintWithEquationIndexes(LOG_EVENTS, 0, eq_indexes, "[%ld] %s", ix, exp_str);
infoStreamPrintWithEquationIndexes(LOG_EVENTS, 0, eq_indexes, "[%ld] %s", ix+1, exp_str);
}
}

Expand Down Expand Up @@ -283,6 +285,9 @@ void handleEvents(DATA* data, LIST* eventLst, double *eventTime, SOLVER_INFO* so
}

listClear(eventLst);

printRelations(data, LOG_EVENTS);
printZeroCrossings(data, LOG_EVENTS);
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions SimulationRuntime/c/simulation/solver/model_help.c
Expand Up @@ -381,7 +381,9 @@ void printRelations(DATA *data, int stream)

infoStreamPrint(stream, 1, "status of relations at time=%.12g", data->localData[0]->timeValue);
for(i=0; i<data->modelData.nRelations; i++)
infoStreamPrint(stream, 0, "[%ld] %s = %c | pre(%s) = %c", i+1, data->callback->relationDescription(i), data->simulationInfo.relations[i] ? 'T' : 'F', data->callback->relationDescription(i), data->simulationInfo.relationsPre[i] ? 'T' : 'F');
{
infoStreamPrint(stream, 0, "[%ld] (pre: %s) %s = %s", i+1, data->simulationInfo.relationsPre[i] ? " true" : "false", data->simulationInfo.relations[i] ? " true" : "false", data->callback->relationDescription(i));
}
messageClose(stream);

TRACE_POP
Expand Down Expand Up @@ -411,7 +413,7 @@ void printZeroCrossings(DATA *data, int stream)
{
int *eq_indexes;
const char *exp_str = data->callback->zeroCrossingDescription(i,&eq_indexes);
infoStreamPrintWithEquationIndexes(stream, 0, eq_indexes, "[%ld] %s = %g | pre(%s) = %g", i+1, exp_str, data->simulationInfo.zeroCrossings[i], exp_str, data->simulationInfo.zeroCrossingsPre[i]);
infoStreamPrintWithEquationIndexes(stream, 0, eq_indexes, "[%ld] (pre: %2.g) %2.g = %s", i+1, data->simulationInfo.zeroCrossingsPre[i], exp_str, data->simulationInfo.zeroCrossings[i], exp_str);
}
messageClose(stream);

Expand Down

0 comments on commit 74d0abd

Please sign in to comment.