Author: bugman Date: Sat Jun 8 23:51:26 2013 New Revision: 19977 URL: http://svn.gna.org/viewcvs/relax?rev=19977&view=rev Log: Big speeds ups of the lib.dispersion modules. Many replicated calculations have been shifted outside of the dispersion point loop, as these only need to be calculated once per function call. Some if statements have consequently been simplified. Modified: branches/relax_disp/lib/dispersion/cr72.py branches/relax_disp/lib/dispersion/lm63.py branches/relax_disp/lib/dispersion/m61.py branches/relax_disp/lib/dispersion/m61b.py Modified: branches/relax_disp/lib/dispersion/cr72.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/cr72.py?rev=19977&r1=19976&r2=19977&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/cr72.py (original) +++ branches/relax_disp/lib/dispersion/cr72.py Sat Jun 8 23:51:26 2013 @@ -86,6 +86,7 @@ # Repetitive calculations (to speed up calculations). dw2 = dw**2 + r20_kex = r20 + 0.5*kex # The Psi value. Psi = kex**2 - dw2 @@ -119,9 +120,9 @@ # Part of the equation (catch values < 1 to prevent math domain errors). part = Dpos * cosh(etapos) - Dneg * cos(etaneg) - if part < 1: + if part < 1.0: back_calc[i] = 1e100 continue # The full formula. - back_calc[i] = r20 + 0.5*kex - cpmg_frqs[i] * acosh(part) + back_calc[i] = r20_kex - cpmg_frqs[i] * acosh(part) Modified: branches/relax_disp/lib/dispersion/lm63.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/lm63.py?rev=19977&r1=19976&r2=19977&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/lm63.py (original) +++ branches/relax_disp/lib/dispersion/lm63.py Sat Jun 8 23:51:26 2013 @@ -64,6 +64,10 @@ @type num_poinst: int """ + # Repetitive calculations (to speed up calculations). + rex = phi_ex / kex + kex_4 = 4.0 / kex + # Loop over the time points, back calculating the R2eff values. for i in range(num_points): # Catch zeros. @@ -76,4 +80,4 @@ # The full formula. else: - back_calc[i] = r20 + phi_ex / kex * (1.0 - (4.0 * cpmg_frqs[i] / kex) * tanh(kex / (4 * cpmg_frqs[i]))) + back_calc[i] = r20 + rex * (1.0 - kex_4 * cpmg_frqs[i] * tanh(kex / (4.0 * cpmg_frqs[i]))) Modified: branches/relax_disp/lib/dispersion/m61.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/m61.py?rev=19977&r1=19976&r2=19977&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/m61.py (original) +++ branches/relax_disp/lib/dispersion/m61.py Sat Jun 8 23:51:26 2013 @@ -66,15 +66,21 @@ @type num_poinst: int """ + # Repetitive calculations (to speed up calculations). + kex2 = kex**2 + + # The numerator. + numer = sin(theta)**2 * phi_ex * kex + # Loop over the dispersion points, back calculating the R1rho values. for i in range(num_points): # Catch zeros (to avoid pointless mathematical operations). - if phi_ex == 0.0 or kex == 0.0: + if numer == 0.0: back_calc[i] = r1rho_prime continue # Denominator. - denom = kex**2 + (2.0*pi*spin_lock_fields[i])**2 + denom = kex2 + (2.0*pi*spin_lock_fields[i])**2 # Avoid divide by zero. if denom == 0.0: @@ -82,4 +88,4 @@ continue # R1rho calculation. - back_calc[i] = r1rho_prime + sin(theta)**2 * phi_ex * kex / denom + back_calc[i] = r1rho_prime + numer / denom Modified: branches/relax_disp/lib/dispersion/m61b.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/m61b.py?rev=19977&r1=19976&r2=19977&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/m61b.py (original) +++ branches/relax_disp/lib/dispersion/m61b.py Sat Jun 8 23:51:26 2013 @@ -62,18 +62,26 @@ @type num_poinst: int """ + # The B population. + pB = 1.0 - pA + + # Repetitive calculations (to speed up calculations). + pA2dw2 = pA**2 * delta_omega**2 + kex2 = kex**2 + kex2_pA2dw2 = kex2 + pA2dw2 + + # The numerator. + numer = pA2dw2 * pB * kex + # Loop over the dispersion points, back calculating the R1rho values. for i in range(num_points): # Catch zeros (to avoid pointless mathematical operations). - if pA == 0.0 or delta_omega == 0.0 or kex == 0.0: + if numer == 0.0: back_calc[i] = r1rho_prime continue - # Replicated calculation. - pA2dw2 = pA**2 * delta_omega**2 - # Denominator. - denom = kex**2 + pA2dw2 + (2.0*pi*spin_lock_fields[i])**2 + denom = kex2_pA2dw2 + (2.0*pi*spin_lock_fields[i])**2 # Avoid divide by zero. if denom == 0.0: @@ -81,4 +89,4 @@ continue # R1rho calculation. - back_calc[i] = r1rho_prime + pA2dw2 * pB * kex / denom + back_calc[i] = r1rho_prime + numer / denom