Sei sulla pagina 1di 40

Page |1

Final Term Project

Design of a Surface Production Facility

Waleed A., Abdul M., Mitchell J., Khalil K., Mohammed M.


The Pennsylvania State University
Petroleum and Natural Gas Engineering 480
April 24, 2014

Page |2

Table of Contents
Progress Report I .. 3
Progress Report II . 4
Progress Report III ... 5
First Separator .. 6
Second Separator .13
Stock Tank . 17
Glycol Dehydration 20
Glycol Tower Design ..22
Hydrates ..23
Module A Matlab Code ...24
Module B Matlab Code ...27
Module C Matlab Code Validation 1 ..31
Module C Matlab Code Validation 2 ..36

Page |3
Progress Report I:

P(psia)
T(F)
220
500
270
500
320
500
370
500
420
500
470
500
520
500
570
500
620
500
670
500
720
500
770
500
820
500
870
500
920
500
970
500
1020
500
1070
500
1120
500
1170
500
1220
500
1270
500
1320
500
1370
500
1420
500
1470
500
1520
500
1570
500
1620
500
1670
500
1720
500
1770
500
1820
500

480Mix1.txt
Zmin
Zmax
0.986806 0.986806
0.984075 0.984075
0.981444 0.981444
0.978914 0.978914
0.976485 0.976485
0.974157 0.974157
0.971931 0.971931
0.969806 0.969806
0.967783 0.967783
0.965862 0.965862
0.964042 0.964042
0.962323 0.962323
0.960706 0.960706
0.959189 0.959189
0.957772 0.957772
0.956455 0.956455
0.955238 0.955238
0.954118 0.954118
0.953097 0.953097
0.952173 0.952173
0.951345 0.951345
0.950612 0.950612
0.949973 0.949973
0.949428 0.949428
0.948976 0.948976
0.948614 0.948614
0.948342 0.948342
0.948159 0.948159
0.948064 0.948064
0.948055 0.948055
0.948132 0.948132
0.948291 0.948291
0.948534 0.948534

480Mix2.txt
Zmin
Zmax
0.995941 0.995941
0.995134 0.995134
0.994369 0.994369
0.993647 0.993647
0.992967 0.992967
0.992329 0.992329
0.991732 0.991732
0.991177 0.991177
0.990663 0.990663
0.990189 0.990189
0.989757 0.989757
0.989364 0.989364
0.989012 0.989012
0.988699 0.988699
0.988426 0.988426
0.988192 0.988192
0.987997 0.987997
0.987841 0.987841
0.987722 0.987722
0.987642 0.987642
0.987599 0.987599
0.987593 0.987593
0.987623 0.987623
0.987691 0.987691
0.987794 0.987794
0.987933 0.987933
0.988107 0.988107
0.988317 0.988317
0.988561 0.988561
0.988839 0.988839
0.989151 0.989151
0.989496 0.989496
0.989875 0.989875

480Mix3.txt
Zmin
Zmax
0.867912 0.867912
0.837147 0.837147
0.8062
0.8062
0.775181 0.775181
0.744257 0.744257
0.713686 0.713686
0.683847 0.683847
0.655264 0.655264
0.62861 0.62861
0.604648 0.604648
0.584103 0.584103
0.567476 0.567476
0.554922 0.554922
0.546243 0.546243
0.541003 0.541003
0.538669 0.538669
0.538715 0.538715
0.540679 0.540679
0.544177 0.544177
0.548902 0.548902
0.554611 0.554611
0.561114 0.561114
0.568259 0.568259
0.575929 0.575929
0.584031 0.584031
0.592488 0.592488
0.60124 0.60124
0.610239 0.610239
0.619445 0.619445
0.628824 0.628824
0.63835 0.63835
0.648
0.648
0.657754 0.657754

Page |4
Progress Report II:
In Module A, the objective was to complete a program to calculate Z factors for a
compositional simulation. The compositionally based calculation of fluid volumetric behavior
relies on The Equations of State (EOS) for the calculation of Z factors. The equation that we
implemented for the completion of Module A was Peng- Robinson Equation of State. That
was used to illustrate this powerful fluid behavior modeling approach.
In Module B, the objective was to build upon Module A and to obtain the
P(psi)
220
270
320
370
420
470
520
570
620
670
720
770
820
870
920
970
1020
1070
1120
1170
1220
1270
1320
1370
1420
1470
1520
1570
1620
1670
1720
1770
1820

T(F)
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500
500

k(c1)
12.47612
10.34462
8.842532
7.726641
6.864725
6.178725
5.619587
5.154932
4.762527
4.4266
4.135647
3.881083
3.65637
3.456438
3.277297
3.115763
2.96926
2.835687
2.713304
2.600665
2.496552
2.399931
2.30992
2.225757
2.146781
2.07241
2.002133
1.93549
1.872064
1.811472
1.753352
1.697356
1.643129

K(c2)
ALFA(L)
0.5172 0.00391
0.449179
0.1458
0.402277
0.2272
0.368388
0.2827
0.343107
0.3241
0.323839
0.3571
0.308955
0.3847
0.297386
0.4087
0.288399
0.4302
0.28148
0.45
0.276258
0.4686
0.272459
0.4863
0.26988
0.5034
0.268369
0.5201
0.267809
0.5367
0.268114
0.5532
0.26922
0.5697
0.27108
0.5864
0.273664
0.6034
0.276954
0.6209
0.280942
0.6387
0.285634
0.6572
0.291043
0.6764
0.297194
0.6965
0.304124
0.7175
0.31188
0.7396
0.320524
0.7631
0.330136
0.7881
0.340814
0.8148
0.352683
0.8437
0.365901
0.8752
0.380671
0.9097
0.397261
0.9479

Page |5
Progress Report III:
In Module A, the objective was to complete a program to calculate Z factors for a
compositional simulation. The compositionally based calculation of fluid volumetric behavior
relies on The Equations of State (EOS) for the calculation of Z factors. The equation that we
implemented for the completion of Module A was Peng- Robinson Equation of State. That
was used to illustrate this powerful fluid behavior modeling approach.
In Module B, the objective was to build upon Module A and the implementation of the
Rachford-Rice Equation for Binary Mixtures. (The calculation of alpha g and alpha l).We also
applied the Peng Robinson (EOS) to improve (Ki) values, which is simply the volatility ratio.
The easiest the part of the coding was obtaining the values of A, B, and Z parameters
because we already had the code from Module A. That was the only easy task that we
encountered. To be honest, Module B was challenging due the problem we were having with
a writing a code that will do an iteration for all the GUF values to equal to each other
depending the K values.
Now, we are on to Module C which is in laymans terms a more complicated/ bigger
version of what we did in Module C. In this module, we use all the thermodynamic tools
given to use throughout the semester for the prediction of liquid and vapor co-existence in
equilibrium and the composition of the resulting phases. As I mentioned before, this module
is an extension of Module B by expanding the thermodynamic calculations of the previous
module to multi-component mixtures. These calculations will be used in the actual design of
the surface production facility, which will be due in two weeks. Some of the difficulties that
we encountered were finding a reasonable time for all of us to meet, especially this time of
the semester. Also, programming wide, we had difficulties in figuring out how to incorporate
our code to function with Mix 1 due to the large number of components.

Page |6

First Separator: (Stage I)


3-P= 900 psia, T = 65 F, g1 = 0.73395, g = 3.9369 lb/ft3
l = 40.48034 lb/ft3, MWg = 20.2024 lbm/lb-mol, MWl = 78.0184 lbm/lb-mol
APIo = 82.6207

Convert the unit from reservoir ft3 to lb-mol/D.


lb

(Pres [psia] MW [lb/lbmol])

[ft3] = (Zres R [psiaft3/(lbmolR)] T [R])


[

] = [

[/3]

]
[/]

nF [lb

mol
RCF
] = qRC [
]
D
D

[]
(Zres R [psiaft3/(lbmolR)] T [R])

