# Writing UDF (DEFINE_PROFIL) for two surfaces

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

 June 18, 2010, 01:33 Writing UDF (DEFINE_PROFIL) for two surfaces #1 New Member   Luk Join Date: Jun 2009 Posts: 24 Rep Power: 10 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 Have a nice day __________________ *******************************

 June 18, 2010, 17:00 #2 New Member   omid Join Date: Mar 2010 Posts: 17 Rep Power: 9 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. F_CENTROID(x,f,thread); y=x[1]; F_PROFILE(f,thread,index)=191.8 + 178.474*y; printf("answers:%f\n:",F_PROFILE); the bold is important Last edited by om1234; June 18, 2010 at 19:29.

 June 19, 2010, 07:11 #3 New Member   Luk Join Date: Jun 2009 Posts: 24 Rep Power: 10 Thank you for your reply, 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. __________________ ******************************* Last edited by Geisel; June 19, 2010 at 14:00. Reason: stated in post

 June 20, 2010, 09:09 #4 New Member   omid Join Date: Mar 2010 Posts: 17 Rep Power: 9 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 Last edited by om1234; June 20, 2010 at 09:29.

 June 20, 2010, 09:49 #5 New Member   omid Join Date: Mar 2010 Posts: 17 Rep Power: 9 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" DEFINE_ADJUST(pressure,domain) { face_t f; int ID=line 1 or 2 ID;/*u can get the ID in define boundary condition panel real x[ND_ND]; Thread *t=Lookup_Thread(domain,ID); 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) }

June 21, 2010, 08:38
#6
New Member

Luk
Join Date: Jun 2009
Posts: 24
Rep Power: 10
Quote:
 Originally Posted by om1234 (...)
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.
__________________
*******************************

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post golriz Fluent UDF and Scheme Programming 7 November 3, 2011 06:30 ardalan soleymani FLUENT 0 July 11, 2007 01:09 Jack Martinez FLUENT 9 June 14, 2007 10:24 Sandilya FLUENT 0 May 31, 2007 12:03 Henry Lee FLUENT 2 March 23, 2006 04:24

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