mailr20967 - in /branches/relax_disp: lib/dispersion/ target_functions/


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

Header


Content

Posted by edward on September 10, 2013 - 14:43:
Author: bugman
Date: Tue Sep 10 14:43:07 2013
New Revision: 20967

URL: http://svn.gna.org/viewcvs/relax?rev=20967&view=rev
Log:
Some more speed ups for the R1rho dispersion models.

For many models, the square of the spin-lock field strength is a part of the 
equations.  Therefore
this is now pre-calculated when the target function is initialised.


Modified:
    branches/relax_disp/lib/dispersion/dpl94.py
    branches/relax_disp/lib/dispersion/m61.py
    branches/relax_disp/lib/dispersion/m61b.py
    branches/relax_disp/lib/dispersion/tp02.py
    branches/relax_disp/target_functions/relax_disp.py

Modified: branches/relax_disp/lib/dispersion/dpl94.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/dpl94.py?rev=20967&r1=20966&r2=20967&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/dpl94.py (original)
+++ branches/relax_disp/lib/dispersion/dpl94.py Tue Sep 10 14:43:07 2013
@@ -44,7 +44,7 @@
 from math import cos, pi, sin
 
 
-def r1rho_DPL94(r1rho_prime=None, phi_ex=None, kex=None, theta=None, R1=0.0, 
spin_lock_fields=None, back_calc=None, num_points=None):
+def r1rho_DPL94(r1rho_prime=None, phi_ex=None, kex=None, theta=None, R1=0.0, 
spin_lock_fields2=None, back_calc=None, num_points=None):
     """Calculate the R1rho values for the DPL94 model.
 
     See the module docstring for details.
@@ -60,8 +60,8 @@
     @type theta:                numpy rank-1 float array
     @keyword R1:                The R1 relaxation rate.
     @type R1:                   float
-    @keyword spin_lock_fields:  The R1rho spin-lock field strengths (in 
rad.s^-1).
-    @type spin_lock_fields:     numpy rank-1 float array
+    @keyword spin_lock_fields2: The R1rho spin-lock field strengths squared 
(in rad^2.s^-2).
+    @type spin_lock_fields2:    numpy rank-1 float array
     @keyword back_calc:         The array for holding the back calculated 
R1rho values.  Each element corresponds to one of the spin-lock fields.
     @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 spin_lock_fields and back_calc arguments.
@@ -86,7 +86,7 @@
             continue
 
         # Denominator.
-        denom = kex2 + spin_lock_fields[i]**2
+        denom = kex2 + spin_lock_fields2[i]
 
         # Avoid divide by zero.
         if denom == 0.0:

Modified: branches/relax_disp/lib/dispersion/m61.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/m61.py?rev=20967&r1=20966&r2=20967&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/m61.py (original)
+++ branches/relax_disp/lib/dispersion/m61.py Tue Sep 10 14:43:07 2013
@@ -44,7 +44,7 @@
 from math import pi
 
 
-def r1rho_M61(r1rho_prime=None, phi_ex=None, kex=None, 
spin_lock_fields=None, back_calc=None, num_points=None):
+def r1rho_M61(r1rho_prime=None, phi_ex=None, kex=None, 
spin_lock_fields2=None, back_calc=None, num_points=None):
     """Calculate the R2eff values for the M61 model.
 
     See the module docstring for details.
@@ -56,8 +56,8 @@
     @type phi_ex:               float
     @keyword kex:               The kex parameter value (the exchange rate 
in rad/s).
     @type kex:                  float
-    @keyword spin_lock_fields:  The R1rho spin-lock field strengths (in 
rad.s^-1).
-    @type spin_lock_fields:     numpy rank-1 float array
+    @keyword spin_lock_fields2: The R1rho spin-lock field strengths squared 
(in rad^2.s^-2).
+    @type spin_lock_fields2:    numpy rank-1 float array
     @keyword back_calc:         The array for holding the back calculated 
