Sie sind auf Seite 1von 12

FUNCTION VAP_PRES (n, Tr)

implicit double precision (a-h, o-z)


parameter (ntot=40)
double precision Tc(ntot), pc(ntot), x(ntot,4), Tmin(ntot)
integer num_eqn(ntot)
*
*

................................................
This function returns vapor pressure(bar), given the temperature T(K), reduced
temperature Tr and critical pressure(bar). Data used are obtained from 'The prop. of gases &
liquids', 4th ed., by R.C. Reid et al. n denotes the fluid number.
................................................
data ((x(i,j), j=1,4), i=1,ntot)/
+ -5.90501, 1.12627, -0.76787, -1.62721, !argon!
+ -6.00435, 1.18850, -0.83408, -1.22833, !methane!
+ -6.34307, 1.01630, -1.19116, -2.03539, !ethane!
+ -6.72219, 1.33236, -2.13868, -1.38551, !propane!
+ -6.88709, 1.15157, -1.99873, -3.13003, !n-butane!
+ -7.46765, 1.44211, -3.28222, -2.50941, !n-hexane!
+ -7.91211, 1.38007, -3.80435, -4.50132, !n-octane!
+ -8.56523, 1.97756, -5.81971, -0.29982, !n-decane!
+ -7.76451, 1.45838, -2.77580, -1.23303, !water!
+ 45.327, 4104.67, -5.146, 615.0,
!ammonia!
+ -8.54796, 0.76982, -3.10850, 1.54481, !methanol!
+ -8.51838, 0.34163, -5.73683, 8.32581, !ethanol!
+ -8.05594, 0.0425183, -7.51296, 6.89004, !propanol!
+ -8.00756, 0.53783, -9.34240, 6.68692, !n-butanol!
+ -7.45514, 1.20200, -2.43926, -3.35590, !acetone!
+ 40.774, 5392.43, -4.357, 2615.0, !acetonitrile!
+ -7.29916, 1.24828, -2.91931, -3.36740, !diethyl eter!
+ -6.95546, 1.16625, -2.13970, -3.44421, !chloroform!
+ -6.20798, 1.27885, -1.34533, -2.56842, !c-monoxide!
+ -7.12597, 1.81710, -3.10058, -0.91638, !dimethyl eter!
+ -7.64466, 2.88475, -6.32922, 0.33736, !met-ethyl eter!
+ -3.97466, 1.00074, 1.50056, -0.43020, !helium!
+ 31.994, 2626.67, -3.443, 538.0,
!HCl!
+ -7.83183, 5.51929d-4, 0.24709, -8.50462, !acetic acid!
+ -7.04687, 0.12142, -2.6604d-2, -5.90300, !ethanal!
+ -8.05406, 2.56375, -5.12994, 0.16125, !met-acetate!
+ -7.15825, 1.10752, -2.12022, -4.54857, !R-114!
+ -7.23667, 2.11017, -3.53882, 0.34775, !ethylchloride!
+ -6.96009, 1.31328, -2.75683, -2.45491, !cyclohexane!
+ -6.98273, 1.33213, -2.62863, -3.33399, !benzene!
+ -7.28607, 1.38091, -2.83433, -2.79168, !toluene!
+ -6.32055, 1.16819, -1.55935, -1.83552, !ethylene!
+ -6.56234, 0.42696, -1.25638, -3.18133, !ethyleneoxide!
+ -8.7555, 2.92651, -6.31601, -1.36889, !phenol!
+ -6.96578, 1.50970, -2.73740, -1.73828, !et-mercaptan!
+ -6.40952, 1.21015, -1.54976, -2.10074, !COS!
+ -6.95626, 1.19695, -3.12614, 2.99448, !CO2!
+ -6.09676, 1.13670, -1.04072, -1.93306, !n2!
+ -7.32301, 1.50248, -2.64678, -4.93429, !c2f6!

+ -7.28936, 1.53679,

-3.08367, -1.02456/ !n-pentane!

data (Tc(i), i=1,ntot)/


