|
[Sponsors] |
January 20, 2016, 10:31 |
Compile UDF for Fluent
|
#1 |
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 12 |
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 |
|
January 20, 2016, 17:03 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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.
|
|
January 21, 2016, 12:42 |
|
#3 |
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 12 |
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 |
|
January 21, 2016, 18:48 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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)); |
|
January 29, 2016, 06:46 |
|
#5 |
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 12 |
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 |
|
January 29, 2016, 09:29 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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; Code:
real 0.00000126;, 300.;, 0.006;, 0.005;, source; Code:
#DEFINE I 300. Option 2: don't use #DEFINE: Code:
real mu=0.00000126, I=300, ... |
|
|
|
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 07:05 |
Compile udf error | Cfdbug | Fluent UDF and Scheme Programming | 2 | December 17, 2015 20:03 |
Compile c99 standard UDF in Cluster | darsonli | Fluent UDF and Scheme Programming | 0 | July 7, 2015 03:58 |
looking for instructions on how to compile an udf in windows OS | Srinivasa Rao | Fluent UDF and Scheme Programming | 2 | May 22, 2015 11:00 |
Fluent doesn´t compile UDF on Windows | HSeldon | FLUENT | 4 | February 15, 2007 00:01 |