Challenge

Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation

In this challenge we will be simulating incompressible laminar pipe flow , for this simulation we will be using the axisymmetrical geometry with angle theta and wedge and symmetry boundary conditions for both the front and back faces as given below

also different values of theta will be

10

25

45

Also we have written a code that gives us the blockMeshDict for the required boundary condition and angle theta as given below

clear all
close all
clc

%% inputs for the blockMeshDict

% diameter of pipe
D = input('enter the diameter of pipe  ');
% radius = diameter/2
R = D/2;
% length of pipe
L = input('enter the length of pipe  ');
% wedge angle 
theta = input('enter the angle theta  ');
% boundary condition
% 1 for wedge and 2 for symmetry

bc = input('enter boundary condition(1 for wedge and 2 for symmetry)  ')
%% creating a blockMeahDict file

% filename = 'blockMeshDict';
f1 = blockMesh_generator(R, theta, L, bc);

% reynolds number - this value is specified in the question
Re = 2100;
% considering the following values for the properties of water
% density of water 
rho = 1e+3;
% dynamic viscosity 
eta = 0.001; 
% kinematic viscosity of water 
nu = eta/rho;

%%
% inlet velocity - this velocity will be given as the inlet velocity in the
% U file in the 0 folder. 
% average velocity = (Reynold number * kinematic viscosity )/diameter
v_avg = (Re * nu)/D;

% maximum velocity - to validate with our simulation results when we
% observe our results in paraFoam in terms of plots and contours.
v_max = 2* v_avg;

% total time of simulation
t = L/v_max;

% length of developing flow region
% hydrodynamic length = 0.06* reynolds number * Diameter
Lh = 0.06*Re*D;

% Hagen Poiseuille flow equation - to validate the pressure drop through the pipe length 
DeltaP = (32*eta*(L-Lh)*v_avg)/(D^2);
% the pressure in opoenfoam is kinematic pressure so we divide the static prssure with the density

and the supporting function is given below

function [f1] = blockMesh_generator(R, theta, L, bc)

if bc == 1

    f1 = fopen('blockMeshDict','w');

    fprintf(f1,'FoamFile\n');

    fprintf(f1,'{\n\tversion\t\t2.0;\n\tformat\t\tascii;\n\tclass\t\tdictionary;\n\tobject\t\tblockMeshDict;\n}\n\n');

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

    fprintf(f1,'vertices\n(\n\t(%f %f %f)\n',0,0,0);

    fprintf(f1,'\t(%f %f %f)\n',R*sind(theta/2),R*cosd(theta/2),0);
    fprintf(f1,'\t(%f %f %f)\n',-(R*sind(theta/2)),R*cosd(theta/2),0);
    fprintf(f1,'\t(%f %f %f)\n',0,0,L);
    fprintf(f1,'\t(%f %f %f)\n',R*sind(theta/2),R*cosd(theta/2),L);
    fprintf(f1,'\t(%f %f %f)\n);\n\n',-(R*sind(theta/2)),R*cosd(theta/2),L);

    fprintf(f1,'blocks\n(\n');
    fprintf(f1,'\thex (0 3 4 1 0 3 5 2) (300 20 1) simpleGrading (1 0.2 1)\n);\n\n');

    fprintf(f1,'edges\n(\n');
    fprintf(f1,'\tarc 1 2 (0 %f 0)',R);
    fprintf(f1,'\n\tarc 4 5 (0 %f %f)\n);\n\n',R,L);

    fprintf(f1,'boundary\n(\n');
    fprintf(f1,'\tinlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(0 1 2 0)\n\t\t);\n\t}\n');
    fprintf(f1,'\toutlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(3 5 4 3)\n\t\t);\n\t}\n');
    fprintf(f1,'\tnoSlipWall\n\t{\n\t\ttype wall;\n\t\tfaces\n\t\t(\n\t\t\t(1 4 5 2)\n\t\t);\n\t}\n');
    fprintf(f1,'\tfront\n\t{\n\t\ttype wedge;\n\t\tfaces\n\t\t(\n\t\t\t(0 3 4 1)\n\t\t);\n\t}\n');
    fprintf(f1,'\tback\n\t{\n\t\ttype wedge;\n\t\tfaces\n\t\t(\n\t\t\t(0 2 5 3)\n\t\t);\n\t}\n');
    fprintf(f1,'\taxis\n\t{\n\t\ttype empty;\n\t\tfaces\n\t\t(\n\t\t\t(0 3 3 0)\n\t\t);\n\t}\n');
    fprintf(f1,');\n\n');
    fprintf(f1,'mergePatchPairs\n(\n);\n');

    fclose(f1);
