mailr23585 - 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:24:
Author: tlinnet
Date: Thu May 29 12:24:23 2014
New Revision: 23585

URL: http://svn.gna.org/viewcvs/relax?rev=23585&view=rev
Log:
Converting back to having back_calc as a function argument to model NS CPMG 
2site expanded.

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/ns_cpmg_2site_expanded.py
    branches/disp_speed/target_functions/relax_disp.py
    
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_ns_cpmg_2site_expanded.py

Modified: branches/disp_speed/lib/dispersion/ns_cpmg_2site_expanded.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/ns_cpmg_2site_expanded.py?rev=23585&r1=23584&r2=23585&view=diff
==============================================================================
--- branches/disp_speed/lib/dispersion/ns_cpmg_2site_expanded.py        
(original)
+++ branches/disp_speed/lib/dispersion/ns_cpmg_2site_expanded.py        Thu 
May 29 12:24:23 2014
@@ -241,7 +241,7 @@
 from lib.float import isNaN
 
 
-def r2eff_ns_cpmg_2site_expanded(r20=None, pA=None, dw=None, k_AB=None, 
k_BA=None, relax_time=None, inv_relax_time=None, tcp=None, num_points=None, 
num_cpmg=None):
+def r2eff_ns_cpmg_2site_expanded(r20=None, pA=None, dw=None, k_AB=None, 
k_BA=None, relax_time=None, inv_relax_time=None, tcp=None, back_calc=None, 
num_points=None, num_cpmg=None):
     """The 2-site numerical solution to the Bloch-McConnell equation using 
complex conjugate matrices.
 
     This function calculates and stores the R2eff values.
@@ -263,7 +263,9 @@
     @type inv_relax_time:       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 tcp .
+    @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 tcp and back_calc arguments.
     @type num_points:           int
     @keyword num_cpmg:          The array of numbers of CPMG blocks.
     @type num_cpmg:             numpy int16, rank-1 array
@@ -271,7 +273,8 @@
 
     # 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 pA == 1.0 or k_AB == 0.0:
-        return array([r20]*num_points)
+        back_calc[:] = array([r20]*num_points)
+        return
 
     # Repeditive calculations.
     half_tcp = 0.5 * tcp
@@ -363,4 +366,4 @@
     if not isfinite(sum(R2eff)) or min(Mx) <= 0.0 or not isfinite(sum(Mx)):
         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=23585&r1=23584&r2=23585&view=diff
==============================================================================
--- branches/disp_speed/target_functions/relax_disp.py  (original)
+++ branches/disp_speed/target_functions/relax_disp.py  Thu May 29 12:24:23 
2014
@@ -1480,7 +1480,7 @@
                 dw_frq = dw[si] * self.frqs[0][si][mi]
 
                 # Back calculate the R2eff values.
-                self.back_calc[0][si][mi][0] = 
r2eff_ns_cpmg_2site_expanded(r20=R20[r20_index], pA=pA, dw=dw_frq, k_AB=k_AB, 
k_BA=k_BA, relax_time=self.relax_times[0][mi], 
inv_relax_time=self.inv_relax_times[0][mi], tcp=self.tau_cpmg[0][mi], 
num_points=self.num_disp_points[0][si][mi][0], num_cpmg=self.power[0][mi])
+                r2eff_ns_cpmg_2site_expanded(r20=R20[r20_index], pA=pA, 
dw=dw_frq, k_AB=k_AB, k_BA=k_BA, relax_time=self.relax_times[0][mi], 
inv_relax_time=self.inv_relax_times[0][mi], 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], num_cpmg=self.power[0][mi])
 
                 # 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_ns_cpmg_2site_expanded.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_ns_cpmg_2site_expanded.py?rev=23585&r1=23584&r2=23585&view=diff
==============================================================================
--- 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_ns_cpmg_2site_expanded.py
   (original)
+++ 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_ns_cpmg_2site_expanded.py
   Thu May 29 12:24:23 2014
@@ -43,6 +43,7 @@
         self.num_points = 3
         self.tcp = array([0.1, 0.2, 0.3], float64)
         self.num_cpmg = array([1, 2, 3], int16)
+        self.R2eff = zeros(self.num_points, float64)
 
         # The spin Larmor frequencies.
         self.sfrq = 200. * 1E6
@@ -55,14 +56,14 @@
         k_AB, k_BA, dw_frq = self.param_conversion(pA=self.pA, kex=self.kex, 
dw=self.dw, sfrq=self.sfrq)
 
         # Calculate the R2eff values.
-        R2eff = r2eff_ns_cpmg_2site_expanded(r20=self.r20, pA=self.pA, 
dw=dw_frq, k_AB=k_AB, k_BA=k_BA, relax_time=0.3, inv_relax_time=1/0.3, 
tcp=self.tcp, num_points=self.num_points, num_cpmg=self.num_cpmg)
+        r2eff_ns_cpmg_2site_expanded(r20=self.r20, pA=self.pA, dw=dw_frq, 
k_AB=k_AB, k_BA=k_BA, relax_time=0.3, inv_relax_time=1/0.3, tcp=self.tcp, 
back_calc=self.R2eff, num_points=self.num_points, num_cpmg=self.num_cpmg)
 
         if self.kex >= 1.e5:
             for i in range(self.num_points):
-                self.assertAlmostEqual(R2eff[i], self.r20, 5)
+                self.assertAlmostEqual(self.R2eff[i], self.r20, 5)
         else:
             for i in range(self.num_points):
-                self.assertAlmostEqual(R2eff[i], self.r20)
+                self.assertAlmostEqual(self.R2eff[i], self.r20)
 
 
     def param_conversion(self, pA=None, kex=None, dw=None, sfrq=None):




Related Messages


Powered by MHonArc, Updated Thu May 29 12:40:03 2014