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

Compile UDF for Fluent

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2016, 09:31
Exclamation Compile UDF for Fluent
  #1
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 11
kcgmech is on a distinguished road
I need to include Lorentz force equation as a source term in my model. how can i compile a UDF and use it in fluent ?
__________________
--
K.C.Ganesh
Research Scholar
NIT Trichy
India
kcgmech is offline   Reply With Quote

Old   January 20, 2016, 16:03
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Use the DEFINE_SOURCE macro for specifying a custom source term (ensure the units are of the form generation rate per volume, e.g. kg/m^3/s for the continuity equation), there are a couple of examples in the UDF manual to get you started (ask back here if you get stuck). As for compiling UDFs, see the reply in your duplicate thread.
`e` is offline   Reply With Quote

Old   January 21, 2016, 11:42
Default
  #3
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 11
kcgmech is on a distinguished road
respected sir,
could suggest me what mistake i do in this code as given below ?

#include "udf.h"
#define mu 1.26*(10e-6)
#define I 300
#define reff 0.008
#define r 0.005
/*--------------------------------------------------------
Momentum source term in x
----------------------------------------------------------*/
DEFINE_SOURCE(xmom_source,c,t,dS,eqn)
{
float x[ND_ND], source;
face_t f;
F_CENTROID (x,f,t);
source =-((mu*I*I)/(4*3.14*3.14*reff*reff*r)) * (exp (-r*r / (2*reff*reff))) * (1-(exp (-r*r / (2*reff*reff)))) * pow((1-(x[1]/t),2) * (x[0]/r);
dS[eqn] = 0;
return source;
}
/*--------------------------------------------------------
Momentum source term in y
----------------------------------------------------------*/
DEFINE_SOURCE(ymom_source,c,t,dS,eqn)
{
float x[ND_ND], source;
face_t f;
F_CENTROID (x,f,t);
source = -((mu*I*I)/(4*3.14*3.14*r*r)) * pow((1-(exp (-r*r / (2*reff*reff)))),2) * (1-(x[1]/t));
dS[eqn] = 0;
return source;
}
/* HEAT INPUT CODE */
DEFINE_PROFILE(Gauss,t,i)
{
real x[ND_ND], c[ND_ND];
face_t f;
real r;
r = 0.0035;
begin_f_loop(f, t)
{
F_CENTROID (x,f,t);
F_PROFILE (f,t,i) = (3*(300*14*0.7) / (3.14*pow(r,2))) * exp (-3*(x[0]*x[0])/ pow(r,2));
}
end_f_loop(f,t)
}
__________________
--
K.C.Ganesh
Research Scholar
NIT Trichy
India
kcgmech is offline   Reply With Quote

Old   January 21, 2016, 17:48
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
For starters, use a trailing dot for real numbers (otherwise the compiler will read them as integers), for example:

Code:
F_PROFILE (f,t,i) = (3.*(300.*14.*0.7) / (3.14*pow(r,2))) * exp (-3.*(x[0]*x[0])/ pow(r,2));
Next, be specific. Show us any errors and explain what result you're expecting compared to what you're actually achieving.
`e` is offline   Reply With Quote

Old   January 29, 2016, 05:46
Default
  #5
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 11
kcgmech is on a distinguished road
i have modified the format with trailing dot as suggested. the UDF is given below and it gives the error: Line 27: invalid type for binary expression: float / pointer to structure.

how can i rectify the error in the following udf ?

/*------ HEAT FLUX -------- */
#include "udf.h"
DEFINE_PROFILE(Gauss,t,i)
{
real x[ND_ND], c[ND_ND];
face_t f;
real r;
r = 0.005;
begin_f_loop(f, t)
{
F_CENTROID (x,f,t);
F_PROFILE (f,t,i) = (3.*(300.*14.*0.7/0.001) / (3.14*pow(r,2.))) * exp (-3.*(x[0]*x[0])/ pow(r,2.));
}
end_f_loop(f,t)
}
/*--------- Lorentz Force ----------*/
/*-------- x momentum source ------*/
#DEFINE mu 0.00000126;
#DEFINE I 300.;
#DEFINE reff 0.006;
#DEFINE r 0.005;
DEFINE_SOURCE(xmom,c,t,dS,eqn)
{
real x[ND_ND];
real mu, I, reff, r, source;
C_CENTROID(x,c,t);
source = -((mu*I*I)/(4.*3.14*3.14*reff*reff*r)) * (exp (-r*r / (2.*reff*reff))) * (1.-(exp (-r*r / (2.*reff*reff)))) * pow((1.-(x[1]/t),2.) * (x[0]/r));
dS[eqn]=0;
return source;
}
/* ----------- y momentum source ------------*/
DEFINE_SOURCE(ymom,c,t,dS,eqn)
{
real x[ND_ND];
real source;
C_CENTROID(x,c,t);
source = -((mu*I*I)/(4.*3.14*3.14*r*r*c)) * pow((1.-(exp (-r*r / (2.*reff*reff)))),2.) * (1.-(x[1]/t));
dS[eqn]=0;
return source;
}
__________________
--
K.C.Ganesh
Research Scholar
NIT Trichy
India
kcgmech is offline   Reply With Quote

Old   January 29, 2016, 08:29
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
One of your problems is here:

Code:
#DEFINE mu 0.00000126; 
#DEFINE I 300.; 
#DEFINE reff 0.006;
#DEFINE r 0.005;
...
real mu, I, reff, r, source;
"#DEFINE mu 0.00000126;" means: everywhere where you write "mu", the compiler should read "0.00000126;". So the last line that I copied becomes:
Code:
real 0.00000126;, 300.;, 0.006;, 0.005;, source;
This not what you want. You should choose. Option 1: use #define in the right way:
Code:
#DEFINE I 300.
Note: no ; after the number! And don't try to redefine I as real.

Option 2: don't use #DEFINE:
Code:
real mu=0.00000126, I=300, ...
There may be other problems.
pakk 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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 06:05
Compile udf error Cfdbug Fluent UDF and Scheme Programming 2 December 17, 2015 19:03
Compile c99 standard UDF in Cluster darsonli Fluent UDF and Scheme Programming 0 July 7, 2015 02:58
looking for instructions on how to compile an udf in windows OS Srinivasa Rao Fluent UDF and Scheme Programming 2 May 22, 2015 10:00
Fluent doesn´t compile UDF on Windows HSeldon FLUENT 4 February 14, 2007 23:01


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