1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module for the calculation of pseudocontact shifts."""
25
26
27 from numpy import dot, sum
28
29
31 """Calculate the ensemble average PCS, using the 3D tensor.
32
33 This function calculates the average PCS for a set of XH bond vectors from a structural ensemble, using the 3D tensorial form of the alignment tensor. The formula for this ensemble average PCS value is::
34
35 _N_
36 \ T
37 <delta_ij(theta)> = > pc . djc . mu_jc . Ai . mu_jc,
38 /__
39 c=1
40
41 where:
42 - i is the alignment tensor index,
43 - j is the index over spins,
44 - c is the index over the states or multiple structures,
45 - N is the total number of states or structures,
46 - theta is the parameter vector,
47 - djc is the PCS constant for spin j and state c,
48 - pc is the population probability or weight associated with state c (equally weighted to 1/N if weights are not provided),
49 - mu_jc is the unit vector corresponding to spin j and state c,
50 - Ai is the alignment tensor.
51
52 The PCS constant is defined as::
53
54 mu0 15kT 1
55 dj = --- ----- ---- ,
56 4pi Bo**2 r**3
57
58 where:
59 - mu0 is the permeability of free space,
60 - k is Boltzmann's constant,
61 - T is the absolute temperature,
62 - Bo is the magnetic field strength,
63 - r is the distance between the paramagnetic centre (electron spin) and the nuclear spin.
64
65
66 @param dj: The PCS constants for each structure c for spin j. This should be an array with indices corresponding to c.
67 @type dj: numpy rank-1 array
68 @param vect: The electron-nuclear unit vector matrix. The first dimension corresponds to the structural index, the second dimension is the coordinates of the unit vector. The vectors should be parallel to the vector connecting the paramagnetic centre to the nuclear spin.
69 @type vect: numpy matrix
70 @param N: The total number of structures.
71 @type N: int
72 @param A: The alignment tensor.
73 @type A: numpy rank-2 3D tensor
74 @param weights: The weights for each member of the ensemble (the last member need not be supplied).
75 @type weights: numpy rank-1 array
76 @return: The average PCS value.
77 @rtype: float
78 """
79
80
81 val = 0.0
82
83
84 if weights == None:
85 pc = 1.0 / N
86 weights = [pc] * N
87
88
89 if len(weights) < N:
90 pN = 1.0 - sum(weights, axis=0)
91 weights = weights.tolist()
92 weights.append(pN)
93
94
95 for c in xrange(N):
96 val = val + weights[c] * dj[c] * dot(vect[c], dot(A, vect[c]))
97
98
99 return val
100
101
103 """Calculate the ensemble average PCS gradient element for Amn, using the 3D tensor.
104
105 This function calculates the average PCS gradient for a set of electron-nuclear spin unit vectors (paramagnetic to the nuclear spin) from a structural ensemble, using the 3D tensorial form of the alignment tensor. The formula for this ensemble average PCS gradient element is::
106
107 _N_
108 ddelta_ij(theta) \ T dAi
109 ---------------- = > pc . djc . mu_jc . ---- . mu_jc,
110 dAmn /__ dAmn
111 c=1
112
113 where:
114 - i is the alignment tensor index,
115 - j is the index over spins,
116 - m, the index over the first dimension of the alignment tensor m = {x, y, z}.
117 - n, the index over the second dimension of the alignment tensor n = {x, y, z},
118 - c is the index over the states or multiple structures,
119 - theta is the parameter vector,
120 - Amn is the matrix element of the alignment tensor,
121 - djc is the PCS constant for spin j and state c,
122 - N is the total number of states or structures,
123 - pc is the population probability or weight associated with state c (equally weighted to 1/N if weights are not provided),
124 - mu_jc is the unit vector corresponding to spin j and state c,
125 - dAi/dAmn is the partial derivative of the alignment tensor with respect to element Amn.
126
127
128 @param dj: The PCS constants for each structure c for spin j. This should be an array with indices corresponding to c.
129 @type dj: numpy rank-1 array
130 @param vect: The electron-nuclear unit vector matrix. The first dimension corresponds to the structural index, the second dimension is the coordinates of the unit vector. The vectors should be parallel to the vector connecting the paramagnetic centre to the nuclear spin.
131 @type vect: numpy matrix
132 @param N: The total number of structures.
133 @type N: int
134 @param dAi_dAmn: The alignment tensor derivative with respect to parameter Amn.
135 @type dAi_dAmn: numpy rank-2 3D tensor
136 @param weights: The weights for each member of the ensemble (the last member need not be supplied).
137 @type weights: numpy rank-1 array
138 @return: The average PCS gradient element.
139 @rtype: float
140 """
141
142
143 grad = 0.0
144
145
146 if weights == None:
147 pc = 1.0 / N
148 weights = [pc] * N
149
150
151 if len(weights) < N:
152 pN = 1.0 - sum(weights, axis=0)
153 weights = weights.tolist()
154 weights.append(pN)
155
156
157 for c in xrange(N):
158 grad = grad + weights[c] * dj[c] * dot(vect[c], dot(dAi_dAmn, vect[c]))
159
160
161 return grad
162
163
165 """Calculate the PCS, using the 3D alignment tensor.
166
167 The PCS value is::
168
169 T
170 delta_ij(theta) = dj . mu_j . Ai . mu_j,
171
172 where:
173 - i is the alignment tensor index,
174 - j is the index over spins,
175 - theta is the parameter vector,
176 - dj is the PCS constant for spin j,
177 - mu_j i the unit vector corresponding to spin j,
178 - Ai is the alignment tensor.
179
180 The PCS constant is defined as::
181
182 mu0 15kT 1
183 dj = --- ----- ---- ,
184 4pi Bo**2 r**3
185
186 where:
187 - mu0 is the permeability of free space,
188 - k is Boltzmann's constant,
189 - T is the absolute temperature,
190 - Bo is the magnetic field strength,
191 - r is the distance between the paramagnetic centre (electron spin) and the nuclear spin.
192
193
194 @param dj: The PCS constant for spin j.
195 @type dj: float
196 @param mu: The unit vector connecting the electron and nuclear spins.
197 @type mu: numpy rank-1 3D array
198 @param A: The alignment tensor.
199 @type A: numpy rank-2 3D tensor
200 @return: The PCS value.
201 @rtype: float
202 """
203
204
205 return dj * dot(mu, dot(A, mu))
206