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

Changing Heat source with position (UDF)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 8, 2013, 06:29
Default Changing Heat source with position (UDF)
  #1
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
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
Luis.Castro is offline   Reply With Quote

Old   January 8, 2013, 10:49
Default
  #2
Member
 
Li
Join Date: Mar 2009
Posts: 54
Rep Power: 17
llrr is on a distinguished road
Quote:
Originally Posted by Luis.Castro View Post
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.
llrr is offline   Reply With Quote

Old   January 8, 2013, 11:04
Default
  #3
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
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
Luis.Castro is offline   Reply With Quote

Old   January 8, 2013, 11:16
Default
  #4
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Could you be a bit more specific about the results being "not good"?
Or maybe even provide some details about your setup.
flotus1 is offline   Reply With Quote

Old   January 8, 2013, 11:26
Default
  #5
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
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.
Luis.Castro is offline   Reply With Quote

Old   January 9, 2013, 04:01
Default
  #6
Member
 
Li
Join Date: Mar 2009
Posts: 54
Rep Power: 17
llrr is on a distinguished road
Quote:
Originally Posted by Luis.Castro View Post
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.
llrr is offline   Reply With Quote

Old   January 9, 2013, 04:38
Default
  #7
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
Quote:
Originally Posted by llrr View Post
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 is offline   Reply With Quote

Old   January 9, 2013, 06:41
Default
  #8
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
How can I define a local coordinate system for a specific UDF?
Luis.Castro is offline   Reply With Quote

Old   January 9, 2013, 07:29
Default
  #9
Member
 
Li
Join Date: Mar 2009
Posts: 54
Rep Power: 17
llrr is on a distinguished road
Quote:
Originally Posted by Luis.Castro View Post
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=...
llrr is offline   Reply With Quote

Old   January 9, 2013, 10:02
Default
  #10
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
Quote:
Originally Posted by llrr View Post
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 is offline   Reply With Quote

Old   January 10, 2013, 05:16
Default
  #11
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
Nobody?
Luis.Castro is offline   Reply With Quote

Old   January 10, 2013, 12:40
Default
  #12
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Quote:
Originally Posted by Luis.Castro View Post
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
flotus1 is offline   Reply With Quote

Old   January 11, 2013, 05:58
Default
  #13
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
Quote:
Originally Posted by flotus1 View Post
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].
Luis.Castro is offline   Reply With Quote

Old   January 11, 2013, 06:12
Default
  #14
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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)));
flotus1 is offline   Reply With Quote

Old   January 11, 2013, 06:39
Default
  #15
New Member
 
Join Date: Dec 2012
Posts: 13
Rep Power: 14
Luis.Castro is on a distinguished road
Quote:
Originally Posted by flotus1 View Post
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?
Luis.Castro is offline   Reply With Quote

Old   January 11, 2013, 07:01
Default
  #16
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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?
flotus1 is offline   Reply With Quote

Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 11:03
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
Heat source UDF, please Sasha Fluent UDF and Scheme Programming 4 October 14, 2014 02:32
UDF source term jerome_ FLUENT 2 July 11, 2011 12:55
Momentum source UDF Matthew Brannock FLUENT 5 May 3, 2001 22:18


All times are GMT -4. The time now is 20:28.