+ 150.8, 190.4, 305.4,
+ 647.3, 405.5, 512.6,
+ 466.7, 536.4, 132.9,
+ 461.0, 506.8, 418.9,
+ 469.0, 694.2, 499.0,

369.8,
513.9,
400.0,
460.4,
378.8,

data (pc(i), i=1,ntot)/


+ 48.7, 46.0, 48.8, 42.5,
+ 221.2, 113.5, 80.9, 61.4,
+ 36.4, 53.7, 35.0, 52.4,
+ 55.7, 46.9, 32.6, 52.7,
+ 71.9, 61.3, 54.9, 63.5,

425.2,
536.8,
437.8,
553.5,
304.1,

38.0,
51.7,
44.0,
40.7,
73.8,

507.5, 568.8, 617.7,


563.1, 508.1, 545.5,
5.19, 324.7, 592.7,
562.2, 591.8, 282.4,
126.2, 293.0, 469.7/

30.1, 24.9,
44.2, 47.0,
2.27, 83.1,
48.9, 41.0,
33.9, 30.6,

21.2,
48.3,
57.9,
50.4,
33.7/

data (Tmin(i), i=1,ntot)/


+ 84., 91., 133., 145., 170., 220., 260., 368.,
+ 275., 220., 288., 293., 260., 275., 259., 300.,
+ 250., 215., 71., 194., 224., 2., 180., 304.,
+ 273., 275., 180., 217., 293., 288., 309., 105.,
+ 238., 380., 273., 162., 217., 63., 173., 195/

data (num_eqn(i), i=1,ntot)/


+ 1,
1,
1,
1,
1,
1,
+ 1,
2,
1,
1,
1,
1,
+ 1,
1,
1,
1,
1,
1,
+ 1,
1,
1,
1,
1,
1,
+ 1,
1,
1,
1,
1,
1,

*
*

1,
1,
2,
1,
1,

1,
2,
1,
1,
1/

T = Tr*Tc(n)
Trmin = Tmin(n)/Tc(n)
if (Tr .lt. Trmin) then
write(*,*)'warning!, T < Tmin for vp calc'
write(*,*)'for compound number: ', n
endif
n_eqn = num_eqn(n)
if (n_eqn .eq. 1) then
Wagner eqn...
y = 1. - Tr
rhs = x(n,1)*y + x(n,2)*y**1.5 + x(n,3)*y**3 + x(n,4)*y**6
p = pc(n)*dexp(rhs/Tr)
endif
if (n_eqn .eq. 2) then
Frost-Kalkwarf-Thodos eqn...
rhs_trunc = x(n,1) - x(n,2)/T + x(n,3)*dlog(T)
p = dexp(rhs_trunc)
del = 1.
iter = 1
do while (dabs(del) .gt. 0.00001)

fp = x(n,1) - x(n,2)/T + x(n,3)*dlog(T) + x(n,4)*p/T/T - dlog(p)


dfdp = x(n,4)/T/T - 1./p
pnew = p - fp/dfdp
del = (p - pnew)/p
iter = iter + 1
if (iter .gt. 50) then
write(*,*)'problem in FKT vap-pressure'
write(*,*)'for compound number',n
stop
end if
p = pnew

end do
endif
if (n_eqn .eq. 3) then
Antoine eqn...
p = dexp(x(n,1) - x(n,2)/(x(n,3)+T))
endif
if ((n_eqn.ne.1) .and. (n_eqn.ne.2) .and. (n_eqn.ne.3)) then
write(*,*) 'eqn-number not recognized'
stop
endif
vap_pres = p
return
END

FUNCTION FIND_PS (n_eos, id_fluid, a, b, c, u, w, d, T, Tr, vliq, vvap, n_alpha)


implicit double precision (a-h, o-z)
double precision pres(3), fp(2)
*
*
*

