Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
Objective:
Simulating the same problem done in the earlier weel by changing boundary conditions to symmetry form wedge with different angles of 10deg, 25deg and 45deg. Validating the velocity profiles, pressure drop and shear stress and comparting with Hagen Poiseuille's equation.
And the assumptions considering before simulation are:
1) Diamter of the pipe, d = 0.02m
2) Radius of the pipe, r = d/2;
3) Reynold's number, Re = 2100;
4) Density of the water, rho = 997 N/m^3
5) Length of the pipe, Le = 0.06*Re*d = 2.52m;
6) Total length of the pipe, L_t = Le + 0.25*L_t = 3.15m;
7) Dyanamic Viscosity, mu = 0.00089 N.s/m^2;
According to H.P equations,
- Average Velocity, V_avg = Re*mu/rho*d = 0.091731 m/s;
- Maximum Velocity, V_max = 2*V_avg = 0.18746 m/s
- Pressure drop, Del_p = (8*mu*L_t*v_a)/(r^2) = 21.022 Kpa;
- Kinematic Viscosity, kin_p = delta_p/rho = 0.021085 N/m^2;
MATLAB CODE TO GENERATE AUTOMATE BLOCKMESHDICT FILE
clear all
close all
clc
%Initial Data
d = 0.02; %diameter of the pipe
r = d/2; % radius of the pipe
Re = 2100;
L_e = 0.06*d*Re; % length of the pipe at entrance
L_t = L_e+0.25*L_e; % total length of the pipe
theta = input('Enter the value of wedge angle =') %Angle of the wedge;
mu = 0.00089; % Dyanamic viscosity of the water
rho = 997; %density of water
nu = mu/rho; % kinematic viscosity
%average velocity of the water in the pipe
v_a = (Re*nu)/d;
% maximum velocity of the waterfall
v_m = 2*v_a;
%pressure gradient across the pipe
delta_p = (8*mu*L_t*v_a)/(r^2);
%kinematic pressure
kin_p = delta_p/rho;
%% Scrpit for blockMeshDict
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( 'blockMeshDict.txt','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');
fprintf (f1, '{\n');
fprintf (f1, '%12s \t 2.0;\n', 'version');
fprintf (f1, '%12s \t ascii;\n', 'format');
fprintf (f1, '%12s \t dictionary;\n', 'class');
fprintf (f1, '%12s \t blockMeshDict;\n', 'object');
fprintf (f1, '}\n');
fprintf ( f1, '%s\n\n', '// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf (f1, 'convertToMeters 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_t,0,0)
fprintf (f1, '\t (%d %d %d)\n', L_t, r*cosd(theta/2),-r*sind(theta/2))
fprintf (f1, '\t (%d %d %d)\n', L_t, r*cosd(theta/2),r*sind(theta/2))
fprintf (f1, ');\n\n');
fprintf (f1, 'blocks\n')
fprintf( f1, '(\n');
fprintf (f1, '\t hex (0 1 2 0 3 4 5 3) (%d %d %d)', 20,1,300)
fprintf (f1, ' simpleGrading (%d %d %d)\n', 1,0.1,1)
fprintf (f1,');\n\n')
fprintf (f1,'edges\n')
fprintf (f1, '(\n')
fprintf (f1, '%12s arc 1 2 (0 %f 0)\n', blanks(1), r)
fprintf (f1, '%12s arc 4 5 (%f %f 0)\n', blanks(1),L_t, r)
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 (%d %d %d %d)\n', 0,2,1,0)
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 (%d %d %d %d)\n', 3,4,5,3)
fprintf (f1, '\t\t );\n')
fprintf (f1, '\t }\n')
fprintf (f1, '\t pipewall \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 (%d %d %d %d)\n', 1,2,5,4)
fprintf (f1, '\t\t );\n')
fprintf (f1, '\t }\n')
fprintf (f1, '\t front \n')
fprintf (f1, '\t {\n')
fprintf (f1, '\t\t type symmetry;\n')
fprintf (f1, '\t\t faces\n')
fprintf (f1, '\t\t(\n')
fprintf (f1, '\t\t\t (%d %d %d %d)\n', 0,3,5,2)
fprintf (f1, '\t\t );\n')
fprintf (f1, '\t }\n')
fprintf (f1, '\t back \n')
fprintf (f1, '\t {\n')
fprintf (f1, '\t\t type symmetry;\n')
fprintf (f1, '\t\t faces\n')
fprintf (f1, '\t\t(\n')
fprintf (f1, '\t\t\t (%d %d %d %d)\n', 0,1,4,3)
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 (%d %d %d %d)\n', 0,3,3,0)
fprintf (f1, '\t\t );\n')
fprintf (f1, '\t }\n')
fprintf (f1,');\n\n')
fprintf (f1, 'mergePatchpairs\n')
fprintf (f1, '(\n')
fprintf (f1, ');\n\n')
fprintf (f1,'// ************************************************************************* //')
fclose(f1);
BLOCKMESHDICT FILE FOR 10DEG:
/*--------------------------------*- 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.00996195 -0.000871557)
(0 0.00996195 0.000871557)
(3.15 0 0)
(3.15 0.00996195 -0.000871557)
(3.15 0.00996195 0.000871557)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (20 1 300) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 0.010000 0)
arc 4 5 (3.150000 0.010000 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
pipewall
{
type wall;
faces
(
(1 2 5 4)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchpairs
(
);
// ************************************************************************* //
BLOCKMESHDICT FILE FOR 25DEG:
/*--------------------------------*- 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.00976296 -0.0021644)
(0 0.00976296 0.0021644)
(3.15 0 0)
(3.15 0.00976296 -0.0021644)
(3.15 0.00976296 0.0021644)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (20 1 300) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 0.010000 0)
arc 4 5 (3.150000 0.010000 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
pipewall
{
type wall;
faces
(
(1 2 5 4)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchpairs
(
);
// ************************************************************************* //
BLOCKMESHDICT FILE FOR 45DEG:
/*--------------------------------*- 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.0092388 -0.00382683)
(0 0.0092388 0.00382683)
(3.15 0 0)
(3.15 0.0092388 -0.00382683)
(3.15 0.0092388 0.00382683)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (20 1 300) simpleGrading (1 0.1 1)
);
edges
(
arc 1 2 (0 0.010000 0)
arc 4 5 (3.150000 0.010000 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
pipewall
{
type wall;
faces
(
(1 2 5 4)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchpairs
(
);
// ************************************************************************* //
INITIAL CONDITIONS FOR 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 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.093731 0 0);
}
outlet
{
type zeroGradient;
}
pipewall
{
type noSlip;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
INITIAL CONDITIONS FOR 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.021085;
}
pipewall
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
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 1;
deltaT 0.001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
functions
{
#include "FOfindMinMax"
}
// ************************************************************************* //
FUNCTION FILE TO FIND MAXIMUM AND MINIMUM VELOCITIES AND PRESSURE:
To find the maximum and minumum values for velocity and pressure, we can function present in the library of the openFoam and the alogorithm will be as follow and the same has to mention in the ControlDict File as above.
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
/*-------------------------------------------------------------------------------*/
fieldMinMax1
{
type fieldMinMax;
libs ("libfieldFunctionObjects.so");
write yes;
log yes;
location yes;
mode magnitude;
fields
(
U
p
);
}
// ************************************************************************* //
OUTPUT:
After simulating with the same initial conditions and controlDict files with different BlockMeshDict file, the plots for velocities and pressure at different angles along the radius are as follows:
FOR 10DEG:
Velocities Profile plots at different lenghts of the pipe:






