## Bug #18

### Implement position rescaling with Rahman Parrinello barostat.

**Description**

Althougth there is some ongoing work to enhance the barostat with Gromacs, the

current barostat can be made more accurate with a painless change. In

do_update_md, modify the updating of the coordinates to include the change of

the box. In fact, I believe that not doing so was a misunderstanding of the

equations. The differential equation of the coordinates, in the box reference

frame is:

m_i d^2s_i/dt^2 = h^(-1) f_i - m_i G^(-1) dG/dt d s_i/dt

s = coordinates in the box frame

h = box matrix, transposed of Gromacs box

G = h^t t

Looking at Gromacs code in do_update_md and parrinellorahman_pcoupl and

comparing to the equation above we see that the velocity is defined as:

v_i = h ds_i/dt

therefore, the updating of the coordinates should be

dx_i/dt = d(h s_i)/dt = dh/dt * s_i + h * d s_i/dt = = dh/dt * h^(-1) * x_i + v_i = = M * x_i + v_i

(the last step assumes that dh/dt * h^(-1) is symmetric)

### History

#### #1 Updated by Ramon Garcia almost 15 years ago

Created an attachment (id=3)

Patch to implement the feature described.

Do patch < the_patch in the directory of update.c

#### #2 Updated by Ramon Garcia almost 15 years ago

Created an attachment (id=4)

Small correction to the previous patch.

#### #3 Updated by Erik Lindahl almost 15 years ago

Hi Ramon,

Thanks - we'll look into this later. We just have to stabilize 3.3 first, and then get back to working in the

head branch (where this will go).

#### #4 Updated by David van der Spoel about 13 years ago

This bug goes the same fate as 14 but its contents have been copied to the wiki.