Week 11 - Simulation of Flow through a pipe in OpenFoam
AIM-:The Hagen-Poiseuille equation describes the parabolic velocity profile of frictional, laminar pipe flows of incompressible, Newtonian fluids. from the Hagen-Poiseuille equation, we simulating pipe flow using OpenFOAM with Matlab. In this CFD problem, we use water as a fluid at room temperature. The flow is laminar in nature. For this condition, we use the icoFoam solver in OpenFOAM to solve the case.
Hagen-Poiseuille Flow-:
The flow of fluids through pipes is of great importance in many cases in nature and technology. In the chemical industry, for example, one often has to deal with liquids that are transported through pipes. Especially when it comes to the correct mixing of reaction partners, the volume flow rate supplied plays a major role. It is of central importance to determine the flow rate on the basis of the pressure generated by the pump and the pipe diameter.
Flows are basically caused by pressure differences which push the fluid from points of higher pressure to points of lower pressure. A permanently decreasing pressure is thus formed along the pipe in the direction of flow. The greater this pressure drop over a certain length of the pipe, the faster the fluid flows through the pipe, and the greater the flow rate. The drive for a flow is thus a pressure gradient dp/dx,i.e. the pressure drop per unit length.
This drive is counteracted by frictional forces of the fluid, which act both between fluid and pipe and within the fluid itself. They are caused by the viscosity of the fluid.
Laminar flows in pipes can be described mathematically on the basis of both forces, pressure forces as drive and friction forces as resistance. In the following, both the velocity profile and the volume flow rate of such a frictional pipe flow will be derived.
blockMeshDict using matlab-:
clear all
close all
clc
x1='/*--------------------------------*- C++ -*----------------------------------*';
x2='| ========= | |';
x3='| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |';
x4='| \ / O peration | Version: 4.0 |';
x5='| \ / A nd | Website: https://openfoam.org |';
x6='| \/ M anipulation | |';
x7='*----------------------------------------------------------------------------*/';
x8='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
D=0.02;
R=D/2;
theta=2;
Re=2100;
L_hydrodynamic=0.06*Re*D;
L_pipe=L_hydrodynamic + 0.4;
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_pipe 0 0];
v4=[L_pipe R*cosd(theta/2)-R*sind(theta/2)];
v5=[L_pipe R*cosd(theta/2) R*sind(theta/2)];
nx=20;
ny=1;
nz=300;
gx=0.2;
gy=1;
gz=1;
f1=fopen('blockMeshDict,txt','w');
fprintf(f1,'%sn',x1);
fprintf(f1,'%sn',x2);
fprintf(f1,'%sn',x3);
fprintf(f1,'%sn',x4);
fprintf(f1,'%sn',x5);
fprintf(f1,'%sn',x6);
fprintf(f1,'%sn',x7);
fprintf(f1,'FoamFilen');
fprintf(f1,'{n');
fprintf(f1,'%16sn %fn','version 2.0;');
fprintf(f1,'%16sn %12sn','format ascii;');
fprintf(f1,'%16sn %17sn','class dictionary;');
fprintf(f1,'%16sn %20sn','object blockMeshDict;');
fprintf(f1,'}n');
fprintf(f1,x8);
fprintf(f1,'nn');
fprintf(f1,'%snn %fnn','convertToMeters 1;');
fprintf(f1,'verticesn(n');
fprintf(f1,'(%d %d %d)n',v0);
fprintf(f1,'(%d %d %d)n',v1);
fprintf(f1,'(%d %d %d)n',v2);
fprintf(f1,'(%d %d %d)n',v3);
fprintf(f1,'(%d %d %d)n',v4);
fprintf(f1,'(%d %d %d)n);nn',v5);
fprintf(f1,'blocksn(n');
fprintf(f1,'%20s (%d %d %d) %s (%d %d %d)n','hex (0 1 2 0 3 4 5 3)','nx,ny,nz','simpleGrading', gx,gy,gz);
fprintf(f1,');nn');
fprintf(f1, '%sn','edges');
fprintf(f1,');nn');
fprintf(f1, '%sn','boundary');
fprintf(f1,'(n');
fprintf(f1, '%10sn','inlet');
fprintf(f1,'%6sn','{');
fprintf(f1, '%18sn %18sn','type patch');
fprintf(f1,'%11sn','faces');
fprintf(f1, '%8sn','(');
fprintf(f1, '%20sn','(0 2 1 0)');
fprintf(f1, '%9sn',');');
fprintf(f1, '%6sn','}');
fprintf(f1, '%11sn','outlet');
fprintf(f1,'%6sn','{');
fprintf(f1, '%18sn %18sn','type patch');
fprintf(f1,'%11sn','faces');
fprintf(f1, '%8sn','(');
fprintf(f1, '%20sn','(3 4 5 3)');
fprintf(f1, '%9sn',');');
fprintf(f1, '%6sn','}');
fprintf(f1, '%15sn','FrontWedge');
fprintf(f1,'%6sn','{');
fprintf(f1, '%18sn %18sn','type wedge');
fprintf(f1,'%11sn','faces');
fprintf(f1, '%8sn','(');
fprintf(f1, '%20sn','(0 3 5 2)');
fprintf(f1, '%9sn',');');
fprintf(f1, '%6sn','}');
fprintf(f1, '%14sn','BackWedge');
fprintf(f1,'%6sn','{');
fprintf(f1, '%18sn %18sn','type wedge;');
fprintf(f1,'%11sn','faces');
fprintf(f1, '%8sn','(');
fprintf(f1, '%20sn','(0 1 4 3)');
fprintf(f1, '%9sn',');');
fprintf(f1, '%6sn','}');
fprintf(f1, '%16sn','noslipwalls');
fprintf(f1,'%6sn','{');
fprintf(f1, '%18sn %18sn','type wall;');
fprintf(f1,'%11sn','faces');
fprintf(f1,'%8sn','(');
fprintf(f1, '%20sn','(1 2 5 4)');
fprintf(f1, '%9sn',');');
fprintf(f1, '%6sn','}');
fprintf(f1,');nn');
fprintf(f1,'%sn','mergePatchPairs');
fprintf(f1,'(n');
fprintf(f1,');nn');
fprintf(f1,x8);
fclose(f1)
Transportproperties file-:
/*--------------------------------*- 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 transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.9025e-6;
// ************************************************************************* //
ControlDict File-:
/*--------------------------------*- 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 transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFoam startTime;
startTime 0;
stopAt endTime;
endTime 20;
deltaT 0.01;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormate general;
TimePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Velocity-:
/*--------------------------------*- 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.0947625 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.0947625 0 0);
}
outlet
{
type zeroGradient;
}
FrontWedge
{
type wedge;
}
BackWedge
{
type wedge;
}
noslipwalls
{
type noSlip;
}
}
// ************************************************************************* //
Pressure-:
/*--------------------------------*- 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;
}
FrontWedge
{
type wedge;
}
BackWedge
{
type wedge;
}
noslipwalls
{
type zeroGradient;
}
}
// ************************************************************************* //
Result-:
The velocity of flow

shear stress of the flow

Conclusion-:
as per simulation, we see that the velocity of the profile can be observed after 2m from the inlet. velocity at the center of the pipe is maxed and near the edges it is minimum.
for shear, we see that the at the center of the pipe is a min and near the edges is max because of the friction of the wall.