Author: bugman Date: Wed Jul 9 16:13:45 2008 New Revision: 6888 URL: http://svn.gna.org/viewcvs/relax?rev=6888&view=rev Log: Created the average_rdc_5D() function. This calculates the average RDC for an ensemble set of XH bond vectors, using the 5D alignment tensor notation. Modified: branches/rdc_analysis/maths_fns/rdc.py Modified: branches/rdc_analysis/maths_fns/rdc.py URL: http://svn.gna.org/viewcvs/relax/branches/rdc_analysis/maths_fns/rdc.py?rev=6888&r1=6887&r2=6888&view=diff ============================================================================== --- branches/rdc_analysis/maths_fns/rdc.py (original) +++ branches/rdc_analysis/maths_fns/rdc.py Wed Jul 9 16:13:45 2008 @@ -19,6 +19,56 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # ############################################################################### - + # Module docstring. """Module containing functions for the calculation of RDCs.""" + + +def average_rdc_5D(vect, K, Axx, Ayy, Axy, Axz, Ayz): + """Calculate the average RDC for an ensemble set of XH bond vectors, using the 5D notation. + + This function calculates the average RDC for a set of XH bond vectors from a structural + ensemble, using the 5D vector form of the alignment tensor. The formula for this ensemble + average RDC value is:: + + _K_ + 1 \ + <RDC_i> = - > RDC_ik (theta), + K /__ + k=1 + + where K is the total number of structures, k is the index over the multiple structures, RDC_ik + is the back-calculated RDC value for spin system i and structure k, and theta is the parameter + vector consisting of the alignment tensor parameters {Axx, Ayy, Axy, Axz, Ayz}. The + back-calculated RDC is given by the formula:: + + RDC_ik(theta) = (x**2 - z**2)Axx + (y**2 - z**2)Ayy + 2x.y.Axy + 2x.z.Axz + 2y.z.Ayz. + + + @param vect: The XH bond vector matrix. The first dimension corresponds to the + structural index, the second dimension is the coordinates of the vector. + @type vect: numpy matrix + @param K: The total number of structures. + @type K: int + @param Axx: The xx component of the alignment tensor. + @type Axx: float + @param Ayy: The yy component of the alignment tensor. + @type Ayy: float + @param Axy: The xy component of the alignment tensor. + @type Axy: float + @param Axz: The xz component of the alignment tensor. + @type Axz: float + @param Ayz: The yz component of the alignment tensor. + @type Ayz: float + """ + + # Initial back-calculated RDC value. + val = 0.0 + + # Loop over the structures k. + for k in xrange(K): + # Back-calculate the RDC. + val = val + (vect[k, 1]**2 - vect[k, 3]**2)*Axx + (vect[k, 2]**2 - vect[k, 3]**2)*Ayy + 2*vect[k, 1]*vect[k, 2]*Axy + 2*vect[k, 1]*vect[k, 3]*Axz + 2*vect[k, 2]*vect[k, 3]*Ayz + + # Return the average RDC. + return val / K