From: Jelle van Sijl (
Date: Wed Feb 03 2010 - 11:21:33 CST

Dear All,
I would like to compute the molecular dipole moment for a given
selection of atoms. The file contains 4 Wannier centers
per H2O molecule identified by atom name "X".

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

package require pbctools
  set mol [mol new {} waitfor all]
  mol addfile {} waitfor all
  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"]
  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]
    $xsel frame $f
    $xsel set user $ul
  close $fp

which gives the following error message:
atomsel: set: bad data in 0th element

How can I select the right WFC's given a selection of atoms?
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

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