CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Particle cooling rate - UDF (https://www.cfd-online.com/Forums/fluent-udf/96057-particle-cooling-rate-udf.html)

 papteo January 11, 2012 10:50

Particle cooling rate - UDF

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!

 papteo January 12, 2012 09:59

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!

 papteo January 13, 2012 07:53

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?

 mali28 January 13, 2012 11:31

Quote:
 Originally Posted by papteo (Post 339170) 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

 ComputerGuy January 14, 2012 20:41

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 (Post 339170) 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

 papteo January 16, 2012 04:28

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

 ComputerGuy January 17, 2012 00:01

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 (Post 339476) 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

 papteo January 17, 2012 04:30

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!

 papteo January 26, 2012 12:36

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;
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 */
PS_temp = P_T(p,t);
/* PS_temp Particle outer surface Temperature */

C_UDMI(c,t,0) = PS_temp;
}
}

{
real PS_temp;
real Q;
real PSnew_temp;
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)
}

 ComputerGuy January 29, 2012 10:28

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: