Package lib :: Package dispersion :: Module ns_r1rho_2site
[hide private]
[frames] | no frames]

Source Code for Module lib.dispersion.ns_r1rho_2site

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2000-2001 Nikolai Skrynnikov                                  # 
  4  # Copyright (C) 2000-2001 Martin Tollinger                                    # 
  5  # Copyright (C) 2013-2014 Edward d'Auvergne                                   # 
  6  #                                                                             # 
  7  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  8  #                                                                             # 
  9  # This program is free software: you can redistribute it and/or modify        # 
 10  # it under the terms of the GNU General Public License as published by        # 
 11  # the Free Software Foundation, either version 3 of the License, or           # 
 12  # (at your option) any later version.                                         # 
 13  #                                                                             # 
 14  # This program is distributed in the hope that it will be useful,             # 
 15  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 16  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 17  # GNU General Public License for more details.                                # 
 18  #                                                                             # 
 19  # You should have received a copy of the GNU General Public License           # 
 20  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  # Module docstring. 
 25  """The numerical solution for the 2-site Bloch-McConnell equations for R1rho-type data, the U{NS R1rho 2-site<http://wiki.nmr-relax.com/NS_R1rho_2-site>} model. 
 26   
 27  Description 
 28  =========== 
 29   
 30  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 U{https://web.archive.org/web/https://gna.org/support/download.php?file_id=18404} attached to U{https://web.archive.org/web/https://gna.org/task/?7712#comment5}). 
 31   
 32   
 33  References 
 34  ========== 
 35   
 36  The solution has been modified to use the from presented in: 
 37   
 38      - 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.  I{J. Am. Chem. Soc.}, B{127}, 713-721. (U{DOI: 10.1021/ja0446855<http://dx.doi.org/10.1021/ja0446855>}). 
 39   
 40   
 41  Links 
 42  ===== 
 43   
 44  More information on the NS R1rho 2-site model can be found in the: 
 45   
 46      - U{relax wiki<http://wiki.nmr-relax.com/NS_R1rho_2-site>}, 
 47      - U{relax manual<http://www.nmr-relax.com/manual/NS_2_site_R1_model.html>}, 
 48      - U{relaxation dispersion page of the relax website<http://www.nmr-relax.com/analyses/relaxation_dispersion.html#NS_R1rho_2-site>}. 
 49  """ 
 50   
 51  # Python module imports. 
 52  from math import atan2, cos, log, sin 
 53  from numpy import dot 
 54   
 55  # relax module imports. 
 56  from lib.dispersion.ns_matrices import rr1rho_3d 
 57  from lib.float import isNaN 
 58  from lib.linear_algebra.matrix_exponential import matrix_exponential 
 59   
 60   
61 -def ns_r1rho_2site(M0=None, matrix=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):
62 """The 2-site numerical solution to the Bloch-McConnell equation for R1rho data. 63 64 This function calculates and stores the R1rho values. 65 66 67 @keyword M0: This is a vector that contains the initial magnetizations corresponding to the A and B state transverse magnetizations. 68 @type M0: numpy float64, rank-1, 7D array 69 @keyword matrix: A numpy array to be populated to create the evolution matrix. 70 @type matrix: numpy rank-2, 6D float64 array 71 @keyword r1rho_prime: The R1rho_prime parameter value (R1rho with no exchange). 72 @type r1rho_prime: float 73 @keyword omega: The chemical shift for the spin in rad/s. 74 @type omega: float 75 @keyword offset: The spin-lock offsets for the data. 76 @type offset: numpy rank-1 float array 77 @keyword r1: The R1 relaxation rate. 78 @type r1: float 79 @keyword pA: The population of state A. 80 @type pA: float 81 @keyword pB: The population of state B. 82 @type pB: float 83 @keyword dw: The chemical exchange difference between states A and B in rad/s. 84 @type dw: float 85 @keyword k_AB: The rate of exchange from site A to B (rad/s). 86 @type k_AB: float 87 @keyword k_BA: The rate of exchange from site B to A (rad/s). 88 @type k_BA: float 89 @keyword spin_lock_fields: The R1rho spin-lock field strengths (in rad.s^-1). 90 @type spin_lock_fields: numpy rank-1 float array 91 @keyword relax_time: The total relaxation time period for each spin-lock field strength (in seconds). 92 @type relax_time: float 93 @keyword inv_relax_time: The inverse of the relaxation time period for each spin-lock field strength (in inverse seconds). This is used for faster calculations. 94 @type inv_relax_time: float 95 @keyword back_calc: The array for holding the back calculated R2eff values. Each element corresponds to one of the CPMG nu1 frequencies. 96 @type back_calc: numpy rank-1 float array 97 @keyword num_points: The number of points on the dispersion curve, equal to the length of the tcp and back_calc arguments. 98 @type num_points: int 99 """ 100 101 # Repetitive calculations (to speed up calculations). 102 Wa = omega # Larmor frequency [s^-1]. 103 Wb = omega + dw # Larmor frequency [s^-1]. 104 W = pA*Wa + pB*Wb # Population-averaged Larmor frequency [s^-1]. 105 dA = Wa - offset # Offset of spin-lock from A. 106 dB = Wb - offset # Offset of spin-lock from B. 107 d = W - offset # Offset of spin-lock from population-average. 108 109 # Loop over the time points, back calculating the R2eff values. 110 for i in range(num_points): 111 # The matrix that contains all the contributions to the evolution, i.e. relaxation, exchange and chemical shift evolution. 112 rr1rho_3d(matrix=matrix, R1=r1, r1rho_prime=r1rho_prime, pA=pA, pB=pB, wA=dA, wB=dB, w1=spin_lock_fields[i], k_AB=k_AB, k_BA=k_BA) 113 114 # The following lines rotate the magnetization previous to spin-lock into the weff frame. 115 theta = atan2(spin_lock_fields[i], dA) 116 M0[0] = sin(theta) # The A state initial X magnetisation. 117 M0[2] = cos(theta) # The A state initial Z magnetisation. 118 119 # This matrix is a propagator that will evolve the magnetization with the matrix R. 120 Rexpo = matrix_exponential(matrix*relax_time) 121 122 # Magnetization evolution. 123 MA = dot(M0, dot(Rexpo, M0)) 124 125 # The next lines calculate the R1rho using a two-point approximation, i.e. assuming that the decay is mono-exponential. 126 if MA <= 0.0 or isNaN(MA): 127 back_calc[i] = 1e99 128 else: 129 back_calc[i]= -inv_relax_time * log(MA)
130