CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF (https://www.cfd-online.com/Forums/fluent/36282-udf.html)

Suvash April 6, 2005 02:44

UDF
 
Hi How can I write a UDF of the boundary condition T(t)=Tm+Asin(wt), where T is the temperature, t=time, Tm=mean temaperature, A= amplitude=DeltaT/2, w=2pi/P=angular freequency, P=24 for the fluent....

P April 6, 2005 05:10

Re: UDF
 
ITs very easy just check some examples in udf document. P

Suvash April 6, 2005 05:41

Re: UDF
 
Hi P, Thanks for your advice. I wrote the following but could not getting the result.

#include "udf.h" DEFINE_PROFILE(Surface_hotflux_profile,t,i) { real x[ND_ND]; /* this will hold the position vector */ /* real xS; y direction */ /* real tempS; surface temperature*/

/* real Bi=1.; Biot number*/ real deltaTime=86400.; /* recycling time of day and night*/

real timeB=RP_Get_Real("flow-time"); real vt; face_t f;

if ( timeB<deltaTime) /*1 recycling*/

{

vt=timeB;

} if ( timeB>=deltaTime) /*2 recycling*/

{

vt=timeB-deltaTime;

}

if ( timeB>=deltaTime*2.) /*3 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*3.) /*4 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*4.) /*5 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*5.) /*6 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*6.) /*7 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*7.) /*8 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*8.) /*9 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*9.) /*10 recycling*/

{

vt=vt-deltaTime;

}

if ( timeB>=deltaTime*10.) /*11 recycling*/

{

vt=vt-deltaTime;

}

if ( vt>deltaTime/2.)

{

begin_f_loop(f,t)

{

/* tempS=F_T(f,t); get temp in surface */

F_CENTROID(x,f,t);

F_PROFILE(f, t, i)=290.+5.*sin(2*3.141592654*vt/deltaTime);

}

end_f_loop(f,t)

}

else

{

begin_f_loop(f,t)

{

F_CENTROID(x,f,t);

F_PROFILE(f, t, i)=0.;

}

end_f_loop(f,t)

} }

P April 6, 2005 06:58

Re: UDF
 
Do you get some error message then cut and paste them here in order for us to help u. P

Sham April 6, 2005 23:57

Re: UDF
 
That's because you have not define sin function in the library. You need to write include math.h as well afer the include udf.h. This will define the sin function. Only UDF library is noy enough to recognise it.

Hope this help.

Sham.


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