R1rho values.  Each element corresponds to one of the spin-lock fields.
     @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 spin_lock_fields and back_calc arguments.
@@ -78,7 +78,7 @@
             continue
 
         # Denominator.
-        denom = kex2 + spin_lock_fields[i]**2
+        denom = kex2 + spin_lock_fields2[i]
 
         # Avoid divide by zero.
         if denom == 0.0:

Modified: branches/relax_disp/lib/dispersion/m61b.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/m61b.py?rev=20967&r1=20966&r2=20967&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/m61b.py (original)
+++ branches/relax_disp/lib/dispersion/m61b.py Tue Sep 10 14:43:07 2013
@@ -54,8 +54,8 @@
     @type dw:                   float
     @keyword kex:               The kex parameter value (the exchange rate 
in rad/s).
     @type kex:                  float
-    @keyword spin_lock_fields:  The R1rho spin-lock field strengths (in 
rad.s^-1).
-    @type spin_lock_fields:     numpy rank-1 float array
+    @keyword spin_lock_fields2: The R1rho spin-lock field strengths squared 
(in rad^2.s^-2).
+    @type spin_lock_fields2:    numpy rank-1 float array
     @keyword back_calc:         The array for holding the back calculated 
R1rho values.  Each element corresponds to one of the spin-lock fields.
     @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 spin_lock_fields and back_calc arguments.
@@ -80,7 +80,7 @@
             continue
 
         # Denominator.
-        denom = kex2_pA2dw2 + spin_lock_fields[i]**2
+        denom = kex2_pA2dw2 + spin_lock_fields2[i]
 
         # Avoid divide by zero.
         if denom == 0.0:

Modified: branches/relax_disp/lib/dispersion/tp02.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/tp02.py?rev=20967&r1=20966&r2=20967&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/tp02.py (original)
+++ branches/relax_disp/lib/dispersion/tp02.py Tue Sep 10 14:43:07 2013
@@ -36,7 +36,7 @@
 from math import atan, cos, pi, sin
 
 
