Author: bugman Date: Sun Jun 9 22:36:05 2013 New Revision: 20001 URL: http://svn.gna.org/viewcvs/relax?rev=20001&view=rev Log: Created the DPL94 model target function. This is the David, Perlman and London 1994 R1rho 2-site fast exchange model. 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=20001&r1=20000&r2=20001&view=diff ============================================================================== --- branches/relax_disp/target_functions/relax_disp.py (original) +++ branches/relax_disp/target_functions/relax_disp.py Sun Jun 9 22:36:05 2013 @@ -28,12 +28,13 @@ # relax module imports. from lib.dispersion.cr72 import r2eff_CR72 +from lib.dispersion.dpl94 import r1rho_DPL94 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_M61B, MODEL_NOREX, MODEL_R2EFF +from specific_analyses.relax_disp.variables import MODEL_CR72, MODEL_DPL94, MODEL_LIST_FULL, MODEL_LM63, MODEL_M61, MODEL_M61B, MODEL_NOREX, MODEL_R2EFF class Dispersion: @@ -49,6 +50,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. + - 'DPL94': The Davis, Perlman and London (1994) 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. @@ -123,6 +125,8 @@ self.func = self.func_CR72 if model == MODEL_M61: self.func = self.func_M61 + if model == MODEL_DPL94: + self.func = self.func_DPL94 if model == MODEL_M61B: self.func = self.func_M61b @@ -177,6 +181,52 @@ return chi2_sum + def func_DPL94(self, params): + """Target function for the Davis, Perlman and London (1994) 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]] + phi_ex = params[self.end_index[0]: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 phi_ex from ppm^2 to (rad/s)^2. + phi_ex_scaled = phi_ex[spin_index] * self.frqs[spin_index, frq_index]**2 + + # Back calculate the R2eff values. + r1rho_DPL94(r1rho_prime=R20[r20_index], phi_ex=phi_ex_scaled, 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_LM63(self, params): """Target function for the Luz and Meiboom (1963) fast 2-site exchange model.