end

if bc == 2
        f1 = fopen('blockMeshDict','w');

    fprintf(f1,'FoamFile\n');

    fprintf(f1,'{\n\tversion\t\t2.0;\n\tformat\t\tascii;\n\tclass\t\tdictionary;\n\tobject\t\tblockMeshDict;\n}\n\n');

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

    fprintf(f1,'vertices\n(\n\t(%f %f %f)\n',0,0,0);

    fprintf(f1,'\t(%f %f %f)\n',R*sind(theta/2),R*cosd(theta/2),0);
    fprintf(f1,'\t(%f %f %f)\n',-(R*sind(theta/2)),R*cosd(theta/2),0);
    fprintf(f1,'\t(%f %f %f)\n',0,0,L);
    fprintf(f1,'\t(%f %f %f)\n',R*sind(theta/2),R*cosd(theta/2),L);
    fprintf(f1,'\t(%f %f %f)\n);\n\n',-(R*sind(theta/2)),R*cosd(theta/2),L);

    fprintf(f1,'blocks\n(\n');
    fprintf(f1,'\thex (0 3 4 1 0 3 5 2) (300 20 1) simpleGrading (1 0.2 1)\n);\n\n');

    fprintf(f1,'edges\n(\n');
    fprintf(f1,'\tarc 1 2 (0 %f 0)',R);
    fprintf(f1,'\n\tarc 4 5 (0 %f %f)\n);\n\n',R,L);

    fprintf(f1,'boundary\n(\n');
    fprintf(f1,'\tinlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(0 1 2 0)\n\t\t);\n\t}\n');
    fprintf(f1,'\toutlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(3 5 4 3)\n\t\t);\n\t}\n');
    fprintf(f1,'\tnoSlipWall\n\t{\n\t\ttype wall;\n\t\tfaces\n\t\t(\n\t\t\t(1 4 5 2)\n\t\t);\n\t}\n');
    fprintf(f1,'\tfront\n\t{\n\t\ttype symmetry;\n\t\tfaces\n\t\t(\n\t\t\t(0 3 4 1)\n\t\t);\n\t}\n');
    fprintf(f1,'\tback\n\t{\n\t\ttype symmetry;\n\t\tfaces\n\t\t(\n\t\t\t(0 2 5 3)\n\t\t);\n\t}\n');
    fprintf(f1,'\taxis\n\t{\n\t\ttype empty;\n\t\tfaces\n\t\t(\n\t\t\t(0 3 3 0)\n\t\t);\n\t}\n');
    fprintf(f1,');\n\n');
    fprintf(f1,'mergePatchPairs\n(\n);\n');

    fclose(f1);
end

end

we get the required blockMeshDict by running the above code.

Now we willbe setting the transportProperties file where we edit the value of nu as 1e-6.

then set the inital conditions in the U and p file that re inside the folder named '0'. we keep the inital velocity as 0.105 m/s with fixed value at the inlet and 0 gauge pressure with fixed value at the outlet. lastly we change the runtime to 14.5 seconds so that a stedy state is reached. all the calculation for the above value is done in the code given above.

RESULTS:

Wedge

Angle = 10:

we will first see the results of the wedge boundary condition with 10 degree as the value of angle theta.

the variation of the velocity with the length of pipe is given below

we can see that a flow is in developing state for the length of pipe upto 2.5m then the velocity remains constant and there the flow is fully developed.

here we see that the velocity stop increseing after 2.53 m so it is the hydrodynamic length. and the maximum velocity is 0.0205757m/s

now we will be seening the pressure drop for the region of fully developed flow

the presssure drop is 0.0040156 in the region of fully developed flow

according to our calculation the maximum velocity and pressure drop should be

now calculating the error in our values

for velocity

`sf"error in velocity" = (0.21-0.2058)/0.21= 0.020247`

the error is 2% that is acceptable

for pressure drop

`sf"error in pressure" = (0.004-0.040156)/0.04 = 0.0039`

the error for prrssure drop is 0.39% that is acceptable

Now to validate our flow profile we will plot the velocity over the diameter in a fully developed region

the velocity profile is parabolic that is correct.

