# Simulation of Flow through a pipe in                                OpenFoam

Objective of the project:-

1. Calculation of flow variables.

2. Generation of the blockMeshDict using the wedge boundary condition. create the blockMeshDict file in MATLAB such that the mesh is autoatically created for various wedge angles.

3. Simulating the pipe flow in openFoam using icoFoa solver.

4. Post process the velocity profile and shear  strass and comparfe the simulation results with analytical results obtained using the hagen poiseuille's equation.Post processing is carried out in the paraVIEW.

Assumptions:-

Fluid obey's the neuton's law of viscosity(tau=mu*((du)/dy))

No slip of the fluid particles at the boundary.

Flow variables:-

The working fluid is water.

Density =1000 kg*m^-3

Dynamic viscosity = 8.90*10^-4pa*s

Reynolds number= 2100

diameter of pipe=0.004 m

Formulae:-

V(r)=V_max *(1-r^2/R^2)

tau(r)=(2*mu*V_max*r)/R^2

"Length of pipe"=0.05*Re*D

"Velocity(v)"=(Re*mu)/(rho*D)

V_max =2*V

"Pressure(P)"=(32*mu*V*L)/D^2

"Kinematic pressure"=P/rho

"Maximum shear stress"(tau_max)=(2*mu*V_max)/R

Calculated results:-

L=0.42 m

V=0.4686 m/s

V_max = 0.9373 m/s

Kinematic pressure = 0.3493161

tau_max= 0.831705 N/m^2

since the minimum length required for fully developed flow is 0.42m, hence we take the pipe length as 1m.

Hydrodynamic Entrance Length :-

It is the distance a flow travels in the pipe before it becomes fully developed. Entrance length refers to the length of entry region, the area following the pipe entrance where effects originating from the interior wall of the pipe propagate into the flow as an expanding boundary layer. When the boundary layer expands to fill the entire pipe, the developing flow becomes a fully developed flow, where flow characteristics no longer changes with increased distance along the pipe.

For laminar flow, the hydrodynamic entrance length is given as-

L = 0.05*Re *D or L=1.05m

Hence the length of the pipe for simulation is taken as 1.2m.

Analytical solution by Hagen-Poiseuille equation:-

Average velocity=V_(avg) = (Re*mu)/(rho*D)=0.46725 m/s

maximum velocity=V_max =2*V_(avg)=0.9345 m/sec

pressure drop =triangleP=(32*mu*L*V_(avg))/D^2=349.3161

Kinematic pressure drop=triangleP_k=(triangleP)/rho=0.3493161

Matlab code for automatic generation of the blockMeshDict file:-

clear all
close all
clc

L=1;
D=0.004;
r=D/2;
theta=3;
nx=500;
ny=50;
nz=1;

line1='/*----------------------------------------*- C++ -*-------------------------------------*\';
line2='|  =========                   |                                                         |';
line3='|  \\      /    F ield         | openFoam: The open source CFD Toolbox                   |';
line4='|   \\    /     O peration     | Version:  4.1                                           |';
line5='|    \\  /      A nd           | Web:      www.openFoam.org                              |';
line6='|     \\/       M anipulation  |                                                         |';
line7='\*--------------------------------------------------------------------------------------*/';

bmd=fopen('blockMeshDict','w')
fprintf(bmd,'%s\n',line1);
fprintf(bmd,'%s\n',line2);
fprintf(bmd,'%s\n',line3);
fprintf(bmd,'%s\n',line4);
fprintf(bmd,'%s\n',line5);
fprintf(bmd,'%s\n',line6);
fprintf(bmd,'%s\n',line7);

fprintf(bmd,'Foamfile\n{\n');
fprintf(bmd,'%12s\t 2.0;\n','version');
fprintf(bmd,'%11s\t ascii;\n','format');
fprintf(bmd,'%10s\t dictionary;\n','class');
fprintf(bmd,'%11s\t blockMeshDict;\n','object');
fprintf(bmd,'}\n');
line8='//**************************************************************************************//';
fprintf(bmd,'%s\n\n',line8);

fprintf(bmd,'convertToMeters 1;\n\n');
fprintf(bmd,'vertices\n')
fprintf(bmd,'(\n')
fprintf(bmd,'\t (%d %d %d)\n',0,0,0); %point 0
fprintf(bmd,'\t (%d %d %d)\n',0,r*cosd(theta/2),r*sind(theta/2)); %point 1
fprintf(bmd,'\t (%d %d %d)\n',0,r*cosd(theta/2),-r*sind(theta/2)); %point 2
fprintf(bmd,'\t (%d %d %d)\n',L,0,0); %point 3
fprintf(bmd,'\t (%d %d %d)\n',L,r*cosd(theta/2),r*sind(theta/2)); %point 4
fprintf(bmd,'\t (%d %d %d)\n',L,r*cosd(theta/2),-r*sind(theta/2)); %point 5
fprintf(bmd,');\n\n');

