|
[Sponsors] |
May 12, 2013, 10:42 |
Temperature-dependent source term udf
|
#1 |
New Member
ashkan
Join Date: May 2013
Posts: 12
Rep Power: 13 |
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, 21:34 |
|
#2 | |
Senior Member
|
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:
|
||
May 13, 2013, 07:04 |
reply
|
#3 |
New Member
ashkan
Join Date: May 2013
Posts: 12
Rep Power: 13 |
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, 21:28 |
|
#4 |
Senior Member
|
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 20:40. |
|
May 14, 2013, 09:24 |
reply
|
#5 |
New Member
ashkan
Join Date: May 2013
Posts: 12
Rep Power: 13 |
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 15, 2013, 06:05 |
reply
|
#7 |
New Member
ashkan
Join Date: May 2013
Posts: 12
Rep Power: 13 |
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, 15:57 |
reply
|
#9 |
New Member
ashkan
Join Date: May 2013
Posts: 12
Rep Power: 13 |
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 16, 2013, 05:38 |
reply
|
#11 |
New Member
ashkan
Join Date: May 2013
Posts: 12
Rep Power: 13 |
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, 12:03 |
reply
|
#13 |
New Member
ashkan
Join Date: May 2013
Posts: 12
Rep Power: 13 |
I try to learn how to compile the file,after that I message you again.
Thanks |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF Source term problem | natantyt | FLUENT | 2 | May 15, 2018 22:40 |
[swak4Foam] swak4Foam-groovyBC build problem | zxj160 | OpenFOAM Community Contributions | 18 | July 30, 2013 14:14 |
UDF Source Term | Christian | FLUENT | 4 | August 1, 2009 06:53 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |
UDF for energy source | mauricio sanchez | FLUENT | 0 | August 30, 2005 16:56 |