mailr11473 - in /1.3/maths_fns: frame_order.py frame_order_matrix_ops.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on August 11, 2010 - 18:37:
Author: bugman
Date: Wed Aug 11 18:37:35 2010
New Revision: 11473

URL: http://svn.gna.org/viewcvs/relax?rev=11473&view=rev
Log:
Implemented the torsionless isotropic cone frame order model.


Modified:
    1.3/maths_fns/frame_order.py
    1.3/maths_fns/frame_order_matrix_ops.py

Modified: 1.3/maths_fns/frame_order.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/maths_fns/frame_order.py?rev=11473&r1=11472&r2=11473&view=diff
==============================================================================
--- 1.3/maths_fns/frame_order.py (original)
+++ 1.3/maths_fns/frame_order.py Wed Aug 11 18:37:35 2010
@@ -31,7 +31,7 @@
 from generic_fns.frame_order import print_frame_order_2nd_degree
 from maths_fns.alignment_tensor import to_5D, to_tensor
 from maths_fns.chi2 import chi2
-from maths_fns.frame_order_matrix_ops import compile_2nd_matrix_iso_cone, 
compile_2nd_matrix_iso_cone_free_rotor, compile_2nd_matrix_pseudo_ellipse, 
compile_2nd_matrix_pseudo_ellipse_free_rotor, 
compile_2nd_matrix_pseudo_ellipse_torsionless, reduce_alignment_tensor
+from maths_fns.frame_order_matrix_ops import compile_2nd_matrix_iso_cone, 
compile_2nd_matrix_iso_cone_free_rotor,compile_2nd_matrix_iso_cone_torsionless,
 compile_2nd_matrix_pseudo_ellipse, 
compile_2nd_matrix_pseudo_ellipse_free_rotor, 
compile_2nd_matrix_pseudo_ellipse_torsionless, reduce_alignment_tensor
 from maths_fns.rotation_matrix import euler_to_R_zyz as euler_to_R
 from relax_errors import RelaxError
 
@@ -256,6 +256,30 @@
         return chi2(self.red_tensors, self.red_tensors_bc, self.red_errors)
 
 
+    def func_iso_cone_torsionless(self, params):
+        """Target function for torsionless isotropic cone model optimisation.
+
+        This function optimises against alignment tensors.
+
+        @param params:  The vector of parameter values {beta, gamma, theta, 
phi, cone_theta} where the first 2 are the tensor rotation Euler angles, the 
next two are the polar and azimuthal angles of the cone axis, and cone_theta 
is cone opening angle.
+        @type params:   list of float
+        @return:        The chi-squared or SSE value.
+        @rtype:         float
+        """
+
+        # Unpack the parameters.
+        ave_pos_beta, ave_pos_gamma, axis_theta, axis_phi, cone_theta = 
params
+
+        # Generate the 2nd degree Frame Order super matrix.
+        frame_order_2nd = 
compile_2nd_matrix_iso_cone_torsionless(self.frame_order_2nd, self.rot, 
self.z_axis, self.cone_axis, axis_theta, axis_phi, cone_theta)
+
+        # Reduce and rotate the tensors.
+        self.reduce_and_rot(0.0, ave_pos_beta, ave_pos_gamma, 
frame_order_2nd)
+
+        # Return the chi-squared value.
+        return chi2(self.red_tensors, self.red_tensors_bc, self.red_errors)
+
+
     def func_pseudo_ellipse(self, params):
         """Target function for pseudo-elliptic cone model optimisation.
 

Modified: 1.3/maths_fns/frame_order_matrix_ops.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/maths_fns/frame_order_matrix_ops.py?rev=11473&r1=11472&r2=11473&view=diff
==============================================================================
--- 1.3/maths_fns/frame_order_matrix_ops.py (original)
+++ 1.3/maths_fns/frame_order_matrix_ops.py Wed Aug 11 18:37:35 2010
@@ -121,6 +121,68 @@
 
     # Populate the Frame Order matrix in the eigenframe.
     populate_2nd_eigenframe_iso_cone_free_rotor(matrix, s1)
+
+    # Average position rotation.
+    two_vect_to_R(z_axis, cone_axis, R)
+
+    # Rotate and return the frame order matrix.
+    return rotate_daeg(matrix, R)
+
+
+def compile_2nd_matrix_iso_cone_torsionless(matrix, R, z_axis, cone_axis, 
theta_axis, phi_axis, cone_theta):
+    """Generate the rotated 2nd degree Frame Order matrix for the 
torsionless isotropic cone.
+
+    The cone axis is assumed to be parallel to the z-axis in the eigenframe.
+
+
+    @param matrix:      The Frame Order matrix, 2nd degree to be populated.
+    @type matrix:       numpy 9D, rank-2 array
+    @param R:           The rotation matrix to be populated.
+    @type R:            numpy 3D, rank-2 array
+    @param z_axis:      The molecular frame z-axis from which the cone axis 
is rotated from.
+    @type z_axis:       numpy 3D, rank-1 array
+    @param cone_axis:   The storage structure for the cone axis.
+    @type cone_axis:    numpy 3D, rank-1 array
+    @param theta_axis:  The cone axis polar angle.
+    @type theta_axis:   float
+    @param phi_axis:    The cone axis azimuthal angle.
+    @type phi_axis:     float
+    @param cone_theta:  The cone opening angle.
+    @type cone_theta:   float
+    """
+
+    # Zeros.
+    for i in range(9):
+        for j in range(9):
+            matrix[i, j] = 0.0
+
+    # Repetitive trig calculations.
+    cos_tmax = cos(cone_theta)
+    cos_tmax2 = cos_tmax**2
+
+    # Diagonal.
+    matrix[0, 0] = (3.0*cos_tmax2 + 6.0*cos_tmax + 15.0) / 24.0
+    matrix[1, 1] = (cos_tmax2 + 10.0*cos_tmax + 13.0) / 24.0
+    matrix[2, 2] = (4.0*cos_tmax2 + 10.0*cos_tmax + 10.0) / 24.0
+    matrix[3, 3] = matrix[1, 1]
+    matrix[4, 4] = matrix[0, 0]
+    matrix[5, 5] = matrix[2, 2]
+    matrix[6, 6] = matrix[2, 2]
+    matrix[7, 7] = matrix[2, 2]
+    matrix[8, 8] = (cos_tmax2 + cos_tmax + 1.0) / 3.0
+
+    # Off diagonal set 1.
+    matrix[0, 4] = matrix[4, 0] = (cos_tmax2 - 2.0*cos_tmax + 1.0) / 24.0
+    matrix[0, 8] = matrix[8, 0] = -(cos_tmax2 + cos_tmax - 2.0) / 6.0
+    matrix[4, 8] = matrix[8, 4] = matrix[0, 8]
+
+    # Off diagonal set 2.
+    matrix[1, 3] = matrix[3, 1] = matrix[0, 4]
+    matrix[2, 6] = matrix[6, 2] = -matrix[0, 8]
+    matrix[5, 7] = matrix[7, 5] = -matrix[0, 8]
+
+    # Generate the cone axis from the spherical angles.
+    spherical_to_cartesian([1.0, theta_axis, phi_axis], cone_axis)
 
     # Average position rotation.
     two_vect_to_R(z_axis, cone_axis, R)




Related Messages


Powered by MHonArc, Updated Wed Aug 11 23:20:01 2010