Week 11 - Simulation of Flow through a pipe in OpenFoam
HYDRODYNAMIC ENTRANCE REGION :
The hydrodynamic entrance regio refers to the area of the pipe where the fluid enters and develops a velocity profile due to the viscous forces spreading from a pipe's interior wall. This region has a non uniform flow. The fluid enters a pipe at a constant speed, so the fluid particles in the layer in contact with pipe's sufarce come to a complete stop because of the no-slip condition. The layer in the contact with pipe surface is resistance to the acceleration of the neighbouring layer due to the viscous forces with in the fluid and slowly slow down adjacent layer of the fluid, creating a velocity profile. To keep th e mass true, the speed of the fluid layer in the centre of the pipe increase to compensate for the reduced speed of hte fluid layer near the surface of the pipe. it creates a gradient of the velocity across the pipe cross section.
HAGEN POISEULLIE'S LAW AND CONSIDERATIONS :

MATHLAB CODE :
close all
clear all
clc
Re=2100;
rho=1000;
d=0.002;
r=d/2;
l_in=0.06*Re*d;
mu=0.00089;
nu=mu/rho;
theta=3;
v_avg=Re*nu/d;
l=l_in+0.03;
delp=(8*v_avg*mu*l)/r^2;
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)];
b1=200;
b2=20;
b3=1;
grading=0.2;
h1='/*--------------------------------*- C++ -*----------------------------------*\';
h2=' ========= ';
h3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox';
h4=' \\ / O peration | Website: https://openfoam.org';
h5=' \\ / A nd | Version: 8';
h6=' \\/ M anipulation |';
h7='\*---------------------------------------------------------------------------*/';
h8=' version 2.0';
h9=' format ascii';
h10=' class dictionary';
h11=' object blockMeshDict';
h12='// ************************************************************************* //';
f1=fopen('blockMeshDict.txt','wt');
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 \n',h7);
fprintf(f1,'FoamFile \n {\n ');
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'%s\n',h10);
fprintf(f1,'%s\n',h11);
fprintf(f1,'%2s\n','}');
fprintf(f1,'%2s\n\n','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f1,'%2s\n\n','convertToMeters 1;');
fprintf(f1,'vertices \n (\n ');
fprintf(f1,'\t(%d %d %d)\n',v0);
fprintf(f1,'\t(%d %d %d)\n',v1);
fprintf(f1,'\t(%d %d %d)\n',v2);
fprintf(f1,'\t(%d %d %d)\n',v3);
fprintf(f1,'\t(%d %d %d)\n',v4);
fprintf(f1,'\t(%d %d %d)\n',v5);
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'blocks \n (\n ');
fprintf(f1,'\t %s (%d %d %d %d %d %d %d %d) (%d %d %d) %s (%d 1 1) \n','hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (0.2 1 1)');
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'edges \n (\n ');
fprintf(f1,'\t %s (0 %d 0)\n','arc 1 2',r);
fprintf(f1,'\t %s (%d %d 0)\n','arc 1 2',l,r);
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'boundary \n (\n ');
fprintf(f1,'\t %5s \n','inlet','{');
fprintf(f1,'\t %13s %s\n','type','patch;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 0 2 1)',');','}');
fprintf(f1,'\t %5s \n','outlet','{');
fprintf(f1,'\t %13s %s\n','type','patch;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(3 4 5 3)',');','}');
fprintf(f1,'\t %5s \n','frontwedge','{');
fprintf(f1,'\t %13s %s\n','type','wedge;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 1 4 3)',');','}');
fprintf(f1,'\t %5s \n','backwedge','{');
fprintf(f1,'\t %13s %s\n','type','wedge;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 2 5 3)',');','}');
fprintf(f1,'\t %5s \n','wall','{');
fprintf(f1,'\t %13s %s\n','type','wall;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(2 1 4 5)',');','}');
fprintf(f1,'\t %5s \n','axis','{');
fprintf(f1,'\t %13s %s\n','type','empty;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 3 3 0)',');','}');
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'mergePatchPairs \n (\n );\n');
fprintf(f1,'%2s\n\n',h12);
fclose(f1);
BLOCKMESHDICT CODE :
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 9.99e-3 2.61e-4)
(0 9.99e-3 -2.61e-4)
(2.82e+0 0 0)
(2.82e+0 9.99e-3 2.61e-4)
(2.82e+0 9.99e-3 -2.61e-4)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 0.01e+0 0)
arc 4 5 (2.82e+0 0.01e+0 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 0 2 1)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
frontwedge
{
type wedge;
faces
(
(0 1 4 3)
);
}
backwedge
{
type wedge;
faces
(
(0 2 5 3)
);
}
wall
{
type wall;
faces
(
(2 1 4 5)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
CONTROLDICT CODE :
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 50;
deltaT 0.01;
writeControl timeStep;
writeInterval 200;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
TRNSPORTPROPERTIES CODE :
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.89e-6;
// ************************************************************************* //
PRESSURE CODE :
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ 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;
}
outlet
{
type fixedValue;
value uniform 0.018;
}
frontwedge
{
type wedge;
}
backwedge
{
type wedge;
}
Topwall
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
VELOCITY CODE :
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0.09345 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.09345 0 0);
}
outlet
{
type zeroGradient;
}
frontwedge
{
type wedge;
}
backwedge
{
type wedge;
}
Topwall
{
type fixedValue;
value uniform (0 0 0);
}
axis
{
type empty;
}
}
// ************************************************************************* //
BLOCKMESH :


PIPE FLOW :


GRAPHS OF VELOCITY PROFILE AT DIFFERENT LENGTH :




SHEAR STRESS GRAPH :

MATHLAB CODE FOR SHEAR STRESS (ANALYTICAL) :
close all
clear all
clc
Re=2100;
rho=1000;
d=0.02;
r=d/2;
R=linspace(0,0.01,1000)
l_in=0.06*Re*d;
mu=0.00089;
nu=mu/rho;
v_avg=Re*nu/d;
l=l_in+0.03;
delp=(8*v_avg*mu*l)/r^2;
U_max=2*v_avg;
for i=1:length(R)
tau(i)=(2*U_max*mu*abs(R(i)))/(r^2);
endfor
figure 1
plot(R,tau)
xlabel('radial distance in m');
ylabel('shear stress(tau) in N/m^2');
title(sprintf('change in shear stress in fully developed flow at x=2.82m with radial distance'));
GRAPH FOR SHEAR STRESS USING MATLAB :

CONCLUSION :
- When the fluid is in motion, the shear stress developed due to the particles in the fluid moving relative to another one.
- For the fluid flowig in the pipe the velocity will be zero near the walls, and maximum at the centre.
- The shear stress will increase with radial distance increase.
- The velocity profile is parabolic after the entrance length.
- Pressure shows constant slope after the entrance.
- If 'mu' is constant then the shear stress is linearly dependant on the velocity gradient.