2
$\begingroup$

If I have the followind data:

data={{45, 2.93495}, {50, 2.94697}, {55, 1.9801}, {60,0.734437}, {65, -0.0128219}, {70, -0.695535}, {75,-1.35939}, {80,-1.47567}}

where the x values are Temperature in Celsius (T) and the y values are log10 of time (t).

Question:

  1. How can I fit the following equation to the data and find the fitting parameters K1 and K2?

enter image description here

where log (tind) is the log in base 10 of time (y axis of my data), T is the x axis of my data and T0=259.246 (*Kelvin*), B=2595.89, Tm=433.15 (*Kelvin*)

I have been trying the following but it does not work:

T0=259.246 (*Kelvin*); 
B=2595.89; 
Tm=433.15 (*Kelvin*);
    eq = k1 - 2*Log10[T] + (k2/(2.303*T^3*(Tm - T)^2)) + 0.75*(B/(2.303*(T - T0))) (*T would be the x axis of my data*)
    nlmtind = NonlinearModelFit[data, eq, {k1, k2}, x]

Notice that the x axis should be converted to kelvin (+273.15) for consistency of units

$\endgroup$
2
  • $\begingroup$ In your code Tm,T0,B are not specified and x in the fit is T, I presume. This works: nlmtind = NonlinearModelFit[data, eq, {k1, k2, Tm, T0, B}, T] $\endgroup$
    – Andrzej
    May 19, 2021 at 20:16
  • $\begingroup$ @Andrzej thanks for your comment. Tm, T0 and B are numbers shown above. I put this numbers in the code to make it more specific. Unfortunately, your suggestions is not working. $\endgroup$
    – John
    May 19, 2021 at 20:19

1 Answer 1

3
$\begingroup$

Try this:

data = {{45, 2.93495}, {50, 2.94697}, {55, 1.9801}, {60, 
    0.734437}, {65, -0.0128219}, {70, -0.695535}, {75, -1.35939}, \
{80, -1.47567}};
y = k1 - 2 Log[x, 10] + k2/2.303/(x^3 (Tm - x)^2) + 
    0.75 B/2.303/(x - T0) /. {T0 -> 259.246, B -> 2595.89, 
    Tm -> 433.15};

fun[x_] = NonlinearModelFit[data, y, {k1, k2}, x] // Normal;

Plot[fun[x], {x, 45, 80}, Epilog -> Point[data]]

enter image description here

Addendum

If you want to force the k1 and k2 to be positive, the fit will be horrible:

t = NonlinearModelFit[data, {y, k1 > 0, k2 > 0}, {k1, k2}, x];
t["BestFitParameters"]

(* {k1 -> 11.496, k2 -> 1874.25} *)  

k1 and k2 are now positive, but the fit is bad:

fun[x_] = t // Normal
Plot[fun[x], {x, 45, 80}, Epilog -> Point[data], PlotRange -> {-1, 7}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you Daniel! One quick question: How can I make k1 and k2 be greater than 0? I am trying this from your code: NonlinearModelFit[data, y, {{k1>0}, {k2>0}}, x] but it does not seem to force those fitting parameters to be greater than 0 $\endgroup$
    – John
    May 19, 2021 at 21:06
  • 1
    $\begingroup$ Try fun[x_] = NonlinearModelFit[data, {y, k1 > 0, k2 > 0}, {k1, k2}, x] $\endgroup$ May 20, 2021 at 0:52
  • 1
    $\begingroup$ I made an addendum to my answer. To request the parameters to be positive gives an unusable fit. $\endgroup$ May 20, 2021 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.