| 3 | 1/1 | 返回列表 |
| 查看: 1341 | 回復(fù): 2 | |||
[交流]
【求助】求高手幫看一下程序(泡點溫度計算)
|
|
使用SRK方程和wilson方程計算泡點溫度和組成 m文件中,y(1)是組分1 的氣相組成,y(2)是溫度 m文件如下 function f=myfun(y,x1) p=101325; T1c=579.35;V1c=219E-06;Z1c=0.259;p1c=56.9E+05;w1=0.193; ANTA1=36.6016;ANTB1=-2979.4;ANTC1=-10.104;ANTD1=1.1445E-09;ANTE1=3.2472E-06; T2c=591.79;V2c=315.8e-06;Z2c=0.264;p2c=41.09e+05;w2=0.264; ANTA2=34.0755;ANTB2=-3.0379e+03;ANTC2=-9.1635;ANTD2=1.0289E-11;ANTE2=2.7035E-06; b=[4198.6 -3001.6]; x2=1-x1; p1s=10^(ANTA1+ANTB1/y(2)+ANTC1*log10(y(2))+ANTD1*y(2)+ANTE1*y(2)* y(2))*133.322; p2s=10^(ANTA2+ANTB2/y(2)+ANTC2*log10(y(2))+ANTD2*y(2)+ANTE2*y(2)* y(2))*133.322; SRKa1=0.42748*8.31441*8.31441*T1c*T1c/p1c*(1+(0.480+1.574*w1-0.176*w1^2)*(1-(y(2)/T1c)^0.5))^2; SRKb1=0.08664*8.31441*T1c/p1c; SRKk1=-8.31441*y(2)/p1s; SRKm1=SRKa1/p1s-SRKb1*8.31441*y(2)/p1s-(SRKb1)^2; SRKn1=-SRKa1*SRKb1/p1s; SRKp1=[1 SRKk1 SRKm1 SRKn1]; SRKV1=roots(SRKp1); V1=max(SRKV1); Z1=p1s*V1/8.31441/y(2); fai1s=exp((Z1-1)-log(p1s*(V1-SRKb1)/8.31441/y(2))-SRKa1*log(1+SRKb1/SRKV1)/SRKb1/8.31441/y(2)); SRKa2=0.42748*8.31441*8.31441*T2c*T2c/p2c*(1+(0.480+1.574*w2-0.176*w2^2)*(1-(y(2)/T2c)^0.5))^2; SRKb2=0.08664*8.31441*T2c/p2c; SRKk2=-8.31441*y(2)/p2s; SRKm2=SRKa2/p2s-SRKb2*8.31441*y(2)/p2s-(SRKb2)^2; SRKn2=-SRKa2*SRKb2/p2s; SRKp2=[1 SRKk2 SRKm2 SRKn2]; SRKV2=roots(SRKp2); V2=max(SRKV2); Z2=p2s*V2/8.31441/y(2); fai2s=exp((Z2-1)-log(p2s*(V2-SRKb2)/8.31441/y(2))-SRKa2*log(1+SRKb2/V2)/SRKb2/8.31441/y(2)); Tc12=(T1c*T2c)^0.5; Vc12=((nthroot(V1c,3)+nthroot(V2c,3))/2)^3; Zc12=(Z1c+Z2c)/2; pc12=Zc12*8.31441*Tc12/Vc12; w12=(w1+w2)/2; SRKa12=(SRKa1*SRKa2)^0.5; SRKam=y(1)*y(1)*SRKa1+2*y(1)*(1-y(1))*SRKa12+(1-y(1))*(1-y(1))*SRKa2; SRKbm=y(1)*SRKb1+(1-y(1))*SRKb2; SRKkm=-8.31441*y(2)/p; SRKmm=SRKam/p-SRKbm*8.31441*y(2)/p-(SRKbm)^2; SRKnm=-SRKam*SRKbm/p; SRKpm=[1 SRKkm SRKmm SRKnm]; SRKVm=roots(SRKpm); Vm=max(SRKVm); Zm=p*Vm/8.31441/y(2); fai1=exp(SRKb1/SRKbm*(Zm-1)-log(p*(Vm-SRKbm)/8.31441/y(2))+SRKam*(SRKb1/SRKbm-2*(y(1)*SRKa1+(1-y(1))*SRKa12)/SRKam)*log(1+SRKbm/SRKVm)/SRKbm/8.31441/y(2)); fai2=exp(SRKb2/SRKbm*(Zm-1)-log(p*(Vm-SRKbm)/8.31441/y(2))+SRKam*(SRKb2/SRKbm-2*(y(1)*SRKa12+(1-y(1))*SRKa2)/SRKam)*log(1+SRKbm/SRKVm)/SRKbm/8.31441/y(2)); V1L=V1c*Z1c^((1-y(2)/T1c)^(2/7)); V2L=V2c*Z2c^((1-y(2)/T2c)^(2/7)); A12=(V2L/V1L)*exp(-b(1)/8.314/y(2)); A21=(V1L/V2L)*exp(-b(2)/8.314/y(2)); r1cal=exp(-log(x1+A12*x2)+x2*(A12/(x1+A12*x2)-A21/(x2+A21*x1))); r2cal=exp(-log(x2+A21*x1)-x1*(A12/(x1+A12*x2)-A21/(x2+A21*x1))); f=abs(y(1)*p*fai1-r1cal*p1s*fai1s*x1*exp(V1L*(p-p1s)/8.31441/y(2)))+abs((1-y(1))*p*fai2-r2cal*p2s*fai2s*x2*exp(V2L*(p-p2s)/8.31441/y(2))); main文件如下 x1=[0.9643 0.9165 0.8322 0.7520 0.6696 0.6362 0.5576 0.4416 0.3864 0.3407 0.2988 0.2628 0.2271 0.1877 0.1482 0.0933 0.0586 0.0375]; n=18; for i=1:n x0=[1;355]; [x fval]=fminsearch(@(x) myfun(x,x1(i)),x0) x1(i)=x(1); x2(i)=x(2); end; x1; x2; 運行提示Subscripted assignment dimension mismatch. Error in ==> fminsearch at 205 fv(:,1) = funfcn(x,varargin{:}); [ Last edited by flying_fay on 2010-12-1 at 11:26 ] |
» 搶金幣啦!回帖就可以得到:
+2/412
+1/236
+1/83
+1/79
+1/72
+2/66
+1/33
+1/29
+1/21
+1/13
+1/11
+1/9
+1/7
+1/6
+1/5
+1/5
+1/2
+1/1
+1/1
+1/1
| 3 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 303求調(diào)劑 +5 | 安憶靈 2026-03-22 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 08工科 320總分 求調(diào)劑 +7 | 梨花珞晚風(fēng) 2026-03-17 | 7/350 |
|
|
[考研] 生物學(xué)071000 329分求調(diào)劑 +4 | 我愛生物生物愛?/a> 2026-03-17 | 4/200 |
|
|
[考研] 286求調(diào)劑 +10 | Faune 2026-03-21 | 10/500 |
|
|
[考研] 初試 317 +7 | 半拉月丙 2026-03-20 | 7/350 |
|
|
[考研] 材料與化工(0856)304求B區(qū)調(diào)劑 +3 | 邱gl 2026-03-20 | 7/350 |
|
|
[考研] 278求調(diào)劑 +9 | 煙火先于春 2026-03-17 | 9/450 |
|
|
[考研] 0703化學(xué)297求調(diào)劑 +3 | Daisy☆ 2026-03-20 | 3/150 |
|
|
[考研] 307求調(diào)劑 +3 | 余意卿 2026-03-18 | 3/150 |
|
|
[考研] 299求調(diào)劑 +4 | 某某某某位 2026-03-21 | 4/200 |
|
|
[考研] 材料 336 求調(diào)劑 +3 | An@. 2026-03-18 | 4/200 |
|
|
[考研] 材料專業(yè)求調(diào)劑 +6 | hanamiko 2026-03-18 | 6/300 |
|
|
[考研] 296求調(diào)劑 +6 | www_q 2026-03-18 | 10/500 |
|
|
[考研] 308求調(diào)劑 +3 | 阿姐阿姐家啊 2026-03-18 | 3/150 |
|
|
[考研] A區(qū)線材料學(xué)調(diào)劑 +5 | 周周無極 2026-03-20 | 5/250 |
|
|
[考研] 求調(diào)劑 +3 | @taotao 2026-03-20 | 3/150 |
|
|
[考研] 廣西大學(xué)家禽遺傳育種課題組2026年碩士招生(接收計算機專業(yè)調(diào)劑) +3 | 123阿標(biāo) 2026-03-17 | 3/150 |
|
|
[考研]
|
不想起名字112 2026-03-19 | 3/150 |
|
|
[考研] 生物學(xué)調(diào)劑招人!! +3 | 山海天嵐 2026-03-17 | 4/200 |
|
|
[考研] 328求調(diào)劑,英語六級551,有科研經(jīng)歷 +4 | 生物工程調(diào)劑 2026-03-16 | 12/600 |
|