# Temperature-dependent source term udf

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

 May 12, 2013, 09:42 Temperature-dependent source term udf #1 New Member   ashkan Join Date: May 2013 Posts: 12 Rep Power: 4 Dear all I have one problem in fluent udf.I want to write one temperature-dependent source term.I want my temperature increase up to 350K because of source term,and when it reach to 350K ,source term is stop and because of free convection the temperature come back to initial values and again this cycle continue.I write one udf but I have really problem in this,please help me. I sent the my UDF, #include "udf.h" DEFINE_SOURCE(cell_source, cell, thread) { real source; real temp = C_T(cell, thread); if(temp <350.15) { source=20000000*(1+.02*(temp-250.15)); } if(temp>=350.15) { while(temp>=250.15) { temp = C_T(cell, thread); source=0; } } return source; }

May 12, 2013, 20:34
#2
Senior Member

Join Date: Aug 2011
Posts: 315
Rep Power: 11
You should have a clear definition of the point when the source terms should be switch on, and you should tell us whether such switch is global or cell-wise.

Quote:
 Originally Posted by ashkan_1984 Dear all I have one problem in fluent udf.I want to write one temperature-dependent source term.I want my temperature increase up to 350K because of source term,and when it reach to 350K ,source term is stop and because of free convection the temperature come back to initial values and again this cycle continue.I write one udf but I have really problem in this,please help me. I sent the my UDF, #include "udf.h" DEFINE_SOURCE(cell_source, cell, thread) { real source; real temp = C_T(cell, thread); if(temp <350.15) { source=20000000*(1+.02*(temp-250.15)); } if(temp>=350.15) { /* this branch results in an indefinite loop */ while(temp>=250.15) /*always true because temp >= 350.15*/ { /* it does not change the value of temp */ temp = C_T(cell, thread); source=0; } } return source; }

 May 13, 2013, 06:04 reply #3 New Member   ashkan Join Date: May 2013 Posts: 12 Rep Power: 4 Thanks for your answer, The temperature of the center of channel is important for me where the cordinate axis is (0,0,0). I have problem in second loop,when source==0,because of free convection the cell is cooled and temperature is decrease.I want when temperature reach to initial value again repeat the cycle.

 May 13, 2013, 20:28 #4 Senior Member   Join Date: Aug 2011 Posts: 315 Rep Power: 11 The reference cell is fixed so that you could find cell index cell_at_0 and cell thread thread_at_0 once for all. Replace the "???" by the values you find for that particular value. The value of T_lower should be a bit higher than the initial and surrounding values, or the source may never be turned on again. #include "udf.h" #define T_upper 350.15 #define T_lower 250.15 Thread *thread_at_0; cell_t cell_at_0; DEFINE_ON_DEMAND(once_for_all) { /*The solution is provided by William Wangard*/ CX_Cell_Id *cc; real p0[]={0.0, 0.0, 0.0}; CX_Start_ND_Point_Search(); cc = CX_Find_Cell_With_Point(p0); if ( NNULLP(cc) ) { thread_at_0 = cc->ct.t; cell_at_0 = cc->ct.c; } else { Error("Point not in domain\n"); } CX_End_ND_Point_Search(); } DEFINE_SOURCE(cell_source, cell, thread) { static int SRC_ON=1; real source; real temp = C_T(cell_at_0, thread_at_0); if(temp>=T_higher) { SRC_ON = 0; } if (temp < T_lower) { SRC_ON = 1; } if(SRC_ON) { source=20000000*(1+.02*(temp-250.15)); } else { source = 0. } return source; } Last edited by blackmask; May 15, 2013 at 19:40.

 May 14, 2013, 08:24 reply #5 New Member   ashkan Join Date: May 2013 Posts: 12 Rep Power: 4 I used your udf code but I have some problem that I said in following: 1-I give cell_at_0 and thread_at_0 the center of my channel cordinate [0,0,0] but the system get a error. 2-the fluent give error to static int SRC_ON=1 and I change it to int SRC_ON=1 3-the fluent give error to real temp = C_T(cell0, thread0); and I change it to real temp = C_T(cell, thread); 4-after this changes,I run the fluent but unfortunately my temperature isn,t increase. I sent the last udf I used #define cell_at_0 [0,0,0] #define thread_at_0 [0,0,0] #define T_upper 353.15 #define T_lower 280.15 #include "udf.h" DEFINE_SOURCE(cell_source, cell, thread) { int SRC_ON=1; real source; real temp = C_T(cell, thread); if (temp>=T_upper) { SRC_ON=0.0; } if(temp<=T_lower) { SRC_ON=1.0; } if(SRC_ON) { source=20000000*(1+.02*(temp-250.15));} else { source=0.0; } return source; }

 May 14, 2013, 21:44 #6 Senior Member   Join Date: Aug 2011 Posts: 315 Rep Power: 11 I have modified my code in my last post but have never test it. I will give you some suggestion but I really do not have the time for the entire solution.

 May 15, 2013, 05:05 reply #7 New Member   ashkan Join Date: May 2013 Posts: 12 Rep Power: 4 Thank you dear, in fact this is my M.S. thesis and I try to in for a long time.I am really confused.

 May 15, 2013, 06:50 #8 Senior Member   Join Date: Aug 2011 Posts: 315 Rep Power: 11 Message me if you need help. The code I posted above should work for some versions of fluent. It seems that FLUENT has modified the interface for some functions among different versions.

 May 15, 2013, 14:57 reply #9 New Member   ashkan Join Date: May 2013 Posts: 12 Rep Power: 4 I have this error in fluent 6.3 for this sentence cc = CX_Find_Cell_With_Point(p0); CX_Find_Cell_With_Point: argument 1 type mismatch (float instead of pointer to float) and in fluent 14 for this sentence CX_Start_ND_Point_Search() I have this error: CX_Start_ND_Point_Search: undeclared variable

 May 15, 2013, 19:41 #10 Senior Member   Join Date: Aug 2011 Posts: 315 Rep Power: 11 Sorry. The line real p0={0.0, 0.0, 0.0}; should be changed to real p0[] = {0.0, 0.0, 0.0};

 May 16, 2013, 04:38 reply #11 New Member   ashkan Join Date: May 2013 Posts: 12 Rep Power: 4 Sorry for my more question,I'm really beginner in udf. Now I have this error for this line thread_at_0 = cc->ct.t; fluent write; structure reference not implemented I remove the _ and write this line like this thread_at_0 = cc>ct.t; but again fluent said ct: undeclared variable

 May 16, 2013, 05:03 #12 Senior Member   Join Date: Aug 2011 Posts: 315 Rep Power: 11 Did you interpret the UDF? Try compile it.

 May 16, 2013, 11:03 reply #13 New Member   ashkan Join Date: May 2013 Posts: 12 Rep Power: 4 I try to learn how to compile the file,after that I message you again. Thanks

 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 zxj160 OpenFOAM 18 July 30, 2013 13:14 natantyt FLUENT 1 July 27, 2011 14:07 Christian FLUENT 4 August 1, 2009 05:53 jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51 mauricio sanchez FLUENT 0 August 30, 2005 15:56

All times are GMT -4. The time now is 04:46.