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  # Dependency check module. 
 52  import dep_check 
 53   
 54  # Python module imports. 
 55  from math import atan, cos, log, pi, sin, sqrt 
 56  from numpy import dot 
 57   
 58  # relax module imports. 
 59  from lib.dispersion.ns_matrices import rr1rho_3d 
 60  from lib.float import isNaN 
 61  from lib.linear_algebra.matrix_exponential import matrix_exponential 
 62   
 63   
64 -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):
65 """The 2-site numerical solution to the Bloch-McConnell equation for R1rho data. 66 67 This function calculates and stores the R1rho values. 68 69 70 @keyword M0: This is a vector that contains the initial magnetizations corresponding to the A and B state transverse magnetizations. 71 @type M0: numpy float64, rank-1, 7D array 72 @keyword matrix: A numpy array to be populated to create the evolution matrix. 73 @type matrix: numpy rank-2, 6D float64 array 74 @keyword r1rho_prime: The R1rho_prime parameter value (R1rho with no exchange). 75 @type r1rho_prime: float 76 @keyword omega: The chemical shift for the spin in rad/s. 77 @type omega: float 78 @keyword offset: The spin-lock offsets for the data. 79 @type offset: numpy rank-1 float array 80 @keyword r1: The R1 relaxation rate. 81 @type r1: float 82 @keyword pA: The population of state A. 83 @type pA: float 84 @keyword pB: The population of state B. 85 @type pB: float 86 @keyword dw: The chemical exchange difference between states A and B in rad/s. 87 @type dw: float 88 @keyword k_AB: The rate of exchange from site A to B (rad/s). 89 @type k_AB: float 90 @keyword k_BA: The rate of exchange from site B to A (rad/s). 91 @type k_BA: float 92 @keyword spin_lock_fields: The R1rho spin-lock field strengths (in rad.s^-1). 93 @type spin_lock_fields: numpy rank-1 float array 94 @keyword relax_time: The total relaxation time period for each spin-lock field strength (in seconds). 95 @type relax_time: float 96 @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. 97 @type inv_relax_time: float 98 @keyword back_calc: The array for holding the back calculated R2eff values. Each element corresponds to one of the CPMG nu1 frequencies. 99 @type back_calc: numpy rank-1 float array 100 @keyword num_points: The number of points on the dispersion curve, equal to the length of the tcp and back_calc arguments. 101 @type num_points: int 102 """ 103 104 # Repetitive calculations (to speed up calculations). 105 Wa = omega # Larmor frequency [s^-1]. 106 Wb = omega + dw # Larmor frequency [s^-1]. 107 W = pA*Wa + pB*Wb # Population-averaged Larmor frequency [s^-1]. 108 dA = Wa - offset # Offset of spin-lock from A. 109 dB = Wb - offset # Offset of spin-lock from B. 110 d = W - offset # Offset of spin-lock from population-average. 111 112 # Loop over the time points, back calculating the R2eff values. 113 for i in range(num_points): 114 # The matrix that contains all the contributions to the evolution, i.e. relaxation, exchange and chemical shift evolution. 115 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) 116 117 # The following lines rotate the magnetization previous to spin-lock into the weff frame. 118 theta = atan(spin_lock_fields[i]/dA) 119 M0[0] = sin(theta) # The A state initial X magnetisation. 120 M0[2] = cos(theta) # The A state initial Z magnetisation. 121 122 # This matrix is a propagator that will evolve the magnetization with the matrix R. 123 Rexpo = matrix_exponential(matrix*relax_time) 124 125 # Magnetization evolution. 126 MA = dot(M0, dot(Rexpo, M0)) 127 128 # The next lines calculate the R1rho using a two-point approximation, i.e. assuming that the decay is mono-exponential. 129 if MA <= 0.0 or isNaN(MA): 130 back_calc[i] = 1e99 131 else: 132 back_calc[i]= -inv_relax_time * log(MA)
133