## Fluids

#### Mis Calculations on the Fluent UDF

• abdul.zahir
Subscriber

I am using a UDF to calculate the mass transfer between gas and liquid phase. In that UDF i am calculating various other variable as the mass transfer model terms. Two of them are as follow

Hatta=pow(14152.47*D*MeaConc,0.5)/(Coeff2);

Enhancement=Hatta;

But when I go to "Reports>Surface Integrals>Mass weighted-average>User Defined Memory (Field variable)>User Memory 16 and 17" both values are different for same phase and surface. How can it be?
If Enhancement=Hatta then both UDM 16 and 17 should be the same.

What can be the reason for this mis calculation? or Am I looking a wrong report type?

Thank you

• Rob
Ansys Employee

What's E4

• abdul.zahir
Subscriber

E4=Enhancement

It's a typo error in the post

• Rob
Ansys Employee

OK, thanks.

How well converged is the model, and are both UDMs defined in the same cell loop?

• abdul.zahir
Subscriber

Overall the convergance is good.

Yes both UDMs are in the same cell loop.

• Rob
Ansys Employee

What is the number type definition of Hatta and Enhancement

• abdul.zahir
Subscriber

Every variable is defined as "real"

• Rob
Ansys Employee

Can you post the full code in the section you're defining the UDM and also post images of the contours of the two UDMs.

• abdul.zahir
Subscriber

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

#include “udf.h”

if(ROOT_DOMAIN_P(d))
{
cell_t c;
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);
{
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)
{
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))
{
D=d*0.000000001; /* ******* Diffusion in m2/s******/

b=pow(L/(at*u),0.17);

e=0.65*a*b*c1*d1;

f=(dp/(D*at))*(1-(0.93*(Vo/Vt))-1.13*(Vi/Vt));

Coeff=e/f; /* ****volumetric liquid-side mass transfer coefficient, 1/s */

Coeff2=Coeff/(EIA+0.000000001);

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);

real avg=1/SUM;

Hatta=pow(14152.47*D*MeaConc,0.5)/(Coeff2);

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;

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

CO2Conc=0;
Hatta =0;

Coeff =0;

ST= 0;

}
if (( C_VOF(c, liq) <= 1.0) && (C_VOF(c, liq) >0))
{

keq= 0.000000000972;

rate=(14152.47*Cr)/((-14152.47/keq)*Pr);

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

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

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

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

{
real MEA_Source;
return MEA_Source;
}
{
real h2O_Source;
return h2O_Source;
}
{
real CO2_Source;
return CO2_Source;
}
{
real h3O_Source;
return h3O_Source;
}
{
real Carbamate_Source;
return Carbamate_Source;
}
{
real ST_Source;
return ST_Source;
}

• DrAmine
Ansys Employee

Weird. Just set the UDMI to be equal why using the long way?

• abdul.zahir
Subscriber

The mentioned UDMI was just an example. Every variable/UDMI which stores the calculated data i found mis calculated.

• DrAmine
Ansys Employee

Enhancement is not declared. Can you delcare it and try again?

• abdul.zahir
Subscriber

Yes I have also tried with that. I defined it as

real Enhancement;

The strange thing is that even if i make it as

Enhancement=1;

in that case the value is again not equal to 1. it's rather 3-8.

• Rob
Ansys Employee

Odd, however, if you assign a real give it a real value: 0 is an integer. Shouldn't make any difference but it's good practice.

• DrAmine
Ansys Employee

Just test this: