# Particle cooling rate - UDF

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

 January 11, 2012, 10:50 Particle cooling rate - UDF #1 Member   Theodoros Papadopoulos Join Date: Mar 2011 Posts: 36 Rep Power: 7 Hi all, I want to simulate the cooling process of hot metal particles using air. The problem is that using the Langrangian approach the particle is calculated with one average Temperature and is really important to know the rate dT/dt inside the particle. So I suppose this can be done only through a UDF . I am thinking to implement all the heat transfer equations for tha particle through the UDF but my problem is how I will connect the heat transfer between the particle and the fluid. What I want to say is how I can define that the particleīs temperature that Fluent uses is the one at the outer surface?? One other question is how can I store and read the value of the Temperature at the previous timestep? thank you very much in advance!

 January 12, 2012, 09:59 #2 Member   Theodoros Papadopoulos Join Date: Mar 2011 Posts: 36 Rep Power: 7 Can anyone help me? I donīt think that I am asking something really complicated! It is urgent to finish it by Sunday! I just want to know how I can define that the temperature at the outer surface should be used for the next step as particle temperature fot the heat exchange between particle and fluid! Thanks!

January 13, 2012, 07:43
#3
Senior Member

Join Date: Jun 2011
Posts: 125
Rep Power: 7
Quote:
 Originally Posted by papteo Can anyone help me? I donīt think that I am asking something really complicated! It is urgent to finish it by Sunday! I just want to know how I can define that the temperature at the outer surface should be used for the next step as particle temperature fot the heat exchange between particle and fluid! Thanks!
You can use the following code to determine particle temperature:

http://www.pasteit.in/1745

 January 13, 2012, 07:53 #4 Member   Theodoros Papadopoulos Join Date: Mar 2011 Posts: 36 Rep Power: 7 Thank you mali28 for your answer. But I donīt think that you understood correctly my question, perhaps because I didnīt explain properly. What I want to do is to calculate through the UDF a function T(r) where r is the diameter of particle! because according to the temperature and some criterias it would be calculated the thickness of the solid part of the particle. After calculating this value I want to pass back to fluent the outer surface particle temperature calculated from the UDF for example T(4) where 4=mm as the P_T(p). Can you help me with this? Thanks again for your reply

January 13, 2012, 11:31
#5
Senior Member

Join Date: Jun 2011
Posts: 125
Rep Power: 7
Quote:
 Originally Posted by papteo Thank you mali28 for your answer. But I donīt think that you understood correctly my question, perhaps because I didnīt explain properly. What I want to do is to calculate through the UDF a function T(r) where r is the diameter of particle! because according to the temperature and some criterias it would be calculated the thickness of the solid part of the particle. After calculating this value I want to pass back to fluent the outer surface particle temperature calculated from the UDF for example T(4) where 4=mm as the P_T(p). Can you help me with this? Thanks again for your reply
It will be highly computationally expensive if you have large number of particles in the simulation. I have calculated the temperature gradient inside a spherical particle as a function of time. But I have done it in MATLAB.
You will need to use a numerical method in UDF to solve the temperature gradient within the particle. I used Crank-Nicholson method as well as Fully implicit backward (FIB) method to solve the partial differential equation for heat transfer in a sphere. FIB method is comparably less computationally expensive.
Here is the code I used in MATLAB to evaluate the temperature gradient using FIB method.
You will first need to specify the number of grid points (in the radius) where you want the temperature to be evaluated. Then use FIB to discretise the equations. The apply Gaussian elimination method to solve the unknowns.

You can use the same technique to solve it in UDF.

http://www.pasteit.in/1748

January 14, 2012, 20:41
#6
Senior Member

Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 193
Rep Power: 8
I think this would assume that thermal gradients within the particle are handled properly. I've read nothing in the Fluent manual to suggest that the out-of-the-box treatment of Lagrangian particles is anything other than a lumped capacitance solution (i.e. the particle temperature is constant throughout). You should verify the correctness of this assumption by taking a look at the Biot number of your particle(s).

ComputerGUy

Quote:
 Originally Posted by papteo Thank you mali28 for your answer. But I donīt think that you understood correctly my question, perhaps because I didnīt explain properly. What I want to do is to calculate through the UDF a function T(r) where r is the diameter of particle! because according to the temperature and some criterias it would be calculated the thickness of the solid part of the particle. After calculating this value I want to pass back to fluent the outer surface particle temperature calculated from the UDF for example T(4) where 4=mm as the P_T(p). Can you help me with this? Thanks again for your reply

 January 16, 2012, 04:28 #7 Member   Theodoros Papadopoulos Join Date: Mar 2011 Posts: 36 Rep Power: 7 Thank you very much both for your answer. I think that my assumption is not wrong as long as I return to Fluent the value of the outer surface as the particle temperature and then I calculate the temperature profile within the particle through the UDF. The only think is I donīt know how to pass this information back. I don`t think that writing for example P_T(p) = 1500 is correct. Does anyone of you know how can I define it at the UDF

January 17, 2012, 00:01
#8
Senior Member

Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 193
Rep Power: 8
P_T(p)=1500 is absolutely fine, so long as p is a pointer to a particle. It will need to be placed in the appropriate loop (which loops over all particles in an Injection), or in a routine which passes the p pointer directly.

Have a look here: Here

or

Here

For some DPM-specific macros. The second link, in particular, has an instance where the particle temperature is set.

Quote:
 Originally Posted by papteo Thank you very much both for your answer. I think that my assumption is not wrong as long as I return to Fluent the value of the outer surface as the particle temperature and then I calculate the temperature profile within the particle through the UDF. The only think is I donīt know how to pass this information back. I don`t think that writing for example P_T(p) = 1500 is correct. Does anyone of you know how can I define it at the UDF

 January 17, 2012, 04:30 #9 Member   Theodoros Papadopoulos Join Date: Mar 2011 Posts: 36 Rep Power: 7 Thank you very much ComputerGuy for your answer! I will try this and if I have a problem I will post it! As soon as I manage to write the appropriate UDF I will post it also at this thread! Thank you very much again!

 January 26, 2012, 12:36 #10 Member   Theodoros Papadopoulos Join Date: Mar 2011 Posts: 36 Rep Power: 7 Hi again, I start writing the following UDF, I am not sure if I programmed everything correclty as I am new to the UDF field. The first part should read all the injections and write the temperature value at each time step as UDMI. The second part should include all the appropriate equations to calculate the heat transfer inside the particle but I again I donīt know if I read correctly the values and set the parameters! I would be really grateful if someone of you could help me with this stuff. Thank you very much in advance!!! :-) #include"udf.h" #include"dpm.h" 　 　 DEFINE_ON_DEMAND(UDMInit) { /* run this first to initialize your UDM*/ Domain *d; /* declare domain pointer since it is not passed a */ /* argument to DEFINE macro */ real PS_temp; Thread *ct; cell_t c; Particle *p; /* Loop over all cell threads in the domain */ 　 loop(p,I->p) /* Standard Fluent Looping Macro to get particle streams in an Injection */ { cell = P_CELL(p,t); /* Get the cell and thread that the particle is currently in */ cthread = P_CELL_THREAD(p); PS_temp = P_T(p,t); /* PS_temp Particle outer surface Temperature */ C_UDMI(c,t,0) = PS_temp; } } 　 DEFINE_ADJUST(tparticle, d) { real PS_temp; real Q; real PSnew_temp; Thread *ct; cell_t c; Particle *p; #define dx=0.000001 /* step to iterate inside the particle */ loop(p,I->p) { begin_c_loop(c,t) { PSnew_temp= P_CELL(p,t); k=-0,0029*PSnew_temp^6 + 0,08*PSnew_temp^5 - 0,8523*PSnew_temp^4 + 4,3974*PSnew_temp^3 - 11,448*PSnew_temp^2 + 14,239*PSnew_temp - 4,8363 /* thermal conductivity depending on Temperature */ Q=k*(P_DIAM(p)/2)*(PSnew_temp-C_UDMI(c,t,0)) /*calculate the heat between two steps! */ /* now I am trying a way to implement what is happening within the particle and the solidification criteria! /* } end_c_loop(c,t) }

January 29, 2012, 10:28
#11
Senior Member

Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 193
Rep Power: 8
Theodoros,

I assume your code isn't working, which is why you've posted it here.

There are a few syntax errors with the code. The first one which is clear is:
• k=-0,0029*PSnew_temp^6 + 0,08*PSnew_temp^5 - 0,8523*PSnew_temp^4 + 4,3974*PSnew_temp^3 - 11,448*PSnew_temp^2 + 14,239*PSnew_temp - 4,8363

You cannot use ^ to define exponentiation. You need to use pow (double base, double exponent);

I also don't know that C/Fluent supports localization; you'll probably need to convert you numbers with commas "-0,0029" into numbers with decimals "-0.0029"

• I don't see where you're actually getting a pointer to the injections in the define_adjust macro

You need something like:
Code:
```DEFINE_ON_DEMAND(UDMInit)
{
Injection *AllInject;
Injection *I;
Particle *p;
AllInject = Get_dpm_injections();
Loop(I, AllInject)
{
Loop(p, I->p)
{
C_UDMI(c,t,0) = P_T(p);
}
}
}```
Let's get a few bits of code working before you try and tackle more complex stuff. Let us know if the above works.

ComputerGuy

Quote:
 Originally Posted by papteo Hi again, I start writing the following UDF, I am not sure if I programmed everything correclty as I am new to the UDF field. The first part should read all the injections and write the temperature value at each time step as UDMI. The second part should include all the appropriate equations to calculate the heat transfer inside the particle but I again I donīt know if I read correctly the values and set the parameters! I would be really grateful if someone of you could help me with this stuff. Thank you very much in advance!!! :-) #include"udf.h" #include"dpm.h" 　 　 DEFINE_ON_DEMAND(UDMInit) { /* run this first to initialize your UDM*/ Domain *d; /* declare domain pointer since it is not passed a */ /* argument to DEFINE macro */ real PS_temp; Thread *ct; cell_t c; Particle *p; /* Loop over all cell threads in the domain */ 　 loop(p,I->p) /* Standard Fluent Looping Macro to get particle streams in an Injection */ { cell = P_CELL(p,t); /* Get the cell and thread that the particle is currently in */ cthread = P_CELL_THREAD(p); PS_temp = P_T(p,t); /* PS_temp Particle outer surface Temperature */ C_UDMI(c,t,0) = PS_temp; } } 　 DEFINE_ADJUST(tparticle, d) { real PS_temp; real Q; real PSnew_temp; Thread *ct; cell_t c; Particle *p; #define dx=0.000001 /* step to iterate inside the particle */ loop(p,I->p) { begin_c_loop(c,t) { PSnew_temp= P_CELL(p,t); k=-0,0029*PSnew_temp^6 + 0,08*PSnew_temp^5 - 0,8523*PSnew_temp^4 + 4,3974*PSnew_temp^3 - 11,448*PSnew_temp^2 + 14,239*PSnew_temp - 4,8363 /* thermal conductivity depending on Temperature */ Q=k*(P_DIAM(p)/2)*(PSnew_temp-C_UDMI(c,t,0)) /*calculate the heat between two steps! */ /* now I am trying a way to implement what is happening within the particle and the solidification criteria! /* } end_c_loop(c,t) }

Last edited by ComputerGuy; January 29, 2012 at 10:29. Reason: Adjusted particle temperature code

 Tags cooling rate, particle, particle temperature, udf

 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 natantyt Fluent UDF and Scheme Programming 5 July 25, 2016 08:17 ADI FLUENT 3 June 23, 2014 17:31 a.lynchy Fluent UDF and Scheme Programming 21 February 15, 2014 03:18 JJi Fluent UDF and Scheme Programming 0 May 12, 2009 04:32 dm2747 FLUENT 0 April 17, 2009 01:29

All times are GMT -4. The time now is 02:05.