Challenge

Week 11 - Simulation of Flow through a pipe in OpenFoam

SIMULATION OF FLOW THROUGH PIPE IN OPENFOAM

Objective:

  • To simulate an axi-symmetric flow by applying the wedge boundary condition.
  • Validate the result with Hagen - Poiseuille's equation for fully developed flow.
  • Write Code in Matlab to automate the generation of blockMeshDict File.
  • Validate Hydro-dynamic length with the numerical result.
  • Validate the fully developed flow velocity profile with its analytical profile
  • validate Maximum velocity and Pressure drop for fully developed flow.
  • Post-process Shear stress and validate wall shear stress for fully developed flow.

Hint:

1. Wedge angle Should be less than 5°.

2. Assume Pipe Diameter.

Physical Properties:-

The water is considering a working fluid.

  • Diameter of the Pipe (D) = 0.02 m
  • Wedge angle (θ) = 3°
  • Reynolds Number (Re) = 2100
  • Density of the water (ρ) = `998.2kg//m^3`
  • Dynamic viscosity of water `(mu)` = `1.005 xx 10^-3 Pa.s`
  • Kinematic viscosity of water `(nu)`= `1.002 xx 10^-6 m^2//s`

Hagen - Poiseuille equation:-

The Hagen - Poiseuille equation is a physical law that gives the pressure drop in a fluid flow through a long cylindrical pipe. The assumption of the equation is that the flow is laminar viscous and incompressible and the flow is through a constant circular cross-section that is substantially longer than its diameter. The equation is also known as the Hagen -Poiseuille law.

`Q = (DeltaPpiD^4)/(128muL)`

Laminar Flow:-

In laminar flow, the motion of the particles of the fluid is very orderly with particles close to a solid surface moving in straight lines parallel to that surface. Laminar flow is a flow regime characterized by high momentum diffusion and low momentum convection.

Reynolds number:-

The ratio of inertia forces to viscous force in the fluid. This ratio is called the Reynolds number and is expressed for internal flow in a circular pipe as

`Re = (rho V_(avg)D)/(mu)`

Under the most practical conditions, the flow in a circular pipe is

`Re <= 2300` The flow is Laminar flow

`Re >= 4000` The Turbulent flow

`2300 <= Re <= 4000` The flow is Transitional flow

Hydrodynamic entry region.

The region of the flow in which the effects of the viscous shearing forces caused by fluid viscosity are felt is called the velocity boundary layer.

The hypothetical boundary surface divides the flow in a pipe into two regions. the boundary layer region, in which the viscous effects and the velocity changes are significant, and the velocity changes are significant, and the velocity changes are significant, and the rotational flow region, in which the frictional effects are negligible and the velocity remains essentially constant in the radial direction.

The thickness of this boundary layer increases in the flow direction until the boundary layer reaches the pipe center and thus fills the entire pipe. The region from the pipe inlet to the point at which the velocity profile is fully developed is called the hydrodynamic entrance region, and the length of this region is called the hydrodynamic entry length.

`L_(h,"laminar")/(D) = 0.05 Re`

The region beyond the entrance region in which the velocity profile is fully developed and remains unchanged is called the hydrodynamically fully developed region. The flow is said to be fully developed when the normalized temperature profile remains unchanged as well.

The velocity profile in the fully developed region is parabolic in laminar flow and much flatter in turbulent flow due to eddy motion and more vigorous mixing in the radial direction.

The shear stress at the pipe wall `tau_w`is related to the slope of the velocity profile at the surface. The velocity profile remains unchanged in the hydrodynamically fully developed region, the wall shear stress also remains constant in that region.

1. Velocity Average:

`Re = (rhoDV_(avg))/(mu)`

`2100 = (998.2 xx 0.02 xx V_(avg))/ (1.005 xx 10^-3)`

`V_(avg) = 0.1057 (m//s^-2)`

2. Maximum Velocity:

`U_max = 2.V_(avg) => U_max = 2 xx 0.1057`

`U_max = 0.2114 m//s^-2`

3. Hydrodynamic Entrance Length of the Pipe:

`L_h,("laminar") ~= 0.05*Re*D`

`L_(h,"laminar") ~= 0.05 xx 2100 xx 0.02`

`L_h,("laminar") ~= 2.1 m`

4. Total Length of the Pipe:

`L_T = 3m`

5. Pressure Drop `(DeltaP)`:

`DeltaP = (32muLV_(avg))/(D^2)`

`DeltaP = (32 xx 1.005xx10^-3 xx 3 xx 0.1057)/(0.02^2)`

`DeltaP = 25.49 Pa`

Geometry Model:

In this Geometry, the original model is reduced to find the flow of a fluid. It is easy to find the geometry vertices.

MATLAB blockMeshDict File:-

In Matlab to automate the generation of blockMeshDict file to run the simulation in OpenFoam.

clear all
close all
clc

% Input Parameters
Re = 2100;        % Reynolds number
D = 0.02;         % Diameter of Pipe
R = D/2;          % Radius of Pipe
theta = 3;        % Wedge angle
rho = 998.2;      % Denssity of water @ 20° in   'kg/m3'
mu = 1.005e-3;    % Dynamic viscosity @ 20° in   'Pa*s'
nu = 1.002e-6;    % Kinematic viscosity @ 20° in 'm2/s'

% Calculation of velocity, pressure and entrance length

