Simulation of flow of water through pipe for symmetry BC and compare it s results with wedge BC
Objective:
Now, your task is to make the simulation work with Symmetry Boundary Condition.
- You should have results obtained from solving the Hagen Poisuelle\'s equation
- You should have results obtained from simulating the pipe flow with the wedge BC
- You should obtain results for the pipe flow with symmetry BC
- Write a Matlab program that takes an angle as input and generates a blockMesh file for the given angle.
- Angles to test 10,25,45
Compare the above results and discuss your findings.
Solution:
A) validation by Hagen Poisuelle\'s equation:
1)Here Reynold number is assumed to be 2100 and diameter of duct to be 0.02 m and thus by entry length formula Le is as follows
Le=0.06*Re*D
Le=2.52 m
2) hereby Hagen poiseuille\'s equation:
Re=2100; % Reynold number
D=0.02; %diameter
Le=0.06*Re*D; %entry length for flow to develop
R=D/2;
mu=0.89e-3; % dynamic viscosity at25 degree
rho=997;%density
nu=mu/rho;
% here by hagen poiseuille theorem
v_avg=Re*mu/(D*rho);% average velocity
v_avg=velocity at inlet:0.093731 m/s
validation for velocity :
here by simulalation following profile emerges and it shows velocity to be 0.094 m/s and thus accuracy has been achieved
v_max=2*v_avg;
pressure_diff=(32*mu*v_avg*Le)/(D^2);
Kinematic_press_drop=pressure_diff/rho;
Kinematic_press_drop=pressure at exit:0.016868 m or 165.3762239389769 Pascal
validation for pressure drop:
here it observed that pressure drop by simulation is around 155 Pa whereas by calculation it comes to be 165.37 Pa and thus accuracy has been achieved.
B) MATLAB code to create BlockMeshDict file as follows:
% mesh parameter
n1=50;%along the length
n2=1;%radial
n3=300;% along curve
gradingfactor=0.2;
clc;
close all;
clear all;
% Input
theta=input(\'enter the wedge angle in degree:\');
Re=2100; % Reynold number
D=0.02; %diameter
Le=0.06*Re*D; %entry length for flow to develop
fprintf(\'entry length:%f\\n\',Le)
R=D/2;
mu=0.89e-3; % dynamic viscosity at25 degree
rho=997;%density
nu=mu/rho;
% here by hagen poiseuille theorem
v_avg=Re*mu/(D*rho);% average velocity
fprintf(\'velocity at inlet:%f\\n\',v_avg);
v_max=2*v_avg;
pressure_diff=(32*mu*v_avg*Le)/(D^2);
Kinematic_press_drop=pressure_diff/rho;
fprintf(\'pressure at exit:%f\\n\',Kinematic_press_drop)
% mesh parameter
n1=50;%along the length
n2=1;%radial
n3=300;% along curve
gradingfactor=0.2;
%vertices of the wedge
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=[Le 0 0];
v4=[Le R*cosd(theta/2) -R*sind(theta/2)];
v5=[Le R*cosd(theta/2) R*sind(theta/2)];
% printing the file
t1=\'/*-------------------------------*- C++ -*-------------------------------* OPENFOAM*/\';
% creating blockMeshDict file
f1=fopen(\'blockMeshDict.txt\',\'wt\');
fprintf(f1,\'%s\\n\',t1);
fprintf(f1,\'FoamFile\\n{\\n\');
fprintf(f1,\'%16s 2.0;\\n\',\'version\');
fprintf(f1,\'%16s ascii;\\n\',\'format\');
fprintf(f1,\'%16s dictionary;\\n\',\'class\');
fprintf(f1,\'%16s blockMeshDict;\\n}\\n\',\'object\');
fprintf(f1,\'convertToMeters 1;\\n\\n\');
fprintf(f1,\'vertices\\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,\'blocks\\n(\\n\');
fprintf(f1,\' hex(0 1 2 0 3 4 5 3) (%d %d %d) simpleGrading (%0.1f,1,1)\\n);\\n\\n\',n1,n2,n3,gradingfactor);
fprintf(f1,\'edges\\n(\\n arc %d %d (%d %0.2f %d)\\n arc %d %d (%0.2f %0.2f %d)\\n);\\n\\n\',1,2,0,R,0,4,5,Le,R,0);
fprintf(f1,\'boundary\\n(\\n\');
fprintf(f1,\' %s\\n {\\n type %s;\\n faces \\n (\\n (%d %d %d %d) \\n );\\n }\\n\\n\',\'axis\',\'empty\',0,3,3,0);
fprintf(f1,\' %s\\n {\\n type %s;\\n faces \\n (\\n (%d %d %d %d) \\n );\\n }\\n\\n\',\'inlet\',\'patch\',0,1,2,0);
fprintf(f1,\' %s\\n {\\n type %s;\\n faces \\n (\\n (%d %d %d %d) \\n );\\n }\\n\\n\',\'pipe\',\'wall\',1,4,5,2);
fprintf(f1,\' %s\\n {\\n type %s;\\n faces \\n (\\n (%d %d %d %d) \\n );\\n }\\n\\n\',\'outlet\',\'patch\',3,4,5,3);
fprintf(f1,\' %s\\n {\\n type %s;\\n faces \\n (\\n (%d %d %d %d) \\n );\\n }\\n\\n\',\'front\',\'symmetry\',0,3,5,2);
fprintf(f1,\' %s\\n {\\n type %s;\\n faces \\n (\\n (%d %d %d %d) \\n );\\n }\\n\\n\',\'back\',\'symmetry\',0,1,4,3);
fprintf(f1,\');\\n\\n\');
fprintf(f1,\'mergePatchPairs\\n(\\n);\\n\\n\');
fclose(f1);
Matlab code output:
enter the wedge angle in degree:45
entry length:2.520000
velocity at inlet:0.093731
the pressure at exit:0.016868
along with that, it will create blockMeshDict file and we have to copy-paste that in the system folder for a given wedge angle.
C) BlockMeshdict File for wedge angle 10,25 and 45 degree as follows
for 10 degree
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ 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.520000e+00 0 0)
(2.520000e+00 9.961947e-03 -8.715574e-04)
(2.520000e+00 9.961947e-03 8.715574e-04)
);
blocks
(
hex (0 1 2 0 3 4 5 3) (50 1 300) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2.52 0.01 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
pipe
{
type wall;
faces
(
(1 4 5 2)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location \"system\";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.01;
deltaT 0.000001;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ 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;
}
pipe
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0.0168682;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0.0937312 0 0);
boundaryField
{
axis
{
type empty;
}
inlet
{
type fixedValue;
value uniform (0.0937312 0 0);
}
pipe
{
type noSlip;
}
outlet
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
}
// ************************************************************************* //
for 25 degree
/*-------------------------------*- C++ -*-------------------------------* OPENFOAM*/
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.520000e+00 0 0)
(2.520000e+00 9.762960e-03 -2.164396e-03)
(2.520000e+00 9.762960e-03 2.164396e-03)
);
blocks
(
hex(0 1 2 0 3 4 5 3) (50 1 300) simpleGrading (0.2,1,1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2.52 0.01 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
pipe
{
type wall;
faces
(
(1 4 5 2)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
);
mergePatchPairs
(
);
for 45 degree
/*-------------------------------*- C++ -*-------------------------------* OPENFOAM*/
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.520000e+00 0 0)
(2.520000e+00 9.238795e-03 -3.826834e-03)
(2.520000e+00 9.238795e-03 3.826834e-03)
);
blocks
(
hex(0 1 2 0 3 4 5 3) (50 1 300) simpleGrading (0.2,1,1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2.52 0.01 0)
);
boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
pipe
{
type wall;
faces
(
(1 4 5 2)
);
}
outlet
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type symmetry;
faces
(
(0 3 5 2)
);
}
back
{
type symmetry;
faces
(
(0 1 4 3)
);
}
);
mergePatchPairs
(
);
D)Solution:
graphs of velocity profile generated from Simulation shows that flow has been developed over the length of the pipe. and thus simulation is correct as it satisfies both velocity and pressure drop figures.
for x=0 m
for x=1.255 m
for x=2.51 m
Conclusions:
1) Here it is observed that simulation results are more accurate for 45 degree wedge angle with symmetry BC.
2) It is observed that symmetry BC takes more time than wedge BC for execution.
3) Results obtained from symmetry BC are more accurate than Wedge BC.
4) Here results obtained using icoFoam solver and results are promising which can further be refined by refining the mesh.