Challenge

Week 11 - Simulation of Flow through a pipe in OpenFoam

objective:

In this challenge we need to simulate axi-symetric,laminar flow through a constant are of cross- section of pipe by using wedge boundary conditions and validate those results with the haigen-poisselle equation for hydrodynamic length, velocity, pressure and the sherar stress

Theory :

There is no need for much explation of the theory part, we just need to look at the haigen-poiselles equations and presentation of the codes anf graphs

Haigen-Poisuelle equations:

In non ideal fluid dynamics, the haigen-poisuille equation, is a physical law that gives the pressure drop in an incompressible and newtonian fluid in laminar flow flowing through a long cylindrical pipe of constant cross section. it can be successfully applied to air flow or the flow through a drinking straw or through a hypodermic needle.

The assumptions of the equation are

The fluid is incompressible and newtonian , the flow is laminar through a pipe of constant circular cross section that is substantially longer than its diameter and there is should be no acceleration of fluid in a pipe. for velocities and pipe diameters above a threshold, actual fluid flow os not laminar but turbulent, leading to larger pressure drops than calculated by this equation

This equation describes the pressure drop due to viscosity of the fluid

The Hagen–Poiseuille equation can be derived from the navier stokes equations The laminar flow through a pipe of uniform (circular) cross-section is known as Hagen–Poiseuille flow. The equations governing the Hagen–Poiseuille flow can be derived directly from the navie stokes equations r,θ,x) by making the following set of assumptions:

  1. The flow is steady ( ∂.../∂t = 0 ).
  2. The radial and azimuthal components of the fluid velocity are zero ( ur = uθ = 0 ).
  3. The flow is axisymmetric ( ∂.../∂θ = 0 ).
  4. The flow is fully developed ( ∂ux/∂x = 0 ). Here However, this can be proved via mass conservation, and the above assumptions.

Then the angular equation in the momentum equations and the continuity equation are identically satisfied. The radial momentum equation reduces to ∂p/∂r = 0, i.e., the pressure p is a function of the axial coordinate x only. For brevity, use u instead of u x {\displaystyle u_{x}} . The axial momentum equation reduces to

1 r ∂ ∂ r ( r ∂ u ∂ r ) = 1 μ d p d x {\displaystyle {\frac {1}{r}}{\frac {\partial }{\partial r}}\left(r{\frac {\partial u}{\partial r}}\right)={\frac {1}{\mu }}{\frac {\mathrm {d} p}{\mathrm {d} x}}}

where μ is the dynamic viscosity of the fluid. In the above equation, the left-hand side is only a function of r and the right-hand side term is only a function of x, implying that both terms must be the same constant. Evaluating this constant is straightforward. If we take the length of the pipe to be L and denote the pressure difference between the two ends of the pipe by Δp (high pressure minus low pressure), then the constant is simply

− d p d x = Δ p L = G {\displaystyle -{\frac {\mathrm {d} p}{\mathrm {d} x}}={\frac {\Delta p}{L}}=G}

defined such that G is positive. The solution is

u = − G r 2 4 μ + c 1 ln ⁡ r + c 2 {\displaystyle u=-{\frac {Gr^{2}}{4\mu }}+c_{1}\ln r+c_{2}}

Since u needs to be finite at r = 0, c1 = 0. The no slip boundary condition at the pipe wall requires that u = 0 at r = R (radius of the pipe), which yields c2 = GR2/4μ. Thus we have finally the following parabolic velocity profile:

u = G 4 μ ( R 2 − r 2 ) . {\displaystyle u={\frac {G}{4\mu }}\left(R^{2}-r^{2}\right).}

The maximum velocity occurs at the pipe centerline (r = 0), umax = GR2/4μ. The average velocity can be obtained by integrating over the pipe

u a v g = 1 π R 2 ∫ 0 R 2 π r u d r = 1 2 u m a x . {\displaystyle {u}_{\mathrm {avg} }={\frac {1}{\pi R^{2}}}\int _{0}^{R}2\pi ru\mathrm {d} r={\tfrac {1}{2}}{u}_{\mathrm {max} }.}

The easily measurable quantity in experiments is the volumetric flow rate Q = πR2 uavg. Rearrangement of this gives the Hagen–Poiseuille equation

