Author: tlinnet Date: Wed Jun 18 19:01:24 2014 New Revision: 24121 URL: http://svn.gna.org/viewcvs/relax?rev=24121&view=rev Log: Moved the parameter conversion for r1rho 3site into lib function. Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion models for Clustered analysis. Modified: branches/disp_spin_speed/lib/dispersion/ns_r1rho_3site.py branches/disp_spin_speed/target_functions/relax_disp.py Modified: branches/disp_spin_speed/lib/dispersion/ns_r1rho_3site.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/lib/dispersion/ns_r1rho_3site.py?rev=24121&r1=24120&r2=24121&view=diff ============================================================================== --- branches/disp_spin_speed/lib/dispersion/ns_r1rho_3site.py (original) +++ branches/disp_spin_speed/lib/dispersion/ns_r1rho_3site.py Wed Jun 18 19:01:24 2014 @@ -65,7 +65,7 @@ from lib.linear_algebra.matrix_exponential import matrix_exponential -def ns_r1rho_3site(M0=None, matrix=None, r1rho_prime=None, omega=None, offset=None, r1=0.0, pA=None, pB=None, pC=None, dw_AB=None, dw_AC=None, k_AB=None, k_BA=None, k_BC=None, k_CB=None, k_AC=None, k_CA=None, spin_lock_fields=None, relax_time=None, inv_relax_time=None, back_calc=None, num_points=None): +def ns_r1rho_3site(M0=None, matrix=None, r1rho_prime=None, omega=None, offset=None, r1=0.0, pA=None, pB=None, dw_AB=None, dw_AC=None, kex_AB=None, kex_BC=None, kex_AC=None, spin_lock_fields=None, relax_time=None, inv_relax_time=None, back_calc=None, num_points=None): """The 3-site numerical solution to the Bloch-McConnell equation for R1rho data. This function calculates and stores the R1rho values. @@ -87,24 +87,16 @@ @type pA: float @keyword pB: The population of state B. @type pB: float - @keyword pC: The population of state C. - @type pC: float @keyword dw_AB: The chemical exchange difference between states A and B in rad/s. @type dw_AB: numpy float array of rank [NS][NM][NO][ND] @keyword dw_AC: The chemical exchange difference between states A and C in rad/s. @type dw_AC: numpy float array of rank [NS][NM][NO][ND] - @keyword k_AB: The rate of exchange from site A to B (rad/s). - @type k_AB: float - @keyword k_BA: The rate of exchange from site B to A (rad/s). - @type k_BA: float - @keyword k_BC: The rate of exchange from site B to C (rad/s). - @type k_BC: float - @keyword k_CB: The rate of exchange from site C to B (rad/s). - @type k_CB: float - @keyword k_AC: The rate of exchange from site A to C (rad/s). - @type k_AC: float - @keyword k_CA: The rate of exchange from site C to A (rad/s). - @type k_CA: float + @keyword kex_AB: The exchange rate between sites A and B for 3-site exchange with kex_AB = k_AB + k_BA (rad.s^-1) + @type kex_AB: float + @keyword kex_BC: The exchange rate between sites A and C for 3-site exchange with kex_AC = k_AC + k_CA (rad.s^-1) + @type kex_BC: float + @keyword kex_AC: The exchange rate between sites B and C for 3-site exchange with kex_BC = k_BC + k_CB (rad.s^-1) + @type kex_AC: float @keyword spin_lock_fields: The R1rho spin-lock field strengths (in rad.s^-1). @type spin_lock_fields: numpy float array of rank [NS][NM][NO][ND] @keyword relax_time: The total relaxation time period for each spin-lock field strength (in seconds). @@ -116,6 +108,18 @@ @keyword num_points: The number of points on the dispersion curve, equal to the length of the tcp and back_calc arguments. @type num_points: numpy int array of rank [NS][NM][NO] """ + + # Once off parameter conversions. + pC = 1.0 - pA - pB + pA_pB = pA + pB + pA_pC = pA + pC + pB_pC = pB + pC + k_BA = pA * kex_AB / pA_pB + k_AB = pB * kex_AB / pA_pB + k_CB = pB * kex_BC / pB_pC + k_BC = pC * kex_BC / pB_pC + k_CA = pA * kex_AC / pA_pC + k_AC = pC * kex_AC / pA_pC # Extract shape of experiment. NE, NS, NM, NO = num_points.shape Modified: branches/disp_spin_speed/target_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/target_functions/relax_disp.py?rev=24121&r1=24120&r2=24121&view=diff ============================================================================== --- branches/disp_spin_speed/target_functions/relax_disp.py (original) +++ branches/disp_spin_speed/target_functions/relax_disp.py Wed Jun 18 19:01:24 2014 @@ -765,16 +765,6 @@ """ # Once off parameter conversions. - pC = 1.0 - pA - pB - pA_pB = pA + pB - pA_pC = pA + pC - pB_pC = pB + pC - k_BA = pA * kex_AB / pA_pB - k_AB = pB * kex_AB / pA_pB - k_CB = pB * kex_BC / pB_pC - k_BC = pC * kex_BC / pB_pC - k_CA = pA * kex_AC / pA_pC - k_AC = pC * kex_AC / pA_pC dw_AC = dw_AB + dw_BC # Convert dw from ppm to rad/s. Use the out argument, to pass directly to structure. @@ -785,7 +775,7 @@ self.r20_struct[:] = multiply.outer( r1rho_prime.reshape(self.NE, self.NS, self.NM), self.no_nd_ones ) # Back calculate the R2eff values for each experiment type. - ns_r1rho_3site(M0=self.M0, matrix=self.matrix, r1rho_prime=self.r20_struct, omega=self.chemical_shifts, offset=self.offset, r1=self.r1, pA=pA, pB=pB, pC=pC, dw_AB=self.dw_AB_struct, dw_AC=self.dw_AC_struct, k_AB=k_AB, k_BA=k_BA, k_BC=k_BC, k_CB=k_CB, k_AC=k_AC, k_CA=k_CA, spin_lock_fields=self.spin_lock_omega1, relax_time=self.relax_times, inv_relax_time=self.inv_relax_times, back_calc=self.back_calc, num_points=self.num_disp_points) + ns_r1rho_3site(M0=self.M0, matrix=self.matrix, r1rho_prime=self.r20_struct, omega=self.chemical_shifts, offset=self.offset, r1=self.r1, pA=pA, pB=pB, dw_AB=self.dw_AB_struct, dw_AC=self.dw_AC_struct, kex_AB=kex_AB, kex_BC=kex_BC, kex_AC=kex_AC, spin_lock_fields=self.spin_lock_omega1, relax_time=self.relax_times, inv_relax_time=self.inv_relax_times, back_calc=self.back_calc, num_points=self.num_disp_points) # Clean the data for all values, which is left over at the end of arrays. self.back_calc = self.back_calc*self.disp_struct