Author: bugman
Date: Fri Jun  3 11:03:54 2016
New Revision: 28224

URL: http://svn.gna.org/viewcvs/relax?rev=28224&view=rev
Log:
Bug fix for the inversion recovery equations (sr #3345).

The inversion recovery experiment was incorrectly implemented as I(t) = Iinf - 
I0 * exp(-R1 * t)
whereas it should be I(t) = Iinf - (Iinf - I0) * exp(-R1 * t).

Modified:
    trunk/target_functions/exponential_inv.c

Modified: trunk/target_functions/exponential_inv.c
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/exponential_inv.c?rev=28224&r1=28223&r2=28224&view=diff
==============================================================================
--- trunk/target_functions/exponential_inv.c    (original)
+++ trunk/target_functions/exponential_inv.c    Fri Jun  3 11:03:54 2016
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2014 Edward d'Auvergne
+ * Copyright (C) 2006-2016 Edward d'Auvergne
  *
  * This file is part of the program relax (http://www.nmr-relax.com).
  *
@@ -30,21 +30,21 @@
      *
      * The function used is::
      *
-     *     I = Iinf - I0 * exp(-R.t)
-    */
-
-    /* Declarations. */
-    int i;
-
-    /* Loop over the time points. */
-    for (i = 0; i < num_times; i++) {
-        /* Zero Rx value. */
-        if (R == 0.0)
-            back_calc[i] = Iinf - I0;
+     *     I = Iinf - (Iinf - I0) * exp(-R.t)
+    */
+
+    /* Declarations. */
+    int i;
+
+    /* Loop over the time points. */
+    for (i = 0; i < num_times; i++) {
+        /* Zero Rx value. */
+        if (R == 0.0)
+            back_calc[i] = I0;
 
         /* Back calculate. */
         else
-            back_calc[i] = Iinf - I0 * exp(-relax_times[i] * R);
+            back_calc[i] = Iinf - (Iinf - I0) * exp(-relax_times[i] * R);
 
     }
 }
@@ -61,11 +61,11 @@
     for (i = 0; i < num_times; i++) {
         /* Zero Rx value. */
         if (R == 0.0)
-            back_calc_grad[param_index][i] = -1.0;
-
-        /* The partial derivate. */
-        else
-            back_calc_grad[param_index][i] = -exp(-relax_times[i] * R);
+            back_calc_grad[param_index][i] = 1.0;
+
+        /* The partial derivate. */
+        else
+            back_calc_grad[param_index][i] = exp(-relax_times[i] * R);
     }
 }
 
@@ -79,7 +79,13 @@
 
     /* Everything is one. */
     for (i = 0; i < num_times; i++) {
-        back_calc_grad[param_index][i] = 1.0;
+        /* Zero Rx value. */
+        if (R == 0.0)
+            back_calc_grad[param_index][i] = 0.0;
+
+        /* The partial derivate. */
+        else
+            back_calc_grad[param_index][i] = 1.0 - exp(-relax_times[i] * R);
     }
 }
 
@@ -95,11 +101,11 @@
     for (i = 0; i < num_times; i++) {
         /* Zero Rx value. */
         if (R == 0.0)
-            back_calc_grad[param_index][i] = I0 * relax_times[i];
-
-        /* The partial derivate. */
-        else
-            back_calc_grad[param_index][i] = I0 * relax_times[i] * 
exp(-relax_times[i] * R);
+            back_calc_grad[param_index][i] = (Iinf - I0) * relax_times[i];
+
+        /* The partial derivate. */
+        else
+            back_calc_grad[param_index][i] = (Iinf - I0) * relax_times[i] * 
exp(-relax_times[i] * R);
     }
 }
 
@@ -158,11 +164,11 @@
     for (i = 0; i < num_times; i++) {
         /* Zero Rx value. */
         if (R == 0.0)
-            back_calc_hess[I0_index][R_index][i] = relax_times[i];
+            back_calc_hess[I0_index][R_index][i] = -relax_times[i];
 
         /* The second partial derivate. */
         else
-            back_calc_hess[I0_index][R_index][i] = relax_times[i] * 
exp(-relax_times[i] * R);
+            back_calc_hess[I0_index][R_index][i] = -relax_times[i] * 
exp(-relax_times[i] * R);
 
         /* Hessian symmetry. */
         back_calc_hess[R_index][I0_index][i] = 
back_calc_hess[I0_index][R_index][i];
@@ -177,10 +183,18 @@
     /* Declarations. */
     int i;
 
-    /* Everything is zero. */
-    for (i = 0; i < num_times; i++) {
-        back_calc_hess[R_index][Iinf_index][i] = 0.0;
-        back_calc_hess[Iinf_index][R_index][i] = 0.0;
+    /* Loop over the time points. */
+    for (i = 0; i < num_times; i++) {
+        /* Zero Rx value. */
+        if (R == 0.0)
+            back_calc_hess[Iinf_index][R_index][i] = relax_times[i];
+
+        /* The second partial derivate. */
+        else
+            back_calc_hess[Iinf_index][R_index][i] = relax_times[i] * 
exp(-relax_times[i] * R);
+
+        /* Hessian symmetry. */
+        back_calc_hess[R_index][Iinf_index][i] = 
back_calc_hess[Iinf_index][R_index][i];
     }
 }
 
@@ -196,10 +210,10 @@
     for (i = 0; i < num_times; i++) {
         /* Zero Rx value. */
         if (R == 0.0)
-            back_calc_hess[R_index][R_index][i] = -I0 * square(relax_times[i]);
-
-        /* The partial derivate. */
-        else
-            back_calc_hess[R_index][R_index][i] = -I0 * square(relax_times[i]) 
* exp(-relax_times[i] * R);
-    }
-}
+            back_calc_hess[R_index][R_index][i] = -(Iinf - I0) * 
square(relax_times[i]);
+
+        /* The partial derivate. */
+        else
+            back_calc_hess[R_index][R_index][i] = -(Iinf - I0) * 
square(relax_times[i]) * exp(-relax_times[i] * R);
+    }
+}


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

This is the relax-commits mailing list
relax-commits@gna.org

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

Reply via email to