CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   help on UDF mass source (https://www.cfd-online.com/Forums/fluent/30017-help-udf-mass-source.html)

 shao1 July 11, 2002 18:23

help on UDF mass source

Hi, I am doing a sample run using UDF. It's a single phase mixing tank with production and depletion of species. There are originally three species in the liquid: benzene, ethanol, and water. As time goes on, Benzene will discrease, and ethanol will increase. The rate of depletion of Benzene is R=-S*X/(900*(1+S)); the rate of production of Ethanol is R=S*X/(9000*(1+S)); Where S and X are the mass concentration of Benzene and Ethanol respectively. When I enable the UDF, both of the mass fractions of Benzene and Ethanol decrease. My UDF is as follows, please help me to find out the problem. Thanks! ------------------------------------------------------- DEFINE_SOURCE(Benzene_src,cell,thread,dS,eqn) { real source, S, X; if(!Data_Valid_P()) return 0.0; S = C_YI(cell,thread,0)*C_R(cell,thread); X = C_YI(cell,thread,1)*C_R(cell,thread); source = -S*X/(900*(1+S)); dS[eqn] = 0.0;

return source; }

DEFINE_SOURCE(Ethanol_src,cell,thread,dS,eqn) { real source, S, X; if(!Data_Valid_P()) return 0.0; S = C_YI(cell,thread,0)*C_R(cell,thread); X = C_YI(cell,thread,1)*C_R(cell,thread); source = S*X/(9000*(1+S));*/ source = 0.002; dS[eqn] = 0.0;

return source; }

DEFINE_SOURCE(Total_src,cell,thread,dS,eqn) { real source, S, X; if(!Data_Valid_P()) return 0.0; S = C_YI(cell,thread,0)*C_R(cell,thread); X = C_YI(cell,thread,1)*C_R(cell,thread); source = -S*X/(900*(1+S))+S*X/(9000*(1+S)); source = 0.0; dS[eqn] = 0.0;

return source; }

 Greg Perkins July 11, 2002 19:20

Re: help on UDF mass source

Looks like you have an unnecessary source=0.0; in your Total_src routine.

Greg

 shao1 July 11, 2002 20:36

sorry, I put on the wrong code

Sorry, I put on the wrong code. Here is the code with problem. Please find the problem for me. Thanks!

-------------------------------------------------

{

real source, S, X;

if(!Data_Valid_P()) return 0.0;

source = -S*X/(900*(1+S));

dS[eqn] = 0.0;

return source;

}

{

real source, S, X;

if(!Data_Valid_P()) return 0.0;

source = S*X/(9000*(1+S));

dS[eqn] = 0.0;

return source;

}

{

real source, S, X;

if(!Data_Valid_P()) return 0.0;