CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDS source term (http://www.cfd-online.com/Forums/fluent-udf/109924-uds-source-term.html)

er.mkumar November 30, 2012 00:55

UDS source term
 
Dear all,

I need little help to write my UDS source term.
My equation represents reaction rate and is represented as:

(dX/dt) = k_a*e^(-Ea/(R_u*T))*((P_i - P_eq)/P_eq)*(1-X)

where,
X is concentration at any time instant 't' [0< X <1]
k_a is reaction constant
E_a is activation energy (Constant)
R_u is universal gas constant
T is temperature of cell
P_i is initial supply pressure (constant)
P_eq is equilibrium pressure (dependent on 'T') defined as

ln(P_eq) = (DELTA_S/R_u)-(DELTA_H/(R_u*T))

Here, DELTA_S & DELTA_H are again constants
R_u & T are as defined above.

I wrote this, But it doesn't seem to work properly as the temperature of my domain vary radially (an annular cylinder) and hence reaction rate is different at different radii, Ideally as 'x' reaches '1' reaction should stop but when I plot 'X' contours it shows values > 1 in colder regions (suggesting reaction continues even after reaching a value >1) as this should't be.


Code:

DEFINE_UDS_UNSTEADY(uds_time,c,t,i,apu,su)
{
        real physical_dt;
        real vol;
        real rho;
        real phi_old;
        physical_dt = RP_Get_Real("physical-time-step");
        vol = C_VOLUME(c,t);
        rho = 1;
        *apu = -rho*vol/physical_dt;
        phi_old = C_STORAGE_R(c,t,SV_UDSI_M1(0));
        *su = rho*vol*phi_old/physical_dt;
}

/* Kinetic Equation SOURCE term */
/* Convection & Diffusion part are zero */
DEFINE_SOURCE(uds_source,c,t,ds,eqn)
{
        real tp;
        real rate;
        real P_eq;
        real cond;
               
        tp = C_T(c,t);
        P_eq = pow(10,5)*pow(2.72,((DELTA_S/R_u)-(DELTA_H/(R_u*tp))));
        C_UDMI(c,t,0)= P_eq;
        cond = P_i/P_eq;
       
        if(cond>1)
        {
                rate = k_a*pow(2.72,(-E_a/(R_u*tp)))*((P_i/P_eq)-1)*((C_UDSI_M1(c,t,0) - x_f)/(x_i - x_f));
                ds[eqn] = k_a*pow(2.72,(-E_a/(R_u*tp)))*((P_i/P_eq)-1)*(1/(x_i - x_f));                /* Derivative of SOURCE w.r.t. DEPENDENT variable */
        }
        else
        {
                rate = 0;
                ds[eqn] = 0;
        }
       
        C_UDMI(c,t,1) = rate;
        return rate;
       
}


er.mkumar December 6, 2012 06:59

UDS source is not returning value to Energy source term
 
Someone please help!

What I figured out was my UDS source is calculating values for various cells but I guess it is not returning the values to energy source term.

What could be the reason.

Monitoring 'rate' (UDS source) shows variations spatially (as temperature is varying spatially) But this variation is not taken up by the Energy source term although it is directly dependent on the 'rate' (UDS source).


Please, please ......someone help me out.

weloveUDF January 29, 2013 12:51

Quote:

Originally Posted by er.mkumar (Post 396093)
Someone please help!

What I figured out was my UDS source is calculating values for various cells but I guess it is not returning the values to energy source term.

What could be the reason.

Monitoring 'rate' (UDS source) shows variations spatially (as temperature is varying spatially) But this variation is not taken up by the Energy source term although it is directly dependent on the 'rate' (UDS source).


Please, please ......someone help me out.

Maybe you could try using UDM to store "rate" and to obtain "rate" by reading UDM.

er.mkumar January 31, 2013 17:26

Hello Lin,

Sorry I didn't updated the status on my work. And yes you are correct to suggest using UDM. I solved the problem using UDM. Thanks.

Regards,
Mukesh

longbk January 14, 2014 05:06

Quote:

Originally Posted by er.mkumar (Post 405399)
Hello Lin,

Sorry I didn't updated the status on my work. And yes you are correct to suggest using UDM. I solved the problem using UDM. Thanks.

Regards,
Mukesh

Dear Mukesh,

I'm working on the model of hydrogen storage by metal hydride. So, I'm very confused about the UDF code for source term. Could you share with me your UDF code just for reference?

Thank you very much

Regards,
Long Nguyen


All times are GMT -4. The time now is 17:03.