Week 11 - Simulation of Flow through a pipe in OpenFoam
HYDRODYNAMIC VALIDATION:
hydrodynamic entrance length:
For internal regime an entrance region is typical. In this region a nearly inviscid upstream flow converges and enters the tube. To characterize this region the hydrodynamic entrance length is introduced and is approximately equal to
The maximum hydrodynamic entrance length, at ReD,crit = 2300 (laminar flow), is Le = 138d, where D is the diameter of the pipe. This is the longest development length possible. In turbulent flow, the boundary layers grow faster, and Le is relatively shorter. For any given problem, Le / D has to be checked to see if Le is negligible when compared to the pipe length. At a finite distance from the entrance, the entrance effects may be neglected, because the boundary layers merge and the inviscid core disappears. The tube flow is then fully developed.
Formulas:
entry length: Le= 0.06*Re*D = 2.52 m
Total length L= Le+ 0.3 = 2.82 m
Average velocity = (mu*Re)/(rho*D) = 0.0937 m/s
Maximum velocity = 2*v_avg = 0.1875 m/s
pressure drop del_p = (8*mu*L*v_avg)/(r^2) = 18.8197 N/m^2
kinematic pressure drop = del_p/rho = 0.0189 m^2/s^2
Initial static pressure drop must be converted to kinematic pressure drop as the incompressible solver in OpenFOAM uses
kinematic pressure.
Matlab program

%11
clear all
close all
clc
rno=2100;
r=0.005;
d=2*r;
ang=4;
%dynamic viscosity
dv=0.1874;
%water density
rho=1000;
%kinematic viscosity
kv=dv/rho;
le=0.12*rno*r;
lt=le+0.25*le;
vavg=(rno*kv)/(2*rho);
vmax=2*vavg;
dp=(8*dv*vavg*lt)/r^2;
%kinematic pressure
pk=dp/rho;
k=linspace(-r,r,1000)
for i=1:length(k)
tu(i)=2*vmax*dv*(abs(k(i)))/r^2;
end
plot(k,tu,'b')
xlabel('radius')
ylabel('shear stress')
grid on
legend('post processed shear stress')
p0=[0 0 0]
p1=[0 r*cosd(ang/2) -r*sind(ang/2)]
p2=[0 r*cosd(ang/2) r*sind(ang/2)]
p3=[lt 0 0]
p4=[lt r*cosd(ang/2) -r*sind(ang/2)]
p5=[lt r*cosd(ang/2) r*sind(ang/2)]
f1=fopen('blockMeshDict.txt','w')
%creating blockMeshDict file in openFoam
l1='/*------------------------------------*-C++ -*---------------------------------*|';
l2='| ========= | |';
l3='| \\ /F ield | openFoam: The open source CFD toolbox|';
l4='| \\ / O operation | website: https://opemfoam.org |';
l5='| \\ / A nd | Version: 8 |';
l6='| \\/ M manipulation | |';
l7='\*-----------------------------------------------------------------------------*/';
l8='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
fprintf(f1,'%s\n',l1)
fprintf(f1,'%s\n',l2)
fprintf(f1,'%s\n',l3)
fprintf(f1,'%s\n',l4)
fprintf(f1,'%s\n',l5)
fprintf(f1,'%s\n',l6)
fprintf(f1,'%s\n \n',l7)
fprintf(f1,'FoamFile \n {\n')
fprintf(f1,'%16s %10s\n','version','2.0;')
fprintf(f1,'%16s %12s\n','format','ascii;')
fprintf(f1,'%16s %17s\n','class','dictionary;')
fprintf(f1,'%16s %20\n','object','blockMeshDict;')
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',p0)
fprintf(f1,'\t(%d %d %d)\n',p1)
fprintf(f1,'\t(%d %d %d)\n',p2)
fprintf(f1,'\t(%d %d %d)\n',p3)
fprintf(f1,'\t(%d %d %d)\n',p4)
fprintf(f1,'\t(%d %d %d)\n',p5)
fprintf(f1,' %2s\n\n', ');')
fprintf(f1,'blocks \n (\n')
fprintf(f1,' \t hex (0 3 5 2 0 3 4 1) (%d %d %d)',300,30,1)
fprintf(f1,' simpleGrading (1 0.1 1)\n\n')
fprintf(f1, ');\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 4 5',r)
fprintf(f1,' %2s\n\n', ');')
fprintf(f1,'boundary \n (\n')
fprintf(f1,'\t %5s \n','axis','{')
fprintf(f1,'\t %13s \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,' \t %5s \n','top','{')
fprintf(f1,'\t %13s \n','type','wall;')
fprintf(f1,'\t %14s \n%18s\n','faces','(')
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(1 4 5 2)',');','}')
fprintf(f1,' \t %5s \n','inlet','{')
fprintf(f1,'\t %13s \n','type','patch;')
fprintf(f1,'\t %14s \n%18s\n','faces','(')
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 1 2 0)',');','}')
fprintf(f1,' \t %5s \n','outlet','{')
fprintf(f1,'\t %13s \n','type','patch;')
fprintf(f1,'\t %14s \n%18s\n','faces','(')
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(3 5 4 3)',');','}')
fprintf(f1,' \t %5s \n','front','{')
fprintf(f1,'\t %13s \n','type','wedge;')
fprintf(f1,'\t %14s \n%18s\n','faces','(')
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 3 4 1)',');','}')
fprintf(f1,' \t %5s \n','back','{')
fprintf(f1,'\t %13s \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,'mergePatchPairs \n (\n );\n')
fprintf(f1,'%2s\n\n','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//')
fclose(f1)
OPENFOAM SOLVING;tut--->incompressible------>icoFoam solver------->cavity .then create a run folder to entry the geometry and modify blockMeshDict and initial and final conditions .
BLOCKMESHDICT
/*--------------------------------*- 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 4.999238e-03 8.726203e-05)
(0 4.999238e-03 -8.726203e-05)
(2 0 0)
(2 4.999238e-03 8.726203e-05)
(2 4.999238e-03 -8.726203e-05)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (300 30 1) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 5.000000e-03 0)
arc 4 5 (2 5.000000e-03 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
inlet
{
type patch;
faces
(
(0 0 2 1)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type wedge;
faces
(
(0 3 4 1)
);
}
back
{
type wedge;
faces
(
(0 2 5 3)
);
}
);
mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
);
// ************************************************************************* //
PRESSURE VARIATION
/*--------------------------------*- 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
{
axis
{
type empty;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0.10709;
}
wall
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
top
{
type zeroGradient;
}
}
// ************************************************************************* //
CONTROL DICT
/
*--------------------------------*- 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 8;
deltaT 4.4469e-04;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat 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.1874 0 0);
boundaryField
{
axis
{
type empty;
}
inlet
{
type fixedValue;
value uniform (0.1874 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
top
{
type fixedValue;
value uniform (0 0 0);
}
}
//**********************************************************************************************************************************************************//
TRANSPORT PROPERTIES
/*--------------------------------*- 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] 8.9267e-07;
// ************************************************************************* //
shear stress vs radius diagram:

geometry
wedged cross-sectional portion

velocityprofile at an instant

general mesh distribution

pressure distribution at an instant

plots
velocity along the length of the pipe

velocity over the period of time

pressure over the period of time


Results:
- From the above plots, it is clear that as the fluid enters the pipe with a constant velocity (x=0m) and progresses through the pipe, the velocity profile along the radial distance keeps changing.