Simulation of Flow through a pipe in OpenFoam Part - 2
Objective:
To compare the results obtained from solving Hagen-Poisuielle\'s equation, Simulation results obtained by using Symmetry Boundary condition (Wedge angle= 10, 25 and 45 degrees), Simulation results obtained by using Wedge Boundary Condition (Less than 5-degree wedge angle).
Introduction:
In this challenge, the wedge boundary condition is used to reduce computational time. Applying wedge boundary condition is simple, just replace the symmetry by the wedge in blockMeshDict file, Velocity, and Pressure boundary condition files. In wedge type boundary condition, the wedge angle should be below 5-degree.
Matlab code for creating blockMeshDict file for various wedge angle:
clear all
close all
clc
D=0.02;%Diameter of the pipe
R=D/2; %Radius of the pipe
Re=2100; %Given Reynolds number
L_E=0.06*Re*D;%Entrance length
L=0.3+L_E; %Total length of the pipe
nu=0.0000010023; %Kinematic viscosity of water at 20 deg. Cel.
u=(nu*Re)/(D);
prompt = \'Wedge angle(the value should be less than 5degree)=\';
theta=input(prompt);
prompt= \'Mesh Grading Factor=\';
g_s=input(prompt);
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)];
f1=fopen(\'blockMeshDict.txt\',\'w\');
fprintf(f1,\'%s\\n\',\'/*--------------------------------*- C++ -*----------------------------------*\\\\\');
fprintf(f1,\'%s\\n\',\' ========= |\');
fprintf(f1,\'%s\\n\',\' \\\\\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox\');
fprintf(f1,\'%s\\n\',\' \\\\\\\\ / O peration | Website: https://openfoam.org\');
fprintf(f1,\'%s\\n\',\' \\\\\\\\ / A nd | Version: 6\');
fprintf(f1,\'%s\\n\',\' \\\\\\\\/ M anipulation |\');
fprintf(f1,\'%s\\n\',\'\\\\*---------------------------------------------------------------------------*/\');
fprintf(f1,\'%s\\n\',\'FoamFile\');
fprintf(f1,\'%s\\n\',\'{\');
fprintf(f1,\'%s\\n\',\' version 2.0;\');
fprintf(f1,\'%s\\n\',\' format ascii;\');
fprintf(f1,\'%s\\n\',\' class dictionary;\');
fprintf(f1,\'%s\\n\',\' object blockMeshDict;\');
fprintf(f1,\'%s\\n\',\'}\');
fprintf(f1,\'%s\\n\\n\',\'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\');
fprintf(f1,\'%s\\n\\n\',\'convertToMeters 1;\');
fprintf(f1,\'vertices\\n(\\n\');
fprintf(f1,\'\\t(%d %d %d)\\n\',v0(1),v0(2),v0(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v1(1),v1(2),v1(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v2(1),v2(2),v2(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v3(1),v3(2),v3(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v4(1),v4(2),v4(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v5(1),v5(2),v5(3));
fprintf(f1,\');\\n\\nblocks\\n(\\n\');
fprintf(f1,\'\\thex (0 3 4 1 0 3 5 2) (200 50 1) simpleGrading (1 %d 1)\\n\',g_s);
fprintf(f1,\');\\n\\nedges\\n(\\n\');
fprintf(f1,\'\\tarc %d %d (%d %d %d)\\n\',1,2,0,R,0);
fprintf(f1,\'\\tarc %d %d (%d %d %d)\\n\',4,5,L,R,0);
fprintf(f1,\');\\n\\n\');
fprintf(f1,\'boundary\\n(\\n\');
fprintf(f1,\'\\tinlet\\n\\t{\\n\');
fprintf(f1,\'\\t\\ttype patch;\\n\');
fprintf(f1,\'\\t\\tfaces\\n\\t\\t(\\n\');
fprintf(f1,\'\\t\\t\\t(0 2 1 0)\\n\');
fprintf(f1,\'\\t\\t);\\n\\t}\\n\');
fprintf(f1,\'\\toutlet\\n\\t{\\n\');
fprintf(f1,\'\\t\\ttype patch;\\n\');
fprintf(f1,\'\\t\\tfaces\\n\\t\\t(\\n\');
fprintf(f1,\'\\t\\t\\t(3 4 5 3)\\n\');
fprintf(f1,\'\\t\\t);\\n\\t}\\n\');
fprintf(f1,\'\\tfront\\n\\t{\\n\');
fprintf(f1,\'\\t\\ttype symmetry;\\n\');
fprintf(f1,\'\\t\\tfaces\\n\\t\\t(\\n\');
fprintf(f1,\'\\t\\t\\t(0 3 5 2)\\n\');
fprintf(f1,\'\\t\\t);\\n\\t}\\n\');
fprintf(f1,\'\\tback\\n\\t{\\n\');
fprintf(f1,\'\\t\\ttype symmetry;\\n\');
fprintf(f1,\'\\t\\tfaces\\n\\t\\t(\\n\');
fprintf(f1,\'\\t\\t\\t(0 1 4 3)\\n\');
fprintf(f1,\'\\t\\t);\\n\\t}\\n\');
fprintf(f1,\'\\ttop\\n\\t{\\n\');
fprintf(f1,\'\\t\\ttype wall;\\n\');
fprintf(f1,\'\\t\\tfaces\\n\\t\\t(\\n\');
fprintf(f1,\'\\t\\t\\t(1 2 5 4)\\n\');
fprintf(f1,\'\\t\\t);\\n\\t}\\n\');
fprintf(f1,\'\\taxis\\n\\t{\\n\');
fprintf(f1,\'\\t\\ttype empty;\\n\');
fprintf(f1,\'\\t\\tfaces\\n\\t\\t(\\n\');
fprintf(f1,\'\\t\\t\\t(0 3 3 0)\\n\');
fprintf(f1,\'\\t\\t);\\n\\t}\\n\');
fprintf(f1,\');\\n\\n\');
fprintf(f1,\'mergePatchPairs\\n(\\n);\\n\\n\');
fprintf(f1,\'// ************************************************************************* //\');
fclose(f1);
BlockMeshDict file for Wedge boundary condition:
/*--------------------------------*- C++ -*----------------------------------*\\\\
========= |
\\\\\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\\\\\ / O peration | Website: https://openfoam.org
\\\\\\\\ / A nd | Version: 6
\\\\\\\\/ M anipulation |
\\\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0 9.993908e-03 -3.489950e-04)
(0 9.993908e-03 3.489950e-04)
(2.820000e+00 0 0)
(2.820000e+00 9.993908e-03 -3.489950e-04)
(2.820000e+00 9.993908e-03 3.489950e-04)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0 1.000000e-02 0)
arc 4 5 (2.820000e+00 1.000000e-02 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type wedge;
faces
(
(0 3 5 2)
);
}
back
{
type wedge;
faces
(
(0 1 4 3)
);
}
top
{
type wall;
faces
(
(1 2 5 4)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Transport properties file:
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location \"constant\";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.0000010023;
// ************************************************************************* //
ControlDict file:
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ 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;
// ************************************************************************* //
Boundary conditions:
Velocity file for wedge boundary condition:
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ 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.1052 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
top
{
type noSlip;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Pressure file for wedge boundary condition:
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ 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 wedge;
}
back
{
type wedge;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Results:
1) Outlet velocity profile (wedge angle=10-degree in symmetry BC)
2) Outlet velocity profile (wedge angle=25-degree in symmetry BC)
3) Outlet velocity profile (wedge angle=45-degree in symmetry BC)
4) Outlet velocity profile (wedge angle=4-degree in Wedge BC)
5) Velocity Profile (wedge angle=10-degree in symmetry BC)
6) Velocity Profile (wedge angle=25-degree in symmetry BC)
7) Velocity Profile (wedge angle=45-degree in symmetry BC)
8) Velocity Profile (wedge angle=4-degree in Wedge BC)
9)
| Wedge BC | Symmetry BC 10 | Symmetry BC 25 | Symmetry BC 45 | |
| Execution time | 178.27 s | 235.65 s | 217.26 s | 200.65 s |
| u_max | 0.2093 m/s | 0.2093 m/s | 0.2095 m/s | 0.2098 m/s |
| Error % (u_max) | 0.52% | 0.52% | 0.43% | 0.28% |
| Pressure drop | 1.70196 N/m^2 | 1.712 N/m^2 | 1.7803 N/m^2 | 1.9819 N/m^2 |
| Error % (∆P) | 1.06% | 1.66% | 5.71% | 17.6% |
Inferences:
1) From the above table, it was noted that using Wedge Boundary condition instead of symmetry Boundary condition saves execution time.
2) Wedge Boundary condition has a minimum error while calculating the maximum velocity and Pressure drop than Symmetry Boundary condition.
3) Error percentage of maximum velocity decreases while increasing the wedge angle in the symmetry boundary condition.
4) Error percentage of Pressure drop increases while increasing the wedge angle in the symmetry boundary condition.
5) From the above results of the velocity profile, the parabolic curves are attained in all wedge angles.