Author: bugman Date: Mon Jul 15 10:57:48 2013 New Revision: 20295 URL: http://svn.gna.org/viewcvs/relax?rev=20295&view=rev Log: Completed the conversion of the ground and excited states (G, E) to the A and B states. This follows from http://thread.gmane.org/gmane.science.nmr.relax.devel/4132/focus=4154. Modified: branches/relax_disp/lib/dispersion/ns_2site_star.py branches/relax_disp/lib/dispersion/ns_matrices.py branches/relax_disp/target_functions/relax_disp.py Modified: branches/relax_disp/lib/dispersion/ns_2site_star.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/ns_2site_star.py?rev=20295&r1=20294&r2=20295&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/ns_2site_star.py (original) +++ branches/relax_disp/lib/dispersion/ns_2site_star.py Mon Jul 15 10:57:48 2013 @@ -41,7 +41,7 @@ from lib.linear_algebra.matrix_power import square_matrix_power -def r2eff_ns_2site_star(r20a=None, r20b=None, fg=None, kge=None, keg=None, tcpmg=None, cpmg_frqs=None, back_calc=None, num_points=None): +def r2eff_ns_2site_star(r20a=None, r20b=None, fA=None, pA=None, pB=None, kex=None, k_AB=None, k_BA=None, tcpmg=None, cpmg_frqs=None, back_calc=None, num_points=None): """The 2-site numerical solution to the Bloch-McConnell equation using complex conjugate matrices. This function calculates and stores the R2eff values. @@ -51,12 +51,18 @@ @type r20a: float @keyword r20b: The R2 value for state A in the absence of exchange. @type r20b: float - @keyword fg: The frequency of the ground state. - @type fg: float - @keyword kge: The forward exchange rate from state A to state B. - @type kge: float - @keyword keg: The reverse exchange rate from state B to state A. - @type keg: float + @keyword fA: The frequency of state A. + @type fA: float + @keyword pA: The population of state A. + @type pA: float + @keyword pB: The population of state B. + @type pB: float + @keyword kex: The kex parameter value (the exchange rate in rad/s). + @type kex: float + @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 tcpmg: Total duration of the CPMG element (in seconds). @type tcpmg: float @keyword cpmg_frqs: The CPMG nu1 frequencies. @@ -70,11 +76,11 @@ # The matrix that contains only the R2 relaxation terms ("Redfield relaxation", i.e. non-exchange broadening). Rr = -1.0 * matrix([[r20b, 0.0], [0.0, r20a]]) - # The matrix that contains the exchange terms between the two states G and E. - Rex = -1.0 * matrix([[kge, -keg], [-kge, keg]]) + # The matrix that contains the exchange terms between the two states A and B. + Rex = -1.0 * matrix([[k_AB, -k_BA], [-k_AB, k_BA]]) # 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). - RCS = complex(0.0, -1.0) * matrix([[0.0, 0.0], [0.0, fg]]) + RCS = complex(0.0, -1.0) * matrix([[0.0, 0.0], [0.0, fA]]) # The matrix that contains all the contributions to the evolution, i.e. relaxation, exchange and chemical shift evolution. R = Rr + Rex + RCS @@ -82,17 +88,8 @@ # 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 = conj(R) * 2.0 - # Conversion of kinetic rates. - kex = kge + keg - - # Calculate relative populations - will be used for generating the equilibrium magnetizations. - IGeq = keg / kex - - # As the preceding line but for the excited state. - IEeq = kge / kex - - # This is a vector that contains the initial magnetizations corresponding to ground (G) and excited (E) state transverse magnetizations. - M0 = matrix([[IGeq], [IEeq]]) + # This is a vector that contains the initial magnetizations corresponding to the A and B state transverse magnetizations. + M0 = matrix([[pA], [pB]]) # Replicated calculations for faster operation. inv_tcpmg = 1.0 / tcpmg Modified: branches/relax_disp/lib/dispersion/ns_matrices.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/ns_matrices.py?rev=20295&r1=20294&r2=20295&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/ns_matrices.py (original) +++ branches/relax_disp/lib/dispersion/ns_matrices.py Mon Jul 15 10:57:48 2013 @@ -79,75 +79,75 @@ return R -def rcpmg_2d(R2E=None, R2G=None, df=None, kGE=None, kEG=None): +def rcpmg_2d(R2A=None, R2B=None, df=None, k_AB=None, k_BA=None): """Definition of the 2D exchange matrix. - @keyword R2E: The transverse, spin-spin relaxation rate for state A. - @type R2E: float - @keyword R2G: The transverse, spin-spin relaxation rate for state B. - @type R2G: float + @keyword R2A: The transverse, spin-spin relaxation rate for state A. + @type R2A: float + @keyword R2B: The transverse, spin-spin relaxation rate for state B. + @type R2B: float @keyword df: FIXME - add description. @type df: float - @keyword kGE: The forward exchange rate from state A to state B. - @type kGE: float - @keyword kEG: The reverse exchange rate from state B to state A. - @type kEG: float + @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 @return: The relaxation matrix. @rtype: numpy rank-2, 4D array """ # Parameter conversions. - fG = 0 - fE = fG + df + fA = 0 + fB = fA + df # Create the matrix. temp = matrix([ - [-R2G-kGE, -fG, kEG, 0.0], - [ fG, -R2G-kGE, 0.0, kEG], - [ kGE, 0.0, -R2E-kEG, -fE], - [ 0.0, kGE, fE, -R2E-kEG] + [ -R2A-k_AB, -fA, k_BA, 0.0], + [ fA, -R2A-k_AB, 0.0, k_BA], + [ k_AB, 0.0, -R2B-k_BA, -fB], + [ 0.0, k_AB, fB, -R2B-k_BA] ]) # Return the matrix. return temp -def rcpmg_3d(R1E=None, R1G=None, R2E=None, R2G=None, df=None, kGE=None, kEG=None): +def rcpmg_3d(R1A=None, R1B=None, R2A=None, R2B=None, df=None, k_AB=None, k_BA=None): """Definition of the 3D exchange matrix. - @keyword R1E: The longitudinal, spin-lattice relaxation rate for state A. - @type R1E: float - @keyword R1G: The longitudinal, spin-lattice relaxation rate for state B. - @type R1G: float - @keyword R2E: The transverse, spin-spin relaxation rate for state A. - @type R2E: float - @keyword R2G: The transverse, spin-spin relaxation rate for state B. - @type R2G: float + @keyword R1A: The longitudinal, spin-lattice relaxation rate for state A. + @type R1A: float + @keyword R1B: The longitudinal, spin-lattice relaxation rate for state B. + @type R1B: float + @keyword R2A: The transverse, spin-spin relaxation rate for state A. + @type R2A: float + @keyword R2B: The transverse, spin-spin relaxation rate for state B. + @type R2B: float @keyword df: FIXME - add description. @type df: float - @keyword kGE: The forward exchange rate from state A to state B. - @type kGE: float - @keyword kEG: The reverse exchange rate from state B to state A. - @type kEG: float + @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 @return: The relaxation matrix. @rtype: numpy rank-2, 7D array """ # Parameter conversions. - fG = 0.0 - fE = df - IGeq = kEG / (kEG + kGE) - IEeq = kGE / (kEG + kGE) + fA = 0.0 + fB = df + pA = k_BA / (k_BA + k_AB) + pB = k_AB / (k_BA + k_AB) # Create the matrix. temp = matrix([ - [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], - [ 0.0, -R2G-kGE, -fG, 0.0, kEG, 0.0, 0.0], - [ 0.0, fG, -R2G-kGE, 0.0, 0.0, kEG, 0.0], - [2.0*R1G*IGeq, 0.0, 0.0, -R1G-kGE, 0.0, 0.0, kEG], - [ 0.0, kGE, 0.0, 0.0, -R2E-kEG, -fE, 0.0], - [ 0.0, 0.0, kGE, 0.0, fE, -R2E-kEG, 0.0], - [2.0*R1E*IEeq, 0.0, 0.0, kGE, 0.0, 0.0, -R1E-kEG] + [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], + [ 0.0, -R2A-k_AB, -fA, 0.0, k_BA, 0.0, 0.0], + [ 0.0, fA, -R2A-k_AB, 0.0, 0.0, k_BA, 0.0], + [ 2.0*R1A*pA, 0.0, 0.0, -R1A-k_AB, 0.0, 0.0, k_BA], + [ 0.0, k_AB, 0.0, 0.0, -R2B-k_BA, -fB, 0.0], + [ 0.0, 0.0, k_AB, 0.0, fB, -R2B-k_BA, 0.0], + [ 2.0*R1B*pB, 0.0, 0.0, k_AB, 0.0, 0.0, -R1B-k_BA] ]) # Return the matrix. 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=20295&r1=20294&r2=20295&view=diff ============================================================================== --- branches/relax_disp/target_functions/relax_disp.py (original) +++ branches/relax_disp/target_functions/relax_disp.py Mon Jul 15 10:57:48 2013 @@ -497,8 +497,8 @@ # Once off parameter conversions. pB = 1.0 - pA - kge = pA * kex - keg = pB * kex + k_AB = pA * kex + k_BA = pB * kex # Initialise. chi2_sum = 0.0 @@ -514,15 +514,15 @@ dw_frq = dw[spin_index] * self.frqs[spin_index, frq_index] # Back calculate the R2eff values. - r2eff_ns_2site_star(r20a=R20A[r20_index], r20b=R20B[r20_index], pA=pA, kge=kge, keg=keg, cpmg_frqs=self.cpmg_frqs, 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 + r2eff_ns_2site_star(r20a=R20A[r20_index], r20b=R20B[r20_index], pA=pA, pB=pB, kex=kex, k_AB=k_AB, k_BA=k_BA, cpmg_frqs=self.cpmg_frqs, 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