Author: bugman Date: Wed Jul 9 16:19:13 2008 New Revision: 6889 URL: http://svn.gna.org/viewcvs/relax?rev=6889&view=rev Log: Created the average_rdc_tensor() function. This is equivalent to the average_rdc_5D() function but takes the full tensor in numpy matrix form rather than the elements of the 5D vector. 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=6889&r1=6888&r2=6889&view=diff ============================================================================== --- branches/rdc_analysis/maths_fns/rdc.py (original) +++ branches/rdc_analysis/maths_fns/rdc.py Wed Jul 9 16:19:13 2008 @@ -72,3 +72,47 @@ # Return the average RDC. return val / K + + +def average_rdc_tensor(vect, K, A): + """Calculate the average RDC for an ensemble set of XH bond vectors, using the 3D tensor. + + This function calculates the average RDC for a set of XH bond vectors from a structural + ensemble, using the 3D tensorial 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. The back-calculated RDC is given by the formula:: + + RDC_ik(theta) = muT . A . mu, + + where mu is the unit XH bond vector, T is the transpose, and A is the alignment tensor matrix. + + + @param vect: The unit XH bond vector matrix. The first dimension corresponds to the + structural index, the second dimension is the coordinates of the unit + vector. + @type vect: numpy matrix + @param K: The total number of structures. + @type K: int + @param A: The alignment tensor. + @type A: numpy rank-2 3D tensor + """ + + # Initial back-calculated RDC value. + val = 0.0 + + # Loop over the structures k. + for k in xrange(K): + # Back-calculate the RDC. + val = val + dot(vect[k], dot(A, vect[k])) + + # Return the average RDC. + return val / K