This function returns the value of saturation pressure (psat) in bars at a given T,
determined iteratively using the SECANT formula until the equality of fugacity at VLE
(ln(f/p)vap=ln(f/p)liq) is satisfied within the specified convergence criteria.
pres(1) = vap_pres (id_fluid, Tr)
pres(2) = 1.005*pres(1)

Begin Secant iteration...


itmax = 50
iter = 1
Do while (iter .le. itmax)
istat = 1
Calculate liquid and vapor-phase volumes...
i=1
Do while (i .le. 2)
p = pres(i)
call cubic_coef (n_eos, a, b, c, T, p, c2, c1, c0)
call cubic (c2, c1, c0, vvap, vliq)
Calculate liquid and vapor-phase fugacities...
call fuga_p_cub (n_eos, a, b, c, vliq, T, p, fp_l, dfdp_l)

call fuga_p_cub (n_eos, a, b, c, vvap, T, p, fp_v, dfdp_v)


fp(i) = fp_l - fp_v
i=i+1
end do
*
*

Compute new p using Secant formula...


pres(3) = pres(2) - fp(2)*(pres(2)-pres(1))/(fp(2)-fp(1))
Check for convergence of p and fp...
delta = (pres(3) - pres(2))/pres(2)
if (dabs(delta) .gt. 0.000001) istat = 0
if (dabs(fp(2)) .gt. 0.00001) istat = 0
If convergence is achieved, print results and return...
if (istat .eq. 1) then
find_ps = pres(3)
return
endif
pres(1) = pres(2)
pres(2) = pres(3)
iter = iter + 1
End do
write(*,*)'no convergence, iteration > itmax'
find_ps = 0.
return
END

SUBROUTINE CUBIC (q, r, s, zv, zl)


implicit double precision (a-h,o-z)
dimension z(3)
*
*
*
*
*
*
*
*
*

.........................................................
Cubic.for :
This routine solves cubic equation of the form
z^3 + q.z^2 + r.z + s = 0
where z could be the compressibility factor or volume.
The liquid root is returned as the smallest root,zl,
the vapor root is returned as the highest root, zv,
and the intermediate root, if there is one, is discarded.
.........................................................
g = r-q*q/3.
h = (2.*q**3-9.*q*r+27.*s)/27.
disc = h**2/4.+g**3/27.

*
*

Either one (disc>0) or three identical real root


(disc=0)

if (disc .ge. 0.0) then

*
*
*
*
*
*

tt = dabs(-h/2. + dsqrt(g**3/27. + h**2/4.))


uu = dabs(-h/2. - dsqrt(g**3/27. + h**2/4.))
zv = tt**(1./3.)-uu**(1./3.)-q/3.
zl = zv
return
end if
if (disc .ge. 0.0) then
tt = -h/2. + dsqrt(g**3/27. + h**2/4.)
uu = -h/2. - dsqrt(g**3/27. + h**2/4.)
if (tt .ge. 0.0) then
zv1 = tt**(1./3.)
else
zv1 = -(dabs(tt))**(1./3.)
endif
if (uu .ge. 0.0) then
zv2 = uu**(1./3.)
else
zv2 = -(dabs(uu))**(1./3.)
endif
zv = zv1 + zv2 - q/3.
zl = zv
return
endif

*
*

Three real unidentical roots, the intermediate


root is not physically meaningful
xa = -h/2./dsqrt(-g**3/27.)
phi = 3.1415926535/2. - datan(xa/dsqrt(1.-xa**2))
z(1) = 2.*dsqrt(-g/3.)*dcos(phi/3.) - q/3.
z(2) = 2.*dsqrt(-g/3.)*dcos(phi/3. + 2.094395) - q/3.
z(3) = 2.*dsqrt(-g/3.)*dcos(phi/3. + 4.188790) - q/3.
zl = dmin1 (z(1),z(2),z(3))
zv = dmax1 (z(1),z(2),z(3))
return
END

SUBROUTINE FUGA_P_CUB (n_eos, a, b, c, v, T, p, f, df)


implicit double precision (a-h,o-z)
R = 0.08314
!L.bar/mol/K!
*
*
*
*
*

