help with writing a nebspline script in matlab
Posted: Mon Sep 27, 2010 1:01 am
I was trying to write a nebspline script in matlab (which is supposed to be a computer lab exercise in a chemistry class) but there seems to be something wrong. The spline is not continuos and takes very high and low values (on the order of 10 eV when the barrier is 0.5 eV and the forces are low). Something is wrong here. I both tried to do the cubic coefficients like in your papers and also as in the nebspline.pl script. However, I do not think those two formulas are the same though, and the results are quite different. Anyway, I have tried to make this work, but have not spot the error. Any help, asap, would be great so that I can finish this exercise for the students tomorrow...
here is the matlab code where I am trying to do it just like in the papers introducing this
G. Henkelman, G. Jóhannesson, and H. Jónsson, `Methods for Finding Saddle Points and Minimum Energy Paths', Progress on Theoretical Chemistry and Physics, ed. S. D. Schwartz (Kluwar Academic Publishers, 2000)
G. Henkelman and H. Jónsson, `Improved Tangent Estimate in the NEB Method for Finding Minimum Energy Paths and Saddle Points', J. Chem. Phys. Vol. 113, p. 9978 (2000):
clear all
close all
R = [0 0.9 1.9 2.5 3.8]; % the coordinates in Angstrom
E = [0 0.2 0.5 0.2 0]; % the energy of each image
%x = 0:0.1:10;
%f = spline(R,E,x);
F = [0 0.2 0.0 0.2 0]; % the parallel forces on each image
%F = zeros(size(R));
for i=1:length(R)-1
dR = R(i+1)-R(i);
F1 = F(i);
F2 = F(i+1);
U1 = E(i);
U2 = E(i+1);
d = U1;
c = -F1;
b = (3*U2 - U1)/dR^2 + (2*F1 + F2)/dR;
a = (2*U2 - U1)/dR^3 - (F1 + F2)/dR^2;
r = [R(i):0.1:R(i+1)];
e = a*r.^3 + b*r.^2 + c*r + d;
plot(r,e)
hold on
end
and here is the code when I am trying to mimic the perl script:
clear all
close all
R = [0 0.9 1.9 2.5 3.8]; % the coordinates in Angstrom
E = [0 0.2 0.5 0.2 0]; % the energy of each image
%x = 0:0.1:10;
%f = spline(R,E,x);
F = [0 0.2 0.0 0.2 0]; % the parallel forces on each image
%F = zeros(size(R));
for i=1:length(R)-1
dR = R(i+1)-R(i);
F1 = F(i)*dR;
F2 = F(i+1)*dR;
U1 = E(i);
U2 = E(i+1);
Fs = F1 + F2;
Ud = U2 - U1;
d = U1;
c = -F1;
b = 3*Ud + F1 + Fs;
a = -2*Ud - Fs;
r = [R(i):0.1:R(i+1)];
e = a*r.^3 + b*r.^2 + c*r + d;
plot(r,e,'r')
hold on
end
Best regards
egillsk
here is the matlab code where I am trying to do it just like in the papers introducing this
G. Henkelman, G. Jóhannesson, and H. Jónsson, `Methods for Finding Saddle Points and Minimum Energy Paths', Progress on Theoretical Chemistry and Physics, ed. S. D. Schwartz (Kluwar Academic Publishers, 2000)
G. Henkelman and H. Jónsson, `Improved Tangent Estimate in the NEB Method for Finding Minimum Energy Paths and Saddle Points', J. Chem. Phys. Vol. 113, p. 9978 (2000):
clear all
close all
R = [0 0.9 1.9 2.5 3.8]; % the coordinates in Angstrom
E = [0 0.2 0.5 0.2 0]; % the energy of each image
%x = 0:0.1:10;
%f = spline(R,E,x);
F = [0 0.2 0.0 0.2 0]; % the parallel forces on each image
%F = zeros(size(R));
for i=1:length(R)-1
dR = R(i+1)-R(i);
F1 = F(i);
F2 = F(i+1);
U1 = E(i);
U2 = E(i+1);
d = U1;
c = -F1;
b = (3*U2 - U1)/dR^2 + (2*F1 + F2)/dR;
a = (2*U2 - U1)/dR^3 - (F1 + F2)/dR^2;
r = [R(i):0.1:R(i+1)];
e = a*r.^3 + b*r.^2 + c*r + d;
plot(r,e)
hold on
end
and here is the code when I am trying to mimic the perl script:
clear all
close all
R = [0 0.9 1.9 2.5 3.8]; % the coordinates in Angstrom
E = [0 0.2 0.5 0.2 0]; % the energy of each image
%x = 0:0.1:10;
%f = spline(R,E,x);
F = [0 0.2 0.0 0.2 0]; % the parallel forces on each image
%F = zeros(size(R));
for i=1:length(R)-1
dR = R(i+1)-R(i);
F1 = F(i)*dR;
F2 = F(i+1)*dR;
U1 = E(i);
U2 = E(i+1);
Fs = F1 + F2;
Ud = U2 - U1;
d = U1;
c = -F1;
b = 3*Ud + F1 + Fs;
a = -2*Ud - Fs;
r = [R(i):0.1:R(i+1)];
e = a*r.^3 + b*r.^2 + c*r + d;
plot(r,e,'r')
hold on
end
Best regards
egillsk