原子距离问题.docx

上传人:b****7 文档编号:25488111 上传时间:2023-06-09 格式:DOCX 页数:25 大小:54.74KB
下载 相关 举报
原子距离问题.docx_第1页
第1页 / 共25页
原子距离问题.docx_第2页
第2页 / 共25页
原子距离问题.docx_第3页
第3页 / 共25页
原子距离问题.docx_第4页
第4页 / 共25页
原子距离问题.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

原子距离问题.docx

《原子距离问题.docx》由会员分享,可在线阅读,更多相关《原子距离问题.docx(25页珍藏版)》请在冰豆网上搜索。

原子距离问题.docx

原子距离问题

实验7无约束优化

题目5

某分子由25个原子组成,并且已经通过实验测量得到了其中某些原子对之间的距离(假设在平面结构上讨论),如表7.8所示。

请你确定每个原子的位置关系。

表7.8

原子对

距离

原子对

距离

原子对

距离

原子对

距离

(4,1)

0.9607

(5,4)

0.4758

(18,8)

0.8363

(15,13)

0.5725

(12,1)

0.4399

(12,4)

1.3402

(13,9)

0.3208

(19,13)

0.7660

(13,1)

0.8143

(24,4)

0.7006

(15,9)

0.1574

(15,14)

0.4394

(17,1)

1.3765

(8,6)

0.4945

(22,9)

1.2736

(16,14)

1.0952

(21,1)

1.2722

(13,6)

1.0559

(11,10)

0.5781

(20,16)

1.0422

(5,2)

0.5294

(19,6)

0.6810

(13,10)

0.9254

(23,16)

1.8255

(16,2)

0.6144

(25,6)

0.3587

(19,10)

0.6401

(18,17)

1.4325

(17,2)

0.3766

(8,7)

0.3351

(20,10)

0.2467

(19,17)

1.0851

(25,2)

0.6893

(14,7)

0.2878

(22,10)

0.4727

(20,19)

0.4995

(5,3)

0.9488

(16,7)

1.1346

(18,11)

1.3840

(23,19)

1.2277

(20,3)

0.8000

(20,7)

0.3870

(25,11)

0.4366

(24,19)

1.1271

(21,3)

1.1090

(21,7)

0.7511

(15,12)

1.0307

(23,21)

0.7060

(24,3)

1.1432

(14,8)

0.4439

(17,12)

1.3904

(23,22)

0.8025

【模型建立】

设第i个点所在的位置为

,因为所求的是各原子间的位置关系,可以设定第一个点坐标为

,然后再计算其他原子的位置

,使它在最大程度上满足上表中提供的数据,即让

达到最小,其中

表示第i个原子和第j个原子之间的距离,数据如上表中所示。

问题转化为无约束优化:

【算法设计】

上面是一个无约束优化问题,要求

可以归结到无约束规划模型minf(x),令X=[0,X2,X3,X4,……,x25,0,y2,y3,……,y25],调用基本命令fminunc来做,也可以令

调用lsqnonlin命令来做。

【程序】

方法一用lsqnonlin命令实现

functionf=distance(x,d)

f

(1)=(x(1,3))^2+(x(2,3))^2-d

(1)^2;%对应条件第4个和第1个原子间距

f

(2)=(x(1,11))^2+(x(2,11))^2-d

(2)^2;

f(3)=(x(1,12))^2+(x(2,12))^2-d(3)^2;

f(4)=(x(1,16))^2+(x(2,16))^2-d(4)^2;

f(5)=(x(1,20))^2+(x(2,20))^2-d(5)^2;

f(6)=(x(1,4)-x(1,1))^2+(x(2,4)-x(2,1))^2-d(6)^2;

f(7)=(x(1,15)-x(1,1))^2+(x(2,15)-x(2,1))^2-d(7)^2;

f(8)=(x(1,16)-x(1,1))^2+(x(2,16)-x(2,1))^2-d(8)^2;

f(9)=(x(1,24)-x(1,1))^2+(x(2,24)-x(2,1))^2-d(9)^2;

f(10)=(x(1,4)-x(1,2))^2+(x(2,4)-x(2,2))^2-d(10)^2;

