mailr23588 - in /branches/disp_speed: lib/dispersion/ target_functions/ test_suite/unit_tests/_lib/_dispersion/


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

Header


Content

Posted by tlinnet on May 29, 2014 - 12:33:
Author: tlinnet
Date: Thu May 29 12:33:36 2014
New Revision: 23588

URL: http://svn.gna.org/viewcvs/relax?rev=23588&view=rev
Log:
Converting back to having back_calc as a function argument to model TSMFK01.

This is to clean up the API.
There can be bo no partial measures/implementations in the relax trunk.

The problem is, that many numerical models can't be optimised further, since 
they
evolve the spin-magnetisation in a matrix.  That spin evolvement can't be put 
into
a larger numpy array.

This is related to: task #7793: (https://gna.org/task/?7793) Speed-up of 
dispersion models.

Modified:
    branches/disp_speed/lib/dispersion/tsmfk01.py
    branches/disp_speed/target_functions/relax_disp.py
    branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_tsmfk01.py

Modified: branches/disp_speed/lib/dispersion/tsmfk01.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/tsmfk01.py?rev=23588&r1=23587&r2=23588&view=diff
==============================================================================
--- branches/disp_speed/lib/dispersion/tsmfk01.py       (original)
+++ branches/disp_speed/lib/dispersion/tsmfk01.py       Thu May 29 12:33:36 
2014
@@ -70,7 +70,7 @@
 from numpy import array, min, sin, isfinite, sum
 
 
-def r2eff_TSMFK01(r20a=None, dw=None, k_AB=None, tcp=None, num_points=None):
+def r2eff_TSMFK01(r20a=None, dw=None, k_AB=None, tcp=None, back_calc=None, 
num_points=None):
     """Calculate the R2eff values for the TSMFK01 model.
 
     See the module docstring for details.
@@ -84,13 +84,16 @@
     @type k_AB:             float
     @keyword tcp:           The tau_CPMG times (1 / 4.nu1).
     @type tcp:              numpy rank-1 float array.
-    @keyword num_points:    The number of points on the dispersion curve, 
equal to the length of the cpmg_frqs.
+    @keyword back_calc:     The array for holding the back calculated R2eff 
values.  Each element corresponds to one of the CPMG nu1 frequencies.
+    @type back_calc:        numpy rank-1 float array
+    @keyword num_points:    The number of points on the dispersion curve, 
equal to the length of the cpmg_frqs and back_calc arguments.
     @type num_points:       int
     """
 
     # Catch parameter values that will result in no exchange, returning flat 
R2eff = R20 lines (when kex = 0.0, k_AB = 0.0).
     if dw == 0.0 or k_AB == 0.0:
-        return array([r20a]*num_points)
+        back_calc[:] = array([r20a]*num_points)
+        return
 
     # Denominator.
     denom = dw * tcp
@@ -101,7 +104,8 @@
     # Catch zeros (to avoid pointless mathematical operations).
     # This will result in no exchange, returning flat lines.
     if min(numer) == 0.0:
-        return array([r20a + k_AB]*num_points) 
+        back_calc[:] = array([r20a + k_AB]*num_points)
+        return
 
     # Calculate R2eff.
     R2eff = r20a + k_AB - k_AB * numer / denom
@@ -111,4 +115,4 @@
     if not isfinite(sum(R2eff)):
         R2eff = array([1e100]*num_points)
 
-    return R2eff
+    back_calc[:] = R2eff

Modified: branches/disp_speed/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/target_functions/relax_disp.py?rev=23588&r1=23587&r2=23588&view=diff
==============================================================================
--- branches/disp_speed/target_functions/relax_disp.py  (original)
+++ branches/disp_speed/target_functions/relax_disp.py  Thu May 29 12:33:36 
2014
@@ -1921,7 +1921,7 @@
                 dw_frq = dw[si] * self.frqs[0][si][mi]
 
                 # Back calculate the R2eff values.
-                self.back_calc[0][si][mi][0] = 
r2eff_TSMFK01(r20a=R20A[r20a_index], dw=dw_frq, k_AB=k_AB, 
tcp=self.tau_cpmg[0][mi], num_points=self.num_disp_points[0][si][mi][0])
+                r2eff_TSMFK01(r20a=R20A[r20a_index], dw=dw_frq, k_AB=k_AB, 
tcp=self.tau_cpmg[0][mi], back_calc=self.back_calc[0][si][mi][0], 
num_points=self.num_disp_points[0][si][mi][0])
 
                 # For all missing data points, set the back-calculated value 
to the measured values so that it has no effect on the chi-squared value.
                 for di in range(self.num_disp_points[0][si][mi][0]):

Modified: 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_tsmfk01.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_tsmfk01.py?rev=23588&r1=23587&r2=23588&view=diff
==============================================================================
--- 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_tsmfk01.py  
(original)
+++ 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_tsmfk01.py  
Thu May 29 12:33:36 2014
@@ -45,6 +45,7 @@
         relax_times = 0.04
         self.cpmg_frqs = self.ncyc / relax_times
         self.tau_cpmg = 0.25 / self.cpmg_frqs
+        self.R2eff = zeros(self.num_points, float64)
 
         # The spin Larmor frequencies.
         self.sfrq = 200. * 1E6
@@ -57,11 +58,11 @@
         k_AB, k_BA, pB, dw_frq = self.param_conversion(pA=self.pA, 
kex=self.kex, dw=self.dw, sfrq=self.sfrq)
 
         # Calculate the R2eff values.
-        R2eff = r2eff_TSMFK01(r20a=self.r20a, dw=dw_frq, k_AB=k_AB, 
tcp=self.cpmg_frqs, num_points=self.num_points)
+        r2eff_TSMFK01(r20a=self.r20a, dw=dw_frq, k_AB=k_AB, 
tcp=self.cpmg_frqs, back_calc=self.R2eff, num_points=self.num_points)
 
         # Check all R2eff values.
         for i in range(self.num_points):
-            self.assertAlmostEqual(R2eff[i], self.r20a)
+            self.assertAlmostEqual(self.R2eff[i], self.r20a)
 
 
     def param_conversion(self, pA=None, kex=None, dw=None, sfrq=None):




Related Messages


Powered by MHonArc, Updated Thu May 29 13:20:03 2014