mailr23433 - /branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_m61b.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by tlinnet on May 26, 2014 - 20:13:
Author: tlinnet
Date: Mon May 26 20:13:56 2014
New Revision: 23433

URL: http://svn.gna.org/viewcvs/relax?rev=23433&view=rev
Log:
Added 8 unit tests demonstrating edge case 'no Rex' failures of the model 
'M61b'.

This follows from the ideas in the post 
http://article.gmane.org/gmane.science.nmr.relax.devel/5858.
This is related to: task #7793: (https://gna.org/task/?7793) Speed-up of 
dispersion models.

This is to implement catching of math domain errors, before they occur.

These tests cover all parameter value combinations which result in no 
exchange:

    - dw = 0.0,
    - pA = 1.0,
    - kex = 0.0,
    - dw = 0.0 and pA = 1.0,
    - dw = 0.0 and kex = 0.0,
    - pA = 1.0 and kex = 0.0,
    - dw = 0.0, pA = 1.0, and kex = 0.0.
    - kex = 1e20,

Modified:
    branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_m61b.py

Modified: 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_m61b.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_m61b.py?rev=23433&r1=23432&r2=23433&view=diff
==============================================================================
--- branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_m61b.py   
  (original)
+++ branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_m61b.py   
  Mon May 26 20:13:56 2014
@@ -25,54 +25,71 @@
 from unittest import TestCase
 
 # relax module imports.
-from lib.dispersion.lm63 import r2eff_LM63
+from lib.dispersion.m61b import r1rho_M61b
 
 
-class Test_lm63(TestCase):
-    """Unit tests for the lib.dispersion.lm63 relax module."""
+class Test_m61b(TestCase):
+    """Unit tests for the lib.dispersion.m61b relax module."""
 
     def setUp(self):
         """Set up for all unit tests."""
 
         # Default parameter values.
-        self.r20 = 2.0
+
+
+        # The R1rho_prime parameter value (R1rho with no exchange).
+        self.r1rho_prime = 2.5
+        # Population of ground state.
         self.pA = 0.9
+        # The chemical exchange difference between states A and B in ppm.
         self.dw = 0.5
-        self.kex = 100.0
+        self.kex = 1000.0
+        # The R1 relaxation rates.
+        self.r1 = 1.0
+        # The spin-lock field strengths in Hertz.
+        self.spin_lock_nu1 = array([ 1000., 1500., 2000., 2500., 3000., 
3500., 4000., 4500., 5000., 5500., 6000.])
+        # The rotating frame tilt angles for each dispersion point.
+        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])
 
         # The spin Larmor frequencies.
         self.sfrq = 599.8908617*1E6
 
         # Required data structures.
-        self.num_points = 3
-        self.cpmg_frqs = array([[2.5, 1.25, 0.83]], float64)
-        self.R2eff = zeros(3, float64)
+        self.num_points = 11
 
 
-    def calc_r2eff(self):
-        """Calculate and check the R2eff values."""
+    def calc_r1rho(self):
+        """Calculate and check the R1rho values."""
 
         # Parameter conversions.
-        phi_ex_scaled = self.param_conversion(pA=self.pA, dw=self.dw, 
sfrq=self.sfrq)
+        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)
 
-        # Calculate the R2eff values.
-        R2eff = r2eff_LM63(r20=self.r20, phi_ex=phi_ex_scaled, kex=self.kex, 
cpmg_frqs=self.cpmg_frqs, num_points=self.num_points)
-        # Check all R2eff values.
-        for i in range(self.num_points):
-            self.assertAlmostEqual(R2eff[i], self.r20)
+        # Calculate the R1rho values.
+        R1rho = r1rho_M61b(r1rho_prime=self.r1rho_prime, pA=self.pA, 
dw=dw_frq, kex=self.kex, spin_lock_fields2=spin_lock_omega1_squared, 
num_points=self.num_points)
 
 
-    def param_conversion(self, pA=None, dw=None, sfrq=None):
+        # Check all R1rho values.
+        if self.kex > 1.e5:
+            for i in range(self.num_points):
+                self.assertAlmostEqual(R1rho[i], self.r1rho_prime, 2)
+        else:
+            for i in range(self.num_points):
+                self.assertAlmostEqual(R1rho[i], self.r1rho_prime)
+
+
+    def param_conversion(self, pA=None, dw=None, sfrq=None, 
spin_lock_nu1=None):
         """Convert the parameters.
 
-        @keyword pA:    The population of state A.
-        @type pA:       float
-        @keyword dw:    The chemical exchange difference between states A 
and B in ppm.
-        @type dw:       float
-        @keyword sfrq:  The spin Larmor frequencies in Hz.
-        @type sfrq:     float
-        @return:        The parameters phi_ex_scaled
-        @rtype:         float
+        @keyword pA:            The population of state A.
+        @type pA:               float
+        @keyword dw:            The chemical exchange difference between 
states A and B in ppm.
+        @type dw:               float
+        @keyword sfrq:          The spin Larmor frequencies in Hz.
+        @type sfrq:             float
+        @keyword spin_lock_nu1: The spin-lock field strengths in Hertz. 
+        @type spin_lock_nu1:    float
+        @return:                The parameters {phi_ex_scaled, dw_frq, 
spin_lock_omega1_squared}.
+        @rtype:                 tuple of float
         """
 
         # Calculate pB.
