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

(ask) how to create UDF for inlet velocity profile

Register Blogs Community New Posts Updated Threads Search

Like Tree21Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 7, 2011, 05:23
Default
  #21
Member
 
Naimah
Join Date: Nov 2011
Posts: 58
Rep Power: 15
wanna88 is on a distinguished road
Quote:
Originally Posted by Amir View Post
Dear Naimah,

It depends, e.g. if you want to have pressure or velocity in a specified point, you can use "solve->monitor->surface ...."; if you didn't activate it before iteration, you have to write a simple journal file for this purpose.
For extracting data of cross-sections; firstly you need to generate these cross-sections in "surface->quadratic or plane" then you can export desired data to other post processors in "file->export". But if you want to export these data for successive time steps; you have to choices: 1) there is such capability in ver. 13 in "file-> export" I think. 2) you can write a journal file to do what you want during iteration.

Bests,

Dear Amir,

Thank you for the info.
Since I m a new user of FLUENT, may I know how to get to this command
"surface->quadratic or plane"

Is this thing read the result at the cross section?

Besides, what is mean by read to journal file? I have tried to read data at certain interval that I set up. However, It come out with a lot of nodes number at 1 time interval. may I know how to extract this data?

Thank you so much for your help.

Regards,
Naimah
wanna88 is offline   Reply With Quote

Old   December 7, 2011, 06:28
Default
  #22
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by wanna88 View Post
Since I m a new user of FLUENT, may I know how to get to this command
"surface->quadratic or plane"
Is this thing read the result at the cross section?
You need to create desired cross-sections for post processing; for this purpose, from the surface tab you can select either quadratic or plane that are two different way to create these cross-sections. When you create these cross-sections, the data are interpolated automatically for them.
Quote:
Originally Posted by wanna88 View Post
Besides, what is mean by read to journal file? I have tried to read data at certain interval that I set up. However, It come out with a lot of nodes number at 1 time interval. may I know how to extract this data?
Journal files are simple tools to automate what we need in FLUENT; I'm not sure that I understand your goal, but with this tool you can do any post processing with several case and data files. I may help if I know what exactly you need to do.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   December 7, 2011, 06:49
Default
  #23
Member
 
Naimah
Join Date: Nov 2011
Posts: 58
Rep Power: 15
wanna88 is on a distinguished road
Quote:
Originally Posted by Amir View Post
You need to create desired cross-sections for post processing; for this purpose, from the surface tab you can select either quadratic or plane that are two different way to create these cross-sections. When you create these cross-sections, the data are interpolated automatically for them.

Journal files are simple tools to automate what we need in FLUENT; I'm not sure that I understand your goal, but with this tool you can do any post processing with several case and data files. I may help if I know what exactly you need to do.

Bests,
Dear Amir,

My project is to perform CFD simulation for aortic dissecting aneurysm.

I would like to see what happen in the geometry at particular time and location (cross section). To see how it changes from certain time to time.

Therefore, I need to see the plot at different part of the aorta.

Thank you

Regards,
Naimah
wanna88 is offline   Reply With Quote

Old   December 7, 2011, 10:41
Default
  #24
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by wanna88 View Post
Dear Amir,

My project is to perform CFD simulation for aortic dissecting aneurysm.

I would like to see what happen in the geometry at particular time and location (cross section). To see how it changes from certain time to time.

Therefore, I need to see the plot at different part of the aorta.

Thank you

Regards,
Naimah
Ok, if you want to have contours of desired variables and you haven't run the case ans also use FLUENT 13 or newer, there's an option for transient exporting data @ specified surfaces, but if this is not the case, i.e. you've run your case or you may want some graphs not contours I think the only way is using journal file. For example, do what you want via text user interface in FLUENT, when you find a correct commands, you'll need a journal generator; which can be a simple program with any language that can expand the text user interface commands for transient data files which are saved before. For more info, you can refer to user and TUI guides.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   December 9, 2011, 00:44
Default
  #25
Member
 
Naimah
Join Date: Nov 2011
Posts: 58
Rep Power: 15
wanna88 is on a distinguished road
Dear Amir,