Pressure Profile plot:

FOR 25DEG:
Velocities Profile plots at different lenghts of the pipe:







Pressure Profile Plot along the radius:

FOR 45DEG:
Velocities Profile plots at different lenghts of the pipe:







PRESSURE PROFILE PLOT ALONG THE RADIUS:

SHEAR STRESS PLOTS FOR DIFFERENT ANGLES :
FOR 10DEG:

FOR 25DEG:

FOR 45DEG:

MAXIMUM AND MINUMUM VELOCITIES AND PRESSURE RESULTS :
FOR10DEG:
fieldMinMax fieldMinMax1 write:
min(mag(U)) = 0 in cell 19 at location (0.00525 0.00996195 0)
max(mag(U)) = 0.116138 in cell 200 at location (0.11025 0.000332065 0)
min(p) = 0.021085 in cell 5980 at location (3.15 0.000332065 0)
max(p) = 0.0639803 in cell 19 at location (0.00525 0.00971503 -1.58823e-20)
FOR 25DEG:
fieldMinMax fieldMinMax1 write:
min(mag(U)) = 0 in cell 19 at location (0.00525 0.00976296 0)
max(mag(U)) = 0.116575 in cell 240 at location (0.13125 0.000325432 3.9054e-21)
min(p) = 0.021085 in cell 5980 at location (3.15 0.000325432 0)
max(p) = 0.065046 in cell 19 at location (0.00525 0.00952097 -1.02519e-19)
FOR 45DEG:
fieldMinMax fieldMinMax1 write:
min(mag(U)) = 0 in cell 19 at location (0.00525 0.0092388 0)
max(mag(U)) = 0.118105 in cell 5780 at location (3.03975 0.00030796 -9.29249e-21)
min(p) = 0.021085 in cell 5980 at location (3.15 0.00030796 0)
max(p) = 0.06813 in cell 19 at location (0.00525 0.0090098 -5.95142e-20)
FOR 4DEG WEDGE:
fieldMinMax fieldMinMax1 write:
min(mag(U)) = 0 in cell 19 at location (0.00525 0.00999391 0)
max(mag(U)) = 0.115953 in cell 5780 at location (3.03975 0.00033313 0)
min(p) = 0.021085 in cell 5980 at location (3.15 0.00033313 0)
max(p) = 0.0638145 in cell 19 at location (0.00525 0.0097462 9.05843e-21)
COMPARISION PLOT OF VELOCITIES AT DIFFERENT ANGLES AT SAME LENGTH OF THE PIPIE:
COMPARISION OF MAGNITUDES IN A TABLE:

OBSERVATION:
- From Velocity Profile plots, will get to know that at entry the profile is uniform and after 0.1m from entry the flow is starting to develop and can be observed that the plot is very similar to each.
- From Pressure plots, we can observe that the pressure is minimal at the centre and reaches maximum pressure near to walls.
- From Shear Stress plot, we can get to know that the shear stress is very minimal which gives maximum velocity and reaches high near to walls results in minimum velocity.
- From velocity profile comparision plot, will get know that by increasing the wedge angle, the maximum velocity also increases and near to exact H.P equation. And looking at the y coordinate, the 45deg plot is fully developing compared to other two plots.
- From comparision tables also, we can get to know that increasing the angle of the pipe, the maximum velocity reaching to exact solution. For pressure, simulation time and courant number also increases by increasing the angles of the pipe.
- To conclude that even though the results ans plots looks similar but the difference between wedge and symmetry is that the wedge is 1 cell thick, running along the centre line, straddling one of the coordinate planes and symmetry plane is used for for any (non-planar) patch which uses the symmetry plane (slip) condition.