Cumulative Rounding Error in AdvanceModelTime
The current AdvanceModelTime will lose time compared to the time passed in the function if the timestep is not equally divisible by the engines' timestep, this means that time will pass slower in Pulse than on the outside, the rate being dependent on the remainder of the division.
Also with correcting for the difference the error()
log could be downgraded to a warning()
or even just info, as the time not advanced will eventually add up to a timestep.
A possible fix ...
void PulseEngine::AdvanceModelTime(double time, const TimeUnit& unit)
{
double time_s = Convert(time,unit,TimeUnit::s) + m_timestepError;
int count = (int)(time_s / m_Config->GetTimeStep(TimeUnit::s));
if (count == 0)
Error("Requested advancement time is smaller than time step, not advancing.");
for(int i=0;i<count;i++)
AdvanceModelTime();
m_timestepError = time_s - count * m_Config->GetTimeStep(TimeUnit::s);
}