Example of using NEQNF subroutine
Example Statement
Consider a binary system of component 1 and 2, with component 1 being the more volatile one. For a given pressure P and a vapor composition y of component 1 the dew point calculation consist in determining the Temperature T and the liquid composition x. Assuming ideal phase equilibrium the Pressure and the liquid composition are given by:
The pressure should be in mmHg and temperature in oK.
----------------------------------------------------------------------------------------------------------------------------
Fortran Program Listing
[Fortran] 纯文本查看 复制代码 INTEGER N,ITMAX
REAL X(3), XG(3), FNORM
EXTERNAL FCN
N=2
ERRREL=1.0e-4
ITMAX=100
XG(1)=0.5
XG(2)=100.0
call NEQNF (FCN, ERRREL, N, ITMAX, XG, X, FNORM)
WRITE(6,*)
WRITE(6,*)'FNORM = ',FNORM
WRITE(6,*)'X1 = ',X(1)
WRITE(6,*)'X2 = ',X(2)
STOP
END
SUBROUTINE FCN(X,F,N)
INTEGER N
REAL X(N),F(N)
P=3.0*750.6
Y=0.6
A1=19.6664
B1=-4361.55
A2=20.1735
B2=-5050.5
PS1=EXP(A1+B1/(X(2)+273))
PS2=EXP(A2+B2/(X(2)+273))
F(1)=P-X(1)*PS1-(1-X(1))*PS2
F(2)=Y*P-X(1)*PS1
RETURN
END
C Output
C FNORM = 5.483037E-04
C X1 = 2.966535E-01
C X2 = 114.950700
C Stop - Program terminated.
C Press any key to continue
|