Skip to content

Commit

Permalink
Handling time events at one time instant at once
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23780 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
nimen committed Dec 15, 2014
1 parent df6a438 commit 60b2c68
Showing 1 changed file with 29 additions and 38 deletions.
67 changes: 29 additions & 38 deletions SimulationRuntime/cpp/Core/SimController/SimManager.cpp
Expand Up @@ -578,7 +578,7 @@ void SimManager::runSingleProcess()
{
_timeevent_system->handleTimeEvent(_timeeventcounter);
}
_cont_system->evaluateODE(IContinuous::CONTINUOUS); // vxworksupdate
_cont_system->evaluateAll(IContinuous::CONTINUOUS); // vxworksupdate
_event_system->getZeroFunc(zeroVal_new);

for (int i = 0; i < _dimZeroFunc; i++)
Expand All @@ -605,50 +605,41 @@ void SimManager::runSingleProcess()
for (; iter != _tStops[0].end(); ++iter)
{
endTime = iter->first;
if (endTime - startTime < UROUND)

// Setzen von Start- bzw. Endzeit und initial step size
_solver->setStartTime(startTime);
_solver->setEndTime(endTime);
_solver->setInitStepSize(_config->getGlobalSettings()->gethOutput());
_solver->solve(_solverTask);

if (_solverTask & ISolver::FIRST_CALL)
{
startTime = endTime;
_timeeventcounter[iter->second]++;
_timeevent_system->handleTimeEvent(_timeeventcounter);
_cont_system->evaluateODE(IContinuous::CONTINUOUS); // vxworksupdate
_solverTask = ISolver::SOLVERCALL(_solverTask ^ ISolver::FIRST_CALL);
_solverTask = ISolver::SOLVERCALL(_solverTask | ISolver::RECALL);
}
startTime = endTime;
if (_dimtimeevent)
{
// Find all time events at the current time
while(abs(iter->first - endTime) <1e4*UROUND)
{
_timeeventcounter[iter->second]++;
iter++;
}
// set the iterator back to the current end time
iter--;

_timeevent_system->handleTimeEvent(_timeeventcounter);
_cont_system->evaluateAll(IContinuous::CONTINUOUS); // vxworksupdate
_event_system->getZeroFunc(zeroVal_new);
for (int i = 0; i < _dimZeroFunc; i++)
_events[i] = bool(zeroVal_new[i]);
_mixed_system->handleSystemEvents(_events);
//_cont_system->evaluateODE(IContinuous::CONTINUOUS);
//reset time-events
_timeevent_system->handleTimeEvent(_timeeventcounter);
}
else
{
// Setzen von Start- bzw. Endzeit und initial step size
_solver->setStartTime(startTime);
_solver->setEndTime(endTime);
_solver->setInitStepSize(_config->getGlobalSettings()->gethOutput());
_solver->solve(_solverTask);

if (_solverTask & ISolver::FIRST_CALL)
{
_solverTask = ISolver::SOLVERCALL(_solverTask ^ ISolver::FIRST_CALL);
_solverTask = ISolver::SOLVERCALL(_solverTask | ISolver::RECALL);
}
startTime = endTime;
if (_dimtimeevent)
{
_timeeventcounter[iter->second]++;
_timeevent_system->handleTimeEvent(_timeeventcounter);
_cont_system->evaluateODE(IContinuous::CONTINUOUS); // vxworksupdate
_event_system->getZeroFunc(zeroVal_new);
for (int i = 0; i < _dimZeroFunc; i++)
_events[i] = bool(zeroVal_new[i]);
_mixed_system->handleSystemEvents(_events);
//_cont_system->evaluateODE(IContinuous::CONTINUOUS);
//reset time-events
_timeevent_system->handleTimeEvent(_timeeventcounter);
}
}

user_stop = (_solver->getSolverStatus() & ISolver::USER_STOP);

user_stop = (_solver->getSolverStatus() & ISolver::USER_STOP);
if (user_stop)
break;
} // end for time events
Expand Down Expand Up @@ -697,7 +688,7 @@ void SimManager::runSingleProcess()
if (zeroVal_new)
{
_timeevent_system->handleTimeEvent(_timeeventcounter);
_cont_system->evaluateODE(IContinuous::CONTINUOUS); // vxworksupdate
_cont_system->evaluateAll(IContinuous::CONTINUOUS); // vxworksupdate
_event_system->getZeroFunc(zeroVal_new);
for (int i = 0; i < _dimZeroFunc; i++)
_events[i] = bool(zeroVal_new[i]);
Expand Down

0 comments on commit 60b2c68

Please sign in to comment.