f(11)=(x(1,19)-x(1,2))^2+(x(2,19)-x(2,2))^2-d(11)^2;

f(12)=(x(1,20)-x(1,2))^2+(x(2,20)-x(2,2))^2-d(12)^2;

f(13)=(x(1,23)-x(1,2))^2+(x(2,23)-x(2,2))^2-d(13)^2;

f(14)=(x(1,4)-x(1,3))^2+(x(2,4)-x(2,3))^2-d(14)^2;

f(15)=(x(1,11)-x(1,3))^2+(x(2,11)-x(2,3))^2-d(15)^2;

f(16)=(x(1,23)-x(1,3))^2+(x(2,23)-x(2,3))^2-d(16)^2;

f(17)=(x(1,7)-x(1,5))^2+(x(2,7)-x(2,5))^2-d(17)^2;

f(18)=(x(1,12)-x(1,5))^2+(x(2,12)-x(2,5))^2-d(18)^2;

f(19)=(x(1,18)-x(1,5))^2+(x(2,18)-x(2,5))^2-d(19)^2;

f(20)=(x(1,24)-x(1,5))^2+(x(2,24)-x(2,5))^2-d(20)^2;

f(21)=(x(1,7)-x(1,6))^2+(x(2,7)-x(2,6))^2-d(21)^2;

f(22)=(x(1,13)-x(1,6))^2+(x(2,13)-x(2,6))^2-d(22)^2;

f(23)=(x(1,15)-x(1,6))^2+(x(2,15)-x(2,6))^2-d(23)^2;

f(24)=(x(1,19)-x(1,6))^2+(x(2,19)-x(2,6))^2-d(24)^2;

f(25)=(x(1,20)-x(1,6))^2+(x(2,20)-x(2,6))^2-d(25)^2;

f(26)=(x(1,13)-x(1,7))^2+(x(2,13)-x(2,7))^2-d(26)^2;

f(27)=(x(1,17)-x(1,7))^2+(x(2,17)-x(2,7))^2-d(27)^2;

f(28)=(x(1,12)-x(1,8))^2+(x(2,12)-x(2,8))^2-d(28)^2;

f(29)=(x(1,14)-x(1,8))^2+(x(2,14)-x(2,8))^2-d(29)^2;

f(30)=(x(1,21)-x(1,8))^2+(x(2,21)-x(2,8))^2-d(30)^2;

f(31)=(x(1,10)-x(1,9))^2+(x(2,10)-x(2,9))^2-d(31)^2;

f(32)=(x(1,12)-x(1,9))^2+(x(2,12)-x(2,9))^2-d(32)^2;

f(33)=(x(1,18)-x(1,9))^2+(x(2,18)-x(2,9))^2-d(33)^2;

f(34)=(x(1,19)-x(1,9))^2+(x(2,19)-x(2,9))^2-d(34)^2;

f(35)=(x(1,21)-x(1,9))^2+(x(2,21)-x(2,9))^2-d(35)^2;

f(36)=(x(1,17)-x(1,10))^2+(x(2,17)-x(2,10))^2-d(36)^2;

f(37)=(x(1,24)-x(1,10))^2+(x(2,24)-x(2,10))^2-d(37)^2;

f(38)=(x(1,14)-x(1,11))^2+(x(2,14)-x(2,11))^2-d(38)^2;

f(39)=(x(1,16)-x(1,11))^2+(x(2,16)-x(2,11))^2-d(39)^2;

f(40)=(x(1,14)-x(1,12))^2+(x(2,14)-x(2,12))^2-d(40)^2;

f(41)=(x(1,18)-x(1,12))^2+(x(2,18)-x(2,12))^2-d(41)^2;

f(42)=(x(1,14)-x(1,13))^2+(x(2,14)-x(2,13))^2-d(42)^2;

f(43)=(x(1,15)-x(1,13))^2+(x(2,15)-x(2,13))^2-d(43)^2;

f(44)=(x(1,19)-x(1,15))^2+(x(2,19)-x(2,15))^2-d(44)^2;

f(45)=(x(1,22)-x(1,15))^2+(x(2,22)-x(2,15))^2-d(45)^2;

