# [gmx-developers] external potential ?

Pim Schravendijk schraven at mpip-mainz.mpg.de
Fri Feb 13 00:38:52 CET 2004

```Ok, I understand, I have to preserve my kinetic energy.

Then, actually, for a box which hize is at least four times the cutoff, I
could do as follows:

if (x[i][ZZ] > (L/2)) {
x[i][ZZ] = L-x[i][ZZ];
v[i][ZZ] *= -1;
}
And the same for 0

(or variations on this theme)

If I make shure that all my molecules are within z=0 and z=L/2 at the
beginning of the run, I will have introduced a wall and a vacuum, and can
then apply my additional wall potential at z=0 and at z=L/2. This looks
like a very elegant solution to me. Thanks for the tip!

--
Pim Schravendijk - PhD Student
Max Planck Institute for Polymer Research
http://www.mpip-mainz.mpg.de/~schraven/

On Thu, 12 Feb 2004, David wrote:

> On Thu, 2004-02-12 at 20:27, Pim Schravendijk wrote:
> > > If it is that simple you might want to implement it in the update code:
> > >
> > > if (x[i][ZZ] > L) {
> > >   x[i][ZZ] = 2*L-x[i][ZZ];
> > >   v[i][ZZ] *= -1;
> > > }
> > > and similar for zero.
> >
> > Hmm, this would however create a fully-elastic wall if I see it correctly,
> > which is not really what I had in mind. I preferrably want to exclude the
> > energies between atoms and their minimum image neighbours* at the other
> > side of z=0,L out of my energy calculation, or at least out of the force
> > calculation. Just not putting them in the neigbour list during the
> > neighbour search would seem the most elegant solution to this imho.
> >
> that you can do by adding a layer of vacuum beyond z=L which is larger
> than the cut-off.
>
> my solution does represent an elastic wall. if you don't do that you
> have to transfer energy between the wall and the particles...

```