mailr23583 - 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 - 11:52:
Author: tlinnet
Date: Thu May 29 11:52:37 2014
New Revision: 23583

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

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

Modified: branches/disp_speed/lib/dispersion/mmq_cr72.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/mmq_cr72.py?rev=23583&r1=23582&r2=23583&view=diff
==============================================================================
--- branches/disp_speed/lib/dispersion/mmq_cr72.py      (original)
+++ branches/disp_speed/lib/dispersion/mmq_cr72.py      Thu May 29 11:52:37 
2014
@@ -50,7 +50,7 @@
 from numpy import arccosh, array, cos, cosh, isfinite, log, max, sin, sqrt, 
sum
 
 
-def r2eff_mmq_cr72(r20=None, pA=None, pB=None, dw=None, dwH=None, kex=None, 
k_AB=None, k_BA=None, cpmg_frqs=None, inv_tcpmg=None, tcp=None, 
num_points=None, power=None):
+def r2eff_mmq_cr72(r20=None, pA=None, pB=None, dw=None, dwH=None, kex=None, 
k_AB=None, k_BA=None, cpmg_frqs=None, inv_tcpmg=None, tcp=None, 
back_calc=None, num_points=None, power=None):
     """The CR72 model extended to MMQ CPMG data.
 
     This function calculates and stores the R2eff values.
@@ -78,7 +78,9 @@
     @type inv_tcpmg:        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 power:         The matrix exponential power array.
     @type power:            numpy int16, rank-1 array
@@ -86,7 +88,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 and dwH == 0.0) or pA == 1.0 or k_AB == 0.0:
-        return array([r20]*num_points)
+        back_calc[:] = array([r20]*num_points)
+        return
 
     # Repetitive calculations (to speed up calculations).
     dw2 = dw**2
@@ -130,7 +133,8 @@
     # Catch math domain error of cosh(val > 710).
     # This is when etapos > 710.
     if max(etapos) > 700:
-        return array([r20]*num_points)
+        back_calc[:] = array([r20]*num_points)
+        return
 
     # The full eta - values.
     etaneg = etaneg_part / cpmg_frqs
@@ -156,4 +160,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=23583&r1=23582&r2=23583&view=diff
==============================================================================
--- branches/disp_speed/target_functions/relax_disp.py  (original)
+++ branches/disp_speed/target_functions/relax_disp.py  Thu May 29 11:52:37 
2014
@@ -1335,7 +1335,7 @@
                         aliased_dwH = dw_frq
 
                     # Back calculate the R2eff values.
-                    self.back_calc[ei][si][mi][0] = 
r2eff_mmq_cr72(r20=R20[r20_index], pA=pA, pB=pB, dw=aliased_dw, 
dwH=aliased_dwH, kex=kex, k_AB=k_AB, k_BA=k_BA, 
cpmg_frqs=self.cpmg_frqs[ei][mi][0], inv_tcpmg=self.inv_relax_times[ei][mi], 
tcp=self.tau_cpmg[ei][mi], num_points=self.num_disp_points[ei][si][mi][0], 
power=self.power[ei][mi])
+                    r2eff_mmq_cr72(r20=R20[r20_index], pA=pA, pB=pB, 
dw=aliased_dw, dwH=aliased_dwH, kex=kex, k_AB=k_AB, k_BA=k_BA, 
cpmg_frqs=self.cpmg_frqs[ei][mi][0], inv_tcpmg=self.inv_relax_times[ei][mi], 
tcp=self.tau_cpmg[ei][mi], back_calc=self.back_calc[ei][si][mi][0], 
num_points=self.num_disp_points[ei][si][mi][0], power=self.power[ei][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[ei][si][mi][0]):

Modified: 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mmq_cr72.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mmq_cr72.py?rev=23583&r1=23582&r2=23583&view=diff
==============================================================================
--- 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mmq_cr72.py 
(original)
+++ 
branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_mmq_cr72.py 
Thu May 29 11:52:37 2014
@@ -47,6 +47,7 @@
         self.cpmg_frqs = self.ncyc / relax_times
         self.inv_relax_times = 1.0 / 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
@@ -59,11 +60,11 @@
         k_AB, k_BA, pB, dw_frq, dwH_frq = self.param_conversion(pA=self.pA, 
kex=self.kex, dw=self.dw, dwH=self.dwH, sfrq=self.sfrq)
 
         # Calculate the R2eff values.
-        R2eff = r2eff_mmq_cr72(r20=self.r20, pA=self.pA, pB=pB, dw=dw_frq, 
dwH=dwH_frq, kex=self.kex, k_AB=k_AB, k_BA=k_BA, cpmg_frqs=self.cpmg_frqs, 
inv_tcpmg=self.inv_relax_times, tcp=self.tau_cpmg, 
num_points=self.num_points, power=self.ncyc)
+        r2eff_mmq_cr72(r20=self.r20, pA=self.pA, pB=pB, dw=dw_frq, 
dwH=dwH_frq, kex=self.kex, k_AB=k_AB, k_BA=k_BA, cpmg_frqs=self.cpmg_frqs, 
inv_tcpmg=self.inv_relax_times, tcp=self.tau_cpmg, back_calc=self.R2eff, 
num_points=self.num_points, power=self.ncyc)
 
         # Check all R2eff values.
         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, dwH=None, 
sfrq=None):




Related Messages


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