abdul.zahir
Subscriber

 

 


#include “udf.h”
#include “mem.h”
#include “math.h”
#include “metric.h”
#include “sg.h”

#include “udf.h”

DEFINE_ADJUST(myadjust,d)

if(ROOT_DOMAIN_P(d))
{
cell_t c;
Thread *t;
Domain *sd = DOMAIN_SUB_DOMAIN(d,1); Alloc_Storage_Vars(sd,SV_VOF_RG,SV_VOF_G,SV_NULL); 
Scalar_Reconstruction(sd, SV_VOF,-1,SV_VOF_RG,NULL); 
Scalar_Derivatives(sd,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,&Vof_Deriv_Accumulate);
thread_loop_c(t,d)
if(FLUID_THREAD_P(t))
{
Thread *pt = THREAD_SUB_THREAD(t,1);
begin_c_loop(c,t) 
{
C_UDMI(c,t,2) = NV_MAG(C_VOF_G(c,pt));
}
end_c_loop(c,t)
}
Free_Storage_Vars(sd,SV_VOF_RG,SV_VOF_G,SV_NULL);

}


/* ************** Model Parameters ***************** */

#define u 0.00167        /* Liquid viscosity (Pa.s) */
#define ro 1003.4        /* Solvent density (Kg/m3) */
#define d 0.41             /* CO2 Diffusivity (10^-5 cm2/s) */
#define at 469            /* Surface area of the packing (1/m)*/
#define Vi 0.0002512        /* Vol. within the inner packing circle (m3) */
#define Vt 0.047            /* Tot. vol. of RPB (m3) */
#define Vo 0.00052752        /* Vol. between outer packing and stationaty housing (m3) */
#define L 2051.953        /* mass flux(Kg/m2.s) */
#define Ac 1099.56        /* Centrifugal acceleration(m2/s) */
#define Sig 0.05352        /* Surface tension of solvent (N/m) */
#define Solubility 1.06         /* Solubility of gas in liq (Kg/m3) */
#define dp 0.006847            /* equivalent spherical diameter (m) */