Thank you so much for the info.
I still working on it.

However, may i ask you question regarding how fluent function?
Based on tutorial 4 : modeling compressible transient flow

A steady state solution is run first before it used as the initial condition for transient.
In the tutorial, after simulation for steady state is done, the next steps is to change the time from steady to transient.

May I know how the software function/how the software read the result from steady state solution to be used as input/initial condition for transient simulation.

I believe it is not just a simple click by changing the steady to transient.

Thank you.

Regards,
Naimah
wanna88 is offline   Reply With Quote

Old   December 9, 2011, 03:54
Default
  #26
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by wanna88 View Post
Dear Amir,

Thank you so much for the info.
I still working on it.

However, may i ask you question regarding how fluent function?
Based on tutorial 4 : modeling compressible transient flow

A steady state solution is run first before it used as the initial condition for transient.
In the tutorial, after simulation for steady state is done, the next steps is to change the time from steady to transient.

May I know how the software function/how the software read the result from steady state solution to be used as input/initial condition for transient simulation.

I believe it is not just a simple click by changing the steady to transient.

Thank you.

Regards,
Naimah
Dear Naimah,

In contrast to your belief, it's done by simply changing steady to unsteady solver in current case.
I other words, FLUENT uses any data stored in computational domain which can be provided via direct initialization or any previous simulations as initial condition .... (Also, you can use results of one case for initialization of other case; for this purpose, you need to use "file->interpolate")

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   December 30, 2011, 04:15
Default
  #27
Member
 
Naimah
Join Date: Nov 2011
Posts: 58
Rep Power: 15
wanna88 is on a distinguished road
Dear Amir,

Thank you so much for the info.

I have another questions regarding the Fluent.

1. I have set the value at inlet boundary condition at : velocity inlet : 0.175 m/s
At the solution initialization when I click compute from inlet, it will give diffrence value:

Initial value:
Gauge pressure : 0 Pa
X velocity :- 0.036 m/s
Y velocity: -0.0053 m/s
Z velocity : 0.165821 m/s

Why it give difference value? Are these value initial guess calculated by the Fluent?

2. Can I used different types of Solution methods for transient and steady case for the same case:

Transient : PISO and second order upwind
Steady : SIMPLE and first order upwind


REgards,
Naimah
wanna88 is offline   Reply With Quote

Old   December 30, 2011, 06:29
Default
  #28
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi,

1) Maybe you've set the velocity magnitude normal to the boundary and FLUENT computes its projections in required direction. I don't think this would be an important issue; this is just an initial guess which improved later.

2) Note that PISO, SIMPLE and ... are pressure velocity coupling methods and can be used with other interpolation schemes such as first order, .... Obviously, you cannot use 2 velocity-pressure coupling methods simultaneously! but you can use them separately and may used as initial values for others. Note that you can also use "SIMPLE and first order upwind" for transient and vice versa; although, the PISO algorithm is more preferable for unsteady simulations. (for more info regarding algorithms and schemes you can refer to the user manual)

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   January 4, 2012, 04:35
Default
  #29
Member
 
Naimah
Join Date: Nov 2011
Posts: 58
Rep Power: 15
wanna88 is on a distinguished road
Hi Amir,

Thank you very much for the info.

May I ask some more questions?
I have real image from CT scan data.
After smoothing, the inner part that I want to evaluate is lose.
Therefore I would like to create this part in Design Modeler in ANSYS.
Can it be done?

Thank you.

Regards,
Naimah
wanna88 is offline   Reply With Quote

Old   January 4, 2012, 09:14
Default
  #30
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by wanna88 View Post
Hi Amir,

Thank you very much for the info.

May I ask some more questions?
I have real image from CT scan data.
After smoothing, the inner part that I want to evaluate is lose.
Therefore I would like to create this part in Design Modeler in ANSYS.
Can it be done?

Thank you.

Regards,
Naimah
Dear Naimah,

I'm not sure it can be done via ANSYS Design Modeler. I heard mimics software can process these data for importing to grid generator softwares but I don't have further info in this field.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   February 14, 2012, 23:50
Default Axial velocity
  #31
