I am trying to fit data to a Morse potential using NonlinearModelFit
as follows:
morse[r_] := d (1 - Exp[a (re - r)])^2;
nlm1 = NonlinearModelFit[data1,
d (1 - Exp[a (re - r)])^2, {d, {a, 1.5}, {re, 1.5}}, r]
However upon doing so I get the following error:
NonlinearModelFit::cvmit:
Failed to converge to the requested accuracy or precision within 100 iterations.
I have tried using different values for my constant and it's puzzling that the data does not fit. Here is the data I am using currently:
{"Internuclear Separation ()", "Potential Energy (eV)"}, {2.2678,
1.44954}, {2.274, 1.41403}, {2.2801, 1.3726}, {2.2864,
1.32543}, {2.2929, 1.27275}, {2.3, 1.2149}, {2.3077,
1.15223}, {2.3163, 1.08509}, {2.3258, 1.01378}, {2.3364,
0.938569}, {2.3482, 0.859714}, {2.3614, 0.777423}, {2.376,
0.691882}, {2.3924, 0.603253}, {2.411, 0.511677}, {2.4324,
0.417273}, {2.4577, 0.320146}, {2.4891, 0.220385}, {2.5321,
0.118071}, {2.6176, 0.0132722}, {2.7173, 0.0132722}, {2.834,
0.118071}, {2.9083, 0.220385}, {2.9715, 0.320146}, {3.0294,
0.417273}, {3.0844, 0.511677}, {3.1379, 0.603253}, {3.1909,
0.691882}, {3.2443, 0.777423}, {3.2987, 0.859714}, {3.3549,
0.938569}, {3.4136, 1.01378}, {3.4758, 1.08509}, {3.5424,
1.15223}, {3.6149, 1.2149}, {3.6949, 1.27275}, {3.7846,
1.32543}, {3.8867, 1.3726}, {4.0049, 1.41403}, {4.144, 1.44954}}
Any ideas?
D
is the built-in Mathematica function for taking a partial derivative. Bad idea to use it to name a parameter. $\endgroup$NonlinearModelFit
does not likeSubscript[r, e]
as a parameter name. Try substitutingre
and see if that doesn't help. $\endgroup$nlm = TransformedFit[data, morse[d, a, Subscript[r, e], r], {{d, 1.5}, {a, 1.5}, Subscript[r, e]}, r, "FitFunction" -> NonlinearModelFit]
and subsequentlynlm[1, x]
in the plot. Because the parameters have been renamed, the messages do not arise. But working with renamed parameters is more awkward, so it's a double-edged sword. $\endgroup$