VMD-L Mailing List
From: Stéphane Pezennec (stephane.pezennec_at_rennes.inra.fr)
Date: Thu Feb 24 2011 - 03:05:22 CST
- Next message: Jérôme Hénin: "Re: RMSF measurement"
- Previous message: David Joiner: "Re: Compiling on Windows"
- In reply to: John Stone: "Re: Incorrect results from 'measure dipole -masscenter'"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Le mercredi 23 février à 13h55 (-0600), John Stone a écrit :
> I took a close look at this, and I think I've found what's going
> wrong with the -masscenter case:
> double mscale = totalq / (totalm * sel->selected);
>
> This is dividing by both total mass and by the number of selected
> atoms, I believe it should only be dividing by total mass:
> double mscale = totalq / totalm;
>
> This should account for the difference between the Tcl proc Stephane
> wrote vs. the output from "measure dipole" with -masscenter.
> I will double check this and commit the fix if I didn't miss something
> here.
Dear all,
I was not sure about the meaning of 'sel->selected' when I looked at
Measure.C, but I think that John is right: the division by the number of
atoms is justified in the 'geometrical center' case (which works
correctly), but not in the 'center of mass' case.
In a quick test, a modified script (see below) with the extra division
by the number of atoms gives the same (incorrect) result as the old
'measure dipole -masscenter'.
Thanks and congratulations for your reactivity!
Regards,
Stéphane
[Tcl]
proc dipoleX {selection} {
set cdm [measure center $selection weight mass]
set p [veczero]
set cht 0.0
foreach pos [$selection get {x y z}] charge [$selection get charge] {
set p [vecadd $p [vecscale $charge $pos ]]
set cht [expr $cht + $charge]
}
puts $cht
return [vecsub $p [vecscale [expr $cht / [$selection num]] $cdm]]
}
[/Tcl]
-- Stéphane Pezennec
- Next message: Jérôme Hénin: "Re: RMSF measurement"
- Previous message: David Joiner: "Re: Compiling on Windows"
- In reply to: John Stone: "Re: Incorrect results from 'measure dipole -masscenter'"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]