Package lib :: Package frame_order :: Module rotor_axis
[hide private]
[frames] | no frames]

Source Code for Module lib.frame_order.rotor_axis

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2014 Edward d'Auvergne                                        # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """Functions for creating or calculating the rotor axis for the frame order models.""" 
 24   
 25  # Python module imports. 
 26  from numpy import array, cross, dot, float64, zeros 
 27  from numpy.linalg import norm 
 28   
 29  # relax module imports. 
 30  from lib.geometry.coord_transform import spherical_to_cartesian 
 31  from lib.geometry.rotations import axis_angle_to_R, euler_to_R_zyz 
 32   
 33  # Module variables. 
 34  R = zeros((3, 3), float64)    # A rotation matrix. 
 35  Z_AXIS = array([0, 0, 1], float64) 
 36   
 37   
38 -def create_rotor_axis_alpha(alpha=None, pivot=None, point=None):
39 """Create the rotor axis from the axis alpha angle. 40 41 @keyword alpha: The axis alpha angle, defined as the angle between a vector perpendicular to the pivot-CoM vector in the xy-plane and the rotor axis. 42 @type alpha: float 43 @keyword pivot: The pivot point on the rotation axis. 44 @type pivot: numpy rank-1 3D array 45 @keyword point: The reference point in space. 46 @type point: numpy rank-1 3D array 47 @return: The rotor axis as a unit vector. 48 @rtype: numpy rank-1 3D float64 array 49 """ 50 51 # The CoM-pivot unit vector - the norm of the system (the pivot is defined as the point on the axis closest to the point). 52 n = point - pivot 53 n /= norm(n) 54 55 # The vector perpendicular to the CoM-pivot vector and in the xy plane. 56 mu_xy = cross(Z_AXIS, n) 57 mu_xy /= norm(mu_xy) 58 59 # Rotate the vector about the CoM-pivot axis by the angle alpha. 60 axis_angle_to_R(n, alpha, R) 61 axis = dot(R, mu_xy) 62 63 # Return the new axis. 64 return axis
65 66
67 -def create_rotor_axis_euler(alpha=None, beta=None, gamma=None):
68 """Create the rotor axis from the Euler angles. 69 70 @keyword alpha: The alpha Euler angle in the zyz notation. 71 @type alpha: float 72 @keyword beta: The beta Euler angle in the zyz notation. 73 @type beta: float 74 @keyword gamma: The gamma Euler angle in the zyz notation. 75 @type gamma: float 76 @return: The rotor axis as a unit vector. 77 @rtype: numpy rank-1 3D float64 array 78 """ 79 80 # Initialise the 3D frame. 81 frame = zeros((3, 3), float64) 82 83 # Euler angle to rotation matrix conversion. 84 euler_to_R_zyz(alpha, beta, gamma, frame) 85 86 # Return the z-axis component. 87 return frame[:, 2]
88 89
90 -def create_rotor_axis_spherical(theta=None, phi=None):
91 """Create the rotor axis from the spherical coordinates. 92 93 @keyword theta: The polar spherical angle. 94 @type theta: float 95 @keyword phi: The azimuthal spherical angle. 96 @type phi: float 97 @return: The rotor axis as a unit vector. 98 @rtype: numpy rank-1 3D float64 array 99 """ 100 101 # Initialise the axis. 102 axis = zeros(3, float64) 103 104 # Parameter conversion. 105 spherical_to_cartesian([1.0, theta, phi], axis) 106 107 # Return the new axis. 108 return axis
109