mailr23592 - 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 on May 29, 2014 - 13:55:
Author: bugman
Date: Thu May 29 13:55:17 2014
New Revision: 23592

URL: http://svn.gna.org/viewcvs/relax?rev=23592&view=rev
Log:
Merged revisions 23239 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/disp_speed

........
  r23239 | tlinnet | 2014-05-19 14:44:10 +0200 (Mon, 19 May 2014) | 10 lines
  
  Math-domain catching for model B14.
  
  task #7793: (https://gna.org/task/?7793) Speed-up of dispersion models.
  
  This is to implement catching of math domain errors, before they occur.
  These can be found via the --numpy-raise function to the systemtests.
  
  To make the code look clean, the class object "back_calc" is no longer
  being updated per time point, but is updated in the relax_disp target 
function in
  one go.
........

Modified:
    trunk/   (props changed)
    trunk/lib/dispersion/b14.py
    trunk/target_functions/relax_disp.py

Propchange: trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May 29 13:55:17 2014
@@ -1 +1 @@
-/branches/disp_speed:1-23214,23216-23229
+/branches/disp_speed:1-23214,23216-23229,23239

Modified: trunk/lib/dispersion/b14.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/b14.py?rev=23592&r1=23591&r2=23592&view=diff
==============================================================================
--- trunk/lib/dispersion/b14.py (original)
+++ trunk/lib/dispersion/b14.py Thu May 29 13:55:17 2014
@@ -110,12 +110,12 @@
 """
 
 # Python module imports.
-from numpy import arccosh, arctan2, array, cos, cosh, isfinite, log, power, 
sin, sinh, sqrt, sum
+from numpy import abs, arccosh, arctan2, array, cos, cosh, isfinite, log, 
min, power, sin, sinh, sqrt, sum
 
 # Repetitive calculations (to speed up calculations).
 g_fact = 1/sqrt(2)
 
-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, ncyc=None, inv_tcpmg=None, tcp=None, num_points=None):
     """Calculate the R2eff values for the CR72 model.
 
     See the module docstring for details.
@@ -143,9 +143,7 @@
     @type inv_tcpmg:        float
     @keyword tcp:           The tau_CPMG times (1 / 4.nu1).
     @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.
+    @keyword num_points:    The number of points on the dispersion curve, 
equal to the length of the cpmg_frqs.
     @type num_points:       int
     """
 
@@ -216,12 +214,24 @@
     # Real. The v_1c in paper.
     v1c = F0 * cosh(E0) - F2 * cos(E2)
 
+    # Catch math domain error of sqrt(neg val).
+    # This is when abs(v1c) =< 1.
+    if min(abs(v1c)) <= 1.:
+        R2eff = array([1e100]*num_points)
+        return R2eff
+
     # Exact result for v2v3.
     v3 = sqrt(v1c**2 - 1.)
 
     y = power( (v1c - v3) / (v1c + v3), ncyc)
 
     Tog = 0.5 * (1. + y) + (1. - y) * v5 / (2. * v3 * N )
+
+    # Catch math domain error of log(neg val or zero).
+    # This is when Tog.real =< 0.
+    if min(Tog.real) <= 0.:
+        R2eff = array([1e100]*num_points)
+        return R2eff
 
     ## -1/Trel * log(LpreDyn).
     # Rpre = (r20a + r20b + kex) / 2.0
@@ -241,6 +251,4 @@
     if not isfinite(sum(R2eff)):
         R2eff = array([1e100]*num_points)
 
-    # Parse back the value to update the back_calc class object.
-    for i in range(num_points):
-        back_calc[i] = R2eff[i]
+    return R2eff

Modified: trunk/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_disp.py?rev=23592&r1=23591&r2=23592&view=diff
==============================================================================
--- trunk/target_functions/relax_disp.py        (original)
+++ trunk/target_functions/relax_disp.py        Thu May 29 13:55:17 2014
@@ -439,7 +439,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=aliased_dw, 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])
+                    self.back_calc[ei][si][mi][0] = 
r2eff_B14(r20a=R20A[r20_index], r20b=R20B[r20_index], pA=pA, pB=pB, 
dw=aliased_dw, 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], 
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]):




Related Messages


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