.........................................................
f is ln(f/p) of the liquid and vapor phase for vliq and
vvap respectively. df is df(p)/dp needed to calculate
p_saturation(T).
.........................................................

z = p*v/R/T
RT = R*T
u=c
if (n_eos .eq. 2) then
two = 2.
f = dsqrt(two)*a*dlog((v+(1.-dsqrt(two))*b)/(v+
+
(dsqrt(two)+1.)*b))/(b*RT)/4. - dlog(z) +
dlog(v-b) + dlog(v) + z - 1.
df = v/RT - 1./p
endif
*
*
*

write(*,*)'z,a,b,c,v,t,p,rt'
write(*,*)z,a,b,c,v
write(*,*)t,p,rt
if (n_eos .eq. 3) then
f = -dlog(z)+z+(a*dsqrt(c**2+6.*b*c+b**2)*dlog(-(-2.*
+
v**2+dsqrt(c**2+6.*b*c+b**2)*(2.*v+c+b)+(-2.*c-2.
+
*b)*v-c**2-4.*b*c-b**2)/(v**2+(c+b)*v-b*c)/2.0)+
c**2*RT*dlog(v-b)-6.*b*c*RT*dlog(v-b)-b**2*RT
+
*dlog(v-b)+c**2*RT*dlog(v)+6.*b*c*RT*dlog(v)+b
+
**2*RT*dlog(v))/((c**2+6.*b*c+b**2)*r*t)-1.
*
write(*,*)'fmz',f
t1 = a*dlog(-(-2.*v**2+dsqrt(c**2+6*b*c+b**2)*(2.*v+c+b)+
+ (-2.*c-2.*b)*v-c**2-4*b*c-b**2)/(v**2+(c+b)*v-b*c)/2.0)
+ /(dsqrt(c**2+6*b*c+b**2)*r*t)
t2 = -dlog(p*v/(r*t))
t3 = -c**2*dlog(v-b)/(c**2+6*b*c+b**2)
t4 = -6*b*c*dlog(v-b)/(c**2+6*b*c+b**2)
t5 = -b**2*dlog(v-b)/(c**2+6*b*c+b**2)
t6 = c**2*dlog(v)/(c**2+6*b*c+b**2)
t7 = 6*b*c*dlog(v)/(c**2+6*b*c+b**2)
t8 = b**2*dlog(v)/(c**2+6*b*c+b**2)
t9 = p*v/(r*t)
t10 = -1

f = t1+t2+t3+t4+t5+t6+t7+t8+t9+t10
write(*,*)'fnew',f

df = (z - 1.)/p
endif
if (n_eos .eq. 4) then
f = -dlog(z)+z+(a*dsqrt(u**2+4.*u)*dlog(-(-2.*v**2+
+
dsqrt(u**2+4.*u)*(2.*b*v+b**2*u)-2.*b*u*v-b**2*u**2
+
-2.*b**2*u)/(2.*v**2+2.*b*u*v-2.*b**2*u))+(-b*RT*
+
u**2-4.*b*RT*u)*dlog(v-b)+(b*RT*u**2+4.*b*RT*u)*
+
dlog(v))/(b*RT*u**2+4.*b*RT*u)-1.

df = (z - 1.)/p
endif
return
END

