Author: tlinnet Date: Wed May 21 13:02:55 2014 New Revision: 23295 URL: http://svn.gna.org/viewcvs/relax?rev=23295&view=rev Log: Align math-domain catching for model CR72 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/cr72.py Modified: branches/disp_speed/lib/dispersion/cr72.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/cr72.py?rev=23295&r1=23294&r2=23295&view=diff ============================================================================== --- branches/disp_speed/lib/dispersion/cr72.py (original) +++ branches/disp_speed/lib/dispersion/cr72.py Wed May 21 13:02:55 2014 @@ -92,7 +92,7 @@ """ # Python module imports. -from numpy import arccosh, array, cos, cosh, isfinite, max, sqrt, sum +from numpy import arccosh, array, cos, cosh, isfinite, min, max, sqrt, sum # Repetitive calculations (to speed up calculations). eta_scale = 2.0**(-3.0/2.0) @@ -128,6 +128,10 @@ k_BA = pA * kex k_AB = pB * kex + # Catch parameter values that will result in no exchange, returning flat R2eff = R20 lines. + if dw == 0.0 or pA == 1.0 or kex == 0.0: + return array([r20_kex]*num_points) + # The Psi and zeta values. if r20a != r20b: fact = r20a - r20b - k_BA + k_AB @@ -156,8 +160,15 @@ return R2eff + # The arccosh argument - catch invalid values. + fact = Dpos * cosh(etapos) - Dneg * cos(etaneg) + if min(fact) < 1.0: + R2eff = array([r20_kex]*num_points) + + return R2eff + # Calculate R2eff. - R2eff = r20_kex - cpmg_frqs * arccosh( Dpos * cosh(etapos) - Dneg * cos(etaneg) ) + R2eff = r20_kex - cpmg_frqs * arccosh( fact ) # Catch errors, taking a sum over array is the fastest way to check for # +/- inf (infinity) and nan (not a number). _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org 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