Member
 
Naimah
Join Date: Nov 2011
Posts: 58
Rep Power: 15
wanna88 is on a distinguished road
Hi Amir,


I would like to ask several questions regarding how to define and plot the axial velocity and how to define the rotation axis direction in Cell Zone Condition.

Herewith I attached the figures that showed the plane in a curved tube.
Based on my understanding, I need to define the rotation axis direction for the flow to select the axial velocity. Is it correct?

How Im going to determine the rotation axis direction in the curved plane as per attached file? the rotation axis direction is not 90 degree (perpendicular) to the plane.
How Im going to take/Define the result of axial velocity?

Looking forward for your feedback.

Thank you so much.

naimah
Attached Images
File Type: jpg image.jpg (35.9 KB, 89 views)
wanna88 is offline   Reply With Quote

Old   February 15, 2012, 08:56
Default
  #32
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Quote:
Originally Posted by wanna88 View Post
Hi Amir,


I would like to ask several questions regarding how to define and plot the axial velocity and how to define the rotation axis direction in Cell Zone Condition.

Herewith I attached the figures that showed the plane in a curved tube.
Based on my understanding, I need to define the rotation axis direction for the flow to select the axial velocity. Is it correct?

How Im going to determine the rotation axis direction in the curved plane as per attached file? the rotation axis direction is not 90 degree (perpendicular) to the plane.
How Im going to take/Define the result of axial velocity?

Looking forward for your feedback.

Thank you so much.

naimah
Hi!
I think you can create a custom field function in fluent (http://hpce.iitm.ac.in/website/Manua...g/node1364.htm) to decompose for example the x velocity into a velocity perpendicular to your plane (use sin and cos).

Daniele
ghost82 is offline   Reply With Quote

Old   February 15, 2013, 08:31
Default UDF_logarithmic velocity profile
  #33
New Member
 
Join Date: Feb 2013
Posts: 18
Rep Power: 13
Roby_1986 is on a distinguished road
Hi everybody,
I'm studying, with Fluent, the model shown in the attached image.
I've to impose a loarithmic velocity profile at the upwind boundary, that is:
U(h)=Uo/k*ln(h/ho)
where: Uo= 1,068 m/s
ho=o,005 m
k=0,41 (-)

The questions are two:

1)In setting the boundary conditions,I've to select, for the upwind face, a UDF velocity profil (created on the basis of the formula: U(h)=Uo/k*ln(h/ho)). While, for the other three faces, which are also inlet faces, I have to select the same UDF or to create other ones?

2)I've imposted a possible code for UDF, that is:

#include "udf.h"

#DEFINE Uo 1,068 //unit m/s
#DEFINE k 0,41
#DEFINE ho 0,005 //unit m

DEFINE_PROFILE(inlet_x_velocity,t,i)
{
real x[ND_ND];
real y;
face_t f;

begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y = x[1];
F_PROFILE(f,thread,index) = Uo/k*log(y/ho);
}
end_f_loop(f,t)
}

Is it correct in your opinion?
I've never programmed in C language, so I don't know how to crate a UDF file, for loading it in FLUENT. Someone could please tell me how to do this?
Or, eventually, could I copy the code directly within command lines of fluent?

Thanks
Roby_1986 is offline   Reply With Quote

Old   February 15, 2013, 10:02
Default
  #34
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by Roby_1986 View Post
Hi everybody,
I'm studying, with Fluent, the model shown in the attached image.
I've to impose a loarithmic velocity profile at the upwind boundary, that is:
U(h)=Uo/k*ln(h/ho)
where: Uo= 1,068 m/s
ho=o,005 m
k=0,41 (-)

The questions are two:

1)In setting the boundary conditions,I've to select, for the upwind face, a UDF velocity profil (created on the basis of the formula: U(h)=Uo/k*ln(h/ho)). While, for the other three faces, which are also inlet faces, I have to select the same UDF or to create other ones?

2)I've imposted a possible code for UDF, that is:

#include "udf.h"

#DEFINE Uo 1,068 //unit m/s
#DEFINE k 0,41
#DEFINE ho 0,005 //unit m

