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/)
-   -   udf for heat generation (https://www.cfd-online.com/Forums/fluent-udf/123809-udf-heat-generation.html)

sarah l September 21, 2013 13:21

udf for heat generation
 
hi ,
I am supposed to write a udf for a heat generation that depends on time and space . here its formula:

Q(t0,ts)=Q_0(X)*A*(ts^ (–a)-( t_0 + ts)^(-a))

Q_0(X)=(5000*sin(0.285*x[0])+ 1800)
t_0=35424000
i try to write a udf
#include "udf.h"
#include "math.h"

DEFINE_SOURCE(energy_source,c,t,dS,eqn)
{
real x[ND_ND];
real source;
real t = CURRENT_TIME ;
real t_0;
cell_t c;
t_0=35424000;
begin_c_loop(c,t)
{
C_CENTROID(x,c,t);
if((t>0.1) && (t<10))
{
source = (4958000*sin(0.285*x[0])+ 1866900)*0.0603*
(pow(t,-0.0639)-pow(t+t_0, -0.0639) ;
dS[eqn] = 1416001.489*cos(0.285*x[0])*0.0603*(pow(t,-0.0639)-pow(t+t_0, -0.0639) ;
return source;
}
if((t>10) && (t<150))
{
source = (4958000*sin(0.285*x[0])+ 1866900)*0.0766*(pow(t,-0.181)-pow(t+t_0, -0.181) ;
dS[eqn] = 1416001.489*cos(0.285*x[0])* 0.0766*(pow(t,-0.181)-pow(t+t_0, -0.181) ;
return source;
}
if((t>150) && (t<4000000))
{
source = (4958000*sin(0.285*x[0])+ 1866900)*0.13*(pow(t,-0.283)-pow(t+t_0, -0. 283) ;
dS[eqn] = 1416001.489*cos(0.285*x[0])* 0.13*(pow(t,-0.283)-pow(t+t_0, -0. 283);
return source;
}
if((t>4000000) && (t<200000000))
{
source = (4958000*sin(0.285*x[0])+ 1866900)*0.266*(pow(t,-0.335)-pow(t+t_0, -0. 335) ;
dS[eqn] = 1416001.489*cos(0.285*x[0])* 0.266*(pow(t,-0.335)-pow(t+t_0, -0. 335);
return source;
}
end_c_loop(c,t)
}

but there are some errors !
is there any nice person who help me to correct it?
Thanks

David UTFSM MEC October 16, 2013 17:48

Hey! its an old post but anyway,.. im working too with source terms .

i think you dont need the cell loop in the define_source macro, cause this is already looping on the cell thread zone.

another thing, the variable t that you are using could be a problem, cause its been used for time and threat pointer at the same time. i hope it helps


All times are GMT -4. The time now is 19:30.