Package maths_fns :: Module order_parameters
[hide private]
[frames] | no frames]

Source Code for Module maths_fns.order_parameters

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2010 Edward d'Auvergne                                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax.                                     # 
 6  #                                                                             # 
 7  # relax 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 2 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # relax 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 relax; if not, write to the Free Software                        # 
19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Module docstring. 
24  """Module for the conversion of order parameters to specific model parameters and vice versa.""" 
25   
26  # Python module imports. 
27  from math import acos, cos, pi, sqrt 
28   
29   
30 -def iso_cone_theta_to_S(theta):
31 """Convert the isotropic cone angle to the order parameter S. 32 33 This uses Woessner's diffusion in a cone order parameter defined as:: 34 35 S = 1/2 (1 + cos(theta)) * cos(theta) 36 37 38 @param theta: The isotropic cone angle. 39 @type theta: float 40 @return: The order parameter value. 41 @rtype: float 42 """ 43 44 # Convert. 45 S = 0.5 * (1.0 + cos(theta)) * cos(theta) 46 47 # Return the order parameter. 48 return S
49 50
51 -def iso_cone_S_to_theta(S):
52 """Convert the isotropic cone order parameter S into the cone angle. 53 54 This uses Woessner's diffusion in a cone order parameter defined as:: 55 56 S = 1/2 (1 + cos(theta)) * cos(theta) 57 58 The conversion equation is:: 59 60 theta = acos((sqrt(8.0*S + 1) - 1)/2) 61 62 Hence the cone angle is only between 0 and 2pi/3, as the order parameter for higher cone angles is ambiguous. 63 64 65 @param S: The order parameter value (not squared). 66 @type S: float 67 @return: The value of cos(theta). 68 @rtype: float 69 """ 70 71 # Catch bad order parameters. 72 if S > 1.0: 73 return 0.0 74 if S < -0.125: 75 return 2*pi 76 77 # Convert. 78 theta = acos(0.5*(sqrt(8.0*S + 1) - 1)) 79 80 # Return theta. 81 return theta
82