mailr23567 - 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 28, 2014 - 19:17:
Author: tlinnet
Date: Wed May 28 19:17:27 2014
New Revision: 23567

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

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

Modified: branches/disp_speed/lib/dispersion/it99.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/it99.py?rev=23567&r1=23566&r2=23567&view=diff
==============================================================================
--- branches/disp_speed/lib/dispersion/it99.py  (original)
+++ branches/disp_speed/lib/dispersion/it99.py  Wed May 28 19:17:27 2014
@@ -76,7 +76,7 @@
 from numpy import array, isfinite, sqrt, sum
 
 
-def r2eff_IT99(r20=None, pA=None, pB=None, dw=None, tex=None, 
cpmg_frqs=None, num_points=None):
+def r2eff_IT99(r20=None, pA=None, pB=None, dw=None, tex=None, 
cpmg_frqs=None, back_calc=None, num_points=None):
     """Calculate the R2eff values for the IT99 model.
 
     See the module docstring for details.
@@ -94,7 +94,10 @@
     @type tex:              float
     @keyword cpmg_frqs:     The CPMG nu1 frequencies.
     @type cpmg_frqs:        numpy rank-1 float array
-    @keyword num_points:    The number of points on the dispersion curve, 
equal to the length of the cpmg_frqs.
+    @type tcp:              numpy rank-1 float array
+    @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
     """
 
@@ -110,7 +113,8 @@
     # Catch zeros (to avoid pointless mathematical operations).
     # This will result in no exchange, returning flat lines.
     if numer == 0.0:
-        return array([r20]*num_points)
+        back_calc[:] = array([r20]*num_points)
+        return
 
     # The effective rotating frame field.
     omega_1eff4 = 2304.0 * cpmg_frqs**4
@@ -127,4 +131,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=23567&r1=23566&r2=23567&view=diff
==============================================================================
--- branches/disp_speed/target_functions/relax_disp.py  (original)
+++ branches/disp_speed/target_functions/relax_disp.py  Wed May 28 19:17:27 
2014
@@ -1015,7 +1015,7 @@
                 dw_frq = dw[si] * self.frqs[0][si][mi]
 
                 # Back calculate the R2eff values.
-                self.back_calc[0][si][mi][0] = 
r2eff_IT99(r20=R20[r20_index], pA=pA, pB=pB, dw=dw_frq, tex=tex, 
cpmg_frqs=self.cpmg_frqs[0][mi][0], 
num_points=self.num_disp_points[0][si][mi][0])
+                r2eff_IT99(r20=R20[r20_index], pA=pA, pB=pB, dw=dw_frq, 
tex=tex, cpmg_frqs=self.cpmg_frqs[0][mi][0], 
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_it99.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_it99.py?rev=23567&r1=23566&r2=23567&view=diff
==============================================================================
--- branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_it99.py   
  (original)
+++ branches/disp_speed/test_suite/unit_tests/_lib/_dispersion/test_it99.py   
  Wed May 28 19:17:27 2014
@@ -44,6 +44,7 @@
         self.ncyc = array([2, 4, 8, 10, 20, 40, 500])
         relax_times = 0.04
         self.cpmg_frqs = self.ncyc / relax_times
+        self.R2eff = zeros(self.num_points, float64)
 
         # The spin Larmor frequencies.
         self.sfrq = 200. * 1E6
@@ -56,15 +57,15 @@
         pB, dw_frq, tex = self.param_conversion(pA=self.pA, kex=self.kex, 
dw=self.dw, sfrq=self.sfrq)
 
         # Calculate the R2eff values.
-        R2eff = r2eff_IT99(r20=self.r20, pA=self.pA, pB=pB, dw=dw_frq, 
tex=tex, cpmg_frqs=self.cpmg_frqs, num_points=self.num_points)
+        r2eff_IT99(r20=self.r20, pA=self.pA, pB=pB, dw=dw_frq, tex=tex, 
cpmg_frqs=self.cpmg_frqs, back_calc=self.R2eff, num_points=self.num_points)
 
         # Check all R2eff values.
         if self.kex > 1.e5:
             for i in range(self.num_points):
-                self.assertAlmostEqual(R2eff[i], self.r20, 2)
+                self.assertAlmostEqual(self.R2eff[i], self.r20, 2)
         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 Wed May 28 19:40:02 2014