Challenge

Week 12 - Symmetry vs Wedge vs HP equation

Hagen Poisuelle's: Hagen Poisselle's law states that in nonideal fluid dynamics, The fluid is incompressible and Newtonian fluid in a laminar flow flowing through a cylindrical pipe gives a pressure difference. The fluid flow has the following characteristics as Density, Viscosity, pressure, Length of the pipe, and diameter.

Hagen Poisuelle's Equation: The Pressure Difference is given as `trianglep=(8muLQ)/(piR^4)`

SIMULATION OF SYMMETRY AND WEDGE BOUNDARY CONDITIONS:

  • In this challenge, we will use the previous Matlab code and execute three different blockMeshDict files of 10, 25, and 45-degree angle values.
  • Here we will compare the boundary conditions of pressure and velocity type symmetry with the wedge.
  • I have pasted the necessary file below for reference.
  • After making the changes, open the terminal and run the OpenFOAM command and compare the values.
  • Do the same thing for all the projects such as 10, 25, and 45 degrees and execute the files.

MATLAB CODE:

clear all
close all
clc

% Initial Parameters

Re=2100;
D= 0.02;
R=D/2;
theta=input('Enter value for Wedge angle=');
mu=0.00089; %Dynamic viscocity
rho=998.21;
nu=mu/rho;

%analytical calculation
L_e=0.06*Re*D;
L_t=L_e+0.3;
v_avg=(Re*nu)/D;
v_max=2*v_avg;
Delta_P=(8*mu*v_avg*L_t)/R^2;
kin_P=Delta_P/rho;

% Finding vertices
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_t 0 0];
v4=[L_t R*cosd(theta/2) -R*sind(theta/2)];
v5=[L_t R*cosd(theta/2) R*sind(theta/2)];

% script to form blockMeshDict
f1=fopen('blockMeshDict45D.txt','w'); %To create and write blocmesh file

fprintf(f1,'%s','/*--------------------------*- C++-*---------------------------*\');
fprintf(f1,'\n========= |\n');
fprintf(f1,'\\ / F ield | OpenFoam: the Open Source CFD Toolbox\n');
fprintf(f1,' \\ / O peration | Website: https://openfoam.org\n');
fprintf(f1,' \\ / A nd | Version: 8\n');
fprintf(f1,' \\/ M anipulation |\n');
fprintf(f1,'%s','\*---------------------------------------------------------------*/');


b1=blanks(5);
b2=blanks(6);
b3=blanks(7);
b4=blanks(4);

fprintf(f1,'{\n');
fprintf(f1,'%s',' version',b1,'2.0;');
fprintf(f1,'\n');
fprintf(f1,'%s',' format',b2,'ascii;');
fprintf(f1,'\n');
fprintf(f1,'%s',' class',b3,'dictionary;');
fprintf(f1,'\n');
fprintf(f1,'%s',' object',b2,'blockMeshDict;');
fprintf(f1,'\n');
fprintf(f1,'}\n');
fprintf(f1,'%s','//************************************************************//');
fprintf(f1,'\n\nconvertToMeters 1;\n\n');

%To form vertices

fprintf(f1,'vertices\n');

fprintf(f1,'(\n');
fprintf(f1,b4,'%s','(');
v_0= fprintf(f1,'(%f %f %f)\n',v0(1),v0(2),v0(3));
fprintf(f1,b4,'%s','(');
v_1= fprintf(f1,'(%f %f %f)\n',v1(1),v1(2),v1(3));
fprintf(f1,b4,'%s','(');
v_2= fprintf(f1,'(%f %f %f)\n',v2(1),v2(2),v2(3));
fprintf(f1,b4,'%s','(');
v_3= fprintf(f1,'(%f %f %f)\n',v3(1),v3(2),v3(3));
fprintf(f1,b4,'%s','(');
v_4= fprintf(f1,'(%f %f %f)\n',v4(1),v4(2),v4(3));
fprintf(f1,b4,'%s','(');
v_5= fprintf(f1,'(%f %f %f)\n',v5(1),v5(2),v5(3));
fprintf(f1,b4,'%s','(');
fprintf(f1,');\n');
%To create blocks
fprintf(f1,'blocks\n');
fprintf(f1,'(\n');
fprintf(f1,b4,'%s','(');
fprintf(f1,'%s','hex (0 3 5 2 0 3 4 1)');

%to create mesh
m1= input('Enter no. of mesh element along X-axis:');
m2= input('Enter no. of mesh element along Y-axis:');
m3= input('Enter no. of mesh element along Z-axis:');

fprintf(f1,blanks(1),'%s','(');
fprintf(f1,'(%3.0f %1.0f %3.0f) ',m1,m2,m3);
fprintf(f1,'%s','simplegrading (1 1 1)');
fprintf(f1,'\n);');

%To create edges

fprintf(f1,'\nedged \n');
fprintf(f1,'(\n');
fprintf(f1,'%s arc 1 2 (0 %f 0)',blanks(1),R);
fprintf(f1,'\n%s arc 4 5 (%f %f 0)',blanks(1),L_t,R);
fprintf(f1,'\n);\n\n');

% To apply boundary conditions

% For axis
fprintf(f1, 'boundary\n(\n');
fprintf(f1,'%s',' axis');
fprintf(f1,'\n {\n');
fprintf(f1,'%s',blanks(10),'type empty;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(13),'(0 3 3 0)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),');');
fprintf(f1,'\n }\n');

