如何在 Gnuplot 中将数据拟合到 Lennard-Jones 势

问题描述 投票:0回答:1

我正在开发一个项目,需要将数据集拟合到 Gnuplot 中的 Lennard-Jones 势,但我无法正确实现它。我的数据集由两列组成:第一列表示距离 (r),第二列表示潜在值。

以下是数据:

1   -438.10479452
1.1 -445.94323088
1.2 -452.07508054
1.3 -456.20604417
1.4 -458.81075037
1.5 -460.28321318
1.6 -460.99208193
1.7 -461.18673038   
1.8 -461.07112685
1.9 -460.79716730
2   -460.53742177
2.1 -460.24917871
2.2 -459.99323880
2.3 -459.76274023
2.4 -459.56247520
2.5 -459.37823253
2.6 -459.21828504
2.7 -459.09018076
2.8 -458.98484535
2.9 -458.89741339
3   -458.94036802
4   -458.82477397
5   -458.77588758
6   -458.75509627
7   -458.74829025
8   -458.58961604
9   -458.73566475
10  -458.73375523

我的目标是使用 Gnuplot 将这些数据拟合到 Lennard-Jones 势。但是,我很难找到最好的方法。

如何在 Gnuplot 中执行此拟合?

f(x)= (4*epsilon) * ( (sigma**12/x**12) - (sigma**6/x**6) )
fit f(x) 'data.dat' using 1:2 via sigma,epsilon
plot f(x)  lw 3 lc "blue" 

gnuplot physics chemistry
1个回答
1
投票

如果你检查你的函数,当

0
时它会通过
sigma = x
,对于大
0
则接近
x
。您无法通过数据实现此目的,因为您的 y 偏移量约为
-458
,并且可能还有一些 x 偏移量。因此,您要么需要移动数据,要么在函数中引入一些 x,y 偏移。

f(x) = 4*epsilon * ( (sigma/(x-x0))**12 - (sigma/(x-x0))**6) + y0

所以,我能得到的最好的结果如下:

数据:

SO78162265.dat

1   -438.10479452
1.1 -445.94323088
1.2 -452.07508054
1.3 -456.20604417
1.4 -458.81075037
1.5 -460.28321318
1.6 -460.99208193
1.7 -461.18673038
1.8 -461.07112685
1.9 -460.79716730
2   -460.53742177
2.1 -460.24917871
2.2 -459.99323880
2.3 -459.76274023
2.4 -459.56247520
2.5 -459.37823253
2.6 -459.21828504
2.7 -459.09018076
2.8 -458.98484535
2.9 -458.89741339
3   -458.94036802
4   -458.82477397
5   -458.77588758
6   -458.75509627
7   -458.74829025
8   -458.58961604
9   -458.73566475
10  -458.73375523

脚本:

### fitting
reset session

FILE = "SO78162265.dat"

f(x) = 4*epsilon * ( (sigma/(x-x0))**12 - (sigma/(x-x0))**6) + y0
epsilon = 1     # some starting values
sigma   = 1.4
x0      = -0.4
y0      = 459
set fit brief nolog
fit f(x) FILE u 1:2 via sigma,epsilon, x0, y0
set samples 1000

plot [1:10] FILE u 1:2 w p pt 7 lc "red", \
       f(x) lw 3 lc "blue"
### end of script

结果:

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
sigma           = 3.44155          +/- 0.133        (3.866%)
epsilon         = 2.32564          +/- 0.2699       (11.61%)
x0              = -2.04519         +/- 0.1347       (6.584%)
y0              = -458.378         +/- 0.1771       (0.03864%)

© www.soinside.com 2019 - 2024. All rights reserved.