Author: tlinnet Date: Wed May 21 13:03:02 2014 New Revision: 23300 URL: http://svn.gna.org/viewcvs/relax?rev=23300&view=rev Log: Align math-domain catching for model MP05 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/mp05.py Modified: branches/disp_speed/lib/dispersion/mp05.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/mp05.py?rev=23300&r1=23299&r2=23300&view=diff ============================================================================== --- branches/disp_speed/lib/dispersion/mp05.py (original) +++ branches/disp_speed/lib/dispersion/mp05.py Wed May 21 13:03:02 2014 @@ -111,13 +111,6 @@ wbeff2 = spin_lock_fields2 + db**2 # Effective field at B. weff2 = spin_lock_fields2 + d**2 # 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) @@ -126,6 +119,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 numer == 0.0: + return R1_cos_theta2 + R1rho_prime_sin_theta2 + # Denominator. waeff2_wbeff2 = waeff2*wbeff2 fact_denom = waeff2_wbeff2 + weff2*kex2 @@ -133,19 +131,10 @@ # Catch math domain error of dividing with 0. # This is when fact_denom = 0. if min(abs(fact_denom)) == 0: - R2eff = array([1e100]*num_points) - - return R2eff + return array([1e100]*num_points) fact = 1.0 + 2.0*kex2*(pA*waeff2 + pB*wbeff2) / fact_denom denom = waeff2_wbeff2/weff2 + kex2 - sin_theta2*phi_ex*(fact) - - # 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 # R1rho calculation. R1rho = R1_cos_theta2 + R1rho_prime_sin_theta2 + sin_theta2 * numer / denom