CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Writing UDF (DEFINE_PROFIL) for two surfaces (http://www.cfd-online.com/Forums/fluent-udf/77267-writing-udf-define_profil-two-surfaces.html)

 Geisel June 18, 2010 01:33

Writing UDF (DEFINE_PROFIL) for two surfaces

Hi everyone,

I am a little bit confused, UDF is a new thing for me, never tried it (never need it) but now i have to calculate something different.

The matter is a two different size surfaces inside some space (as on sketch), each has different temperature profil.

I have tried to write UDF code in order to set proper termal distribution along two surfaces and only the upper one is evenly distributed, for bottom surface it is completly incorrect (I had a negative temperatures what is impossible for my case).
I think the problem can lies on coordinates taken into consideration for both surfaces.
Maybe for cases including more than one UDF functions (for couple things in Fluent) syntax looks completly different... I do not know, did not find that in UG.

I appreciate for any help or tips.

enclosured code and sketch:
Code:

```#include "udf.h" DEFINE_PROFILE(GK_sp,thread,index) { real x[ND_ND]; real y; face_t f; begin_f_loop(f,thread) { F_CENTROID(x,f,thread); y=x[1]; F_PROFILE(f,thread,index)=191.8 + 178.474*y; } end_f_loop(f,thread) }    DEFINE_PROFILE(ZK_sp,thread,index) { real x[ND_ND]; real y; face_t f; begin_f_loop(f,thread) { F_CENTROID(x,f,thread); y=x[1]; F_PROFILE(f,thread,index)=48.25 + 64.*y; } end_f_loop(f,thread) } Some explonations: I assume the centre in the middle of surface in that case I have adequately temperature in the middle +- temperature gradient*appriopriate length```
Legend:
1-GK
2-ZK
http://img24.imageshack.us/img24/9299/sketchne.jpg

Have a nice day

 om1234 June 18, 2010 17:00

dear friend
I cant understand what ur model is,but i can told u that:
x[0]= x coordinate
x[1]= y coordinate
x[2]= z coordinate.
define_profile is used to specify values in BCs and as i can find out lines 1,2 r interior, and i think it's not correct to use this macro here. if u wanna specify temp in part of ur studied domain u can use define-adjust profile to do this.
in addition u can test ur udf with printf() to see the answers in fluent graph window.

y=x[1];
the bold is important

 Geisel June 19, 2010 07:11

Sketch was a rough interpretation of my work. My project is a plate heat exchanger with sophisticated shape of corrugations. I am trying to obtain a much simpler model of it trying to set a proper (analytical results) temperatures along the fluid flow. Actual those lines are rectangular shapes of plates.

From the UDF UG examples chapter I know that 0,0 coordinates should be on the middle of surface, in my case 0,0 is at the bottom left end of outlet surface. Can this be a problem? I used F_centroid because i thought that UDF will take those coordinates as an origin for calculation, but the temperature distribution is not the same like in my code.

I have tried to put:
Code:

`printf("answers:%f\n:",F_PROFILE);`
into my code
but Fluent says that F_profile is undeclared

I am experienced with Fortran, but nonetheless it has a little bit different syntax

EDIT:

I found the reason. In UDF all variables must be in SI i.e. temperature in K, I set it in C grad.
The second one was the length y. I thought that y in formula is (current surface length)/2 but it looks like y = the whole length.

 om1234 June 20, 2010 09:09

hi
i'm not experienced with heat transfer. and i dont know what do u want to do and if it is correct or not. but i think can help u to write this udf.
at first, u wanna specify temp in line 1&2,is it right?
if it is, so line 1&2 are intereior/thread and as i told u, ]u cant use f_profile(it is used with define_macro to specify values in boundary conditions,there is 3 arg in this macro f,t,i and the third one refer to type of your boundary for example if it is pressure outlet,it is refered to p value and here u dont have any thing that arg i is refer to it and it's why printf show u nothing )to specify temp in these lines.
u need to use define_adjust to do it. and how?
u have 2 option:
1. u can specify line 1 &2 as a interior(u can do it in gambit;e.g u can split your base figure with a right plane and specify the interior/interface as a wall. when u run your model in fluent,fluent automatically create a wall shadow and u can change wall to interior ).in this case there is a macro,Thread *t=Lookup_Thread(domain,ID), that can use it to find the thread ID(interior line) and u can use macro C_T(f,t) and i'm not sure if u can use F_T(f,t) in interior to define the temp of that cell/face centroid.
2.u can define an interior(e.g interior for x coordinate and in here a constant value for y coordinate).
i'm going to write a udf like the first one(but for pressure) and if u want i can share it with u in few days(maybe hours).
read the define boundary condition in just one cell face thread for some information about the macros.
about ur question, i think there is no problem, because i dont think there is any dependence between them,macro f-profile get the coordinates of the centroid and it's not depend on where the origin coordinate system is,and in addition u can test it with printf("aaaaaaaa:%f\n",y)
best regard

 om1234 June 20, 2010 09:49

u can use this simple udf to get the centroid(if lines 1&2 have been defined in control panel and had ID no.)
#include"udf.h"

#include"udf.h"

{

face_t f;
int ID=line 1 or 2 ID;/*u can get the ID in define boundary condition panel
real x[ND_ND];

begin_f_loop(f, t)
{
F_CENTROID(x,f,t);

printf("cccccccccc:%f,%f,%f\n",x[0],x[1],x[2]);
}
end_f_loop(f, t)
}

 Geisel June 21, 2010 08:38

Quote:
 Originally Posted by om1234 (Post 263756) (...)
Thank you, I will check it later.
UDF is still beyond my comprehension, but I made a progress, though I have just started to learn it.

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