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/)
-   -   Define_Source and C_YI(c,t,i) (https://www.cfd-online.com/Forums/fluent-udf/199595-define_source-c_yi-c-t-i.html)

SanchoBuendia March 9, 2018 16:11

Define_Source and C_YI(c,t,i)
 
Hi everyone, I have a mixture flow of the salt water (water, cl- and Na+) and I've a potential in the wall on the cylinder. My problem is that I want to calculate the different force for each specie, for example, to especie Cl- the force will be positive and to Na+ negative, but I don't know how to say specify the specie in udf.

For example, it's my udf define_source

DEFINE_SOURCE(EGL,cell,thread,dS,eqn)
{
double source2;
double k;

real xc[ND_ND];

C_CENTROID(xc,cell,thread);

k = (1/pow(((ee*Kb*T)/(2*NA*pow(el,2)*ninf)),0.5));

source2 = -ee*U0*pow(k,2)*Ex;

dS[eqn] = 0.0;
return source2;

}

But I want to read the kind of specie and to choose which source to use.

Can I write this way?

DEFINE_SOURCE(EGL,cell,thread,dS,eqn)
{

if (C_YI(c,t,2))
{
double source2;
double k;

real xc[ND_ND];

C_CENTROID(xc,cell,thread);

k = (1/pow(((ee*Kb*T)/(2*NA*pow(el,2)*ninf)),0.5));

source2 = ee*U0*pow(k,2)*Ex;

dS[eqn] = 0.0;
return source2;
}

if (C_YI(c,t,3))
{
double source2;
double k;

real xc[ND_ND];

C_CENTROID(xc,cell,thread);

k = (1/pow(((ee*Kb*T)/(2*NA*pow(el,2)*ninf)),0.5));

source2 = -ee*U0*pow(k,2)*Ex;

dS[eqn] = 0.0;
return source2;
}

}

Where, C_YI(c,t,3) is the specie Cl and C_YI(c,t,2) is Na.

Thanks


All times are GMT -4. The time now is 20:14.