Author: bugman Date: Sun Dec 8 19:47:59 2013 New Revision: 21870 URL: http://svn.gna.org/viewcvs/relax?rev=21870&view=rev Log: Speed up of the 'TP02' and 'NS R1rho 2-site' dispersion models. Repetitive calculations have been minimised. Modified: trunk/lib/dispersion/ns_r1rho_2site.py trunk/lib/dispersion/tp02.py Modified: trunk/lib/dispersion/ns_r1rho_2site.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/ns_r1rho_2site.py?rev=21870&r1=21869&r2=21870&view=diff ============================================================================== --- trunk/lib/dispersion/ns_r1rho_2site.py (original) +++ trunk/lib/dispersion/ns_r1rho_2site.py Sun Dec 8 19:47:59 2013 @@ -81,13 +81,11 @@ # Repetitive calculations (to speed up calculations). Wa = omega # Larmor frequency [s^-1]. Wb = omega + dw # Larmor frequency [s^-1]. + dA = Wa - offset # Offset of spin-lock from A. + dB = Wb - offset # Offset of spin-lock from B. # Loop over the time points, back calculating the R2eff values. for i in range(num_points): - Wsl = offset # Larmor frequency of spin lock [s^-1]. - dA = Wa - Wsl # Offset of spin-lock from A. - dB = Wb - Wsl # Offset of spin-lock from B. - # The matrix R that contains all the contributions to the evolution, i.e. relaxation, exchange and chemical shift evolution. R = rr1rho_3d(R1=r1, Rinf=r1rho_prime, pA=pA, pB=pB, wA=dA, wB=dB, w1=spin_lock_fields[i], k_AB=k_AB, k_BA=k_BA) Modified: trunk/lib/dispersion/tp02.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/tp02.py?rev=21870&r1=21869&r2=21870&view=diff ============================================================================== --- trunk/lib/dispersion/tp02.py (original) +++ trunk/lib/dispersion/tp02.py Sun Dec 8 19:47:59 2013 @@ -72,6 +72,13 @@ Wa = omega # Larmor frequency [s^-1]. Wb = omega + dw # Larmor frequency [s^-1]. kex2 = kex**2 + W = pA*Wa + pB*Wb # Pop-averaged Larmor frequency [s^-1]. + da = Wa - offset # Offset of spin-lock from A. + db = Wb - offset # Offset of spin-lock from B. + d = W - offset # Offset of spin-lock from pop-average. + da2 = da**2 + db2 = db**2 + d2 = d**2 # The numerator. numer = pA * pB * dw**2 * kex @@ -79,13 +86,9 @@ # Loop over the dispersion points, back calculating the R1rho values. for i in range(num_points): # We assume that A resonates at 0 [s^-1], without loss of generality. - W = pA*Wa + pB*Wb # Pop-averaged Larmor frequency [s^-1]. - da = Wa - offset # Offset of spin-lock from A. - db = Wb - offset # Offset of spin-lock from B. - d = W - offset # Offset of spin-lock from pop-average. - waeff2 = spin_lock_fields2[i] + da**2 # Effective field at A. - wbeff2 = spin_lock_fields2[i] + db**2 # Effective field at B. - weff2 = spin_lock_fields2[i] + d**2 # Effective field at pop-average. + waeff2 = spin_lock_fields2[i] + da2 # Effective field at A. + wbeff2 = spin_lock_fields2[i] + db2 # Effective field at B. + weff2 = spin_lock_fields2[i] + d2 # Effective field at pop-average. # The rotating frame flip angle. theta = atan(spin_lock_fields[i] / d)