
[Sponsors] 
June 12, 2010, 06:07 
Writing UDF for heat source term

#1 
New Member
Floyd
Join Date: Jun 2010
Posts: 9
Rep Power: 15 
Dear all,
I am new to UDF and need to write some codes for a time dependent heat source term in DEFINE_SOURCE Macros. However, I don't see there is any time argument in the DEFINE_SOURCE Macros. I hope some nice persons could give me some idea of how to write codes for time dependent source term. With thanks & regards, Floyd 

June 12, 2010, 22:42 

#2 
Member
Hongjin Wang
Join Date: Mar 2010
Posts: 37
Rep Power: 15 
FLUENT provides a macro called CURRENT_TIME to return the real current flow time in seconds, and another one called CURRENT_TIMESTEP to return the physical current time step size. I think you may need this two macros. For details, please google the udf manual..
Good luck! 

June 13, 2010, 09:03 

#3 
New Member
Floyd
Join Date: Jun 2010
Posts: 9
Rep Power: 15 
Thanks for your reply,
That's the code I am using in my simulation. I don't know what I should do with the argument "cell" and "thread". Is it fine to leave them if I only need to write a time dependent source term within a solid? /************************************************** ********************* UDF for time dependent volumetric heat generation of 18650 cell ************************************************** **********************/ #include "udf.h" #define C1 8.0e3 //define constant term #define C2 4.0e6 #define C3 0.0042 #define C4 2.3582 DEFINE_SOURCE(heat_gen,cell,thread,dS,eqn) { real source; real time; time = CURRENT_TIME; //taking time value; source = C1*pow(time,3)+C2*pow(time,2)time*C3+C4; //time dependent heat source; dS[eqn] = 0; return source; } 

June 13, 2010, 22:13 

#4  
Member
Hongjin Wang
Join Date: Mar 2010
Posts: 37
Rep Power: 15 
Quote:


June 14, 2010, 01:46 

#5 
New Member
Floyd
Join Date: Jun 2010
Posts: 9
Rep Power: 15 
Thanks for your help again! Yes, what I want was just to create a heat source which is increasing with time only. I sucessfully interpreted, compiled and hooked the code into fluent. however, I got another problem. The residuals of energy didn't converged and was growing when I ran the calculation. What possible factor could make this happen?


June 14, 2010, 09:59 

#6 
Member
Hongjin Wang
Join Date: Mar 2010
Posts: 37
Rep Power: 15 
Hi,
The residuals may get more difficulities in convergence in the cases with UDF defined sources than those without sources do. Maybe your time step is to large for your case. But I have not seen your case. Hence I am not sure what exactly goes wrong. But you can try this way: first, run the case without UDF sources hooked at steady model to see whether the residuals will converge. If it will not, there might be some problems with your grids. Check your meshes. If it will, hook the UDF to your zones and Key "0" into time step in the iteration pannel. If the residuals still get divergent, chang (usually decrease ) the time step size. Run iteration till they converge. Then, type other number rather than 0 in the time step, run again. Ps: although the initial condition does nothing with the results theoriticaly, a suitable one will reduce the iteration numbers. Besides, note the iteration numbers of each time step. your case may just not run enough iterations. Or maybe the convergency conditions are too strick. 

June 15, 2010, 09:50 

#7 
New Member
Floyd
Join Date: Jun 2010
Posts: 9
Rep Power: 15 
Hi Hongjin!
I really appreciated your help, I followed your instructions and now trying on my simulation. I am actually working on a simulation of temperature changes of a battery which is generating heat along time under natural convection. It sounds pretty simple case. what kind of advise you may give me in doing a case like this? Thank you very much! 

June 18, 2010, 01:20 

#8 
Member
Hongjin Wang
Join Date: Mar 2010
Posts: 37
Rep Power: 15 
Sorry Floyd, I did not see your reply untill now. I have not done such a case. So I might not give your more detailed suggestions. Yet I know there are a lot of studies about the battery and you might find what you want. I am sorry.
Regards, Hongjin Wang 

June 18, 2010, 05:51 

#9 
New Member
Floyd
Join Date: Jun 2010
Posts: 9
Rep Power: 15 
It's Ok! you've been so nice to help me out. I 'll try to dig out the rest. Thank you very much!
Regards, Floyd 

October 15, 2010, 07:50 

#10  
New Member
samt
Join Date: Jan 2010
Posts: 13
Rep Power: 15 
Quote:
Thanks, Best regards 

June 18, 2018, 21:23 

#11  
New Member
Edwin P
Join Date: Jun 2018
Posts: 13
Rep Power: 7 
Quote:
Hi Floyd I have the same problem as you. I write a similar UDF for the source term. It compiles but does not converge. Did you solve that problem? Regards 

July 3, 2021, 02:56 
Hi there, hope everyone here is doing good! I have a small doubt in udf.

#12  
New Member
Sangeeth
Join Date: Jun 2021
Posts: 3
Rep Power: 4 
Quote:
Thanks in advance, have a good day! 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Problem of SOURCE term gradient in UDS  wind  Fluent UDF and Scheme Programming  6  December 1, 2022 14:21 
HELP! adding a mass source to VOF eqn. by UDF???  ROOZBEH  FLUENT  5  December 3, 2016 17:53 
UDF Source Term  Christian  FLUENT  4  August 1, 2009 05:53 
The source term of UDF  summer  FLUENT  0  August 24, 2006 17:44 
UDFs for Scalar Eqn  Fluid/Solid HT  Greg Perkins  FLUENT  0  October 11, 2000 03:43 