1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from numpy import array, cos, float64, pi, sin, zeros
24 from unittest import TestCase
25
26
27 from lib.dispersion.dpl94 import r1rho_DPL94
28
29
31 """Unit tests for the lib.dispersion.dpl94 relax module."""
32
34 """Set up for all unit tests."""
35
36
37
38
39
40 self.r1rho_prime = 2.5
41
42 self.pA = 0.95
43
44 self.dw = 0.5
45 self.kex = 1000.0
46
47 self.r1 = 1.0
48
49 self.spin_lock_nu1 = array([ 1000., 1500., 2000., 2500., 3000., 3500., 4000., 4500., 5000., 5500., 6000.])
50
51 self.theta = array([1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966])
52
53
54 self.sfrq = 599.8908617*1E6
55
56
57 self.num_points = 11
58 self.R1rho = zeros(self.num_points, float64)
59
60
62 """Calculate and check the R1rho values."""
63
64
65 phi_ex_scaled, spin_lock_omega1_squared = self.param_conversion(pA=self.pA, dw=self.dw, sfrq=self.sfrq, spin_lock_nu1=self.spin_lock_nu1)
66
67
68 r1rho_DPL94(r1rho_prime=self.r1rho_prime, phi_ex=phi_ex_scaled, kex=self.kex, theta=self.theta, R1=self.r1, spin_lock_fields2=spin_lock_omega1_squared, back_calc=self.R1rho)
69
70
71 r1rho_no_rex = self.r1 * cos(self.theta)**2 + self.r1rho_prime * sin(self.theta)**2
72
73
74 if self.kex > 1.e5:
75 for i in range(self.num_points):
76 self.assertAlmostEqual(self.R1rho[i], r1rho_no_rex[i], 2)
77 else:
78 for i in range(self.num_points):
79 self.assertAlmostEqual(self.R1rho[i], r1rho_no_rex[i])
80
81
83 """Convert the parameters.
84
85 @keyword pA: The population of state A.
86 @type pA: float
87 @keyword dw: The chemical exchange difference between states A and B in ppm.
88 @type dw: float
89 @keyword sfrq: The spin Larmor frequencies in Hz.
90 @type sfrq: float
91 @keyword spin_lock_nu1: The spin-lock field strengths in Hertz.
92 @type spin_lock_nu1: float
93 @return: The parameters {phi_ex_scaled, k_BA}.
94 @rtype: tuple of float
95 """
96
97
98 pB = 1.0 - pA
99
100
101 frqs = sfrq * 2 * pi
102
103
104 phi_ex = pA * pB * (dw / 1.e6)**2
105
106
107 phi_ex_scaled = phi_ex * frqs**2
108
109
110 spin_lock_omega1_squared = (2. * pi * spin_lock_nu1)**2
111
112
113 return phi_ex_scaled, spin_lock_omega1_squared
114
115
117 """Test the r1rho_dpl94() function for no exchange when dw = 0.0."""
118
119
120 self.dw = 0.0
121
122
123 self.calc_r1rho()
124
125
127 """Test the r1rho_dpl94() function for no exchange when pA = 1.0."""
128
129
130 self.pA = 1.0
131
132
133 self.calc_r1rho()
134
135
137 """Test the r1rho_dpl94() function for no exchange when kex = 0.0."""
138
139
140 self.kex = 0.0
141
142
143 self.calc_r1rho()
144
145
147 """Test the r1rho_dpl94() function for no exchange when dw = 0.0 and pA = 1.0."""
148
149
150 self.pA = 1.0
151 self.dw = 0.0
152
153
154 self.calc_r1rho()
155
156
158 """Test the r1rho_dpl94() function for no exchange when dw = 0.0 and kex = 0.0."""
159
160
161 self.dw = 0.0
162 self.kex = 0.0
163
164
165 self.calc_r1rho()
166
167
169 """Test the r1rho_dpl94() function for no exchange when pA = 1.0 and kex = 0.0."""
170
171
172 self.pA = 1.0
173 self.kex = 0.0
174
175
176 self.calc_r1rho()
177
178
180 """Test the r1rho_dpl94() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
181
182
183 self.dw = 0.0
184 self.kex = 0.0
185
186
187 self.calc_r1rho()
188
189
191 """Test the r1rho_dpl94() function for no exchange when kex = 1e20."""
192
193
194 self.kex = 1e20
195
196
197 self.calc_r1rho()
198