Author: tlinnet Date: Mon May 19 03:20:51 2014 New Revision: 23226 URL: http://svn.gna.org/viewcvs/relax?rev=23226&view=rev Log: Speed-up of model LM63.
task #7793: (https://gna.org/task/?7793) Speed-up of dispersion models. Change in systemtest was: test_hansen_cpmg_data_auto_analysis 13.731s -> 9.971s test_hansen_cpmg_data_auto_analysis_r2eff 13.370s -> 9.510s test_hansen_cpmg_data_to_lm63 3.254s -> 2.080s Modified: branches/disp_speed/lib/dispersion/lm63.py Modified: branches/disp_speed/lib/dispersion/lm63.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/dispersion/lm63.py?rev=23226&r1=23225&r2=23226&view=diff ============================================================================== --- branches/disp_speed/lib/dispersion/lm63.py (original) +++ branches/disp_speed/lib/dispersion/lm63.py Mon May 19 03:20:51 2014 @@ -64,7 +64,7 @@ """ # Python module imports. -from math import tanh +from numpy import isfinite, sum, tanh def r2eff_LM63(r20=None, phi_ex=None, kex=None, cpmg_frqs=None, back_calc=None, num_points=None): @@ -91,16 +91,14 @@ rex = phi_ex / kex kex_4 = 4.0 / kex - # Loop over the time points, back calculating the R2eff values. + # Calculate R2eff. + R2eff = r20 + rex * (1.0 - kex_4 * cpmg_frqs * tanh(kex / (4.0 * cpmg_frqs))) + + # 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(R2eff)): + R2eff = array([1e100]*num_points) + + # Parse back the value to update the back_calc class object. for i in range(num_points): - # Catch zeros. - if phi_ex == 0.0: - back_calc[i] = r20 - - # Avoid divide by zero. - elif kex == 0.0: - back_calc[i] = 1e100 - - # The full formula. - else: - back_calc[i] = r20 + rex * (1.0 - kex_4 * cpmg_frqs[i] * tanh(kex / (4.0 * cpmg_frqs[i]))) + back_calc[i] = R2eff[i] _______________________________________________ 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