Author: bugman Date: Mon Dec 9 12:33:31 2013 New Revision: 21899 URL: http://svn.gna.org/viewcvs/relax?rev=21899&view=rev Log: Added the R2eff calculating functions for the 'NS R1rho 3-site' models to the relax library. This is for the 'NS R1rho 3-site' and 'NS R1rho 3-site linear' dispersion models. This follows the tutorial for adding relaxation dispersion models at: http://wiki.nmr-relax.com/Tutorial_for_adding_relaxation_dispersion_models_to_relax#The_relax_library. Added: trunk/lib/dispersion/ns_r1rho_3site.py - copied, changed from r21888, trunk/lib/dispersion/ns_r1rho_2site.py Modified: trunk/lib/dispersion/ns_matrices.py Modified: trunk/lib/dispersion/ns_matrices.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/ns_matrices.py?rev=21899&r1=21898&r2=21899&view=diff ============================================================================== --- trunk/lib/dispersion/ns_matrices.py (original) +++ trunk/lib/dispersion/ns_matrices.py Mon Dec 9 12:33:31 2013 @@ -160,6 +160,96 @@ return temp +def rr1rho_3d_3site(matrix=None, R1=None, r1rho_prime=None, pA=None, pB=None, pC=None, wA=None, wB=None, wC=None, w1=None, k_AB=None, k_BA=None, k_BC=None, k_CB=None, k_AC=None, k_CA=None): + """Definition of the 3D exchange matrix. + + @keyword matrix: The matrix to fill. + @type matrix: numpy rank-2 9D array + @keyword R1: The longitudinal, spin-lattice relaxation rate. + @type R1: float + @keyword r1rho_prime: The R1rho transverse, spin-spin relaxation rate in the absence of exchange. + @type r1rho_prime: float + @keyword pA: The population of state A. + @type pA: float + @keyword pB: The population of state B. + @type pB: float + @keyword pC: The population of state C. + @type pC: float + @keyword wA: The chemical shift offset of state A from the spin-lock. + @type wA: float + @keyword wB: The chemical shift offset of state B from the spin-lock. + @type wB: float + @keyword wC: The chemical shift offset of state C from the spin-lock. + @type wC: float + @keyword w1: The spin-lock field strength in rad/s. + @type w1: float + @keyword k_AB: The forward exchange rate from state A to state B. + @type k_AB: float + @keyword k_BA: The reverse exchange rate from state B to state A. + @type k_BA: float + @keyword k_BC: The forward exchange rate from state B to state C. + @type k_BC: float + @keyword k_CB: The reverse exchange rate from state C to state B. + @type k_CB: float + @keyword k_AC: The forward exchange rate from state A to state C. + @type k_AC: float + @keyword k_CA: The reverse exchange rate from state C to state A. + @type k_CA: float + """ + + # The AB auto-block. + matrix[0, 0] = -r1rho_prime - k_AB - k_AC + matrix[0, 1] = -wA + matrix[1, 0] = wA + matrix[1, 1] = -r1rho_prime - k_AB - k_AC + matrix[1, 2] = -w1 + matrix[2, 1] = w1 + matrix[2, 2] = -R1 - k_AB - k_AC + + # The AC auto-block. + matrix[3, 3] = -r1rho_prime - k_BA - k_BC + matrix[3, 4] = -wB + matrix[4, 3] = wB + matrix[4, 4] = -r1rho_prime - k_BA - k_BC + matrix[4, 5] = -w1 + matrix[5, 4] = w1 + matrix[5, 5] = -R1 - k_BA - k_BC + + # The BC auto-block. + matrix[6, 6] = -r1rho_prime - k_CA - k_CB + matrix[6, 7] = -wC + matrix[7, 6] = wC + matrix[7, 7] = -r1rho_prime - k_CA - k_CB + matrix[7, 8] = -w1 + matrix[8, 7] = w1 + matrix[8, 8] = -R1 - k_CA - k_CB + + # The AB cross-block. + matrix[3, 0] = k_AB + matrix[4, 1] = k_AB + matrix[5, 2] = k_AB + matrix[0, 3] = k_BA + matrix[1, 4] = k_BA + matrix[2, 5] = k_BA + + # The AC cross-block. + matrix[6, 0] = k_AC + matrix[7, 1] = k_AC + matrix[8, 2] = k_AC + matrix[0, 6] = k_CA + matrix[1, 7] = k_CA + matrix[2, 8] = k_CA + + # The BC cross-block. + matrix[6, 3] = k_BC + matrix[7, 4] = k_BC + matrix[8, 5] = k_BC + matrix[3, 6] = k_CB + matrix[4, 7] = k_CB + matrix[5, 8] = k_CB + + + def rr1rho_3d(R1A=None, R1=None, Rinf=None, pA=None, pB=None, wA=None, wB=None, w1=None, k_AB=None, k_BA=None): """Definition of the 3D exchange matrix. Copied: trunk/lib/dispersion/ns_r1rho_3site.py (from r21888, trunk/lib/dispersion/ns_r1rho_2site.py) URL: http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/ns_r1rho_3site.py?p2=trunk/lib/dispersion/ns_r1rho_3site.py&p1=trunk/lib/dispersion/ns_r1rho_2site.py&r1=21888&r2=21899&rev=21899&view=diff ============================================================================== --- trunk/lib/dispersion/ns_r1rho_2site.py (original) +++ trunk/lib/dispersion/ns_r1rho_3site.py Mon Dec 9 12:33:31 2013 @@ -22,15 +22,13 @@ ############################################################################### # Module docstring. -"""This function performs a numerical fit of 2-site Bloch-McConnell equations for R1rho-type experiments. +"""This function performs a numerical fit of 3-site Bloch-McConnell equations for R1rho-type experiments. -This is the model of the numerical solution for the 2-site Bloch-McConnell equations. It originates from the funNumrho.m file from the Skrynikov & Tollinger code (the sim_all.tar file https://gna.org/support/download.php?file_id=18404 attached to https://gna.org/task/?7712#comment5). +This is the model of the numerical solution for the 3-site Bloch-McConnell equations. It originates from the funNumrho.m file from the Skrynikov & Tollinger code (the sim_all.tar file https://gna.org/support/download.php?file_id=18404 attached to https://gna.org/task/?7712#comment5). The solution has been modified to use the from presented in: - - Korzhnev, D. M., Orekhov, V. Y., and Kay, L. E. (2005). Off-resonance R(1rho) NMR -studies of exchange dynamics in proteins with low spin-lock fields: an application to a -Fyn SH3 domain. J. Am. Chem. Soc., 127, 713-721. (U{DOI: 10.1021/ja0446855<http://dx.doi.org/10.1021/ja0446855>}). + - Korzhnev, D. M., Orekhov, V. Y., and Kay, L. E. (2005). Off-resonance R(1rho) NMR studies of exchange dynamics in proteins with low spin-lock fields: an application to a Fyn SH3 domain. J. Am. Chem. Soc., 127, 713-721. (U{DOI: 10.1021/ja0446855<http://dx.doi.org/10.1021/ja0446855>}). """ # Dependency check module. @@ -41,19 +39,21 @@ from numpy import dot # relax module imports. -from lib.dispersion.ns_matrices import rr1rho_3d +from lib.dispersion.ns_matrices import rr1rho_3d_3site from lib.float import isNaN from lib.linear_algebra.matrix_exponential import matrix_exponential -def ns_r1rho_2site(M0=None, r1rho_prime=None, omega=None, offset=None, r1=0.0, pA=None, pB=None, dw=None, k_AB=None, k_BA=None, spin_lock_fields=None, relax_time=None, inv_relax_time=None, back_calc=None, num_points=None): - """The 2-site numerical solution to the Bloch-McConnell equation for R1rho data. +def ns_r1rho_3site(M0=None, matrix=None, r1rho_prime=None, omega=None, offset=None, r1=0.0, pA=None, pB=None, pC=None, dw_AB=None, dw_AC=None, k_AB=None, k_BA=None, k_BC=None, k_CB=None, k_AC=None, k_CA=None, spin_lock_fields=None, relax_time=None, inv_relax_time=None, back_calc=None, num_points=None): + """The 3-site numerical solution to the Bloch-McConnell equation for R1rho data. This function calculates and stores the R1rho values. @keyword M0: This is a vector that contains the initial magnetizations corresponding to the A and B state transverse magnetizations. @type M0: numpy float64, rank-1, 7D array + @keyword matrix: A numpy array to be populated to create the evolution matrix. + @type matrix: numpy rank-2, 2D complex64 array @keyword r1rho_prime: The R1rho_prime parameter value (R1rho with no exchange). @type r1rho_prime: float @keyword omega: The chemical shift for the spin in rad/s. @@ -66,12 +66,24 @@ @type pA: float @keyword pB: The population of state B. @type pB: float - @keyword dw: The chemical exchange difference between states A and B in rad/s. - @type dw: float + @keyword pC: The population of state C. + @type pC: float + @keyword dw_AB: The chemical exchange difference between states A and B in rad/s. + @type dw_AB: float + @keyword dw_AC: The chemical exchange difference between states A and C in rad/s. + @type dw_AC: float @keyword k_AB: The rate of exchange from site A to B (rad/s). @type k_AB: float @keyword k_BA: The rate of exchange from site B to A (rad/s). @type k_BA: float + @keyword k_BC: The rate of exchange from site B to C (rad/s). + @type k_BC: float + @keyword k_CB: The rate of exchange from site C to B (rad/s). + @type k_CB: float + @keyword k_AC: The rate of exchange from site A to C (rad/s). + @type k_AC: float + @keyword k_CA: The rate of exchange from site C to A (rad/s). + @type k_CA: float @keyword spin_lock_fields: The R1rho spin-lock field strengths (in rad.s^-1). @type spin_lock_fields: numpy rank-1 float array @keyword relax_time: The total relaxation time period for each spin-lock field strength (in seconds). @@ -85,25 +97,27 @@ """ # Repetitive calculations (to speed up calculations). - Wa = omega # Larmor frequency [s^-1]. - Wb = omega + dw # Larmor frequency [s^-1]. - W = pA*Wa + pB*Wb # Population-averaged Larmor frequency [s^-1]. + Wa = omega # Larmor frequency for state A [s^-1]. + Wb = omega + dw_AB # Larmor frequency for state B [s^-1]. + Wc = omega + dw_AC # Larmor frequency for state C [s^-1]. + W = pA*Wa + pB*Wb + pC*Wc # Population-averaged Larmor frequency [s^-1]. dA = Wa - offset # Offset of spin-lock from A. dB = Wb - offset # Offset of spin-lock from B. + dC = Wc - offset # Offset of spin-lock from C. d = W - offset # Offset of spin-lock from population-average. # Loop over the time points, back calculating the R2eff values. for i in range(num_points): - # 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) + # The matrix that contains all the contributions to the evolution, i.e. relaxation, exchange and chemical shift evolution. + rr1rho_3d_3site(matrix=matrix, R1=r1, r1rho_prime=r1rho_prime, pA=pA, pB=pB, pC=pC, wA=dA, wB=dB, wC=dC, w1=spin_lock_fields[i], k_AB=k_AB, k_BA=k_BA, k_BC=k_BC, k_CB=k_CB, k_AC=k_AC, k_CA=k_CA) # The following lines rotate the magnetization previous to spin-lock into the weff frame. theta = atan(spin_lock_fields[i]/d) M0[0] = sin(theta) - M0[4] = cos(theta) + M0[1] = cos(theta) # This matrix is a propagator that will evolve the magnetization with the matrix R. - Rexpo = matrix_exponential(R*relax_time) + Rexpo = matrix_exponential(matrix*relax_time) # Magnetization evolution. MA = dot(M0, dot(Rexpo, M0)) @@ -113,5 +127,3 @@ back_calc[i] = 1e99 else: back_calc[i]= -inv_relax_time * log(MA) - -