Project

Simulation of Flow through a pipe in OpenFoam

Topic: Simulation of flow through a pipe in OpenFoam.

Theory:

Source https://en.wikipedia.org/wiki/Entrance_length#/media/File:Development_of_fluid_flow_in_the_entrance_region_of_a_pipe.jpg

When the liquid enters the pipe, the viscous boundary layers grow up downstream, the axial flow slows down and the central flow accelerates to maintain continuity. At a distance from the inlet, called the Entrance length (Le), the velocity profile becomes constant as it achieves viscous flow. For laminar flow;

Le/D = 0.06 Re (Laminar)

The derivation of the Hagen-Poiseuille equation for laminar flow in straight, circular pipes is based on the following two assumptions;

a) The viscous property of fluid follows Newton’s law of viscosity, that is, τ=μ(du/dy),

  1. b) There is no relative motion between fluid particles and solid boundaries, that is, no slip of fluid particles at the solid boundary.

Given:

Working Fluid= Water

Density= 1000 kg/m3

Re= 2100

Absolute viscosity= 8.9*10-4

Diameter= 1cm

Calculations:

Velocity= (Re*mu)/(rho*D)= 0.1869 m/s

Length of the Pipe= 0.06* Re*D= 1.26m

Max. Velocity= 2* Vavg= 0.3738 m/s

(Taking length as 2 m)

Pressure= (32*mu*v*L)/4*D2= 0.106 N/m2

Max. Shear Stress= 2*mu*Vmax/R = 0.133 N/m2

Programs:

1.) MATLAB Program:

close all

clear all

clc

l1= '/*--------------------------------*- C++ -*----------------------------------*\';

l2= ' ========= |';

l3= ' \\ / F ield | OpenFOAM: The Open Source CFD Toolbox';

l4= ' \\ / O peration | Website: https://openfoam.org';

l5= ' \\ / A nd | Version: 7';

l6= ' \\/ M anipulation |';

l7= '\*---------------------------------------------------------------------------*/';

l8= 'FoamFile';

l9= '{ version 2.0;';

l10= ' format ascii;';

l11= ' class dictionary;';

l12= ' object blockMeshDict;}';

l13= '// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';

l14= 'convertToMeters 0.001;';

l15= 'vertices';

blockmesh= fopen('blockMeshDict1.txt','w')

fprintf(blockmesh, '%s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n',l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15);

r= 5;

th = 3;

fprintf(blockmesh, '(\n (%f %f %f)\n',2000,0,0);

fprintf(blockmesh, ' (%f %f %f)\n',2000,r*cosd(th/2),r*sind(th/2));

fprintf(blockmesh, ' (%f %f %f)\n',2000,r*cosd(th/2),-r*sind(th/2));

fprintf(blockmesh, ' (%f %f %f)\n',0,0,0);

fprintf(blockmesh, ' (%f %f %f)\n',0,r*cosd(th/2),r*sind(th/2));

fprintf(blockmesh, ' (%f %f %f)\n );',0,r*cosd(th/2),-r*sind(th/2));

fprintf(blockmesh, '\n blocks \n(\n hex (%d %d %d %d %d %d %d %d) (1 50 150) simpleGrading (1 0.1 1)\n);',0,0,1,2,3,3,4,5);

fprintf(blockmesh, '\n edges\n(\n arc %d %d(%d %d %d)\n',1,2,2000,r,0);

fprintf(blockmesh, '\n arc %d %d(%d %d %d)\n);',4,5,0,r,0);

fprintf(blockmesh, '\nboundary\n(\n');

fprintf(blockmesh, '\tInlet\n\t{\n');

fprintf(blockmesh, '\t type patch;\n');

fprintf(blockmesh, '\t faces\n\t (\n');

fprintf(blockmesh, '\t\t(3 5 4 3)\n\t );\n\t}\n\n');

fprintf(blockmesh, '\tOutlet\n\t{\n');

