CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

UDF defining transient boundary condition

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 20, 2015, 04:12
Default UDF defining transient boundary condition
  #1
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 3
jpina is on a distinguished road
Hello,

I'm trying to develop a UDF for defining the fluid velocity in the inlet boundary condition.

However, the velocity is transient, and at each time step the velocity profile is defined by a polynomial.

For example:

v(time_step_0)=-1.0988e4x^2-27x-0.0155
v(time_step_1)=-8.82e3x^2-18.93x-0.01
etc.

I have a matrix of coefficients where each column suits to the polynomial's coefficients of each time step.

I would appreciate some orientation concerning to how to develop the UDF.

Thanks a lot!
jpina is offline   Reply With Quote

Old   June 23, 2015, 11:31
Default
  #2
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 3
jpina is on a distinguished road
Someone could give me a hint?
jpina is offline   Reply With Quote

Old   June 23, 2015, 11:41
Default
  #3
New Member
 
Join Date: Jun 2015
Posts: 7
Rep Power: 3
Llume is on a distinguished road
You need to define an UDF, a C code for example and define it in fluent. Your scripts needs to look like something like this:

Quote:
#include "udf.h"

DEFINE_PROFILE(unsteady_velocity, thread, index)
{
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f,thread)
{
F_PROFILE(f,thread,index) = 1+15*t+15*t*t;
}
end_f_loop(f,thread)
}
but you need to specify also a dependency on the position of the center of the faces where you want to specify the inlet condition if you wish to do so. To understand the code and how to modify it to include this you should refer to the UDF manual.
Llume is offline   Reply With Quote

Old   June 23, 2015, 11:54
Default
  #4
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 3
jpina is on a distinguished road
Hi Llume!

Maybe I didn't explain myself correctly.

I have a polynomial for each time step, I do not have a function v=f(position,time)!

My aim is to develop a UDF where:

- At time step 1:

v= 2x^2+3x+1

- At time step 2:

v=4x^2+4x+1

- At time step 3:

v= ...

Thanks!
jpina is offline   Reply With Quote

Old   June 23, 2015, 12:00
Default
  #5
New Member
 
Join Date: Jun 2015
Posts: 7
Rep Power: 3
Llume is on a distinguished road
The process would be the same, you need only to use an "if" to check at which timestep the simulation is and change the way the condition is evaluated accordingly, you can check the subsection "Fluent UDF and Scheme Programming" of this forum to see other examples.

This post has an UDF that could be a good starting point for you:

http://www.cfd-online.com/Forums/flu...llel-mode.html
Llume is offline   Reply With Quote

Old   July 8, 2015, 12:23
Default
  #6
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 3
jpina is on a distinguished road
Hello everybody,

finally I have succed on the UDF development.

I copy here the UDF with the aim to help somebody in the future:

/************************************************** *************
********
UDF for specifying steady-state velocity profile boundary
condition
************************************************** **************
********/
#include "udf.h"
DEFINE_PROFILE(unsteady_velocity_profile, t, i)
{
double coef_matrix[3][4];
face_t f;
int j;
double xy[ND_ND];
int curr_ts;
/*Manually copied data from MATLAB, must be automatized*/
coef_matrix[0][0]=-1.0988E4;
coef_matrix[1][0]=26.53;
coef_matrix[2][0]=0.;
coef_matrix[0][1]=-8.83E3;
coef_matrix[1][1]=-18.9;
coef_matrix[2][1]=-0.01;
coef_matrix[0][2]=-6.65E3;
coef_matrix[1][2]=-11.33;
coef_matrix[2][2]=-0.0047;
coef_matrix[0][3]=-4.49E3;
coef_matrix[1][3]=-3.74;
coef_matrix[2][3]=7.33E-4;
begin_f_loop(f, t)
{
curr_ts = N_TIME;
F_CENTROID(xy,f,t);
F_PROFILE(f,t,i)=-(coef_matrix[0][curr_ts]*(xy[1]+4E-
6)*(xy[1]+4E-6)+coef_matrix[1][curr_ts]*(xy[1]+4E-
6)+coef_matrix[2][curr_ts]);
}
end_f_loop(f, t)
}

Each column of the matrix is a time step and each row is a polynomial's coefficient.

See you.
jpina is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind turbine simulation Saturn CFX 45 February 8, 2016 05:42
Using Transient Boundary condition raamek FLUENT 1 September 23, 2014 11:00
Define_profile UDF for Transient Heat flux boundary condition Amoljoshi Fluent UDF and Scheme Programming 1 May 9, 2014 11:17
UDF for inhomogenous Neumann boundary condition akhilesh Fluent UDF and Scheme Programming 3 December 24, 2012 12:14
transient simulation of a rotating rectangle icesniffer CFX 1 August 8, 2009 07:25


All times are GMT -4. The time now is 11:15.