# [gmx-users] g_dipoles

David spoel at xray.bmc.uu.se
Tue Nov 15 20:54:16 CET 2005

```On Tue, 2005-11-15 at 14:33 -0500, Viswanadham Sridhara wrote:
> Thanks David.
> One more quick question.
> g_dipoles takes the molecule number unlike atom number for g_density.
> So if I ran a simulation, is there any way out later to divide the
> molecule into 2 seperate entities and find the dipole moment for these
> 2 entities.
> In other words if i ran the simulation with one kind of molecule which
> has a head and tail, and later I want to seperately calculate the
> dipole moment for the head and for the tail, is there any other way
> instead of re-running the entire simulation by dividing these two
> groups.......
> ((((     A has B and C entities, I want to find the dipole moment of B
> and C separately.    ))))
> I hope my question is clear...

As with perl, there are many ways to do things. Finding out how many is
left as an exercise for the reader.

To start of with, you can use tpbconv to create a tpr file in which all
but the charges your are interested in are zero. Note that you want
neutral groups, otherwise the meaning of the dipole is undefined.

A second, somewhat more difficult possibility is to make a new topology
with different molecule definitions.

> Thanks,
> Viswam.
>
> On 11/10/05, David <spoel at xray.bmc.uu.se> wrote:
>         On Thu, 2005-11-10 at 08:51 -0500, Viswanadham Sridhara wrote:
>         > Hi again,
>         > Is < |M| >\S2\N intentionally made equal to < |M|\S2\N > for
>         t=0? I
>         > ask this question because, the difference of these two terms
>         is almost
>         > zero in every calculation. I am not able to understand
>         exactly how
>         > each term is calculated, I understand how epsilon, kirkwood
>         factor,
>         > moments in each direction and total moment are calculated,
>         but I dont
>         > exactly understand how these fluctuations are
>         calculated.......
>         > Hope someone clarifies to me briefly how they are calculated
>         at t =0
>         > and for t = 0 + of the simulation.
>         For a single step this is by definition correct. Note that M
>         is a vector
>         of length 3.
>
>
>         > Thanks in advance,
>         > Viswam.
>         >
>         > On 11/9/05, David <spoel at xray.bmc.uu.se> wrote:
>         >         On Wed, 2005-11-09 at 15:36 -0500, Viswanadham
>         Sridhara wrote:
>         >         > Hello again,
>         >
>         >         > The first two vectors < |M|\S2\N > and < |M| >\S2
>         \N" are
>         >         assumed to be
>         >         > equal in the very first time step, but from 4ps in
>         th is
>         >         case, they
>         >         > are different, can anyone tell me how they are
>         calculated.
>         >         > I understand how they are calculated at t-0,
>         >         >   sum[(M\sx \N)^2 (M\sy \N )^2 (M\sz \N)^2] and it
>         >         equal for
>         >         > both < |M|\S2\N > and < |M| >\S2\N", so that their
>         ratio is
>         >         1, 4th
>         >         > column in second file........
>         >         > But how are they calculated for t =4 ...and so
>         on.....
>         >
>         >         The same way, here is the source code from
>         gmx_dipoles.c (e2d
>         >         converts e
>         >         nm to Debye).
>         >
>         >         void mol_dip(int k0,int k1,atom_id ma[],rvec x
>         [],t_atom atom
>         >         [],rvec mu)
>         >         {
>         >           int  k,kk,m;
>         >           real q;
>         >
>         >           clear_rvec(mu);
>         >           for(k=k0; (k<k1); k++) {
>         >             kk = ma[k];
>         >             q  = e2d(atom[kk].q);
>         >             for(m=0; (m<DIM); m++)
>         >               mu[m] += q*x[kk][m];
>         >           }
>         >         }
>         >
>         >         >
>         >         > --------------------
>         >         >
>         >         > I hope I am clear this time....
>         >         > Thanks in advance
>         >         >
>         >         > Viswam..
>         >         >
>         >         >
>         >         >
>         >         >
>         >         > On 11/9/05, Viswanadham Sridhara <
>         muta.mestri at gmail.com>
>         >         wrote:
>         >         >         Hello David,
>         >         >         Then why are the files 11.xvg and 111.xvg
>         same as
>         >         first half
>         >         >         of 1.xvg and the second half of 1.xvg
>         respectively,
>         >         in other
>         >         >         words the total dipole moment of the
>         frames for the
>         >         whole
>         >         >         trajectory is same as when calculated
>         separately for
>         >         the first
>         >         >         and second halves and concatenated, but
>         not the
>         >         dipole plus
>         >         >         fluctuations...........(22.xvg and 222.xvg
>         are
>         >         different
>         >         >         compared to 2.xvg)...
>         >         >         Thanks,
>         >         >
>         >         >
>         >         >
>         >         >         On 11/9/05, David <spoel at xray.bmc.uu.se>
>         wrote:
>         >         >                 On Wed, 2005-11-09 at 14:38 -0500,
>         >         >                 Sridhara wrote:
>         >         >                 > Hello Everyone,
>         >         >                 > Can anyone explain me how
>         g_dipoles
>         >         exactly work?
>         >         >                 > I am just briefly explaining
>         what I did.
>         >         >                 > a) I took the whole trajectory
>         and tried
>         >         to find
>         >         >                 dipole moment, --
>         >         >                 > >full.xvg (This is with option -
>         o)
>         >         >                 > b)then i divided the whole
>         trajectory into
>         >         two parts
>         >         >                 and tried to find
>         >         >                 > the dipole moment, first half--
>         >fh.xvg and
>         >         second
>         >         >                 half sh.xvg.
>         >         >                 > Obviously fh.xvg and sh.xvg
>         combined is
>         >         equal to
>         >         >                 full.xvg.
>         >         >                 >
>         >         >                 > But, when i use option -a in
>         g_dipoles,
>         >         and tried to
>         >         >                 find <Mu>^2 -
>         >         >                 > <Mu^2> for the whole trajectory,
>         the n
>         >         umbers I
>         >         >                 found are different
>         >         >                 > for the trajectory when divided
>         into two
>         >         parts.
>         >         >                 >
>         >         >                 > -------------------
>         >         >                 > g_dipoles -f full.gro -s
>         dppc.tpr -o 1 -a
>         >         2 -mu
>         >         >                 2.273 -mumax 5.0 -
>         >         >                 > epsilonRF 78.5
>         >         >                 > g_dipoles -f firsthalf.gro -s
>         dppc.tpr -o
>         >         11 -a 22 -
>         >         >                 mu 2.273 -mumax
>         >         >                 > 5.0 -epsilonRF 78.5
>         >         >                 > g_dipoles -f secondhalf.gro -s
>         dppc.tpr -o
>         >         111 -a
>         >         >                 222 -mu 2.273 -mumax
>         >         >                 > 5.0 -epsilonRF 78.5
>         >         >                 >
>         -------------------------------------
>         >         >                 >
>         >         >                 > In other words,  concatenating
>         11 and 111
>         >         gives me
>         >         >                 1.xvg, but not with
>         >         >                 > 22 and 222......
>         >         >                 > How does Gromacs calculate
>         <Mu>^2 and
>         >         <Mu^2>......
>         >         >                 Mu = Sum q R
>         >         >                 where Mu and R are vectors.
>         >         >
>         >         >                 Obviously if you compare two
>         single
>         >         coordinate files
>         >         >                 the results will be
>         >         >                 different.
>         >         >
>         >         >                 > Thanks in advance,
>         >         >                 > Viswam.
>         >         >                 >
>         >         >                 >
>         >         >                 >
>         >         >                 > --
>         >         >                 > Viswanadham Sridhara,
>         >         >                 > Graduate Research Assistant,
>         >         >                 > Old Dominion University,
>         "VIRGINIA".
>         >         >                 >
>         >         _______________________________________________
>         >         >                 > gmx-users mailing list
>         >         >                 > gmx-users at gromacs.org
>         >         >                 >
>         >         http://www.gromacs.org/mailman/listinfo/gmx-users
>         >         >                 > Please don't post (un)subscribe
>         requests
>         >         to the
>         >         >                 list. Use the
>         >         >                 > www interface or send it to gmx-
>         users-
>         >         >                 request at gromacs.org.
>         >         >                 --
>         >         >                 David.
>         >         >
>         >
>         ________________________________________________________________________
>         >         >                 David van der Spoel, PhD, Assoc.
>         Prof.,
>         >         Molecular
>         >         >                 Biophysics group,
>         >         >                 Dept. of Cell and Molecular
>         Biology, Uppsala
>         >         >                 University.
>         >         >                 Husargatan 3, Box
>         596,          75124
>         >         Uppsala, Sweden
>         >         >                 phone:  46 18 471
>         4205          fax: 46 18
>         >         511 755
>         >         >
>         spoel at xray.bmc.uu.se    spoel at gromacs.org
>         >         >                 http://xray.bmc.uu.se/~spoel
>         >         >                 ++++++++++++++++++++++++++++++++++
>         ++++++++++
>         >         ++++++++++
>         >         >                 ++++++++++++++++++
>         >         >
>         >         >
>         >         _______________________________________________
>         >         >                 gmx-users mailing list
>         >         >                 gmx-users at gromacs.org
>         >         >
>         http://www.gromacs.org/mailman/listinfo/gmx-
>         >         users
>         >         >                 Please don't post (un)subscribe
>         requests to
>         >         the list.
>         >         >                 Use the
>         >         >                 www interface or send it to gmx-
>         users-
>         >         >                 request at gromacs.org.
>         >         >
>         >         >
>         >         >
>         >         >         --
>         >         >         Viswanadham Sridhara,
>         >         >         Graduate Research Assistant,
>         >         >         Old Dominion University, "VIRGINIA".
>         >         >
>         >         >
>         >         >
>         >         >
>         >         > --
>         >         > Viswanadham Sridhara,
>         >         > Graduate Research Assistant,
>         >         > Old Dominion University, "VIRGINIA".
>         >         > _______________________________________________
>         >         > gmx-users mailing list
>         >         > gmx-users at gromacs.org
>         >         > http://www.gromacs.org/mailman/listinfo/gmx-users
>         >         > Please don't post (un)subscribe requests to the
>         list. Use
>         >         the
>         >         > www interface or send it to gmx-users-
>         request at gromacs.org.
>         >         --
>         >         David.
>         >
>         ________________________________________________________________________
>         >         David van der Spoel, PhD, Assoc. Prof., Molecular
>         Biophysics
>         >         group,
>         >         Dept. of Cell and Molecular Biology, Uppsala
>         University.
>         >         Husargatan 3, Box 596,          75124 Uppsala,
>         Sweden
>         >         phone:  46 18 471 4205          fax: 46 18 511 755
>         >         spoel at xray.bmc.uu.se    spoel at gromacs.org
>         >         http://xray.bmc.uu.se/~spoel
>         >         ++++++++++++++++++++++++++++++++++++++++++++++++++++
>         ++++++++++
>         >         ++++++++++
>         >
>         >         _______________________________________________
>         >         gmx-users mailing list
>         >         gmx-users at gromacs.org
>         >         http://www.gromacs.org/mailman/listinfo/gmx-users
>         >         Please don't post (un)subscribe requests to the
>         list. Use the
>         >         www interface or send it to gmx-users-
>         request at gromacs.org.
>         >
>         >
>         >
>         > --
>         > Viswanadham Sridhara,
>         > Graduate Research Assistant,
>         > Old Dominion University, "VIRGINIA".
>         > _______________________________________________
>         > gmx-users mailing list
>         > gmx-users at gromacs.org
>         > http://www.gromacs.org/mailman/listinfo/gmx-users
>         > Please don't post (un)subscribe requests to the list. Use
>         the
>         > www interface or send it to gmx-users-request at gromacs.org.
>         --
>         David.
>         ________________________________________________________________________
>         David van der Spoel, PhD, Assoc. Prof., Molecular Biophysics
>         group,
>         Dept. of Cell and Molecular Biology, Uppsala University.
>         Husargatan 3, Box 596,          75124 Uppsala, Sweden
>         phone:  46 18 471 4205          fax: 46 18 511 755
>         spoel at xray.bmc.uu.se    spoel at gromacs.org
>         http://xray.bmc.uu.se/~spoel
>         ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>         ++++++++++
>
>         _______________________________________________
>         gmx-users mailing list
>         gmx-users at gromacs.org
>         http://www.gromacs.org/mailman/listinfo/gmx-users
>         Please don't post (un)subscribe requests to the list. Use the
>         www interface or send it to gmx-users-request at gromacs.org.
>
>
>
> --
> Graduate Research Assistant,
> Old Dominion University, "VIRGINIA".
> _______________________________________________
> gmx-users mailing list
> gmx-users at gromacs.org
> http://www.gromacs.org/mailman/listinfo/gmx-users
> Please don't post (un)subscribe requests to the list. Use the
> www interface or send it to gmx-users-request at gromacs.org.
--
David.
________________________________________________________________________
David van der Spoel, PhD, Assoc. Prof., Molecular Biophysics group,
Dept. of Cell and Molecular Biology, Uppsala University.
Husargatan 3, Box 596,          75124 Uppsala, Sweden
phone:  46 18 471 4205          fax: 46 18 511 755
spoel at xray.bmc.uu.se    spoel at gromacs.org   http://xray.bmc.uu.se/~spoel
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

```