Challenge

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

Objective : To Simulate the incomressible laminar flow through a pipe using OpenFoam

  1. Validate Hydro-dynamic length with the numerical result
  2. Validate the fully developed flow velocity profile with its analytical profile
  3. Validate maximum velocity and pressured drop for fully developed flow
  4. Post-process Shear stress and validate wall shear stress for fully developed flow
  5. To validate the results with the Hagen- Poiseuille's equations for the fully developed flow.
  6. Use both symmetry and wedge boundary conditions and validate the results

Angles to test:

  • `10degree`
  • `25degree`
  • `45degree`

Procedure :

  1. Edit the matlab code and input the above mentioned angle and change the BC
  2. After generating the blockmesh dict file we make the appropriate BC changes in the OpenFoam
  3. Run the simulation and plot then neccesary graphs at Wedge angles . .

Matlab Code : using Symmetry Bc ( `10degree` wedge angle )

clear all
close all
clc

%Inputs
Re = input('Renolds Number = ');
D = input('Diameter of the pipe =');
L = 0.05*Re*D;%entry length of the pipe
L_p  = L+0.3;%total length of the pipe
r = D/2; %radius of the pipe 
theta = input('Angle of the wedge =');
mu = input('Dynamic viscosity =');
rho = input('Density =');

%Hagen Poiseuille flow equations

v_avg = (Re*mu)/(rho*D);
v_max = 2*(v_avg);
del_p = (8*mu*L_p*v_avg)/(r^2);
P = del_p/rho;
kv = mu/rho;


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


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='\*---------------------------------------------------------------------------*/';

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{\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');
header8='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
fprintf(f1, '%s\n\n',header8);

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_p,0,0);
fprintf(f1, '\t (%d %d %d)\n',L_p,r*cosd(theta/2),r*sind(theta/2));
fprintf(f1, '\t (%d %d %d)\n',L_p,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 4 3 0 2 5 3) (%d %d %d)', 30,300,1);
fprintf(f1, 'SimpleGrading (1 1 1)\n\n');
fprintf(f1, ');\n\n');

fprintf(f1, 'edges\n');
fprintf(f1, '(\n');
fprintf(f1, '\t arc %d %d (%d %d %d)\n', 1,2,0,r,0);
fprintf(f1, '\t arc %d %d (%d %d %d)\n',4,5,L_p,r,0);
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 (0 1 2 0)\n');
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 (3 5 4 3)\n');
fprintf(f1, '\t\t );\n');
fprintf(f1, '\t }\n');
 
fprintf(f1, '\t top \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 (1 4 5 2)\n');
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 (0 3 4 1)\n');
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 (0 2 5 3)\n');
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 (0 3 3 0)\n');
fprintf(f1, '\t\t );\n');
fprintf(f1, '\t }\n');
fprintf(f1, '); \n\n');

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

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

fclose(f1);

BlockMeshDict

/*--------------------------------*- 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 9.961947e-03 8.715574e-04)
	 (0 9.961947e-03 -8.715574e-04)
	 (2.400000e+00 0 0)
	 (2.400000e+00 9.961947e-03 8.715574e-04)
	 (2.400000e+00 9.961947e-03 -8.715574e-04)
);

blocks
(
	 hex (0 1 4 3 0 2 5 3) (30 300 1)SimpleGrading (1 1 1)

);

edges
(
	 arc 1 2 (0 1.000000e-02 0)
	 arc 4 5 (2.400000e+00 1.000000e-02 0)
);

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

mergePatchPairs
(
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Pressure BC

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

    
    axis
    {
        type            empty;
    }

    top
     {
        type            zeroGradient;
    }

    front
     {
        type            symmetry;
    }

    back
     {
        type            symmetry;
    }
}

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

Velocity BC

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

    outlet
    {
        type            zeroGradient;
    }

    
    axis
    {
        type            empty;
    }

    top
     {
        type            noSlip;
    }

    front
     {
        type            symmetry;
    }

    back
     {
        type            symmetry;
    }
}

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

Results

  1. Shear Stress Variation
Wedge BC (`10degree`) Symmetry BC (`10degree`)

Wedge BC (`25degree`) Symmetry BC (`25degree`)

Wedge BC (`45degree`) Symmetry BC (`45degree`)


2. Velocity variation

Wedge BC (`10degree`) Symmetry BC (`10degree`)

Wedge BC (`25degree`) Symmetry BC (`25degree`)

Wedge BC (`45degree`) Symmetry BC (`45degree`)

3. Pressrue drop variation

Wedge BC (`10degree`) Symmetry BC (`10degree`)

Wedge BC (`25degree`) Symmetry BC (`25degree`)

Wedge BC (`45degree`) Symmetry BC (`45degree`)

Validation

Maximum velocity

The maximum velocity obtained from the graph is 2.1m/s

Numerical Analytical
2.1m/s 2.108m/s

Hydro Dynamic Length

At x = 0.5 At x = 2.3

We can observe from the velocity profiles at different locations along x -axis within the Hydrodynamic entrance length the velocity profile is not fully developed and at x = 2.3 (Hydrodynamicaly fully developed region) the velocity attains it maximum as calculated by Hagen- Poiseuille's equations.Analytical the fully developed velocity profile is attained only after x = 2.1 m

Wall shear stress

Shear Stress is maximum near the wall because of the friction , and reduces as we move away from the wall

Differences between Boundary conditons

The symmetry BC considers the mesh as 3D and the calculation is done along all 3 axes. This also increases the compitational time . The results are not changing as we change the BC's

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.