espressomd / espresso

The ESPResSo package
https://espressomd.org
GNU General Public License v3.0
230 stars 188 forks source link

Velocity Verlet step in documentation has a typo #4930

Closed jhossbach closed 4 months ago

jhossbach commented 5 months ago

In the documentation (https://espressomd.github.io/doc/integration.html#velocity-verlet-algorithm) the force used for the first half step is $F(x(t), v(t-\Delta t/2), t)$ but in the code it uses the force at time $t$ instead:

https://github.com/espressomd/espresso/blob/abb087c7027b926687efb53a5ac9630d53488923/src/core/integrators/velocity_verlet_inline.hpp#L34-L45

Used in https://github.com/espressomd/espresso/blob/abb087c7027b926687efb53a5ac9630d53488923/src/core/integrate.cpp#L436

(Note the calculate_forces before it calls integrator_step_1

christophlohrmann commented 5 months ago

the code does what the doc says. whether that is correct, is not obvious for velocity dependent forces (cited literature makes no statement about such forces) in step 4, the velocity argument to the force is missing (same as in step 3)

jngrad commented 5 months ago

Unless I'm overlooking something, at step 4 we have forces calculated based on $F(x(t+\Delta t), v(t+\Delta t/2), t+\Delta t)$, then at the next integration step, step 1 becomes $F(x(t+\Delta t), v(t+\Delta t/2+\Delta t), t+\Delta t)$ i.e. $F(x(t'), v(t'-\Delta t/2), t')$. Regarding velocity-dependent forces (thermostat friction and LB particle coupling), we have tests to make sure they are properly set at the correct place w.r.t the two half-time integration steps.

jngrad commented 5 months ago

Offline discussion: the user guide is consistent with the C++ code. There is only one typo to fix.