Δ p = 8 μ Q L π R 4 . {\displaystyle \Delta p={\frac {8\mu QL}{\pi R^{4}}}.}

The relations of this equation for different varibles can be given as

Velocity profile = u(r) = 2*Vavg (1-r^2 /R^2), Entrance length = lh = 0.006Re *D, Pressure drop = DeltaP = p1 -p2 = 32nuLVavg/D^2, Shear stress = tau = nu* du/dy

Now we shall look at what are the steps to simulate this type of flow (axi-symmetric , laminar ) the programme codes and the respective images are inserted through insert code option and image insert option please check it

In code we need to give create a folder inside run folder which contains 0, constant, system folders and the respective sub folders , there we need to give neccessary conditions in Blockmesh such as diameter, radius entrance length , flow length , vertices boundary conditions (wedge) now also provide with neccessary velocity profile and pressure conditions with intial and final values ,also time step values starting time and finishing time and all the sufficient details, now run for Blockmesh command and solve the equations using solver command named icoFoam and then view the simulation by using paraFoam command and then we simulate all the above variables and validate it with the haigen-poisuille equationd and plot gragh and compare and observe . all the codes and images are attached below please verify

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

// blockMesh parameterization   

/* Geometrical Info */

D	0.004;                      // Diameter 
r #calc "0.5*$D";                   // Radius
angle	5;                          // Angle in degrees
theta   #calc "degToRad($angle)";   // Angle in radians
Re 100;          		    // Reynolds Number
Le #calc "0.06*$Re*$D";             // Entrance Length
L  #calc "0.2 + $Le";		    // Total length of pipe

/* Vertices Info */

xmin	0;    
xmax	$L;   
ymax	#calc "$r*cos($theta)";
zmax	#calc "$r*sin($theta)";
zmin    #calc "-$r*sin($theta)"; 

/* Mesh Info */

nx	10;	// Cells along local X  
ny	1;	// Cells along local Y  
nz	50;	// Cells along local Z  
gx	0.2;	// SG along local X  
gy	1;	// SG along local Y
gz	1;	// SG along local Z 


convertToMeters 1;

vertices
(
    ($xmin 0 0)		 //0
    ($xmin $ymax $zmax)	 //1
    ($xmin $ymax $zmin)	 //2
    ($xmax 0 0)		 //3
    ($xmax $ymax $zmax)	 //4
    ($xmax $ymax $zmin)	 //5

);

blocks
(
    hex (0 2 1 0 3 5 4 3) ($nx $ny $nz) simpleGrading ($gx $gy $gz)
);

edges
(
);

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

mergePatchPairs
(
);

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


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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         5;

deltaT          0.001;

writeControl    timeStep;

writeInterval   500;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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;
}


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

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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-05;
        relTol          0;
    }
}

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


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

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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;       
    }

    front
    {
        type            wedge;   // symmetry
    }
    
    back
    {
        type            wedge;   // symmetry
    }  
 
    wall
    {
        type            zeroGradient;
    }   
    
    axis
    {
        type            empty;
    }
}

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

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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.0223169508525577 0 0);
    }

    outlet
    {
        type            zeroGradient;
    }

    front
    {
        type            wedge;   // symmetry
    }
    
    back
    {
        type            wedge;   // symmetry
    }  
 
    wall
    {
        type            noSlip;
    }   
    
    axis
    {
        type            empty;
    }
    
}

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

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

6
(
    inlet
    {
        type            patch;
        nFaces          10;
        startFace       940;
    }
    outlet
    {
        type            patch;
        nFaces          10;
        startFace       950;
    }
    front
    {
        type            wedge;
        inGroups        List<word> 1(wedge);
        nFaces          500;
        startFace       960;
    }
    back
    {
        type            wedge;
        inGroups        List<word> 1(wedge);
        nFaces          500;
        startFace       1460;
    }
    wall
    {
        type            wall;
        inGroups        List<word> 1(wall);
        nFaces          50;
        startFace       1960;
    }
    axis
    {
        type            empty;
        inGroups        List<word> 1(empty);
        nFaces          0;
        startFace       2010;
    }
)

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

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

nu              [0 2 -1 0 0 0 0] 8.9267803410231e-07;


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

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.