@@ -81,85 +98,101 @@
         # Calculate spin Larmor frequencies in 2pi.
         frqs = sfrq * 2 * pi
 
+        # Convert dw from ppm to rad/s.
+        dw_frq = dw * frqs
+
         # The phi_ex parameter value (pA * pB * delta_omega^2).
         phi_ex = pA * pB * dw**2
 
         # Convert phi_ex from ppm^2 to (rad/s)^2.
         phi_ex_scaled = phi_ex * frqs**2
 
+        # The R1rho spin-lock field strengths squared (in rad^2.s^-2).
+        spin_lock_omega1_squared = (2. * pi * spin_lock_nu1)**2
+
         # Return all values.
-        return phi_ex_scaled
+        return phi_ex_scaled, dw_frq, spin_lock_omega1_squared
 
 
-    def test_lm63_no_rex1(self):
-        """Test the r2eff_lm63() function for no exchange when dw = 0.0."""
+    def test_m61b_no_rex1(self):
+        """Test the r1rho_m61b() function for no exchange when dw = 0.0."""
 
         # Parameter reset.
         self.dw = 0.0
 
-        # Calculate and check the R2eff values.
-        self.calc_r2eff()
+        # Calculate and check the R1rho values.
+        self.calc_r1rho()
 
 
-    def test_lm63_no_rex2(self):
-        """Test the r2eff_lm63() function for no exchange when pA = 1.0."""
+    def test_m61b_no_rex2(self):
+        """Test the r1rho_m61b() function for no exchange when pA = 1.0."""
 
         # Parameter reset.
         self.pA = 1.0
 
-        # Calculate and check the R2eff values.
-        self.calc_r2eff()
+        # Calculate and check the R1rho values.
+        self.calc_r1rho()
 
 
-    def test_lm63_no_rex3(self):
-        """Test the r2eff_lm63() function for no exchange when kex = 0.0."""
+    def test_m61b_no_rex3(self):
+        """Test the r1rho_m61b() function for no exchange when kex = 0.0."""
 
         # Parameter reset.
         self.kex = 0.0
 
-        # Calculate and check the R2eff values.
-        self.calc_r2eff()
+        # Calculate and check the R1rho values.
+        self.calc_r1rho()
 
 
-    def test_lm63_no_rex4(self):
-        """Test the r2eff_lm63() function for no exchange when dw = 0.0 and 
pA = 1.0."""
+    def test_m61b_no_rex4(self):
+        """Test the r1rho_m61b() function for no exchange when dw = 0.0 and 
pA = 1.0."""
 
         # Parameter reset.
         self.pA = 1.0
         self.dw = 0.0
 
-        # Calculate and check the R2eff values.
-        self.calc_r2eff()
+        # Calculate and check the R1rho values.
+        self.calc_r1rho()
 
 
-    def test_lm63_no_rex5(self):
-        """Test the r2eff_lm63() function for no exchange when dw = 0.0 and 
kex = 0.0."""
+    def test_m61b_no_rex5(self):
+        """Test the r1rho_m61b() function for no exchange when dw = 0.0 and 
kex = 0.0."""
 
         # Parameter reset.
         self.dw = 0.0
         self.kex = 0.0
 
-        # Calculate and check the R2eff values.
-        self.calc_r2eff()
+        # Calculate and check the R1rho values.
+        self.calc_r1rho()
 
 
-    def test_lm63_no_rex6(self):
-        """Test the r2eff_lm63() function for no exchange when pA = 1.0 and 
kex = 0.0."""
+    def test_m61b_no_rex6(self):
+        """Test the r1rho_m61b() function for no exchange when pA = 1.0 and 
kex = 0.0."""
 
         # Parameter reset.
         self.pA = 1.0
         self.kex = 0.0
 
-        # Calculate and check the R2eff values.
-        self.calc_r2eff()
+        # Calculate and check the R1rho values.
+        self.calc_r1rho()
 
 
-    def test_lm63_no_rex7(self):
-        """Test the r2eff_lm63() function for no exchange when dw = 0.0, pA 
= 1.0, and kex = 0.0."""
+    def test_m61b_no_rex7(self):
+        """Test the r1rho_m61b() function for no exchange when dw = 0.0, pA 
= 1.0, and kex = 0.0."""
 
         # Parameter reset.
         self.dw = 0.0
         self.kex = 0.0
 
+        # Calculate and check the R1rho values.
+        self.calc_r1rho()
+
+
+    def test_m61b_no_rex8(self):
+        """Test the r1rho_m61b() function for no exchange when kex = 1e20."""
+
+        # Parameter reset.
+        self.kex = 1e20
+
         # Calculate and check the R2eff values.
-        self.calc_r2eff()
+        self.calc_r1rho()




Related Messages


Powered by MHonArc, Updated Mon May 26 20:20:03 2014