mailr23299 - /branches/disp_speed/lib/dispersion/m61.py


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

Header


Content

Posted by tlinnet on May 21, 2014 - 13:03:
Author: tlinnet
Date: Wed May 21 13:03:01 2014
New Revision: 23299

URL: http://svn.gna.org/viewcvs/relax?rev=23299&view=rev
Log:
Align math-domain catching for model M61 with trunk implementation.

task #7793: (https://gna.org/task/?7793) Speed-up of dispersion models.

This is to implement catching of math domain errors, before they occur.

The catching of errors have to be more careful.

Modified:
    branches/disp_speed/lib/dispersion/m61.py

Modified: branches/disp_speed/lib/dispersion/m61.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/m61.py?rev=23299&r1=23298&r2=23299&view=diff
==============================================================================
--- branches/disp_speed/lib/dispersion/m61.py   (original)
+++ branches/disp_speed/lib/dispersion/m61.py   Wed May 21 13:03:01 2014
@@ -91,15 +91,18 @@
     # The numerator.
     numer = phi_ex * kex
 
+    # Catch zeros (to avoid pointless mathematical operations).
+    # This will result in no exchange, returning flat lines.
+    if numer == 0.0:
+        return array([r1rho_prime]*num_points)
+
     # Denominator.
     denom = kex2 + spin_lock_fields2
 
     # Catch math domain error of dividing with 0.
     # This is when denom=0.
     if min(abs(denom)) == 0:
-        R1rho = array([1e100]*num_points)
-
-        return R1rho
+        return array([1e100]*num_points)
 
     # R1rho calculation.
     R1rho = r1rho_prime + numer / denom
@@ -107,6 +110,6 @@
     # Catch errors, taking a sum over array is the fastest way to check for
     # +/- inf (infinity) and nan (not a number).
     if not isfinite(sum(R1rho)):
-        R1rho = array([1e100]*num_points)
+        return array([1e100]*num_points)
 
     return R1rho




Related Messages


Powered by MHonArc, Updated Wed May 21 13:20:03 2014