Compile UDF for Fluent

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 LinkBack Thread Tools Display Modes
 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: 4 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: 800 Rep Power: 11 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: 4 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: 800 Rep Power: 11 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.

 January 29, 2016, 06:46 #5 New Member   Ganesh K C Join Date: Oct 2014 Location: Tiruchirappalli, India Posts: 29 Rep Power: 4 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,072 Rep Power: 14 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.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Rizwan Fluent UDF and Scheme Programming 38 June 2, 2017 04:23 Cfdbug Fluent UDF and Scheme Programming 2 December 17, 2015 20:03 darsonli Fluent UDF and Scheme Programming 0 July 7, 2015 02:58 Srinivasa Rao Fluent UDF and Scheme Programming 2 May 22, 2015 10:00 HSeldon FLUENT 4 February 15, 2007 00:01

All times are GMT -4. The time now is 07:00.

 Contact Us - CFD Online - Top