CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Get the mole fraction in UDS and UDF Error "the fl process could not be started" (https://www.cfd-online.com/Forums/fluent-udf/249920-get-mole-fraction-uds-udf-error-fl-process-could-not-started.html)

kckcc May 16, 2023 08:27

Get the mole fraction in UDS and UDF Error "the fl process could not be started"
 
2 Attachment(s)
I am working on particle-resolved fixed bed and using the UDS to calculate the reaction species in catalysts(represented as solid phase in Fluent), so I need to calculate the diffusion coefficient of species using the macro DEFINE_DIFFUSIVIT(name,c,t,i) and the formula in the attached picture.

I set uds to work in all zones ,so I wrote the codes for the diffusion coefficients in the solid phase and in the liquid phase separately, where the code for the liquid phase is a simplification of the code for the solid phase, you can see the code for the solid phase here.

#Codes
#include "udf.h"
/*[O2,CO2,C2H4,C2H4O,H2O,N2]*/
real M[6]={32,44.01,28.06,44.052,18.015,28.013};/*these are the relative molecular mass of the species i */
real V[6]={16.6,26.9,41.04,28.85,12.7,17.9};/* these are the sum of the atomic diffusion volumes for species i*/
#define species 6
#define R 8.314
#define d_pore 20e-9
#define epslon 0.4
#define tao 2

DEFINE_DIFFUSIVITY(uds_diff_solid,c,t,i)/*to calculate the diffusivity of the species i in the solid phase*/
{
real temp=C_T(c,t);/*get temp in the solid phase*/
real press=C_P(c,t);/*get tpressure in the solid phase*/
real density=C_R(c,t);/*get density in the solid phase*/
real D1=0.;/*calculate the binary diffusion corffcient*/
real Df=0.;/*calculate the molecular diffusivity*/
real Ds=0.;/*to get the the effective diffusivity of the ith species in the solid phase*/
real Dk=0.;/*calculate the Knudsen diffusivity of the species i*/
real Mm=0.;
real Mm_total=0.;
real mole_fraction[6];
int x=i;
int y;
for(y=0;y<species;++y)
{
Mm = Mm + C_UDSI(c,t,y)/M[y];/*use C_UDSI(c,t,i) to get the mass fraction of ith species in solid phase*/
}
Mm_total =1/Mm; /*calculate the average relative molecular mass*/
for(y=0;y<species;++y)
{
mole_fraction[y]=C_UDSI(c,t,y)/(M[y]/Mm_total);
}/*get the mole fraction of ith species in solid phase*/

for (y=0;y<species;++y)
{
if(y!=x)
{
D1=D1+(mole_fraction[y]/(1e-3*pow(temp,1.75)*pow((1/M[x]+1/M[y]),0.5))/(press*pow((pow(V[x],1/3)+pow(V[y],1/3)),2)));
}
}

Df=(1-mole_fraction[x])/D1;/*get the molecular diffusivity, if I need the diffusity of ith species in fluid phase, I will return Df*density */
Dk=48.5*d_pore*pow((temp/M[x]),0.5);/*get the Knudsen diffusivity of the species i*/
Ds=epslon/tao*pow((1/Df+1/Dk),-1);/*get the the effective diffusivity of the ith species in the solid phase*/
return Ds*density;/*the uds needs diffusivity*density, so I return this*/

}

Problems
1. All UDF have been able to compling and load them sucessfully. However, on trying to run the simulation after incorporating those UDF, I am constantly facing an error "The fl process could not be started".
2. I can only get the mass fraction of the ith species by the uds in Fluent, but I have to use the mole fraction to calculate the diffusivity, so I use the method in the attached picture, is there a better solution?
3. As you can see, I have to calculate the mole fraction every time when I want to get the diffusivity of all species , is there a better solution?

I am unable to figure out the exact problem, and would highly appreciate any sort of help. Thanks in advance.

kckcc May 23, 2023 09:49

I have solved the above problem, just modify D1 in the code as follows:
D1 = (1e-3*pow(temp,1.75)*pow((1/M[x]+1/M[y]),0.5))/(press*pow((pow(V[x],1/3)+pow(V[y],1/3)),2));
D2 = mole_fraction[y]/D1;
D3 = D3+D2;


But I have encountered a new problem now.

Solid zones don't provide a pressure term, so I set the pressure constant, it can be calculated.

In the fluid zones I need the actual pressure to calculate, so I set pressure=C_P(c,t), but this causes divergence.


All times are GMT -4. The time now is 23:55.