CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   (ask) how to create UDF for inlet velocity profile (https://www.cfd-online.com/Forums/fluent-udf/86275-ask-how-create-udf-inlet-velocity-profile.html)

wanna88 December 7, 2011 04:23

Quote:

Originally Posted by Amir (Post 334682)
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

Amir December 7, 2011 05:28

Quote:

Originally Posted by wanna88 (Post 334971)
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 (Post 334971)
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,

wanna88 December 7, 2011 05:49

Quote:

Originally Posted by Amir (Post 334988)
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

Amir December 7, 2011 09:41

Quote:

Originally Posted by wanna88 (Post 334991)
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,

wanna88 December 8, 2011 23:44

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

Amir December 9, 2011 02:54

Quote:

Originally Posted by wanna88 (Post 335223)
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,

wanna88 December 30, 2011 03:15

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

Amir December 30, 2011 05:29

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,

wanna88 January 4, 2012 03:35

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

Amir January 4, 2012 08:14

Quote:

Originally Posted by wanna88 (Post 337794)
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,

wanna88 February 14, 2012 22:50

Axial velocity
 
1 Attachment(s)
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

ghost82 February 15, 2012 07:56

Quote:

Originally Posted by wanna88 (Post 344497)
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

Roby_1986 February 15, 2013 07:31

UDF_logarithmic velocity profile
 
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

Amir February 15, 2013 09:02

Quote:

Originally Posted by Roby_1986 (Post 408015)
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,

Roby_1986 February 15, 2013 10:24

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

Amir February 15, 2013 10:58

Quote:

Originally Posted by Roby_1986 (Post 408061)
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 (Post 408061)
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,

Roby_1986 February 26, 2013 04:55

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

ghost82 February 26, 2013 05:05

Quote:

Originally Posted by Roby_1986 (Post 410145)
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?

Roby_1986 February 26, 2013 17:57

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

mesh_generation April 11, 2013 03:26

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


All times are GMT -4. The time now is 10:33.