% For fixedwalls
fprintf(f1,'%s',' fixedWalls');
fprintf(f1,'\n {\n');
fprintf(f1,'%s',blanks(10),'type wall;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(13),'(2 1 4 5)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),');');
fprintf(f1,'\n }\n');


% For front
fprintf(f1,'%s',' front');
fprintf(f1,'\n {\n');
fprintf(f1,'%s',blanks(10),'type wedge;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(13),'(1 0 3 4)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),');');
fprintf(f1,'\n }\n');


% For back
fprintf(f1,'%s',' back');
fprintf(f1,'\n {\n');
fprintf(f1,'%s',blanks(10),'type wedge;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(13),'(2 5 3 0)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),');');
fprintf(f1,'\n }\n');

% For inlet
fprintf(f1,'%s',' inlet');
fprintf(f1,'\n {\n');
fprintf(f1,'%s',blanks(10),'type patch;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(13),'(0 1 2 0)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),');');
fprintf(f1,'\n }\n');

% For outlet
fprintf(f1,'%s',' outlet');
fprintf(f1,'\n {\n');
fprintf(f1,'%s',blanks(10),'type patch;');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'faces');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),'(');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(13),'(3 5 4 3)');
fprintf(f1,'\n');
fprintf(f1,'%s',blanks(10),');');
fprintf(f1,'\n }\n');

fprintf(f1,'\n);\n');

fprintf(f1, '\nmergePatchPairs');
fprintf(f1, '\n(\n);\n\n');
fprintf(f1,'%s','//*********************************************************************//');

fclose(f1);

PRESSURE BOUNDARY CONDITIONS

/*--------------------------------*- 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;
}

fixedWalls
{
type zeroGradient;
}

front
{
type wedge;
}

back
{
type wedge;
}

inlet
{
type zeroGradient;
}

outlet
{
type fixedValue;
value uniform 0.0188;
}
}

// ************************************************************************* //

VELOCITY BOUNDARY CONDITIONS

/*--------------------------------*- 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.0936 0 0);

boundaryField
{
axis
{
type empty;
}

fixedWalls
{
type fixedValue;
value uniform (0 0 0);
}

front
{
type wedge;
}

back
{
type wedge;
}

inlet
{
type fixedValue;
value uniform (0.0936 0 0);
}

outlet
{
type zeroGradient;
}
}
}

// ************************************************************************* //

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 0.5;

deltaT 0.0001;

writeControl timeStep;

writeInterval 20;

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.9160e-07;


// ************************************************************************* //

blockMeshDict (symmetry 10D):

/*--------------------------------*- 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 0.1;

vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009962 -0.000872)
(0.000000 0.009962 0.000872)
(2.820000 0.000000 0.000000)
(2.820000 0.009962 -0.000872)
(2.820000 0.009962 0.000872)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simplegrading (1 1 1)
);
edged
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.820000 0.010000 0)
);

boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
fixedWalls
{
type wall;
faces
(
(2 1 4 5)
);
}
front
{
type symmetry;
faces
(
(1 0 3 4)
);
}
back
{
type symmetry;
faces
(
(2 5 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}

);

mergePatchPairs
(
);

//*********************************************************************//

RESULTS OF THE ABOVE PROGRAM: Pressure and velocity distribution

  1. The above plots show pressure and velocity profiles.
  2. The pressure plots are similar to the walls and also at the center of the pipe.
  3. The velocity profile is different at different positions of the pipe.
  4. For example, the first velocity profile is plotted at the walls of the pipe and the velocity there is almost zero.
  5. whereas, at the center of the pipe, the velocity tends to be maximum.
  6. This situation applies to the rest of the angles.

blockMeshDict (wedge 10D):

