andreadelprete / consim

GNU General Public License v3.0
14 stars 1 forks source link

Results with seldom updates of matrix exponential #16

Closed andreadelprete closed 3 years ago

andreadelprete commented 4 years ago

I've carried out some preliminary tests to check this idea: what if we did not update the matrix exponential at every iteration? This would save a lot of computation time, and if the force prediction remains accurate over a long horizon, maybe we don't lose much accuracy. Here are the integration errors I've got by updating the matrix exponential every 1, 2 and 4 iterations: integrator_error_with_seldom_expm_updates Updating every 2 iterations we don't lose any accuracy (for the time steps tested, but we would for larger time steps). Updating every 4 iterations we have a large loss of accuracy for ndt = 8 and 16, but everything remains stable. For ndt>=32 instead we have no loss of accuracy.

Overall, this test shows that the force predictions obtained with the matrix exponential are more accurate than the other terms of the dynamics (M, h and J), so we don't need to update them very often to achieve high accuracy. This affects much more the "right part" of our plots, that depicts the high accuracy cases. For the cases with large time steps (>1 ms), not updating the matrix exponential at every iteration would probably degrade performance. I'm gonna run more tests and update the issue soon.

andreadelprete commented 4 years ago

Here it is a more complete version of the plot above: integrator_error_with_seldom_expm_updates The take home message is always the same: we don't need to update the matrix exponential (roughly) more than once every ms because doing so doesn't improve accuracy (in the range of time steps tested). Therefore, if the integration accuracy you get with a time step of 1 ms is not enough, you can simply update more frequently the other terms of the dynamics (M, h, J), while keeping updating the matrix exponential only every 1 ms. That's gonna look very good in a plot accuracy VS computation time, where we would see a fast decrease of the error for a small increase of computation!

andreadelprete commented 3 years ago

I've added the possibility to set the frequency of the updates of the matrix exponential in the c++ implementation of the Exponential simulator. However, at the moment I haven't optimized the code to exploit this feature in terms of computation time because it would mainly benefit the high accuracy simulations, whereas I am currently more interested in the low-accuracy but high-speed simulations.