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

UDF for velocity inlet depending on time

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 26, 2018, 10:18
Default UDF for velocity inlet depending on time
  #1
New Member
 
Enrique Pérez Heredia
Join Date: May 2018
Location: Madrid, Spain.
Posts: 16
Rep Power: 8
EnriqueP is on a distinguished road
Hello,

I'm trying to setup a velocity which changes its value depending on time (attahced figure), in an inlet boundary condition.

The UDF that I have written is the following:
DEFINE_PROFILE(y_velocity,t,i)
{
real T, H; /* variable declarations */
face_t f;
T = 1;
H = 3;

begin_f_loop(f,t)
{
if(CURRENT_TIME <= T/2)
F_PROFILE(f,t,i) = 0;
else if (CURRENT_TIME <= 3*T/2 && CURRENT_TIME >T/2)
F_PROFILE(f,t,i) = 4*H/pow(T,2)*pow(CURRENT_TIME-T,2)-H;
else
F_PROFILE(f,t,i) = 0;
}
end_f_loop(f,t)
}

I am quite new to UDFs and Im having some trouble.
Any help would be really appreciated. Thank you.

Enrique P.
__
Attached Images
File Type: png Profile.png (12.1 KB, 91 views)
__________________
Loading signature...
EnriqueP is offline   Reply With Quote

Old   June 26, 2018, 11:42
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Enrique,

This looks basically OK to me, except that you need a line include "udf.h" at the start. What trouble are you having?

I would always recommend that you compile UDFs rather than interpreting. Here are some useful posts on compiling UDFs -- for example: links to instructions Visual Studio 2017 for udf use - which modules do I need?; troubleshooting errors How to solve UDF compilation problems in Fluent.; the basic steps of compile/load/hook The UDF library you are trying to load (libudf) is not compiled for 3D on the current. (at the end).

Ach, I can't resist tweaking your code. It bothers me slightly to see T and t in the same code, though this is perfectly safe, but the thing that really bothers me is recalculating the same velocity for every face. Why not calculate it once and then use it repeatedly? Like this:
Code:
#include "udf.h"

#define PEAK_TIME 1.0
#define PEAK_VELOCITY -3.0

DEFINE_PROFILE(y_velocity,t,i)
{
  real tau,velocity;
  face_t f;

  tau = CURRENT_TIME / PEAK_TIME;
  if(tau > 0.5 && tau < 1.5) {
    velocity = PEAK_VELOCITY *
      (1.0 - 4.0 * (tau - 1.0) * (tau - 1.0));
    /* Note PEAK_VELOCITY is negative; it is multiplied by
     * a quadratic (on a line by itself) which is positive.
     * The quadratic has maximum value 1.0 at tau = 1.0
     * The quadratic has value 0.0 at tau = 0.5 and tau = 1.5. */
  }else{
    velocity = 0.0;
  }

  begin_f_loop(f,t)
  {
    F_PROFILE(f,t,i) = velocity;
  }
  end_f_loop(f,t)
}
Good luck!
Ed
obscureed is offline   Reply With Quote

Old   June 27, 2018, 03:35
Default
  #3
New Member
 
Enrique Pérez Heredia
Join Date: May 2018
Location: Madrid, Spain.
Posts: 16
Rep Power: 8
EnriqueP is on a distinguished road
Hello again, Obscureed.

I made the silliest mistake ever by not including the "udf.h". I realized like 5 mins after posting this.

Thanks for your help and for the improvement in the code.
Really appreciated.
__________________
Loading signature...
EnriqueP is offline   Reply With Quote

Reply

Tags
inlet, profile, udf, velocity


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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 03:36
Inconsistencies in reading .dat file during run time in new injection model Scram_1 OpenFOAM 0 March 23, 2018 23:29
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 03:50
UDF problem- time dependent temperature at inlet kaeran FLUENT 1 June 16, 2015 22:48
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58


All times are GMT -4. The time now is 13:45.