Length_E = 0.05*Re*D;
Length_T = 3;
Velocity_avg = (Re*mu)/(rho*D);

% Vertices of blocks
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 = [Length_T 0 0];
v4 = [Length_T R*cosd(theta/2) R*sind(theta/2)];
v5 = [Length_T R*cosd(theta/2) -R*sind(theta/2)];

% BlockMeshDict File

f1 = fopen('blockMeshDict.txt','w');
fprintf(f1, '%s', '/*--------------------------------*- C++ -*----------------------------------*\');
fprintf(f1, '\n');
fprintf(f1, '%s','  =========                 |');
fprintf(f1, '\n');
fprintf(f1, '%s','  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox');
fprintf(f1, '\n');
fprintf(f1, '%s','   \\    /   O peration     | Website:  https://openfoam.org');
fprintf(f1, '\n');
fprintf(f1, '%s','    \\  /    A nd           | Version:  8');
fprintf(f1, '\n');
fprintf(f1, '%s','     \\/     M anipulation  |');
fprintf(f1, '\n');
fprintf(f1, '%s', '\*---------------------------------------------------------------------------*/');
fprintf(f1, '\nFoamFile\n');
fprintf(f1, '{\n');
fprintf(f1, '    version     2.0;\n');
fprintf(f1, '    format      ascii;\n');
fprintf(f1, '    class       dictionary;\n');
fprintf(f1, '    object      blockMeshDict;\n');
fprintf(f1, '}\n');
fprintf(f1, '%s','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');

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

fprintf(f1, 'vertices\n');
fprintf(f1, '(\n');
fprintf(f1,blanks(4));
fprintf(f1, '(%f %f %f)\n',v0(1),v0(2),v0(3));
fprintf(f1,blanks(4));
fprintf(f1, '(%f %f %f)\n',v1(1),v1(2),v1(3));
fprintf(f1,blanks(4));
fprintf(f1, '(%f %f %f)\n',v2(1),v2(2),v2(3));
fprintf(f1,blanks(4));
fprintf(f1, '(%f %f %f)\n',v3(1),v3(2),v3(3));
fprintf(f1,blanks(4));
fprintf(f1, '(%f %f %f)\n',v4(1),v4(2),v4(3));
fprintf(f1,blanks(4));
fprintf(f1, '(%f %f %f)\n',v5(1),v5(2),v5(3));
fprintf(f1, ');\n\n');

fprintf(f1, 'blocks\n');
fprintf(f1, '(\n');
fprintf(f1, '%s', '    hex (0 1 4 3 0 2 5 3) (20 500 1) simpleGrading (1 1 1)');
fprintf(f1, '\n);\n');

fprintf(f1, '\nedges\n');
fprintf(f1, '(\n');
fprintf(f1, '    arc 2 1 (%f %f %f)\n',0,R,0);
fprintf(f1, '    arc 5 4 (%f %f %f)\n',Length_T,R,0);
fprintf(f1, ');\n\n');

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

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

fprintf(f1, '%s', '// ************************************************************************* //');

fclose(f1);

BlockMeshDict file:-

The blockMeshDict file is obtained from the above Matlab code.

/*--------------------------------*- 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.000000 0.000000 0.000000)
    (0.000000 0.009997 0.000262)
    (0.000000 0.009997 -0.000262)
    (3.000000 0.000000 0.000000)
    (3.000000 0.009997 0.000262)
    (3.000000 0.009997 -0.000262)
);

blocks
(
    hex (0 1 4 3 0 2 5 3) (20 500 1) simpleGrading (1 1 1)
);

edges
(
    arc 2 1 (0.000000 0.010000 0.000000)
    arc 5 4 (3.000000 0.010000 0.000000)
);

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

mergePatchPairs
(
);

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

ControlDict File:-

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

deltaT          0.01;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure(P) File:-

/*--------------------------------*- 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;
    }
       
    axis
    {
        type            empty;
    }
        
    fixedWalls
    {
        type            zeroGradient;
    }

    front
    {
        type            wedge;
    }
    
    back
    {
        type            wedge;
    }
}

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

Velocity(U) File:

/*--------------------------------*- 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.1057 0 0);
    }
    
    outlet
    {
        type            zeroGradient;
    }

    axis
    {
        type            empty;
    }

    fixedWalls
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    
    front
    {
        type            wedge;
    }
        
    back
    {
        type            wedge;
    }   
}

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

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] 0.000001002;


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

Run the Simulaton:-

  • After entering all the values for the geometry to run the simulation by entering the solver name 'icoFoam' to start the simulation.
  • To check the uniform Mesh in Paraview by entering the command in terminal 'paraFoam'

Mesh grid:

RESULT AND CONCLUSION:-

1. Validate velocity profile for fully developed flow:

  • From the above graph, the velocity is plotted from the different lengths of the pipe( 0.1m, 0.5m, 1m, 2m, 3m).
  • The fully developed region is starting from 2.1m to 3m.
  • The velocity profile in the fully developed region is parabolic. From the graph the at 'x = 3 m' of the velocity curve is parabolic.

2. Validate Wall shear stress for fully developed flow:

  • The shear Stress plot is linear in most of the regions. The shear stress is taken from the fully developed flow region of the pipe at 'x = 2.5m'.
  • The wall shear stress remains constant in that hydrodynamic fully developed flow region.
  • Therefore the flow is fully developed because the velocity profile is parabolic, and shear stress is proportional to the velocity gradient in the y-direction.
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.