# UDF for Velocity change at inlet

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

 December 14, 2010, 17:23 UDF for Velocity change at inlet #1 New Member   Alex Hai Join Date: Mar 2010 Posts: 27 Rep Power: 8 Hello Everyone, I am trying to write a UDF for unsteady flow, in which the velocity at the intlet of 2d cylinder is increased by time (or by time step). I am using a VOF model, and it is pressure based. If it is easy, can anyone write me the code, if not, then point me to the right place. I am currently reading the UDF manual, so i know how to compile the c file and load it. Thanks Alex.

 December 14, 2010, 19:16 #2 Senior Member   Real Name :) Join Date: Jan 2010 Location: United States Posts: 193 Rep Power: 8 Alex, Please look here: http://www.cfd-online.com/Forums/flu...tml#post287097

 December 14, 2010, 20:55 #3 New Member   Alex Hai Join Date: Mar 2010 Posts: 27 Rep Power: 8 Computerguy, Thank you for your reply, that was helpful to read.. but that code is made for velocity change at a defined time, how can have that code to change the velocity at everytime step between 0 m/s till 1m/s, within lets say 30000 time steps. And make it only for the inlet boundary. Many thanks, Alex

 December 14, 2010, 21:27 #4 Senior Member   Real Name :) Join Date: Jan 2010 Location: United States Posts: 193 Rep Power: 8 Alex, Are you asking how to perform a ramp of the velocity between 0 and 1 m/s over some defined period of time which takes 30000 time steps? If so, it's simply linear interpolation. I haven't checked the following code, but it should be clear enough to fix if it's broken: Code: #include "udf.h" DEFINE_PROFILE(pressure_magnitude, t, i) { real default_velocity_mag,velocity_mag; real start_velocity,end_velocity; real ramp_start,ramp_end; real line_slope, line_intercept; face_t f; default_velocity_mag=0.0; start_velocity=0.0; end_velocity=1.0; ramp_start=0.0; ramp_end=3.0; velocity_mag=default_velocity_mag; the_current_time = CURRENT_TIME; line_slope=(end_velocity-start_velocity)/(ramp_end-ramp_start); line_intercept=start_velocity-line_slope*ramp_start; if ((the_current_time>=ramp_start) && (the_current_time<=ramp_end)) { velocity_mag=line_slope*the_current_time+line_intercept; } begin_f_loop(f,t) { F_PROFILE(f,t,i) = velocity_mag; } end_f_loop(f,t) } default velocity is the value that the code will use outside the ramp time start velocity is the value of the velocity at the beginning of the ramp (in your case, 0 m/s) end velocity is the value of the velocity at the beginning of the ramp (in your case, 1 m/s) ramp start and ramp end are the times, in seconds, you want to start and end the velocity ramp, respectively. This is easier to do (and slightly more robust) than selecting the number of time steps you'd like to subdivide the ramp into, as it gives you the option to take variable time steps. Let me know if this is clear. ComputerGuy

 December 15, 2010, 16:01 #5 New Member   Alex Hai Join Date: Mar 2010 Posts: 27 Rep Power: 8 Dear Computerguy, Thank you so much. The code is very clear. However i have few questions, they may sound stupid but still i thought i should ask. for the DEFINE_PROFILE(pressure_magnitude, t, i) .. shouldn't be DEFINE_PROFILE(velocity_magnitude, t, i)? or it really doesn't make a difference? My other question is: after lets say 3 seconds of flow time, where the velocity becomes 1 m/s, will the code maintain that velocity at a later time (i.e t>3seconds)? Thanks again CG .. i will do the compiling using FLUENT today.. and i will then run it in the simulation.. i will let you know how it goes. Regards, Alex

 December 15, 2010, 19:58 #6 Senior Member   Real Name :) Join Date: Jan 2010 Location: United States Posts: 193 Rep Power: 8 haihek, Good questions.It doesn't matter what name you use on a UDF, I just forgot to change the name The code will not use the last value from the previous timestep. It will always default to "default_velocity_mag" The updated code you're looking for is below: Code: #include "udf.h" DEFINE_PROFILE(velocity_magnitude, t, i) { real default_early_velocity_mag,default_late_velocity_mag,velocity_mag; real start_velocity,end_velocity; real ramp_start,ramp_end; real line_slope, line_intercept; face_t f; default_early_velocity_mag=0.0; default_late_velocity_mag=3.0; start_velocity=0.0; end_velocity=1.0; ramp_start=0.0; ramp_end=3.0; velocity_mag=default_early_velocity_mag; the_current_time = CURRENT_TIME; line_slope=(end_velocity-start_velocity)/(ramp_end-ramp_start); line_intercept=start_velocity-line_slope*ramp_start; if ((the_current_time>=ramp_start) && (the_current_time<=ramp_end)) { velocity_mag=line_slope*the_current_time+line_intercept; } if ((the_current_time>ramp_end)) { velocity_mag=default_late_velocity_mag; } begin_f_loop(f,t) { F_PROFILE(f,t,i) = velocity_mag; } end_f_loop(f,t) } ComputerGuy

 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 ljp FLUENT 0 April 1, 2010 15:12 Mijin Kim FLUENT 0 September 28, 2009 04:50 aravind FLUENT 0 October 27, 2008 11:08 selçuk ataş FLUENT 1 September 29, 2008 14:16 JI Lucheng FLUENT 2 December 28, 2001 20:18

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