Week 12 - Symmetry vs Wedge vs HP equation
Symmetry vs wedge vs HP equation
Objective :
- To write a matlab code for symmetry boundary conditions of flow through pipe.
- To obtain results at wedge angles of 10,25 and 45 degreesof pipe flow.
- Comparing results of wedge boundary conditions with symmetry boundary conditions.
Description :
Assumptions & considerations from Hagen Poiseuille equations :
Matlab program to generate blockMeshDict file:
clear all
close all
clc
%inputs
Re = 2100; %Reynold Number.
D = 0.02; %Dia of pipe in m.
rho = 997; %Density of water in kg/m^3.
nu = 8.917e-7; %Kinematic viscosity of water in m^2/s.
% Calculations
mu = rho*nu; %Dynamic viscosity of water
%Re = rho*V_avg*D/mu;
V_avg = mu*Re/(rho*D);
V_max = 2*V_avg;
r = D/2; %Radius of pipe in m.
L_entrance = 0.06*D*Re; %Hydrodynamic length at the enterance.
L = L_entrance + 0.3; %Total length of the pipe.
%Hagen Poiseulle equation
delta_p = 8*mu*V_avg*L/r^2; %Pressure in Pa.
Kinematic_P = delta_p/rho; %Kinematic Pressure in m^2/s^2.
%Wedge Angle
theta = input("Enter the value of the wedge angle:"); %wedge angle should be less than 5deg.
% calculacting shear stress
R = linspace(0,D/2,1000);
for i = 1:length(R)
tau(i) = 2*mu*V_max*(abs(R(i)))/r^2;
end
%Plot
plot(R,tau);
xlabel('Radius in m');
ylabel('shear stress in N/m^2');
title('Variation of shear stress along radius of cylinder')
grid on
hold on
% creating blockMeshDict file:
%Calculating vartices
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)];
% Header file in openFoam
h1 ='/*--------------------------------*- C++ -*----------------------------------*';
h2 ='| ========= | |';
h3 ='| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |';
h4 ='| \ / O peration | Website: https://openfoam.org |';
h5 ='| \ / A nd | Version: 8 |';
h6 ='| \/ M anipulation | |';
h7 ='*---------------------------------------------------------------------------*/';
h8 ='FoamFile';
h9 ='{';
h10 = 'version 2.0;';
h11 = 'format ascii;';
h12= 'class dictionary;';
h13 = 'object blockMeshDict;';
h14 ='}';
h15 ='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
f1 = fopen('blockMeshDict.txt','w'); % creating a text file.
fprintf(f1,'%s n',h1);
fprintf(f1,'%s n',h2);
fprintf(f1,'%s n',h3);
fprintf(f1,'%s n',h4);
fprintf(f1,'%s n',h5);
fprintf(f1,'%s n',h6);
fprintf(f1,'%s n',h7);
fprintf(f1,'n');
fprintf(f1,'%s n',h8);
fprintf(f1,'n');
fprintf(f1,'%s n',h9);
fprintf(f1,'%s n',h10);
fprintf(f1,'%s n',h11);
fprintf(f1,'%s n',h12);
fprintf(f1,'%s n',h13);
fprintf(f1,'%s n',h14);
fprintf(f1,'%s n',h15);
fprintf(f1,'n');
fprintf(f1,'%s n','convertToMeters 1;')
fprintf(f1,'n')
%Vertices
fprintf(f1,'%s n','vertices')
fprintf(f1,'%s 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,'%s n',');')
%blocks
fprintf(f1,'n')
fprintf(f1,'%s n','blocks')
fprintf(f1,'%s n','(')
fprintf(f1,'t hex (0 3 4 1 0 3 5 2) (%d %d %d) simpleGrading (1 0.1 1)n',300,30,1)
fprintf(f1,'%s n',');')
%edges
fprintf(f1,'n')
fprintf(f1,'%s n','edges')
fprintf(f1,'%s n','(')
fprintf(f1,'t arc 1 2 (%d %d %d)n',0,r,0)
fprintf(f1,'t arc 4 5 (%d %d %d)n',L,r,0)
fprintf(f1,'%s n',');')
%boundary
fprintf(f1,'n')
fprintf(f1,'%s n','boundary')
fprintf(f1,'%s n','(')
%axis
fprintf(f1,'t axis n t {n')
fprintf(f1,'t type empty;n')
fprintf(f1,'t faces nt ( n')
fprintf(f1,'t (%d %d %d %d)n',0,3,3,0)
fprintf (f1,'tt);n t}n')
%wall
fprintf(f1,'n')
fprintf(f1,'t wall n t {n')
fprintf(f1,'t type wall;n')
fprintf(f1,'t faces n t(n')
fprintf(f1,'t (%d %d %d %d)n',1,4,5,2)
fprintf(f1,'tt);n t}n')
%inlet
fprintf(f1,'n')
fprintf(f1,'t inlet n t {n')
fprintf(f1,'t type patch;n')
fprintf(f1,'t faces nt ( n')
fprintf(f1,'t (%d %d %d %d)n',0,1,2,0)
fprintf (f1,'tt);n t}n')
%outlet
fprintf(f1,'n')
fprintf(f1,'t outlet n t {n')
fprintf(f1,'t type patch;n')
fprintf(f1,'t faces nt ( n')
fprintf(f1,'t (%d %d %d %d)n',3,5,4,3)
fprintf (f1,'tt);n t}n')
%front
fprintf(f1,'n')
fprintf(f1,'t front n t {n')
fprintf(f1,'t type wedge;n')
fprintf(f1,'t faces nt ( n')
fprintf(f1,'t (%d %d %d %d)n',0,3,4,1)
fprintf (f1,'tt);n t}n')
%back
fprintf(f1,'n')
fprintf(f1,'t back n t {n')
fprintf(f1,'t type wedge;n')
fprintf(f1,'t faces nt ( n')
fprintf(f1,'t (%d %d %d %d)n',0,2,5,3)
fprintf (f1,'tt );n t}n tt );n')
fprintf(f1,'n')
fprintf(f1, '%s n','mergePatchPairs')
fprintf(f1,'t(n tt ); n')
fprintf(f1,'// ************************************************************************* //')
fclose(f1)
controlDict file :
/*--------------------------------*- 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 10;
deltaT 1e-3;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
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.917e-7;
// ************************************************************************* //
Boundary conditions :-
velocity(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.09363 0 0);
boundaryField
{
axis
{
type empty;
}
wall
{
type noSlip;
}
inlet
{
type fixedValue;
value uniform (0.09363 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
pressure(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
{
axis
{
type empty;
}
wall
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type zeroGradient;
value uniform 0.018;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
Results :-
blockMeshDict files at different wedge angles :
For wedge angle =10degree:
/*--------------------------------*- 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 9.961947e-03 -8.715574e-04)
(0 9.961947e-03 8.715574e-04)
(2.820000e+00 0 0)
(2.820000e+00 9.961947e-03 -8.715574e-04)
(2.820000e+00 9.961947e-03 8.715574e-04)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (300 30 1) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 1.000000e-02 0)
arc 4 5 (2.820000e+00 1.000000e-02 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
wall
{
type wall;
faces
(
(1 4 5 2)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Geometry:
Meshing:
Plots for wedge angle=10 degree:
For wedge angle =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 9.762960e-03 -2.164396e-03)
(0 9.762960e-03 2.164396e-03)
(2.820000e+00 0 0)
(2.820000e+00 9.762960e-03 -2.164396e-03)
(2.820000e+00 9.762960e-03 2.164396e-03)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (300 30 1) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 1.000000e-02 0)
arc 4 5 (2.820000e+00 1.000000e-02 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
wall
{
type wall;
faces
(
(1 4 5 2)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Geometry:
Meshing:
Plots for wedge angle= 25 degree:
For wedge angle =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 9.238795e-03 -3.826834e-03)
(0 9.238795e-03 3.826834e-03)
(2.820000e+00 0 0)
(2.820000e+00 9.238795e-03 -3.826834e-03)
(2.820000e+00 9.238795e-03 3.826834e-03)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (300 30 1) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 1.000000e-02 0)
arc 4 5 (2.820000e+00 1.000000e-02 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
wall
{
type wall;
faces
(
(1 4 5 2)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
front
{
type symmetry;
faces
(
(0 3 4 1)
);
}
back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Geometry:
Meshing:
Plots for wedge angle= 45 degree:
Conclusion :
symmetry - 10 degree wedge angle
courant number(max) - 0.0349586
Vmax(x=2.8m from inlet) - 0.1753
symmetry - 25 degree wedge angle
courant number(max) - 0.0352204
Vmax(x=2.8m from inlet) - 0.1764
symmetry - 45 degree wedge angle
courant number(max) - 0.0360044
Vmax(x=2.8m from inlet) - 0.1788
Comparing the results:
>> It is clearly observed that excution time for type-symmetry is higher than type-wedge.
>> As the wedge angle increases the error in the maximum velocity decreases. Here there is a slight variation between analytical and numerical results, but on increasing the wedge angle the courant number also increased with slight variation.
>> The velocity for wedge boundary condition at 3-degree is minimum when compared to the wedge angle with synnetry boundary condition.
>> On considering the center portion of pipe, from the plots it is observed that in case of wedge boundary conditions the value of maximum velocity varies with the increase in the angle of the wedge.
>> Where as in symmetry boundary conditions we can select a higher wedge angles, unlike the wedge boundary conditions (i.e. it should be <5) as it is an axis symmetric boundary condition.
>> Hence fro the above obtained results it can be concluded that symmetric boundary conditions paly a vital role in obtaining the accurate results.