Skip to content

Commit

Permalink
- sample with first sample before start-time of the simulation is now…
Browse files Browse the repository at this point in the history
… treated correctly

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15936 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 30, 2013
1 parent f6441b6 commit b08629a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions SimulationRuntime/c/simulation/solver/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,22 @@ void initSample(DATA* data, double startTime, double stopTime)
data->simulationInfo.nextSampleEvent = stopTime + 1.0; /* should never be reached */
for(i=0; i<data->modelData.nSamples; ++i)
{
if(startTime < data->modelData.samplesInfo[i].start)
if(startTime < data->modelData.samplesInfo[i].start) {
data->simulationInfo.nextSampleTimes[i] = data->modelData.samplesInfo[i].start;
else
data->simulationInfo.nextSampleTimes[i] = data->modelData.samplesInfo[i].start + ceil((data->modelData.samplesInfo[i].start - startTime) / data->modelData.samplesInfo[i].interval) * data->modelData.samplesInfo[i].interval;
} else {
data->simulationInfo.nextSampleTimes[i] = data->modelData.samplesInfo[i].start + ceil((startTime-data->modelData.samplesInfo[i].start) / data->modelData.samplesInfo[i].interval) * data->modelData.samplesInfo[i].interval;
}

if((i == 0) || (data->simulationInfo.nextSampleTimes[i] < data->simulationInfo.nextSampleEvent))
if((i == 0) || (data->simulationInfo.nextSampleTimes[i] < data->simulationInfo.nextSampleEvent)) {
data->simulationInfo.nextSampleEvent = data->simulationInfo.nextSampleTimes[i];
}
}

if(stopTime < data->simulationInfo.nextSampleEvent)
if(stopTime < data->simulationInfo.nextSampleEvent) {
DEBUG(LOG_EVENTS, "there are no sample-events");
else
} else {
DEBUG1(LOG_EVENTS, "first sample-event at t = %g", data->simulationInfo.nextSampleEvent);
}
}


Expand Down

0 comments on commit b08629a

Please sign in to comment.