Questions about time matching

I found that there are two exceptions in the code about time matching.
One is gdata->dt < FLT_EPSILON.
The other one is gdata->t == previous_t.

The later one is quite easy to understand, and the datatype of gdata->t is double.
So, actually if this exception is triggered, your simulations may be wrong.

However, the former one. gdata->dt < FLT_EPSILON, kind of weird. Because lots of problem, the timesteps are smaller than 1e-7, like underwater explosion, hightspeed water entry, and so on.
So, I am trying to understand the necessity of this exception.
I know this actually avoid the possibility of “t + dt = t”. Is there something else behind this? Moreover, can i just use t = t + (double)dt to fix this problem, and then work normally even a dt < FLT_EPSILON is used?

Hello @JoJo,

the main reason for the restriction is that such small timesteps have severe effects on the accuracy of the integration, due to the use of single-precision everywhere. While these have been significantly mitigated with the uniform accuracy for spatial coordinates and density, a time-step below FLT_EPSILON is still considered critical. Even for something as simple as tracking the time, it becomes impossible for time to advance (in single precision) past 1s of simulated time if the dt is less than machine epsilon.

If your problem has these kind of requirement, you can try removing the condition from the code, but I expect the results to be quite inaccurate due to the loss of precision. A better alternative is to change the unit of measure of time in your problem, e.g. from the second to the millisecond. Since GPUSPH has no implicit dependency on the SI (aside from aesthetic things such as the display of the current simulation time) , simply adjusting all time-dependent quantities of the corresponding scale factor should be enough (of course, remember to adjust it in the other direction when interpreting the data, since e.g. velocities would now be in m/ms!)