From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Thu Feb 04 2010 - 05:11:59 CST

On Wed, Feb 3, 2010 at 12:21 PM, Jelle van Sijl <j.vansijl_at_gmail.com> wrote:
> Dear All,

dear jelle,

> I would like to compute the molecular dipole moment for a given
> selection of atoms. The IONS+CENTERS.xyz file contains 4 Wannier centers
> per H2O molecule identified by atom name "X".

please keep in mind that the vast majority of people here still
don't have a clue what you are after with the kind of information
that you provide. i assume that you are asking about a file generated
by a CPMD calculation.

> I've searched the vmd list archive and so far came up with creating a
> user field selection of WFC values:

i don't quite understand what this would supposed to be doing.

> package require pbctools
>  set mol [mol new {GEOM.xyz} waitfor all]
>  mol addfile {IONS+CENTERS.xyz} waitfor all

where is the GEOM.xyz file coming from? it should not
be needed, since the IONS+CENTERS.xyz file is effectively
self-contained.

>  set mol [molinfo top]
>  pbc set {12.50 12.50 12.50} -all
>
>  set xsel [atomselect $mol "name X"]
>  set nf [expr [molinfo $mol get numframes] - 1 ]
>  set nx [$xsel num]
>  set fp [open "WANNIER_CENTER" "r"]

why do you read the WANNIER_CENTER file if you
have already read in the IONS+CENTERS.xyz which
contains the positions of the wannier centers and the
spread contained in add the WANNIER_CENTERS file
is irrelevant for the calculation of the dipole moment.

>  for {set f 0} {$f < $nf} {incr f} {
>    set ul {}
>    for {set i 0} {$i < $nx} {incr i} {
>      gets $fp line
>      lappend ul [lindex $line  1 2 3 4]

this line doesn't make any sense at all. its result will
be empty. check the tcl documentation of the lindex command.

>      }
>    $xsel frame $f
>    $xsel set user $ul
>  }
>  close $fp
>
>
> which gives the following error message:
> atomsel: set: bad data in 0th element

no surprise about this error. see my comment above.

> How can I select the right WFC's given a selection of atoms?

there is no generic answer to this question. in some cases, you
simply cannot (e.g., when you have a non-polar bond, where two
atoms share the wannier centers). if your atom selection contains
a full molecule, the wannier centers should be closer to the non-wannier
center position than a typical bond to a hydrogen, so a selection of
"name X and within 1.0 of (within 1.1 of index 0)" should select the
wannier centers that belong to the first water molecule (assuming the
elements in the IONS+CENTERS.xyz are ordered as O O H H H H).

> Once I have the WFC's in a selection, how can I use vmd to combine these
> with the ion positions such that I get the average dipole moment per
> H2O?

this is actually not really a VMD question, and you can answer
it easily for yourself if you answer the following questions.
what does a wannier center stand for? and how do you compute
a molecular dipole moment from a classical charge distribution?
then just have a look at the VMD documentation.

cheers,
    axel.

> Thanks in advance & kind regards,
> Jelle van Sijl
>
>
>
>
> --
> Jelle van Sijl, MSc.
> PhD student, Department of Petrology
> Faculty of Earth and Life Sciences (FALW)
> VU University Amsterdam, De Boelelaan 1085
> 1081 HV Amsterdam, The Netherlands
> Phone +31 (0)20 5983725
> http://www.falw.vu.nl/petrology
>
>
>

-- 
Dr. Axel Kohlmeyer    akohlmey_at_gmail.com
Institute for Computational Molecular Science
College of Science and Technology
Temple University, Philadelphia PA, USA.