Author: bugman Date: Mon May 6 10:58:18 2013 New Revision: 19663 URL: http://svn.gna.org/viewcvs/relax?rev=19663&view=rev Log: Shifted the LM63 dispersion model functions into the new lib.dispersion.lm63 module. Added: branches/relax_disp/lib/dispersion/lm63.py - copied, changed from r19657, branches/relax_disp/lib/dispersion/equations.py Modified: branches/relax_disp/lib/dispersion/equations.py branches/relax_disp/target_functions/relax_disp.py Modified: branches/relax_disp/lib/dispersion/equations.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/equations.py?rev=19663&r1=19662&r2=19663&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/equations.py (original) +++ branches/relax_disp/lib/dispersion/equations.py Mon May 6 10:58:18 2013 @@ -24,7 +24,7 @@ """The relaxation dispersion equations.""" # Python module imports. -from math import log, tanh +from math import log def calc_two_point_r2eff(relax_time=None, I_ref=None, I=None): @@ -49,20 +49,3 @@ # Calculate and return the value (avoiding integer division problems). return -1.0 / relax_time * log(float(I) / I_ref) - - -def r2eff_LM63(params=None, cpmg_frqs=None, back_calc=None, num_disp_points=None): - """Back calculate R2eff. - - The currently supported equation is that for CPMG relaxation dispersion in the fast exchange limit: - - - Millet et al., JACS, 2000, 122, 2867-2877 (equation 19) - - Kovrigin et al., J. Mag. Res., 2006, 180, 93-104 (equation 1) - - In the future, back-calculation should be available for CPMG relaxation dispersion in the slow exchange limit: - - Tollinger et al., JACS, 2001, 123, 11341-11352 (equation 2) - """ - - # Loop over the time points, back calculating the R2eff value. - for i in range(num_disp_points): - back_calc[i] = params[0] + params[1] * (1 - 2 * tanh(params[2] / (2 * 4 * cpmg_frqs[i])) * ((4 * cpmg_frqs[i] ) / params[2])) Copied: branches/relax_disp/lib/dispersion/lm63.py (from r19657, branches/relax_disp/lib/dispersion/equations.py) URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/lm63.py?p2=branches/relax_disp/lib/dispersion/lm63.py&p1=branches/relax_disp/lib/dispersion/equations.py&r1=19657&r2=19663&rev=19663&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/equations.py (original) +++ branches/relax_disp/lib/dispersion/lm63.py Mon May 6 10:58:18 2013 @@ -21,48 +21,49 @@ ############################################################################### # Module docstring. -"""The relaxation dispersion equations.""" +"""The Luz and Meiboom (1963) 2-site fast exchange model. + +This module is for the function, gradient and Hessian of the LM63 model. The model is named after the reference: + + Luz, S. and Meiboom S., 1963, Nuclear Magnetic Resonance study of protolysis of trimethylammonium ion in aqueous solution - order of reaction with respect to solvent, J. Chem. Phys. 1963, 39, 366-370 (U{DOI: 10.1063/1.1734254<http://dx.doi.org/10.1063/1.1734254>}). + +The equation used is: + + phi_ex / 4 * nu_cpmg / kex \ \ + R2eff = R20 + ------ * | 1 - ----------- * tanh | ----------- | | , + kex \ kex \ 4 * nu_cpmg / / + +where: + + phi_ex = pA * pB * delta_omega^2 , + +kex is the chemical exchange rate constant, pA and pB are the populations of states A and B, and delta_omega is the chemical shift difference between the two states. +""" # Python module imports. -from math import log, tanh +from math import tanh -def calc_two_point_r2eff(relax_time=None, I_ref=None, I=None): - """Calculate the R2eff/R1rho value for the fixed relaxation time data. +def r2eff_LM63(r20=None, phi_ex=None, kex=None, cpmg_frqs=None, back_calc=None, num_points=None): + """Calculate the R2eff values for the LM63 model. - The formula is: - - -1 / I1 \ - R2eff = ------- * ln | -- | , - relax_T \ I0 / - - where relax_T is the fixed delay time, I0 is the reference peak intensity when relax_T is zero, and I1 is the peak intensity in a spectrum of interest. + See the module docstring for details. - @keyword relax_time: The fixed relaxation delay time in seconds. - @type relax_time: float - @keyword I_ref: The peak intensity in the reference spectrum. - @type I_ref: float - @keyword I: The peak intensity of interest. - @type I: float + @keyword r20: The R20 parameter value (R2 with no exchange). + @type r20: float + @keyword phi_ex: The phi_ex parameter value (pA * pB * delta_omega^2). + @type phi_ex: float + @keyword kex: The kex parameter value (the exchange rate in rad/s). + @type kex: float + @keyword cpmg_frqs: The CPMG nu1 frequencies. + @type cpmg_frqs: numpy rank-1 float array + @keyword back_calc: The array for holding the back calculated R2eff values. Each element corresponds to one of the CPMG nu1 frequencies. + @type back_calc: numpy rank-1 float array + @keyword num_points: The number of points on the dispersion curve, equal to the length of the cpmg_frqs and back_calc arguments. + @type num_poinst: int """ - # Calculate and return the value (avoiding integer division problems). - return -1.0 / relax_time * log(float(I) / I_ref) - - -def r2eff_LM63(params=None, cpmg_frqs=None, back_calc=None, num_disp_points=None): - """Back calculate R2eff. - - The currently supported equation is that for CPMG relaxation dispersion in the fast exchange limit: - - - Millet et al., JACS, 2000, 122, 2867-2877 (equation 19) - - Kovrigin et al., J. Mag. Res., 2006, 180, 93-104 (equation 1) - - In the future, back-calculation should be available for CPMG relaxation dispersion in the slow exchange limit: - - Tollinger et al., JACS, 2001, 123, 11341-11352 (equation 2) - """ - - # Loop over the time points, back calculating the R2eff value. - for i in range(num_disp_points): - back_calc[i] = params[0] + params[1] * (1 - 2 * tanh(params[2] / (2 * 4 * cpmg_frqs[i])) * ((4 * cpmg_frqs[i] ) / params[2])) + # Loop over the time points, back calculating the R2eff values. + for i in range(num_points): + back_calc[i] = r20 + phi_ex / kex * (1.0 - (4.0 * cpmg_frqs[i] / params[2]) * tanh(kex / (4 * cpmg_frqs[i]))) 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=19663&r1=19662&r2=19663&view=diff ============================================================================== --- branches/relax_disp/target_functions/relax_disp.py (original) +++ branches/relax_disp/target_functions/relax_disp.py Mon May 6 10:58:18 2013 @@ -27,7 +27,7 @@ from numpy import dot, float64, zeros # relax module imports. -from lib.dispersion.equations import r2eff_LM63 +from lib.dispersion.lm63 import r2eff_LM63 from lib.errors import RelaxError from target_functions.chi2 import chi2 from specific_analyses.relax_disp.variables import MODEL_CR72, MODEL_LM63, MODEL_R2EFF @@ -117,7 +117,7 @@ # Loop over the spectrometer frequencies. for frq_index in range(self.num_frq): # Back calculate the R2eff values. - r2eff_LM63(params=params, cpmg_frqs=self.cpmg_frqs, back_calc=self.back_calc[spin_index, frq_index], num_disp_points=self.num_disp_points) + r2eff_LM63(r20=params[0], phi_ex=params[1], kex=params[2], cpmg_frqs=self.cpmg_frqs, back_calc=self.back_calc[spin_index, frq_index], num_points=self.num_disp_points) # Calculate and return the chi-squared value. chi2_sum += chi2(values[spin_index, frq_index], back_calc[spin_index, frq_index], sd[spin_index, frq_index])