[gmx-users] Water out of box? Negative Z-Coordinates

Tsjerk Wassenaar tsjerkw at gmail.com
Tue Apr 1 21:51:26 CEST 2014


Hi GtrAngus,

The code I gave works for any (triclinic) box. The box is a matrix, and
multiplying that with its inverse will give an identity matrix, which can
be regarded a cubic box with length 1.

I think it should be fine working with the pointers like that. The code
snippet changes the values in the array fr.x. Your rvec *pos is just like
an alias for fr.x.

Cheers,

Tsjerk



On Tue, Apr 1, 2014 at 3:22 PM, GtrAngus <maps99 at online.de> wrote:

> Many thanks to both of you! :)
>
> I am not that familiar with C-Code and gromacs. Maybe you could take a look
> at it, that this would be correct for me? Does this code also work for none
> cubic boxes?
>
> // Here begins the actual analysis
> static int analyze_frame(t_topology *top, t_trxframe *fr, t_pbc *pbc,
>               int nr, gmx_ana_selection_t *sel[], void *data)
> {
>     const rvec *pos = fr->x;    // positions
>     const int numAtoms = fr->natoms;    // number of all atoms
>     const rvec box = { fr->box[XX][XX], fr->box[YY][YY], fr->box[ZZ][ZZ] };
> // box size
>
>     // Do I have to change something in the next four lines according to my
> code above?
>     matrix transp,invbox;
>     rvec tmp;
>     transpose(frame.box,transp);
>     m_inv(transp,invbox);
>
>     for (int i=0; i<numAtoms; i++)
>     {
>       mvmul(invbox,fr.x[i],tmp); // Same question for the next five lines
>       tmp[0] -= floor(tmp[0]);
>       tmp[1] -= floor(tmp[1]);
>       tmp[2] -= floor(tmp[2]);
>       mvmul(transp,tmp,fr.x[i]);
>     }
> }
>
> After this code, do I have to work with the tmp or can I use my position
> vector pos? E.g. z-coordinate of particle i is just
>
> pos[i][ZZ];
>
> Or the box size is
>
> box[ZZ];
>
> That is easy to understand for me and I would like to keep it that simple.
> So if it changes the name e.g. from pos to pos2 would be nice :)
>
> Many thanks to you Tsjerk Wassenaar!
>
> --
> View this message in context:
> http://gromacs.5086.x6.nabble.com/Water-out-of-box-Negative-Z-Coordinates-tp5015506p5015541.html
> Sent from the GROMACS Users Forum mailing list archive at Nabble.com.
> --
> Gromacs Users mailing list
>
> * Please search the archive at
> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
> posting!
>
> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>
> * For (un)subscribe requests visit
> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or
> send a mail to gmx-users-request at gromacs.org.
>



-- 
Tsjerk A. Wassenaar, Ph.D.


More information about the gromacs.org_gmx-users mailing list