Week 12 - Symmetry vs Wedge vs HP equation
Aim:
clear all
close all
clc
%input data
D=0.004; %diameter of the pipe
R=D/2 ; %radius of the pipe
Re=2100 ;%reynolds number
Le=0.05*Re*D; %entry length
theta=45; %wedge angle
mu=8.96e-04; %kinematic viscosity of water
rho=997; %density of water
nu=(mu/rho);
L=Le+0.7; %total length of the pipe
%calculating solution according to Hagen poiseuille's equation
V=(Re*mu)/(rho*D); %average velcoity
U_max=2*V; %max velocity
del_Pdel_x=(8*mu*V)/(R^2); % pressure gradient
delta_P=(8*mu*V*L)/(R^2); % pressure drop
Kin_P= delta_P/rho ; % kinematic pressure
%vertices;
v0=[0 0 0]; %point o
v1=[0 R*cosd(theta/2) -R*sind(theta/2)];%point 1
v2=[0 R*cosd(theta/2) R*sind(theta/2)];%point 2
v3=[L 0 0];%point 3
v4=[L R*cosd(theta/2) -R*sind(theta/2)];%point4
v5=[L R*cosd(theta/2) R*sind(theta/2)];%point 5
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: 8 ');
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;');
%defining the vertices of the geometry
fprintf(f1, '%s\n', 'vertices');
fprintf(f1, '%s\n\n', '(');
fprintf(f1, '(%d %d %d)\n' ,v0(1),v0(2),v0(3));
fprintf(f1, '(%d %d %d)\n' ,v1(1),v1(2),v1(3));
fprintf(f1, '(%d %d %d)\n' ,v2(1),v2(2),v2(3));
fprintf(f1, '(%d %d %d)\n' ,v3(1),v3(2),v3(3));
fprintf(f1, '(%d %d %d)\n' ,v4(1),v4(2),v4(3));
fprintf(f1, '(%d %d %d)\n\n' ,v5(1),v5(2),v5(3));
fprintf(f1, '%s\n\n',');');
%defining the blocks
fprintf(f1, '%s\n', 'blocks');
fprintf(f1, '%s\n\n', '(');
fprintf(f1, ' hex(0 3 5 2 0 3 4 1) (%d %d %d) simpleGrading(1 1 1)\n\n',250,25,1);
fprintf(f1, '%s\n\n',');');
%defining the edges
fprintf(f1, '%s\n', 'edges');
fprintf(f1, '%s\n\n', '(');
fprintf(f1, '%s\n\n',');');
%defining the boundaries
fprintf(f1, '%s\n','boundary');
fprintf(f1, '%s\n\n','(');
fprintf(f1, '%s\n',' Inlet'); %inlet
fprintf(f1, '%s\n',' {');
fprintf(f1, '%s\n',' type patch;');
fprintf(f1, '%s\n',' faces');
fprintf(f1, '%s\n',' (');
fprintf(f1, '%s\n',' (0 1 2 0)');
fprintf(f1, '%s\n',' );');
fprintf(f1, '%s\n',' }');
fprintf(f1, '%s\n',' outlet'); %outlet
fprintf(f1, '%s\n',' {');
fprintf(f1, '%s\n',' type patch;');
fprintf(f1, '%s\n',' faces');
fprintf(f1, '%s\n',' (');
fprintf(f1, '%s\n',' (3 5 4 3)');
fprintf(f1, '%s\n',' );');
fprintf(f1, '%s\n',' }');
fprintf(f1, '%s\n',' top'); %top
fprintf(f1, '%s\n',' {');
fprintf(f1, '%s\n',' type wedge;');
fprintf(f1, '%s\n',' faces');
fprintf(f1, '%s\n',' (');
fprintf(f1, '%s\n',' (1 4 5 2)');
fprintf(f1, '%s\n',' );');
fprintf(f1, '%s\n',' }');
fprintf(f1, '%s\n',' front'); %front
fprintf(f1, '%s\n',' {');
fprintf(f1, '%s\n',' type wedge;');
fprintf(f1, '%s\n',' faces');
fprintf(f1, '%s\n',' (');
fprintf(f1, '%s\n',' (0 3 4 1)');
fprintf(f1, '%s\n',' );');
fprintf(f1, '%s\n',' }');
fprintf(f1, '%s\n',' back'); %back
fprintf(f1, '%s\n',' {');
fprintf(f1, '%s\n',' type wedge;');
fprintf(f1, '%s\n',' faces');
fprintf(f1, '%s\n',' (');
fprintf(f1, '%s\n',' (0 2 5 3)');
fprintf(f1, '%s\n',' );');
fprintf(f1, '%s\n',' }');
fprintf(f1, '%s\n',' axis'); %axis
fprintf(f1, '%s\n',' {');
fprintf(f1, '%s\n',' type empty;');
fprintf(f1, '%s\n',' faces');
fprintf(f1, '%s\n',' (');
fprintf(f1, '%s\n',' (0 3 3 0)');
fprintf(f1, '%s\n',' );');
fprintf(f1, '%s\n\n',' }');
fprintf(f1, '%s\n\n',');');
fprintf(f1, '%s\n','mergePatchParis');
fprintf(f1, '%s\n','(');
fprintf(f1, '%s\n\n',');');
fprintf(f1, '%s\n\n','// ************************************************************************* //');
For wedge
1. angle 10:
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 0 0)//point 0
(0 1.9923e-3 1.743e-4)//point 1
(0 1.9923e-3 -1.743e-4)//point 2
(1.12 0 0)//point 3
(1.12 1.9923e-3 1.743e-4)//point 4
(1.12 1.9923e-3 -1.743e-4)//point 5
);
blocks
(
hex (0 3 5 2 0 3 4 1) (100 10 1) simpleGrading (1 0.2 1)
);
edges
(
);
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 wedge;
faces
(
(0 3 4 1)
);
}
back
{
type wedge;
faces
(
(0 2 5 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
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 0;
}
top
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //
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.4718 0 0);
boundaryField
{
Inlet
{
type fixedValue;
value uniform (0.4718 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
value uniform 0;
}
front
{
type wedge;
}
back
{
type wedge;
}
axis
{
type empty;
}
}
// ************************************************************************* //
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 5;
deltaT 0.0007;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Geometry:



Velocity profile:
at 0.1

velocity profile at 0.56

2. angle 25
only the vertices parameters are changed

Geometry




Wedge angle 45:





For symmetry boundary condition
1. for angle 10
blockMesh
/*--------------------------------*- 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)//point 0
(0 1.9923e-3 1.743e-4)//point 1
(0 1.9923e-3 -1.743e-4)//point 2
(1.12 0 0)//point 3
(1.12 1.9923e-3 1.743e-4)//point 4
(1.12 1.9923e-3 -1.743e-4)//point 5
);
blocks
(
hex (0 3 5 2 0 3 4 1) (100 10 1) simpleGrading (1 0.2 1)
);
edges
(
);
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
(
);
// ************************************************************************* //
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 0;
}
top
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
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.4718 0 0);
boundaryField
{
Inlet
{
type fixedValue;
value uniform (0.4718 0 0);
}
outlet
{
type zeroGradient;
}
top
{
type noSlip;
value uniform 0;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
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 5;
deltaT 0.0007;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Geometry:




2.angle 25

geometry:




3.angle 45





| angle | analytical velocity | numerical velocity | error | execution time | courant number |
| 10 | 0.914 | 0.9436 | 3.23 | 39 | 0.0604 |
| 25 | 0.915 | 0.9436 | 3.12 | 40 | 0.0609 |
| 45 | 0.9155 | 0.9436 | 3.06 | 42 | 0.0618 |
Conclusion:
By comparing the different cases for symmetry boundary condition
There is not much difference in analytical velocity for different angles but there is a slight difference when we compared with the analytical and numerical values.
As the angle increases the execution time also increases
And with the increase in the angle, there will be a slight increase in the courant number
And lastly, the symmetry boundary condition is more accurate when we compared with wedge boundary condition and it also takes less execution time.