mailRe: r23316 - /trunk/lib/dispersion/b14.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on May 22, 2014 - 09:53:
I can also see that the calculation "0.5 * arctan2(-zeta, Psi)" is
happening twice, so you could speed this up by eliminating the
repetition.

Regards,

Edward

On 22 May 2014 09:50, Edward d'Auvergne <edward@xxxxxxxxxxxxx> wrote:
Hi Troels,

For reference, do you have the B14 optimisation results for this
parameter set prior to the fix?  This is just to see the difference
the change makes.

Cheers,

Edward



On 21 May 2014 20:36,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Wed May 21 20:36:36 2014
New Revision: 23316

URL: http://svn.gna.org/viewcvs/relax?rev=23316&view=rev
Log:
Extremely important fix to the model B14.

This was discovered by author Andrew Baldwin of the inspection of his code 
in relax.

bug #22021: (https://gna.org/bugs/?22021) Model B14 shows bad fitting to 
data.

The implementation was performed wrong for calculation of g3 and g4.
The implementations should be performed by trigonometric functions.

The model B14 was previously in a state of non-functioning.

The B14 model now shows excellent performance.

For the challenging case of data created with numerical model NS CPMG 
2-site 3D:

sfrq_1 = 599.8908617*1E6
time_T2_1 = 0.06
ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
sfrq_2 = 499.8908617*1E6
time_T2_2 = 0.05
ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]

r2 = 10. rad/s.
kex: 1000 rad/s
pA: 0.99
dw: 2. ppm

CR72 would fit:
----------
CR72 Ala :1@N r2 599.9 GRID=10.116 MIN=10.000 SET=10.000 RELC=0.000
CR72 Ala :1@N r2 499.9 GRID=10.080 MIN=9.999 SET=10.000 RELC=0.000
CR72 Ala :1@N pA GRID=0.929 MIN=0.990 SET=0.990 RELC=0.000
CR72 Ala :1@N dw GRID=1.429 MIN=1.925 SET=2.000 RELC=0.039
CR72 Ala :1@N kex GRID=5714.714 MIN=1034.721 SET=1000.000 RELC=0.034

B14 fits:
-----------
B14 Ala :1@N r2 599.9 GRID=10.116 MIN=10.000 SET=10.000 RELC=0.000
B14 Ala :1@N r2 499.9 GRID=10.080 MIN=10.000 SET=10.000 RELC=0.000
B14 Ala :1@N pA GRID=0.929 MIN=0.990 SET=0.990 RELC=0.000
B14 Ala :1@N dw GRID=1.429 MIN=2.000 SET=2.000 RELC=0.000
B14 Ala :1@N kex GRID=10000.000 MIN=1000.001 SET=1000.000 RELC=0.000

Modified:
    trunk/lib/dispersion/b14.py

Modified: trunk/lib/dispersion/b14.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/dispersion/b14.py?rev=23316&r1=23315&r2=23316&view=diff
==============================================================================
--- trunk/lib/dispersion/b14.py (original)
+++ trunk/lib/dispersion/b14.py Wed May 21 20:36:36 2014
@@ -111,7 +111,7 @@

 # Python module imports.
 import numpy
-from numpy import arccosh, array, cos, cosh, in1d, log, nonzero, sin, 
sinh, sqrt, power
+from numpy import arccosh, arctan2, array, cos, cosh, in1d, log, nonzero, 
sin, sinh, sqrt, power

 # Repetitive calculations (to speed up calculations).
 g_fact = 1/sqrt(2)
@@ -161,11 +161,12 @@
     # Repetitive calculations (to speed up calculations).
     dw2 = dw**2
     two_tcp = 2.0 * tcp
-    sqrt_zeta2_Psi2 = sqrt(zeta**2 + Psi**2)

     # Get the real and imaginary components of the exchange induced shift.
-    g3 = g_fact * sqrt( Psi + sqrt_zeta2_Psi2)
-    g4 = g_fact * sqrt(-Psi + sqrt_zeta2_Psi2)
+    # Trigonometric functions faster than square roots.
+    quad_zeta2_Psi2 = (zeta**2 + Psi**2)**0.25
+    g3 = cos(0.5 * arctan2(-zeta, Psi)) * quad_zeta2_Psi2
+    g4 = sin(0.5 * arctan2(-zeta, Psi)) * quad_zeta2_Psi2

     # Repetitive calculations (to speed up calculations).
     g32 = g3**2


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Thu May 22 10:40:13 2014