Author: tlinnet Date: Tue May 27 12:26:23 2014 New Revision: 23458 URL: http://svn.gna.org/viewcvs/relax?rev=23458&view=rev Log: Modified unit tests demonstrating edge cases 'no Rex' failures of the model 'MP05'. The cathing of errors for off-resonance R1rho models was implemented wrong. This was pointed out in the post http://article.gmane.org/gmane.science.nmr.relax.devel/5938. 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. Modified: branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mp05.py Modified: branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mp05.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mp05.py?rev=23458&r1=23457&r2=23458&view=diff ============================================================================== --- branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mp05.py (original) +++ branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mp05.py Tue May 27 12:26:23 2014 @@ -21,7 +21,7 @@ ############################################################################### # Python module imports. -from numpy import array, float64, int16, pi, zeros +from numpy import arctan2, array, cos, float64, int16, pi, sin, zeros from unittest import TestCase # relax module imports. @@ -69,15 +69,18 @@ # Calculate the R1rho values. R1rho = r1rho_MP05(r1rho_prime=self.r1rho_prime, omega=self.omega, offset=self.offset, pA=self.pA, pB=pB, dw=dw_frq, kex=self.kex, R1=self.r1, spin_lock_fields=spin_lock_omega1, spin_lock_fields2=spin_lock_omega1_squared, num_points=self.num_points) - + + # Compare to function value. + Wa = self.omega # Larmor frequency [s^-1]. + Wb = self.omega + dw_frq # Larmor frequency [s^-1]. + W = self.pA * Wa + pB * Wb # Pop-averaged Larmor frequency [s^-1]. + d = W - self.offset # Offset of spin-lock from pop-average. + theta = arctan2(spin_lock_omega1, d) # The rotating frame flip angle. + r1rho_no_rex = self.r1 * cos(theta)**2 + self.r1rho_prime * sin(theta)**2 # Check all R1rho values. - if self.kex > 1.e5: - for i in range(self.num_points): - self.assertAlmostEqual(R1rho[i], self.r1, 6) - else: - for i in range(self.num_points): - self.assertAlmostEqual(R1rho[i], self.r1rho_prime) + for i in range(self.num_points): + self.assertAlmostEqual(R1rho[i], r1rho_no_rex[i]) def param_conversion(self, pA=None, dw=None, sfrq=None, spin_lock_nu1=None):