Author: bugman Date: Fri Aug 30 15:55:23 2013 New Revision: 20731 URL: http://svn.gna.org/viewcvs/relax?rev=20731&view=rev Log: A number of fixes for the 'NS R1rho 2-site' dispersion model. The model should now be fully functional. The chemical shift and R1 related data are now assembled for this model, and the data correctly passed from the target function to the lib.dispersion module. Modified: branches/relax_disp/lib/dispersion/ns_r1rho_2site.py branches/relax_disp/specific_analyses/relax_disp/api.py branches/relax_disp/target_functions/relax_disp.py Modified: branches/relax_disp/lib/dispersion/ns_r1rho_2site.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/ns_r1rho_2site.py?rev=20731&r1=20730&r2=20731&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/ns_r1rho_2site.py (original) +++ branches/relax_disp/lib/dispersion/ns_r1rho_2site.py Fri Aug 30 15:55:23 2013 @@ -31,7 +31,7 @@ import dep_check # Python module imports. -from math import atan, fabs, log +from math import atan, cos, log, pi, sin, sqrt from numpy import dot if dep_check.scipy_module: from scipy.linalg import expm @@ -41,7 +41,7 @@ from lib.float import isNaN -def ns_r1rho_2site(M0=None, r1rho_prime=None, omega=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): +def ns_r1rho_2site(M0=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): """The 2-site numerical solution to the Bloch-McConnell equation for R1rho data. This function calculates and stores the R1rho values. @@ -53,6 +53,8 @@ @type r1rho_prime: float @keyword omega: The chemical shift for the spin in rad/s. @type omega: float + @keyword offset: The spin-lock offsets for the data. + @type offset: numpy rank-1 float array @keyword r1: The R1 relaxation rate. @type r1: float @keyword pA: The population of state A. @@ -68,9 +70,9 @@ @keyword spin_lock_fields: The R1rho spin-lock field strengths in Hz. @type spin_lock_fields: numpy rank-1 float array @keyword relax_time: The total relaxation time period for each spin-lock field strength (in seconds). - @type relax_time: numpy rank-1 float array + @type relax_time: float @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. - @type inv_relax_time: numpy rank-1 float array + @type inv_relax_time: float @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 tcp and back_calc arguments. @@ -80,7 +82,6 @@ # Repetitive calculations (to speed up calculations). Wa = omega # Larmor frequency [s^-1]. Wb = omega + dw # Larmor frequency [s^-1]. - kex2 = kex**2 # Loop over the time points, back calculating the R2eff values. for i in range(num_points): @@ -102,7 +103,7 @@ M0[5] = cos(thetaB) * pB # This matrix is a propagator that will evolve the magnetization with the matrix R. - Rexpo = expm(R*relax_time[i]) + Rexpo = expm(R*relax_time) # Magnetization evolution. Moft = dot(Rexpo, M0) @@ -115,6 +116,6 @@ if MA <= 0.0 or isNaN(MA): back_calc[i] = 1e99 else: - back_calc[i]= -inv_relax_time[i] * log(MA) + back_calc[i]= -inv_relax_time * log(MA) Modified: branches/relax_disp/specific_analyses/relax_disp/api.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/api.py?rev=20731&r1=20730&r2=20731&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/api.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/api.py Fri Aug 30 15:55:23 2013 @@ -131,7 +131,7 @@ # The offset and R1 data for R1rho off-resonance models. chemical_shifts, offsets, tilt_angles, r1 = None, None, None, None - if spin.model in [MODEL_DPL94, MODEL_TP02]: + if spin.model in [MODEL_DPL94, MODEL_TP02, MODEL_NS_R1RHO_2SITE]: chemical_shifts, offsets, tilt_angles = return_offset_data(spins=[spin], spin_ids=[spin_id], fields=fields, field_count=field_count) r1 = return_r1_data(spins=[spin], spin_ids=[spin_id], fields=fields, field_count=field_count) @@ -1178,7 +1178,7 @@ # The offset and R1 data for R1rho off-resonance models. chemical_shifts, offsets, tilt_angles, r1 = None, None, None, None - if spins[0].model in [MODEL_DPL94, MODEL_TP02]: + if spins[0].model in [MODEL_DPL94, MODEL_TP02, MODEL_NS_R1RHO_2SITE]: chemical_shifts, offsets, tilt_angles = return_offset_data(spins=spins, spin_ids=spin_ids, fields=fields, field_count=field_count) r1 = return_r1_data(spins=spins, spin_ids=spin_ids, fields=fields, field_count=field_count, sim_index=sim_index) 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=20731&r1=20730&r2=20731&view=diff ============================================================================== --- branches/relax_disp/target_functions/relax_disp.py (original) +++ branches/relax_disp/target_functions/relax_disp.py Fri Aug 30 15:55:23 2013 @@ -977,7 +977,7 @@ dw_frq = dw[spin_index] * self.frqs[spin_index, frq_index] # Back calculate the R2eff values. - ns_r1rho_2site(M0=self.M0, r1rho_prime=r1rho_prime[r20_index], omega=self.chemical_shifts[spin_index, frq_index], r1=self.r1[spin_index, frq_index], pA=pA, pB=pB, dw=dw_frq, k_AB=k_AB, k_BA=k_BA, spin_lock_fields=self.spin_lock_nu1, relax_time=self.relax_time, inv_relax_time=self.inv_relax_time, back_calc=self.back_calc[spin_index, frq_index], num_points=self.num_disp_points) + ns_r1rho_2site(M0=self.M0, r1rho_prime=r1rho_prime[r20_index], omega=self.chemical_shifts[spin_index, frq_index], offset=self.spin_lock_offsets[spin_index, frq_index], r1=self.r1[spin_index, frq_index], pA=pA, pB=pB, dw=dw_frq, k_AB=k_AB, k_BA=k_BA, spin_lock_fields=self.spin_lock_nu1, relax_time=self.relax_time, inv_relax_time=self.inv_relax_time, 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):