SUBROUTINE FUGA_P_CUB (nc, n_eos, ic, z, a, b, c, am, bm, cm,


+
v, T, p, f, dfdp, n_kij, kij, prkij)
implicit double precision (a-h,o-z)
double precision z(5), a(5), b(5), c(5), f, dfdp,
+
kij(5,5), prkij(5,5)
R = 0.08314
* .........................................................
* f is ln(f/p) of the liquid and vapor phase for vliq and
* vvap respectively. df is df(p)/dp needed to calculate
* bubble point pressure.
* .........................................................
if (n_kij .eq. 1 .or. n_kij .eq. 2 .or. n_kij .eq. 4) then
sum = 0.
i=1
do while (i .le. nc)
sum = sum + z(i)*dsqrt(a(ic)*a(i))*
+
(1.-kij(ic,i))
i=i+1
end do
endif
if (n_kij .eq. 3) then
term1 = 0.
term2 = 0.
term3 = 0.
i=1
do while (i .le. nc)
term1 = term1 + z(i)*(dsqrt(a(ic)*a(i))*(1.-prkij(ic,i)+
+
(prkij(ic,i)-prkij(i,ic))*z(ic)) + dsqrt(a(i)*a(ic))
+
*(1.-prkij(i,ic)+(prkij(i,ic)-prkij(ic,i))*z(i)))
term2 = term2 + z(i)*(prkij(ic,i)-prkij(i,ic))*
+
dsqrt(a(ic)*a(i))
j=1
do while (j .le. nc)
term3 = term3 + z(i)**2*z(j)*(prkij(i,j)-prkij(j,i))*
+
dsqrt(a(i)*a(j))
j=j+1
end do
i=i+1
end do

sum = (term1 + z(ic)*term2 - term3)/2.


endif

if (n_eos .eq. 2) then


f = b(ic)*(p*v/r/t-1.)/bm - dlog(p*v/r/t-bm*p/r/t) +
+
(am/(2.8284*bm*r*t))*(b(ic)/bm-2.*sum/am)*
+
dlog((v+2.4142*bm)/(v-0.4142*bm))
t1 = b(ic)*p/(bm*r*t) - 1./(v-bm) - am*(b(ic)/bm-2.*sum/am)/
+
(r*t*(v+2.4142*bm)*(v-0.4142*bm))
dvdp = (v-bm)**2*(v**2+2.*bm*v-bm**2)**2/(-r*t*(v**2+2*bm*v+
bm**2)**2+am*(2.*v+2.*bm)*(v-bm)**2)
dfdp = b(ic)*v/(bm*r*t) - 1./p + t1*dvdp
endif
if (n_eos .eq. 3) then
t1 = dsqrt(cm**2+6.*bm*cm+bm**2)
t2 = v**2+v*(bm+cm)-bm*cm
t3 = -bm*cm**3-5.*bm**2*cm**2+5.*bm**3*cm+bm**4
t4 = ((bm*cm+3.*bm**2)*c(ic)+3.*bm*b(ic)*cm+bm**2*b(ic))*t1*t2
+
*dlog((-2.*t1*v+2.*t2-(cm+bm)*t1+cm**2+6.*bm*cm+bm**2)/
+
(2.*t2))
t4 = t4 + ((bm*cm**3+9.*bm**2*cm**2+19.*bm**3*cm+3.*bm**4)*
+
c(ic)+3.*bm*b(ic)*cm**3+19.*bm**2*b(ic)*cm**2+9.*bm**3*
+
b(ic)*cm+bm**4*b(ic))*v+(bm*c(ic)-b(ic)*cm)*t3
t5 = t2*(bm*cm**4+12.*bm**2*cm**3+38.*bm**3*cm**2+12.*bm**4*cm
+
+bm**5)
t6 = (2.*v**2+2.*(-t1+cm+bm)*v-bm*t1+cm*(4.*bm-t1)+bm**2+cm**2)
+
/(2.*v**2+2.*(cm+bm)*v-2.*bm*cm)
f = dlog(v/(v-bm))+b(ic)/(v-bm)+2*sum*dlog(t6)/(r*t*t1)-am*t4/
+
(t5*r*t)-dlog(p*v/r/t)
t1 = dsqrt(bm*cm+(bm+cm)**2/4.)
t3 = v+(bm+cm)/2.
t6 = -1./p
t7 = -(v-bm+b(ic))/(v-bm)**2+2.*sum/(r*t*(t3**2-t1**2))
+
-am*t3*(b(ic)+c(ic))/(r*t*(t3**2-t1**2)**2)
t8 = am*(c(ic)*(3.*bm+cm)+b(ic)*(3.*cm+bm))*(-1./(t3**2-t1**2)+
+
(-t3**2-t1**2)/(t3**2-t1**2)**2)/(4.*t1**2*r*t)
t9 = -r*t/(v-bm)**2+am*(2.*v+bm+cm)/(v**2+(bm+cm)*v-bm*cm)**2
dfdp = t6 + (t7+t8)/t9
endif
if (n_eos .eq. 4) then
t1 = dsqrt(cm**2+4.*bm*cm)
t2 = (cm+2.*bm)*c(ic)+2.*b(ic)*cm
t3 = v**2+cm*v-bm*cm
t4 = cm**2+4.*bm*cm
t5 = t1*t2*t3*dlog((t4+2.*t3-2.*t1*v-cm*t1)/(2.*t3))+
+
t2*t4*v+b(ic)*t4**2-(bm*cm*c(ic)+4.*bm*b(ic)*cm)*t4
t6 = t3*t4**2
t7 = dlog((2.*v**2-t1*(2.*v+cm)+2.*cm*v+cm**2+2.*bm*cm)/
+
(2.*v**2+2.*cm*v-2.*bm*cm))

