Package lib :: Package order :: Module order_parameters
[hide private]
[frames] | no frames]

Source Code for Module lib.order.order_parameters

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2010 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  """Module for the conversion of order parameters to specific model parameters and vice versa.""" 
24   
25  # Python module imports. 
26  from math import acos, cos, pi, sqrt 
27   
28   
29 -def iso_cone_theta_to_S(theta):
30 """Convert the isotropic cone angle to the order parameter S. 31 32 This uses Woessner's diffusion in a cone order parameter defined as:: 33 34 S = 1/2 (1 + cos(theta)) * cos(theta) 35 36 37 @param theta: The isotropic cone angle. 38 @type theta: float 39 @return: The order parameter value. 40 @rtype: float 41 """ 42 43 # Convert. 44 S = 0.5 * (1.0 + cos(theta)) * cos(theta) 45 46 # Return the order parameter. 47 return S
48 49
50 -def iso_cone_S_to_theta(S):
51 """Convert the isotropic cone order parameter S into the cone angle. 52 53 This uses Woessner's diffusion in a cone order parameter defined as:: 54 55 S = 1/2 (1 + cos(theta)) * cos(theta) 56 57 The conversion equation is:: 58 59 theta = acos((sqrt(8.0*S + 1) - 1)/2) 60 61 Hence the cone angle is only between 0 and 2pi/3, as the order parameter for higher cone angles is ambiguous. 62 63 64 @param S: The order parameter value (not squared). 65 @type S: float 66 @return: The value of cos(theta). 67 @rtype: float 68 """ 69 70 # Catch bad order parameters. 71 if S > 1.0: 72 return 0.0 73 if S < -0.125: 74 return 2*pi 75 76 # Convert. 77 theta = acos(0.5*(sqrt(8.0*S + 1) - 1)) 78 79 # Return theta. 80 return theta
81