CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to do UDF for temperature profile on a semi-disc? (https://www.cfd-online.com/Forums/fluent-udf/150584-how-do-udf-temperature-profile-semi-disc.html)

Reivax March 25, 2015 17:13

How to do UDF for temperature profile on a semi-disc?
 
Hello everyone,
I'm new in the world of CFD, started it for a school project and I'm struggling with UDFs right now. I've been through the Ansys Fluent UDF Manual (release 14.5 from October 2012) and I still don't get how it works.

Here's my problem:
I've got this model ; a fluid enter by the inlet and exit by the outlet, the other faces are walls except for the back which is defined as a symmetry.
http://img15.hostingpics.net/thumbs/...91geometry.png
The upside Wall is set to a temperature of 700K and 270K for the downside.
What I want to do is to apply a linear variation of the temperature to the front face following the radii. So whichever radius you chose the variation will be the same.
http://img15.hostingpics.net/thumbs/...xplanation.png

I've seen there are define_profile function examples in the manual and managed to use one of theme for a simpler case, but I don't know how to adapt it to my present case.
I was thinking of something like : for each point, measure the distance to the origin, using this value to find the equivalent point on a lane for wich I can easily write the temperature profile (for example y=0) and apply the same temperature. But I don't know how to proceed.

Does anyone can help me ?
Thank you in advance.


Note
Here the UDF I adapted from the manual for this geometry
http://img15.hostingpics.net/thumbs/...67315barre.png

Quote:

#include "udf.h"

DEFINE_PROFILE (gradient_temp1,t,i)
{
real x[ND_ND];
real y;
face_t f;

begin_f_loop (f,t)
{
F_CENTROID(x,f,t);
y = x[0];
F_PROFILE(f,t,i) = -150*y - 200;
}
end_f_loop (f,t)
}


`e` March 25, 2015 17:32

The DEFINE_PROFILE macro is for defining custom boundary conditions, not initialising your domain. It sounds like you're trying to input the expected result into Fluent, whereas Fluent computes the temperature with the energy equation!

Set the inner and outer faces with constant temperatures (270 K and 700 K, respectively, as you've stated) and initialise the domain with the average temperature (485 K). Next, enable the energy equation and solve.

If you're having convergence issues and/or really want to initialise the domain with the expected temperature profile, then look into patching.

Reivax March 25, 2015 17:39

Hi, thank you for your reply.
Actually I'm asked by my professor to set up a linear variation of the temperature as an input parameter. I know it's possible since I've done it in the simple case I talked about in my previous post but I don't know how to write properly the UDF for the present model.

`e` March 25, 2015 17:58

Well I suppose if you must initialise the temperature within the domain then you could use the DEFINE_INIT macro (set the temperature as you loop through all cells). Furthermore, if you want to force this temperature field at every iteration, then you could use the DEFINE_ADJUST macro (although forcing this temperature field could cause convergence issues).

pakk March 26, 2015 05:39

The way I read Reivax' question, it is not an initialization problem, but he really wants a boundary condition.

This is possible, and conceptually not so difficult: instead of
Code:

y = x[0];
which gives "y" the value of the x-coordinate, you need to calculate the distance to the center of your disc, something like
Code:

y = sqrt(x[0]*x[0]+x[1]*x[1]);
But, although it is possible to implement it, I think it is smarter to take a step back. Why does your professor ask you to do this? Is it really a boundary condition that the temperature is linear? Or is it more an expected result? Ask your professor about this. Try to understand why he asks you to do things.
In your case, I would say it is much better to put a adiabatic boundary condition on the front wall. So that there is no heat flux through the wall. The outcome will be that the temperature profile is (nearly) linear.

And it is much more logical to assume an adiabatic wall than to assume a linear temperature profile.

Reivax April 7, 2015 23:54

Thank you Pakk, your anwser help me solve the problem.
To anwser your question, we simulate a linear variation of the temperature on the to observe its impact on the fluid flow and the htc.


All times are GMT -4. The time now is 16:14.