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/)
-   -   temperature jump code (http://www.cfd-online.com/Forums/fluent-udf/113137-temperature-jump-code.html)

KHAN REHAN WASIM February 13, 2013 07:00

temperature jump code
 
I encountered the following error "temperatuejump.c: line 66: coord_coeff: undeclared variable" while solving the problem using the code mention below

/* ================================================== ======
Temperature change at wall boundaries
================================================== ==== */
#include "udf.h" /* must be at the beginning of every UDF */
#include "sg.h" /*must be at the beginning of this UDF */
#include "math.h" /* must be at the beginning of this UDF */

# ifndef SCHEMESIGMASQUARE
# define sigma_square 1.35305239e-19
# endif
# ifndef SCHEMEAMPRESS
# define ambpress 101325
# endif

# ifndef SCHEMETMAC
# define TMAC 1.0
# endif
# ifndef SCHEMEThAC
# define ThAC 1.0
# endif
# ifndef SCHEMESpHR
# define SpHR 1.4

# endif

# ifndef SCHEMEUDRLXCOEFF
# define UDRLXCOEFF 0.02
# endif

# define Boltzmann 1.3806505e-23
# define PI 3.14159265358979323846
# define SQRT_2 1.41421356237309504880

DEFINE_PROFILE(temperature_jump,f_thread,index)
{
real MeanFreePath;
#ifdef SCHEMEMFP
MeanFreePath=RP_Get_Real("meanfreepath");
#endif

#ifdef SCHEMEThAC
real ThAC= 1;
ThAC=RP_Get_Real("thac");
#endif

#ifdef SCHEMEUDRLXCOEFF
real UDRLXCOEFF=O.2;
UDRLXCOEFF=RP_Get_Real("udrlxcoeff");
#endif

#ifdef SCHEMESpHR
real SpHR;
SpHR=RP_Get_Real("sphr");
#endif

face_t face;
cell_t cell;

Thread*c_thread;

real Coeff2[ND_ND];

real Prandtl,gamma,temp,normal;

/* call the routine that computes the transformation coefficients, once per iteration should be enough*/
coord_coeff(f_thread);

/* loops over all faces in the thread passed into the DEFINE macro argument */

begin_f_loop(face,f_thread);

{
cell=F_C0(face,f_thread);
c_thread=THREAD_T0(f_thread);

#ifndef SCHEMEMFP
MeanFreePath = Boltzmann*F_T(face,f_thread)/(sigma_square*(F_P(face,f_thread)+ambpress)* PI*SQRT_2);

#endif

Prandtl=(C_MU_L(cell,c_thread)*C_CP(cell,c_thread) )/C_K_L(cell,c_thread);

ND_SET(Coeff2[0],Coeff2[1],Coeff2[2],
F_UDMI(face,f_thread,3),
F_UDMI(face,f_thread,4),
F_UDMI(face,f_thread,5));

/* evaluate the dT/dn (normal to surface) term in the local coord. system */

normal=NV_DOT(Coeff2,C_T_G(cell,c_thread));

gamma=(2*SpHR)/(SpHR+1);
temp=((2-ThAC)/ThAC)*gamma*
MeanFreePath/Prandtl*normal;
/* in order to set wall temperature a user definedd scalar variahle F_UDSI( ....,0) has to be created (its transport is not important and won't effect ths result)*/

#ifdef UNDERRLX

F_PROFILE(face,f_thread,index)=
F_T(face,f_thread)*(l-UDRLXCOEFF)+
(F_UDSI(face,f_thread,0)+temp);
#else

F_PROFILE(face,f_thread,index)=(F_UDSI(face,f_thre ad,0)+temp);

#endif

}
end_f_loop(f,thread)

}

void coord_coeff(Thread *f_thread)
{
face_t face;
cell_t cell;
Thread *c_thread;
real y[ND_ND];
real u[ND_ND],a;
real A[ND_ND];
real dr0[ND_ND],es[ND_ND],ds,A_by_es;

begin_f_loop(face,f_thread)
{
F_CENTROID(y,face,f_thread);
cell=F_C0(face,f_thread);
c_thread=THREAD_T0(f_thread);

BOUNDARY_FACE_GEOMETRY(face,f_thread,A,ds,es,A_by_ es,dr0);

ND_SET(u[0],u[1],u[2],
C_U(face,f_thread),
C_V(face,f_thread),
C_W(face,f_thread));
a=NV_MAG(u);

ND_SET(F_UDMI(face,f_thread,0),
F_UDMI(face,f_thread,1),
F_UDMI(face,f_thread,2),
NVD_DOT(u,1,0,0)/a,
NVD_DOT(u,0,1,0)/a,
NVD_DOT(u,0,0,1)/a);

ND_SET(F_UDMI(face,f_thread,3),
F_UDMI(face,f_thread,4),
F_UDMI(face,f_thread,5),
NVD_DOT(A,1,0,0)/A_by_es,
NVD_DOT(A,0,1,0)/A_by_es,
NVD_DOT(A,0,0,1)/A_by_es);
}

end_f_loop(face,f_thread)

}

I will be grateful if someone can help in solving the issue

msaeedsadeghi February 14, 2013 08:07

send this function (void coord_coeff) to top of (DEFINE_PROFILE) function.
I have modeled microchannel flow before :)

Soner_isik May 18, 2013 05:54

Hi Guys

I am trying to use UDF given above for simulating temperature jump in a micro channel. as I understood, 1 user defined scalar and 6 user defined memory units should be allocated before assigning UDF to wall temp. but when I try to use it as thermal BC, fluent gives me Fatal Signal received access violation.what should I do?

please help me
Regards
Soner


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