Challenge

Week 11 - Simulation of Flow through a pipe in OpenFoam

Aim:- Simulation of Flow through a pipe in OpenFoam and validation of the result.

Objective:-

  1. Validate Hydro-dynamic length with the numerical result.
  2. Validate the fully developed flow velocity profile with its analytical profile.
  3. Validate maximum velocity and pressured drop for fully developed flow.
  4. Post-process Shear stress and validate wall shear stress for fully developed flow.

Theory:-

Laminar & Turbulent Flow:-

Laminar flow is also referred to as streamline or viscous flow.

These terms are descriptive of the flow because, in laminar flow.

(1) layers of water flowing over one another at different speeds with virtually no mixing between layers.

(2) fluid particles move in definite and observable paths or streamlines.

(3) the flow is characteristic of viscous (thick) fluid or is one in which viscosity of the fluid plays a significant part.

Turbulent flow is characterized by the irregular movement of particles of the fluid.

There is no definite frequency as there is in wave motion.

The particles travel in irregular paths with no observable pattern and no definite layers.

Reynolds Number:-

  1. It is the non-dimensional number, basically defined as the ratio of the inertial force to the viscous force.
  2. The values of the Reynolds number for laminar and turbulent flow are different as shown below;
  3. Basically, the idea behind the reynold's number is that whenever we are using the small prototype models the criteria to reduce the size of the model from the actual model is done in proportionality that is where concept of Reynolds Number comes into the picture.
  4. This is done by reducing the characteristic length(L) of the Reynold's Number(Re).

`Re= (rhoVL)/mu`

Internal Flows External Flow
Laminar Flow Transition Flow Turbulent Flow Laminar Flow Transition Flow Turbulent Flow
Re<2300
2300<Re<4300
4300"}">
Re>4300
Re<1*e+5
1*e+5<Re<5*e+5
5*e+5"}">
Re>5*e+5

Haugen Poiseuille Equation:-

`Delta P=(8muVL)/R^2=(32muVL)/D^2`

Where,

`DeltaP`-Pressure difference

R -Radius of Pipe

`mu`-Dynamic viscosity

L - length of the pipe

D - Diameter of Pipe

DATA:-

  • Reynold's number at Inlet = 2100
  • Geometry is axis-symmetric.
  • Flow through the pipe is laminar & cross sectional area is constant.
  • Wedge angle should be less than 5 degree.

Analytical Solution:-

Diameter of the pipe:-

D= 0.04m; R=D/2=0.04/2=0.02m;

Angle of Wedge :-

`theta= 3^o`

Density of working fluid:-

`rho =997 (kg)/m^3`

Dynamic Viscosity at 25 degree celcius:-

`mu=0.89*10^-3 Pa.sec`

Kinematic Viscosity:-

`v=mu/rho`

`v=(0.89 *10^-3)/997`

`v=8.9267*10^-7 m^2/sec`

Hydrodynamic Entrance Length:-

`L_h=0.06*Re*D`

`L_h=0.06*2100*0.04`

`L_h=5.04m`

Total Length of Pipe:-

`L_(Total)=5.04+0.56`

`L_(Total)=5.6m`

Average Velocity:-

`V_(avg)=((Re*mu)/(rho*D))`

`V_(avg)=(2100*0.89*10^-3)/(997*0.04)`

`V_(avg)= 46.86*10^-3 m/sec`

Maximum Velocity:-

`V_max=2*V_(avg)`

`V_max=2*46.86*10^-3`

`V_(max)=93.72 m/sec`

Pressure Drop:-

`Delta P=(8muVL)/R^2=(8*0.89*10^-3*46.86*10^-3*5.04)/0.02^2`

`DeltaP=4.204Pa`

Kinematic Pressure Drop:-

`"Kinematic" DeltaP= (Delta P)/rho`

`"Kinematic" DeltaP=4.204/997=0.004216 Pa`

MATLAB CODE:-