/* ********************************************************* */
DEFINE_LINEARIZED_MASS_TRANSFER(mass_transfer, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index, lin_from, lin_to)
{
Thread *gas=THREAD_SUB_THREAD(mixture_thread, from_phase_index);
Thread *liq=THREAD_SUB_THREAD(mixture_thread, to_phase_index);
real D, a, b, c1, d1, e, f, g, Coeff, ST, av_mol_mass, solute_mol_weight, tot_con_2, tc, Enhancement, sum, E, E2,E3, Hatta, DMea, MeaConc, CO2Conc, Density,Coeff2,MEA, h2O, h3O, CO2, Carbamate, Cr, Pr, rate, keq, E4;
ST=0;
Coeff=0;
tc=0;
E=0;
Hatta=0;
a=0;
b=0;
c1=0;
d1=0;
e=0;
f=0;
Coeff2=0;
MeaConc=0;
Enhancement=0;
Cr=0;
Pr=0;
rate=0;
keq=0;

if (( C_VOF(c, liq) < 1.0) && (C_VOF(c, liq) >0))
{
real EIA=C_UDMI(c,mixture_thread,2);
D=d*0.000000001; /* ******* Diffusion in m2/s******/
C_UDMI(c,mixture_thread,3)=D;

a=pow(u/(C_R(c, mixture_thread)*D),0.5);
C_UDMI(c,mixture_thread,4)=a;

b=pow(L/(at*u),0.17);
C_UDMI(c,mixture_thread,5)=b;

c1=pow(dp*dp*dp*C_R(c, mixture_thread)*C_R(c, mixture_thread)*Ac/(u*u),0.3);
C_UDMI(c,mixture_thread,6)=c1;

d1=pow(L*L/(C_R(c, mixture_thread)*at*Sig),0.3);
C_UDMI(c,mixture_thread,7)=d1;

e=0.65*a*b*c1*d1;
C_UDMI(c,mixture_thread,8)=e;

f=(dp/(D*at))*(1-(0.93*(Vo/Vt))-1.13*(Vi/Vt));
C_UDMI(c,mixture_thread,9)=f;

Coeff=e/f; /* ****volumetric liquid-side mass transfer coefficient, 1/s */
C_UDMI(c,mixture_thread,10)=Coeff;

Coeff2=Coeff/(EIA+0.000000001);
C_UDMI(c,mixture_thread,11)=Coeff2;

tc=(C_YI(c,liq, 3)*(C_R(c, mixture_thread)/61))+(C_YI(c,liq, 2)*(C_R(c, mixture_thread)/44))+(C_YI(c,liq, 4)*(C_R(c, mixture_thread)/18))+(C_YI(c,liq, 1)*(C_R(c, mixture_thread)/19))+(C_YI(c,liq, 0)*(C_R(c, mixture_thread)/104)); /* *** molar concentration (Kmol/m3) */
C_UDMI(c,mixture_thread,12)=tc;

real SUM=(C_YI(c,liq, 3)/61)+(C_YI(c,liq, 2)/44)+(C_YI(c,liq, 4)/18)+(C_YI(c,liq, 1)/19)+(C_YI(c,liq, 0)/104);
C_UDMI(c,mixture_thread,13)=SUM;

real avg=1/SUM;
C_UDMI(c,mixture_thread,14)=avg;

Density=(C_R(c, mixture_thread));

MeaConc=(C_YI(c,liq, 3)*(C_R(c, mixture_thread)/61));
C_UDMI(c,mixture_thread,15)=MeaConc;

CO2Conc=(C_YI(c,liq, 1)*(C_R(c, mixture_thread)/44));
Hatta=pow(14152.47*D*MeaConc,0.5)/(Coeff2);
C_UDMI(c,mixture_thread,16)=Hatta;

DMea=exp(-13.275-(2198.3/313)- 0.078142*MeaConc);

E2=1+((DMea*MeaConc)/(2*D*CO2Conc));

E=pow((Hatta*Hatta*((E2-E)/(E2-1))),0.5)/tanh(pow((Hatta*Hatta*((E2-E)/(E2-1))),0.5));
Enhancement=Hatta;
C_UDMI(c,mixture_thread,17)=Enhancement;

if (Enhancement>0)
{
ST= Enhancement*Coeff*tc*(((Solubility/44)-(C_YI(c, liq, 2))))*avg/44; 
C_UDMI(c,mixture_thread,18)=ST;
/* ***** (kmol/m3) */
}
else
{
ST=0;
C_UDMI(c,mixture_thread,18)=ST;
}
}
else
{
MeaConc=0;
C_UDMI(c,mixture_thread,15)=MeaConc;

CO2Conc=0;
Hatta =0;
C_UDMI(c,mixture_thread,16)=Hatta;

Coeff =0;
C_UDMI(c,mixture_thread,10)=Coeff;

ST= 0;
C_UDMI(c,mixture_thread,18)=ST;

}
if (( C_VOF(c, liq) <= 1.0) && (C_VOF(c, liq) >0))
{
Cr=(C_YI(c,liq, 3)*(C_R(c, mixture_thread)/61))+(C_YI(c,liq, 2)*(C_R(c, mixture_thread)/44))+(C_YI(c,liq, 4)*(C_R(c, mixture_thread)/18));
C_UDMI(c,mixture_thread,19)=Cr;

Pr=(C_YI(c,liq, 0)*(C_R(c, mixture_thread)/19))+(C_YI(c,liq, 1)*(C_R(c, mixture_thread)/104));
C_UDMI(c,mixture_thread,20)=Pr;

keq= 0.000000000972;

rate=(14152.47*Cr)/((-14152.47/keq)*Pr);
C_UDMI(c,mixture_thread,21)=rate;

if (( C_YI(c,liq, 3) <= 1.0))
{
MEA=-rate*61;
C_UDMI(c,mixture_thread,22)=MEA;
}
else
{
MEA=0;
C_UDMI(c,mixture_thread,22)=MEA;

if ((C_YI(c,liq, 2)<=1.0))
{
CO2=-rate*44;
C_UDMI(c,mixture_thread,23)=CO2;
}
else
{
CO2=0;
C_UDMI(c,mixture_thread,23)=CO2;

}
if (( C_YI(c,liq, 4) <= 1.0))
{
h2O=-rate*18;
C_UDMI(c,mixture_thread,24)=h2O;
}
else
{
h2O=0;
C_UDMI(c,mixture_thread,24)=h2O;

}
if (( C_YI(c,liq, 1) <= 1.0))
{
h3O=-rate*19;
C_UDMI(c,mixture_thread,25)=h3O;
}
else
{
h3O=0;
C_UDMI(c,mixture_thread,25)=h3O;
}
if (( C_YI(c,liq, 0) <= 1.0))
{
Carbamate=-rate*104;
C_UDMI(c,mixture_thread,26)=Carbamate;
}
else
{
Carbamate=0;
C_UDMI(c,mixture_thread,26)=Carbamate;
}
}
}
return ST;
}

DEFINE_SOURCE(MEA_Source, c,mixture_thread, dS, eqn)
{
real MEA_Source;
MEA_Source=C_UDMI(c,mixture_thread,22);
return MEA_Source;
}
DEFINE_SOURCE(water_Source, c,mixture_thread, dS, eqn)
{
real h2O_Source;
h2O_Source=C_UDMI(c,mixture_thread,24);
return h2O_Source;
}
DEFINE_SOURCE(CDO_Source, c,mixture_thread, dS, eqn)
{
real CO2_Source;
CO2_Source=C_UDMI(c,mixture_thread,23);
return CO2_Source;
}
DEFINE_SOURCE(hydronium_Source, c,mixture_thread, dS, eqn)
{
real h3O_Source;
h3O_Source=C_UDMI(c,mixture_thread,25);
return h3O_Source;
}
DEFINE_SOURCE(carbamate_Source, c,mixture_thread, dS, eqn)
{
real Carbamate_Source;
Carbamate_Source=C_UDMI(c,mixture_thread,26);
return Carbamate_Source;
}
DEFINE_SOURCE(ST_Source, c,mixture_thread, dS, eqn)
{
real ST_Source;
ST_Source=C_UDMI(c,mixture_thread,18);
return ST_Source;
}