mailRe: r23004 - in /trunk: lib/dispersion/b14.py target_functions/relax_disp.py


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

Header


Content

Posted by Edward d'Auvergne on May 06, 2014 - 17:29:
Hi Troels,

This change actually does not speed up the code.  The reason is
because it is not possible to put the r20a and r20b parameter
calculations higher up in the looping.  They have shifted modules, but
the number of times they are calculated has not changed.  It may
actually slow things down a tiny bit due to extra argument passing.
Maybe you could revert?

Cheers,

Edward





On 6 May 2014 17:22,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Tue May  6 17:22:17 2014
New Revision: 23004

URL: http://svn.gna.org/viewcvs/relax?rev=23004&view=rev
Log:
Speed-up. Moved the calculation of deltaR2 and alpha_m out of library 
function.

sr #3154: (https://gna.org/support/?3154) Implementation of Baldwin (2014) 
B14 model - 2-site exact solution model for all time scales.

This follows the tutorial for adding relaxation dispersion models at:
http://wiki.nmr-relax.com/Tutorial_for_adding_relaxation_dispersion_models_to_relax#Debugging


Modified:
    trunk/lib/dispersion/b14.py
    trunk/target_functions/relax_disp.py

Modified: trunk/lib/dispersion/b14.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/b14.py?rev=23004&r1=23003&r2=23004&view=diff
==============================================================================
--- trunk/lib/dispersion/b14.py (original)
+++ trunk/lib/dispersion/b14.py Tue May  6 17:22:17 2014
@@ -102,7 +102,7 @@
 from numpy import arccosh, cos, cosh, log, sin, sinh, sqrt, power


-def r2eff_B14(r20a=None, r20b=None, pA=None, pB=None, dw=None, kex=None, 
k_AB=None, k_BA=None, ncyc=None, inv_tcpmg=None, tcp=None, back_calc=None, 
num_points=None):
+def r2eff_B14(r20a=None, r20b=None, pA=None, pB=None, dw=None, kex=None, 
k_AB=None, k_BA=None, deltaR2=None, alpha_m=None, ncyc=None, 
inv_tcpmg=None, tcp=None, back_calc=None, num_points=None):
     """Calculate the R2eff values for the CR72 model.

     See the module docstring for details.
@@ -124,6 +124,10 @@
     @type k_AB:             float
     @keyword k_BA:          The rate of exchange from site B to A (rad/s).
     @type k_BA:             float
+    @keyword deltaR2:       The difference r20a - r20b.
+    @type deltaR2:          float
+    @keyword alpha_m:       The Carver and Richards (1972) alpha_minus 
short notation. alpha_m = deltaR2 + k_AB - k_BA = r20a - r20b + k_AB - k_BA.
+    @type alpha_m:          float
     @keyword ncyc:          The matrix exponential power array. The number 
of CPMG blocks.
     @type ncyc:             numpy int16, rank-1 array
     @keyword inv_tcpmg:     The inverse of the total duration of the CPMG 
element (in inverse seconds).
@@ -142,8 +146,6 @@
     
#########################################################################
     ##### Baldwins code.
     
#########################################################################
-    deltaR2 = r20a - r20b
-    alpha_m = r20a - r20b + k_AB - k_BA

     
#########################################################################
     #get the real and imaginary components of the exchange induced shift

Modified: trunk/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_disp.py?rev=23004&r1=23003&r2=23004&view=diff
==============================================================================
--- trunk/target_functions/relax_disp.py        (original)
+++ trunk/target_functions/relax_disp.py        Tue May  6 17:22:17 2014
@@ -803,6 +803,12 @@
                     # The R20 index.
                     r20_index = mi + si*self.num_frq

+                    # Repetitive calculations (to speed up calculations).
+                    r20a = R20A[r20_index]
+                    r20b = R20B[r20_index]
+                    deltaR2 = r20a - r20b
+                    alpha_m = deltaR2 + k_AB - k_BA
+
                     # Convert dw from ppm to rad/s.
                     dw_frq = dw[si] * self.frqs[ei][si][mi]

@@ -813,7 +819,7 @@
                         aliased_dw = dw_frq

                     # Back calculate the R2eff values.
-                    r2eff_B14(r20a=R20A[r20_index], r20b=R20B[r20_index], 
pA=pA, pB=pB, dw=dw_frq, kex=kex, k_AB=k_AB, k_BA=k_BA, 
ncyc=self.power[ei][mi], 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])
+                    r2eff_B14(r20a=r20a, r20b=r20b, pA=pA, pB=pB, 
dw=dw_frq, kex=kex, k_AB=k_AB, k_BA=k_BA, deltaR2=deltaR2, alpha_m=alpha_m, 
ncyc=self.power[ei][mi], 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])

                     # 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]):
@@ -825,7 +831,6 @@

         # Return the total chi-squared value.
         return chi2_sum
-


     def func_CR72(self, params):


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Tue May 06 17:40:10 2014