f(46)=(x(1,17)-x(1,16))^2+(x(2,17)-x(2,16))^2-d(46)^2;

f(47)=(x(1,18)-x(1,16))^2+(x(2,18)-x(2,16))^2-d(47)^2;

f(48)=(x(1,19)-x(1,18))^2+(x(2,19)-x(2,18))^2-d(48)^2;

f(49)=(x(1,22)-x(1,18))^2+(x(2,22)-x(2,18))^2-d(49)^2;

f(50)=(x(1,23)-x(1,18))^2+(x(2,23)-x(2,18))^2-d(50)^2;

f(51)=(x(1,22)-x(1,20))^2+(x(2,22)-x(2,20))^2-d(51)^2;

f(52)=(x(1,22)-x(1,21))^2+(x(2,22)-x(2,21))^2-d(52)^2;

clearall

x0=[zeros(1,24);ones(1,24)];

d=[0.9607,0.4399,0.8143,1.3765,1.2722,0.5294,0.6144,0.3766,0.6893,...

0.9488,0.8000,1.1090,1.1432,0.4758,1.3402,0.7006,0.4945,1.0559,...

0.6810,0.3587,0.3351,0.2878,1.1346,0.3870,0.7511,0.4439,0.8363,...

0.3208,0.1574,1.2736,0.5781,0.9254,0.6401,0.2467,0.4727,1.3840,...

0.4366,1.0307,1.3904,0.5725,0.7660,0.4394,1.0952,1.0422,1.8255,...

1.4325,1.0851,0.4995,1.2277,1.1271,0.7060,0.8052]';%设定初值

[x,norms]=lsqnonlin(@distance,x0,[],[],[],d);

p=x';%p第一行即为第二个原子的横、纵坐标;p第二行为第三个原子的横、纵坐标……

a=[0,x(1,:

)];

b=[0,x(2,:

)];

plot(a,b,'*');%画散点图表示出原子的位置

【输出结果】

每个原子的位置如下(即第二个原子的位置为(1.2378,0.0746),第三个原子为(1,6142,1,。

1211),……):

p=

1.23780.0746

1.61421.1211

0.54850.7778

0.91210.4836

0.85461.1533

0.70090.4533

0.98710.6573

0.46940.2363

0.83261.0437

0.43560.6211

-0.0650-0.4184

0.81650.1140

0.73510.2500

0.39710.4986

1.82290.2932

1.3241-0.3717

1.76570.9905

1.35140.7020

0.89210.7787

0.50401.1701

1.31061.1878

0.80311.8060

0.52901.4757

0.89460.7093

为了形象直观地表示出各点的位置,画出如下的散点图:

方法二用fminunc实现

functionf=distance1(x,d)

f=(x(1,3))^2+(x(2,3))^2-d

(1)^2;

f=f+(x(1,11))^2+(x(2,11))^2-d

(2)^2;

f=f+(x(1,12))^2+(x(2,12))^2-d(3)^2;

f=f+(x(1,16))^2+(x(2,16))^2-d(4)^2;

f=f+(x(1,20))^2+(x(2,20))^2-d(5)^2;

f=f+(x(1,4)-x(1,1))^2+(x(2*5-2)-x(2,1))^2-d(6)^2;

f=f+(x(1,15)-x(1,1))^2+(x(2,15)-x(2,1))^2-d(7)^2;

f=f+(x(1,16)-x(1,1))^2+(x(2,16)-x(2,1))^2-d(8)^2;

f=f+(x(1,24)-x(1,1))^2+(x(2,24)-x(2,1))^2-d(9)^2;

f=f+(x(1,4)-x(1,2))^2+(x(2,4)-x(2,2))^2-d(10)^2;

f=f+(x(1,19)-x(1,2))^2+(x(2,19)-x(2,2))^2-d(11)^2;

f=f+(x(1,20)-x(1,2))^2+(x(2,20)-x(2,2))^2-d(12)^2;

f=f+(x(1,23)-x(1,2))^2+(x(2,23)-x(2,2))^2-d(13)^2;

f=f+(x(1,4)-x(1,3))^2+(x(2,4)-x(2,3))^2-d(14)^2;

