ClassProjectPart2

advertisement
ECH 4123 Class Project
Part 2
Frank Wang
July 5, 2006
Introduction
This program uses the Peng-Robinson Equation of State to calculate the molar volume,
departure enthalpy and entropy, change of enthalpy and entropy of ideal gas, and the
change of enthalpy and entropy for real gas. This program also calculates the specific
internal energy, specific Gibbs free energy, and Helmboltz free energy. The required
input is temperature and pressure. The solution of the Peng-Robinson Equation is solved
by using the “Cubic Formula”. The equation is transformed to depressed form,
x3 + p*x + q = 0, then use the method discovered by Scipione dal Ferro to solve for the
roots. The calculated thermodynamic properties use the ideal gas reference state as 25C
and 1 bar.
Theory
RT
a(T )
. For this

V  b V (V  b)  b(V  b)
program, the parameters for oxygen are used. They are the following,
The Peng-Robinson Equation of State is P 
R 2TC2
a (T )  0.45724
 (T )
PC
b(T )  0.07780
RTC
PC
[ (T )]1 / 2  1   (1 
T
)
TC
  0.4069
TC  154.6 K
PC  5.046 MPa
In the program the Peng- Robinson Equation uses the form Z 3  Z 2  Z    0 ,
where
  1  B
  A  3B 2  2 B
   AB  B 2  B 3
Z  PV / RT
A  aP( RT ) 2
B  bP / RT
The departures of enthalpy and entropy are calculated by using
And, the changes of enthalpy and entropy for ideal gas are computed by using
The internal energy, Gibbs free energy and Helmboltz free energy are calculated based on
the enthalpy and entropy computed since pressure and temperature are given.
U  H  P  V
G  H  T  S
A  U  T  S
Sample Outputs
The following sample calculation uses the parameters for oxygen. The result is changes
in enthalpy and entropy for different temperature and pressure. Then the result is
compared to Table 4.4-4 to validate the computation.
Input:
P (Pa) =
T (K) =
a=
b=
Z=
da/dT =
A=
B=



Cp* =
Output:
V (m3/mol)
[H-HIG]T,P (J/mol)
HIG(T2,P2)-HIG(T1,P1) (J/mol)
H(T2,P2)-H(T1,P1) (J/mol)
[S-SIG]T,P (J/mol*K)
SIG(T2,P2)-SIG(T1,P1) (J/mol*K)
S(T2,P2)-S(T1,P1) (J/mol*K)
[U-UIG]T,P (J/mol)
UIG(T2,P2)-UIG(T1,P1) (J/mol)
U(T2,P2)-U(T1,P1) (J/mol)
G (J/mol)
A (J/mol)
State 1 (Ref)
100000
298.15
1.086E-01
2.005E-06
6.650E-01
-2.446E-04
1.768E-03
8.090E-05
-9.999E-01
1.606E-03
-1.365E-07
State 2
500000
423.15
8.252E-02
2.005E-06
6.637E-01
-1.789E-04
3.334E-03
2.850E-04
-9.997E-01
2.764E-03
-8.689E-07
a
b
1.519E-02
25.46
1.648E-02
-841.417
-3.408
-10.883
4.670E-03
-1217.007
3757.790
2540.783
-3.450
-3.028
-6.478
-33.472
4797.040
4774.451
5281.934
7515.603
c
-7.150E-06
d
1.311E-09
Verify sample output with textbook data:
Data Verification (from Table 4.4-4)
State 1
Pressure (bar):
Temperature (K):
V (m^3/kmol)
H (J/mol)
S (J/mol*K)
DH (J/mol)
DS (J/mol*K)
U (J/mol)
G (J/mol)
A (J/mol)
1
298
24.77
-9.44
-0.02
0
0
State 2
5
423
7.033
3734.44
-2.92
3743.88
-2.9
7260.38
4979.04
8495.54
Appendix
The appendix includes the VBA program coding in Microsoft Excel and function library
used in the cells.
VBA coding:
Option Explicit
Private a2 As Double, a1 As Double, a0 As Double
Private p As Double, q As Double, Pcap As Double, Qcap As Double, R As Double
Private x1 As Double, x2 As Double, x3 As Double, Z As Double
Private i As Integer, theta As Double, PI As Double
Sub eos()
PI = 4 * Atn(1)
For i = 2 To 3
a2 = Cells(11, i).Value
a1 = Cells(12, i).Value
a0 = Cells(13, i).Value
p = (1 / 3) * (3 * a1 - a2 ^ 2)
q = (1 / 27) * (2 * a2 ^ 3 - 9 * a1 * a2 + 27 * a0)
R = q ^ 2 / 4 + p ^ 3 / 27
If R > 0 Then
Pcap = (-q / 2 + Abs(R)) ^ (1 / 3)
Qcap = WorksheetFunction.Power((-q / 2 - Abs(R)), (1 / 3))
x1 = Pcap + Qcap
Z = x1
ElseIf R = 0 Then
x1 = 2 * (-q / 2) ^ (1 / 3)
x2 = (q / 2) * (1 / 3)
x3 = x2
Z = WorksheetFunction.Max(x1, x2, x3)
ElseIf R < 0 Then
If q = 0 Then
theta = PI / 2
ElseIf q < 0 Then
theta = -Atn((Abs(R) ^ 0.5) / (q / 2))
ElseIf q > 0 Then
theta = PI - Atn((Abs(R) ^ 0.5) / (q / 2))
End If
x1 = 2 * (q ^ 2 / 4 + Abs(R)) ^ (1 / 6) * Cos(theta)
x2 = (q ^ 2 / 4 + Abs(R)) ^ (1 / 6) * (Cos(theta / 3) - (3) ^ 0.5 * Sin(theta / 3))
x3 = (q ^ 2 / 4 + Abs(R)) ^ (1 / 6) * (Cos(theta / 3) + (3) ^ 0.5 * Sin(theta / 3))
Z = WorksheetFunction.Max(x1, x2, x3)
End If
Cells(7, i).Value = Z
Next i
End Sub
Download