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

variable Heat Source for Solid Region with UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 4, 2015, 10:10
Default variable Heat Source for Solid Region with UDF
  #1
New Member
 
Join Date: Oct 2014
Posts: 7
Rep Power: 12
Alex90 is on a distinguished road
Hello everybody,

as I am still quite new to UDF-scripting I do have problems creating a UDF for a variable heat source term.

Here is my issue. I have three coincident cylinders which do have the same axial length. The middle cylinder is my heat source. For my problem I assume a axial profile for the heat power Q, which means Q changes with z. This results in a heat source profile in z direction.

I want to define a UDF which tells Fluent, that my heat source term changes due to z.

Here is what I wrote so far:

Quote:
#include "udf.h"

DEFINE_PROFILE(heatsource,c,t,dS,eqn)
{
real x[ND_ND];
real source;
real vol;
VOL = 1.256637061*10^(-5);
begin_f_loop(x,c,t)
{
F_CENTROID(x,c,t);
if(x[2] <= 0.300)
source(x,c,t) = 0;
else if(x[2] <= 0.600 && x[2] > 0.300)
source(x,c,t) = 3500.955/VOL;
else if(x[2] <= 1.050 && x[2] > 0.600)
source(x,c,t) = 4738.666/VOL;
else if(x[2] <= 2.100 && x[2] > 1.050)
source(x,c,t) = 4971.053/VOL;
else if(x[2] <= 2.850 && x[2] > 2.100)
source(x,c,t) = 5092.298/VOL;
else if(x[2] <= 3.300 && x[2] > 2.850)
source(x,c,t) = 4738.666/VOL;
else if(x[2] <= 3.600 && x[2] > 3.300)
source(x,c,t) = 3500.955/VOL;
else if(x[2] <= 3.900 && x[2] > 3.600)
source(x,c,t) = 2121.791/VOL;
else
source(x,c,t) = 0;
}
end_f_loop(x,c,t);
}
So far this does not work. Where is the Problem? I wrote a UDF for a profile of q which worked that way.

Thank you for any Help. ....
Alex90 is offline   Reply With Quote

Old   February 4, 2015, 10:23
Default
  #2
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
1) VOL = 1.256637061*10^(-5) is wrong
real VOL = 1.256637061e-5 is correct

2) "real source" means a real variable, source(x,c,t) is a function you haven't defined anywhere.

3) is not DEFINE_PROFILE, is DEFINE_SOURCE

4) DEFINE_SOURCE macro has implicit a loop over cells (check the arguments). If you are also looping over faces, the code will loop over all faces in every cell. The computational cost will be huge.

5) DEFINE_SOURCE needs a "return"

6) "dS" and "eqn" must be defined somewhere, as "dS[eqn] =0.0" at least

I guess I am even missing something

Last edited by upeksa; February 4, 2015 at 10:30. Reason: I had not finished
upeksa is offline   Reply With Quote

Old   February 6, 2015, 15:00
Default
  #3
New Member
 
Join Date: Oct 2014
Posts: 7
Rep Power: 12
Alex90 is on a distinguished road
Hi,
sorry that my answer took so long ...

I tried to insert the changes you suggested, though I am not quite sure if thats totally correct now. Besides I get an Error when I am interpreting it within FLUENT, it tells me that in line 15 (which is the line with source(x,c,t)=0 ''no function prototype'' ? What does that mean ? ...

As I said earlier I am completly new to UDF .... Thanks a lot for support.


Quote:
#include "udf.h"

DEFINE_SOURCE(heatsource,c,t,dS,eqn)
{
real x[ND_ND];
real source;
real VOL;
real Q;

VOL = 1.256637061e-5;

C_CENTROID(x,c,t);
if(x[2] <= 0.300)
{
source(x,c,t) = 0;
}
else if(x[2] <= 0.600 && x[2] > 0.300)
{
source(x,c,t) = 1.309/VOL;
}
else if(x[2] <= 1.050 && x[2] > 0.600)
{
source(x,c,t) = 2.659/VOL;
}
else if(x[2] <= 2.100 && x[2] > 1.050)
{
source(x,c,t) = 6.508/VOL;
}
else if(x[2] <= 2.850 && x[2] > 2.100)
{
source(x,c,t) = 4.762/VOL;
}
else if(x[2] <= 3.300 && x[2] > 2.850)
{
source(x,c,t) = 2.659/VOL;
}
else if(x[2] <= 3.600 && x[2] > 3.300)
{
source(x,c,t) = 1.309/VOL;
}
else if(x[2] <= 3.900 && x[2] > 3.600)
{
source(x,c,t) = 0.794/VOL;
}
else
{
source(x,c,t) = 0;
}

return source;
}
Alex90 is offline   Reply With Quote

Old   February 24, 2015, 12:24
Default
  #4
New Member
 
Join Date: Oct 2014
Posts: 7
Rep Power: 12
Alex90 is on a distinguished road
Hey there,

i tried to make this udf work, I really need it as I am writing my final thesis at university right now.

So here is the CODE I am using currently.

Quote:
#include "udf.h"
#define PI 3.14159265


DEFINE_SOURCE(WQuelle,c,t,dS,eqn)
{
real x[ND_ND];
real vol, source;

C_CENTROID(x,c,t)

vol = PI*0.25*0.004*0.004*x[2]

if(x[2] <= 0.300)
source =0;
else if(x[2] <= 0.600 && x[2] > 0.300)
source = 1.309/vol;
else if(x[2] <= 1.050 && x[2] > 0.600)
source = 2.6587/vol;
else if(x[2] <= 2.100 && x[2] > 1.050)
source = 6.5079/vol;
else if(x[2] <= 2.850 && x[2] > 2.100)
source = 4.7619/vol;
else if(x[2] <= 3.300 && x[2] > 2.850)
source = 2.6587/vol;
else if(x[2] <= 3.600 && x[2] > 3.300)
source = 1.3095/vol;
else if(x[2] <= 3.900 && x[2] > 3.600)
source = 0.7936/vol;
else
source = 0;

dS[eqn]=0;

return source;
}
I am trying to interpret it with FLUENT. But I get the following failure.

Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 14: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 16: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 18: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 20: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 22: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 24: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 26: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 28: parse error.
Error: C:/Users/LOCAL_~1/AppData/Local/Temp/HeatSource.c.22320.3.c: line 30: parse error.

I tried to figure that out, but somehow I really do not quite understand where the problem is. If anyone is able to help ... i would appreciate it ...
Thanks alot ... Alex
Alex90 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
UDF for heat source in Soldification and melting model karthik82 Fluent UDF and Scheme Programming 6 June 30, 2014 03:45
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 13:41
[swak4Foam] swak4Foam-groovyBC build problem zxj160 OpenFOAM Community Contributions 18 July 30, 2013 14:14
variable heat source John Phoenics 3 April 8, 2003 12:12
variable heat source simulation LI Y FLUENT 1 April 8, 2003 00:46


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