Vous êtes sur la page 1sur 3

Assignment 4


Group L - Avijit Ghosh, S N Aditya Murthy, Aditya Goenka

Equilibrium Flash Calculation:

Equations used:

We used Wegstein’s method to converge the


value of alpha. The additional constraints
added were:


0 ≤ α < 1 and xi − 1 < tolerance

Program (Pseudocode):

A python program was used to code the program. The pseudocode is as follows:


#Defining Constants

import math,random

A <- [6.6438,6.82915,6.80338,6.80776]
B <- [395.74,663.72,804.00,935.77]
C <- [266.68,256.68,247.00,238.80]
Z <- [0.1, 0.25, 0.5, 0.15]
Pt <- 2*760

FUNCTION Psat(j):
return math.pow(10,(A[j]-(B[j]/(C[j]+50))))

FUNCTION k(j):
return Psat(j)/Pt

FUNCTION x(j,a):
return Z[j]/(1+(a*(k(j)-1)))

FUNCTION y(j,a):
return k(j)*x(j,a)

FUNCTION f(a):
s <- 0
for j in range(4):
s += Z[j]*(1-k(j))/(1+(a*(k(j)-1)))
ENDFOR
return s

FUNCTION sum_x(a):
s=0
for j in range(4):
s += x(j,a)
ENDFOR
return s

tol <- 0.001


a3 <- None
while True:
a1 <- random.uniform(0, 1)
ENDIF
ENDFOR
a2 <- random.uniform(0, 1)
ENDIF
ENDFOR
while True:
a3 <- ((a1* f(a2)) - (a2*f(a1)))/(a1 - f(a1) - a2 + f(a2))
OUTPUT a3
IF (abs(a3 - a2)<tol):
ENDIF
break
ELSE:
a1 <- a2
a2 <- a3

if(a3>=0.01 AND a3<=1 AND abs(sum_x(a3)-1)<tol):


ENDIF
break
ENDWHILE
ENDWHILE

OUTPUT "The final value of alpha is: ", a3

for i in range(4):
OUTPUT "The value of x"+str(i+1)+" is: "+ str(x(i,a3))
ENDFOR

for i in range(4):
OUTPUT "The value of y"+str(i+1)+" is: "+ str(y(i,a3))
ENDFOR

Output:

For P = 25 atm:

The final value of alpha is: 0.467314697064


The value of x1 is: 0.0150872819975
The value of x2 is: 0.149720568245
The value of x3 is: 0.59544776559
The value of x4 is: 0.240556494574
The value of y1 is: 0.196790786158
The value of y2 is: 0.364307082183
The value of y3 is: 0.391200464596
The value of y4 is: 0.0467759540879

For P = 15 atm and 2 atm the algorithm never converges, this is because for these two cases the
value of alpha is >1, which is not a feasible solution.

Vous aimerez peut-être aussi