f = dlog(v/(v-bm))+b(ic)/(v-bm)+2*sum*t7/(r*t*t1)-am*t5/
+
(t6*r*t)-dlog(p*v/r/t)
t8 = t4+2.*t3-2.*t1*v-cm*t1
t9 = t1*t2*(-2.*t1*t3-2.*v*t4+4.*t1*v**2+cm**2*t1+4.*cm*t1*v+
t4*cm)/t8+dlog(t8/2./t3)*t1*t2*(2.*v+cm)+t2*t4
t10= t4**2*(2.*v+cm)
t11= -b(ic)/(v-bm)**2 - bm/v/(v-bm) - 1./v + (2.*sum/(r*t*t1
+
*dexp(t7)))*((4.*v-2.*t1+2.*cm)/2./t3-(2.*v+cm)*dexp(t7)
+
/t3)-am*(t6*t9-t5*t10)/(r*t*t6**2)
t12= -r*t/(v-bm)**2+am*(2.*v+cm)/(v**2+cm*(v-bm))**2
dfdp = -1./p + t11/t12
endif
return
END

SUBROUTINE BUBLP (nc, id_fl, n_eos, pexp, T, x, yexp, n_av, n_kij,


+
kij, prkij, p, y)
implicit double precision (a-h, o-z)
double precision x(5), y(5), yexp(5), a(5), b(5), c(5),
+
fugl(5), fugv(5), dfdp_l(5), dfdp_v(5), Tr(5),
+
eqk(5), kij(5,5), prkij(5,5), ps(5), dkdp(5)
integer id_fl(5)
character*10 flname
R = 0.08314
* ...........................................................
* This routine calculates bubble pressure of a multicomponent
* mixture. If experimental data is available, n_av is
* equal to 1, otherwise it is set to 0.
* ...........................................................
* Set calculation parameters here...
iterPmax = 2000
iterymax = 400
* If available, use experimental p & {yi} data as initial guesses...
if (n_av .eq. 1) then
p = pexp
i=1
do while (i .le. nc)
y(i) = yexp(i)
i=i+1
end do
endif
* or, use Raoult's law...

if (n_av .eq. 0) then


p = 0.
i=1
do while (i .le. nc)
call fluid_prop (id_fl(i), Tc, pc, Tmin, flname,
+
ac_f, zc, f_wght)
tr(i) = t/tc
ps(i) = vap_pres (id_fl(i), Tr(i))
p = p + x(i)*ps(i)
i=i+1
end do
i=1
do while (i .le. nc)
y(i) = x(i)*ps(i)/p
i=i+1
end do
endif

* Begin iteration, outer loop is to adjust P...


