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

UDF code for heat generating source

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 1 Post By krushna
  • 1 Post By pakk
  • 1 Post By pakk
  • 1 Post By pakk
  • 1 Post By pakk
  • 1 Post By kcgmech
  • 1 Post By bhargavbharathan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 23, 2015, 08:07
Unhappy UDF code for heat generating source
  #1
New Member
 
yashar_aryanfar
Join Date: Oct 2015
Posts: 7
Rep Power: 10
valerhain is on a distinguished road
hi dear friends
I am supposed to write a udf for heat generation rate which is a function at this form:





I prepared this code for simulating :

#include "udf.h"
#define EPS 0.01
#define SIGMA 0.004
DEFINE_SOURCE(cell_x_source, cell, thread, dS, eqn)
{
real x[ND_ND];
real source;
C_CENTROID(x,cell,thread);

source=EPS*exp(((x[0]-0.4)*(x[0]-0.4)+(x[1]-0.004)*(x[1]-0.004))/(-SIGMA*SIGMA));
dS[eqn]=0;
return source;
}


but is not work. this code dont have any effect in my results. dear friend I have less than 5 days for simulating this. please help me and I will thankfull of you...
valerhain is offline   Reply With Quote

Old   October 27, 2015, 02:14
Default
  #2
New Member
 
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 10
krushna is on a distinguished road
hi yashar,
i think first you define scalar for x[0] and x[1] and also write udf for initialization of x[0] and x[1]
regards,
krushna
valerhain likes this.
krushna is offline   Reply With Quote

Old   October 28, 2015, 06:31
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
It is not about x[0] and x[1], they are defined in the code and you don't need a udf to initialize them.

Can you tell us what you did with the code?

You saved it in a text file, and then what? How did you tell Fluent to use this code?

(And are you sure that the source locus, (x0,y0)=(0.4,0.004), is in your domain?)
valerhain likes this.
pakk is offline   Reply With Quote

Old   October 28, 2015, 07:06
Default
  #4
New Member
 
yashar_aryanfar
Join Date: Oct 2015
Posts: 7
Rep Power: 10
valerhain is on a distinguished road
Quote:
Originally Posted by pakk View Post
It is not about x[0] and x[1], they are defined in the code and you don't need a udf to initialize them.

Can you tell us what you did with the code?

You saved it in a text file, and then what? How did you tell Fluent to use this code?

(And are you sure that the source locus, (x0,y0)=(0.4,0.004), is in your domain?)
first of all I am very thankful
I have written this code on the notepad and save it with .c format
If you see the pictures that I was adding in first post, I am trying to add this code in energy equation
user define-->function-->interpreted-->and after choosing the file, I have interpreted the code
then I in boundary condition part, I choose fluid and adding the code to the heat source part
I want to this code define a heat source in (0.4.0.004) and affect boundary layer
but unfortunately it is not work and there is heat source effects in the results
as you said I am going to check domain again
valerhain is offline   Reply With Quote

Old   October 28, 2015, 07:10
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Those seem like good steps...

To check if your code is really used, you can put the following line in:
Code:
Message("Test\n");
Put it for example directly above your "return"-line. If you see "Test" appearing in your text user interface, the code is run, and if you don't see it, it is not run.

Another thing you could do is to increase epsilon for testing. Maybe the source is really added, but the effect is too small to notice. Change epsilon from 0.01 to a big value such as 1000, and see if your result changes.
valerhain likes this.
pakk is offline   Reply With Quote

Old   October 28, 2015, 07:26
Unhappy
  #6
New Member
 
yashar_aryanfar
Join Date: Oct 2015
Posts: 7
Rep Power: 10
valerhain is on a distinguished road
Quote:
Originally Posted by pakk View Post
Those seem like good steps...

To check if your code is really used, you can put the following line in:
Code:
Message("Test\n");
Put it for example directly above your "return"-line. If you see "Test" appearing in your text user interface, the code is run, and if you don't see it, it is not run.

Another thing you could do is to increase epsilon for testing. Maybe the source is really added, but the effect is too small to notice. Change epsilon from 0.01 to a big value such as 1000, and see if your result changes.
I added your code to my UDF and this is what I see :


Error: H:\source.c: line 14: function "CX_Message" not found (pc=128).

valerhain is offline   Reply With Quote

Old   October 28, 2015, 07:29
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by valerhain View Post
I added your code to my UDF and this is what I see :


