Week 11 - Simulation of Flow through a pipe in OpenFoam
Flows through pipe are to be analysed for all the real life problems. It is completely a new domain in gas and oil industries, or chemical industries. Here, let us consider a circular pipe where the flow is laminar. To design the pipe, hagen poiseuille's equations are used.
Hagen poiseuille's theory:
Two assumptions are:
1. The viscosity of fluid follows newtons law of viscosity
2. No slip of fluid particles at the solid boundary
Fully developed velocity profile is as shown in the figure.
Renolds number =2100 (laminar flow)
fluid is water at 25 degrees centigrade
density of water('rho') =997 kg/m^3
dynamic viscosity(`mu`)= 8.9 x 10^-4
Diameter of the pipe (d)=0.02 m
Calculated variables:
Entry length of the pipe = 0.6* Re*d = 2.52m This means that minimum legth of the pipe should be 2.52m. The total length of the pipe is 2.7
Average velocity, `Vavg = (Re.mu)/(rho.d)`=0.094m/s
Maximum velocity,`Vmax = 2 Vavg =0.187m/s`
Pressure drop,`Deltap =(32. mu.l.Vavg)/d^2`=18.01Pa
Kinematic pressure `Deltap= (DeltaP)/rho` = 0.01807 m
As the pipe is circular and symmetric, only a part of pipe is taken and simulated. These can be used for the complete pipe. A wedge of angle<5 degrees is taken for the simulation.
A matlab program is written to generate a blockMesh file for any angle of the wedge(<5 degrees)
close all
clear all
clc
d=0.02; %diameter
r=d/2;
L=2.7;
theta= input('Enter the value of wedge angle = ');
x= input('Enter the grading factor along x = ');
y= input('Enter the grading factor along y =');
z= input('Enter the grading factor alonf z =');
h1='/*--------------------------------*- C++ -*----------------------------------*\';
h2='| ========= | |';
h3='| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |';
h4='| \ / O peration | Version: 1.5 |';
h5='| \ / A nd | Web: http://www.OpenFOAM.org |';
h6='| \/ M anipulation | |';
h7='\*---------------------------------------------------------------------------*/';
bmd= fopen('blockMeshDict','w');
fprintf(bmd,'%s \n',h1);
fprintf(bmd,'%s \n',h2);
fprintf(bmd,'%s \n',h3);
fprintf(bmd,'%s \n',h4);
fprintf(bmd,'%s \n',h5);
fprintf(bmd,'%s \n',h6);
fprintf(bmd,'%s \n',h7);
fprintf(bmd,'FoamFile\n{\n');
fprintf(bmd,'\t version 2.0;\n');
fprintf(bmd,'\t format ascii;\n');
fprintf(bmd,'\t class dictionary;\n');
fprintf(bmd,'\t object blockMeshDict;\n}\n');
fprintf(bmd,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n\n');
fprintf(bmd,'convertToMeters 0.001;\n\n');
fprintf(bmd,'vertices\n(\n');
fprintf(bmd,'\t (%d %d %d)\n',0,0,0); %point0
fprintf(bmd,'\t (%d %d %d)\n',0,r*cosd(theta/2),r*sind(theta/2)); %point1
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); %point3
fprintf(bmd,'\t (%d %d %d)\n',L,r*cosd(theta/2),r*sind(theta/2)); %point4
fprintf(bmd,'\t (%d %d %d)\n',L,r*cosd(theta/2),-r*sind(theta/2)); %point5
fprintf(bmd,');\n\n');
fprintf(bmd,'blocks\n(\n');
fprintf(bmd,'\t hex (0 3 5 2 0 3 4 1) (600 40 1) simpleGrading (%d %d %d)',x,y,z);
fprintf(bmd,'\n);\n\n');
fprintf(bmd,'edges\n(\n');
fprintf(bmd,'\t arc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(bmd,'\t arc %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\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\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 4 5 3)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');
fprintf(bmd,'\t top\n\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\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 5 2)\n');
fprintf(bmd,'\t\t );\n');
fprintf(bmd,'\t}\n');
fprintf(bmd,'\t front\n\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\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');
fprintf(bmd,'\nmergePatchPairs\n(\n);\n');
fprintf(bmd,'\n// * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fclose(bmd);
Output- bloMeshDict:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 1.5 |
| \ / A nd | Web: http://www.OpenFOAM.org |
| \/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 0 0)
(0 9.998477e-03 1.745241e-04)
(0 9.998477e-03 -1.745241e-04)
(2.700000e+00 0 0)
(2.700000e+00 9.998477e-03 1.745241e-04)
(2.700000e+00 9.998477e-03 -1.745241e-04)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (600 20 1) simpleGrading (1 0.2 1)
);
edges
(
arc 1 2 (0 1.000000e-02 0)
arc 4 5 (2.700000e+00 1.000000e-02 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
back
{
type wedge;
faces
(
(0 3 5 2)
);
}
front
{
type wedge;
faces
(
(0 3 4 1)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Boundary conditions:
Pressure
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ 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
{
type zeroGradient;
//value uniform 0;
}
top
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
axis
{
type empty;
}
outlet
{
type fixedValue;
value uniform 0.01807;
}
}
// ************************************************************************* //
Velocity:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ 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.1874 0 0);
}
top
{
type fixedValue;
value uniform (0 0 0);
}
back
{
type wedge;
}
front
{
type wedge;
}
axis
{
type empty;
}
outlet
{
type zeroGradient;
}
}
// ************************************************************************* //
Visualisation of pipe: (velocity)
Plots:
Velocity is plotted as shown in the figure below.
This resembles the profile of that is obtained from Hagen Poisuelli's equation. From this it can be concluded that velocity profile is fully developed in the pipe.
Shear stress plot:
Shear stress increase as the radius of the pipe increase i.e., as we move from the centre of the pipe in the direction of its radius shear stress increases. Hence it follows the newtons law of viscosity.