VMD-L Mailing List
From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Thu Sep 08 2011 - 19:51:54 CDT
- Next message: Christian Wohlschlager: "cionize"
- Previous message: kirtana S: "output values in my script"
- In reply to: kirtana S: "output values in my script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
On Thu, Sep 8, 2011 at 6:38 PM, kirtana S <skirtana4_at_gmail.com> wrote:
> I want to know where I am going wrong here
> using the script as below
>
> set sum 0
> foreach mass [$selection get mass] {
> set sum [expr $sum + $mass]
> }
> puts "mass is sum $sum"
> set com 0
> foreach coord [$sel get {x}] {
> set com [vecadd $com [$vecscale $sum $coord]]
> }
> puts "x is $com"
>
> though this runs my value for center of mass coordinate for x is a bit weird
> as my output says
> x is -17586.98
>
> where am i going wrong here
your algorithm for computing the CoM is wrong
you need to compute:
CoM = Sum_i(m_i*x_i) / Sum_i(m_i)
but you do compute:
Sum_i( Sum_i(m_i) * x_i)
axel.
> Thanks
> kirtana
-- Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0 Institute for Computational Molecular Science Temple University, Philadelphia PA, USA.
- Next message: Christian Wohlschlager: "cionize"
- Previous message: kirtana S: "output values in my script"
- In reply to: kirtana S: "output values in my script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]