Package functions :: Module d2jw_mf
[hide private]
[frames] | no frames]

Source Code for Module functions.d2jw_mf

  1  from Numeric import Float64, zeros 
  2  from re import match 
  3   
4 -class d2Jw:
5 - def __init__(self):
6 "Function for creating the model-free spectral density hessians."
7 8
9 - def d2Jw(self):
10 """Function to create model-free spectral density hessians. 11 12 The spectral density hessians 13 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 15 Data structure: self.data.d2jw 16 Dimension: 4D, (number of NMR frequencies, 5 spectral density frequencies, model-free parameters, model-free parameters) 17 Type: Numeric 4D matrix, Float64 18 Dependencies: None 19 Required by: self.data.d2ri 20 21 22 Formulae 23 ~~~~~~~~ 24 25 Original: Model-free parameter - Model-free parameter 26 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 27 28 d2J(w) 29 ------ = 0 30 dS2**2 31 32 33 d2J(w) 2 1 - (w.te')**2 / tm \ 2 34 ------- = - - . ------------------- . | ------- | 35 dS2.dte 5 (1 + (w.te')**2)**2 \ te + tm / 36 37 38 d2J(w) 4 / tm \ 4 1 39 ------ = - - . (1 - S2) . | ------- | . ------------------- . [w**2.te'(3 - (w.te')**2) + (1 - (w.te')**4)(te + tm).tm**-2] 40 dte**2 5 \ te + tm / (1 + (w.te')**2)**3 41 42 43 Original: Other parameters 44 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 45 46 d2J(w) d2J(w) d2J(w) 47 -------- = 0 , -------- = 0 , ------ = 0 48 dS2.dRex dS2.dcsa dS2.dr 49 50 51 d2J(w) d2J(w) d2J(w) 52 -------- = 0 , -------- = 0 , ------ = 0 53 dte.dRex dte.dcsa dte.dr 54 55 56 d2J(w) d2J(w) d2J(w) 57 ------- = 0 , --------- = 0 , ------- = 0 58 dRex**2 dRex.dcsa dRex.dr 59 60 61 d2J(w) d2J(w) 62 ------- = 0 , ------- = 0 63 dcsa**2 dcsa.dr 64 65 66 d2J(w) 67 ------ = 0 68 dr**2 69 70 71 Extended: Model-free parameter - Model-free parameter 72 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 73 74 d2J(w) 75 ------- = 0 76 dS2f**2 77 78 79 d2J(w) 2 / tm ts' \ 80 --------- = - | ------------- - -------------- | 81 dS2f.dS2s 5 \ 1 + (w.tm)**2 1 + (w.ts')**2 / 82 83 84 d2J(w) 2 1 - (w.tf')**2 / tm \ 2 85 -------- = - - . ------------------- . | ------- | 86 dS2f.dtf 5 (1 + (w.tf')**2)**2 \ tf + tm / 87 88 89 d2J(w) 2 1 - (w.ts')**2 / tm \ 2 90 -------- = - . (1 - S2s) . ------------------- . | ------- | 91 dS2f.dts 5 (1 + (w.ts')**2)**2 \ ts + tm / 92 93 94 d2J(w) d2J(w) 95 ------- = 0 , -------- = 0 96 dS2s**2 dS2s.dtf 97 98 99 d2J(w) 2.S2f 1 - (w.ts')**2 / tm \ 2 100 -------- = - ----- . ------------------- . | ------- | 101 dS2s.dts 5 (1 + (w.ts')**2)**2 \ ts + tm / 102 103 104 d2J(w) 105 ------- = 0 106 dtf.dts 107 108 109 d2J(w) 4 / tm \ 4 1 110 ------ = - - . (1 - S2f) . | ------- | . ------------------- . [w**2.tf'(3 - (w.tf')**2) + (1 - (w.tf')**4)(tf + tm).tm**-2] 111 dtf**2 5 \ tf + tm / (1 + (w.tf')**2)**3 112 113 114 d2J(w) 4 / tm \ 4 1 115 ------ = - - . (S2f - S2) . | ------- | . ------------------- . [w**2.ts'(3 - (w.ts')**2) + (1 - (w.ts')**4)(ts + tm).tm**-2] 116 dts**2 5 \ ts + tm / (1 + (w.ts')**2)**3 117 118 119 Extended: Other parameters 120 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 121 122 d2J(w) d2J(w) d2J(w) 123 --------- = 0 , --------- = 0 , ------- = 0 124 dS2f.dRex dS2f.dcsa dS2f.dr 125 126 127 d2J(w) d2J(w) d2J(w) 128 --------- = 0 , --------- = 0 , ------- = 0 129 dS2s.dRex dS2s.dcsa dS2s.dr 130 131 132 d2J(w) d2J(w) d2J(w) 133 -------- = 0 , -------- = 0 , ------ = 0 134 dtf.dRex dtf.dcsa dtf.dr 135 136 137 d2J(w) d2J(w) d2J(w) 138 -------- = 0 , -------- = 0 , ------ = 0 139 dts.dRex dts.dcsa dts.dr 140 141 142 d2J(w) d2J(w) d2J(w) 143 ------- = 0 , --------- = 0 , ------- = 0 144 dRex**2 dRex.dcsa dRex.dr 145 146 147 d2J(w) d2J(w) 148 ------- = 0 , ------- = 0 149 dcsa**2 dcsa.dr 150 151 152 d2J(w) 153 ------ = 0 154 dr**2 155 156 157 158 """ 159 160 # Initialise the spectral density hessians. 161 self.data.d2jw = zeros((self.mf.data.num_frq, 5, len(self.data.params), len(self.data.params)), Float64) 162 163 # Isotropic rotational diffusion. 164 if match(self.data.diff_type, 'iso'): 165 # Model 1 and 3 hessians are zero. 166 if match('m[24]', self.data.model): 167 for i in range(self.mf.data.num_frq): 168 for param1 in range(len(self.data.jw_param_types)): 169 for param2 in range(param1 + 1): 170 if (self.data.jw_param_types[param1] == 'S2' and self.data.jw_param_types[param2] == 'te') \ 171 or (self.data.jw_param_types[param1] == 'te' and self.data.jw_param_types[param2] == 'S2'): 172 # Calculate the S2/te partial derivatives. 173 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2dte_iso_m24(i, 0) 174 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2dte_iso_m24(i, 1) 175 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2dte_iso_m24(i, 2) 176 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2dte_iso_m24(i, 3) 177 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2dte_iso_m24(i, 4) 178 # Off diagonal hessian components are symmetric. 179 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2] 180 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2] 181 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2] 182 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2] 183 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2] 184 elif self.data.jw_param_types[param1] == 'te' and self.data.jw_param_types[param2] == 'te': 185 # Calculate the te/te partial derivatives. 186 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dte2_iso_m24(i, 0) 187 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dte2_iso_m24(i, 1) 188 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dte2_iso_m24(i, 2) 189 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dte2_iso_m24(i, 3) 190 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dte2_iso_m24(i, 4) 191 elif match('m5', self.data.model): 192 for i in range(self.mf.data.num_frq): 193 for param1 in range(len(self.data.jw_param_types)): 194 for param2 in range(param1 + 1): 195 if (self.data.jw_param_types[param1] == 'S2f' and self.data.jw_param_types[param2] == 'S2s') \ 196 or (self.data.jw_param_types[param1] == 'S2s' and self.data.jw_param_types[param2] == 'S2f'): 197 # Calculate the S2f/S2s partial derivatives. 198 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 0) 199 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 1) 200 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 2) 201 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 3) 202 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 4) 203 # Off diagonal hessian components are symmetric. 204 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2] 205 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2] 206 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2] 207 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2] 208 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2] 209 elif (self.data.jw_param_types[param1] == 'S2f' and self.data.jw_param_types[param2] == 'ts') \ 210 or (self.data.jw_param_types[param1] == 'ts' and self.data.jw_param_types[param2] == 'S2f'): 211 # Calculate the S2f/ts partial derivatives. 212 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2fdts_iso_m5(i, 0) 213 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2fdts_iso_m5(i, 1) 214 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2fdts_iso_m5(i, 2) 215 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2fdts_iso_m5(i, 3) 216 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2fdts_iso_m5(i, 4) 217 # Off diagonal hessian components are symmetric. 218 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2] 219 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2] 220 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2] 221 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2] 222 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2] 223 elif (self.data.jw_param_types[param1] == 'S2s' and self.data.jw_param_types[param2] == 'ts') \ 224 or (self.data.jw_param_types[param1] == 'ts' and self.data.jw_param_types[param2] == 'S2s'): 225 # Calculate the S2s/ts partial derivatives. 226 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2sdts_iso_m5(i, 0) 227 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2sdts_iso_m5(i, 1) 228 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2sdts_iso_m5(i, 2) 229 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2sdts_iso_m5(i, 3) 230 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2sdts_iso_m5(i, 4) 231 # Off diagonal hessian components are symmetric. 232 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2] 233 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2] 234 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2] 235 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2] 236 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2] 237 elif self.data.jw_param_types[param1] == 'ts' and self.data.jw_param_types[param2] == 'ts': 238 # Calculate the ts/ts partial derivatives. 239 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dts2_iso_m5(i, 0) 240 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dts2_iso_m5(i, 1) 241 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dts2_iso_m5(i, 2) 242 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dts2_iso_m5(i, 3) 243 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dts2_iso_m5(i, 4) 244 245 246 # Axially symmetric rotational diffusion. 247 elif match(self.data.diff_type, 'axail'): 248 raise NameError, "Axially symetric diffusion not implemented yet, quitting program." 249 250 # Anisotropic rotational diffusion. 251 elif match(self.data.diff_type, 'aniso'): 252 raise NameError, "Anisotropic diffusion not implemented yet, quitting program." 253 254 else: 255 raise NameError, "Function option not set correctly, quitting program."
256 257
258 - def calc_d2jw_dS2dte_iso_m24(self, i, frq_index):
259 "Calculate the model 2 and 4 S2/te partial derivative of the spectral density function for isotropic rotational diffusion." 260 261 temp = -0.4 * (1.0 - self.data.omega_te_prime_sqrd[i, frq_index]) / ((1.0 + self.data.omega_te_prime_sqrd[i, frq_index])**2) * self.data.fact_a**2 262 return temp
263 264
265 - def calc_d2jw_dte2_iso_m24(self, i, frq_index):
266 "Calculate the model 2 and 4 te/te partial derivative of the spectral density function for isotropic rotational diffusion." 267 268 a = 1.0 / ((1.0 + self.data.omega_te_prime_sqrd[i, frq_index])**3) 269 b = self.mf.data.frq_sqrd_list[i][frq_index] * self.data.te_prime * (3.0 - self.data.omega_te_prime_sqrd[i, frq_index]) 270 c = (1.0 - self.data.omega_te_prime_sqrd[i, frq_index]**2) * (self.data.te + self.data.tm) * self.data.tm**-2 271 272 temp = -0.8 * (1.0 - self.data.s2) * self.data.fact_a**4 * a * (b + c) 273 return temp
274 275
276 - def calc_d2jw_dS2fdS2s_iso_m5(self, i, frq_index):
277 "Calculate the model 5 S2f/S2s partial derivative of the spectral density function for isotropic rotational diffusion." 278 279 temp = 0.4 * (self.data.tm / (1.0 + self.data.omega_tm_sqrd[i, frq_index]) - self.data.ts_prime / (1.0 + self.data.omega_ts_prime_sqrd[i, frq_index])) 280 return temp
281 282
283 - def calc_d2jw_dS2fdts_iso_m5(self, i, frq_index):
284 "Calculate the model 5 S2f/ts partial derivative of the spectral density function for isotropic rotational diffusion." 285 286 temp = 0.4 * (1.0 - self.data.s2s) * ((1.0 - self.data.omega_ts_prime_sqrd[i, frq_index]) / ((1.0 + self.data.omega_ts_prime_sqrd[i, frq_index])**2)) * self.data.fact_a**2 287 return temp
288 289
290 - def calc_d2jw_dS2sdts_iso_m5(self, i, frq_index):
291 "Calculate the model 5 S2s/ts partial derivative of the spectral density function for isotropic rotational diffusion." 292 293 temp = -0.4 * self.data.s2f * ((1.0 - self.data.omega_ts_prime_sqrd[i, frq_index]) / ((1.0 + self.data.omega_ts_prime_sqrd[i, frq_index])**2)) * self.data.fact_a**2 294 return temp
295 296
297 - def calc_d2jw_dts2_iso_m5(self, i, frq_index):
298 "Calculate the model 5 ts/ts partial derivative of the spectral density function for isotropic rotational diffusion." 299 300 a = 1.0 / ((1.0 + self.data.omega_ts_prime_sqrd[i, frq_index])**3) 301 b = self.mf.data.frq_sqrd_list[i][frq_index] * self.data.ts_prime * (3.0 - self.data.omega_ts_prime_sqrd[i, frq_index]) 302 c = (1.0 - self.data.omega_ts_prime_sqrd[i, frq_index]**2) * (self.data.ts + self.data.tm) * self.data.tm**-2 303 304 temp = -0.8 * (self.data.s2f - self.data.s2) * self.data.fact_a**4 * a * (b + c) 305 return temp
306