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

Source Code for Module maths_fns.ri

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004 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   
 24  # relax module imports. 
 25  from ri_comps import r1_comps, dr1_comps, d2r1_comps 
 26  from ri_prime import func_ri_prime 
 27   
 28   
 29  # Calculate the NOE value. 
 30  ########################## 
 31   
32 -def calc_noe(data, i, frq_num, get_r1, params):
33 """Calculate the NOE value. 34 35 Half this code needs to be shifted into the function initialisation code. 36 """ 37 38 # Get the r1 value either from data.ri_prime or by calculation if the value is not in data.ri_prime 39 data.r1[i] = get_r1[i](data, i, frq_num, params) 40 41 # Calculate the NOE. 42 if data.r1[i] == 0.0 and data.ri_prime[i] == 0.0: 43 data.ri[i] = 1.0 44 elif data.r1[i] == 0.0: 45 data.ri[i] = 1e99 46 else: 47 data.ri[i] = 1.0 + data.g_ratio*(data.ri_prime[i] / data.r1[i])
48 49
50 -def calc_dnoe(data, i, frq_num, get_dr1, params, j):
51 """Calculate the derivative of the NOE value. 52 53 Half this code needs to be shifted into the function initialisation code. 54 """ 55 56 # Calculate the NOE derivative. 57 data.dr1[j, i] = get_dr1[i](data, i, frq_num, params, j) 58 if data.r1[i] == 0.0 and data.ri_prime[i] == 0.0: 59 data.dri[j, i] = 0.0 60 elif data.r1[i] == 0.0: 61 data.dri[j, i] = 1e99 62 else: 63 data.dri[j, i] = data.g_ratio * (1.0 / data.r1[i]**2) * (data.r1[i] * data.dri_prime[j, i] - data.ri_prime[i] * data.dr1[j, i])
64 65
66 -def calc_d2noe(data, i, frq_num, get_d2r1, params, j, k):
67 """Calculate the second partial derivative of the NOE value. 68 69 Half this code needs to be shifted into the function initialisation code. 70 """ 71 72 # Calculate the NOE second derivative. 73 data.d2r1[j, k, i] = get_d2r1[i](data, i, frq_num, params, j, k) 74 if data.r1[i] == 0.0 and data.ri_prime[i] == 0.0: 75 data.d2ri[j, k, i] = 0.0 76 elif data.r1[i] == 0.0: 77 data.d2ri[j, k, i] = 1e99 78 else: 79 a = data.ri_prime[i] * (2.0 * data.dr1[j, i] * data.dr1[k, i] - data.r1[i] * data.d2r1[j, k, i]) 80 b = data.r1[i] * (data.dri_prime[j, i] * data.dr1[k, i] + data.dr1[j, i] * data.dri_prime[k, i] - data.r1[i] * data.d2ri_prime[j, k, i]) 81 data.d2ri[j, k, i] = data.g_ratio * (1.0 / data.r1[i]**3) * (a - b)
82 83 84 85 # Calculate the R1 value. 86 ######################### 87
88 -def calc_r1(data, i, frq_num, params):
89 """Calculate the R1 value if there is no R1 data corresponding to the NOE data. 90 91 R1() = dip_const_func . dip_Jw_R1_func + csa_const_func . csa_Jw_R1_func 92 """ 93 94 # Place data in the R1 data class. 95 data.r1_data.remap_table = data.remap_table 96 data.r1_data.jw = data.jw 97 data.r1_data.dip_const_func = data.dip_const_func 98 data.r1_data.csa_const_func = data.csa_const_func 99 100 # Calculate the r1 components. 101 r1_comps(data.r1_data, i, params) 102 103 # Calculate the r1 value. 104 ri = func_ri_prime(data.r1_data) 105 return ri[i]
106 107
108 -def calc_dr1(data, i, frq_num, params, j):
109 """Calculate the R1 value if there is no R1 data corresponding to the NOE data. 110 111 The equations are:: 112 113 dR1() 114 ----- = dip_const_func . dip_Jw_R1_grad + csa_const_func . csa_Jw_R1_grad 115 dJw 116 117 dR1() 118 ----- = 0 119 dRex 120 121 dR1() 122 ----- = dip_const_grad . dip_Jw_R1_func 123 dr 124 125 dR1() 126 ----- = csa_const_grad . csa_Jw_R1_func 127 dcsa 128 """ 129 130 # Place data in the R1 data class. 131 data.r1_data.remap_table = data.remap_table 132 data.r1_data.djw = data.djw 133 data.r1_data.dip_const_grad = data.dip_const_grad 134 data.r1_data.csa_const_grad = data.csa_const_grad 135 136 # Calculate the dr1 components. 137 dr1_comps(data.r1_data, i, params) 138 139 # Calculate the dr1 value. 140 dri = data.r1_data.create_dri_prime[j](data.r1_data) 141 142 return dri[i]
143 144
145 -def calc_d2r1(data, i, frq_num, params, j, k):
146 """Calculate the R1 value if there is no R1 data corresponding to the NOE data.""" 147 148 # Place data in the R1 data class. 149 data.r1_data.remap_table = data.remap_table 150 data.r1_data.d2jw = data.d2jw 151 data.r1_data.dip_const_hess = data.dip_const_hess 152 data.r1_data.csa_const_hess = data.csa_const_hess 153 154 # Calculate the dr1 components. 155 d2r1_comps(data.r1_data, i, params) 156 157 # Calculate the dr1 value. 158 if data.r1_data.create_d2ri_prime[j][k]: 159 d2ri = data.r1_data.create_d2ri_prime[j][k](data.r1_data) 160 return d2ri[i] 161 else: 162 return 0.0
163 164 165 166 # Extract the R1 value. 167 ####################### 168
169 -def extract_r1(data, i, frq_num, params):
170 """Get the R1 value from data.ri_prime""" 171 172 return data.ri_prime[data.noe_r1_table[i]]
173 174
175 -def extract_dr1(data, i, frq_num, params, j):
176 """Get the dR1 value from data.dri_prime""" 177 178 return data.dri_prime[j, data.noe_r1_table[i]]
179 180
181 -def extract_d2r1(data, i, frq_num, params, j, k):
182 """Get the d2R1 value from data.d2ri_prime""" 183 184 return data.d2ri_prime[j, k, data.noe_r1_table[i]]
185