Author: tlinnet Date: Wed May 21 13:03:06 2014 New Revision: 23302 URL: http://svn.gna.org/viewcvs/relax?rev=23302&view=rev Log: Align math-domain catching for model TP02 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/tp02.py Modified: branches/disp_speed/lib/dispersion/tp02.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/tp02.py?rev=23302&r1=23301&r2=23302&view=diff ============================================================================== --- branches/disp_speed/lib/dispersion/tp02.py (original) +++ branches/disp_speed/lib/dispersion/tp02.py Wed May 21 13:03:06 2014 @@ -113,13 +113,6 @@ wbeff2 = spin_lock_fields2 + db2 # Effective field at B. weff2 = spin_lock_fields2 + d2 # Effective field at pop-average. - # Catch math domain error of dividing with 0. - # This is when weff2 = 0. - if min(abs(weff2)) == 0: - R2eff = array([1e100]*num_points) - - return R2eff - # The rotating frame flip angle. theta = arctan2(spin_lock_fields, d) @@ -128,6 +121,11 @@ R1_cos_theta2 = R1 * (1.0 - sin_theta2) R1rho_prime_sin_theta2 = r1rho_prime * sin_theta2 + # Catch zeros (to avoid pointless mathematical operations). + # This will result in no exchange, returning flat lines. + if min(numer) == 0.0: + return R1_cos_theta2 + R1rho_prime_sin_theta2 + # Denominator. denom = waeff2 * wbeff2 / weff2 + kex2 #denom_extended = waeff2*wbeff2/weff2+kex2-2*sin_theta2*pA*pB*dw**2 @@ -135,9 +133,7 @@ # 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 = R1_cos_theta2 + R1rho_prime_sin_theta2 + sin_theta2 * numer / denom