Author: bugman Date: Wed Aug 11 23:56:45 2010 New Revision: 11480 URL: http://svn.gna.org/viewcvs/relax?rev=11480&view=rev Log: Created the free rotor 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=11480&r1=11479&r2=11480&view=diff ============================================================================== --- 1.3/maths_fns/frame_order.py (original) +++ 1.3/maths_fns/frame_order.py Wed Aug 11 23:56:45 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_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.frame_order_matrix_ops import compile_2nd_matrix_free_rotor, 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 @@ -169,6 +169,30 @@ self.func = self.func_iso_cone_elements + def func_free_rotor(self, params): + """Target function for free rotor model optimisation. + + This function optimises against alignment tensors. The Euler angles for the tensor rotation are the first 3 parameters optimised in this model, followed by the polar and azimuthal angles of the cone axis. + + @param params: The vector of parameter values. These are the tensor rotation angles {alpha, beta, gamma, theta, phi}. + @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 = params + + # Generate the 2nd degree Frame Order super matrix. + frame_order_2nd = compile_2nd_matrix_free_rotor(self.frame_order_2nd, self.rot, self.z_axis, self.cone_axis, axis_theta, axis_phi) + + # 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_iso_cone_elements(self, params): """Target function for isotropic cone model optimisation using the Frame Order matrix. 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=11480&r1=11479&r2=11480&view=diff ============================================================================== --- 1.3/maths_fns/frame_order_matrix_ops.py (original) +++ 1.3/maths_fns/frame_order_matrix_ops.py Wed Aug 11 23:56:45 2010 @@ -58,6 +58,54 @@ matrix[0, 0] = fact * quad(part_int_daeg1_pseudo_ellipse_xx, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0] matrix[1, 1] = fact * quad(part_int_daeg1_pseudo_ellipse_yy, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0] matrix[2, 2] = fact * quad(part_int_daeg1_pseudo_ellipse_zz, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0] + + +def compile_2nd_matrix_free_rotor(matrix, R, z_axis, axis, theta_axis, phi_axis): + """Generate the rotated 2nd degree Frame Order matrix for the free rotor model. + + The rotor 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 rotor axis is rotated from. + @type z_axis: numpy 3D, rank-1 array + @param axis: The storage structure for the axis. + @type axis: numpy 3D, rank-1 array + @param theta_axis: The axis polar angle. + @type theta_axis: float + @param phi_axis: The axis azimuthal angle. + @type phi_axis: float + """ + + # Zeros. + for i in range(9): + for j in range(9): + matrix[i, j] = 0.0 + + # Diagonal. + matrix[0, 0] = 0.5 + matrix[1, 1] = 0.5 + matrix[3, 3] = 0.5 + matrix[4, 4] = 0.5 + matrix[8, 8] = 1 + + # Off diagonal set 1. + matrix[0, 4] = matrix[4, 0] = 0.5 + + # Off diagonal set 2. + matrix[1, 3] = matrix[3, 1] = -0.5 + + # Generate the cone axis from the spherical angles. + spherical_to_cartesian([1.0, theta_axis, phi_axis], axis) + + # Average position rotation. + two_vect_to_R(z_axis, axis, R) + + # Rotate and return the frame order matrix. + return rotate_daeg(matrix, R) def compile_2nd_matrix_iso_cone(matrix, R, eigen_alpha, eigen_beta, eigen_gamma, cone_theta, sigma_max):