-def r1rho_TP02(r1rho_prime=None, omega=None, offset=None, pA=None, pB=None, 
dw=None, kex=None, R1=0.0, spin_lock_fields=None, back_calc=None, 
num_points=None):
+def r1rho_TP02(r1rho_prime=None, omega=None, offset=None, pA=None, pB=None, 
dw=None, kex=None, R1=0.0, spin_lock_fields=None, spin_lock_fields2=None, 
back_calc=None, num_points=None):
     """Calculate the R1rho' values for the TP02 model.
 
     See the module docstring for details.  This is the Trott and Palmer 
(2002) equation according to Korzhnev (J. Biomol. NMR (2003), 26, 39-48).
@@ -60,6 +60,8 @@
     @type R1:                   float
     @keyword spin_lock_fields:  The R1rho spin-lock field strengths (in 
rad.s^-1).
     @type spin_lock_fields:     numpy rank-1 float array
+    @keyword spin_lock_fields2: The R1rho spin-lock field strengths squared 
(in rad^2.s^-2).  This is for speed.
+    @type spin_lock_fields2:    numpy rank-1 float array
     @keyword back_calc:         The array for holding the back calculated 
R1rho values.  Each element corresponds to one of the spin-lock fields.
     @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 spin_lock_fields and back_calc arguments.
@@ -81,9 +83,9 @@
         da = Wa - offset[i]                         # Offset of spin-lock 
from A.
         db = Wb - offset[i]                         # Offset of spin-lock 
from B.
         d = W - offset[i]                           # Offset of spin-lock 
from pop-average.
-        waeff2 = spin_lock_fields[i]**2 + da**2     # Effective field at A.
-        wbeff2 = spin_lock_fields[i]**2 + db**2     # Effective field at B.
-        weff2 = spin_lock_fields[i]**2 + d**2       # Effective field at 
pop-average.
+        waeff2 = spin_lock_fields2[i] + da**2     # Effective field at A.
+        wbeff2 = spin_lock_fields2[i] + db**2     # Effective field at B.
+        weff2 = spin_lock_fields2[i] + d**2       # Effective field at 
pop-average.
 
         # The rotating frame flip angle.
         theta = atan(spin_lock_fields[i] / d)

Modified: branches/relax_disp/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/target_functions/relax_disp.py?rev=20967&r1=20966&r2=20967&view=diff
==============================================================================
--- branches/relax_disp/target_functions/relax_disp.py (original)
+++ branches/relax_disp/target_functions/relax_disp.py Tue Sep 10 14:43:07 
2013
@@ -218,6 +218,7 @@
         # Convert the spin-lock data to rad.s^-1.
         if spin_lock_nu1 != None:
             self.spin_lock_omega1 = 2.0 * pi * self.spin_lock_nu1
+            self.spin_lock_omega1_squared = self.spin_lock_omega1 ** 2
 
         # The inverted relaxation delay.
         if model in [MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_3D_FULL, 
MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR, 
MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_R1RHO_2SITE]:
@@ -524,7 +525,7 @@
                 phi_ex_scaled = phi_ex[spin_index] * self.frqs[spin_index, 
frq_index]**2
 
                 # Back calculate the R2eff values.
-                r1rho_DPL94(r1rho_prime=R20[r20_index], 
phi_ex=phi_ex_scaled, kex=kex, theta=self.tilt_angles[spin_index, frq_index], 
R1=self.r1[spin_index, frq_index], spin_lock_fields=self.spin_lock_omega1, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
+                r1rho_DPL94(r1rho_prime=R20[r20_index], 
phi_ex=phi_ex_scaled, kex=kex, theta=self.tilt_angles[spin_index, frq_index], 
R1=self.r1[spin_index, frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
 
                 # 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 point_index in range(self.num_disp_points):
@@ -720,7 +721,7 @@
                 phi_ex_scaled = phi_ex[spin_index] * self.frqs[spin_index, 
frq_index]**2
 
                 # Back calculate the R2eff values.
-                r1rho_M61(r1rho_prime=R20[r20_index], phi_ex=phi_ex_scaled, 
kex=kex, spin_lock_fields=self.spin_lock_omega1, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
+                r1rho_M61(r1rho_prime=R20[r20_index], phi_ex=phi_ex_scaled, 
kex=kex, spin_lock_fields2=self.spin_lock_omega1_squared, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
 
                 # 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 point_index in range(self.num_disp_points):
@@ -767,7 +768,7 @@
                 dw_frq = dw[spin_index] * self.frqs[spin_index, frq_index]
 
                 # Back calculate the R1rho values.
-                r1rho_M61b(r1rho_prime=R20[r20_index], pA=pA, dw=dw_frq, 
kex=kex, spin_lock_fields=self.spin_lock_omega1, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
+                r1rho_M61b(r1rho_prime=R20[r20_index], pA=pA, dw=dw_frq, 
kex=kex, spin_lock_fields2=self.spin_lock_omega1_squared, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
 
                 # 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 point_index in range(self.num_disp_points):
@@ -1064,7 +1065,7 @@
                 dw_frq = dw[spin_index] * self.frqs[spin_index, frq_index]
 
                 # Back calculate the R1rho values.
-                r1rho_TP02(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[spin_index, frq_index], 
offset=self.spin_lock_offsets[spin_index, frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1, back_calc=self.back_calc[spin_index, 
frq_index], num_points=self.num_disp_points)
+                r1rho_TP02(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[spin_index, frq_index], 
offset=self.spin_lock_offsets[spin_index, frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1, 
spin_lock_fields2=self.spin_lock_omega1_squared, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
 
                 # 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 point_index in range(self.num_disp_points):




Related Messages


Powered by MHonArc, Updated Tue Sep 10 15:00:01 2013