fprintf(bmd,'blocks\n');
fprintf(bmd,'(\n');
fprintf(bmd,'     hex (0 3 5 2 0 3 4 1) (%d %d %d) ',nx,ny,nz);
fprintf(bmd,');\n\n');

fprintf(bmd,'edges\n(\n\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(bmd,'\tarc %d %d (%d %d %d)\n',4,5,L,r,0);
fprintf(bmd,');\n\n');

fprintf(bmd,'boundary\n(\n');
fprintf(bmd,'\t inlet\n');
fprintf(bmd,'\t{\n');
fprintf(bmd,'\t\t type patch;\n');
fprintf(bmd,'\t\t faces\n');
fprintf(bmd,'\t\t(\n');
fprintf(bmd,'\t\t\t (0 1 2 0)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');

fprintf(bmd,'\t outlet\n');
fprintf(bmd,'\t{\n');
fprintf(bmd,'\t\t type patch;\n');
fprintf(bmd,'\t\t faces\n');
fprintf(bmd,'\t\t (\n');
fprintf(bmd,'\t\t\t (3 5 4 3)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');

fprintf(bmd,'\t top\n');
fprintf(bmd,'\t{\n');
fprintf(bmd,'\t\t type wall;\n');
fprintf(bmd,'\t\t faces\n');
fprintf(bmd,'\t\t (\n');
fprintf(bmd,'\t\t\t (1 4 5 2)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');

fprintf(bmd,'\t back\n');
fprintf(bmd,'\t{\n');
fprintf(bmd,'\t\t type wedge;\n');
fprintf(bmd,'\t\t faces\n');
fprintf(bmd,'\t\t (\n');
fprintf(bmd,'\t\t\t (0 2 5 3)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');

fprintf(bmd,'\t front\n');
fprintf(bmd,'\t{\n');
fprintf(bmd,'\t\t type wedge;\n');
fprintf(bmd,'\t\t faces\n');
fprintf(bmd,'\t\t (\n');
fprintf(bmd,'\t\t\t (0 3 4 1)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');

fprintf(bmd,'\t axis\n');
fprintf(bmd,'\t{\n');
fprintf(bmd,'\t\t type empty;\n');
fprintf(bmd,'\t\t faces\n');
fprintf(bmd,'\t\t (\n');
fprintf(bmd,'\t\t\t (0 3 3 0)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');
fprintf(bmd,');\n\n')

fprintf(bmd,'mergePatchPairs\n(\n');
fprintf(bmd,');\n')

fprintf(bmd,'%s\n',line8);

fclose(bmd)

blockMeshDict file generated for wedge angle =3^@

/*----------------------------------------*- C++ -*-------------------------------------*\
|  =========                   |                                                         |
|  \\      /    F ield         | openFoam: The open source CFD Toolbox                   |
|   \\    /     O peration     | Version:  4.1                                           |
|    \\  /      A nd           | Web:      www.openFoam.org                              |
|     \\/       M anipulation  |                                                         |
\*--------------------------------------------------------------------------------------*/
Foamfile
{
version	 2.0;
format	 ascii;
class	 dictonary;
object	 blockMeshDict;
}
//**************************************************************************************//

convertToMeters 1;

vertices
(
(0 0 0)
(0 1.999315e-03 5.235390e-05)
(0 1.999315e-03 -5.235390e-05)
(1 0 0)
(1 1.999315e-03 5.235390e-05)
(1 1.999315e-03 -5.235390e-05)
);

blocks
(
hex (0 3 5 2 0 3 4 1) (500 50 1) simpleGrading(1 0.1 1)

);

edges
(
arc 1 2 (0 2.000000e-03 0)
arc 4 5 (1 2.000000e-03 0)
);

boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
back
{
type wedge;
faces
(
(0 2 5 3)
);
}
front
{
type wedge;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);

mergePatchPairs
(
);
//**************************************************************************************//


Velocity boundary condition:-

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
\\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  7
\\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
version     2.0;
format      ascii;
class       volVectorField;
object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
inlet
{
type            fixedValue;
value           uniform (0.46725 0 0);
}

outlet
{
}

top
{
type            noSlip;
}
back
{
type            wedge;
}
front
{
type            wedge;
}
axis
{
type            empty;
}
}