3
[
] [ ]

] = 252,000 [
]

mol
D

. . 4

]
4,250 []

0.860202461 10.73 [

nF = 188,776.1 [

--------------Eq.3

4,250 []

Solve eq.4 to obtain nF [lb

------------------Eq.2

Solve eq.1 to get eq.3 and Substitute into equation 2:


[lb/ft3]
MW [lb/lbmol]

----------------Eq.1

3
] 614.67 []

Obtain
1= = 188,776.1 [

0.73395 = 138,552.2 [

1= = 188,776.1 [

0.26605 = 50,223.88 [

]----------Eq.

]---------Eq.

4i

4ii

Gas volumetric rate:


ft3

qg ( s ) =

ng [

] MW

[ ]

[lb/lbmol]

[86400s] ----------------------------------Eq.5

138,552.2 [ ] 20.2024 [lb/lb mol]


ft3
D
ft3
qg ( ) =
[
] = 8.229 ( )

s
86400s
s
3.9369 [ ]

Page |7

Oil volumetric rate


ft3

qo ( s ) =

no [

] MW

[lb/lbmol]

[ ]

50,223.88 [


] 78.0185 [lb/lb mol]

[
40.48034 [

[1440minute] ----------------------------------Eq.6

D
ft3
] = 67.22 (
)
1440minute
min

We need to identify the flow rate of water. It is given that 0.3 of produced condensate
in the stock tank is water.
qosc (

)=[

(11 )(12 )(13 )nF [lb

mol
] MW
D

[lb/lbmol]

]--------------------Eq.7

5.615 [ ]

(1 0.73395) (1 0.33798) (1 0.2955) 188,776.1 [lb

qosc ( ) =

5.615 40.48034 [ ]

mol] 78.0185 [lb mol]


D
lb

qosc ( ) = 8040.185 ( )

] = 0.3 [ ] = 0.3 8040.185 = 2412.056 [ ]

3
[
] = 2412.056 [ ] (6.5 105 [ ] 60 [
]
]) = 9.407 [

The velocity of oil particle in gas phase is given by the following the equation:
1

vtog

2
ft
lb
lb
ft
4 g [s2] dpog [m] o [ft3] g [ft3]
[ ] = [(

)] Eq. 8
lb
s
3
CD
g [ ]
ft3

We will run several iterations until the difference in velocity is zero which is
demonstrated in the excel file.
1

vtog

2
ft
lb
lb
ft
4 g [s 2 ] dpog [m] o [ft3] g [ft3]
[ ] = [(

)] Eq. 9
lb
s
3
CD
g [ ]
ft3

The Reynolds Number is given by:


lb
ft
(g [ ] dpog [m] vtog [ s ])
ft3
=
. 10
lb
[

fts

The drag coefficient equation is given by:


=

24
3
+
+ 0.34 . . 11

Page |8
ft
ft
vtog [ ] = 0.34903479 [ ]
s
s

The velocity of water particle in oil phase is given by:


vtwo

ft
[ ]=
s

ft
2
2
1 g [s 2 ] dpwo [m ]
lb
lb

(w [ ] o [ ]) Eq. 12
lb
18
ft3
ft3
o [ ]
ft3
(
)
ft
ft
vtwo [ ] = 0.259631 [ ]
s
s

(Please refer to the attached excel file for the numbers and calculations)
1) Vertical
a. Gas Constraint:
ft3
qg [ ]
4
s
Dv|g [ft] ( )
. 13
vtog ft
[s]
Dv_og(ft)
qg
ft^3/s
8.229
vg
ft/s
0.32327912
Dv
ft
5.692981374
Dv(rounded) ft
6
b. Water constraint:
ft3
qo [ s ]
4
Dv|w [ft] ( )
vtwo ft
[s]

. 14

Dv_wo(ft) water settling


vtwo
ft/s
0.259631
qo
ft^3/s 1.120333
Dv_wo
ft
2.343961
Dv rounded
ft
2.5

Page |9
c. Liquid constraint:
ft3
ft3
4 qo [min] [] + [min]
Hlc [ft] = ( )
. 15

D2v [ft 2 ]
qo
Oil
Density
tro
Dvog
Dvog^2
qw
trw
Hlc

Hlc (ft)
ft^3/min

67.22

API
86.6207
min
4
ft
6
ft^2
36
ft^3/min
9.407
min
4
ft
10.84050295

Since API > 35o the retention time of oil and water is estimated to be 3-5 minutes.

Hvd [ft] = max {Dv, 3 ft}


Hil [ft] = max { Dv, 2 ft}
Hme [ft] = 1.5 ft (assuming we have a mist eliminator)

Simplified Height:
[] = +

76
40
( < 3) + + ( > 3) . 17
12
12
Ht(ft) Total length Simplified method
Hlc
ft
10.84050295
Dvog
ft
6
Ht
ft
20.17383629
Ht(rounded)
ft
21

By using the simplified method, the volume can be calculated by:


[ 3 ] =

2 [ft2] Ht [ft] . 18
4

(Please refer to the attached excel file for the numbers and calculations)

P a g e | 10

CD
0.34
0.900056249
1.143094136
1.219395883
1.241376835
1.247561018
1.249289496
1.249771721
1.249906188
1.249943678
1.24995413
1.249957044
1.249957856
1.249958083
1.249958146
1.249958164
1.249958168
1.24995817
1.24995817
1.24995817
1.24995817

Vtog(ft/s)
0.619849045
0.380969817
0.33805269
0.327305296
0.32439457
0.323589557
0.323365625
0.323303234
0.323285842
0.323280994
0.323279642
0.323279266
0.323279161
0.323279131
0.323279123
0.323279121
0.32327912
0.32327912
0.32327912
0.32327912
0.32327912

Iteration Table
Re
95.08626253
58.44164206
51.85805661
50.20938174
49.76286973
49.63937877
49.60502715
49.59545616
49.59278831
49.59204457
49.59183723
49.59177942
49.59176331
49.59175881
49.59175756
49.59175721
49.59175711
49.59175709
49.59175708
49.59175708
49.59175708

New CD
0.900056249
1.143094136
1.219395883
1.241376835
1.247561018
1.249289496
1.249771721
1.249906188
1.249943678
1.24995413
1.249957044
1.249957856
1.249958083
1.249958146
1.249958164
1.249958168
1.24995817
1.24995817
1.24995817
1.24995817
1.24995817

Terminal Velocity (vtwo)


dpw
ft
0.001641
Water denstiy lb/ft^3
62.242
oil density
lb/ft^3 40.48034
oil viscosity
cp
0.6
vtwo
ft/s
0.259631

Terminal Velocity (vtog)


dpo
micron
100
oil density
lb/ft^3 40.48034443
gas density lb/ft^3 3.936902734
gas
viscostiy
cp
0.012575317
vt
ft/s
0.323285842

volume

ft^3

593.7610115

delta CD
0.560056249
0.243037886
0.076301747
0.021980952
0.006184183
0.001728477
0.000482225
0.0001345
0.0000375
0.0000105
0.0000029
0.0000008
0.0000002
0.0000001
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000

P a g e | 11

2) Horizontal
a. Gas Constraint:

. 19

(
)

Gas Capacity Constraint


fAg
fHg
Vt
qg
(L/D)eff
Dh gas

ft/s
ft^3/s
ft

0.5
0.5
0.319343
8.229
2.5
3.622681

b. Liquid Constraint:
3

4( + )
. 20

( )

Liquid Capactiy Constraint


tro, trw min
4
qo
ft^3/min
67.22
qw
ft^3/min
9.407
fAL
0.5
(L/D)eff
2.5
Dh liq
ft
6.783919
c. Water Constraint:

. 21

Dh water settling
Vtwo
ft/s
17618.34
tro
min
4
fHo
0.38
Dh ws
ft
185456.2
Dh max (6.5 ft) < Dh ws(19.5 ft)

We will use Excel to decide which diameter and length is economical. Note that the
slenderness ratio (Lt/D) should be between 3 and 4.

P a g e | 12
L
Leff = ( ) . 22
D eff
4
= . 23
3
= + . 23
(L/D)eff
NA
1.5
2
2.5
3
3.5
4
4.5
5
5.5

Dh gas
ft
1.120141
1.293427
1.446096
1.584118
1.711044
1.829182
1.940141
2.045088
2.144907

Dh liq
ft
8.043225
7.307755
6.783919
6.383912
6.064169
5.800169
5.576861
5.3844
5.216026

Dh max
ft
8.043225
7.307755
6.783919
6.383912
6.064169
5.800169
5.576861
5.3844
5.216026

Dh max
rounded
ft
8
7.5
7
6.5
6.5
6
6
5.5
5.5

Leff
ft
12
15
17.5
19.5
22.75
24
27
27.5
30.25

Lt
ft
16
20
23.33333
26
30.33333
32
36
36.66667
40.33333

Lt
rounded
ft
16
20
24
26
31
32
36
37
41

(Lt/D)
NA
2
2.666667
3.42857
4
4.769231
5.333333
6
6.727273
7.454545

(Please refer to the attached excel file for the numbers and calculations)
Volume Vertical
Volume Horizontal

ft^3
ft^3

593.7610115
923.6282402

From comparing the volumes: Our separator for the first stage would be Vertical

Sep Volume
ft^3
804.2477193
883.5729338
923.6282402
862.7598825
1028.675245
904.7786842
1017.87602
879.0568944
974.0900722

P a g e | 13

Second Separator: (Stage II)


2-P= 115.02 psia; T = 75 F, g2 = 0.337981729; g = 0.592818292 lb/ft3
l = 43.45823428 lb/ft3; MWg 27.57046641 lbm/lb-mol, MWl = 103.7737918 lbm/lb-mol

The produced gas is transferred to the glycol dehydration tower, while the oil is
moved to the second separator, hence, no,1 = nF,2 (lb-mol/D)
2 = 50,223.88


. 4

2= = 50,223.88 [

2= = 50,223.88 [

ft3

qg ( s ) =
ft3

qg ( s ) =

ng [

] MW

] (1-0.337982)

[lb/lbmol]

[ ]

16974.7538[

0.337981729=16974.7538[

]-------------Eq.

4i

4ii

*[86400s] ----------------------------------Eq.5

]27.570466 [lb/lbmol]

.[ ]

= 33249.1262[

]-------------Eq.

*[86400s] = 9.137 [

no [ ] MW [lb/lb mol]
ft3
D
qo ( ) =
[
]

s
1440minute
0 [ 3 ]



33249.1262 [
] 103.774 [
]
ft3
D
3

qo (
)=
[
]
] = 55.136 [

min
1440minute

43.458 [ 3 ]

Do the iteration of oil velocity in gas phase (use eqs. 8-10)

(Please refer to the attached excel file for the numbers and calculations)

P a g e | 14

1) Vertical

a. Gas Constraint:

ft3
qg [ s ]
4
Dv|g [ft] ( )
. 12
vtog ft
[s]
Dv(ft)
qg
ft^3/s
9.137
vg
ft/s
0.678550359
Dv
ft
4.140624329
Dv(rounded) ft
5
b. Liquid constraint:

ft3
ft3
4 qo [min] [] + [min]
Hlc [ft] = ( )
. 14

D2v [ft 2 ]
ql
Oil
Density
tr
Dv
Dv^2
Hlc

Hlc (ft)
ft^3/min
API
min
ft
ft^2
ft/s

55.136
71.6744
1
5
25
2.808053422

Simplified Height:
[] = +

76
40
( < 3) + + ( > 3) . 17
12
12
Ht(ft) Simlified
Hlc
ft
2.808053422
Dv
ft
5
Ht
ft
11.14138675
Ht(rounded)
ft
11.25

Ht
Dv
L/D

Slednderness Ratio
ft
11.25
ft
5
2.25

P a g e | 15
Since API > 35o the retention time of oil is estimated to be one minute because it is a two phase stage.
[ 3 ] =

CD
0.34
1.230556
1.814481
2.065371
2.159094
2.19247
2.204162
2.208234
2.209649
2.210141
2.210312
2.210371
2.210391
2.210399
2.210401
2.210402
2.210402
2.210402
2.210402
2.210402
2.210402
Volume

Vt(ft/s)
1.730128
0.909425
0.74893
0.70197
0.686565
0.68132
0.67951
0.678883
0.678666
0.67859
0.678564
0.678555
0.678552
0.678551
0.678551
0.67855
0.67855
0.67855
0.67855
0.67855
0.67855
ft^3

Re
51.00872
26.81225
22.08044
20.69593
20.24175
20.08709
20.03375
20.01527
20.00886
20.00663
20.00586
20.00559
20.0055
20.00546
20.00545
20.00545
20.00545
20.00545
20.00545
20.00545
20.00545
220.8932

New CD
1.230556
1.814481
2.065371
2.159094
2.19247
2.204162
2.208234
2.209649
2.210141
2.210312
2.210371
2.210391
2.210399
2.210401
2.210402
2.210402
2.210402
2.210402
2.210402
2.210402
2.210402

delta CD
0.890555846
0.583925563
0.250889695
0.093722753
0.033376526
0.011691375
0.00407197
0.0014154
0.0004917
0.0001707
0.0000593
0.0000206
0.0000071
0.0000025
0.0000009
0.0000003
0.0000001
0.0000000
0.0000000
0.0000000
0.0000000

(Please refer to the attached excel file for the numbers and calculations)
2) Horizontal
a. Gas Constraint:

. 19

(
)

Gas Capacity Constraint


fAg
fHg
Vt
qg
(L/D)eff
Dh gas

ft/s
ft^3/s
NA
ft

0.5
0.5
0.677145
9.137
2.5
2.621477

P a g e | 16
b.

Liquid Constraint:
3

4( )
. 20

()

Liquid Capactiy Constraint


trl
min
1
ql
ft^3/min
55.136
fAl
NA
0.5
(L/D)eff NA
2.5
Dh liq
ft
3.829527
Terminal Velocity (vt)
dp
micron
100
oil density
lb/ft^3 43.45823
gas density lb/ft^3 0.592818
gas viscostiy cp
0.009853
vt
ft/s
0.677145
L
Leff = ( ) . 21
D eff
4
= . 22
3
= + . 22
(L/D)eff
NA
1.5
2
2.5
3
3.5
4
4.5
5
5.5

Dh gas

Dh liq

Dh max

ft
1.718752
1.984644
2.2189
2.430683
2.625437
2.80671
2.976966
3.137998
3.29116

ft
4.540406
4.125233
3.82953
3.603723
3.423228
3.274199
3.148142
3.039497
2.94445

ft
4.540406154
4.125232761
3.829526864
3.603722753
3.423227602
3.274199413
3.148141797
3.137997717
3.291159771

Dh max
rounded
ft
4.5
4.5
4
4
3.5
3.5
3.5
3.5
3.5

Volume Vertical
Volume Vertical

Leff

Lt

ft
6.75
9
10
12
12.25
14
15.75
17.5
19.25

ft

ft^3
ft^3

9
12
13.33333333
16
16.33333333
18.66666667
21
23.33333333
25.66666667
220.8932
167.55161

From comparing the volumes: Our separator would be Horizontal

Lt
rounded
ft
9
12
13.5
16
16.5
19
21
23.5
26

(Lt/D)
NA
2
2.666667
3.375
4
4.714286
5.428571
6
6.714286
7.428571

Sep
Volume
ft^3
143.13882
190.85175
167.55161
201.06193
157.14508
179.59438
202.04368
224.49298
246.94227

P a g e | 17

Stock Tank: (Stage III)


2-P= 14.7 psia, T = 75 F, g3 0.295549173, g = 0.129822116lb/ft3, l = 45.02512197lb/ft3, MWg =
48.71448551lbm/lb-mol, MWl = 126.8736759 lbm/lb-mol, APIo = 64.604, GOR = 317.183 SCF/STB
2 = 3 = 33249.1262 [
3= 3 3 = 33249.1262 [
3= 3 3 = 33249.1262 [

)=

0.29554917 = 9826.752 [

] (1

[/]

[ 3 ]

]----------Eq.

0.2955492) = 23422.375 [

4i

]--------Eq. 4ii

[86400] ----------------------------------eq.5

9826.752 [ ] 48.7145[/ ]
3

3
( ) =
[
] = 42.678 [ ]

86400

0.129822116 [ ]
3

[ ] [/ ]
3

(
)=
[
]

1440
0 [ 3 ]



23422.375 [
] 126.874 [
]
3

(
)=
[
]
] = 45.834 [

1440

45.025 [ 3 ]

qosc ( ) =

(1 1 ) (1 2 ) (1 3 ) nF [lb
5.615 [

mol] MW [lb/lb mol]

(1 0.73395) (1 0.33798) (1 0.2955) 33249.1262 [lb

qosc ( ) =

5.615 45.025 [ ]

[
qosc (

) = 2070.4422 ( )

mol] 126.874 [lb mol]


D
lb
]

P a g e | 18
1) Vertical
Terminal Velocity (vt)
dp
micron
100
oil density
lb/ft^3 45.02512197
gas density lb/ft^3 0.129822116
gas
viscostiy
cp
0.007707202
vt
ft/s
1.109945881
a. Gas Constraint:

ft3
qg [ s ]
4
Dv|g [ft] ( )
. 12
vtog ft
[s]
Dv(ft)
qg
ft^3/s
42.678
vg
ft/s
1.109945505
Dv
ft
6.996909561
Dv(rounded) ft
5
b. Liquid constraint:

ft3
ft3
4 qo [min] [] + [min]
Hlc [ft] = ( )
. 14

D2v [ft 2 ]
ql
Oil
Density
tr
Dv
Dv^2
Hlc

Hlc (ft)
ft^3/min
API
min
ft
ft^2
ft/s

45.838
64.064
1
5
25
2.33451017

* API > 35o the retention time of oil is estimated to be one minute.

P a g e | 19

Simplified Height:
[] = +

76
40
( < 3) + + ( > 3) . 17
12
12
Ht(ft) Simlified
Hlc
ft
2.33451017
Dv
ft
5
Ht
ft
10.6678435
Ht(rounded)
ft
11.25

CD
0.34
1.645349
2.826827
3.467542
3.753624
3.872062
3.919665
3.938575
3.946052
3.949004
3.950168
3.950627
3.950808
3.95088
3.950908
3.950919
3.950923
3.950925
3.950926
3.950926
3.950926
Volume

Vt(ft/s)
3.783656
1.719975
1.312204
1.184787
1.138743
1.121192
1.114363
1.111685
1.110631
1.110216
1.110052
1.109987
1.109962
1.109952
1.109948
1.109946
1.109946
1.109946
1.109946
1.109946
1.109945
ft^3

Re
31.22912
14.19613
10.83053
9.778861
9.39883
9.253968
9.197604
9.175497
9.166799
9.163373
9.162023
9.16149
9.16128
9.161198
9.161165
9.161152
9.161147
9.161145
9.161144
9.161144
9.161144
220.8932

New CD
1.645349
2.826827
3.467542
3.753624
3.872062
3.919665
3.938575
3.946052
3.949004
3.950168
3.950627
3.950808
3.95088
3.950908
3.950919
3.950923
3.950925
3.950926
3.950926
3.950926
3.950926

delta CD
1.305349292
1.181477492
0.64071556
0.286081309
0.118438675
0.047602191
0.018910219
0.0074778
0.0029516
0.0011642
0.0004591
0.0001810
0.0000714
0.0000281
0.0000111
0.0000044
0.0000017
0.0000007
0.0000003
0.0000001
0.0000000

(Please refer to the attached excel file for the numbers and calculations)
We did not include the numbers for horizontal design here because we assumed it would be a
vertical design which is common. However, you may look at the excel sheet to see the numbers and
calculations for Horizontal Stock tank.

P a g e | 20
Glycol Dehydration: P= 900 psia, T = 75 F, Wout = 4.0

2
, g

= 3.93685

MWg = 20.2023. , g = 0.0125753165 cP

The gas is sweet.


= 1 + 2 +

= (138,552.25 + 16,974.75 + 9,826.752) [


qgsc = 62.76

ng = 165,353.002

Obtain the DP from GPSA Fig. 20-4.


2

1. P = 900 psia, T = 75 F Win = 35


2

2. P = 900 psia, Wout = 4.0 we can obtain from this DP = 15 F.


2

3. Water Target = ( ) [] [
2

Water Target = (35 4.0) [] 62.76 [

]= 1189.85

(2)

The dew point differences is (75 F 15 F) = 60 F


The facility temperature is 75 F, therefore is 15 F 20 F S.F = -5 F
= 99.25% wt
Glycol concentration = 0.13368 ft3

lb

TEG = 9.34
in Cuft
TEG = 69.868
Water material balance:

Water Target = TEG [


TEG = TEG [

lb

] * [

] = [

] * ( )

] [ 2 ]

lb
3

P a g e | 21

From above step we can obtain the Re


=

1
( )
]

[( [

( ))

We can obtain the t from the above obtain values.


= 96.86%

P a g e | 22
Glycol Tower Design:
Water removal ratio is

( )

Known variables

= 0.8857

( )
,

Re, and from GPSA Fig. 20-69 when N = 1

When N = 1, possible 0.855 of water removable and we are targeting to remove


0.8857 of water so we need to obtain values of N that a greater than 1.
We use GPSA Fig. 20-70 when N = 1.5
When N = 1.5, we were successful, therefore: N = 1.5.
Height calculation:
Hpacking = 3 5 = 15
[] = Hpacking + 8 = 23 ft
Diameter Calculation:

0.35

Due to structured packing.

[ ] = [ ] (

] [ ]
3
3

[ ]
3

0.5

= 3.93685 3 , = 69.868 3

[ ] = 0.35 [ ] (

[] = (

3
]

( [ ])

4 [

] 3.93685 [ ]
3
3

3.93685 [ ]
3

69.868 [

0.5

ft

1.984 s

.5

[ ] = [
] [
] [
] / [ ] [
]
( )

379.5
3
86400
qg = 9.84

ft3
s

Therefore:
= 3.57 4

From the height and diameter we calculated the volume


Vglycol tower = 289.03 ft 3

P a g e | 23

Hydrates:
Hydrates
qsc
73.9536872
Wellhead Pressure
>= 1150
First seperator P
900

MMSCFD
psi
psi

Pave

1025

psi

Reservoir T
Th
Facility T
MW mix
SG
d
Meoh density
MEG density

120
80
75
20.2023
0.697448733
5
32
62

F
F
F
lb/Lbmol

x
y1
y2
MW
m
loss
factor
Loss
MeOH
total

x
y1
y2
MW
m
MEG
total

MeOH
0.064128
85
25
4437.221
304.0494

F
lb/ft3
lb/ft4

%wt
lb/MMSCF
lb/MMSCF
lb/D
lb/D

2.05

lb/MMscf/%wt

972.2168

lb/D

1276.266

lb/D

MEG
0.117202
%wt
85
lb/MMSCF
25
lb/MMSCF
4437.221
lb/D
761.6493
lb/D
2621.747

lb/D

P a g e | 24

Module A Matlab Code:


clear all;
clc
BIC = [
0
0.005
0.01
0.015;
0.005
0
0.002
0.003;
0.01
0.002
0
0.001;
0.015
0.003
0.001
0;
];
c = [0.85 0.05 0.05 0.05 ];
a_alpha = [5054.16964643364 15593.64299014490 29340.79459022810
44218.28221581970];
b = [0.42971240173913 0.64876396662899 0.90391222842276 1.16135832835764 ];
R = 10.73;
aam=0.0;
bm=0.0;
for i=1:4
bm = bm + c(i)*b(i);
for j=1:4
aam= aam+ c(i)*c(j)*((a_alpha(i)* a_alpha(j))^0.5)*(1.0-BIC(i,j));
end;
end;
% aam
% bm
%Dimensionless attraction parameter (A) and co-volume parameter (B)
Pres = [220 270 320 370 420 470 520 570 620 670 720 770 820 870 920 970 1020
1070 1120 1170 1220 1270 1320 1370 1420 1470 1520 1570 1620 1670 1720 1770
1820];
Temp = 500+460;
for o = 1 :33
A=(aam*Pres(o))/((R^2.0)*(Temp^2.0));
B= bm*Pres(o)/(R*Temp);
% A
% B
%Peng-Robinson coefficients
a1 = -(1-B);
b1 = A-(3.*(B.^2)) - (2.*B);
c1 = -(A.*B) + (B.^2) + (B.^3);
% a1
% b1
% c1
k = [1 a1 b1 c1];
Z = roots(k);
Z_real = real(Z);
index = find(imag(Z)== 0);
if length(index)>1
Zreal = real(Z(index))
else
%execute this if there is just one real root

P a g e | 25
Z = real(Z(index));
end;
sprintf('%0.9f', Z)
end;
% Z = roots(k);
%z_ind = find(Z == real(Z));
%z_real = Z(z_ind)
%Zmax = max(z_real);
%Zmin = min(z_real);
%Z_real = real(Z)

clear all;
clc
BIC = [
0
0;
0
0;
];
c = [0.5 0.5];
a_alpha = [5054.169646433640 245329.975005538000
];
b = [0.42971240173913 3.04812175574524];
R = 10.73;
aam=0.0;
bm=0.0;
for i=1:2
bm = bm + c(i)*b(i);
for j=1:2
aam= aam+ c(i)*c(j)*((a_alpha(i)* a_alpha(j))^0.5)*(1.0-BIC(i,j));
end;
end;
% aam
% bm
%Dimensionless attraction parameter (A) and co-volume parameter (B)
Pres = [220 270 320 370 420 470 520 570 620 670 720 770 820 870 920 970 1020
1070 1120 1170 1220 1270 1320 1370 1420 1470 1520 1570 1620 1670 1720 1770
1820];
Temp = 500+460;
for o = 1 :33
A=(aam*Pres(o))/((R^2.0)*(Temp^2.0));
B= bm*Pres(o)/(R*Temp);
% A
% B
%Peng-Robinson coefficients

P a g e | 26
a1 = -(1-B);
b1 = A-(3.*(B.^2)) - (2.*B);
c1 = -(A.*B) + (B.^2) + (B.^3);
% a1
% b1
% c1
k = [1 a1 b1 c1];
Z = roots(k);
Z_real = real(Z);
index = find(imag(Z)== 0);
if length(index)>1
Zreal = real(Z(index))
else
%execute this if there is just one real root
Z = real(Z(index));
end;
sprintf('%0.9f', Z)
end;
% Z = roots(k);
%z_ind = find(Z == real(Z));
%z_real = Z(z_ind)
%Zmax = max(z_real);
%Zmin = min(z_real);
%Z_real = real(Z)

P a g e | 27

Module B Matlab Code:


clear all;
clc
BIC = [
0
0;
0
0;
];
c = [0.5 0.5];
Tc_F = [-116.66 652.2];
for i=1:2
Tc(i) = Tc_F(i)+459.67;
Tr(i) = 959.67/Tc(i);
end;
% a_alpha = [5054.169646433640 245329.975005538000];
Pc = [667 304.6];
accentric = [0.0108 0.4425];
R = 10.73;
aam=0.0;
bm=0.0;
omega_a = [0.45724 0.45724];
omega_b = [0.0778 0.0778];
% ((K9*($B$3^2)*(E9^2))/G9)*((1+(J9*(1-(F9^0.5))))^2)
for i=1:2
if (accentric(i) <= 0.49)
fw(i)= 0.3746+(1.54226*accentric(i))- (0.26992*(accentric(i)^2));
elseif(accentric(i)>0.49)
fw(i)= 0.379642 +(1.48503*accentric(i))(0.164423*(accentric(i)^2))+(0.016666*(accentric(i)^3));
end;
end;
for i = 1:2
a_alpha(i) = ((omega_a(i)*(R^2)*(Tc(i)^2))/Pc(i))*((1+(fw(i)*(1Tr(i)^0.5)))^2);
end;
for i=1:2
b(i) = (omega_b(i) * R * Tc(i)) / Pc(i);
end;
for i=1:2
bm = bm + c(i)*b(i);
for j=1:2
aam= aam+ c(i)*c(j)*(sqrt(a_alpha(i)* a_alpha(j)))*(1.0-BIC(i,j));
end;
end;
% aam
% bm
%Dimensionless attraction parameter (A) and co-volume parameter (B)
load Pres.txt
Pres = Pres;
Temp = 500+459.67;
for o = 1 :33
Pres(o)
A=(aam*Pres(o))/((R^2.0)*(Temp^2.0));

P a g e | 28
B= bm*Pres(o)/(R*Temp);
% A
% B
%Peng-Robinson coefficients
a1 = -(1-B);
b1 = A-(3*(B^2)) - (2*B);
c1 = -((A*B) - (B^2) - (B^3));
% a1
% b1
% c1
k = [1 a1 b1 c1];
Z = roots(k);
%Z_real = real(Z);
% index = find(imag(Z)== 0);
% if length(index)>1
%
Zreal = real(Z(index))
% else
%execute this if there is just one real root
%
Z = real(Z(index));
% end;
% sprintf('%0.9f', Z)
%%% Moduale "B" %%%
%First Calculate an initial guess for the equilibrium ratios (Ki) of each
component using Wilsons
%correlation (Equation 2).
%acentic = [0.0108 0.4425];
%Tc = [343.34 1112.2];
%%% using peng-robinson EOS to obtain new values of A,B AND Z
for f =1:2
Ki(o,f) = Pc(f)/Pres(o) * exp(5.37*(1+accentric(f))*(1-(Tc(f)/Temp)));
%
sprintf('%0.17f', Ki(o,f))
end;
for it = 1:100
% alpha_g = 0.0;
% alpha_l = 0.0;
alpha_g = -(((c(1)/((Ki(o,2))-1)))+((c(2)/((Ki(o,1))-1))));
% sprintf('%0.17f', alpha_g)
alpha_l = 1-alpha_g;
for v = 1:2
if(alpha_g > 0 && alpha_g < 1)%%%% mixture found L+V Equilibrium
xi(v) = c(v) / (1+ (alpha_g * (Ki(o,v)-1)));
yi(v) = Ki(o,v) * xi(v);
elseif (alpha_g >= 1);
yi(v) = c(v);
elseif (alpha_g <=0)
xi(v) = c(v);
end;
end;
bmx = 0.0;
aamx = 0.0;
for i =1:2

P a g e | 29
bmx = bmx + (xi(i)* b(i));
for j=1:2
% aamx = aamx + ((xi(i)*xi(j))*((a_alpha(i)* a_alpha(j))^0.5)*(1BIC(i,j)))
aamx_f(i,j) = xi(i)*xi(j)*(sqrt(a_alpha(i)* a_alpha(j)))*(1BIC(i,j));
aamx = sum(sum(aamx_f));
end;
end;
Ax=(aamx*Pres(o))/((R^2)*(Temp^2));
sprintf('%0.9f', Ax)
Bx= bmx*Pres(o)/(R*Temp);
% sprintf('%0.9f', Bx)
a1x = -(1-Bx);
% sprintf('%0.9f', a1x)
b1x = Ax-(3*(Bx^2)) - (2*Bx);
% sprintf('%0.9f', b1x)
c1x = -(Ax*Bx) + (Bx^2) + (Bx^3);
% sprintf('%0.9f', c1x)
kx = [1 a1x b1x c1x];
Zx = roots(kx);
Z_real_x = real(Zx);
index = find(imag(Zx)== 0);
if length(index)>1
Zrealx = real(Zx(index));
else
%execute this if there is just one real root
Zx = real(Zx(index));
end;
%sprintf('%0.9f', Zx)
%%Zx(o,1) = Zx;
%Calculating the vapor Z-factor
bmy = 0.0;
aamy = 0.0;
for w =1:2
bmy = bmy + yi(w)* b(w);
for j=1:2
aamy= aamy+ yi(w)*yi(j)*((a_alpha(w)* a_alpha(j))^0.5)*(1.0BIC(w,j));
end;
end;
Ay=(aamy*Pres(o))/((R^2.0)*(Temp^2.0));
By= bmy*Pres(o)/(R*Temp);
a1y = -(1-By);
b1y = Ay-(3.*(By.^2)) - (2.*By);
c1y = -(Ay.*By) + (By.^2) + (By.^3);
ky = [1 a1y b1y c1y];
Zy = roots(ky);
Z_real_y = real(Zy);
index = find(imag(Zy)== 0);
if length(index)>1

P a g e | 30
Zrealy = real(Zy(index));
else
%execute this if there is just one real root
Zy = real(Zy(index));
end;
%sprintf('%0.9f', Zy)
%Calculation for BBi and AAi
AAx = 0.0;
AAy = 0.0;
for i = 1:2
BBx(i) = b(i) / bmx;
BBy(i) = b(i) / bmy;
AAx_factor = (2*(sqrt(a_alpha(i)))/aamx);
for j = 1:2
AAx = AAx + xi(j) * (a_alpha(j) ^0.5) * (1.0-BIC(i,j));
end;
AAx(i) = AAx_factor * AAx;
phix(i) = exp(BBx(i)*(Zx-1) - log(Zx-Bx)-((Ax/(2*sqrt(2)*Bx))*(AAx(i)BBx(i))*log((Zx+(sqrt(2)+1)*Bx)/(Zx-(sqrt(2)-1)*Bx))));
GUFx(o,i) = phix(i) * xi(i) * Pres(o);
AAy_factor = (2*(sqrt(a_alpha(i)))/aamy);
for j = 1:2
AAy = AAy + yi(j) * (a_alpha(j) ^0.5) * (1.0-BIC(i,j));
end;
AAy(i) = AAy_factor * AAy;
phiy(i) = exp(BBy(i)*(Zy-1) - log(Zy-By)-((Ay/(2*sqrt(2)*By))*(AAy(i)BBy(i))*log((Zy+(sqrt(2)+1)*By)/(Zy-(sqrt(2)-1)*By))));
GUFy(o,i) = phiy(i) * yi(i) * Pres(o);
if (GUFx(o,i) ~= GUFy(o,i))
Ki_new(o,i) = Ki(o,i)*(GUFx(o,i)/GUFy(o,i));
Ki(o,i) = Ki_new(o,i);
end;
end;
conver = 0.0;
for i = 1:2
conver = conver + (((GUFx(o,i)/GUFy(o,i))-1)^2);
end;
if (conver< 10.^(-18))
break
end;
end;
X = [ alpha_l];
disp(X)
end;

P a g e | 31

Module C Matlab Code:


clear all;
clc
format long
BIC = [
0.00000000
0.26562214;
0.00098600
0.01054100;
0.00784300
0.00228100;
0.02394200
0.00000000;
0.03784100
0.00000000;
0.04744500
0.00000000;
0.26562214
0.00000000;
];

0.000986

0.007843

0.023942

0.037841

0.047445

0.000000

0.003695

0.010541

0.010541

0.010541

0.003695

0.000000

0.002281

0.002281

0.002281

0.010541

0.002281

0.000000

0.000000

0.000000

0.010541

0.002281

0.000000

0.000000

0.000000

0.010541

0.002281

0.000000

0.000000

0.000000

0.010541

0.002281

0.000000

0.000000

0.000000

c = [0.6793 0.099 0.1108 0.045 0.052966 0.011941 0.000993];


Tc_F = [-120.01 89.83 245.87 410.94 600.51 823.88 1060.94];
Temp_F = 60.000;
Temp_R = Temp_F + 459.67;
for i=1:7
Tc(i) = Tc_F(i)+459.67;
Tr(i) = Temp_R/Tc(i);
end;
Pc = [662.81 752.19 581.03 481.06 385 253.07 174.67];
accentric = [0.0133 0.11304 0.17244 0.23561 0.34585 0.55335 0.84182];
R = 10.73;
omega_a = [0.42312848 0.45192604 0.45984739 0.4581188 0.39778691 0.39778691
0.39778691];
omega_b = [0.08046461 0.07926051 0.07843675 0.07791799 0.07510754 0.07510754
0.07510754];
for i=1:7
if (accentric(i) <= 0.49)
fw(i)= 0.3746+(1.54226*accentric(i))- (0.26992*(accentric(i).^2));
elseif(accentric(i)>0.49)
fw(i)= 0.379642 +(1.48503*accentric(i))(0.164423*(accentric(i).^2))+(0.016666*(accentric(i).^3));
end;
a_alpha(i) = ((omega_a(i)*(R.^2)*(Tc(i).^2))/Pc(i))*((1+(fw(i)*(1sqrt(Tr(i))))).^2);
b(i) = (omega_b(i) * R * Tc(i)) / Pc(i);
end;
aam=0.0;
bm=0.0;
for i=1:7
bm = bm + c(i)*b(i);
for j=1:7
aam = aam+ c(i)*c(j)*((a_alpha(i)* a_alpha(j))^0.5)*(1.0-BIC(i,j));

P a g e | 32
end;
end;
load Presm1.txt
Pres = Presm1;
Temp = Temp_R;
for o = 1 :1
Pres(o) = 1800.0;
A=(aam*Pres(o))/((R^2.0)*(Temp^2.0));
B= bm*Pres(o)/(R*Temp);
%Peng-Robinson coefficients
a1 = -(1-B);
b1 = A-(3*(B^2)) - (2*B);
c1 = -((A*B) - (B^2) - (B^3));
k = [1 a1 b1 c1];
Z = roots(k);
% sprintf('%0.9f', Z)
%%% Moduale "B" %%%
%First Calculate an initial guess for the equilibrium ratios (Ki) of each
component using Wilsons
%correlation
%%% using peng-robinson EOS to obtain new values of A,B AND Z
for f =1:7
Ki(o,f) = Pc(f)/Pres(o) * exp(5.37*(1+accentric(f))*(1-(Tc(f)/Temp)));
%sprintf('%0.17f', Ki(o,f))
end;
x = zeros(1,7);
y = zeros(1,7);
for it = 1:1000
it
alpha_g = -(((c(6)/((Ki(o,7))-1)))+((c(7)/((Ki(o,6))-1))));
%Calculating alpha g using the Newton Raphson
for alphait = 1:100
g_alpha_g(o) = 0.0;
g_alpha_g_prime(o) = 0.0;
for i = 1:7
g_alpha_g(o) = g_alpha_g(o) + ((c(i)*(Ki(o,i)1))/(1+(alpha_g*(Ki(o,i)-1))));
g_alpha_g_prime(o) = g_alpha_g_prime(o) + (-(c(i)*(Ki(o,i)1)^2))/((1+ (alpha_g*(Ki(o,i)-1)))^2);
end;
alpha_g_new(o) = alpha_g(o) -

(g_alpha_g(o)/g_alpha_g_prime(o));

if abs(alpha_g_new(o) - alpha_g(o)) < 10^-10


alpha_g(o) = alpha_g_new(o);
break
else
alpha_g(o) = alpha_g_new(o);
end;
end;
sprintf('%0.17f', alpha_g(o))
alpha_l = 1-alpha_g;
for v = 1:7

P a g e | 33
if(alpha_g(o) > 0 && alpha_g(o) < 1)%%%% mixture found L+V
Equilibrium
xi(v) = c(v) / (1+ (alpha_g(o) * (Ki(o,v)-1)));
yi(v) = Ki(o,v) * xi(v);
elseif (alpha_g(o) >= 1);
yi(v) = c(v);
elseif (alpha_g(o) <=0)
xi(v) = c(v);
end;
end;
%Calculation for the Liquid Phase
bmx = 0.0;
aamx = 0.0;
for i =1:7
bmx = bmx + (xi(i)* b(i));
for j=1:7
aamx = aamx + (xi(i) * xi(j) * sqrt(a_alpha(i)* a_alpha(j))*(1BIC(i,j)));
end;
end;
%CHECK aamx
%aamx = 4.434054753600393e+004;
%diff = aamxn - aamx
Ax=(aamx*Pres(o))/((R.^2*Temp.^2));
Bx= bmx*Pres(o)/(R*Temp);
a1x = -(1-Bx);
%sprintf('%0.9f', a1x)
b1x = Ax-(3*(Bx^2)) - (2*Bx);
%sprintf('%0.9f', b1x)
c1x = -(Ax*Bx) + (Bx^2) + (Bx^3);
%sprintf('%0.9f', c1x)
kx = [1 a1x b1x c1x];
Zx = roots(kx);
%
result = isreal(Zx);
%
if (result == 0)
%
Zxmax =Zx(1,1);
%
Zxmin=Zxmax;
%
elseif (result==1)
%
Zxmax = max(Zx);
%
Zxmin = min(Zx);
%
end
Z_real_x = real(Zx);
index = find(imag(Zx)== 0);
if length(index)>1
Zrealx = real(Zx(index));
else
%execute this if there is just one real root
Zx = real(Zx(index));
end;
%sprintf('%0.15f', Zx)
%Calculation the Vapor phase
bmy = 0.0;
aamy = 0.0;
for w =1:7

P a g e | 34
bmy = bmy + yi(w)* b(w);
for j=1:7
aamy= aamy+ yi(w)*yi(j)*((a_alpha(w)* a_alpha(j))^0.5)*(1.0BIC(w,j));
end;
end;
%aamy = 7668.8923328528654;
Ay=(aamy*Pres(o))/((R^2.0)*(Temp^2.0));
By= bmy*Pres(o)/(R*Temp);
a1y = -(1-By);
b1y = Ay-(3.*(By.^2)) - (2.*By);
c1y = -(Ay.*By) + (By.^2) + (By.^3);
ky = [1 a1y b1y c1y];
Zy = roots(ky);
Z_real_y = real(Zy);
index = find(imag(Zy)== 0);
if length(index)>1
Zrealy = real(Zy(index));
else
%execute this if there is just one real root
Zy = real(Zy(index));
end;
%sprintf('%0.15f', Zy)
%Calculation for BBi and AAi
AAx = zeros(1,7);
AAx_sum = zeros(1,7);
AAy = zeros(1,7);
AAy_sum = zeros(1,7);
BBx= zeros(1,7);
BBy= zeros(1,7);
for i = 1:7
BBx(i) = b(i) / bmx;
BBy(i) = b(i) / bmy;
AAx_factor = (2*(sqrt(a_alpha(i)))/aamx);
for j = 1:7
AAx_sum(i) =AAx_sum(i) + (xi(j) * sqrt(a_alpha(j)) * (1.0BIC(i,j)));
end;
AAx(i) = (2*(sqrt(a_alpha(i)))/aamx) * AAx_sum(i);
phix(i) = exp(BBx(i)*(Zx-1) - log(Zx-Bx)((Ax/(2*sqrt(2)*Bx))*(AAx(i)-BBx(i))*log((Zx+(sqrt(2)+1)*Bx)/(Zx-(sqrt(2)1)*Bx))));
GUFx(o,i) = phix(i) * xi(i) * Pres(o);
AAy_factor = (2*(sqrt(a_alpha(i)))/aamy);
for j = 1:7
AAy_sum(i) =AAy_sum(i) + yi(j) * (a_alpha(j) ^ 0.5) * (1.0BIC(i,j));
end;
AAy(i) = (2*(sqrt(a_alpha(i)))/aamy) * AAy_sum(i);
phiy(i) = exp(BBy(i)*(Zy-1) - log(Zy-By)((Ay/(2*sqrt(2)*By))*(AAy(i)-BBy(i))*log((Zy+(sqrt(2)+1)*By)/(Zy-(sqrt(2)1)*By))));
GUFy(o,i) = phiy(i) * yi(i) * Pres(o);
if (GUFx(o,i) ~= GUFy(o,i))
Ki_new(o,i) = Ki(o,i)*(GUFx(o,i)/GUFy(o,i));
Ki(o,i) = Ki_new(o,i);

P a g e | 35
end;
end;
conver = 0.0;
for i = 1:7
conver = conver + (((GUFx(o,i)/GUFy(o,i))-1)^2);
end;
if (conver < 10^-18)
break
end;
end;
end;

P a g e | 36
clear all;
clc
format long

%Number of components and Pressure


nc = 7;
%The three pressures for the three stages.
np = 3;
R = 10.73;
%Preallocating memory and initilaizing the values
fw = zeros(1,nc);
a_alpha = zeros(1,nc);
b = zeros(1,nc);
Tc = zeros(1,nc);
Tr = zeros(1,nc);
%Calling mix 1 data. Making sure we use right compositions
mix_1_data = xlsread('MCV2.xlsx');
BIC = xlsread ('MCV2BIC.xlsx');
for i=1:nc
accentric = mix_1_data(:,6);
if (accentric(i) <= 0.49)
fw(i)= 0.3746+(1.54226*accentric(i))- (0.26992*(accentric(i)^2));
elseif(accentric(i)>0.49)
fw(i)= 0.379642 +(1.48503*accentric(i))(0.164423*(accentric(i)^2))+(0.016666*(accentric(i)^3));
end;
Temp_F = 65.000;
Temp_R = Temp_F + 459.67;
Tc_F = mix_1_data(:,3);
Tc(i) = Tc_F(i)+459.67;
Tr(i) = Temp_R/Tc(i);
omega_a = mix_1_data(:,7);
Pc = mix_1_data(:,4);
a_alpha(i) = ((omega_a(i)*(R.^2)*(Tc(i).^2))/Pc(i))*((1+(fw(i)*(1Tr(i).^0.5))).^2);
omega_b = mix_1_data(:,8);
b(i) = (omega_b(i) * R * Tc(i)) / Pc(i);
end;
MWi = mix_1_data(:,2);
c = mix_1_data(:,1);
%Mocule C Validation 2
%Dimensionless attraction parameter (A) and co-volume parameter (B)
load PresV2.txt
Pres = PresV2;
Temp = Temp_R;
%Preallocating memory for most of the values and initilizing them

P a g e | 37

%g_alpha_g = zeros(1,o);
%g_alpha_g_prime = zeros(1,o);
%alpha_g_new = zeros(1,o);
alpha_g = zeros(1,np);
alpha_l = zeros(1,np);
MW_g = zeros(1,np);
MW_l = zeros(1,np);
roh_g = ones(1,np);
roh_l = ones(1,np);
%The three pressures for the three stages.
for o = 1 :3
%Preallocating memory for most of the values and initilizing them
GUFx = zeros(np,nc);
GUFy = zeros(np,nc);
Pres(o)
%Calculate an initial guess for the equilibrium ratios (Ki) of each
component using Wilsons
%correlation
for f =1:nc
Ki(o,f) = (Pc(f)/Pres(o)) * exp(5.37*(1+accentric(f))*(1(Tc(f)/Temp)));
%sprintf('%0.17f', Ki(o,f))
end;
%Starting the main iteration process
for it = 1:1000
it
alpha_g(o) = -((c(6)/(Ki(o,7)-1))+(c(7)/(Ki(o,6)-1)));
alpha_l(o) = 1-alpha_g(o);
%Obtaining the currect alpha using iteration
for alphait = 1:1000
g_alpha_g(o) = 0.0;
g_alpha_g_prime(o) = 0.0;
alpha_g_new(o) = 0.0;
for i = 1:nc
g_alpha_g(o) = g_alpha_g(o) + (c(i)*(Ki(o,i)1)/(1+alpha_g(o)*(Ki(o,i)-1)));
g_alpha_g_prime(o) = g_alpha_g_prime(o) + (-c(i)*(Ki(o,i)1)^2/(1+ alpha_g(o)*(Ki(o,i)-1))^2);
end;
alpha_g_new(o) = alpha_g(o) - (g_alpha_g(o)/g_alpha_g_prime(o));
if abs(alpha_g_new(o) - alpha_g(o)) < 10^-10
alpha_g(o) = alpha_g_new(o);
break
else
alpha_g(o) = alpha_g_new(o);
end;
end;

P a g e | 38
%sprintf('%0.17f', alpha_g(o))
alpha_l(o) = 1-alpha_g(o);
for v = 1:nc
if(alpha_g(o) > 0 && alpha_g(o) < 1)%%%% mixture found L+V
Equilibrium
xi(v) = (c(v)/(1+alpha_g(o)*(Ki(o,v)-1)));
yi(v) = Ki(o,v) * xi(v);
elseif (alpha_g(o) >= 1)
yi(v) = c(v);
elseif (alpha_g(o) <=0)
xi(v) = c(v);
end;
end;
%Calculating the Liquid Z-factor
bmx = 0;
aamx = 0;
for i =1:nc
bmx = bmx + (xi(i)* b(i));
for j=1:nc
aamx = aamx + xi(i) * xi(j) * sqrt(a_alpha(i)* a_alpha(j))*(1BIC(i,j));
end;
end;
Ax=(aamx*Pres(o))/((R.^2)*(Temp^2))
Bx= (bmx*Pres(o))/(R*Temp);
a1x = -(1-Bx);
b1x = Ax-(3*(Bx^2)) - (2*Bx);
c1x = -(Ax*Bx) + (Bx^2) + (Bx^3);
kx = [1 a1x b1x c1x];
Zx = roots(kx)
%Making sure we pick the right Z if we have more than one real
%root. We choose the smallest value for the liquid calculations
logical_value = isreal (Zx);
if (logical_value == 1)
Zx_max =Zx(3,1);
Zx_min = Zx_max
elseif (logical_value == 0)
Zx_max = max(Zx);
Zx_min = min(Zx)
end;
%Calculating the Vapor Z-factor
bmy = 0.0;
aamy = 0.0;
for w =1:nc
bmy = bmy + yi(w)* b(w);
for j=1:nc
aamy= aamy+ yi(w)*yi(j)*((a_alpha(w)* a_alpha(j))^0.5)*(1.0BIC(w,j));
end;
end;
Ay=(aamy*Pres(o))/((R.^2)*(Temp^2.0));

P a g e | 39
By= bmy*Pres(o)/(R*Temp);
a1y = -(1-By);
b1y = Ay-(3*(By.^2)) - (2*By);
c1y = -(Ay*By) + (By^2) + (By^3);
ky = [1 a1y b1y c1y];
Zy = roots(ky);
%Making sure we pick the right Z if we have more than one real
%root. We choose the largest value for the gas calculations
logical_value = isreal (Zy);
if (logical_value == 1)
Zy_max =max(Zy);
Zy_min =min(Zy);
elseif (logical_value == 0)
Zy_max =Zy(1,1);
Zy_min = Zy_max;
end;
MW_l(o) =0.0;
MW_g(o) =0.0;
for i=1:nc
%Molaculer weight
MW_l(o) = MW_l(o) + MWi(i) * xi(i);
MW_g(o) = MW_g(o) + MWi(i) * yi(i);
end;
%Calculation of the density of liquid and vapor for the three
%stages
roh_l(o) = (Pres(o)* MW_l(o))/(Zx_min*R*Temp);
roh_g(o) = (Pres(o)* MW_g(o))/(Zy_max*R*Temp);
%Calculation of gas oil ration using the equations below which
%we used in the homework
GOR_1 = 379.4 *alpha_g(1) /(((1- alpha_g(1))* (MW_l(1) /
roh_l(1))/5.615));
GOR_2 = 379.4 *(1- alpha_g(1)) * alpha_g(2)/(((1- alpha_g(1))*(1alpha_g(2)))* (MW_l(2) / roh_l (2))/5.615 );
GOR_3 = 379.4 *((1- alpha_g(1)) *(1- alpha_g(2))*alpha_g(3)) /((1-(
alpha_g(1)+(1- alpha_g(1) )* alpha_g(2)+(1- alpha_g(1)) *(1alpha_g(2))*alpha_g(3)))* (MW_l(3) / roh_l (3))/5.615 );
GOR_M = 379.4 *(alpha_g(1)+(1- alpha_g(1) )* alpha_g(2)+(1- alpha_g(1))
*(1- alpha_g(2))*alpha_g(3)) /((1-( alpha_g(1)+(1- alpha_g(1) )* alpha_g(2)+(1alpha_g(1)) *(1-alpha_g(2))*alpha_g(3)))* (MW_l(3) / roh_l(3))/5.615 );
%Calculating the API
API(o) = (141.5/(roh_l(o)/62.4)) - 131.5;
%Calculation for BBi and AAi
AAx = zeros(1,nc);
AAx_sum = zeros(1,nc);
AAy = zeros(1,nc);
AAy_sum = zeros(1,nc);
BBx= zeros(1,nc);
BBy= zeros(1,nc);
for i = 1:nc
%Liquid Phase
BBx(i) = b(i) / bmx;

P a g e | 40
BBy(i) = b(i) / bmy;
AAx_factor = (2*(sqrt(a_alpha(i)))/aamx);
for j = 1:nc
AAx_sum(i) =AAx_sum(i) + (xi(j) * sqrt(a_alpha(j)) * (1BIC(i,j)));
end;
AAx(i) = (2*(sqrt(a_alpha(i)))/aamx) * AAx_sum(i);
phix(i) = exp(BBx(i)*(Zx_min-1) - log(Zx_min-Bx)((Ax/(2*sqrt(2)*Bx))*(AAx(i)-BBx(i))*log((Zx_min+(sqrt(2)+1)*Bx)/(Zx_min(sqrt(2)-1)*Bx))));
GUFx(o,i) = phix(i) * xi(i) * Pres(o);
%Vapor Phase
AAy_factor = (2*(sqrt(a_alpha(i)))/aamy);
for j = 1:nc
AAy_sum(i) =AAy_sum(i) + yi(j) * (a_alpha(j) ^ 0.5) * (1BIC(i,j));
end;
AAy(i) = (2*(sqrt(a_alpha(i)))/aamy) * AAy_sum(i);
phiy(i) = exp(BBy(i)*(Zy_max-1) - log(Zy_max-By)((Ay/(2*sqrt(2)*By))*(AAy(i)-BBy(i))*log((Zy_max+(sqrt(2)+1)*By)/(Zy_max(sqrt(2)-1)*By))));
GUFy(o,i) = phiy(i) * yi(i) * Pres(o);
%Currecting the Ki
if (GUFx(o,i) ~= GUFy(o,i))
Ki_new(o,i) = Ki(o,i)*(GUFx(o,i)/GUFy(o,i));
Ki(o,i) = Ki_new(o,i);
end;
end;
conver = 0.0;
%The iteration check
for i = 1:nc
conver = conver + (((GUFx(o,i)/GUFy(o,i))-1)^2);
end;
conver;
if (conver< 10.^(-18))
for i = 1:nc
c(i) = xi(i);
end;
break
end;
end;
end;

Potrebbero piacerti anche