Project

Simulation of Flow across a pipe in OpenFOAM - Symmetry vs Wedge

AIM:

  • 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.

GIVEN:

  • Reynolds number based on pipe diameter and inlet velocity should be 2100
  • Working fluid - water
  • You need to calculate the length of the pipe
    • Calculate length of the pipe using the entry length formula for laminar flow through a pipe
    • Show that entry length is sufficient to produce a fully developed flow. You will have to compare velocity profiles at different positions along the length of the pipe.
  • Solver - icoFOAM

VALUES:

Reynolds number, Re = 2100

Diameter of the pipe, d = 0.010 m

Density of fluid at 27 degrees, rho = 997 kg/m^3

Dynamic viscosity, mu = 0.000852 kg / ms

Angle = 2 degrees

FORMULAS USED:

Entry length, l = 0.06 Re * d

Kinematic viscosity, nu = mu / rho

velocity, v = (nu * Re) / d

maximum velocity, Vmax = 2 * v

Pressure drop, p = 32 * mu * l * v / d ^ 2

Kinematic pressure, Pk = p / rho

CODE:

% initial values
Re = 2100; %Reynolds numbr
d = 0.01; %diameter in meters
l = 0.06 * Re * d; % entry length in meters
theta = input(\'Enter angle\'); %angle of wedge in degrees
r = d / 2; %radius iin metre
cell_x = 25; %number of cells in x axis
cell_y = 1; %number of cells in y axis
cell_z = 500; %number of cells in z axis
gf_x = 0.1; %grading factor along x axis
gf_y = 1; %grading factor along y axis
gf_z = 10; %grading factor along z axis
y = r*cosd(theta/2);
z = r*sind(theta/2);

%properties of water at 27 degrees celcius
rho = 997; %density
mu = 0.000852; %dynamic viscosity
nu = mu / rho; %kinematic viscosity

%analytical solution
vel = nu * Re / d; %velocity in m/s
vmax = 2 * vel; %maximum velocity
dp = (32 * mu * l * vel )/ (d^2); %pressure change
dp_k = dp / rho; %kinematic pressure

text1 = \'/*--------------------------------*- C++ -*----------------------------------*\\\';
text2 = \'  =========                 |                                                  \';
text3 = \'  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox            \';
text4 = \'   \\\\    /   O peration     | Website:  https://openfoam.org                   \';
text5 = \'    \\\\  /    A nd           | Version:  6                                      \';
text6 = \'     \\\\/     M anipulation  |                                                  \';
text7 = \'\\*---------------------------------------------------------------------------*/\';

bmd = fopen(\'blockMeshDict\');
fprintf(bmd,\'%s \\n\',text1);
fprintf(bmd,\'%s \\n\',text2);
fprintf(bmd,\'%s \\n\',text3);
fprintf(bmd,\'%s \\n\',text4);
fprintf(bmd,\'%s \\n\',text5);
fprintf(bmd,\'%s \\n\',text6);
fprintf(bmd,\'%s \\n\',text7);
fprintf(bmd,\'FoamFile \\n{\\n    version     2.0; \\n    format      ascii; \\n    class       dictionary; \\n    object      blockMeshDict;\\n}\\n\');
fprintf(bmd,\'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\\n\\n\');
fprintf(bmd,\'convertToMeters 1;\\n\\n\');
fprintf(bmd,\'vertices\\n(\\n\');
fprintf(bmd,\'\\t (%f %f %f)\\n\',0,0,0);%point 0
fprintf(bmd,\'\\t (%f %f %f)\\n\',0,y,-z);%point 1 
fprintf(bmd,\'\\t (%f %f %f)\\n\',0,y,z);%point 2
fprintf(bmd,\'\\t (%f %f %f)\\n\',l,0,0);%point 3
fprintf(bmd,\'\\t (%f %f %f)\\n\',l,y,-z);%point 4
fprintf(bmd,\'\\t (%f %f %f)\\n );\\n\\n\',l,y,z);%point 5
fprintf(bmd,\'blocks \\n(\\n\');
fprintf(bmd,\'hex (0 1 2 0 3 4 5 3) (%.0f %.0f %.0f) simpleGrading(%.1f %.1f %.1f)\\n );\\n\\n\',cell_x,cell_y,cell_z,gf_x,gf_y,gf_z);
fprintf(bmd,\'edges\\n(\\n\');
fprintf(bmd,\'\\tarc 1 2 (0 %f 0)\\n\\tarc 4 5 (%f %f 0)\\n);\\n\',r,l,r);
fprintf(bmd,\'boundary \\n(\\n\');
fprintf(bmd,\'\\tinlet\\n\\t{\\n\\t\\ttype patch;\\n\\t\\tfaces\\n\\t\\t(\\n\\t\\t\\t(0 2 1 0)\\n\\t\\t);\\n\\t}\');
fprintf(bmd,\'\\n\\toutlet\\n\\t{\\n\\t\\ttype patch;\\n\\t\\tfaces\\n\\t\\t(\\n\\t\\t\\t(3 4 5 3)\\n\\t\\t);\\n\\t}\');
fprintf(bmd,\'\\n\\ttopWall\\n\\t{\\n\\t\\ttype wall;\\n\\t\\tfaces\\n\\t\\t(\\n\\t\\t\\t(1 2 5 4)\\n\\t\\t);\\n\\t}\');
fprintf(bmd,\'\\n\\tbottomWall\\n\\t{\\n\\t\\ttype wall;\\n\\t\\tfaces\\n\\t\\t(\\n\\t\\t\\t(0 3 3 0)\\n\\t\\t);\\n\\t}\');
fprintf(bmd,\'\\n\\tfrontWedge\\n\\t{\\n\\t\\ttype symmetry;\\n\\t\\tfaces\\n\\t\\t(\\n\\t\\t\\t(0 3 5 2)\\n\\t\\t);\\n\\t}\');
fprintf(bmd,\'\\n\\tbackWedge\\n\\t{\\n\\t\\ttype symmetry;\\n\\t\\tfaces\\n\\t\\t(\\n\\t\\t\\t(0 1 4 3)\\n\\t\\t);\\n\\t}\\n);\\n\\n\');
fprintf(bmd,\'mergePatchPairs\\n(\\n);\\n\\n\');
fprintf(bmd,\'// ************************************************************************* //\');
fclose(bmd);

P FILE:

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  6
     \\\\/     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;
    }
    topWall
    {
        type            zeroGradient;
    }
    bottomWall
    {
        type            empty;
    }
    frontWedge
    {
    type		symmetry;
    }
    backWedge
    {
    type		symmetry;
    }
}

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

U FILE:

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  6
     \\\\/     M anipulation  |
\\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0.1873 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value           uniform (0.1873 0 0);
    }
    outlet
    {
        type            zeroGradient;
    }
    topWall
    {
        type            noSlip;
    }
    bottomWall
    {
        type            empty;
    }
    frontWedge
    {
        type            symmetry;
    }
    backWedge
    {
        type            symmetry;
    }
}

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

TRANSPORT PROPERTIES:

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  6
     \\\\/     M anipulation  |
\\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    \"constant\";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu              [0 2 -1 0 0 0 0] 8.917e-7;


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

BLOCKMESHDICT FOR 10 DEGREES:

/*--------------------------------*- C++ -*----------------------------------*\\ 
  =========                 |                                                  
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox            
   \\\\    /   O peration     | Website:  https://openfoam.org                   
    \\\\  /    A nd           | Version:  6                      
     \\\\/     M anipulation  |                                   
\\*---------------------------------------------------------------------------*/ 
FoamFile 
{
    version     2.0; 
    format      ascii; 
    class       dictionary; 
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices
(
	 (0.000000 0.000000 0.000000)
	 (0.000000 0.004981 -0.000435)
	 (0.000000 0.004981 0.000435)
	 (1.260000 0.000000 0.000000)
	 (1.260000 0.004981 -0.000435)
	 (1.260000 0.004981 0.000435)
 );

blocks 
(
hex (0 1 2 0 3 4 5 3) (25 1 500) simpleGrading (0.1 1.0 10.0)
 );

edges
(
	arc 1 2 (0 0.005000 0)
	arc 4 5 (1.260000 0.005000 0)
 );
boundary 
(
	inlet
	{
		type patch;
		faces
		(
			(0 2 1 0)
		);
	}
	outlet
	{
		type patch;
		faces
		(
			(3 4 5 3)
		);
	}
	topWall
	{
		type wall;
		faces
		(
			(1 2 5 4)
		);
	}
	bottomWall
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	frontWedge
	{
		type symmetry;
		faces
		(
			(0 3 5 2)
		);
	}
	backWedge
	{
		type symmetry;
		faces
		(
			(0 1 4 3)
		);
	}
 );

mergePatchPairs
(
 );

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

BLOCKMESHDICT FOR 25 DEGREES:

/*--------------------------------*- C++ -*----------------------------------*\\ 
  =========                 |                                                  
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox            
   \\\\    /   O peration     | Website:  https://openfoam.org                   
    \\\\  /    A nd           | Version:  6                      
     \\\\/     M anipulation  |                                   
\\*---------------------------------------------------------------------------*/ 
FoamFile 
{
    version     2.0; 
    format      ascii; 
    class       dictionary; 
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices
(
	 (0.000000 0.000000 0.000000)
	 (0.000000 0.024407 -0.005411)
	 (0.000000 0.024407 0.005411)
	 (1.260000 0.000000 0.000000)
	 (1.260000 0.024407 -0.005411)
	 (1.260000 0.024407 0.005411)
 );

blocks 
(
hex (0 1 2 0 3 4 5 3) (25 1 500) simpleGrading (0.1 1.0 10.0)
 );

edges
(
	arc 1 2 (0 0.005000 0)
	arc 4 5 (1.260000 0.005000 0)
 );
boundary 
(
	inlet
	{
		type patch;
		faces
		(
			(0 2 1 0)
		);
	}
	outlet
	{
		type patch;
		faces
		(
			(3 4 5 3)
		);
	}
	topWall
	{
		type wall;
		faces
		(
			(1 2 5 4)
		);
	}
	bottomWall
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	frontWedge
	{
		type symmetry;
		faces
		(
			(0 3 5 2)
		);
	}
	backWedge
	{
		type symmetry;
		faces
		(
			(0 1 4 3)
		);
	}
 );

mergePatchPairs
(
 );

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

BLOCKMESHDICT FOR 45 DEGREES:

/*--------------------------------*- C++ -*----------------------------------*\\ 
  =========                 |                                                  
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox            
   \\\\    /   O peration     | Website:  https://openfoam.org                   
    \\\\  /    A nd           | Version:  6                      
     \\\\/     M anipulation  |                                   
\\*---------------------------------------------------------------------------*/ 
FoamFile 
{
    version     2.0; 
    format      ascii; 
    class       dictionary; 
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices
(
	 (0.000000 0.000000 0.000000)
	 (0.000000 0.023097 -0.009567)
	 (0.000000 0.023097 0.009567)
	 (1.260000 0.000000 0.000000)
	 (1.260000 0.023097 -0.009567)
	 (1.260000 0.023097 0.009567)
 );

blocks 
(
hex (0 1 2 0 3 4 5 3) (25 1 500) simpleGrading (0.1 1.0 10.0)
 );

edges
(
	arc 1 2 (0 0.005000 0)
	arc 4 5 (1.260000 0.005000 0)
 );
boundary 
(
	inlet
	{
		type patch;
		faces
		(
			(0 2 1 0)
		);
	}
	outlet
	{
		type patch;
		faces
		(
			(3 4 5 3)
		);
	}
	topWall
	{
		type wall;
		faces
		(
			(1 2 5 4)
		);
	}
	bottomWall
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	frontWedge
	{
		type symmetry;
		faces
		(
			(0 3 5 2)
		);
	}
	backWedge
	{
		type symmetry;
		faces
		(
			(0 1 4 3)
		);
	}
 );

mergePatchPairs
(
 );

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

CONTROLDICT:

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  6
     \\\\/     M anipulation  |
\\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    \"system\";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     icoFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         10;

deltaT          0.005;

writeControl    timeStep;

writeInterval   100;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

FVSCHEMES:

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  6
     \\\\/     M anipulation  |
\\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    \"system\";
    object      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default         Euler;
}

gradSchemes
{
    default         Gauss linear;
    grad(p)	    Gauss linear;
}

divSchemes
{
    default         none;
    div(phi,U)      Gauss linear;
}

laplacianSchemes
{
    default         Gauss linear orthogonal;
}

interpolationSchemes
{
    default         linear;
}

snGradSchemes
{
    default         orthogonal;
}


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

FVSOLUTION:

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  6
     \\\\/     M anipulation  |
\\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    \"system\";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    p
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance       1e-06;
        relTol          0.05;
    }

    pFinal
    {
        $p;
        relTol          0;
    }

    U
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance       1e-07;
        relTol          0;
    }
}

PISO
{
    nCorrectors     2;
    nNonOrthogonalCorrectors 0;
    pRefCell	    0;
    pRefValue       0;
}


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

IMAGES:

10 DEGREE MESH:

\"\"

10 DEGREE CONTOUR PLOT:

\"\"

10 DEGREE Y DISTANCE VS VELOCITY PLOT:

\"\"

25 DEGREES MESH:

\"\"

25 DEGREES VELOCITY CONTOUR PLOT:

\"\"

25 DEGREES Y DISTANCE VS VELOCITY PLOT:

\"\"

45 DEGREES MESH:

\"\"

45 DEGREES VELOCITY CONTOUR PLOT:

\"\"

45 DEGREES Y DISTANCE VS VELOCITY PLOT:

\"\"

RESULTS:

Comparing the maximum velocity in each case

  • Analytical : 0.35891675 m/s
  • 2 degrees pipe : 0.365927 m/s
  • 10 degrees pipe: 0.351374 m/s
  • 25 degrees pipe : 0.226811 m/s
  • 45 degrees pipe : 0.229535 m/s

Comparing Kinetic Pressure in each case

  • Analytical : 0.121069453 Pa
  • 2 degrees pipe : 0.0141684 Pa
  • 10 degrees pipe : 0.01362543 Pa
  • 25 degrees pipe : 0.00133409 Pa
  • 45 degrees pipe : 0.00127526 Pa

CONCLUSION:

  • The parabolic profile is maintained at all wedge / symmetry angles.
  • The velocity is almost constant in all wedge angle.
  • The pressure drop keeps increasing with increase in angle.
  • The wedge boundary condition saves time compared to symmetry boundary condition
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.