fprintf(blockmesh, '\t type patch;\n');

fprintf(blockmesh, '\t faces\n\t (\n');

fprintf(blockmesh, '\t\t(0 1 2 0)\n\t );\n\t}\n\n');

fprintf(blockmesh, '\tUpper\n\t{\n');

fprintf(blockmesh, '\t type wall;\n');

fprintf(blockmesh, '\t faces\n\t (\n');

fprintf(blockmesh, '\t\t(4 5 2 1)\n\t );\n\t}\n\n');

fprintf(blockmesh, '\tfront\n\t{\n');

fprintf(blockmesh, '\t type wedge;\n');

fprintf(blockmesh, '\t faces\n\t (\n');

fprintf(blockmesh, '\t\t(0 3 4 1)\n\t );\n\t}\n\n');

fprintf(blockmesh, '\tback\n\t{\n');

fprintf(blockmesh, '\t type wedge;\n');

fprintf(blockmesh, '\t faces\n\t (\n');

fprintf(blockmesh, '\t\t(0 2 5 3)\n\t );\n\t}\n\n');

fprintf(blockmesh, '\taxis\n\t{\n');

fprintf(blockmesh, '\t type empty;\n');

fprintf(blockmesh, '\t faces\n\t (\n');

fprintf(blockmesh, '\t\t(0 3 3 0)\n\t );\n\t}\n);\n');

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

fprintf(blockmesh, '\n// ************************************************************************* //');

2.) BlockMeshDict:

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

object blockMeshDict;}

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

convertToMeters 0.001;

vertices

(

(2000.000000 0.000000 0.000000)

(2000.000000 4.998287 0.130885)

(2000.000000 4.998287 -0.130885)

(0.000000 0.000000 0.000000)

(0.000000 4.998287 0.130885)

(0.000000 4.998287 -0.130885)

);

blocks

(

hex (0 0 1 2 3 3 4 5) (1 50 150) simpleGrading (1 0.1 1)

);

edges

(

arc 1 2(2000 5 0)

arc 4 5(0 5 0)

);

boundary

(

Inlet

{

type patch;

faces

(

(3 5 4 3)

);

}

Outlet

{

type patch;

faces

(

(0 1 2 0)

);

}

Upper

{

type wall;

faces

(

(4 5 2 1)

);

}

front

{

type wedge;

faces

(

(0 3 4 1)

);

}

back

{

type wedge;

faces

(

(0 2 5 3)

);

}

axis

{

type empty;

faces

(

(0 3 3 0)

);

}

);

mergePatchPairs

(

);

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

3.) Pressure:

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

{

Inlet

{

type zeroGradient;

}

Outlet

{

type fixedValue;

value uniform 0.106;

}

Upper

{

type zeroGradient;

}

front

{

type wedge;

}

back

{

type wedge;

}

axis

{

type empty;

}

}

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

4.) Velocity:

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

boundaryField

{

Inlet

{

type fixedValue;

value uniform (0.1869 0 0);

}

Outlet

{

type zeroGradient;

}

Upper

{

type noSlip;

}

front

{

type wedge;

}

back

{

type wedge;

}

axis

{

type empty;

}

}

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

5.) transportProperties:

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

location "constant";

object transportProperties;

}

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

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

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

Results:

1.

2.

3.

Graphs:

1) At x= 0.05 m

2) At x= 0.1 m



3) At x=1.26 m

4) At x= 1.9 m

It can be seen that as the flow is fully developed at 1.26 m, there is no change in Velocity graph after that. The maximum velocity achieved is 0.370166 m/s.

Also it can be shown that the velocity profile is a branch of Parabola.

Shear Stress:

For Wedge angle= 3 degree. The max. shear stress is 0.1308N/m2



Wedge angle 4 degree:

Table:

Shear Stress Velocity


Analytical 0.133 N/m2 0.3738 m/s

Simulation 0.1308N/m2 0.3701 m/s

Error 1.5 % 0.98%

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.