Week 12 - Symmetry vs Wedge vs HP equation
Symmetry vs Wedge vs HP equation
This is the continuation of the previous challenge simulation,
Tasks to be completed in this challenge.
- 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.
EQUATION:
In standard fluid-kinetics notation.
where:
- Δp is the pressure difference between the two ends,
- L is the length of pipe,
- μ is the dynamic viscosity,
- Q is the volumetric flow rate,
- R is the pipe radius,
- A is the cross-section of the pipe.
The equation does not hold close to the pipe entrance.
Given parameters.
- Angles to test 10,25,45
- The fluid is incompressible and the flow is laminar.
Expected Velocity Profile.
Assuming the following:
- The distance the fluid has to travel to become fully developed is given by the Entry Length formula.
- Given Reynolds's number is 2100. This implies flow is laminar.
- Hence Entry length formula for Laminar is given by
">Ld=0.06.ReLd=0.06.ReL d = 0.06 . R e - where L is effective length; d is dia of pipe and Re is Reynolds number.
- Assuming the dia of the pipe as 10mm; substituting the values, we get L = 1.2m;
Steps to follow
- First, the geometry is created in the blockMeshDict file, this is done by creating the file through the matlab code.
- The mesh is generated according to requirements.
- The velocity and pressure bc are applied
- The controlDict file is edited for Simulation run time and timestep;
- After the geometry is input, the simulation can be started by calling 'icoFoam' command in the terminal.
- 'paraFoam' command helps to open paraView
- The shear stress diagram is obtained by post-processing the velocity results obtained from Openfoam.
- The Velocity BC and Pressure BC are changed and the condition for front and back is changed from wedge to Symmetry.
Matlab program for automatically generate blockMeshDict file for a wedge angle provided by the user.
Angles to test 10,25,45
clc
clear all
close all
% variable values
D = 0.01;
r = D/2;
L = 1.2;
theta = input(' input the value of wedge angle='); % 10, 25, 45 are to be tested.
% String for header,
h1 =' /*---------------------------------*- C++ -*-------------------------------------------------*\ ';
h2 =' | ========== | |';
h3 =' | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |';
h4 =' | \\ / O peration | Version: 7 |';
h5 =' | \\ / A nd | Web: www.OpenFOAM.org |';
h6 =' | \\ / M anipulation | |';
h7 =' \*------------------------------------------------------------------------------------------*/ ';
h8 =' FoamFile';
h9 ='{';
h10 =' version 2.0;';
h11 =' format ascii;';
h12 =' class dictionary;';
h13 =' object blockMeshDict;';
h14 ='}';
h15 =' // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\';
conv ='convertToMeters 1;';
sp1 = blanks(5); %sp = space
sp2 = blanks(10);
sp3 = blanks(15);
v_0 = [0 0 0];
v_1 = [r*sind(theta/2) r*cosd(theta/2) 0];
v_2 = [-r*sind(theta/2) r*cosd(theta/2) 0];
v_3 = [0 0 L];
v_4 = [r*sind(theta/2) r*cosd(theta/2) L];
v_5 = [-r*sind(theta/2) r*cosd(theta/2) L];
block ='hex (0 0 1 2 3 3 4 5) (1 50 200) simpleGrading (1 0.5 1)';
edge1 ='arc 1 2';
edge2 ='arc 4 5';
e1 = [0 r 0];
e2 = [0 r L];
inlet = '(0 0 2 1)';
outlet = '(3 4 5 3)';
wedge1 = '(0 1 4 3)';
wedge2 = '(3 5 2 0)';
wall =' (4 1 2 5)';
axis =' (0 3 3 0)';
final = '// ************************************************************************************************************************************************** //';
f1 = fopen('blockMeshDict','wt');
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,'%s\n',h8);
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',conv);
fprintf(f1,'\n');
fprintf(f1,'%s\n','vertices');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s (%f %f %f) \n',sp1,v_0(1),v_0(2),v_0(3));
fprintf(f1,'%s (%f %f %f) \n',sp1,v_1(1),v_1(2),v_1(3));
fprintf(f1,'%s (%f %f %f) \n',sp1,v_2(1),v_2(2),v_2(3));
fprintf(f1,'%s (%f %f %f) \n',sp1,v_3(1),v_3(2),v_3(3));
fprintf(f1,'%s (%f %f %f) \n',sp1,v_4(1),v_4(2),v_4(3));
fprintf(f1,'%s (%f %f %f) \n',sp1,v_5(1),v_5(2),v_5(3));
fprintf(f1,'%s \n',');');
fprintf(f1,'\n');
fprintf(f1,'%s\n','blocks');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s %s \n',sp1,block);
fprintf(f1,'%s \n',');');
fprintf(f1,'\n');
fprintf(f1,'%s \n','edges');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s %s (%f %f %f) \n',sp1,edge1,e1(1),e1(2),e1(3));
fprintf(f1,'%s %s (%f %f %f) \n',sp1,edge2,e2(1),e2(2),e2(3));
fprintf(f1,'%s \n',');');
fprintf(f1,'\n');
fprintf(f1,'%s \n','boundary');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s %s \n',sp1,'inflow');
fprintf(f1,'%s %s \n',sp1,'{');
fprintf(f1,'%s %s \n',sp2,'type patch;');
fprintf(f1,'%s %s \n',sp2,'faces');
fprintf(f1,'%s %s \n',sp2,'(');
fprintf(f1,'%s %s \n',sp3,inlet);
fprintf(f1,'%s %s \n',sp2,');');
fprintf(f1,'%s %s \n',sp1,'}');
fprintf(f1,'%s %s \n',sp1,'outflow');
fprintf(f1,'%s %s \n',sp1,'{');
fprintf(f1,'%s %s \n',sp2,'type patch;');
fprintf(f1,'%s %s \n',sp2,'faces');
fprintf(f1,'%s %s \n',sp2,'(');
fprintf(f1,'%s %s \n',sp3,outlet);
fprintf(f1,'%s %s \n',sp2,');');
fprintf(f1,'%s %s \n',sp1,'}');
fprintf(f1,'%s %s \n',sp1,'front');
fprintf(f1,'%s %s \n',sp1,'{');
fprintf(f1,'%s %s \n',sp2,'type wedge;');
fprintf(f1,'%s %s \n',sp2,'faces');
fprintf(f1,'%s %s \n',sp2,'(');
fprintf(f1,'%s %s \n',sp3,wedge1);
fprintf(f1,'%s %s \n',sp2,');');
fprintf(f1,'%s %s \n',sp1,'}');
fprintf(f1,'%s %s \n',sp1,'back');
fprintf(f1,'%s %s \n',sp1,'{');
fprintf(f1,'%s %s \n',sp2,'type wedge;');
fprintf(f1,'%s %s \n',sp2,'faces');
fprintf(f1,'%s %s \n',sp2,'(');
fprintf(f1,'%s %s \n',sp3,wedge2);
fprintf(f1,'%s %s \n',sp2,');');
fprintf(f1,'%s %s \n',sp1,'}');
fprintf(f1,'%s %s \n',sp1,'wall');
fprintf(f1,'%s %s \n',sp1,'{');
fprintf(f1,'%s %s \n',sp2,'type wall;');
fprintf(f1,'%s %s \n',sp2,'faces');
fprintf(f1,'%s %s \n',sp2,'(');
fprintf(f1,'%s %s \n',sp3,wall);
fprintf(f1,'%s %s \n',sp2,');');
fprintf(f1,'%s %s \n',sp1,'}');
fprintf(f1,'%s %s \n',sp1,'axis');
fprintf(f1,'%s %s \n',sp1,'{');
fprintf(f1,'%s %s \n',sp2,'type empty;');
fprintf(f1,'%s %s \n',sp2,'faces');
fprintf(f1,'%s %s \n',sp2,'(');
fprintf(f1,'%s %s \n',sp3,axis);
fprintf(f1,'%s %s \n',sp2,');');
fprintf(f1,'%s %s \n',sp1,'}');
fprintf(f1,'%s \n',');');
fprintf(f1,'\n');
fprintf(f1,'%s \n','mergePatchPairs');
fprintf(f1,'%s \n','(');
fprintf(f1,'%s \n',');');
fprintf(f1,'\n');
fprintf(f1,'%s \n',final);
fclose(f1);
blockMeshDict File:
1) Theta = 10,
/*---------------------------------*- C++ -*-------------------------------------------------*\
| ========== | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 7 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / M anipulation | |
\*------------------------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000436 0.004981 0.000000)
(-0.000436 0.004981 0.000000)
(0.000000 0.000000 1.200000)
(0.000436 0.004981 1.200000)
(-0.000436 0.004981 1.200000)
);
blocks
(
hex (0 0 1 2 3 3 4 5) (1 50 200) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0.000000 0.005000 0.000000)
arc 4 5 (0.000000 0.005000 1.200000)
);
boundary
(
inflow
{
type patch;
faces
(
(0 0 2 1)
);
}
outflow
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type wedge;
faces
(
(0 1 4 3)
);
}
back
{
type wedge;
faces
(
(3 5 2 0)
);
}
wall
{
type wall;
faces
(
(4 1 2 5)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************************************************************************************** //
2) Theta = 25
/*---------------------------------*- C++ -*-------------------------------------------------*\
| ========== | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 7 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / M anipulation | |
\*------------------------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.001082 0.004881 0.000000)
(-0.001082 0.004881 0.000000)
(0.000000 0.000000 1.200000)
(0.001082 0.004881 1.200000)
(-0.001082 0.004881 1.200000)
);
blocks
(
hex (0 0 1 2 3 3 4 5) (1 50 200) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0.000000 0.005000 0.000000)
arc 4 5 (0.000000 0.005000 1.200000)
);
boundary
(
inflow
{
type patch;
faces
(
(0 0 2 1)
);
}
outflow
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type wedge;
faces
(
(0 1 4 3)
);
}
back
{
type wedge;
faces
(
(3 5 2 0)
);
}
wall
{
type wall;
faces
(
(4 1 2 5)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************************************************************************************** //
3) Theta = 45
/*---------------------------------*- C++ -*-------------------------------------------------*\
| ========== | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 7 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / M anipulation | |
\*------------------------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.001913 0.004619 0.000000)
(-0.001913 0.004619 0.000000)
(0.000000 0.000000 1.200000)
(0.001913 0.004619 1.200000)
(-0.001913 0.004619 1.200000)
);
blocks
(
hex (0 0 1 2 3 3 4 5) (1 50 200) simpleGrading (1 0.5 1)
);
edges
(
arc 1 2 (0.000000 0.005000 0.000000)
arc 4 5 (0.000000 0.005000 1.200000)
);
boundary
(
inflow
{
type patch;
faces
(
(0 0 2 1)
);
}
outflow
{
type patch;
faces
(
(3 4 5 3)
);
}
front
{
type wedge;
faces
(
(0 1 4 3)
);
}
back
{
type wedge;
faces
(
(3 5 2 0)
);
}
wall
{
type wall;
faces
(
(4 1 2 5)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************************************************************************************** //
- VELOCITY BOUNDARY CONDITIONS.
/*--------------------------------*- 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 0 0);
boundaryField
{
inflow
{
type fixedValue;
value uniform (0 0 0.1869);
}
outflow
{
type zeroGradient;
}
wall
{
type noSlip;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
- PRESSURE BOUNDARY CONDITIONS.
/*--------------------------------*- 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
{
inflow
{
type zeroGradient;
}
outflow
{
type fixedValue;
value uniform 0.0638749;
}
wall
{
type zeroGradient;
}
front
{
type symmetry;
}
back
{
type symmetry;
}
axis
{
type empty;
}
}
// ************************************************************************* //
Symmetry is used in front and back walls, This changes the
Wedge Geometry:
10 Degrees
25 Degrees
45 Degrees
RESULTS:
Conclusion:
- The percentage error decreases as the wedge angle decreases.
- Symmetry type BC is more accurate.
- Simulation time is greater in wedge condition than symmetry condition.