// ************************************************************************* //

Pressure boundary condition:-

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
\\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  7
\\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
version     2.0;
format      ascii;
class       volScalarField;
object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
inlet
{
}

outlet
{
type            fixedValue;
value           uniform 0.3493161;
}

top
{
}
back
{
type            wedge;
}
front
{
type            wedge;
}
axis
{
type            empty;
}
}

// ************************************************************************* //

OpenFoam case setUp:-

A wedge boundary condition is used in this case as it is cylinder and flow is axi-symmetric along the axis.

After updating the blockMeshDict and pressure and velocity boundary conditions file simulation is ran using the icoFoam solver which is used to simulate the turbulent, incompressible flows.

Base mesh for wedge angle=3^@

Results for the wedge angle=3^@

Velocity contours:-

Pressure contours:-

Velocity profile At 0.01m:-

the velocity profile near the entrance of the pipe is flat. It means the flow is still developing.

Velocity profile At 0.1m:-

velocity profile At 0.43m:-

velocity profile At 0.75m:-

A parabolic velocity profile is obtained after a certain distance in the pipe. This profiles remains unchanged thereafter. it concludes that the length of the pipe as calculated theoritically is suffiecient to get a fully developed flow at the outlet of the pipe.

The shear stress is calculated from the given formula

tau =mu*(du)/(dy) Pa

Pressure Profile:-

### Explore Tutorial No 1- SI final Saurabh kumar sharma · 2020-04-03 08:29:59

Explore Tutorial No 1- SI final Introduction:- A spark ignition IC engine model take for my case study is single cylinder model. It is port injected and fuel and air enters in to the combustion chamber as homogenious mixture. This model of our engine runs at 1800 rpm Read more

### Assignment 1 Understanding GT Power Saurabh kumar sharma · 2020-03-13 11:56:54

Assignment 1: Understanding GT Power   1. Introduction:- GT Suite is multiphysics CAE system simulation software. The foundation of GT suite is a versatile multi-physics plateform for constructing models of general systems based on many underlying Read more

### Gearbox sloshing effect Saurabh kumar sharma · 2020-03-02 18:35:18

Gearbox Sloshing effect The objective is to perform gear sloshing simulation on ansys fluent for two different gearboxes with different clearance. The User defined function is used which provides the angular velocity of 200rpm. Four simulations were performed:- Case Read more

### Challenge on Combustion Saurabh kumar sharma · 2020-02-16 18:45:07

Challenge on Combustion Objective:- Perform a combustion simulation on the combuster model and plot the variation of the mass fraction of the different species in the simulation using line probes at different locations of the combuster. You need to plot Read more

# Cyclone Separator Challenge

Objective:-

We have to perform an analysis on the cyclone seperator model for  different number of inectioned particles.

1. The four imperical models use Read more

### Gate Valve Parametric Study Saurabh kumar sharma · 2020-01-31 18:16:41

Gate Valve Parametric Study A gate valve, also known as a sluice valve, is a valve that opens by lifting a barrier(gate) out of the path of the fluid.Gate valves are used to shut off the flow of liquids rather than for flow regulation. Gate valve require Read more

### Conjugate Heat Transfer Analysis on a graphics card Saurabh kumar sharma · 2020-01-22 19:18:44

Conjugate Heat Transfer Analysis on a graphics card. Description of a conjugate heat transfer analysis:- Conjugate heat transfer represents the combination of heat transfer in liquids and solids simulteneously. The mode of heat transfer in solids is conduction and con Read more

### Rayleigh Taylor Instability Challenge Saurabh kumar sharma · 2020-01-09 17:49:16

Rayleigh Taylor Instability Challenge SOLUTION-1:- Models used for Rayleigh-Taylor instability:- Early-time growth Potential flow Buoyancy-drag balance Energy budget   1. Early-time growth:- It was noted in the taylor (1950) that t Read more

### Exhaust Port Challenge Saurabh kumar sharma · 2019-12-19 08:14:22

Exhaust Port Challenge SOLUTION1:- Why and Where a CHT analysis is used? Conjugate Heat Transfer analysis:- Conjugate heat transfer analysis is generally used when there is a teperature variation during heating and co Read more

### Ahmed Body Challenge Saurabh kumar sharma · 2019-12-17 16:08:31

Ahmed Body Challenge  SOLUTION1: Ahmed body:- The Ahmed body was originally described By S.R. Ahmed in 1984. Ahmed body is a simplified car body. The shape provides a  model to study geometric effects Read more