Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
Objective:
To simulate the Hagen-poisuelle flow by applying Symmetry Boundary Condition. for mentioned wedge anagle.
Angles to test:
- 10degree
- 25degree
- 45degree
Flow Parameters:
dynamic Viscocity: 8.9278x10^-4 Pa.s
Velocity: 0.119m/s
Matlab Code:
clear all
close all
clc
%length
l = 2.5;
angle = 45;
%angle
theta = 90-angle/2;
%diameter
d = 15e-3;
%division
div_x = 2;
div_y = 2;
div_z = 1;
nodiv_z = linspace(0,l,div_z+1);
tot = div_x + div_y + div_z;
%computing vertices
d_lx = d;
d_lz = d;
a = 1;
for i = 1:length(nodiv_z)
for j = 1: div_y+1
if j == 1
vertex(a,1:3) = [nodiv_z(i) 0 0];
elseif j <= (div_y) && j > 1
vertex(a,1:3) = [nodiv_z(i) d/2*sind(theta) d/2*cosd(theta)];
d_lx = d_lx - d_lx/div_x;
elseif j == 3
d_lx = d;
vertex(a,1:3) = [nodiv_z(i) d/2*sind(theta) -d/2*cosd(theta)];
end
a = a+1;
end
d_lx = d;
end
f1 = fopen('Mesh.txt','r');
r = sprintf('blockMeshDict_%.3f.txt',angle);
f2 = fopen(r,'w') ;
for i = 1:17
A = fgetl(f1);
h_line = convertCharsToStrings(A);
fprintf(f2,'%s\n',h_line)
end
fprintf(f2,'vertices\n(\n')
for i = 1:length(vertex)
fprintf(f2,'\t(%d %d %d)\n',vertex(i,1:3))
end
fprintf(f2,');\n\n');
fprintf(f2,'blocks\n(\n\thex (0 3 5 2 0 3 4 1) (600 20 1) SimpleGrading (1 0.1 1)\n);')
fprintf(f2,'\nedges\n(\n\tarc 1 2(0 %d 0)\n\tarc 4 5(%d %d 0)\n);\n',d/2,l,d/2)
fprintf(f2, 'boundary\n\t(\n')
fprintf(f2,'\n\t\tinlet\n\t\t{\n\t\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(0 1 2 0)\n\t\t);\n\t\t}')
fprintf(f2,'\n\t\toutlet\n\t\t{\n\t\t\ttype \tpatch;\n\t\tfaces\n\t\t(\n\t\t\t(3 5 4 3)\n\t\t);\n\t\t}\n')
fprintf(f2,'\n\t\ttop\n\t\t{\n\t\t\ttype \twall; \n\t\tfaces\n\t\t(\n\t\t\t(1 4 5 2)\n\t\t);\n\t\t}\n')
fprintf(f2,'\n\t\tfront\n\t\t{\n\t\t\ttype \tsymmetry; \n\t\tfaces\n\t\t(\n\t\t\t(0 3 4 1)\n\t\t);\n\t\t}\n')
fprintf(f2,'\n\t\tback\n\t\t{\n\t\t\ttype \tsymmetry; \n\t\tfaces\n\t\t(\n\t\t\t(0 2 5 3)\n\t\t);\n\t\t}\n')
fprintf(f2,'\n\t\taxis\n\t\t{\n\t\ttype \tempty; \n\t\tfaces\n\t\t(\n\t\t\t(0 3 3 0)\n\t\t);\n\t\t}\n')
fprintf(f2,'\t);\n')
fprintf(f2,'mergePatchPairs\n')
fprintf(f2,'(\n);\n')
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.000000 0.000000 0.000000)
(0.000000 0.007471 0.000654)
(0.000000 0.007471 -0.000654)
(2.500000 0.000000 0.000000)
(2.500000 0.007471 0.000654)
(2.500000 0.007471 -0.000654)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (600 20 1) SimpleGrading (1 0.1 1)
);
edges
(
arc 1 2(0 0.007500 0)
arc 4 5(2.500000 0.007500 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
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: 8
\\/ 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.02;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
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.9268e-07;
// ************************************************************************* ///
Initial P:
/*--------------------------------*- 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;
}
axis
{
type empty;
}
top
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
Initial U:
/*--------------------------------*- 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 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.1190 0 0);
}
outlet
{
type
zeroGradient;
}
axis
{
type empty;
}
top
{
type fixedValue;
value uniform (0 0 0);
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
Results:
Wedge angle 10:
Pressure:



Pressure drop after fully developed flow:

Velocity:



Velocity profile after fully developed:

Shear stress:

Wedge angle 25:
Pressure:



Pressure drop after fully developed flow:

Velocity:


Velocity profile after fully developed:

Shear stress:

Wedge angle 45:
Pressure:



Pressure drop after fully developed flow:

Velocity:



Velocity profile after fully developed:

Shear stress:

Comparison:
| Theoretical Values | Computed Values | Percentage error | |
| Wedge angle 10: | |||
| Pressure | 0.012086 | 0.0122715 | 1.534833692 |
| Velocity | 0.235362 | 0.23537 | 0.003399019 |
| Shear stress | 0.056655 | 0.05564 | 1.791545318 |
| Wedge angle 25: | |||
| Pressure | 0.012086 | 0.012759 | 5.568426278 |
| Velocity | 0.235362 | 0.23544 | 0.033140439 |
| Shear stress | 0.056655 | 0.056819 | 0.289471362 |
| Wedge angle 45: | |||
| Pressure | 0.012086 | 0.0142037 | 17.5219262 |
| Velocity | 0.235362 | 0.23558 | 0.092623278 |
| Shear stress | 0.056655 | 0.05996 | 5.833553967 |
Conclusion:
- The Matlab code which was used to develop the blockMeshDict file was made.
- The simulation was performed on symmetry boundary conditions with angles of 10°, 25°, and 45°.
- From the results of the simulation, it is clear that on increasing the wedge angle the percentage error in wall shear stress was found to decrease and then increased also the percentage error of all the other parameters was found to increase with the increase in the wedge angle.
- It can be concluded from the results that, the symmetric boundary condition gives better accuracy over the wedge boundary condition. So to consider which boundary condition to select is based on which are the parameters we want to capture in the simulation accurately.