Allow running PE at double precision while LB is at single precision
Currently, precision (real_t
) can only be switched globally between single and double precision. For LB, single precision is sufficient under certain circumstances. For integrating particle trajectories however, single precision almost never suffices for several reasons:
- If your box size is 100 and your particle velocity is 0.001, your relative displacement per time step is 1e-5. That's just two orders of magnitude above the float epsilon. If your box is larger or your velocity is smaller, eventually your displacements would get lost in the epsilon floor.
- Bounce-back force is accumulated in
force_
andtorque_
insideRigidBody
. Much of these force contributions cancel out so that the total force is typically several orders of magnitude smaller than the total of the absolute forces. This leads to huge cancellation errors. - For certain special orientations (like pointing along a cartesian axis), the components of the quaternion are significantly different in magnitude. There is a significant number of arithmetic operations inside the rotational integration by multiplying quaternions. So with small angular velocities, orientations can get "stuck".