
[Sponsors] 
June 23, 2014, 02:10 
UDF for heat source in Soldification and melting model

#1 
New Member
karthik
Join Date: Oct 2013
Posts: 7
Rep Power: 5 
Hi all,
I am using solidification and melting model for simulating melting process for a phase change material in a spherical capsule. Only energy equation is solved. The default model assumes linear temperature enthalpy relationship. But I need to use a heat source in energy equation (enthalpy varies with temp) to incorporate polynomial enthalpy temperature relationship. My source term is: Se = density/deltaT*f[T] , (unit will be W/meter cube, since f(T) is J/kg). I wrote my UDF which is shown below. #include "udf.h" #define C1 1757.9 #define C2 3.0e6 #define C3 2e9 #define C4 1e12 #define C5 2e14 #define C6 3e16 #define C7 1e18 DEFINE_SOURCE(phase_change,cell,thread) { real source,time,rho,temp,pretime; rho = C_R(c,t); temp = C_T(c,t); time = CURRENT_TIME; pretime= PREVIOUS_TIME; source = (rho/(timepretime))*(C1*pow(temp,6)C2*pow(temp,5)+C3*pow(temp,4)C4*pow(temp,3)+C5*pow(temp,2)C6*temp+C7); return source; } Negative sign in source indicates the process is melting ( heat sink). Please kindly advise me whether this is right format and once I interpret the simulation says temp definition shadows previous definition and This deltaT is time difference between real flow time ( whether we have to take timestep difference or real flow time difference ?) During execution the cell temperature is too low. And I get temperature limited to 1.0 K in the output. Please kindly advise me about this UDF. Thanks Regards, Karthik 

June 23, 2014, 05:20 

#2 
New Member
karthik
Join Date: Oct 2013
Posts: 7
Rep Power: 5 
Awaiting for reply..
Thanks. 

June 23, 2014, 05:46 

#3 
Senior Member
Join Date: Nov 2013
Posts: 1,072
Rep Power: 14 
The "temp definition shadows previous definition" message only says that the variable "temp" that you used, is already in use somewhere else by Fluent.
To be safe, give it a different name, such as "temperature". That probably is not your problem. I think your problem is in your physics. The heat sink due to melting should not depend on the time step in your model. Right now, if you make your time step 2 times smaller, your equation tells you that more heat is removed. That makes no sense. And try to be more patient on this forum. You don't have to remind others after only 3 hours that there was no reply yet. Although your message of 11:20 was polite and well intended, it could have had the opposite effect of what you wanted. 

June 23, 2014, 06:01 

#4 
New Member
karthik
Join Date: Oct 2013
Posts: 7
Rep Power: 5 
Thanks Pakk for your kindful reply.
I will again go through the UDF and get to understand the Physics more. 

June 30, 2014, 00:09 

#5 
New Member
karthik
Join Date: Oct 2013
Posts: 7
Rep Power: 5 
Hi Pakk,
I went through the UDF again and made little corrections. Changed the temp to tempe, hence I don't see any warning.And used if condition to calculate the source for the temperature range( 300.97 to 303 K). The physical time step size (delta t) is used to avoid error due to time step incorporation in heat source term. Thanks for your suggestions. Again I like to highlight about the source term for better view: My source term is: S=ρ/∆t *∫f(T)dT ( temperature lower limit: Tsolidus; upper limit: Tliquidus) Se =  density/Time*intergral of f[T] , (unit will be W/meter cube, since f(T) is J/kg). My UDF is: #include "udf.h" #define C1 1757.9 #define C2 3.0e6 #define C3 2e9 #define C4 1e12 #define C5 2e14 #define C6 3e16 #define C7 1e18 DEFINE_SOURCE(phase_change,c,t,dS,eqn) { real rho; real source; real tempe; real time; time =RP_Get_Real("physicaltimestep"); rho = C_R(c,t); tempe = C_T(c,t); if(tempe>300.97 && tempe<303) { source = (rho/time)*((C1*pow(tempe,6))(C2*pow(tempe,5))+(C3*pow(tempe,4))(C4*pow(tempe,3))+(C5*pow(tempe,2))(C6*tempe)+C7); } else { source=0; } dS[eqn]=0; return source; } No error in temperature (like the previous one which had 1 K when the simulation runs). The simulation runs but I don't find any difference in results (temperature variation with time) with and without source to energy equation. My question is: Whether the UDF for source is correct? Since my source is a unsteady term and dependent on temperature, I assume there is an error in the source UDF ( code). Whether I have to use C_UDSI or C_UDMI for source term to update temperature in source term for every timestep? I found from manual and CFD online forum there is a unsteady udf built function. Whether it has to be combined to Define source udf.? Please kindly help me about this UDF function. Thank you. Regards, Karthik 

June 30, 2014, 02:19 

#6 
Senior Member
Join Date: Nov 2013
Posts: 1,072
Rep Power: 14 
A UDF is correct if it does want you want it to do. I don't know what you want it to do, so I can not judge that.
You explained the purpose of this udf, "simulating melting process for a phase change material in a spherical capsule", but that is not nearly detailed enough. To judge that, you would need to write down exactly the sink that you want to implement. Don't bother to do that, I will probably not want to spend time to check it. (I have other things to do ) Having said that, I still think having the time step in the sink definition is wrong. Because you should not incorporate the time step in the heat source term. I don't understand your comment that you add this "to avoid error due to time step incorporation in heat source term". If you think it is fine, ok, it's your model, but I don't believe it. 

June 30, 2014, 02:45 

#7 
New Member
karthik
Join Date: Oct 2013
Posts: 7
Rep Power: 5 
Thanks Pakk.
In my first post I took difference in flow time ( current time  previous time) for delta t. After going through UDF manual and forum I came to know that time step size is used for delta t. 

Thread Tools  
Display Modes  

