mailr19974 - /branches/relax_disp/target_functions/relax_disp.py


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

Header


Content

Posted by edward on June 08, 2013 - 23:24:
Author: bugman
Date: Sat Jun  8 23:24:21 2013
New Revision: 19974

URL: http://svn.gna.org/viewcvs/relax?rev=19974&view=rev
Log:
Created the M61 skew model target function.

This is the Meiboom 1961 on-resonance 2-site model for skewed populations (pA 
pB).

This commit follows step 4 of the relaxation dispersion model addition 
tutorial
(http://thread.gmane.org/gmane.science.nmr.relax.devel/3907).


Modified:
    branches/relax_disp/target_functions/relax_disp.py

Modified: branches/relax_disp/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/target_functions/relax_disp.py?rev=19974&r1=19973&r2=19974&view=diff
==============================================================================
--- branches/relax_disp/target_functions/relax_disp.py (original)
+++ branches/relax_disp/target_functions/relax_disp.py Sat Jun  8 23:24:21 
2013
@@ -30,9 +30,10 @@
 from lib.dispersion.cr72 import r2eff_CR72
 from lib.dispersion.lm63 import r2eff_LM63
 from lib.dispersion.m61 import r1rho_M61
+from lib.dispersion.m61b import r1rho_M61b
 from lib.errors import RelaxError
 from target_functions.chi2 import chi2
-from specific_analyses.relax_disp.variables import MODEL_CR72, 
MODEL_LIST_FULL, MODEL_LM63, MODEL_M61, MODEL_NOREX, MODEL_R2EFF
+from specific_analyses.relax_disp.variables import MODEL_CR72, 
MODEL_LIST_FULL, MODEL_LM63, MODEL_M61, MODEL_M61B, MODEL_NOREX, MODEL_R2EFF
 
 
 class Dispersion:
@@ -48,6 +49,7 @@
             - 'LM63':  The Luz and Meiboom (1963) 2-site fast exchange model.
             - 'CR72':  The Carver and Richards (1972) 2-site model for all 
time scales.
             - 'M61':  The Meiboom (1961) 2-site fast exchange model for 
R1rho-type experiments.
+            - 'M61 skew':  The Meiboom (1961) on-resonance 2-site model with 
skewed populations (pA >> pB) for R1rho-type experiments.
 
 
         @keyword model:             The relaxation dispersion model to fit.
@@ -121,6 +123,8 @@
             self.func = self.func_CR72
         if model == MODEL_M61:
             self.func = self.func_M61
+        if model == MODEL_M61B:
+            self.func = self.func_M61b
 
 
     def func_CR72(self, params):
@@ -265,6 +269,53 @@
         return chi2_sum
 
 
+    def func_M61b(self, params):
+        """Target function for the Meiboom (1961) fast 2-site exchange model 
for R1rho-type experiments.
+
+        @param params:  The vector of parameter values.
+        @type params:   numpy rank-1 float array
+        @return:        The chi-squared value.
+        @rtype:         float
+        """
+
+        # Scaling.
+        if self.scaling_flag:
+            params = dot(params, self.scaling_matrix)
+
+        # Unpack the parameter values.
+        R20 = params[:self.end_index[0]]
+        dw = params[self.end_index[0]:self.end_index[1]]
+        pA = params[self.end_index[1]]
+        kex = params[self.end_index[1]]
+
+        # Initialise.
+        chi2_sum = 0.0
+
+        # Loop over the spins.
+        for spin_index in range(self.num_spins):
+            # Loop over the spectrometer frequencies.
+            for frq_index in range(self.num_frq):
+                # The R20 index.
+                r20_index = frq_index + spin_index*self.num_frq
+
+                # Convert dw from ppm to rad/s.
+                dw_frq = dw[spin_index] * self.frqs[spin_index, frq_index]
+
+                # Back calculate the R1rho values.
+                r1rho_M61b(r1rho_prime=R20[r20_index], pA=pA, dw=dw_frq, 
kex=kex, spin_lock_fields=self.spin_lock_nu1, 
back_calc=self.back_calc[spin_index, frq_index], 
num_points=self.num_disp_points)
+
+                # For all missing data points, set the back-calculated value 
to the measured values so that it has no effect on the chi-squared value.
+                for point_index in range(self.num_disp_points):
+                    if self.missing[spin_index, frq_index, point_index]:
+                        self.back_calc[spin_index, frq_index, point_index] = 
self.values[spin_index, frq_index, point_index]
+
+                # Calculate and return the chi-squared value.
+                chi2_sum += chi2(self.values[spin_index, frq_index], 
self.back_calc[spin_index, frq_index], self.errors[spin_index, frq_index])
+
+        # Return the total chi-squared value.
+        return chi2_sum
+
+
     def func_NOREX(self, params):
         """Target function for no exchange.
 




Related Messages


Powered by MHonArc, Updated Sat Jun 08 23:40:01 2013