f=f+(x(1,11)-x(1,3))^2+(x(2,11)-x(2,3))^2-d(15)^2;

f=f+(x(1,23)-x(1,3))^2+(x(2,23)-x(2,3))^2-d(16)^2;

f=f+(x(1,7)-x(1,5))^2+(x(2,7)-x(2,5))^2-d(17)^2;

f=f+(x(1,12)-x(1,5))^2+(x(2,12)-x(2,5))^2-d(18)^2;

f=f+(x(1,18)-x(1,5))^2+(x(2,18)-x(2,5))^2-d(19)^2;

f=f+(x(1,24)-x(1,5))^2+(x(2,24)-x(2,5))^2-d(20)^2;

f=f+(x(1,7)-x(1,6))^2+(x(2,7)-x(2,6))^2-d(21)^2;

f=f+(x(1,13)-x(1,6))^2+(x(2,13)-x(2,6))^2-d(22)^2;

f=f+(x(1,15)-x(1,6))^2+(x(2,15)-x(2,6))^2-d(23)^2;

f=f+(x(1,19)-x(1,6))^2+(x(2,19)-x(2,6))^2-d(24)^2;

f=f+(x(1,20)-x(1,6))^2+(x(2,20)-x(2,6))^2-d(25)^2;

f=f+(x(1,13)-x(1,7))^2+(x(2,13)-x(2,7))^2-d(26)^2;

f=f+(x(1,17)-x(1,7))^2+(x(2,17)-x(2,7))^2-d(27)^2;

f=f+(x(1,12)-x(1,8))^2+(x(2,12)-x(2,8))^2-d(28)^2;

f=f+(x(1,14)-x(1,8))^2+(x(2,14)-x(2,8))^2-d(29)^2;

f=f+(x(1,21)-x(1,8))^2+(x(2,21)-x(2,8))^2-d(30)^2;

f=f+(x(1,10)-x(1,9))^2+(x(2,10)-x(2,9))^2-d(31)^2;

f=f+(x(1,12)-x(1,9))^2+(x(2,12)-x(2,9))^2-d(32)^2;

f=f+(x(1,18)-x(1,9))^2+(x(2,18)-x(2,9))^2-d(33)^2;

f=f+(x(1,19)-x(1,9))^2+(x(2,19)-x(2,9))^2-d(34)^2;

f=f+(x(1,21)-x(1,9))^2+(x(2,21)-x(2,9))^2-d(35)^2;

f=f+(x(1,17)-x(1,10))^2+(x(2,17)-x(2,10))^2-d(36)^2;

f=f+(x(1,24)-x(1,10))^2+(x(2,24)-x(2,10))^2-d(37)^2;

f=f+(x(1,14)-x(1,11))^2+(x(2,14)-x(2,11))^2-d(38)^2;

f=f+(x(1,16)-x(1,11))^2+(x(2,16)-x(2,11))^2-d(39)^2;

f=f+(x(1,14)-x(1,12))^2+(x(2,14)-x(2,12))^2-d(40)^2;

f=f+(x(1,18)-x(1,12))^2+(x(2,18)-x(2,12))^2-d(41)^2;

f=f+(x(1,14)-x(1,13))^2+(x(2,14)-x(2,13))^2-d(42)^2;

f=f+(x(1,15)-x(1,13))^2+(x(2,15)-x(2,13))^2-d(43)^2;

f=f+(x(1,19)-x(1,15))^2+(x(2,19)-x(2,15))^2-d(44)^2;

f=f+(x(1,22)-x(1,15))^2+(x(2,22)-x(2,15))^2-d(45)^2;

f=f+(x(1,17)-x(1,16))^2+(x(2,17)-x(2,16))^2-d(46)^2;

f=f+(x(1,18)-x(1,16))^2+(x(2,18)-x(2,16))^2-d(47)^2;

f=f+(x(1,19)-x(1,18))^2+(x(2,19)-x(2,18))^2-d(48)^2;

f=f+(x(1,22)-x(1,18))^2+(x(2,22)-x(2,18))^2-d(49)^2;

f=f+(x(1,23)-x(1,18))^2+(x(2,23)-x(2,18))^2-d(50)^2;