DEFINE_PROFILE(inlet_x_velocity,t,i)
{
real x[ND_ND];
real y;
face_t f;

begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y = x[1];
F_PROFILE(f,thread,index) = Uo/k*log(y/ho);
}
end_f_loop(f,t)
}

Is it correct in your opinion?
I've never programmed in C language, so I don't know how to crate a UDF file, for loading it in FLUENT. Someone could please tell me how to do this?
Or, eventually, could I copy the code directly within command lines of fluent?

Thanks
Dear Roberta,

1) Yes, you can hook this UDF to all three faces (like aerodynamic examples)
2) Your UDF needs few modifications, try this:
Code:
#include "udf.h" 

#define Uo 1.068    //unit m/s
#define k 0.41
#define ho 0.005    //unit m

DEFINE_PROFILE(inlet_x_velocity,t,i)
{
  real x[ND_ND]; 
  real y; 
  face_t f;

  begin_f_loop(f,t)
  {
      F_CENTROID(x,f,t);
      y = x[1];
      F_PROFILE(f,t,i) = Uo/k*log(y/ho);  
  }
  end_f_loop(f,t)
}
3) You can interpret such simple UDFs, however, you can also compile it via extra C++ compiler on your system. Refer to my blog here for further tips in this regard.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   February 15, 2013, 11:24
Default
  #35
New Member
 
Join Date: Feb 2013
Posts: 18
Rep Power: 13
Roby_1986 is on a distinguished road
Dear Amir,
Thanks for the corrections.
Someone else has suggested to me to set the top, left and right faces as symmetry boundary conditions.
But I can't understand what this means. I should not have a symmetry with respect to anything?
Someone said that: "the problem with inlet BCs at the side walls is that the flow should be perpendicular to the face. In my case, the velocity is tangential to the surface. A symmetry boundary condition (zero shear stress) is the usual way to model such a boundary".

I've seen that setting the boundary conditions at the other 3 faces, besides the upwind one, I can choose, within Velocity Inlet, the option "Magnitude and Direction" and, as Reference frame, the option "Relative to adjacent cell zone", and then select the UDF inlet_x_velocity as Velocity Magnitude.
What do you think about this way?Should be more correct to use Symmetry BC, rather than velocity inlet?In which way?

Finally, as regard the definition of UDF, since I don't have basis of C programmation, I've seen that I can write these simple boundary conditions in a txt file, then save it as c.file and intrerpret it in fluent.


Thanks a lot.
Bests
Roby_1986 is offline   Reply With Quote

Old   February 15, 2013, 11:58
Default
  #36
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by Roby_1986 View Post
What do you think about this way?Should be more correct to use Symmetry BC, rather than velocity inlet?In which way?
You know, it depends on your case, to be more precise:
- Setting U velocity means: Specific U velocity, Zero lateral velocities
- Setting Symmetry BC means: Zero shear stress, Zero lateral velocity (There is not any constrain on tangential velocity magnitude)
If you're modelling a building among others, the symmetry bc in better but if it's the only building in a rather large domain, I suggest velocity bc. As I said this is a common choice in aerodynamic cases in incompressible flow field too where we want to set bc around a single wing.
Quote:
Originally Posted by Roby_1986 View Post
Finally, as regard the definition of UDF, since I don't have basis of C programmation, I've seen that I can write these simple boundary conditions in a txt file, then save it as c.file and intrerpret it in fluent.
Yah, this is the best approach for such UDFs.

Do not hesitate to ask if it's not clear or face any difficulties.

Bests,
cfd_worker99 likes this.
__________________
Amir
Amir is offline   Reply With Quote

Old   February 26, 2013, 05:55
Default
  #37
New Member
 
