1 from Numeric import Float64, zeros
2 from re import match
3
6 "Function for creating the model-free spectral density hessians."
7
8
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 Parameter transformations
26 ~~~~~~~~~~~~~~~~~~~~~~~~~
27 ae = c.te
28
29 af = c.tf
30
31 as = c.ts
32
33
34 therefore:
35
36 tm.ae
37 te' = ---------
38 ae + c.tm
39
40 tm.af
41 tf' = ---------
42 af + c.tm
43
44 tm.as
45 ts' = ---------
46 as + c.tm
47
48
49 Original: Model-free parameter - Model-free parameter
50 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
52 d2J(w)
53 ------ = 0
54 dS2**2
55
56
57 d2J(w) 2 (ae + c.tm)**2 - (w.tm.ae)**2
58 ------- = - - . c . tm**2 . ----------------------------------
59 dS2.dae 5 ((ae + c.tm)**2 + (w.tm.ae)**2)**2
60
61
62 d2J(w) 4 (ae + c.tm)**3 + 3.c.tm**3.ae.w**2.(ae + c.tm) - (1/ae).(w.tm.ae)**4
63 ------ = - - . c . tm**2 . (1 - S2) . --------------------------------------------------------------------
64 dae**2 5 ((ae + c.tm)**2 + (w.tm.ae)**2)**3
65
66
67 Original: Other parameters
68 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
69
70 d2J(w) d2J(w) d2J(w)
71 -------- = 0 , -------- = 0 , ------ = 0
72 dS2.dRex dS2.dcsa dS2.dr
73
74
75 d2J(w) d2J(w) d2J(w)
76 -------- = 0 , -------- = 0 , ------ = 0
77 dae.dRex dae.dcsa dae.dr
78
79
80 d2J(w) d2J(w) d2J(w)
81 ------- = 0 , --------- = 0 , ------- = 0
82 dRex**2 dRex.dcsa dRex.dr
83
84
85 d2J(w) d2J(w)
86 ------- = 0 , ------- = 0
87 dcsa**2 dcsa.dr
88
89
90 d2J(w)
91 ------ = 0
92 dr**2
93
94
95 Extended: Model-free parameter - Model-free parameter
96 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
98 d2J(w)
99 ------- = 0
100 dS2f**2
101
102
103 d2J(w) 2*tm / 1 (as + c.tm) . as \
104 --------- = ---- | ------------- - ----------------------------- |
105 dS2f.dS2s 5 \ 1 + (w.tm)**2 (as + c.tm)**2 + (w.tm.as)**2 /
106
107
108 d2J(w) 2 (af + c.tm)**2 - (w.tm.af)**2
109 -------- = - - . c . tm**2 . ----------------------------------
110 dS2f.daf 5 ((af + c.tm)**2 + (w.tm.af)**2)**2
111
112
113 d2J(w) 2 (as + c.tm)**2 - (w.tm.as)**2
114 -------- = - . c . tm**2 . (1 - S2s) . ----------------------------------
115 dS2f.das 5 ((as + c.tm)**2 + (w.tm.as)**2)**2
116
117
118 d2J(w) d2J(w)
119 ------- = 0 , ------------- = 0
120 dS2s**2 dS2s.daf
121
122
123 d2J(w) 2 (as + c.tm)**2 - (w.tm.as)**2
124 -------- = - - . c . tm**2 . S2f . ----------------------------------
125 dS2s.das 5 ((as + c.tm)**2 + (w.tm.as)**2)**2
126
127
128 d2J(w) 4 (af + c.tm)**3 + 3.c.tm**3.af.w**2.(af + c.tm) - (1/af).(w.tm.af)**4
129 ------ = - - . c . tm**2 . (1 - S2f) . --------------------------------------------------------------------
130 daf**2 5 ((af + c.tm)**2 + (w.tm.af)**2)**3
131
132
133 d2J(w)
134 ------- = 0
135 daf.das
136
137
138 d2J(w) 4 (as + c.tm)**3 + 3.c.tm**3.as.w**2.(as + c.tm) - (1/as).(w.tm.as)**4
139 ------ = - - . c . tm**2 . S2f . (1 - S2s) . --------------------------------------------------------------------
140 das**2 5 ((as + c.tm)**2 + (w.tm.as)**2)**3
141
142
143 Extended: Other parameters
144 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
145
146 d2J(w) d2J(w) d2J(w)
147 --------- = 0 , --------- = 0 , ------- = 0
148 dS2f.dRex dS2f.dcsa dS2f.dr
149
150
151 d2J(w) d2J(w) d2J(w)
152 --------- = 0 , --------- = 0 , ------- = 0
153 dS2s.dRex dS2s.dcsa dS2s.dr
154
155
156 d2J(w) d2J(w) d2J(w)
157 -------- = 0 , -------- = 0 , ------ = 0
158 daf.dRex daf.dcsa daf.dr
159
160
161 d2J(w) d2J(w) d2J(w)
162 -------- = 0 , -------- = 0 , ------ = 0
163 das.dRex das.dcsa das.dr
164
165
166 d2J(w) d2J(w) d2J(w)
167 ------- = 0 , --------- = 0 , ------- = 0
168 dRex**2 dRex.dcsa dRex.dr
169
170
171 d2J(w) d2J(w)
172 ------- = 0 , ------- = 0
173 dcsa**2 dcsa.dr
174
175
176 d2J(w)
177 ------ = 0
178 dr**2
179
180
181
182 """
183
184
185 self.data.d2jw = zeros((self.mf.data.num_frq, 5, len(self.data.params), len(self.data.params)), Float64)
186
187
188 if match(self.data.diff_type, 'iso'):
189
190 if match('m[24]', self.data.model):
191 for i in range(self.mf.data.num_frq):
192 for param1 in range(len(self.data.jw_param_types)):
193 for param2 in range(param1 + 1):
194 if (self.data.jw_param_types[param1] == 'S2' and self.data.jw_param_types[param2] == 'te') \
195 or (self.data.jw_param_types[param1] == 'te' and self.data.jw_param_types[param2] == 'S2'):
196
197 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2dae_iso_m24(i, 0)
198 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2dae_iso_m24(i, 1)
199 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2dae_iso_m24(i, 2)
200 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2dae_iso_m24(i, 3)
201 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2dae_iso_m24(i, 4)
202
203 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2]
204 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2]
205 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2]
206 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2]
207 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2]
208 elif self.data.jw_param_types[param1] == 'te' and self.data.jw_param_types[param2] == 'te':
209
210 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dae2_iso_m24(i, 0)
211 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dae2_iso_m24(i, 1)
212 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dae2_iso_m24(i, 2)
213 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dae2_iso_m24(i, 3)
214 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dae2_iso_m24(i, 4)
215 elif match('m5', self.data.model):
216 for i in range(self.mf.data.num_frq):
217 for param1 in range(len(self.data.jw_param_types)):
218 for param2 in range(param1 + 1):
219 if (self.data.jw_param_types[param1] == 'S2f' and self.data.jw_param_types[param2] == 'S2s') \
220 or (self.data.jw_param_types[param1] == 'S2s' and self.data.jw_param_types[param2] == 'S2f'):
221
222 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 0)
223 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 1)
224 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 2)
225 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 3)
226 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2fdS2s_iso_m5(i, 4)
227
228 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2]
229 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2]
230 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2]
231 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2]
232 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2]
233 elif (self.data.jw_param_types[param1] == 'S2f' and self.data.jw_param_types[param2] == 'ts') \
234 or (self.data.jw_param_types[param1] == 'ts' and self.data.jw_param_types[param2] == 'S2f'):
235
236 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2fdas_iso_m5(i, 0)
237 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2fdas_iso_m5(i, 1)
238 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2fdas_iso_m5(i, 2)
239 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2fdas_iso_m5(i, 3)
240 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2fdas_iso_m5(i, 4)
241
242 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2]
243 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2]
244 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2]
245 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2]
246 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2]
247 elif (self.data.jw_param_types[param1] == 'S2s' and self.data.jw_param_types[param2] == 'ts') \
248 or (self.data.jw_param_types[param1] == 'ts' and self.data.jw_param_types[param2] == 'S2s'):
249
250 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_dS2sdas_iso_m5(i, 0)
251 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_dS2sdas_iso_m5(i, 1)
252 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_dS2sdas_iso_m5(i, 2)
253 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_dS2sdas_iso_m5(i, 3)
254 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_dS2sdas_iso_m5(i, 4)
255
256 self.data.d2jw[i, 0, param2, param1] = self.data.d2jw[i, 0, param1, param2]
257 self.data.d2jw[i, 1, param2, param1] = self.data.d2jw[i, 1, param1, param2]
258 self.data.d2jw[i, 2, param2, param1] = self.data.d2jw[i, 2, param1, param2]
259 self.data.d2jw[i, 3, param2, param1] = self.data.d2jw[i, 3, param1, param2]
260 self.data.d2jw[i, 4, param2, param1] = self.data.d2jw[i, 4, param1, param2]
261 elif self.data.jw_param_types[param1] == 'ts' and self.data.jw_param_types[param2] == 'ts':
262
263 self.data.d2jw[i, 0, param1, param2] = self.calc_d2jw_das2_iso_m5(i, 0)
264 self.data.d2jw[i, 1, param1, param2] = self.calc_d2jw_das2_iso_m5(i, 1)
265 self.data.d2jw[i, 2, param1, param2] = self.calc_d2jw_das2_iso_m5(i, 2)
266 self.data.d2jw[i, 3, param1, param2] = self.calc_d2jw_das2_iso_m5(i, 3)
267 self.data.d2jw[i, 4, param1, param2] = self.calc_d2jw_das2_iso_m5(i, 4)
268
269
270
271 elif match(self.data.diff_type, 'axail'):
272 raise NameError, "Axially symetric diffusion not implemented yet, quitting program."
273
274
275 elif match(self.data.diff_type, 'aniso'):
276 raise NameError, "Anisotropic diffusion not implemented yet, quitting program."
277
278 else:
279 raise NameError, "Function option not set correctly, quitting program."
280
281
283 "Calculate the model 2 and 4 S2/te partial derivative of the spectral density function for isotropic rotational diffusion."
284
285 a = (self.data.ae_plus_c_tm_sqrd - self.data.omega_tm_ae_sqrd[i, frq_index])
286 b = (self.data.ae_plus_c_tm_sqrd + self.data.omega_tm_ae_sqrd[i, frq_index])**2
287 temp = -0.4 * self.data.c * self.data.tm_sqrd * (a/b)
288 return temp
289
290
292 "Calculate the model 2 and 4 te/te partial derivative of the spectral density function for isotropic rotational diffusion."
293
294 a = self.data.ae_plus_c_tm**3
295 b = 3.0 * self.data.c * self.data.tm**3 * self.data.ae * self.mf.data.frq_sqrd_list[i][frq_index] * self.data.ae_plus_c_tm
296 c = (self.mf.data.frq_list[i][frq_index] * self.data.tm)**4 * self.data.ae**3
297 d = (self.data.ae_plus_c_tm_sqrd + self.data.omega_tm_ae_sqrd[i, frq_index])**3
298 temp = -0.8 * self.data.c * self.data.tm_sqrd * (1.0 - self.data.s2) * (a + b - c) / d
299 return temp
300
301
303 "Calculate the model 5 S2f/S2s partial derivative of the spectral density function for isotropic rotational diffusion."
304
305 a = 1.0 / (1.0 + self.data.omega_tm_sqrd[i, frq_index])
306 b = self.data.as_plus_c_tm * self.data.as / (self.data.as_plus_c_tm_sqrd + self.data.omega_tm_as_sqrd[i, frq_index])
307 temp = 0.4 * self.data.tm * (a - b)
308 return temp
309
310
312 "Calculate the model 5 S2f/ts partial derivative of the spectral density function for isotropic rotational diffusion."
313
314 a = (self.data.as_plus_c_tm_sqrd - self.data.omega_tm_as_sqrd[i, frq_index])
315 b = (self.data.as_plus_c_tm_sqrd + self.data.omega_tm_as_sqrd[i, frq_index])**2
316 temp = -0.4 * self.data.c * self.data.tm_sqrd * (a/b)
317 return temp
318
319
321 "Calculate the model 5 S2s/ts partial derivative of the spectral density function for isotropic rotational diffusion."
322
323 a = (self.data.as_plus_c_tm_sqrd - self.data.omega_tm_as_sqrd[i, frq_index])
324 b = (self.data.as_plus_c_tm_sqrd + self.data.omega_tm_as_sqrd[i, frq_index])**2
325 temp = 0.4 * self.data.c * self.data.tm_sqrd * (1.0 - self.data.s2s) * (a/b)
326 return temp
327
328
330 "Calculate the model 5 ts/ts partial derivative of the spectral density function for isotropic rotational diffusion."
331
332 a = self.data.as_plus_c_tm**3
333 b = 3.0 * self.data.c * self.data.tm**3 * self.data.as * self.mf.data.frq_sqrd_list[i][frq_index] * self.data.as_plus_c_tm
334 c = (self.mf.data.frq_list[i][frq_index] * self.data.tm)**4 * self.data.as**3
335 d = (self.data.as_plus_c_tm_sqrd + self.data.omega_tm_as_sqrd[i, frq_index])**3
336 temp = -0.8 * self.data.c * self.data.tm_sqrd * self.data.s2f * (1.0 - self.data.s2s) * (a + b - c) / d
337 return temp
338