mailr24343 - /branches/disp_spin_speed/lib/dispersion/b14.py


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

Header


Content

Posted by edward on June 27, 2014 - 14:52:
Author: bugman
Date: Fri Jun 27 14:52:08 2014
New Revision: 24343

URL: http://svn.gna.org/viewcvs/relax?rev=24343&view=rev
Log:
Slight speed up of the 'B14' and 'B14 full' dispersion models by minimising 
repetitive maths.

Using the disp_profile_all.py script, the speed ups for these two models are:

100 single spins analysis:
B14:                         3.944+/-0.032 ->   3.888+/-0.038,   1.014x 
faster.
B14 full:                    4.037+/-0.040 ->   3.940+/-0.025,   1.025x 
faster.

Cluster of 100 spins analysis:
B14:                         0.522+/-0.003 ->   0.507+/-0.008,   1.031x 
faster. 
B14 full:                    0.507+/-0.008 ->   0.487+/-0.007,   1.042x 
faster. 


Modified:
    branches/disp_spin_speed/lib/dispersion/b14.py

Modified: branches/disp_spin_speed/lib/dispersion/b14.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/lib/dispersion/b14.py?rev=24343&r1=24342&r2=24343&view=diff
==============================================================================
--- branches/disp_spin_speed/lib/dispersion/b14.py      (original)
+++ branches/disp_spin_speed/lib/dispersion/b14.py      Fri Jun 27 14:52:08 
2014
@@ -169,21 +169,20 @@
 
     # Repetitive calculations (to speed up calculations).
     deltaR2 = r20a - r20b
+    dw2 = dw**2
+    two_tcp = 2.0 * tcp
 
     # The Carver and Richards (1972) alpha_minus short notation.
     alpha_m = deltaR2 + k_AB - k_BA
     zeta = 2.0 * dw * alpha_m
-    Psi = alpha_m**2 + 4.0 * k_BA * k_AB - dw**2
-
-    # Repetitive calculations (to speed up calculations).
-    dw2 = dw**2
-    two_tcp = 2.0 * tcp
+    Psi = alpha_m**2 + 4.0 * k_BA * k_AB - dw2
 
     # Get the real and imaginary components of the exchange induced shift.
     # Trigonometric functions faster than square roots.
     quad_zeta2_Psi2 = (zeta**2 + Psi**2)**0.25
-    g3 = cos(0.5 * arctan2(-zeta, Psi)) * quad_zeta2_Psi2
-    g4 = sin(0.5 * arctan2(-zeta, Psi)) * quad_zeta2_Psi2
+    fact = 0.5 * arctan2(-zeta, Psi)
+    g3 = cos(fact) * quad_zeta2_Psi2
+    g4 = sin(fact) * quad_zeta2_Psi2
 
     # Repetitive calculations (to speed up calculations).
     g32 = g3**2
@@ -310,4 +309,4 @@
     # +/- inf (infinity) and nan (not a number).
     if not isfinite(sum(back_calc)):
         # Replaces nan, inf, etc. with fill value.
-        fix_invalid(back_calc, copy=False, fill_value=1e100)
+        fix_invalid(back_calc, copy=False, fill_value=1e100)




Related Messages


Powered by MHonArc, Updated Fri Jun 27 16:00:02 2014