CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

Particle cooling rate - UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 11, 2012, 09:50
Default Particle cooling rate - UDF
  #1
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 5
papteo is on a distinguished road
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 is offline   Reply With Quote

Old   January 12, 2012, 08:59
Default
  #2
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 5
papteo is on a distinguished road
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 is offline   Reply With Quote

Old   January 13, 2012, 06:43
Default
  #3
Senior Member
 
Join Date: Jun 2011
Posts: 105
Rep Power: 5
mali28 is on a distinguished road
Quote:
Originally Posted by papteo View Post
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
mali28 is offline   Reply With Quote

Old   January 13, 2012, 06:53
Default
  #4
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 5
papteo is on a distinguished road
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 is offline   Reply With Quote

Old   January 13, 2012, 10:31
Default
  #5
Senior Member
 
Join Date: Jun 2011
Posts: 105
Rep Power: 5
mali28 is on a distinguished road
Quote:
Originally Posted by papteo View Post
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
mali28 is offline   Reply With Quote

Old   January 14, 2012, 19:41
Default
  #6
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 178
Rep Power: 6
ComputerGuy is on a distinguished road
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 View Post
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
ComputerGuy is offline   Reply With Quote

Old   January 16, 2012, 03:28
Default
  #7
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 5
papteo is on a distinguished road
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 is offline   Reply With Quote

Old   January 16, 2012, 23:01
Default
  #8
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 178
Rep Power: 6
ComputerGuy is on a distinguished road
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 View Post
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
ComputerGuy is offline   Reply With Quote

Old   January 17, 2012, 03:30
Default
  #9
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 5
papteo is on a distinguished road
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 is offline   Reply With Quote

Old   January 26, 2012, 11:36
Default
  #10
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 5
papteo is on a distinguished road
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)
}
papteo is offline   Reply With Quote

Old   January 29, 2012, 09:28
Default
  #11
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 178
Rep Power: 6
ComputerGuy is on a distinguished road
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 View Post
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 09:29. Reason: Adjusted particle temperature code
ComputerGuy is offline   Reply With Quote

Reply

Tags
cooling rate, particle, particle temperature, udf

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF for VR Rate calculation ADI FLUENT 3 June 23, 2014 17:31
UDF to measure Mass Flow Rate a.lynchy Fluent UDF and Scheme Programming 21 February 15, 2014 02:18
Fluent UDF urgent! Variable reaction rate natantyt Fluent UDF and Scheme Programming 3 July 7, 2011 03:59
charged particle UDS, UDF JJi Fluent UDF and Scheme Programming 0 May 12, 2009 04:32
DPM UDF particle position using the macro P_POS(p)[i] dm2747 FLUENT 0 April 17, 2009 01:29


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