Challenge

Week 11 - Simulation of Flow through a pipe in OpenFoam

AIM- Simulation of Flow through a pipe in OpenFoam.

EXPECTED RESULTS:

  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.

INPUT PARAMETERS:

reynolds number Re=2000;
total length of the pipe L=2.5;
diameter of pipe D=0.02;

wedge angle in degrees=5 DEGREES
density(kg/m3) rho=997;
dynamic viscocity(pa.sec) mu= 8.90e-4;
radius of pipe R=D/2;


GRID ALONG X=nx=20;
GRID ALONG Y=ny=1;
GRID ALONG Z=nz=500;

LET US GET TO KNOW THE THEORY OF THE Hagen Poiseuille Equation

In nonideal fluid dynamics, the Hagen–Poiseuille equation, also known as the Hagen–Poiseuille law, Poiseuille law or Poiseuille 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 in lung alveoli, or the flow through a drinking straw or through a hypodermic needle. It was experimentally derived independently by Jean Léonard Marie Poiseuille in 1838 and Gotthilf Heinrich Ludwig Hagen, and published by Poiseuille in 1840–41 and 1846. The theoretical justification of the Poiseuille law was given by George Stokes in 1845.

The assumptions of the equation are that 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 no acceleration of fluid in the pipe. For velocities and pipe diameters above a threshold, actual fluid flow is not laminar but turbulent, leading to larger pressure drops than calculated by the Hagen–Poiseuille equation.

Poiseuille's Equation describes the pressure drop due to the viscosity of the fluid; Other types of pressure drops may still occur in a fluid (see a demonstration here). For example, the pressure needed to drive a viscous fluid up against gravity would contain both that as needed in Poiseuille's Law plus that as needed in Bernoulli's equation, such that any point in the flow would have a pressure greater than zero (otherwise no flow would happen).

Another example is when blood flows into a narrower constriction, its speed will be greater than in a larger diameter (due to continuity of volumetric flow rate), and its pressure will be lower than in a larger diameter (due to Bernoulli's equation). However, the viscosity of blood will cause additional pressure drop along the direction of flow, which is proportional to length traveled(as per Poiseuille's Law). Both effects contribute to the actual pressure drop.

LET US LOOK AT SOME EQUATIONS FROM A REFERENCE BOOK

THESE ARE THE EQUATIONS TO FIND MAX VELOCITY AND PRESUREDROP.

THE FORMULAE FOR SHEAR STRESS IS BELOW.

THE HAND CALCULATION IS ATTACHED BELOW.

NOW LET US SEE HOW WE WROTE THE BLOCKMESHDICT FILE.

WE USE MATLAB TO PERFORM THE SAME.

LET US SEE THE CODE.

%input parameters
%reynolds number
Re=2000;
%total length of the pipe
L=2.5;
%diameter of pipe
D=0.02;
%wedge angle in degrees
th= input('<0> wedge angle in degree - ');
%density(kg/m3)
rho=997;
%dynamic viscocity(pa.sec)
mu= 8.90e-4;
%radius of pipe m
R=D/2;
nx=20;
ny=1;
nz=500;
%GENERATING THE blockMeshDict file using the following function.
result=blockMesh(R,th,L,nx,ny,nz);

%max_velocity
%analytical_max_velocity=amv
%openfoam_max_velocity=omv
amv=0.1785;
omv=0.177416;
error_velocity=((amv-omv)/amv)*100

%pressure drop
%analytical_pressure_drop=apd
%openfoam_pressure_drop=opd
apd=2.53472;
opd=2.54505;
error_pressuredrop=abs(((apd-opd)/apd)*100)

%hear stress at wall
%analytical_shearstress=ass
%openfoam_shearstress=oss
ass=0.031773;
oss=0.0303933;
error_shearstress=abs(((ass-oss)/ass)*100)


NOW LET US TAKE A LOOK AT THE FUNCTION.

%generation of blockMeshDict file

function[f1]=blockMesh(R,th,L,nx,ny,nz)

f1=fopen('blockMeshDict','w');
fprintf(f1,'/--------------------------------- C++ -----------------------------------/\n');
fprintf(f1,'=========                 | \n');
fprintf(f1,'\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox \n');
fprintf(f1,' \\    /   O peration     | Website:  https://openfoam.org \n');
fprintf(f1,'  \\  /    A nd           | Version:  8 \n');
fprintf(f1,'   \\/     M anipulation  | \n');
fprintf(f1,'\*---------------------------------------------------------------------------*/ \n');

fprintf(f1,'         \n');

fprintf(f1,'FoamFile \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,'         \n');
fprintf(f1,'convertToMeters 1; \n');
fprintf(f1,'         \n');

fprintf(f1,'vertices \n');
%inputing the coordinated sof the wedge shaped pipe,
fprintf(f1,' ( \n');
fprintf(f1,'   (0 0 0) \n');
fprintf(f1,'   (%f %f 0)\n',R*cosd(th/2),R*sind(th/2));
fprintf(f1,'   (%f %f %f)\n',R*cosd(th/2),R*sind(th/2),L);
fprintf(f1,'   (0 0 %f)\n',L);
fprintf(f1,'   (%f %f 0)\n',R*cosd(th/2),-R*sind(th/2));
fprintf(f1,'   (%f %f %f)\n',R*cosd(th/2),-R*sind(th/2),L);
fprintf(f1,' ); \n');


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


%defining the blocks
fprintf(f1,'blocks \n');
fprintf(f1,' ( \n');
fprintf(f1,'   hex (0 4 1 0 3 5 2 3) (%d %d %d) simpleGrading (0.2 1 1) \n',nx,ny,nz);
fprintf(f1,' ); \n');

fprintf(f1,'         \n');

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

fprintf(f1,'         \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 4 1 0) \n');
fprintf(f1,'       ); \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 2 3) \n');
fprintf(f1,'        ); \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 1 2 3) \n');
fprintf(f1,'             ); \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 3 5 4) \n');
fprintf(f1,'          ); \n');
fprintf(f1,'   } \n');

fprintf(f1,'         \n');

fprintf(f1,'   pipewall \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,'         \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,'); \n');

fprintf(f1,'         \n');

%marging all the boundaries
fprintf(f1,' mergePatchPairs  \n');
fprintf(f1,'( \n');
fprintf(f1,'); \n');

fprintf(f1,'         \n');


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



end

IN OPENFOAM THE BLOCKMESH DICT FILE LOOKS AS FOLLOWS.

/*--------------------------------*- 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.009990 0.000436 0)
   (0.009990 0.000436 2.500000)
   (0 0 2.500000)
   (0.009990 -0.000436 0)
   (0.009990 -0.000436 2.500000)
   
 ); 
         
         
blocks 
 ( 
   hex (0 4 1 0 3 5 2 3) (20 1 500) simpleGrading (0.2 1 1) 
 ); 
         
edges 
 ( 
    arc 4 1 (0 0.010000 0) 
    arc 5 2 (2.500000 0.010000 0) 
  ); 
         
boundary 
( 
   inlet 
    { 
     type patch; 
     faces 
       ( 
       (0 4 1 0) 
       ); 
    } 
         
   outlet 
   { 
      type patch; 
      faces 
        ( 
        (3 5 2 3) 
        ); 
   } 
         
   front 
   { 
          type wedge; 
          faces 
            ( 
             (0 1 2 3) 
             ); 
   } 
         
   back 
   { 
          type wedge; 
          faces 
          ( 
          (0 3 5 4) 
          ); 
   } 
         
   pipewall 
   { 
           type wall; 
           faces 
             ( 
             (1 4 5 2) 
              ); 
   } 
         
   axis 
   { 
           type empty; 
           faces 
               ( 
               (0 3 3 0) 
                ); 
   } 
); 
         
 mergePatchPairs  
(
); 
         
  // ************************************************************************* // 

THE CONTROLDICT C++ FILE WILL LOOK AS FOLLOWS.IT CONTAINS ALL THE ITERATIVE PARAMETERS.

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

deltaT          0.0001;

writeControl    timeStep;

writeInterval   1000;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

THE TRANSPORT PROPERTIES CONTAIN THE VALUE OF nu WHICH IS 8.90Ee-4

THE MESH LOOKS LIKE BELOW.

1.

2.

NOW LET US TAKE A LOOT AT THE DIFFERENT PROFILES.

1.MAX VELOCITY GRAPH.

2.PRESSURE DROP AT 0.4M OF THE PIPE

3.SHEAR STRESS GRAPH AT WALL OF PIPE AT 0.01M FROM CENTER

THE ERROR TERMS ARE LISTED BELOW:

error_velocity =0.6073%


error_pressuredrop = 0.4075%


error_shearstress = 4.3424%

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.