/*--------------------------------*- 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 0.1;

vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009962 -0.000872)
(0.000000 0.009962 0.000872)
(2.820000 0.000000 0.000000)
(2.820000 0.009962 -0.000872)
(2.820000 0.009962 0.000872)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simplegrading (1 1 1)
);
edged
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.820000 0.010000 0)
);

boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
fixedWalls
{
type wall;
faces
(
(2 1 4 5)
);
}
front
{
type wedge;
faces
(
(1 0 3 4)
);
}
back
{
type wedge;
faces
(
(2 5 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}

);

mergePatchPairs
(
);

//*********************************************************************//

Results of the above program:

Plottings:

blockMeshDict (Symmetry 25D):

/*--------------------------------*- 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 0.1;

vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009763 -0.002164)
(0.000000 0.009763 0.002164)
(2.820000 0.000000 0.000000)
(2.820000 0.009763 -0.002164)
(2.820000 0.009763 0.002164)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simplegrading (1 1 1)
);
edged
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.820000 0.010000 0)
);

boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
fixedWalls
{
type wall;
faces
(
(2 1 4 5)
);
}
front
{
type symmetry;
faces
(
(1 0 3 4)
);
}
back
{
type symmetry;
faces
(
(2 5 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}

);

mergePatchPairs
(
);

//*********************************************************************//

Results of the above program:

Plottings:

blockMwshDict(wedge25D):

/*--------------------------------*- 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 0.1;

vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009763 -0.002164)
(0.000000 0.009763 0.002164)
(2.820000 0.000000 0.000000)
(2.820000 0.009763 -0.002164)
(2.820000 0.009763 0.002164)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simplegrading (1 1 1)
);
edged
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.820000 0.010000 0)
);

boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
fixedWalls
{
type wall;
faces
(
(2 1 4 5)
);
}
front
{
type wedge;
faces
(
(1 0 3 4)
);
}
back
{
type wedge;
faces
(
(2 5 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}

);

mergePatchPairs
(
);

//*********************************************************************//

Results of the above program:

Plottings:

blockMeshDict(symmetry 45D):

/*--------------------------------*- 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 0.1;

vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009239 -0.003827)
(0.000000 0.009239 0.003827)
(2.820000 0.000000 0.000000)
(2.820000 0.009239 -0.003827)
(2.820000 0.009239 0.003827)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simplegrading (1 1 1)
);
edged
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.820000 0.010000 0)
);

boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
fixedWalls
{
type wall;
faces
(
(2 1 4 5)
);
}
front
{
type symmetry;
faces
(
(1 0 3 4)
);
}
back
{
type symmetry;
faces
(
(2 5 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}

);

mergePatchPairs
(
);

//*********************************************************************//

Results of the above program:

Plottings:

blockMeshDict(wedge 45D):

/*--------------------------------*- 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 0.1;

vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009239 -0.003827)
(0.000000 0.009239 0.003827)
(2.820000 0.000000 0.000000)
(2.820000 0.009239 -0.003827)
(2.820000 0.009239 0.003827)
);
blocks
(
hex (0 3 4 1 0 3 5 2) (200 50 1) simplegrading (1 1 1)
);
edged
(
arc 1 2 (0 0.010000 0)
arc 4 5 (2.820000 0.010000 0)
);

boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
fixedWalls
{
type wall;
faces
(
(2 1 4 5)
);
}
front
{
type wedge;
faces
(
(1 0 3 4)
);
}
back
{
type wedge;
faces
(
(2 5 3 0)
);
}
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}

);

mergePatchPairs
(
);

//*********************************************************************//

Results of the above program:

Plottings:

Analytical Solution:

Average Velocity= 0.09373 (m/s)

Maximum Velocity= 2*(Average velocity)=

WEDGE ANGLE Kinematic Pressure MAX.VELOCITY(HP EQUATION) MAX.VELOCITY(SIMULATION) ERROR
10 DEGREE 0.0188 0.18746 0.187235150920147 0.00023
25 DEGREE 0.0188 0.18746 0.187235150920147 0.00023
45 DEGREE 0.0188 0.18746 0.187235150920147 0.00023

Conclusion:

  1. For every simulation, I have plotted two velocity profiles.
  2. As we know that the velocity at the walls of the pipe is zero.
  3. For the 25 and 45 degree angle, the distance of the first velocity profile is half of the radius i.e, 0.004981 meters from the center.
  4. And for the second velocity profile, the points lie exactly at the center.
  5. Here, from the two plotting, we can observe one thing very clearly that, the velocity of the fluid decreases as we go away from the center.
  6. At 0.004981, the velocity at the entrance fluctuates, and it gets stable as it travels further.
  7. Whereas in the second graph there are no such fluctuations, the velocity at the entrance increases gradually and stable after some distance.
  8. The pressure in all three simulations it is the same and the graph represents the decline of pressure along the length of the pipe for both symmetry and wedge type boundary conditions.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.