Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
*AIM:-
-To write the program in matlabthat can generate the computational mesh automatically for any symmetric angle and grading schemes
*Introdution:-
-Hydrodynamic Entrance Length

-Many different enterance lengths exist to describe a variety of flow conditions. The entrance length refers to the length of the entry region where effects from the pipe interior wall spread as an expanding boundary layer in the flow.
-The entrance length describes the distance travelled by the flow after entering the pipe before the flow becomes fully developed.
-Hydrodynamic entrance length describes the formation of a velocity profile caused by viscous forces propagating from the pipe wall.
-After the fluid becomes fully developed the flow characteristics no longer changes with the increased distance along the length of pipe.
-Entrance length for the laminar flow is given below:-
Entrance length=Le=0.06*Re*D
*Data:-
Reynold's number(Re):- 2100
Diameter of the pipe(D)= 0.02m
Radious of the pipe(R)= D/2= 0.01m
Density (rho)= 997 kg/m^3
Kinematic viscocity(v):- 0.00089 n/m^2
*Hagen-poisselus equation:-
- Poiseuille equation is a physical law that gives the pressure drop in an incompressible and newtonian fluid in laminar flow flowing through a long cylindrical pipe of constant cross section.
-Poiseuille's equation describes the pressure drop due to the viscocity of the fluid
-Average velocity:- `V_(avg)=(R_e∙μ)/(ρ∙D)`
-Maximum velocity:- `V_max=2∙V_(avg)`
-Pressure difference:- `∆p=(8∙μ∙L∙V_(avg))/r^2`
-Kinematic pressure difference:- `∆P_k=(∆p)/ρ`
-Shear stress:-`τ=(2∙μ∙V_max∙R)/r^2`
*BlockMeshDict:-
i) For 10 degree:-
/*--------------------------------*- 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
(0 9.9619e-03 8.7155e-04) //1
(0 9.9619e-03 -8.7155e-04) //2
(2.82 0 0) //3
(2.82 9.9619e-03 8.7155e-04) //4
(2.82 9.9619e-03 -8.7155e-04) //5
);
blocks
(
hex (0 3 5 2 0 3 4 1) (500 25 1) simpleGrading (1 0.2 1)
);
edges
(
arc 1 2 (0 1e-2 0)
arc 4 5 (2.82 1e-2 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
(
);
// ************************************************************************* //
ii) For 25 degree:-
/*--------------------------------*- 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
(0 9.7629e-03 2.1643e-04) //1
(0 9.7629e-03 -2.1643e-04) //2
(2.82 0 0) //3
(2.82 9.7629e-03 2.1643e-04) //4
(2.82 9.7629e-03 -2.1643e-04) //5
);
blocks
(
hex (0 3 5 2 0 3 4 1) (500 25 1) simpleGrading (1 0.2 1)
);
edges
(
arc 1 2 (0 1e-2 0)
arc 4 5 (2.82 1e-2 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
(
);
// ************************************************************************* //
iii) For 45 degree:-
/*--------------------------------*- 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
(0 9.2387e-03 8.8268e-04) //1
(0 9.2387e-03 -8.8268e-04) //2
(2.82 0 0) //3
(2.82 9.2387e-03 8.8268e-04) //4
(2.82 9.2387e-03 -8.8268e-04) //5
);
blocks
(
hex (0 3 5 2 0 3 4 1) (500 25 1) simpleGrading (1 0.2 1)
);
edges
(
arc 1 2 (0 1e-2 0)
arc 4 5 (2.82 1e-2 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
(
);
// ************************************************************************* //
2) transportproperties:-
/*--------------------------------*- 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.9256e-07;
// ************************************************************************* //
3) 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 0.8;
deltaT 1e-3;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
4) fvschemes:-
/*--------------------------------*- 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 fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default Gauss linear orthogonal;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default orthogonal;
}
// ************************************************************************* //
5) fvsolutions:-
/*--------------------------------*- 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 fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.05;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
// ************************************************************************* //
6) Pressure:-
/*--------------------------------*- 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 5.377;
}
top
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
7) 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.09373 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.09373 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
*Geometry:-
i) For 10 degree:-


ii) For 25 degree:-


iii) For 45 degree:-


*Matlab code:-
clear all
close all
clc
%Reynold's number
Re=2100;
%Diameter of pipe
D=0.02;
%Entry length of pipe
L=0.06*Re*D;
%Total length of pipe
L_P=L+3;
%Radious of pipe
r=D/2;
%Angle of wedge
theta=10;
%theta=25 & 45
%Dynamic viscocity
mu=0.89e-03;
%Density
rho=997;
%Hagen poissuel flow equation
%Average velocity
v_avg=(Re*mu)/(rho*D);
%Maximum velocity
v_max=2*(v_avg);
%Pressure difference
del_p=(8*mu*L_P*v_avg)/(r^2);
%Kinematic pressure
kinematic_p=del_p/rho;
%Calculating shear stress
R=linspace(0,(D/2),1000);
for i=1:length(R)
%Shear stress
tau(i)=2*mu*v_max*(abs(R(i)))/r^2;
end
plot(R,tau)
xlabel('radious');
ylabel('shear stress');
axis([0 0.01 0 0.1]);
grid on
legend('shear stress');
header1='/*--------------------------------*- C++ -*----------------------------------*\'
header2=' ========= | '
header3=' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox '
header4=' \\ / O peration | Website: https://openfoam.org '
header5=' \\ / A nd | Version: 8 '
header6=' \\/ M anipulation | '
header7='\*---------------------------------------------------------------------------*/'
f1=fopen('blockMwshdict','w')
fprintf(f1, '%s\n', header1)
fprintf(f1, '%s\n', header2)
fprintf(f1, '%s\n', header3)
fprintf(f1, '%s\n', header4)
fprintf(f1, '%s\n', header5)
fprintf(f1, '%s\n', header6)
fprintf(f1, '%s\n', header7)
fprintf(f1, 'FoamFile\n{\n')
fprintf(f1, '%s \t 2.0;\n','version')
fprintf(f1, '%s \t ascii;\n','format')
fprintf(f1, '%s \t dictionary;\n','class')
fprintf(f1, '%s \t blockMeshDict;\n','object')
fprintf(f1, '}\n')
header8='\*---------------------------------------------------------------------------*/'
fprintf(f1, '%s\n\n', header8)
fprintf(f1, 'conertToMeters 1;\n\n')
fprintf(f1,'vertices\n')
fprintf(f1,'(\n')
fprintf(f1, '\t (%d %d %d)\n',0,0,0)
fprintf(f1, '\t (%d %d %d)\n',0,r*cosd(theta/2),r*sind(theta/2))
fprintf(f1, '\t (%d %d %d)\n',0,r*cosd(theta/2),-r*sind(theta/2))
fprintf(f1, '\t (%d %d %d)\n',L_P,0,0)
fprintf(f1, '\t (%d %d %d)\n',L_P,r*cosd(theta/2),r*sind(theta/2))
fprintf(f1, '\t (%d %d %d)\n',L_P,r*cosd(theta/2),-r*sind(theta/2))
fprintf(f1, ');\n\n')
fprintf(f1,'block\n')
fprintf(f1,'(\n')
fprintf(f1, '\t hex (0 3 5 2 0 3 4 1) (%d %d %d)',500,25,1)
fprintf(f1, 'simpleGrading (1 0.2 1)\n\n')
fprintf(f1, ');\n\n')
fprintf(f1,'edges\n')
fprintf(f1,'(\n')
fprintf(f1, '\t arc %d %d (%d %d %d)\n',1,2,0,r,0)
fprintf(f1, '\t arc %d %d (%d %d %d)\n',4,5,L_P,r,0)
fprintf(f1, ');\n\n')
fprintf(f1,'boundary\n')
fprintf(f1,'(\n')
fprintf(f1, '\t inlet \n')
fprintf(f1, '\t {\n')
fprintf(f1, '\t\t type patch;\n')
fprintf(f1, '\t\t faces \n')
fprintf(f1, '\t\t (\n')
fprintf(f1, '\t\t\t(0 1 2 0)\n')
fprintf(f1, '\t\t);\n')
fprintf(f1, '\t }\n')
fprintf(f1, '\t outlet \n')
fprintf(f1, '\t {\n')
fprintf(f1, '\t\t type patch;\n')
fprintf(f1, '\t\t faces \n')
fprintf(f1, '\t\t (\n')
fprintf(f1, '\t\t\t(3 5 4 3)\n')
fprintf(f1, '\t\t);\n')
fprintf(f1, '\t }\n')
fprintf(f1, '\t top \n')
fprintf(f1, '\t {\n')
fprintf(f1, '\t\t type wall;\n')
fprintf(f1, '\t\t faces \n')
fprintf(f1, '\t\t (\n')
fprintf(f1, '\t\t\t(1 4 5 2)\n')
fprintf(f1, '\t\t);\n')
fprintf(f1, '\t }\n')
fprintf(f1, '\t front \n')
fprintf(f1, '\t {\n')
fprintf(f1, '\t\t type wall;\n')
fprintf(f1, '\t\t faces \n')
fprintf(f1, '\t\t (\n')
fprintf(f1, '\t\t\t(0 3 4 1)\n')
fprintf(f1, '\t\t);\n')
fprintf(f1, '\t }\n')
fprintf(f1, '\t axis \n')
fprintf(f1, '\t {\n')
fprintf(f1, '\t\t type empty;\n')
fprintf(f1, '\t\t faces \n')
fprintf(f1, '\t\t (\n')
fprintf(f1, '\t\t\t(0 3 3 0)\n')
fprintf(f1, '\t\t);\n')
fprintf(f1, '\t }\n')
fprintf(f1,'mergePatchParis\n')
fprintf(f1, '(\n')
fprintf(f1, ');\n')
header9='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //'
fprintf(f1, '%s\n', header9)
fclose(f1)
*Plot of shear stress vs Radious:-
