圧縮係数 ホームページプログラミング 


非線形方程式の解法zfact.html

プログラム部分を示す。一変数の非線形方程式解法プログラム。

<script language="VBScript"><!--
Option Explicit
Dim T,p,Tc,pc,omega,omegar,Tr,pr
Dim B1,B2,B3,B4,C1,C2,C3,C4,D1,D2,BTA,GAM,B,C,D
Dim BB1,BB2,BB3,BB4,CC1,CC2,CC3,CC4,DD1,DD2,BBTA,GGAM,BB,CC,DD
Dim NL,ZEP,ZX0,ZXD,X,G,ZX1,ZX2,ZX3,Z,R,VR,V,Z0,ZR,Vcm,Z1
Sub A_onClick
T=ValT.value
p=Valp.value
Tc=ValTc.value
pc=Valpc.value
omega=Valomega.value
omegar=0.3978
Tr=T/Tc
pr=p/pc
B1=0.1181193
B2=0.265728
B3=0.154790
B4=0.030323
C1=2.36744e-2
C2=1.86984e-2
C3=0.0
C4=0.042724
D1=1.55488e-5
D2=6.23689e-5
BTA=0.65392
GAM=0.060167
B=B1-B2/Tr-B3/(Tr*Tr)-B4/(Tr*Tr*Tr)
C=C1-C2/Tr+C3/(Tr*Tr*Tr)
D=D1+D2/Tr
BB1=0.202658
BB2=0.331511
BB3=0.027655
BB4=0.203488
CC1=3.13385e-2
CC2=5.03618e-2
CC3=0.016901
CC4=0.041577
DD1=4.8736e-5
DD2=7.40336e-6
BBTA=1.226
GGAM=0.03754
BB=BB1-BB2/Tr-BB3/(Tr*Tr)-BB4/(Tr*Tr*Tr)
CC=CC1-CC2/Tr+CC3/(Tr*Tr*Tr)
DD=DD1+DD2/Tr
NL =1 
ZEP = .000001
ZX0=0.1
ZXD=0.1
Do While ABS(ZXD) > ZEP
ValNL.value=NL
X = ZX0
zfact
ZX1 = G
X = ZX1
zfact
ZX2 = G
ZXD = ZX2 - 2 * ZX1 + ZX0
ZX3 = ZX2
ZX3 = ZX0 - (ZX1 - ZX0) * (ZX1 - ZX0) / ZXD
ZX0 = ZX3
NL=NL+1
IF NL>100 Then
	Exit Do
End If
Loop
ValTr.Value=Tr
Valpr.value=pr
VR=ZX3
ValVr.value=VR
Z=pr*VR/Tr
Valz.value=Z
Valz0.value=Z0
Valz1.value=Z1
R=8.3143
V=Z*R*T/(P*1e6)
ValV.value=V
Vcm=V*1e6
ValVcm.value=Vcm
IF NL>100 Then
	ValNL.value="収束しません" 
	ValVr.value="---"
	Valz.value="---"
ValV.value="---"
ValVcm.value="---"
End If
End Sub
Sub zfact
VR=X
Z0=1+B/VR+C/(VR*VR)+D/(VR*VR*VR*VR*VR)+(C4/(Tr*Tr*Tr)/(VR*VR))*(BTA+GAM/(VR*VR))*exp(-GAM/(VR*VR))
ZR=1+BB/VR+CC/(VR*VR)+DD/(VR*VR*VR*VR*VR)+(CC4/(Tr*Tr*Tr)/(VR*VR))*(BBTA+GGAM/(VR*VR))*exp(-GGAM/(VR*VR))
Z1=(omega/omegar)*(ZR-Z0)
Z=Z0+Z1
VR=Z*Tr/pr
G=VR
End Sub
--></script>