Author: bugman Date: Fri Jun 6 10:30:45 2014 New Revision: 23684 URL: http://svn.gna.org/viewcvs/relax?rev=23684&view=rev Log: Parameter conversion for all of the CaM free rotor test data frame_order.py optimisation scripts. The rotor axis spherical angles have been replaced by the axis alpha angle defining the rotor with respect to the xy-plane. Modified: branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor/frame_order.py branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor2/frame_order.py branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor_missing_data/frame_order.py Modified: branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor/frame_order.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor/frame_order.py?rev=23684&r1=23683&r2=23684&view=diff ============================================================================== --- branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor/frame_order.py (original) +++ branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor/frame_order.py Fri Jun 6 10:30:45 2014 @@ -1,7 +1,46 @@ # Script for optimising the free rotor frame order test model of CaM. # Python module imports. -from numpy import array +from numpy import array, cross, float64, zeros +from numpy.linalg import norm + +# relax module imports. +from lib.frame_order.rotor_axis import create_rotor_axis_alpha +from lib.geometry.lines import closest_point_ax +from lib.geometry.coord_transform import spherical_to_cartesian +from lib.geometry.rotations import reverse_euler_zyz +from lib.geometry.vectors import vector_angle +from pipe_control.structure.mass import pipe_centre_of_mass + + +def alpha_angle(pivot=None, com=None, axis=None): + """Calculate and return the rotor alpha angle.""" + + # The CoM-pivot axis. + com_piv = com - pivot + com_piv /= norm(com_piv) + + # The mu_xy vector. + z_axis = array([0, 0, 1], float64) + mu_xy = cross(z_axis, com_piv) + mu_xy /= norm(mu_xy) + + # The alpha angle. + return vector_angle(mu_xy, axis, com_piv) + + +def shift_pivot(pivot_orig=None, com=None, axis=None): + """Shift the pivot to the closest point on the rotor axis to the CoM.)""" + + # The closest point. + pivot_new = closest_point_ax(line_pt=pivot_orig, axis=axis, point=com) + + # Printout. + print("\n%-20s%s" % ("Original pivot:", pivot_orig)) + print("%-20s%s" % ("New pivot:", pivot_new)) + + # Return the shifted pivot. + return pivot_new # The real parameter values. @@ -10,6 +49,11 @@ AVE_POS_GAMMA = 4.6622313104265416 AXIS_THETA = 0.9600799785953431 AXIS_PHI = 4.0322755062196229 + +# Reconstruct the rotation axis. +AXIS = zeros(3, float64) +spherical_to_cartesian([1, AXIS_THETA, AXIS_PHI], AXIS) +print("Rotation axis: %s" % AXIS) # Create the data pipe. pipe.create(pipe_name='frame order', pipe_type='frame order') @@ -71,7 +115,7 @@ frame_order.ref_domain('N') # Set the initial pivot point. -pivot = array([ 37.254, 0.5, 16.7465]) +pivot = shift_pivot(pivot_orig=array([ 37.254, 0.5, 16.7465]), com=pipe_centre_of_mass(verbosity=0), axis=AXIS) frame_order.pivot(pivot, fix=True) # Set the paramagnetic centre. @@ -84,8 +128,7 @@ value.set(param='ave_pos_z', val=AVE_POS_Z) value.set(param='ave_pos_beta', val=AVE_POS_BETA) value.set(param='ave_pos_gamma', val=AVE_POS_GAMMA) -value.set(param='axis_theta', val=AXIS_THETA) -value.set(param='axis_phi', val=AXIS_PHI) +value.set(param='axis_alpha', val=alpha_angle(pivot=pivot, com=pipe_centre_of_mass(verbosity=0), axis=AXIS)) calc() # Create the PDB representation of the true state. @@ -93,7 +136,7 @@ # Grid search (low quality for speed). frame_order.num_int_pts(num=100) -grid_search(inc=[None, None, None, None, None, 21, 21]) +grid_search(inc=[None, None, None, None, None, 21]) # Iterative optimisation with increasing precision. num_int_pts = [100, 1000, 10000, 50000] @@ -112,6 +155,17 @@ for i in range(len(num_int_pts)): frame_order.num_int_pts(num=num_int_pts[i]) minimise('simplex', func_tol=func_tol[i]) + +# The distance from the optimised pivot and the rotation axis. +opt_piv = array([cdp.pivot_x, cdp.pivot_y, cdp.pivot_z]) +print("\n\nOptimised pivot displacement: %s" % norm(pivot - opt_piv)) +pt = closest_point_ax(line_pt=pivot, axis=AXIS, point=opt_piv) +print("Distance from axis: %s\n" % norm(pt - opt_piv)) + +# Recreate the axis and compare to the original. +opt_axis = create_rotor_axis_alpha(alpha=cdp.axis_alpha, pivot=opt_piv, point=pipe_centre_of_mass(verbosity=0)) +print("Original axis: %s" % AXIS) +print("Optimised axis: %s" % opt_axis) # Test Monte Carlo simulations (at low quality for speed). frame_order.num_int_pts(num=100) Modified: branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor2/frame_order.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor2/frame_order.py?rev=23684&r1=23683&r2=23684&view=diff ============================================================================== --- branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor2/frame_order.py (original) +++ branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor2/frame_order.py Fri Jun 6 10:30:45 2014 @@ -1,7 +1,46 @@ # Script for optimising the second free rotor frame order test model of CaM. # Python module imports. -from numpy import array +from numpy import array, cross, float64, zeros +from numpy.linalg import norm + +# relax module imports. +from lib.frame_order.rotor_axis import create_rotor_axis_alpha +from lib.geometry.lines import closest_point_ax +from lib.geometry.coord_transform import spherical_to_cartesian +from lib.geometry.rotations import reverse_euler_zyz +from lib.geometry.vectors import vector_angle +from pipe_control.structure.mass import pipe_centre_of_mass + + +def alpha_angle(pivot=None, com=None, axis=None): + """Calculate and return the rotor alpha angle.""" + + # The CoM-pivot axis. + com_piv = com - pivot + com_piv /= norm(com_piv) + + # The mu_xy vector. + z_axis = array([0, 0, 1], float64) + mu_xy = cross(z_axis, com_piv) + mu_xy /= norm(mu_xy) + + # The alpha angle. + return vector_angle(mu_xy, axis, com_piv) + + +def shift_pivot(pivot_orig=None, com=None, axis=None): + """Shift the pivot to the closest point on the rotor axis to the CoM.)""" + + # The closest point. + pivot_new = closest_point_ax(line_pt=pivot_orig, axis=axis, point=com) + + # Printout. + print("\n%-20s%s" % ("Original pivot:", pivot_orig)) + print("%-20s%s" % ("New pivot:", pivot_new)) + + # Return the shifted pivot. + return pivot_new # The real parameter values. @@ -12,6 +51,11 @@ AVE_POS_GAMMA = 0.09243393677259322 AXIS_THETA = 0.69828059079619353433 AXIS_PHI = 4.03227550621962294031 + +# Reconstruct the rotation axis. +AXIS = zeros(3, float64) +spherical_to_cartesian([1, AXIS_THETA, AXIS_PHI], AXIS) +print("Rotation axis: %s" % AXIS) # Create the data pipe. pipe.create(pipe_name='frame order', pipe_type='frame order') @@ -73,7 +117,7 @@ frame_order.ref_domain('N') # Set the initial pivot point. -pivot = array([ 37.254, 0.5, 16.7465]) +pivot = shift_pivot(pivot_orig=array([ 37.254, 0.5, 16.7465]), com=pipe_centre_of_mass(verbosity=0), axis=AXIS) frame_order.pivot(pivot, fix=True) # Set the paramagnetic centre. @@ -86,8 +130,7 @@ value.set(param='ave_pos_z', val=AVE_POS_Z) value.set(param='ave_pos_beta', val=AVE_POS_BETA) value.set(param='ave_pos_gamma', val=AVE_POS_GAMMA) -value.set(param='axis_theta', val=AXIS_THETA) -value.set(param='axis_phi', val=AXIS_PHI) +value.set(param='axis_alpha', val=alpha_angle(pivot=pivot, com=pipe_centre_of_mass(verbosity=0), axis=AXIS)) calc() # Create the PDB representation of the true state. @@ -95,7 +138,7 @@ # Grid search (low quality for speed). frame_order.num_int_pts(num=100) -grid_search(inc=[None, None, None, None, None, 21, 21]) +grid_search(inc=[None, None, None, None, None, 21]) # Iterative optimisation with increasing precision. num_int_pts = [100, 1000, 10000, 50000] @@ -114,6 +157,17 @@ for i in range(len(num_int_pts)): frame_order.num_int_pts(num=num_int_pts[i]) minimise('simplex', func_tol=func_tol[i]) + +# The distance from the optimised pivot and the rotation axis. +opt_piv = array([cdp.pivot_x, cdp.pivot_y, cdp.pivot_z]) +print("\n\nOptimised pivot displacement: %s" % norm(pivot - opt_piv)) +pt = closest_point_ax(line_pt=pivot, axis=AXIS, point=opt_piv) +print("Distance from axis: %s\n" % norm(pt - opt_piv)) + +# Recreate the axis and compare to the original. +opt_axis = create_rotor_axis_alpha(alpha=cdp.axis_alpha, pivot=opt_piv, point=pipe_centre_of_mass(verbosity=0)) +print("Original axis: %s" % AXIS) +print("Optimised axis: %s" % opt_axis) # Test Monte Carlo simulations (at low quality for speed). frame_order.num_int_pts(num=100) Modified: branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor_missing_data/frame_order.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor_missing_data/frame_order.py?rev=23684&r1=23683&r2=23684&view=diff ============================================================================== --- branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor_missing_data/frame_order.py (original) +++ branches/frame_order_cleanup/test_suite/shared_data/frame_order/cam/free_rotor_missing_data/frame_order.py Fri Jun 6 10:30:45 2014 @@ -1,7 +1,46 @@ # Script for optimising the free rotor frame order test model of CaM. # Python module imports. -from numpy import array +from numpy import array, cross, float64, zeros +from numpy.linalg import norm + +# relax module imports. +from lib.frame_order.rotor_axis import create_rotor_axis_alpha +from lib.geometry.lines import closest_point_ax +from lib.geometry.coord_transform import spherical_to_cartesian +from lib.geometry.rotations import reverse_euler_zyz +from lib.geometry.vectors import vector_angle +from pipe_control.structure.mass import pipe_centre_of_mass + + +def alpha_angle(pivot=None, com=None, axis=None): + """Calculate and return the rotor alpha angle.""" + + # The CoM-pivot axis. + com_piv = com - pivot + com_piv /= norm(com_piv) + + # The mu_xy vector. + z_axis = array([0, 0, 1], float64) + mu_xy = cross(z_axis, com_piv) + mu_xy /= norm(mu_xy) + + # The alpha angle. + return vector_angle(mu_xy, axis, com_piv) + + +def shift_pivot(pivot_orig=None, com=None, axis=None): + """Shift the pivot to the closest point on the rotor axis to the CoM.)""" + + # The closest point. + pivot_new = closest_point_ax(line_pt=pivot_orig, axis=axis, point=com) + + # Printout. + print("\n%-20s%s" % ("Original pivot:", pivot_orig)) + print("%-20s%s" % ("New pivot:", pivot_new)) + + # Return the shifted pivot. + return pivot_new # The real parameter values. @@ -10,6 +49,11 @@ AVE_POS_GAMMA = 4.6622313104265416 AXIS_THETA = 0.9600799785953431 AXIS_PHI = 4.0322755062196229 + +# Reconstruct the rotation axis. +AXIS = zeros(3, float64) +spherical_to_cartesian([1, AXIS_THETA, AXIS_PHI], AXIS) +print("Rotation axis: %s" % AXIS) # Create the data pipe. pipe.create(pipe_name='frame order', pipe_type='frame order') @@ -73,7 +117,7 @@ frame_order.ref_domain('N') # Set the initial pivot point. -pivot = array([ 37.254, 0.5, 16.7465]) +pivot = shift_pivot(pivot_orig=array([ 37.254, 0.5, 16.7465]), com=pipe_centre_of_mass(verbosity=0), axis=AXIS) frame_order.pivot(pivot, fix=True) # Set the paramagnetic centre. @@ -86,8 +130,7 @@ value.set(param='ave_pos_z', val=AVE_POS_Z) value.set(param='ave_pos_beta', val=AVE_POS_BETA) value.set(param='ave_pos_gamma', val=AVE_POS_GAMMA) -value.set(param='axis_theta', val=AXIS_THETA) -value.set(param='axis_phi', val=AXIS_PHI) +value.set(param='axis_alpha', val=alpha_angle(pivot=pivot, com=pipe_centre_of_mass(verbosity=0), axis=AXIS)) calc() # Create the PDB representation of the true state. @@ -95,7 +138,7 @@ # Grid search (low quality for speed). frame_order.num_int_pts(num=100) -grid_search(inc=[None, None, None, None, None, 21, 21]) +grid_search(inc=[None, None, None, None, None, 21]) # Iterative optimisation with increasing precision. num_int_pts = [100, 1000, 10000, 50000] @@ -114,6 +157,17 @@ for i in range(len(num_int_pts)): frame_order.num_int_pts(num=num_int_pts[i]) minimise('simplex', func_tol=func_tol[i]) + +# The distance from the optimised pivot and the rotation axis. +opt_piv = array([cdp.pivot_x, cdp.pivot_y, cdp.pivot_z]) +print("\n\nOptimised pivot displacement: %s" % norm(pivot - opt_piv)) +pt = closest_point_ax(line_pt=pivot, axis=AXIS, point=opt_piv) +print("Distance from axis: %s\n" % norm(pt - opt_piv)) + +# Recreate the axis and compare to the original. +opt_axis = create_rotor_axis_alpha(alpha=cdp.axis_alpha, pivot=opt_piv, point=pipe_centre_of_mass(verbosity=0)) +print("Original axis: %s" % AXIS) +print("Optimised axis: %s" % opt_axis) # Test Monte Carlo simulations (at low quality for speed). frame_order.num_int_pts(num=100)