1 from Numeric import Float64, zeros
2 from re import match
3
6 "Function for creating the model-free spectral density gradients."
7
8
10 """Function to create model-free spectral density gradients.
11
12 The spectral density gradients
13 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14
15 Data structure: self.data.djw
16 Dimension: 3D, (number of NMR frequencies, 5 spectral density frequencies, model-free parameters)
17 Type: Numeric 3D matrix, Float64
18 Dependencies: None
19 Required by: self.data.dri, 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
50 ~~~~~~~~
51
52 dJ(w) 2.tm / 1 (ae + c.tm) . ae \
53 ----- = ---- | ------------- - ----------------------------- |
54 dS2 5 \ 1 + (w.tm)**2 (ae + c.tm)**2 + (w.tm.ae)**2 /
55
56
57 dJ(w) 2 (ae + c.tm)**2 - (w.tm.ae)**2
58 ----- = - . c . tm**2 . (1 - S2) . ----------------------------------
59 dae 5 ((ae + c.tm)**2 + (w.tm.ae)**2)**2
60
61
62 dJ(w)
63 ----- = 0
64 dRex
65
66
67 dJ(w)
68 ----- = 0
69 dcsa
70
71
72 dJ(w)
73 ----- = 0
74 dr
75
76
77 Extended
78 ~~~~~~~~
79
80 dJ(w) 2.tm / S2s (af + c.tm) . af (1 - S2s)(as + c.tm) . as \
81 ----- = ---- | ------------- + ----------------------------- + ----------------------------- |
82 dS2f 5 \ 1 + (w.tm)**2 (af + c.tm)**2 + (w.tm.af)**2 (as + c.tm)**2 + (w.tm.as)**2 /
83
84
85 dJ(w) 2.S2f.tm / 1 (as + c.tm) . as \
86 ----- = -------- | ------------- + ----------------------------- |
87 dS2s 5 \ 1 + (w.tm)**2 (as + c.tm)**2 + (w.tm.as)**2 /
88
89
90 dJ(w) 2 (af + c.tm)**2 - (w.tm.af)**2
91 ----- = - . c . tm**2 . (1 - S2f) . ----------------------------------
92 daf 5 ((af + c.tm)**2 + (w.tm.af)**2)**2
93
94
95 dJ(w) 2 (as + c.tm)**2 - (w.tm.as)**2
96 ----- = - . c . tm**2 . (S2f - S2) . ----------------------------------
97 das 5 ((as + c.tm)**2 + (w.tm.as)**2)**2
98
99
100 dJ(w)
101 ----- = 0
102 dRex
103
104
105 dJ(w)
106 ----- = 0
107 dcsa
108
109
110 dJ(w)
111 ----- = 0
112 dr
113 """
114
115
116 self.data.djw = zeros((self.mf.data.num_frq, 5, len(self.data.params)), Float64)
117
118
119 if match(self.data.diff_type, 'iso'):
120 if match('m[13]', self.data.model):
121 for i in range(self.mf.data.num_frq):
122 for param in range(len(self.data.jw_param_types)):
123 if self.data.jw_param_types[param] == 'S2':
124 self.data.djw[i, 0, param] = self.calc_djw_dS2_iso_m13(i, 0)
125 self.data.djw[i, 1, param] = self.calc_djw_dS2_iso_m13(i, 1)
126 self.data.djw[i, 2, param] = self.calc_djw_dS2_iso_m13(i, 2)
127 self.data.djw[i, 3, param] = self.calc_djw_dS2_iso_m13(i, 3)
128 self.data.djw[i, 4, param] = self.calc_djw_dS2_iso_m13(i, 4)
129 elif match('m[24]', self.data.model):
130 for i in range(self.mf.data.num_frq):
131 for param in range(len(self.data.jw_param_types)):
132 if self.data.jw_param_types[param] == 'S2':
133 self.data.djw[i, 0, param] = self.calc_djw_dS2_iso_m24(i, 0)
134 self.data.djw[i, 1, param] = self.calc_djw_dS2_iso_m24(i, 1)
135 self.data.djw[i, 2, param] = self.calc_djw_dS2_iso_m24(i, 2)
136 self.data.djw[i, 3, param] = self.calc_djw_dS2_iso_m24(i, 3)
137 self.data.djw[i, 4, param] = self.calc_djw_dS2_iso_m24(i, 4)
138 elif self.data.jw_param_types[param] == 'te':
139 self.data.djw[i, 0, param] = self.calc_djw_dae_iso_m24(i, 0)
140 self.data.djw[i, 1, param] = self.calc_djw_dae_iso_m24(i, 1)
141 self.data.djw[i, 2, param] = self.calc_djw_dae_iso_m24(i, 2)
142 self.data.djw[i, 3, param] = self.calc_djw_dae_iso_m24(i, 3)
143 self.data.djw[i, 4, param] = self.calc_djw_dae_iso_m24(i, 4)
144 elif match('m5', self.data.model):
145 for i in range(self.mf.data.num_frq):
146 for param in range(len(self.data.jw_param_types)):
147 if self.data.jw_param_types[param] == 'S2f':
148 self.data.djw[i, 0, param] = self.calc_djw_dS2f_iso_m5(i, 0)
149 self.data.djw[i, 1, param] = self.calc_djw_dS2f_iso_m5(i, 1)
150 self.data.djw[i, 2, param] = self.calc_djw_dS2f_iso_m5(i, 2)
151 self.data.djw[i, 3, param] = self.calc_djw_dS2f_iso_m5(i, 3)
152 self.data.djw[i, 4, param] = self.calc_djw_dS2f_iso_m5(i, 4)
153 if self.data.jw_param_types[param] == 'S2s':
154 self.data.djw[i, 0, param] = self.calc_djw_dS2s_iso_m5(i, 0)
155 self.data.djw[i, 1, param] = self.calc_djw_dS2s_iso_m5(i, 1)
156 self.data.djw[i, 2, param] = self.calc_djw_dS2s_iso_m5(i, 2)
157 self.data.djw[i, 3, param] = self.calc_djw_dS2s_iso_m5(i, 3)
158 self.data.djw[i, 4, param] = self.calc_djw_dS2s_iso_m5(i, 4)
159 if self.data.jw_param_types[param] == 'ts':
160 self.data.djw[i, 0, param] = self.calc_djw_das_iso_m5(i, 0)
161 self.data.djw[i, 1, param] = self.calc_djw_das_iso_m5(i, 1)
162 self.data.djw[i, 2, param] = self.calc_djw_das_iso_m5(i, 2)
163 self.data.djw[i, 3, param] = self.calc_djw_das_iso_m5(i, 3)
164 self.data.djw[i, 4, param] = self.calc_djw_das_iso_m5(i, 4)
165
166
167 elif match(self.data.diff_type, 'axail'):
168 raise NameError, "Axially symetric diffusion not implemented yet, quitting program."
169
170
171 elif match(self.data.diff_type, 'aniso'):
172 raise NameError, "Anisotropic diffusion not implemented yet, quitting program."
173
174 else:
175 raise NameError, "Function option not set correctly, quitting program."
176
177
179 "Calculate the model 1 and 3 S2 derivative of the spectral density function for isotropic rotational diffusion."
180
181 temp = 0.4 * self.data.tm / (1.0 + self.data.omega_tm_sqrd[i, frq_index])
182 return temp
183
184
186 "Calculate the model 2 and 4 S2 derivative of the spectral density function for isotropic rotational diffusion."
187
188 a = 1.0 / (1.0 + self.data.omega_tm_sqrd[i, frq_index])
189 b = self.data.ae_plus_c_tm * self.data.ae / (self.data.ae_plus_c_tm_sqrd + self.data.omega_tm_ae_sqrd[i, frq_index])
190 temp = 0.4 * self.data.tm * (a - b)
191 return temp
192
193
195 "Calculate the model 5 S2f derivative of the spectral density function for isotropic rotational diffusion."
196
197 a = self.data.s2s / (1.0 + self.data.omega_tm_sqrd[i, frq_index])
198 b = (1.0 - self.data.s2s) * 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])
199 temp = 0.4 * self.data.tm * (a + b)
200 return temp
201
202
204 "Calculate the model 5 S2f derivative of the spectral density function for isotropic rotational diffusion."
205
206 a = 1.0 / (1.0 + self.data.omega_tm_sqrd[i, frq_index])
207 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])
208 temp = 0.4 * self.data.s2f * self.data.tm * (a - b)
209 return temp
210
211
213 "Calculate the model 2 and 4 te derivative of the spectral density function for isotropic rotational diffusion."
214
215 a = (self.data.ae_plus_c_tm_sqrd - self.data.omega_tm_ae_sqrd[i, frq_index])
216 b = (self.data.ae_plus_c_tm_sqrd + self.data.omega_tm_ae_sqrd[i, frq_index])**2
217 temp = 0.4 * self.data.c * self.data.tm_sqrd * (1.0 - self.data.s2) * (a/b)
218 return temp
219
220
222 "Calculate the model 5 ts derivative of the spectral density function for isotropic rotational diffusion."
223
224 a = (self.data.as_plus_c_tm_sqrd - self.data.omega_tm_as_sqrd[i, frq_index])
225 b = (self.data.as_plus_c_tm_sqrd + self.data.omega_tm_as_sqrd[i, frq_index])**2
226 temp = 0.4 * self.data.c * self.data.tm_sqrd * self.data.s2f * (1.0 - self.data.s2s) * (a/b)
227
228 return temp
229