Symmetry vs Wedge vs HP equation
This project is a part of the course- Introduction to CFD using MATLAB and OpenFOAM
This is a continuation of the previous theoretical project where we studied the Hagen-Poiseuille's equation, simulated laminar flow of an incompressible fluid through wedge-shaped pipe section and compared the analytical and observed values. In this part of the project, we will use the symmetry boundary conditions instead of wedge boundary conditions.
Procedure:
Like in the previous case, blockMeshDict file was generated using MATLAB for angles of 10, 25 and 45 degrees. The cavity file under the incompressible and laminar flows was used and the slover used was icoFoam, like in the previous project.
The test conditions and input parameters have been mentioned in the previous section of the project along with analytical calculations.
MATLAB Code:
clear all
close all
clc
%Data for flow analysis%
RN = 2100; %Reynold's number value%
rho = input('Enter density: \t'); %Taking user input for density%
mu = input('Enter dynamic viscosity: \t'); %Taking user input for dynamic viscosity%
d = input('Enter pipe diameter (m): \t'); %Taking user input for diameter%
theta = input('Enter wedge angle: \t'); %Taking user input for wedge angle%
l_entry = d*(0.06*RN); %Entry length of the pipe%
l = 0.5+l_entry; %Actual length of the pipe%
%Boundary Conditions%
v_avg = (RN*mu)/(rho*l); %Average velocity calculation%
v_max = 2*v_avg; %Maximum value of velocity%
dp = (32*v_avg*mu*l)/(d)^2;
nu = mu/rho; %Kinematic viscosity%
%Wedge Geometry%
v_0 = [0 0 0];
v_1 = [0 d/2*cosd(theta/2) -d/2*sind(theta/2)];
v_2 = [0 d/2*cosd(theta/2) d/2*sind(theta/2)];
v_3 = [l 0 0];
v_4 = [l d/2*cosd(theta/2) -d/2*sind(theta/2)];
v_5 = [l d/2*cosd(theta/2) d/2*sind(theta/2)];
%Format of blockMeshDict file%
line1='|/*----------------------------------------c++----------------------------------------*\|';
line2='| ========= \|';
line3='| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \|';
line4='| \\ / O peration | Website: https://openfoam.org \|';
line5='| \\ / A nd | Version: 7 \|';
line6='| \\/ M anipulation | \|';
line7='|\*-----------------------------------------------------------------------------------*/|';
line8='FoamFile ';
line9=' { ';
%Using Parsing technique to create blockMeshDict file%
f1=fopen('blockMeshDict_SymmVSwedge_45.txt','w')
fprintf(f1,'%s\n',line1);
fprintf(f1,'%s\n',line2);
fprintf(f1,'%s\n',line3);
fprintf(f1,'%s\n',line4);
fprintf(f1,'%s\n',line5);
fprintf(f1,'%s\n',line6);
fprintf(f1,'%s\n',line7);
fprintf(f1,'\n');
fprintf(f1,'%s\n',line8);
fprintf(f1,'%s\n\n',line9);
fprintf(f1,'%16s %10s \n','version','2.0; ');
fprintf(f1,'%16s %10s \n','format' ,'ascii; ');
fprintf(f1,'%16s %10s \n','class' ,'dictionary; ');
fprintf(f1,'%16s %10s \n','object' ,'blockMeshDict; ');
fprintf(f1,'\n } \n\n');
fprintf(f1,'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//\n');
fprintf(f1,' convertToMeters 1\n\n');
%Defining Geometry%
fprintf(f1,'\t\tvertices \n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%f %f %f)\n',v_0);
fprintf(f1,'\t\t\t(%f %f %f)\n',v_1);
fprintf(f1,'\t\t\t(%f %f %f)\n',v_2);
fprintf(f1,'\t\t\t(%f %f %f)\n',v_3);
fprintf(f1,'\t\t\t(%f %f %f)\n',v_4);
fprintf(f1,'\t\t\t(%f %f %f)\n',v_5);
fprintf(f1,'\t\t);\n\n');
fprintf(f1,'\t\tblocks \n');
fprintf(f1,'\t\t( \n');
fprintf(f1,'\t\t\t hex (0 1 2 0 3 4 5 3) (100 1 50) simpleGrading (1 1 1)\n\t\t); \n \n');
%Defining Sides of Geometry%
%Edge of Pipe%
fprintf(f1,'\t\tedges \n');
fprintf(f1,'\t\t( \n ');
fprintf(f1,'\t\t\tarc 1 2 (%f %f %f) \n',0,d/2,0);
fprintf(f1,'\t\t\tarc 4 5 (%f %f %f) \n',l,d/2,0);
fprintf(f1,' \t\t); \n\n');
%Defining Boundary of pipe%
fprintf(f1,' \t\tboundary\n\t\t(\n');
%Inlet Section%
fprintf(f1,'%16s\n','inlet');
fprintf(f1,'%10s\n','{');
fprintf(f1,'%25s\n','type patch;');
fprintf(f1,'%19s\n','faces');
fprintf(f1,'%15s\n','(');
fprintf(f1,'%28s\n','(0 1 2 0)');
fprintf(f1,'%16s\n',');');
fprintf(f1,'%10s\n','}');
fprintf(f1,'\n');
%Outlet Section%
fprintf(f1,'%15s\n','outlet');
fprintf(f1,'%10s\n','{');
fprintf(f1,'%25s\n','type patch;');
fprintf(f1,'%19s\n','faces');
fprintf(f1,'%15s\n','(');
fprintf(f1,'%28s\n','(3 4 5 3)');
fprintf(f1,'%16s\n',');');
fprintf(f1,'%10s\n','}');
fprintf(f1,'\n');
%Front Side of Pipe%
fprintf(f1,'%13s\n','front');
fprintf(f1,'%10s\n','{');
fprintf(f1,'%25s\n','type symmetry;');
fprintf(f1,'%19s\n','faces');
fprintf(f1,'%15s\n','(');
fprintf(f1,'%28s\n','(0 2 5 3)');
fprintf(f1,'%16s\n',');');
fprintf(f1,'%10s\n','}');
fprintf(f1,'\n');
%Back Side of Pipe%
fprintf(f1,'%13s\n','back');
fprintf(f1,'%10s\n','{');
fprintf(f1,'%25s\n','type symmetry;');
fprintf(f1,'%19s\n','faces');
fprintf(f1,'%15s\n','(');
fprintf(f1,'%28s\n','(0 3 4 1)');
fprintf(f1,'%16s\n',');');
fprintf(f1,'%10s\n','}');
fprintf(f1,'\n');
%Top Side of Pipe%
fprintf(f1,'%12s\n','top');
fprintf(f1,'%10s\n','{');
fprintf(f1,'%24s\n','type wall;');
fprintf(f1,'%19s\n','faces');
fprintf(f1,'%15s\n','(');
fprintf(f1,'%28s\n','(1 2 5 4)');
fprintf(f1,'%16s\n',');');
fprintf(f1,'%10s\n','}');
fprintf(f1,'\n');
%Axis of Pipe%
fprintf(f1,'%13s\n','axis');
fprintf(f1,'%10s\n','{');
fprintf(f1,'%25s\n','type empty;');
fprintf(f1,'%19s\n','faces');
fprintf(f1,'%15s\n','(');
fprintf(f1,'%28s\n','(0 3 3 0)');
fprintf(f1,'%16s\n',');');
fprintf(f1,'%10s\n','}');
fprintf(f1,'%5s\n',');');
fprintf(f1,'\n');
fprintf(f1,'%20s\n','mergePatchPairs');
fprintf(f1,'%6s\n','(');
fprintf(f1,'%7s\n',');');
fclose(f1)
The blockMeshDict files for 3 different cases are different since the co-ordinates for each case will be different.
blockMeshDict (for 10 degrees):
/*--------------------------------*- 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.000000 0.000000 0.000000)
(0.000000 0.009962 -0.000872)
(0.000000 0.009962 0.000872)
(3.020000 0.000000 0.000000)
(3.020000 0.009962 -0.000872)
(3.020000 0.009962 0.000872)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (100 1 50) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 2 5 3)
);
}
back
{
type symmetry;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 2 5 4)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
):
mergePatchPairs
(
);
// ************************************************************************* //
blockMeshDict (for 25 degrees):
/*--------------------------------*- 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.000000 0.000000 0.000000)
(0.000000 0.009763 -0.002164)
(0.000000 0.009763 0.002164)
(3.020000 0.000000 0.000000)
(3.020000 0.009763 -0.002164)
(3.020000 0.009763 0.002164)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (100 1 50) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 2 5 3)
);
}
back
{
type symmetry;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 2 5 4)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
blockMeshDict (for 45 degrees):
/*--------------------------------*- 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.000000 0.000000 0.000000)
(0.000000 0.009239 -0.003827)
(0.000000 0.009239 0.003827)
(3.020000 0.000000 0.000000)
(3.020000 0.009239 -0.003827)
(3.020000 0.009239 0.003827)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (100 1 50) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0.000000 0.010000 0.000000)
arc 4 5 (3.020000 0.010000 0.000000)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 2 5 3)
);
}
back
{
type symmetry;
faces
(
(0 3 4 1)
);
}
top
{
type wall;
faces
(
(1 2 5 4)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
The other files such as the controlDict, U, p and transportProperties remain the same as we are using the same test conditions.
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 10;
deltaT 0.001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
p:
/*--------------------------------*- 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.0189;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
top
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
U:
/*--------------------------------*- 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.0937 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.0937 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
top
{
type fixedValue;
value uniform (0 0 0);
}
axis
{
type empty;
}
}
// ************************************************************************* //
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.9256e-7;
// ************************************************************************* //
Results for 10 degree wedge angle:
Wedge Geometry (10 degrees)
Velocity distribution at mid-section of the Pipe
Velocity profile at various points along the flow-
at X=0.001m (Inlet):
at X=0.1m:
at X=0.3m:
at X=0.6m:
at X=1.5m:
at X=3m (outlet):
The variation of the velocity profile can be seen from the graphs. The profile changes till X=0.6m but remains constant thereafter, indicating the fully developed nature of the flow.
The velocity profile characteristics were same for all three cases of wedge angles, hence the detailed images were shown only for 10 degrees wedge angle. For the other two, only the significant images are shown. The pressure variation also remains fairly the same and is displayed at the end.
Results for 25 degree wedge angle:
Geometry (25 degrees)
Velocity Profiles:
at X=0.001m (Inlet):
at X=0.3m:
at X=0.6m:
The velocity profile after X=0.3m remains fairly constant.
Results for 45 degree wedge angle:
Geometry for wedge angle 45 degrees
Velocity profiles:
at X=0.001m (Inlet):
at X=0.3m:
at X=0.6m:
The velocity profile after X=0.3m remains fairly constant.
Pressure Distribution:
The graph of Pressure variation along the pipe length is similar for all the three cases with minor changes in pressure values. Since our main aim is to check the velocity profiles, we do not need to go into much details about pressure variation. The variation is as shown.
RESULTS:
| Angle | Vmax Analytical (m/s) | Vmax Observed (m/s) | Mean Courant Number | Maximum Courant Number | Simulation Time (s) |
| 10 | 0.187462 | 0.179476 | 0.001954543 | 0.0146663 | 1166 |
| 25 | 0.187462 | 0.176925 | 0.00194753 | 0.0148481 | 1557 |
| 45 | 0.187462 | 0.175437 | 0.00195278 | 0.0153504 | 1395 |
CONCLUSION:
- As can be seen from the table above, the observed velocity value decreases as the angle increases, which means that smaller the angle, better is the solution accuracy.
- The maximum Courant Number is also the lowest for 10 degrees angle. Even though the maximum Courant number value increases with increase in angle, the increase is very small to cause any instabilities in the solution. Hence, Courant number does not play a crucial role in these simulations.
- The simulation time is also the lowest for the lowest angle of 10 degrees. This can be intuitively explained by the fact that the size of the computational domain is less for a smaller angle. [To put things into perspective, for the same end time and time step as symmetry BC, the simulation with wedge BC (previous project) took 1500s to only complete 30% of the simulation. That too, for a small angle of 2 degrees.]
- The simulation times of all the three simulations with 'symmetry' BC when compared with that of the 'wedge' BC were substantially lower. This can be attributed to the fact that the symmetry boundary condition mirrors the values and hence, computation of values is only done in a sub-domain and not the entire domain.
Also, using the symmetry boundary condition, we can go to geometries with large angles as compared to the 5 degrees restriction for the wedge boundary condition.
Thus, using a symmetry BC instead of a wedge BC will be advantageous.