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/)
-   -   Changing Heat source with position (UDF) (https://www.cfd-online.com/Forums/fluent-udf/111474-changing-heat-source-position-udf.html)

Luis.Castro January 8, 2013 05:29

Changing Heat source with position (UDF)
 
Hi everybody,

I have a heat source that is changing within the distance of my model. I would like to know which is the best way to program it. I have tried with DEFINE_PROFILE and DEFINE_SOURCE but I'm still not getting satisfactory results. I am new in C langauge.

Thank you for your help,

Luis

llrr January 8, 2013 09:49

Quote:

Originally Posted by Luis.Castro (Post 400691)
Hi everybody,

I have a heat source that is changing within the distance of my model. I would like to know which is the best way to program it. I have tried with DEFINE_PROFILE and DEFINE_SOURCE but I'm still not getting satisfactory results. I am new in C langauge.

Thank you for your help,

Luis

I think DEFINE_SOURCE should be used.

Luis.Castro January 8, 2013 10:04

Thank you Ilrr,

Yes, in fact I am using DEFINE_SOURCE function but I still don't have good results.

My UDF is like follows:

Quote:

#include "udf.h"
DEFINE_SOURCE(cell_x_source, c, t, dS, eqn)
{
real x[ND_ND];
real con, source;
C_CENTROID(x,c,t);
con = 85714.28571*exp(-x[1]/0.1245);
source = con;
dS[eqn]= 0;
return source;
}
I know it might be completely wrong because it's my first time using this language, but any tip would be completely helpful. Thanks,

Luis

flotus1 January 8, 2013 10:16

Could you be a bit more specific about the results being "not good"?
Or maybe even provide some details about your setup.

Luis.Castro January 8, 2013 10:26

Well my model is a simple 2D heat simulation with microwave (heat generates directly in the liquid)

I am using Lambert's equation to model the heat generated. This equation says that heat generated decreases exponentially with distance. I am getting the opposite results (the temperature is lower next to the wall).

There is a negative exponential in the equation, so I don't know what I am defining wrong in my UDF code.

llrr January 9, 2013 03:01

Quote:

Originally Posted by Luis.Castro (Post 400749)
Well my model is a simple 2D heat simulation with microwave (heat generates directly in the liquid)

I am using Lambert's equation to model the heat generated. This equation says that heat generated decreases exponentially with distance. I am getting the opposite results (the temperature is lower next to the wall).

There is a negative exponential in the equation, so I don't know what I am defining wrong in my UDF code.

Since it is 2D, the distance you are talking about is in x direction or in y direction. I agree that some set up can have more people help you.

Luis.Castro January 9, 2013 03:38

Quote:

Originally Posted by llrr (Post 400880)
Since it is 2D, the distance you are talking about is in x direction or in y direction. I agree that some set up can have more people help you.

It's in the Y direction. But I think it's more of a coordinates problem because I guess the equations start in Y=0?. I want it to start at the wall (which is not Y=0)

Luis.Castro January 9, 2013 05:41

How can I define a local coordinate system for a specific UDF?

llrr January 9, 2013 06:29

Quote:

Originally Posted by Luis.Castro (Post 400892)
It's in the Y direction. But I think it's more of a coordinates problem because I guess the equations start in Y=0?. I want it to start at the wall (which is not Y=0)

You can use 'if' to set the limitation of y, for example,

if (0.1<x[1]<0.5) source=...

Luis.Castro January 9, 2013 09:02

Quote:

Originally Posted by llrr (Post 400927)
You can use 'if' to set the limitation of y, for example,

if (0.1<x[1]<0.5) source=...

Dear llrr,

Thank you for your suggestion, but what I really need is that the heat source function starts calculating from the wall (Like if the wall was heating the fluid) instead of the center of the fluid (where my (0,0) coordinate is located).

Like if the heat was generated from the wall to the center, not from the center to the wall

Any idea how to solve this?.

Here is my code with some small changes

Quote:

#include "udf.h"
DEFINE_SOURCE(cell_x_source, c, t, dS, eqn)
{
real x[ND_ND];
real source;
real y;
F_CENTROID(x,c,t);
y = x[1];
source = (85714*(exp(-fabs(y)/0.1245)));
dS[eqn]= 0;
return source;
}
Luis

Luis.Castro January 10, 2013 04:16

Nobody? :(

flotus1 January 10, 2013 11:40

Quote:

Originally Posted by Luis.Castro (Post 400892)
It's in the Y direction. But I think it's more of a coordinates problem because I guess the equations start in Y=0?. I want it to start at the wall (which is not Y=0)

Just shift your equation:

source = (85714*(exp(-(y-y_wall)/0.1245)));

where y_wall is the y-position of the wall

Luis.Castro January 11, 2013 04:58

Quote:

Originally Posted by flotus1 (Post 401242)
Just shift your equation:

source = (85714*(exp(-(y-y_wall)/0.1245)));

where y_wall is the y-position of the wall

I did that and the heat still seems to start from the origin.

Maybe I have to make operations with vectors?. Like if I want that my point [0 0] is in fact my point [0 0.04].

flotus1 January 11, 2013 05:12

So your wall is at a y-position of 0.04 and you want your source term to decrease away from the wall, where the y-position is SMALLER than 0.04?
Then there is just a wrong sign in your equation.

source = (85714*(exp(+(y-y_wall)/0.1245)));

Luis.Castro January 11, 2013 05:39

Quote:

Originally Posted by flotus1 (Post 401336)
So your wall is at a y-position of 0.04 and you want your source term to decrease away from the wall, where the y-position is SMALLER than 0.04?
Then there is just a wrong sign in your equation.

source = (85714*(exp(+(y-y_wall)/0.1245)));

Yes you are right.

But the heat source is supposed to decrease from the wall to the center hence the negative sign. A positive sign would make it increase. Rght?

flotus1 January 11, 2013 06:01

exp(y) increases with INCREASING y, thats right.
But what I got from the information you gave so far is that your y-position DECREASES away from the wall. Hence you need the positive sign for your heatsource to decrease.

Could you post a few images for clarification?


All times are GMT -4. The time now is 11:06.