sumkxm1 = 1.
iterP = 1
do while (dabs(sumkxm1) .gt. 0.0001)
* Calculate fugacity coefficients...
* For saturated vapor...
call mixparam (nc, id_fl, n_eos, T, p, y, n_kij, kij,
+
prkij, a, b, c, am, bm, cm, vl, vv)
icomp = 1
do while (icomp .le. nc)
if (n_eos .eq. 1) then
call fuga_p_qph (nc, icomp, y, a, b, c, am, bm, cm, vv,
+
T, p, fugv(icomp), dfdp_v(icomp),
+
n_kij, kij, prkij)
else
call fuga_p_cub (nc, n_eos, icomp, y, a, b, c, am, bm,
+
cm, vv, T, p, fugv(icomp),
+
dfdp_v(icomp), n_kij, kij, prkij)
endif
icomp = icomp + 1
end do
* For saturated liquid...
call mixparam (nc, id_fl, n_eos, T, p, x, n_kij, kij,
+
prkij, a, b, c, am, bm, cm, vl, vv)
icomp = 1
do while (icomp .le. nc)
if (n_eos .eq. 1) then
call fuga_p_qph (nc, icomp, x, a, b, c, am, bm, cm, vl,
+
T, p, fugl(icomp), dfdp_l(icomp),
+
n_kij, kij, prkij)

else
call fuga_p_cub (nc, n_eos, icomp, x, a, b, c, am, bm,
+
cm, vl, T, p, fugl(icomp),
+
dfdp_l(icomp), n_kij, kij, prkij)
endif
icomp = icomp + 1
end do
* Find K values...
sumkx = 0.0
i=1
do while (i .le. nc)
eqk(i) = dexp(fugl(i))/dexp(fugv(i))
sumkx = sumkx + eqk(i)*x(i)
i=i+1
end do
oldsum = sumkx
* Begin iteration to stabilize sum of ki*xi...
diffkx = 0.001
itery = 1
do while (dabs(diffkx) .gt. 0.0001)
i=1
do while (i .le. nc)
y(i) = eqk(i)*x(i)/sumkx
i=i+1
end do
* Recalculate vapor phase fugacity coefficient...
call mixparam (nc, id_fl, n_eos, T, p, y, n_kij, kij, prkij,
+
a, b, c, am, bm, cm, vl, vv)
i=1
do while (i .le. nc)
if (n_eos .eq. 1) then
call fuga_p_qph (nc, i, y, a, b, c, am, bm, cm,
+
vv, T, p, fugv(i), dfdp_v(i),
+
n_kij, kij, prkij)
else
call fuga_p_cub (nc, n_eos, i, y, a, b, c, am, bm,
+
cm, vv, T, p, fugv(i), dfdp_v(i),
+
n_kij, kij, prkij)
endif
i=i+1
end do
* Find K values with ...
sumkx = 0.0
i=1
do while (i .le. nc)
eqk(i) = dexp(fugl(i))/dexp(fugv(i))
sumkx = sumkx + eqk(i)*x(i)
i=i+1

end do
diffkx = oldsum - sumkx
oldsum = sumkx
itery = itery + 1
if (itery .eq. iterymax) then
write(*,1)
stop
endif
end do
* Adjust P by Newton Raphson formula...
dfdp = 0.
i=1
do while (i .le. nc)
dkdp(i) = eqk(i)*(dfdp_l(i)-dfdp_v(i))
dfdp = dfdp + x(i)*dkdp(i)
i=i+1
end do
fp = sumkx - 1.
pnew = p - fp/dfdp
diffP = pnew - p
*
write(*,5) p, pnew, diffp
p = pnew
iterP = iterP + 1
sumkxm1 = fp
if (iterP .eq. iterPmax) then
write(*,2)
stop
endif
end do
* Convergence achieved, end of calculations...

1
2
3
4
5

format(5x,'excessive iteration for sum ki*xi')


format(5x,'excessive iteration for p')
format(5x,'p=',f7.3,3x,'pexp=',f7.3,3x,f7.3)
format(5x,'y=',f7.4,3x,'yexp=',f7.3,3x,f7.3)
format(5x,'p, pnew, diffp=',3(f8.4,3x))
return
End

Das könnte Ihnen auch gefallen