Join Date: Feb 2013
Posts: 18
Rep Power: 13
Roby_1986 is on a distinguished road
Dear Amir,
I've done some simulations with the different boundary conditions, already discussed in the previous post.
Finally my BC are:
On the frontal face of the huge air parallelepiped: inlet velocity with a UDF imposing a velocity profile changing with a log-law.
On the upper and side faces of the huge air parallelepiped: inlet velocity with the same UDF on x direction
On the back face of the huge domain: pressure outlet=0
On the building walls, there is no slip and a roughness height=0 and roughness constant=0.5.
While the basis of the huge air parallelepiped is a wall, with no slip and a roughness height of 5*10^(-5) and a roughness constant=0.5.
Then, I've a k-epsilon RNG model, with Standard Wall Function It=4% and Lt=0.4 m
Now, I've to calculate a Volume flow rate on an opening, located on the front wall of the building, so while meshing I've created a name selection on the surface of this opening, which is set as "Interior"on boundary condition in Fluent.
The problem is that I obtain a Volume flow rate too small, and I can't understand the reason.
The model converges, the mass conservation is respected. I've tried to change BC on the upper and side faces of the domain, to eliminate the roughness on the basis but nothing changes.
What could be the problem?
Thanks a lot
Roby_1986 is offline   Reply With Quote

Old   February 26, 2013, 06:05
Default
  #38
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Quote:
Originally Posted by Roby_1986 View Post
Dear Amir,
I've done some simulations with the different boundary conditions, already discussed in the previous post.
Finally my BC are:
On the frontal face of the huge air parallelepiped: inlet velocity with a UDF imposing a velocity profile changing with a log-law.
On the upper and side faces of the huge air parallelepiped: inlet velocity with the same UDF on x direction
On the back face of the huge domain: pressure outlet=0
On the building walls, there is no slip and a roughness height=0 and roughness constant=0.5.
While the basis of the huge air parallelepiped is a wall, with no slip and a roughness height of 5*10^(-5) and a roughness constant=0.5.
Then, I've a k-epsilon RNG model, with Standard Wall Function It=4% and Lt=0.4 m
Now, I've to calculate a Volume flow rate on an opening, located on the front wall of the building, so while meshing I've created a name selection on the surface of this opening, which is set as "Interior"on boundary condition in Fluent.
The problem is that I obtain a Volume flow rate too small, and I can't understand the reason.
The model converges, the mass conservation is respected. I've tried to change BC on the upper and side faces of the domain, to eliminate the roughness on the basis but nothing changes.
What could be the problem?
Thanks a lot
Maybe your grid is too coarse?
What is the calculated value and the real one?
ghost82 is offline   Reply With Quote

Old   February 26, 2013, 18:57
Default
  #39
New Member
 
Join Date: Feb 2013
Posts: 18
Rep Power: 13
Roby_1986 is on a distinguished road
Hi everybody,
Probably the problem is not the mesh but the boundary conditions. I want to try to separate the outdoor air domain (the huge air parallelepiped) and the internal building air domain, setting the building window not as "interior" but as velocity inlet or pressure inlet for the domain constitutes of the interior air.
This might be correct in your opinion?
My aim is to evaluate the volume flow rate on the building window.
Thanks a lot
Roby_1986 is offline   Reply With Quote

Old   April 11, 2013, 04:26
Default
  #40
New Member
 
Ashutosh
Join Date: Jan 2013
Location: mhow
Posts: 3
Rep Power: 13
mesh_generation is on a distinguished road
Dear Sir
I am working on fluent for last one year. I am familier with C++ and MATLAB. In writing UDF for inlet boundary or for moving wall I feel difficulty. From last few weeks only due to one error in my code I can not proceed further. Please help me or contact me on my personal mail id so we can discuss in detail:

my mail id is
: ashutoshverma194@ymail.com
vermaashutosh143@gmail.com
mesh_generation is offline   Reply With Quote

Reply


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
UDF problems - velocity profile Oli Fluent UDF and Scheme Programming 6 October 24, 2016 11:38
How to create non-uniform velocity profile in FLUENT? pankaj FLUENT 7 October 24, 2016 05:52
udf for velocity profile in a geometry having two inlets shubham208011 Fluent UDF and Scheme Programming 0 April 6, 2009 16:13
UDF velocity and temperature Raj FLUENT 3 February 1, 2009 19:29
UDF velocity profile at nodes Emad FLUENT 2 January 29, 2009 07:35


All times are GMT -4. The time now is 21:40.