Now to validate the shear stress and wall shear stress we willbe ploting tau(shear stress over the radius in a fully developed flow region

the maximum value of shear stress is 0.0407598 and the wall shear stress can be seen as the shear stress values reducing near the wall.

the error in the max shear is

`sf"error in shear stress" = (0.042- 0.0408)/0.042 = 0.0285`

the error 2.85 % which is in acceptable range.

Also here we can see that we have compared the calculated maximum value at the wall with the value that is actually away from the wall in the numerical solution this is because of the meshing that is not fine enough to calculate the exact values at the wall.

Angle = 25:

we will first see the results of the wedge boundary condition with 25 degree as the value of angle theta.

the variation of the velocity with the length of pipe is given below

we can see that a flow is in developing state for the length of pipe upto 2.5m then the velocity remains constant and there the flow is fully developed.

here we see that the velocity stop increseing after 2.54 m so it is the hydrodynamic length. and the maximum velocity is 0.0206173m/s

now we will be seening the pressure drop for the region of fully developed flow

the presssure drop is 0.00408574 in the region of fully developed flow

according to our calculation the maximum velocity and pressure drop should be

now calculating the error in our values

for velocity

`sf"error in velocity" = (0.21-0.2061)/0.21= 0.0185`

the error is 1.85% that is acceptable

for pressure drop

`sf"error in pressure" = (0.004-0.004086)/0.04 = 0.0215`

the error for prrssure drop is 2.15% that is acceptable

Now to validate our flow profile we will plot the velocity over the diameter in a fully developed region

the velocity profile is parabolic that is correct.

Now to validate the shear stress and wall shear stress we willbe ploting tau(shear stress over the radius in a fully developed flow region

the maximum value of shear stress is 0.0415076 and the wall shear stress can be seen as the shear stress values reducing near the wall.

the error in the max shear is

`sf"error in shear stress" = (0.042- 0.0415)/0.042 = 0.0119`

the error 1.19% which is in acceptable range.

Also here we can see that we have compared the calculated maximum value at the wall with the value that is actually away from the wall in the numerical solution this is because of the meshing that is not fine enough to calculate the exact values at the wall.

Angle = 45:

we will first see the results of the wedge boundary condition with 45 degree as the value of angle theta.

the variation of the velocity with the length of pipe is given below

we can see that a flow is in developing state for the length of pipe upto 2.5m then the velocity remains constant and there the flow is fully developed.

here we see that the velocity stop increseing after 2.455 m so it is the hydrodynamic length. and the maximum velocity is 0.207077 m/s

now we will be seening the pressure drop for the region of fully developed flow

the presssure drop is 0.00538 in the region of fully developed flow

according to our calculation the maximum velocity and pressure drop should be

now calculating the error in our values

for velocity

`sf"error in velocity" = (0.21-0.207077)/0.21= 0.0139`

the error is 1.39% that is acceptable

for pressure drop

`sf"error in pressure" = (0.004-0.00538)/0.04 = 0.345`

the error for prrssure drop is 34.5% that is not acceptable

Now to validate our flow profile we will plot the velocity over the diameter in a fully developed region

the velocity profile is parabolic that is correct.

Now to validate the shear stress and wall shear stress we willbe ploting tau(shear stress over the radius in a fully developed flow region

the maximum value of shear stress is 0.043650 and the wall shear stress can be seen as the shear stress values reducing near the wall.

the error in the max shear is

`sf"error in shear stress" = (0.042- 0.04365)/0.042 = 0.0393`

the error 3.93% which is in acceptable range.

Also here we can see that we have compared the calculated maximum value at the wall with the value that is actually away from the wall in the numerical solution this is because of the meshing that is not fine enough to calculate the exact values at the wall.

Symmetry

Angle = 10:

we will first see the results of the symmetry boundary condition with 10 degree as the value of angle theta.

the variation of the velocity with the length of pipe is given below

we can see that a flow is in developing state for the length of pipe upto 2.5m then the velocity remains constant and there the flow is fully developed.

here we see that the velocity stop increseing after 2.45 m so it is the hydrodynamic length. and the maximum velocity is 0.0205607m/s

now we will be seening the pressure drop for the region of fully developed flow

the presssure drop is 0.00410286 in the region of fully developed flow

according to our calculation the maximum velocity and pressure drop should be

now calculating the error in our values

for velocity

`sf"error in velocity" = (0.21-0.2056)/0.21= 0.02095`

the error is 2.095% that is acceptable

for pressure drop

`sf"error in pressure" = (0.004-0.0410286)/0.04 = 0.0025`

the error for prrssure drop is 2.5% that is acceptable

Now to validate our flow profile we will plot the velocity over the diameter in a fully developed region

the velocity profile is parabolic that is correct.

Now to validate the shear stress and wall shear stress we willbe ploting tau(shear stress over the radius in a fully developed flow region

the maximum value of shear stress is 0.0407221 and the wall shear stress can be seen as the shear stress values reducing near the wall.

the error in the max shear is

`sf"error in shear stress" = (0.042- 0.0407)/0.042 = 0.0309`

the error 3.09% which is in acceptable range.

Also here we can see that we have compared the calculated maximum value at the wall with the value that is actually away from the wall in the numerical solution this is because of the meshing that is not fine enough to calculate the exact values at the wall.

Angle = 25:

we will first see the results of the symmetry boundary condition with 25 degree as the value of angle theta.

the variation of the velocity with the length of pipe is given below

we can see that a flow is in developing state for the length of pipe upto 2.5m then the velocity remains constant and there the flow is fully developed.

here we see that the velocity stop increseing after 2.5 m so it is the hydrodynamic length. and the maximum velocity is 0.0206161m/s

now we will be seening the pressure drop for the region of fully developed flow

the presssure drop is 0.00444112 in the region of fully developed flow

according to our calculation the maximum velocity and pressure drop should be

now calculating the error in our values

for velocity

`sf"error in velocity" = (0.21-0.206161)/0.21= 0.0182`

the error is 1.82% that is acceptable

for pressure drop

`sf"error in pressure" = (0.004-0.00444)/0.04 = 0.11`

the error for prrssure drop is 11% that is not acceptable

Now to validate our flow profile we will plot the velocity over the diameter in a fully developed region

the velocity profile is parabolic that is correct.

Now to validate the shear stress and wall shear stress we willbe ploting tau(shear stress over the radius in a fully developed flow region

the maximum value of shear stress is 0.041531 and the wall shear stress can be seen as the shear stress values reducing near the wall.

the error in the max shear is

`sf"error in shear stress" = (0.042- 0.04153)/0.042 = 0.01119`

the error 1.11% which is in acceptable range.

Also here we can see that we have compared the calculated maximum value at the wall with the value that is actually away from the wall in the numerical solution this is because of the meshing that is not fine enough to calculate the exact values at the wall.

Angle = 45:

we will first see the results of the symmetry boundary condition with 45 degree as the value of angle theta.

the variation of the velocity with the length of pipe is given below

we can see that a flow is in developing state for the length of pipe upto 2.5m then the velocity remains constant and there the flow is fully developed.

here we see that the velocity stop increseing after 2.54 m so it is the hydrodynamic length. and the maximum velocity is 0.0206173m/s

now we will be seening the pressure drop for the region of fully developed flow

the presssure drop is 0.00474463 in the region of fully developed flow

according to our calculation the maximum velocity and pressure drop should be

now calculating the error in our values

for velocity

`sf"error in velocity" = (0.21-0.206173)/0.21= 0.0182`

the error is 1.82% that is acceptable

for pressure drop

`sf"error in pressure" = (0.004-0.004744)/0.04 = 0.186`

the error for prrssure drop is 18.6% that is not acceptable

Now to validate our flow profile we will plot the velocity over the diameter in a fully developed region

the velocity profile is parabolic that is correct.

Now to validate the shear stress and wall shear stress we willbe ploting tau(shear stress over the radius in a fully developed flow region

the maximum value of shear stress is 0.0437005 and the wall shear stress can be seen as the shear stress values reducing near the wall.

the error in the max shear is

`sf"error in shear stress" = (0.042- 0.0437)/0.042 = 0.04047`

the error 4.04% which is in acceptable range.

Also here we can see that we have compared the calculated maximum value at the wall with the value that is actually away from the wall in the numerical solution this is because of the meshing that is not fine enough to calculate the exact values at the wall.

From the above results we can see that the pressure drop value of our simulation with angles 45 degree is have a very large error that is not acceptable but as the angles decreases the error drops. also the error for the wedge is higher as compared to symmetry when the angle is 45. and for smaller angle 10 the error is less for wedge boundar than compared to symmetry boundary conditions.

So from here we can say that when we have to simulate for a smaller angles we will be using wedge and for larger angles we can use symmetry

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.