mailRe: r24175 - /branches/disp_spin_speed/lib/dispersion/ns_matrices.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on June 23, 2014 - 10:17:
As with the NS CPMG 2-site 3D model, you can shift all of the m_*
matrices out of the function so they are initialised only once when
relax starts, and not for each function call.

Cheers,

Edward

On 20 June 2014 08:11,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Fri Jun 20 08:11:47 2014
New Revision: 24175

URL: http://svn.gna.org/viewcvs/relax?rev=24175&view=rev
Log:
Added the function "rcpmg_star_rankN" for the collection of the 
multidimensional relaxation matrix for model NS CPMG 2site star.

Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion 
models for Clustered analysis.

Modified:
    branches/disp_spin_speed/lib/dispersion/ns_matrices.py

Modified: branches/disp_spin_speed/lib/dispersion/ns_matrices.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/lib/dispersion/ns_matrices.py?rev=24175&r1=24174&r2=24175&view=diff
==============================================================================
--- branches/disp_spin_speed/lib/dispersion/ns_matrices.py      (original)
+++ branches/disp_spin_speed/lib/dispersion/ns_matrices.py      Fri Jun 20 
08:11:47 2014
@@ -31,7 +31,7 @@

 # Python module imports.
 from math import cos, sin, pi
-from numpy import array, float64, matrix, multiply
+from numpy import add, array, conj, complex64, float64, matrix, multiply


 def r180x_2d(flip=pi):
@@ -318,6 +318,105 @@

     # Return the matrix.
     return c_mat
+
+
+def rcpmg_star_rankN(R2A=None, R2B=None, pA=None, pB=None, dw=None, 
k_AB=None, k_BA=None, tcp=None):
+    """Definition of the exchange matrix, for rank 
[NE][NS][NM][NO][ND][2][2].
+
+    @keyword R2A:   The transverse, spin-spin relaxation rate for state A.
+    @type R2A:      numpy float array of rank [NE][NS][NM][NO][ND]
+    @keyword R2B:   The transverse, spin-spin relaxation rate for state B.
+    @type R2B:      numpy float array of rank [NE][NS][NM][NO][ND]
+    @keyword pA:    The population of state A.
+    @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:       numpy float array of rank [NE][NS][NM][NO][ND]
+    @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 tcp:   The tau_CPMG times (1 / 4.nu1).
+    @type tcp:      numpy float array of rank [NE][NS][NM][NO][ND]
+    @return:        The relaxation matrix R and complex conjugate cR2.
+    @rtype:         numpy float array of rank [NE][NS][NM][NO][ND][2][2]
+    """
+
+    # Pre-multiply with tcp.
+    r20a_tcp = R2A * tcp
+    r20b_tcp = R2B * tcp
+    k_AB_tcp = k_AB * tcp
+    k_BA_tcp = k_BA * tcp
+    # Complex dw.
+    dw_tcp_C = dw * tcp * -1j
+
+    # Create matrix for collection of Rr matrix.
+    # The matrix that contains only the R2 relaxation terms ("Redfield 
relaxation", i.e. non-exchange broadening).
+    #Rr[0, 0] = -R2A_si_mi
+    #Rr[1, 1] = -R2B_si_mi
+
+    m_r20a = array([
+        [-1.0, 0.0],
+        [0.0, 0.0],], complex64)
+
+    m_r20b = array([
+        [0.0, 0.0],
+        [0.0, -1.0],], complex64)
+
+    # Multiply and expand.
+    m_r20a_tcp = multiply.outer( r20a_tcp, m_r20a )
+    m_r20b_tcp = multiply.outer( r20b_tcp, m_r20b )
+
+    # Collect Rr matrix.
+    Rr_mat = (m_r20a_tcp + m_r20b_tcp)
+
+    # Create matrix for collection of Rex.
+    # Set up the matrix that contains the exchange terms between the two 
states A and B.
+    #Rex[0, 0] = -k_AB
+    #Rex[0, 1] = k_BA
+    #Rex[1, 0] = k_AB
+    #Rex[1, 1] = -k_BA
+
+    m_k_AB = array([
+        [-1.0, 0.0],
+        [1.0, 0.0],], complex64)
+
+    m_k_BA = array([
+        [0.0, 1.0],
+        [0.0, -1.0],], complex64)
+
+    # Multiply and expand.
+    m_k_AB_tcp = multiply.outer( k_AB_tcp, m_k_AB )
+    m_k_BA_tcp = multiply.outer( k_BA_tcp, m_k_BA )
+
+    # Collect Rex matrix.
+    Rex_mat = (m_k_AB_tcp + m_k_BA_tcp)
+
+    # Create the matrix for RCS.
+    # The matrix that contains the chemical shift evolution.  It works 
here only with X magnetization, and the complex notation allows to evolve 
in the transverse plane (x, y).  The chemical shift for state A is assumed 
to be zero.
+    #RCS[1, 1] = complex(0.0, -dw_si_mi)
+
+    m_dw = array([
+        [0.0, 0.0],
+        [0.0, 1.0],], complex64)
+
+    # Multiply and expand.
+    m_dw_tcp_C = multiply.outer( dw_tcp_C, m_dw )
+
+    # Collect RCS matrix.
+    RCS_mat = m_dw_tcp_C
+
+    # The matrix R that contains all the contributions to the evolution, 
i.e. relaxation, exchange and chemical shift evolution.
+    R_mat = add(Rr_mat, Rex_mat)
+    R_mat = add(R_mat, RCS_mat)
+
+    # This is the complex conjugate of the above.  It allows the chemical 
shift to run in the other direction, i.e. it is used to evolve the shift 
after a 180 deg pulse.  The factor of 2 is to minimise the number of 
multiplications for the prop_2 matrix calculation.
+    cR2_mat = conj(R_mat) * 2.0
+
+    # Return the matrixes.
+    return R_mat, cR2_mat, Rr_mat, Rex_mat, RCS_mat
+


 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):


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Mon Jun 23 10:40:14 2014