f=f+(x(1,22)-x(1,20))^2+(x(2,22)-x(2,20))^2-d(51)^2;

f=f+(x(1,22)-x(1,21))^2+(x(2,22)-x(2,21))^2-d(52)^2;

clearall;

d=[0.9607,0.4399,0.8143,1.3765,1.2722,0.5294,0.6144,0.3766,0.6893,0.9488,0.8000,1.1090,1.1432,0.4758,1.3402,0.7006,0.4945,1.0559,0.6810,0.3587,0.3351,0.2878,1.1346,0.3870,0.7511,0.4439,0.8363,0.3208,0.1574,1.2736,0.5781,0.9254,0.6401,0.2467,0.4727,1.3840,0.4366,1.0307,1.3904,0.5725,0.7660,0.4394,1.0952,1.0422,1.8255,1.4325,1.0851,0.4995,1.2277,1.1271,0.7060,0.8052]';

x0=[zeros(1,26),ones(1,24)];

opt=optimset('tolx',1e-16,'tolf',1e-16);

[x,z,exit1,out1]=fminunc(@distance1,x0,opt,d);

p=[0,0;x(1:

24)',x(25:

48)'];

a=[0,x(1:

24)];

b=[0,x(25:

48)];

plot(a,b,'*');%画散点图表示原子位置

【输出结果】

每个原子的位置如下(即第二个原子的位置为(-0.6818,0.6856),第二个原子为(-0.3563,0.2298),……):

p=

00

-0.68180.6856

-0.35630.2298

-0.05300.9715

-0.48661.1721

0.05061.0700

0.39920.6744

0.05470.5349

-0.39480.3789

-0.13881.0752

0.41900.9660

-0.3796-0.3227

-0.74300.3687

0.15110.9167

-0.26150.6897

-0.56210.0830

-0.98360.9375

-0.2070-0.2659

-0.01440.4168

0.07170.9085

-0.01171.2804

-0.08901.6054

0.68771.4172

-0.66611.3305

0.01250.7379

画出位置散点图如下:

【结果分析】

(1)关于lsqononlin与fminunc精确性的探讨

用上面两种不同的命令所求出来的结果并不一样,可能是因为模型建立稍有差别导致算法不同而引起的。

为了找到更适合解决本题的模型,在命令窗口中输入以下命令比较两种算法的精确性。

对于方法一(用lsqnonlin命令实现)

>>d=[0.9607,0.4399,0.8143,1.3765,1.2722,0.5294,0.6144,0.3766,0.6893,...

0.9488,0.8000,1.1090,1.1432,0.4758,1.3402,0.7006,0.4945,1.0559,...

0.6810,0.3587,0.3351,0.2878,1.1346,0.3870,0.7511,0.4439,0.8363,...

0.3208,0.1574,1.2736,0.5781,0.9254,0.6401,0.2467,0.4727,1.3840,...

0.4366,1.0307,1.3904,0.5725,0.7660,0.4394,1.0952,1.0422,1.8255,...

1.4325,1.0851,0.4995,1.2277,1.1271,0.7060,0.8052]';

x=p';

f

(1)=(x(1,3))^2+(x(2,3))^2-d

(1)^2;%对应条件第4个和第1个原子间距

f

(2)=(x(1,11))^2+(x(2,11))^2-d

(2)^2;

f(3)=(x(1,12))^2+(x(2,12))^2-d(3)^2;

f(4)=(x(1,16))^2+(x(2,16))^2-d(4)^2;

f(5)=(x(1,20))^2+(x(2,20))^2-d(5)^2;

f(6)=(x(1,4)-x(1,1))^2+(x(2*5-2)-x(2,1))^2-d(6)^2;

f(7)=(x(1,15)-x(1,1))^2+(x(2,15)-x(2,1))^2-d(7)^2;

f(8)=(x(1,16)-x(1,1))^2+(x(2,16)-x(2,1))^2-d(8)^2;

f(9)=(x(1,24)-x(1,1))^2+(x(2,24)-x(2,1))^2-d(9)^2;

f(10)=(x(1,4)-x(1,2))^2+(x(2,4)-x(2,2))^2-d(10)^2;

f

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 解决方案

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1