CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDS source term

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2012, 00:55
Default UDS source term
  #1
New Member
 
Mukesh
Join Date: Sep 2012
Posts: 28
Rep Power: 13
er.mkumar is on a distinguished road
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 is offline   Reply With Quote

Old   December 6, 2012, 06:59
Default UDS source is not returning value to Energy source term
  #2
New Member
 
Mukesh
Join Date: Sep 2012
Posts: 28
Rep Power: 13
er.mkumar is on a distinguished road
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.
er.mkumar is offline   Reply With Quote

Old   January 29, 2013, 12:51
Default
  #3
New Member
 
Jeremiah Lin
Join Date: Jan 2013
Posts: 2
Rep Power: 0
weloveUDF is on a distinguished road
Quote:
Originally Posted by er.mkumar View Post
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.
weloveUDF is offline   Reply With Quote

Old   January 31, 2013, 17:26
Default
  #4
New Member
 
Mukesh
Join Date: Sep 2012
Posts: 28
Rep Power: 13
er.mkumar is on a distinguished road
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
er.mkumar is offline   Reply With Quote

Old   January 14, 2014, 05:06
Default
  #5
New Member
 
Long Nguyen
Join Date: Sep 2013
Posts: 11
Rep Power: 12
longbk is on a distinguished road
Quote:
Originally Posted by er.mkumar View Post
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
longbk is offline   Reply With Quote

Reply

Tags
source term, uds source

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDS source term units Ale FLUENT 3 March 29, 2017 08:08
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 11:57
lid-driven cavity in matlab using BiCGStab Don456 Main CFD Forum 1 January 19, 2012 16:00
Large source term in species equation MACFD FLUENT 4 January 4, 2011 15:16
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 04:43


All times are GMT -4. The time now is 11:02.