Beruflich Dokumente
Kultur Dokumente
................................................
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,
369.8,
513.9,
400.0,
460.4,
378.8,
425.2,
536.8,
437.8,
553.5,
304.1,
38.0,
51.7,
44.0,
40.7,
73.8,
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/
*
*
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)
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
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)
.........................................................
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.
*
*
*
*
*
*
*
*
*
*
.........................................................
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
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
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