UDF writing: parabolic profile

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 10, 2012, 02:57 UDF writing: parabolic profile #1 Member   Robert Join Date: Mar 2011 Location: Warsaw Posts: 62 Rep Power: 7 Hello! I try to create a parabolic velocity profile for the velocity inlet in 3D geometry. I have created UDF below but I have still problems with it. Does my UDF see x and y coordinates? #include "udf.h" DEFINE_PROFILE(parabolic_profile,t,i) { real x; real y; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); y = x[1]; F_PROFILE(f,t,i) = x*x+y+y; } end_f_loop(f,t) }

 April 10, 2012, 04:49 #2 Senior Member   Max Join Date: Mar 2009 Posts: 133 Rep Power: 9 No, it does not. Define x as a vector having three components --> x[0] will give you x-coordinate, x[1] y-coord and x[2] z-coordinate. cheers cheers

 April 10, 2012, 06:54 #3 Member   Robert Join Date: Mar 2011 Location: Warsaw Posts: 62 Rep Power: 7 So should it look like this? #include "udf.h" DEFINE_PROFILE(parabolic_profile,t,i) { real x [ND_ND]; real y; real z; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); y = x[0]; z = x[1]; F_PROFILE(f,t,i) = y*y+z+z; } end_f_loop(f,t) } By the way what is [ND_ND] for? Do I have to write it?

 May 23, 2012, 12:26 Help, unable to interpret #5 New Member   karthik Join Date: Oct 2010 Posts: 14 Rep Power: 8 Hi, Please can you help me, I am trying to set a velocity inlet condition (not really a profile, more just a value for the inlet). I wrote the following UDF, but now I cannot get it to interpret, keeps giving me a parse error on the equation that I enter for the Velocity_Profile. Here is the c_code: #include "udf.h" DEFINE_PROFILE(Velocity_Profile, thread, position) { /****************************/ /* THE USER INPUTS */ /****************************/ /* the centroid of the boundary face (x0,y0,z0) */ real x0 = 0.0; real y0 = 0.0; real z0 = 0.0; /****************************/ /*Parameters*/ /****************************/ //Stochiometric factor real Anode = 1.5; real Cathode = 2; real F = 96485; /* Faradays constant (C/mol) */ real R = 8.314; /* Universal gas constant (J/mol)*/ real T = 353; /* Temperature (K) */ real P_anode = 101325; /* Anode pressure (Pa) */ real i = 0.00004; //(A/m2) current density /****************************/ /* Main Program */ /****************************/ real x[ND_ND]; real Velocity_Profile; /* Velocity to be written to boundary */ face_t f; /* f the hooked boundary face in fluent */ begin_f_loop(f,thread); { F_CENTROID(x, f, thread); /* the coordinates of the current face/element centroid accessed by F_CENTROID */ /* Write Profile in x */ Velocity_Profile = Anode*(i/(2*F))/(P_anode/(R*T); /* Write velocity boundary condition */ F_PROFILE(f, thread, position) = Velocity_Profile; /* Apply velocity profile to selected boundary */ } end_f_loop(f, thread); /****************************/ /****************************/ //return Velocity_Profile; }

 May 28, 2012, 07:36 #6 Member   Daniel Tanner Join Date: Apr 2009 Posts: 54 Rep Power: 9 Velocity_Profile = Anode*(i/(2*F))/(P_anode/(R*T) is missing a bracket.

 May 29, 2012, 04:21 #7 New Member   karthik Join Date: Oct 2010 Posts: 14 Rep Power: 8 Hi Daniel, Thanks for the reply, I actually figured out the problem the moment I put up the question, should have put a follow up saying that I got the answer. Thanks again. I also had a quick question regarding multiple UDFs on the same C file. Can I run multiple macros on the same file? i.e. specify an inlet velocity as well as a sink term using multiple macros on the same file and then interpret it in fluent? I am asking this question because I am struggling to compile my different c-files due to not being able to install microsoft visual studio. Thanks

May 29, 2012, 05:37
#8
Senior Member

Daniele
Join Date: Oct 2010
Location: Italy
Posts: 992
Rep Power: 17
Quote:
 Originally Posted by kitrax Hi Daniel, Thanks for the reply, I actually figured out the problem the moment I put up the question, should have put a follow up saying that I got the answer. Thanks again. I also had a quick question regarding multiple UDFs on the same C file. Can I run multiple macros on the same file? i.e. specify an inlet velocity as well as a sink term using multiple macros on the same file and then interpret it in fluent? I am asking this question because I am struggling to compile my different c-files due to not being able to install microsoft visual studio. Thanks
Yes you can, but be sure that your macros can run if interpreted and not compiled (for example, udfs for body motion have to be compiled)

 May 29, 2012, 06:24 #9 New Member   karthik Join Date: Oct 2010 Posts: 14 Rep Power: 8 Thanks Ghost, I got it to work, my system is a fuel cell so dont think I have any body motion UDFs. Plus I check all my UDFs can be interpreted anyway. Thanks again. Just a quick question regarding post-processing. I am looking at the concentration change of hydrogen and I want to compare my 3-D results with a 1-D model, so i just want to look at the concentration change in the z-axis. To do this I am using X-Y plot in fluent. I set my y-axis function as the concentration of H2 and my x-axis function as my direction vector (z-axis direction in this case). However, I dont get a single concentration profile, but multiple points. Doesnt make any sense as the the 3-D solution and a slice in the axis of interest looks correct. can you help

 June 5, 2012, 08:18 #10 New Member   karthik Join Date: Oct 2010 Posts: 14 Rep Power: 8 Hi Ghost/Daniel, Regarding my last question, if you try running the UDF, it interprets, but the value it gives is incorrect, can simply be checked using a calculator. Can you explain why? Makes no sense to me. K

June 5, 2012, 09:02
#11
Senior Member

Daniele
Join Date: Oct 2010
Location: Italy
Posts: 992
Rep Power: 17
Quote:
 Originally Posted by kitrax Hi Ghost/Daniel, Regarding my last question, if you try running the UDF, it interprets, but the value it gives is incorrect, can simply be checked using a calculator. Can you explain why? Makes no sense to me. K
Hi,
I'm not an expert in udf..but aren't you assigning a constant velocity with this equation??

/* Write Profile in x */
Velocity_Profile = Anode*(i/(2*F))/(P_anode/(R*T);

Daniele

 June 5, 2012, 10:13 #12 New Member   karthik Join Date: Oct 2010 Posts: 14 Rep Power: 8 Hi Daniele, Yeah its constant, my supervisor wants me to write it to be able to change the current density value later on (when I get it to work). I actually got the code to work properly though, the reason for the mistake was that fluent doesnt understand 10^-10, only 1e-10, stupid error but thanks for the reply. On the topic of fluent, I am writing a UDF to define a sink term in the catalyst zone of my domain (consisting of 3 zones). However, I need to specify a flux with the following units(kg/m3.sec). I am not sure whether to divide my mass flow(kg/sec) by total catalyst domain volume or a the volume of a single element. I would think its the volume of the entire domain and then fluent calculates the kg/sec value by multiplying by the volume of a single element and summing that over the domain.

 Tags profile, udf

 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 Zaqie Fluent UDF and Scheme Programming 9 June 25, 2016 19:08 raju FLUENT 3 September 22, 2008 16:36 Nuno FLUENT 0 September 1, 2008 15:31 Jack Martinez FLUENT 9 June 14, 2007 10:24 Sandilya FLUENT 0 May 31, 2007 12:03

All times are GMT -4. The time now is 05:34.