Skip to content

Commit 14e5c61

Browse files
committed
- fix #2704 (don't handle impure functions as constant)
- add TRACE information to dassl.c::functionODE_residual and solver_main.c::finishSimulation git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20789 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 3d977ef commit 14e5c61

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

Compiler/BackEnd/RemoveSimpleEquations.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,7 @@ algorithm
15441544
// const
15451545
case (_, _, _, _, _, (vars, shared, eqns, seqns, index, mT, _))
15461546
equation
1547+
true = Expression.isConst(exp); // lochel: this is at least for impure functions needed
15471548
Debug.fcall(Flags.DEBUG_ALIAS, BackendDump.debugStrCrefStrExpStr, ("Const Equation ", cr, " = ", exp, " found.\n"));
15481549
colum = mT[i];
15491550
_ = arrayUpdate(mT, i, index::colum);

Compiler/FrontEnd/Expression.mo

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7201,7 +7201,6 @@ algorithm
72017201

72027202
case (DAE.TUPLE(PR = ae),_) then isConstWorkList(ae,true);
72037203

7204-
72057204
case (DAE.ASUB(exp=e,sub=ae),_) then isConstWorkList(ae,isConstWork(e,true));
72067205

72077206
case (DAE.TSUB(exp=e),_) then isConstWork(e,true);
@@ -7219,7 +7218,6 @@ algorithm
72197218
then isConstWork(e1,isConstWork(e2,true));
72207219

72217220
else false;
7222-
72237221
end match;
72247222
end isConstWork;
72257223

SimulationRuntime/c/simulation/solver/dassl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ int functionODE_residual(double *t, double *y, double *yd, double* cj, double *d
503503
long i;
504504
int saveJumpState;
505505
int success = 0;
506+
507+
TRACE_PUSH
506508

507509
timeBackup = data->localData[0]->timeValue;
508510
data->localData[0]->timeValue = *t;
@@ -524,7 +526,8 @@ int functionODE_residual(double *t, double *y, double *yd, double* cj, double *d
524526

525527
/* get the difference between the temp_xd(=localData->statesDerivatives)
526528
and xd(=statesDerivativesBackup) */
527-
for(i=0; i < data->modelData.nStates; i++) {
529+
for(i=0; i < data->modelData.nStates; i++)
530+
{
528531
delta[i] = data->localData[0]->realVars[data->modelData.nStates + i] - yd[i];
529532
}
530533
success = 1;
@@ -540,6 +543,7 @@ int functionODE_residual(double *t, double *y, double *yd, double* cj, double *d
540543

541544
data->localData[0]->timeValue = timeBackup;
542545

546+
TRACE_POP
543547
return 0;
544548
}
545549

SimulationRuntime/c/simulation/solver/solver_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ int finishSimulation(DATA* data, SOLVER_INFO* solverInfo, const char* outputVari
410410
int ui;
411411

412412
SIMULATION_INFO *simInfo = &(data->simulationInfo);
413+
414+
TRACE_PUSH
413415

414416
/* Last step with terminal()=true */
415417
if(solverInfo->currentTime >= simInfo->stopTime && solverInfo->solverMethod != S_OPTIMIZATION)
@@ -498,6 +500,8 @@ int finishSimulation(DATA* data, SOLVER_INFO* solverInfo, const char* outputVari
498500

499501
rt_tick(SIM_TIMER_TOTAL);
500502
}
503+
504+
TRACE_POP
501505
return retValue;
502506
}
503507

0 commit comments

Comments
 (0)