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