Package lib :: Package auto_relaxation :: Module ri
[hide private]
[frames] | no frames]

Source Code for Module lib.auto_relaxation.ri

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