SIMULATION OF FLOW THROUGH A PIPE USING OPENFOAM
AIM:
- Calculate length of the pipe using the entry length formula for laminar flow through a pipe.
- Show that entry length is sufficient to produce a fully developed flow. You will have to compare velocity profiles at different positions along the length of the pipe.
- To Show that the velocity profile is fully developed.
- Post process velocity and shear stress.
OVERVIEW:
- Reynolds number based on pipe diameter and inlet velocity should be 2100
- Working fluid - water
- You need to calculate the length of the pipe
- Calculate length of the pipe using the entry length formula for laminar flow through a pipe
- Show that entry length is sufficient to produce a fully developed flow. You will have to compare velocity profiles at different positions along the length of the pipe.
- Solver - icoFOAM.
- Write a program in Matlab that can generate the computational mesh automatically for any wedge angle and grading schemes
- Hint: wedge angle should be less than 5 degrees
- Make sure that number of cells along the "axi symmetric"
- For a baseline mesh, show that the velocity profile matches with the Hagen poiseuille's equation
- Show that the velocity profile is fully developed
- Post process velocity and shear stress
Data:
Re = 2100;
D = 0.015;
L = 0.06*Re*D;
R = D/2;
theta =4;
mu = 0.890e-3;
rho = 997;
n1 = 1;
n2 = 50;
n3 = 200;
gfactor =0.2;
Formula:
v_avg = (Re*mu)/(rho*D);
v_max = 2*(v_avg);
del_p = (32*mu*L*v_avg)/(D^2);
kinematic = del_p/rho;
s = (2*mu*v_max)/R;
c0 = [0 0 0];
c1 = [0 R*cosd(theta/2) -R*sind(theta/2)];
c2 = [0 R*cosd(theta/2) R*sind(theta/2)];
c3 = [0 0 L];
c4 = [L R*cosd(theta/2) -R*sind(theta/2)];
c5 = [L R*cosd(theta/2) R*sind(theta/2)];
Calculations:
MatLAB coding:
clear
close all
clc
Re = 2100;
D = 0.015;
L = 0.06*Re*D;
R = D/2;
theta =4;
mu = 0.890e-3;
rho = 997;
n1 = 1;
n2 = 50;
n3 = 200;
gfactor =0.2;
v_avg = (Re*mu)/(rho*D);
v_max = 2*(v_avg);
del_p = (32*mu*L*v_avg)/(D^2);
kinematic = del_p/rho;
c0 = [0 0 0];
c1 = [0 R*cosd(theta/2) -R*sind(theta/2)];
c2 = [0 R*cosd(theta/2) R*sind(theta/2)];
c3 = [0 0 L];
c4 = [L R*cosd(theta/2) -R*sind(theta/2)];
c5 = [L R*cosd(theta/2) R*sind(theta/2)];
line1 = ('/*--------------------------------*- C++ -*----------------------------------*\');
line2 = ('| ========= |');
line3 = ('| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |');
line4 = ('| \\ / O peration | Website: https://openfoam.org |');
line5 = ('| \\ / A nd | Version: 7 |');
line6 = ('| \\/ M anipulation | |');
line7 = ('\*---------------------------------------------------------------------------*/');
line8 = ('// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fileID = fopen('blockMeshDict.txt','wt');
fprintf(fileID,'%s\n',line1);
fprintf(fileID,'%s\n',line2);
fprintf(fileID,'%s\n',line3);
fprintf(fileID,'%s\n',line4);
fprintf(fileID,'%s\n',line5);
fprintf(fileID,'%s\n',line6);
fprintf(fileID,'%s\n',line7);
fprintf(fileID,'FoamFile\n{\n');
fprintf(fileID,'%16s \t 2.0;\n','version');
fprintf(fileID,'%16s \t ascii;\n','format');
fprintf(fileID,'%16s \t dictionary;\n','class');
fprintf(fileID,'%16s \t blockMeshDict;\n}\n','object');
fprintf(fileID,'%s\n\n',line8);
%vertices
fprintf(fileID,'convertToMeters 1;\n\n');
fprintf(fileID,'vertices\n(\n');
fprintf(fileID,'t(%d %d %d)\n',c0(1),c0(2),c0(3));
fprintf(fileID,'t(%d %d %d)\n',c1(1),c1(2),c1(3));
fprintf(fileID,'t(%d %d %d)\n',c2(1),c2(2),c2(3));
fprintf(fileID,'t(%d %d %d)\n',c3(1),c3(2),c3(3));
fprintf(fileID,'t(%d %d %d)\n',c4(1),c4(2),c4(3));
fprintf(fileID,'t(%d %d %d)\n);\n\n',c5(1),c5(2),c5(3));
fprintf(fileID,'blocks\n(\n');
fprintf(fileID,'t hex (0 0 1 2 3 3 4 5) (1 50 200) simplegrading (1 0.5 1)\n');
fprintf(fileID,');\n');
fprintf(fileID,'t arc 1 2 (%d %d %d)\n',0, R, 0);
fprintf(fileID,'t arc 4 5 (%d %d %d)\n',L, R, 0);
fprintf(fileID,');\n');
fprintf(fileID,'boundary\n(\n');
fprintf(fileID,'\t inflow\n');
fprintf(fileID,'\t {\n');
fprintf(fileID,'\t type patch;\n');
fprintf(fileID,'\t faces\n');
fprintf(fileID,'\t (\n');
fprintf(fileID,'\t\t (0 0 2 1)\n');
fprintf(fileID,'\t );\n');
fprintf(fileID,'\t }\n\n');
fprintf(fileID,'\t outflow\n');
fprintf(fileID,'\t {\n');
fprintf(fileID,'\t type patch ;\n');
fprintf(fileID,'\t faces\n');
fprintf(fileID,'\t (\n');
fprintf(fileID,'\t\t (3 4 5 3)\n');
fprintf(fileID,'\t );\n');
fprintf(fileID,'\t }\n');
fprintf(fileID,'\t pipe\n');
fprintf(fileID,'\t {\n');
fprintf(fileID,'\t type wall;\n');
fprintf(fileID,'\t faces\n');
fprintf(fileID,'\t (\n');
fprintf(fileID,'\t\t (4 1 2 5)\n');
fprintf(fileID,'\t );\n');
fprintf(fileID,'\t }\n');
fprintf(fileID,'\t wedgeback\n');
fprintf(fileID,'\t {\n');
fprintf(fileID,'\t type wedge;\n');
fprintf(fileID,'\t faces\n');
fprintf(fileID,'\t (\n');
fprintf(fileID,'\t\t (3 5 2 0)\n');
fprintf(fileID,'\t );\n');
fprintf(fileID,'\t }\n');
fprintf(fileID,'\t wedgefront\n');
fprintf(fileID,'\t {\n');
fprintf(fileID,'\t type wedge;\n');
fprintf(fileID,'\t faces\n');
fprintf(fileID,'\t (\n');
fprintf(fileID,'\t\t (0 1 4 3)\n');
fprintf(fileID,'\t );\n');
fprintf(fileID,'\t }\n');
fprintf(fileID,'\t axis\n');
fprintf(fileID,'\t (\n');
fprintf(fileID,'\t type empty;\n');
fprintf(fileID,'\t faces\n');
fprintf(fileID,'\t (\n');
fprintf(fileID,'\t\t (0 3 3 0)\n');
fprintf(fileID,'\t );\n');
fprintf(fileID,'\t }\n');
fprintf(fileID,'\t );\n');
fprintf(fileID,'mergePatchPairs\n');
fprintf(fileID,'(\n');
fprintf(fileID,');\n');
fprintf(fileID,'%s',line8);
fclose(fileID);
BlockMeshDict:
/*--------------------------------*- 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 dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000300 0.007500 0.000000)
(-0.000300 0.007500 0.000000)
(0.000000 0.000000 1.890000)
(0.000300 0.007500 1.890000)
(-0.000300 0.007500 1.890000)
);
blocks
(
hex (0 0 1 2 3 3 4 5) (1 50 200) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0.000000 0.005000 0.000000)
arc 4 5 (0.000000 0.005000 1.890000)
);
boundary
(
inflow
{
type patch;
faces
(
(0 0 1 2)
);
}
outflow
{
type patch;
faces
(
(3 4 5 3)
);
}
pipe
{
type wall;
faces
(
(4 1 2 5)
);
}
wedgeback
{
type wedge;
faces
(
(3 5 2 0)
);
}
wedgefront
{
type wedge;
faces
(
(0 1 4 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Pressure:
/*--------------------------------*- 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
{
inflow
{
type zeroGradient;
}
outflow
{
type fixedValue;
value uniform 0.029;
}
wedgefront
{
type wedge;
}
wedgeback
{
type wedge;
}
pipe
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Velocity:
/*--------------------------------*- 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
{
inflow
{
type fixedValue;
value uniform (0 0 0.125);
}
outflow
{
type zeroGradient;
}
pipe
{
type noSlip;
}
wedgefront
{
type wedge;
}
wedgeback
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //
controlDict:
/*--------------------------------*- 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 dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.01;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
plot at x=0.05 along Y-axis,U-max = 0.156055
plot at x=0.945 along Y-axis, U_max = 0.236774
plot at x=1.5 along Y-axis, U_max = 0.245738
plot at x=1.89 along Y-axis, U_max = 0.247027
plot at x= 1.5 along Y-axis, shear stress = 0.0491609
Conclusion:
There is a small difference between the analytical and theoritical values at 1.89 the max shear stress is 0.029317 analytically and 0.0296548 theoritically
U shear stress
Analytical 0.247027 0.029317
Theoritical 0.2499 0.296548