Obtaning values and plotting Lennard-Jones function
古いコメントを表示
I need to evaluate the below function which is the Lennard-Jones function defining the van der Waals forces between atoms. The function and the plot it must give are attached. Sigma and epsilon are constants in the function. I tried to write the code for it in couple of different forms and also tried to do it in MS Excel but all of those gave a curve that resembles a saturation curve. Any help would be very appreciated.
3 件のコメント
Star Strider
2015 年 4 月 19 日
Show the code you wrote. We don’t know the values of the constants or the reason your code failed.
Ugur Batir
2015 年 4 月 19 日
John D'Errico
2015 年 4 月 19 日
In fact, your plot is identical to what I produced. What you apparently don't understand is what happens for small r. The plot axes explode. So you never see the essential shape of the curve, since you went all the way down to r=1.
Try this instead:
r=3.4:0.01:10;
採用された回答
その他の回答 (4 件)
Star Strider
2015 年 4 月 19 日
I believe the information you were provided is incorrect. The equation for F actually appears to be the Lennard-Jones equation, not the van der Waals equation. Since F appears to be the integral of U w.r.t. r, and now having ‘sigma’ (I still need ‘epsilon’), this would be my approach:
U = @(e,s,r) 4*e*((s./r).^12 - (s./r).^6); % Lennard-Jones
e = 1.0; % epsilon (GUESS)
s = 3.4; % sigma
r = linspace(0.75, 2.5)*s;
U_LJ = U(e,s,r);
F_vdW = cumtrapz(U_LJ, r); % van der Waals
figure(1)
plot(r/s, U_LJ/e, '--k')
hold on
plot(r/s, (F_vdW-F_vdW(end))*s/e, '-k')
hold off
grid
axis([0.75 3 -20 4.5])
legend('Lennard-Jones \itU/\epsilon\rm', 'van der Waals \itF\sigma/\epsilon')
Subtracting the last value of ‘F_vdW’ corrects for the constant-of-integration. This produces a plot that does not exactly match the sort you posted, but is reasonably close. You will have to experiment with your equations and constants to get the correct result:

4 件のコメント
Star Strider
2015 年 4 月 19 日
I don’t have a problem approximating the curves with this code (a slight variation on my previous code), but I have the feeling that some information is missing somewhere. (It wouldn’t be the first time a paper omitted information that was important to reproducing their results.) I had to fudge the plot a bit (note the negative derivative), but I got a decent approximation to the plots you posted:
U = @(e,s,r) 24*(e/s)*(2*(s./r).^13 - (s./r).^7); % Lennard-Jones
e = 0.0556; % epsilon (GUESS)
s = 3.4; % sigma
r = linspace(0.75, 2.5)*s;
U_LJ = U(e,s,r); % L-J Evaluated
F_vdW = gradient(U_LJ, r(2)-r(1)); % van der Waals
figure(1)
plot(r/s, U_LJ/e, '--k')
hold on
plot(r/s, -F_vdW*s/e, '-k')
hold off
grid
axis([0.75 3 -3 5])
legend('Lennard-Jones \itU/\epsilon\rm', 'van der Waals \itF\sigma/\epsilon')
The new plot:

Rob Qualls
2016 年 2 月 27 日
編集済み: Rob Qualls
2016 年 2 月 27 日
Thanks for posting this. Ran into a similar issue on some data crunching for a physics class, this helped a lot.
Star Strider
2016 年 2 月 27 日
My pleasure.
I am happy it helped. I would appreciate it if you would Vote for it.
NURSAFIKA BAHIRA JULI
2020 年 1 月 21 日
Hye, can i run monte carlo Simulation for LJ's model?? And how?
LATEFA ALSHAMMARY
2018 年 11 月 9 日
0 投票
U = @(e,s,r) 24*(e/s)*(2*(s./r).^13 - (s./r).^7); % Lennard-Jones e = 0.0556; % epsilon (GUESS) s = 3.4; % sigma r = linspace(0.75, 2.5)*s; U_LJ = U(e,s,r); % L-J Evaluated F_vdW = gradient(U_LJ, r(2)-r(1)); % van der Waals figure(1) plot(r/s, U_LJ/e, '--k') hold on plot(r/s, -F_vdW*s/e, '-k') hold off grid axis([0.75 3 -3 5]) legend('Lennard-Jones \itU/\epsilon\rm', 'van der Waals \itF\sigma/\epsilon')
algeed alshammari
2018 年 11 月 11 日
0 投票
I need code in matlab TO PLOTE Lennard-Jones PLESE
カテゴリ
ヘルプ センター および File Exchange で Gravitation, Cosmology & Astrophysics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

