-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgamma_wilson_3.c
52 lines (45 loc) · 1.4 KB
/
gamma_wilson_3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//this is a file in the VAc dynamic model software package
//parent-routine: bubpt_column.c
//Copyright: Rong Chen and Kedar Dave, June 2002
//VERSION 1.0
//This function calculates VLE activity coefficient using Wilson model for three components in the distillation column
#include <stdio.h>
#include <math.h>
void gamma_wilson_3(double wilson[], double TT, double xx[], double vvij[][3], double aaij[][3], double R, double T_ref)
{
/*input*/
/*TT: bubble-point temperature, degC*/
/*x: liquid molar fraction*/
/*VIJ: molar volume of component i / j*/
/*aij: Wilson parameter*/
/*R: gas constant, which is 1.987 kcal/(kmol*K)*/
/*T_ref: absolute temperature of 0 degC, which is 273.15 K*/
/*output*/
/*wilson(i,j) used in bubble-point calculation*/
int i, j;
double Lambda[3][3];
double sLambda[3]={0.,0.,0.};
double const_vect[3]={0.,0.,0.};
double the_sum[3]={0.,0.,0.};
double z[3]={0.,0.,0.};
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
Lambda[i][j] = vvij[i][j]*exp(-aaij[i][j]/(R*(TT + T_ref)));
};
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
sLambda[i]+=Lambda[i][j]*xx[j];
const_vect[i]+= Lambda[i][j]*xx[j];
};
};
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
the_sum[i]+=(Lambda[j][i]/const_vect[j])*xx[j];
z[i] = 1-log(sLambda[i])-the_sum[i];
wilson[i] = exp(z[i]);
};
}