Error: H:\source.c: line 14: function "CX_Message" not found (pc=128).

Silly me, you are interpreting, then Message does not work...
Use printf instead.

printf("test\n");
valerhain likes this.
pakk is offline   Reply With Quote

Old   October 28, 2015, 07:44
Default
  #8
New Member
 
yashar_aryanfar
Join Date: Oct 2015
Posts: 7
Rep Power: 10
valerhain is on a distinguished road
Quote:
Originally Posted by pakk View Post
Silly me, you are interpreting, then Message does not work...
Use printf instead.

printf("test\n");
I tried again....there is not any error that be written in the user text interface but the test message also not!
valerhain is offline   Reply With Quote

Old   October 28, 2015, 07:48
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
To be clear: the text should show up when you clicked 'Calculate'.
If it doesn't show up then, the code is never run by Fluent, but I can not explain why not.
valerhain likes this.
pakk is offline   Reply With Quote

Old   October 28, 2015, 07:53
Default
  #10
New Member
 
yashar_aryanfar
Join Date: Oct 2015
Posts: 7
Rep Power: 10
valerhain is on a distinguished road
Quote:
Originally Posted by pakk View Post
To be clear: the text should show up when you clicked 'Calculate'.
If it doesn't show up then, the code is never run by Fluent, but I can not explain why not.
bingooooooooooooooooooooooooooooooooo
it is works.....when i push calculate buttun many of test!!! letter are written in the interfaaaaaaaaaaaaaaaaace!
yohuuuuuuuuuuuuuuuuuuuuu
valerhain is offline   Reply With Quote

Old   October 28, 2015, 08:06
Default
  #11
New Member
 
yashar_aryanfar
Join Date: Oct 2015
Posts: 7
Rep Power: 10
valerhain is on a distinguished road
Quote:
Originally Posted by pakk View Post
To be clear: the text should show up when you clicked 'Calculate'.
If it doesn't show up then, the code is never run by Fluent, but I can not explain why not.
my Pc works on it
fluent process the problem
so as soon as I see the results I will tell you

dear friend
you are reallllllllllllllly helpful person
thank alooooooooooooooooot
valerhain is offline   Reply With Quote

Old   October 31, 2015, 03:56
Default
  #12
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 11
kcgmech is on a distinguished road
Quote:
Originally Posted by valerhain View Post
hi dear friends
I am supposed to write a udf for heat generation rate which is a function at this form:





I prepared this code for simulating :

#include "udf.h"
#define EPS 0.01
#define SIGMA 0.004
DEFINE_SOURCE(cell_x_source, cell, thread, dS, eqn)
{
real x[ND_ND];
real source;
C_CENTROID(x,cell,thread);

source=EPS*exp(((x[0]-0.4)*(x[0]-0.4)+(x[1]-0.004)*(x[1]-0.004))/(-SIGMA*SIGMA));
dS[eqn]=0;
return source;
}


but is not work. this code dont have any effect in my results. dear friend I have less than 5 days for simulating this. please help me and I will thankfull of you...
dear valerhain,
what you are trying to do? if you want to include the heat generation source as surface heat flux, you can apply using DEFINE PROFILE...
valerhain likes this.
kcgmech is offline   Reply With Quote

Old   November 18, 2015, 11:55
Default
  #13
Member
 
Bhargav Bharathan
Join Date: Jun 2015
Location: Montreal, Canada
Posts: 71
Rep Power: 10
bhargavbharathan is on a distinguished road
Hi,

I'm not sure if it has been addressed already but I think source UDFs can only be compiled and interpreted.

Bhargav
valerhain likes this.
bhargavbharathan is offline   Reply With Quote

Old   November 18, 2015, 14:24
Default
  #14
New Member
 
yashar_aryanfar
Join Date: Oct 2015
Posts: 7
Rep Power: 10
valerhain is on a distinguished road
Quote:
Originally Posted by bhargavbharathan View Post
Hi,

I'm not sure if it has been addressed already but I think source UDFs can only be compiled and interpreted.

Bhargav
thanks alot dear friend
valerhain 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] difficulties installing swak4foam newbie29 OpenFOAM Community Contributions 120 October 21, 2022 04:01
[swak4Foam] groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 10:03
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 11:44
Please help me run UDF code for source Suga FLUENT 1 February 3, 2006 03:40


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