Phil Dias Wedge Pipe Flow
Introduction:
This challenge simulates flow through a pipe using OpenFOAM. A wedge method is used to reduce computational time. Ocatve was used to generate the computational mesh for any wedge angle and grading scheme.
- Working fluid: Water @ 25C
- Reynold\'s Number: Re = 2100; Laminar
- Kinematic viscosity: 8.917e-7 m^2/s
- Pipe Diameter: 1 in
- Entrance Length: Le = 0.06* Re* D
- Density of Water: 1000 kg/m^3
- Length to fully developed flow: L = Le + 0.3
since, `Re = (V*rho*D)/(mu)`
Therefore; V = 0.0738 m/s
Hagen-Poiseuille Equation:
`DeltaP = - (8*mu*L)/(R^2) U`
Octave Code:
clear all
close all
clc
% Diameter (1\" pipe)
D = 0.0254;
R = D/2;
% Reynold\'s Number
Re = 2100;
% Entrance Length
Le = 0.06*Re*D;
% Total Length
L = 0.3 + Le;
% Assumed wedge angle
theta = 4;
% Kinematic Viscosity of water @ 25C
nu = 8.917e-07;
% Inlet Velocity
u = (nu*Re)/D;
% Vertices
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)];
% Blockmesh File
f1 = fopen(\'blockMeshDict.txt\',\'w\');
fprintf(f1,\'%s \\r\\n\', \'\\*------------------------------------------*/\');
fprintf(f1, \' \\r\\n\');
fprintf(f1, \'FoamFile \\r\\n{ \\r\\n\');
fprintf(f1, \'%16s %10s\\t 2.0; \\r\\n\', \'version\');
fprintf(f1, \'%12s \\t ascii; \\r\\n\', \'format\');
fprintf(f1, \'%11s \\t directory; \\r\\n\', \'class\');
fprintf(f1, \'12s \\t blockMeshDict;\\r\\n}\\r\\n\' , \'object\');
fprintf(f1, \'%s \\r\\n\', \'//************************************//\');
fprintf(f1, \'convertToMeters 1; \\r\\n\\r\\n\');
fprintf(f1, \'vertices\\r\\n(\\r\\n\');
fprintf(f1, \'\\t(%d %d %d)\\r\\n\', v0(1),v0(2),v0(3));
fprintf(f1, \'\\t(%d %d %d)\\r\\n\', v1(1),v1(2),v1(3));
fprintf(f1, \'\\t(%d %d %d)\\r\\n\', v2(1),v2(2),v2(3));
fprintf(f1, \'\\t(%d %d %d)\\r\\n\', v3(1),v3(2),v3(3));
fprintf(f1, \'\\t(%d %d %d)\\r\\n\', v4(1),v4(2),v4(3));
fprintf(f1, \'\\t(%d %d %d)\\r\\n\', v5(1),v5(2),v5(3));
fprintf(f1, \');\\r\\n\\r\\n\');
fprintf(f1, \'blocks\\r\\n(\\r\\n\');
fprintf(f1, \'\\thex (0 3 4 1 0 3 5 2) (200 50 1)\');
fprintf(f1, \' simpleGrading (%d %d %d)\\r\\n\', 1,0.5,1);
fprintf(f1, \');\\r\\n\');
fprintf(f1, \'edges\\r\\n\\t(\\r\\n\');
fprintf(f1, \'\\t\\t arc %d %d (%d %d %d)\\r\\n\', 1,2,0,R,0);
fprintf(f1, \'\\t\\t arc %d %d (%d %d %d)\\r\\n\', 4,5,L,R,0);
fprintf(f1, \'\\t);\\r\\n\');
fprintf(f1, \'boundary\\r\\n(\\r\\n\');
% assign boundary conditions
fprintf(f1, \'\\tinlet\\r\\n\\t{\\r\\n\');
fprintf(f1, \'\\t\\ttype patch;\\r\\n\');
fprintf(f1, \'\\t\\tfaces\\r\\n\\t\\t(\\r\\n\');
fprintf(f1, \'\\t\\t\\t(0 2 1 0)\\r\\n\');
fprintf(f1, \'\\t\\t);\\r\\n\\t}\\r\\n\');
fprintf(f1, \'\\toutlet\\r\\n\\t{\\r\\n\');
fprintf(f1, \'\\t\\ttype patch;\\r\\n\');
fprintf(f1, \'\\t\\tfaces\\r\\n\\t\\t(\\r\\n\');
fprintf(f1, \'\\t\\t\\t(3 4 5 3)\\r\\n\');
fprintf(f1, \'\\t\\t);\\r\\n\\t}\\r\\n\');
fprintf(f1, \'\\tfront\\r\\n\\t{\\r\\n\');
fprintf(f1, \'\\t\\ttype symmetry;\\r\\n\');
fprintf(f1, \'\\t\\tfaces\\r\\n\\t\\t(\\r\\n\');
fprintf(f1, \'\\t\\t\\t(0 3 5 2)\\r\\n\');
fprintf(f1, \'\\t\\t);\\r\\n\\t}\\r\\n\');
fprintf(f1, \'\\tback\\r\\n\\t{\\r\\n\');
fprintf(f1, \'\\t\\ttype symmetry;\\r\\n\');
fprintf(f1, \'\\t\\tfaces\\r\\n\\t\\t(\\r\\n\');
fprintf(f1, \'\\t\\t\\t(0 1 4 3)\\r\\n\');
fprintf(f1, \'\\t\\t);\\r\\n\\t}\\r\\n\');
fprintf(f1, \'\\ttop\\r\\n\\t{\\r\\n\');
fprintf(f1, \'\\t\\ttype wall;\\r\\n\');
fprintf(f1, \'\\t\\tfaces\\r\\n\\t\\t(\\r\\n\');
fprintf(f1, \'\\t\\t\\t(1 2 5 4)\\r\\n\');
fprintf(f1, \'\\t\\t);\\r\\n\\t}\\r\\n\');
fprintf(f1, \'\\taxis\\r\\n\\t{\\r\\n\');
fprintf(f1, \'\\t\\ttype empty;\\r\\n\');
fprintf(f1, \'\\t\\tfaces\\r\\n\\t\\t(\\r\\n\');
fprintf(f1, \'\\t\\t\\t(0 3 3 0)\\r\\n\');
fprintf(f1, \'\\t\\t);\\r\\n\\t}\\r\\n\');
fprintf(f1, \');\\r\\n\\r\\n\');
fprintf(f1, \'mergePatchPairs\\r\\n\\r\\n(\\r\\n);\');
fprintf(f1, \'// ************************************************** //\');
fclose(f1);
OpenFoam:
blockMesh Dict:
/*--------------------------------*- 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 0 0)
(0 0.0126923 -0.000443224)
(0 0.0126923 0.000443224)
(3.5004 0 0)
(3.5004 0.0126923 -0.000443224)
(3.5004 0.0126923 0.000443224)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0 0.0127 0)
arc 4 5 (3.5004 0.0127 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
top
{
type wall;
faces
(
(1 2 5 4)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
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 20;
deltaT 0.01;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
transportProperties:
/*--------------------------------*- 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 \"constant\";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 8.917e-07;
// ************************************************************************* //
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
{
inlet
{
type fixedValue;
value uniform (0.073723 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
wall
{
type noSlip;
}
axis
{
type empty;
}
}
// ************************************************************************* //
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
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
wall
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Results:
The theoretical results are similar to the simulation results. For velocity, the theoretical and simulated results are 0.2104 m/s and 0.20877 m/s. For shear stress, the theoretical and simulated results are 4.21 Pa and 4.177 Pa. Both results show a percent error of less than 0.8%.
Conclusion:
It is deduced from the parabolic curve that the flow becomes fully developed after the entrance lenth. The theoretical results calculated using the Hagen-Poiseuille equation are near the results from the simulation.