% SIMULATION OF FLOW THROUGH A PIPE
% Code to automate generation of blockMeshDict file
clear all
close all
clc
% INPUTS
% Assumptions
% Diameter of Pipe (m)
D = 0.04;
% Radius of Pipe (m)
R = D/2;
% Reynold's Number
Re = 2100;
% Wedge Angle (degrees)
theta = 4;
% Total Length of the Pipe (m)
L = 5.6;
% Assuming working fluid is water at 25° C
% Density of water (kg/m³)
rho = 997;
% Dynamic Viscosity of Water (Pa.s)
mu = 8.90 * 10^-4;
% Kinematic Viscosity of Water (m^2/s)
nu = mu/rho;
% Hydrodynamic Entrance Length (m)
L_h = 0.06 * Re * D;
% HAGEN - POISEUILLE'S FLOW EQUATIONS
% Average Velocity (m/s)
V_avg = (mu * Re)/(rho * D);
% Maximum Velocity (m/s)
V_max = 2 * V_avg;
% Pressure Drop (Pa)
delta_p = (32*mu*V_avg*L)/(D^2);
% Kinematic Pressure Drop (Pa)
kinematic_delta_p = delta_p/rho;
%Vortices of the Wedge
V0=[0 0 0]
V1=[0 R*cosd(theta/2) -R*sind(theta/2)]
V2=[0 R*cosd(theta/2) R*sind(theta/2)]
V3=[L 0 0]
V4=[L R*cosd(theta/2) -R*sind(theta/2)]
V5=[L R*cosd(theta/2) R*sind(theta/2)]
%Creating BlockMeshDict File
%Creating the file
%Header
h1='/*--------------------------------*- C++ -*----------------------------------*\';
h2=' ========= |';
h3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox';
h4=' \\ / O peration | Website: https://openfoam.org';
h5=' \\ / A nd | Version: 10';
h6=' \\/ M anipulation |';
h7='\*---------------------------------------------------------------------------*/';
h8='FoamFile';
h9='{';
h10=' format ascii;';
h11=' class dictionary;';
h12=' object blockMeshDict;';
h13='}';
h14='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
f1=fopen('blockMeshDict.txt',"w");
%Header
fprintf(f1,'%s\n',h1);
fprintf(f1,'%s\n',h2);
fprintf(f1,'%s\n',h3);
fprintf(f1,'%s\n',h4);
fprintf(f1,'%s\n',h5);
fprintf(f1,'%s\n',h6);
fprintf(f1,'%s\n',h7);
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'%s\n',h10);
fprintf(f1,'%s\n',h11);
fprintf(f1,'%s\n',h12);
fprintf(f1,'%s\n',h13);
fprintf(f1,'%s\n\n',h14);
%Conversion Factor
fprintf(f1,'%s\n\n','convertToMeters 1;');
fprintf(f1,'%s\n','vertices');
fprintf(f1,'%s\n','(');
fprintf(f1,'\t(%d %d %d)\n',V0);
fprintf(f1,'\t(%d %f %f)\n',V1);
fprintf(f1,'\t(%d %f %f)\n',V2);
fprintf(f1,'\t(%.2f %d %d)\n',V3);
fprintf(f1,'\t(%.2f %f %f)\n',V4);
fprintf(f1,'\t(%.2f %f %f)\n',V5);
fprintf(f1,'%s\n',');');
%Blocks
fprintf(f1,'%s\n','blocks');
fprintf(f1,'%s\n','(');
fprintf(f1,'\thex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (1 1 1)\n');
fprintf(f1,'%s\n',');');
%EDGES
fprintf(f1,'%s\n','edges');
fprintf(f1,'%s\n','(');
fprintf(f1,'\tarc 2 1(%d %.3f %d)\n',0,R,0);
fprintf(f1,'\tarc 5 4(%.3f %.3f %d)\n',L,R,0);
fprintf(f1,'%s\n',');');
%BOUNDARY
fprintf(f1,'%s\n','boundary');
fprintf(f1,'%s\n','(');
%Axis
fprintf(f1,'\taxis\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 3 0)\n');
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tinlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 1 2 0)\n');
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\toutlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(3 5 4 3)\n');
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tfrontface\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 3 4 1)\n');
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\trareface\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(0 2 5 3)\n');
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tpipewall\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(1 4 5 2)\n');
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'%s\n\n',');');
fprintf(f1,'%s\n','mergePatchPairs');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s\n\n',');');
fprintf(f1,'%s\n','// ************************************************************************* //');

BlockMeshDict File:-

/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 0.019988 -0.000698)
(0 0.019988 0.000698)
(5.60 0 0)
(5.60 0.019988 -0.000698)
(5.60 0.019988 0.000698)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (30 1 100) simpleGrading (1 1 1)
);
edges
(
arc 2 1(0 0.020 0)
arc 5 4(5.600 0.020 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
inlet
{
type empty;
faces
(
(0 1 2 0)
);
}
outlet
{
type empty;
faces
(
(3 5 4 3)
);
}
frontface
{
type empty;
faces
(
(0 3 4 1)
);
}
rareface
{
type empty;
faces
(
(0 2 5 3)
);
}
pipewall
{
type empty;
faces
(
(1 4 5 2)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //

GEOMETRY:-

MESH:-

P File:-

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

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

internalField uniform 0;

boundaryField
{

inlet
{
type zeroGradient;
}

outlet
{
type zeroGradient;
value uniform 0.0187;
}

front
{
type wedge;
}

back
{
type wedge;
}

pipeWall
{
type zeroGradient;
}
}

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

U File:-

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

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

internalField uniform (0.046 0 0);

boundaryField
{

inlet
{
type fixedValue;
value uniform (0.046 0 0);
}

outlet
{
type zeroGradient;
}

front
{
type wedge;
}

back
{
type wedge;
}

pipeWall
{
type noSlip;
}
}

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

Physical Properties:-

/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object physicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu [0 2 -1 0 0 0 0] 8.9268e-4;


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

ControlDict:-

/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application icoFoam;

startFrom startTime;

startTime 0;

stopAt endTime;

endTime 120;

deltaT 0.0015;

writeControl timeStep;

writeInterval 20;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

runTimeModifiable true;


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

fvSchemes:-

/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
default Euler;
}

gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}

divSchemes
{
default none;
div(phi,U) Gauss linear;
}

laplacianSchemes
{
default Gauss linear orthogonal;
}

interpolationSchemes
{
default linear;
}

snGradSchemes
{
default orthogonal;
}


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

fvSolutions:-

/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.05;
}

pFinal
{
$p;
relTol 0;
}

U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
}

PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}


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

RESULTS:-

PRESSURE:-

VELOCITY:-

CONCLUSION:-

From the above results, we can observed that the velocity is going to decrease at the pipe wall regions where the pressure is more, as the boundary layer is created. As we move away from the wall the the velocity is goes on increasing upto the centre, where the pressure is less.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.