All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Title: Simulation flow through a pipe in openFoam Objective: 1.To calculate length of the pipe using the entry length formula for laminar flow through a pipe 2.To show that entry length is sufficient to produce a fully developed flow. 3.To write a program in Matlab that can generate the computational mesh automatically…
Dipakv Virkarwe
updated on 14 Feb 2020
Title: Simulation flow through a pipe in openFoam
Objective:
1.To calculate length of the pipe using the entry length formula for laminar flow through a pipe
2.To show that entry length is sufficient to produce a fully developed flow.
3.To write a program in Matlab that can generate the computational mesh automatically for any wedge angle and grading schemes.
4.To show that the velocity profile is fully developed.
Theory
The main objecive of this challange is to simulate the laminar flow through a pipe by use of openFoam tool. There is use of wedge shaped domain to peroform the simulation, for that there is made Matlab code that can generate the computational mesh automatically for any wedge angle.
For any simulation flow through pipe it is very important to calculate the velocity, pressure & shear stress distribution along the length, for that hagen poiseuille define that. When fluid is travel some distance after entering in to the pipe & that region called entrance length or hydrodynamic region. once fluid reach entire wall & in pipe there is developement of parabolic shape f fluid flow.
Hagen poiseuille derived some equation & that equation will be use for comaprison of theoretical & computational result.
1. Entrance length of pipe
Le= 0.06* Re*D
2.Total Length
L=Le+0.3
3. Average velocity or intial velocity
Vavg=Re⋅μρ⋅D
Re= Reynold No.
mu=Dynamic Viscosity
rho=density of water
D=Diameter of pipe
4. Maximum Velocity
Vmax=2⋅Vavg
5. Pressure distribution
P1−P2=32⋅μ⋅Vavg⋅LD2
5.Kinematic Pressure
ΔK=ΔPρ
6. Shear stress
τ=2⋅μ⋅VmaxR2
Given data for simulation
1.Re=2100 for laminar flow
2.working fluid is water
3. density of water= 997 kg/m3
4.Dynamic viscosity =0.89*10^-03
5. Diameter of pipe (D)= 0.020m (Assumed)
Calculate the following data by above formula
1.Entrance length of pipe =2.52m
2.Total length of pipw= 2.82m
3.Vavg=0.09373m/sec
4.Vmax=0.1874m/s
5.Pressure diffrence= 18.819pa
6.Kinematic pressure=0.018876m2/sec2
7.shear strees= 3.32 N/m2
8.Use of icoFoam solver.
Matlab code for prepare blockMeshDict file of openFoam
Matlab Code
close all
clear all
clc
% given data
Re=2100; % Reynold No.
mu=0.89e-3; % Dynamic viscosity
D=0.020; % Diameter of pipe D=20mm
R=(D/2); % Raduis of pipe
rho=997 ; % Density of water
Le= (0.06*Re*D); % Entry lenght of pipe
L= Le+0.3 ; % Length of pipe
theta=4; % Angle of wedge(less than 5 degree)
% writing the header part for blockMeshDict file in Matlab
h1=\'/*--------------------------------*- C++ -*----------------------------------*\\\';
h2=\' ========= |\';
h3=\' \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox\';
h4=\' \\\\ / O peration | Website: https://openfoam.org\';
h5=\' \\\\ / A nd | Version: 7\';
h6=\' \\\\/ M anipulation |\';
h7=\'\\*---------------------------------------------------------------------------*/\';
h8=\'FoamFile\';
h9=\'{\';
h10=\' version 2.0;\';
h11=\' format ascii;\';
h12=\' class dictionary;\';
h13=\' object blockMeshDict;\';
h14=\'}\';
h15=\'// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\';
conv=\'convertToMeters 1;\';
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=[L 0 0];
v4=[L R*cosd(theta/2) R*sind(theta/2)];
v5=[L R*cosd(theta/2) -R*sind(theta/2)];
block=\'hex (0 3 5 2 0 3 4 1) (300 10 1) simpleGrading (1 1 1)\';
inlet=\'(0 1 2 0)\';
outlet=\'(3 5 4 3)\';
top=\'(1 4 5 2)\';
front=\'(0 3 4 1)\';
back=\'(0 2 5 3)\';
axis=\'(0 3 3 0)\';
s1=blanks(4);
s2=blanks(7);
s3=blanks(11);
s4=blanks(3);
% Writing blockMeshDict file
f1=fopen(\'blockMeshDict.txt\',\'w\');
fprintf(f1,\'%s\\n\',h1);
fprintf(f1,\'%s\\n\',h2);
fprintf(f1,\'%s\\n\',h3);
fprintf(f1,\'%s\\n\',h4);
fprintf(f1,\'%s\\n\',h5);
fprintf(f1,\'%s\\n\',h6);
fprintf(f1,\'%s\\n\',h7);
fprintf(f1,\'%s\\n\',h8);
fprintf(f1,\'%s\\n\',h9);
fprintf(f1,\'%s\\n\',h10);
fprintf(f1,\'%s\\n\',h11);
fprintf(f1,\'%s\\n\',h12);
fprintf(f1,\'%s\\n\',h13);
fprintf(f1,\'%s\\n\',h14);
fprintf(f1,\'%s\\n\',h15);
fprintf(f1,\'\\n\');
fprintf(f1,\'%s\\n\',conv);
fprintf(f1,\'\\n\');
fprintf(f1,\'%s\\n\',\'vertices\');
fprintf(f1,\'%s\\n\',\'(\');
fprintf(f1,\'%s(%d %d %d)\\n\',s1,v0(1),v0(2),v0(3));
fprintf(f1,\'%s(%d %d %d)\\n\',s1,v1(1),v1(2),v1(3));
fprintf(f1,\'%s(%d %d %d)\\n\',s1,v2(1),v2(2),v2(3));
fprintf(f1,\'%s(%d %d %d)\\n\',s1,v3(1),v3(2),v3(3));
fprintf(f1,\'%s(%d %d %d)\\n\',s1,v4(1),v4(2),v4(3));
fprintf(f1,\'%s(%d %d %d)\\n\',s1,v5(1),v5(2),v5(3));
fprintf(f1,\'%s\\n\',\');\');
fprintf(f1,\'\\n\');
fprintf(f1, \'%s\\n\',\'blocks\');
fprintf(f1,\'%s\\n\',\'(\');
fprintf(f1,\'%s %s\\n\',s4,block);
fprintf(f1,\'\\n\');
fprintf(f1,\'%s\\n\',\');\');
fprintf(f1,\'\\n\');
fprintf(f1,\'%s\\n\',\'edges\');
fprintf(f1,\'%s\\n\',\'(\');
fprintf(f1,\'%s %s %d %d (%d %d %d)\\n\',s4,\'arc\',1,2,0,R,0);
fprintf(f1,\'%s %s %d %d (%d %d %d)\\n\',s4,\'arc\',4,5,L,R,0);
fprintf(f1,\'%s\\n\',\');\');
fprintf(f1,\'\\n\');
fprintf(f1,\'%s\\n\',\'boundary\');
fprintf(f1,\'%s\\n\',\'(\');
fprintf(f1,\'%s %s\\n\',s4,\'inlet\');
fprintf(f1,\'%s %s\\n\',s4,\'{\');
fprintf(f1,\'%s %s\\n\',s2,\'type patch;\')
fprintf(f1,\'%s %s\\n\',s2,\'faces\')
fprintf(f1,\'%s %s\\n\',s2,\'(\');
fprintf(f1,\'%s (%d %d %d %d)\\n\',s3,0,1,2,0);
fprintf(f1,\'%s %s\\n\',s2,\');\');
fprintf(f1,\'%s %s\\n\',s4,\'}\');
fprintf(f1,\'%s %s\\n\',s4,\'outlet\');
fprintf(f1,\'%s %s\\n\',s4,\'{\');
fprintf(f1,\'%s %s\\n\',s2,\'type patch;\')
fprintf(f1,\'%s %s\\n\',s2,\'faces\')
fprintf(f1,\'%s %s\\n\',s2,\'(\');
fprintf(f1,\'%s (%d %d %d %d)\\n\',s3,3,5,4,3);
fprintf(f1,\'%s %s\\n\',s2,\');\');
fprintf(f1,\'%s %s\\n\',s4,\'}\');
fprintf(f1,\'%s %s\\n\',s4,\'top\');
fprintf(f1,\'%s %s\\n\',s4,\'{\');
fprintf(f1,\'%s %s\\n\',s2,\'type wall;\')
fprintf(f1,\'%s %s\\n\',s2,\'faces\')
fprintf(f1,\'%s %s\\n\',s2,\'(\');
fprintf(f1,\'%s (%d %d %d %d)\\n\',s3,1,4,5,2);
fprintf(f1,\'%s %s\\n\',s2,\');\');
fprintf(f1,\'%s %s\\n\',s4,\'}\');
fprintf(f1,\'%s %s\\n\',s4,\'front\');
fprintf(f1,\'%s %s\\n\',s4,\'{\');
fprintf(f1,\'%s %s\\n\',s2,\'type wedge;\')
fprintf(f1,\'%s %s\\n\',s2,\'faces\')
fprintf(f1,\'%s %s\\n\',s2,\'(\');
fprintf(f1,\'%s (%d %d %d %d)\\n\',s3,0,3,4,1);
fprintf(f1,\'%s %s\\n\',s2,\');\');
fprintf(f1,\'%s %s\\n\',s4,\'}\');
fprintf(f1,\'%s %s\\n\',s4,\'back\');
fprintf(f1,\'%s %s\\n\',s4,\'{\');
fprintf(f1,\'%s %s\\n\',s2,\'type wedge;\')
fprintf(f1,\'%s %s\\n\',s2,\'faces\')
fprintf(f1,\'%s %s\\n\',s2,\'(\');
fprintf(f1,\'%s (%d %d %d %d)\\n\',s3,0,2,5,3);
fprintf(f1,\'%s %s\\n\',s2,\');\');
fprintf(f1,\'%s %s\\n\',s4,\'}\');
fprintf(f1,\'%s %s\\n\',s4,\'axis\');
fprintf(f1,\'%s %s\\n\',s4,\'{\');
fprintf(f1,\'%s %s\\n\',s2,\'type empty;\')
fprintf(f1,\'%s %s\\n\',s2,\'faces\')
fprintf(f1,\'%s %s\\n\',s2,\'(\');
fprintf(f1,\'%s (%d %d %d %d)\\n\',s3,0,3,3,0);
fprintf(f1,\'%s %s\\n\',s2,\');\');
fprintf(f1,\'%s %s\\n\',s4,\'}\');
fprintf(f1,\'%s\\n\',\');\');
fprintf(f1,\'\\n\');
fprintf(f1,\'%s\\n\',\'mergePatchPairs\');
fprintf(f1,\'%s\\n\',\'(\');
fprintf(f1,\'%s\\n\',\');\');
h16=\'// ************************************************************************* //\';
fprintf(f1,\'%s\\n\',h16);
fclose(f1);
BlockMeshDict file
/*--------------------------------*- 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 1;
vertices
(
(0 0 0)
(0 9.993908e-03 3.489950e-04)
(0 9.993908e-03 -3.489950e-04)
(2.820000e+00 0 0)
(2.820000e+00 9.993908e-03 3.489950e-04)
(2.820000e+00 9.993908e-03 -3.489950e-04)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (300 10 1) simpleGrading (1 1 1)
);
edges
(
arc 1 2 (0 1.000000e-02 0)
arc 4 5 (2.820000e+00 1.000000e-02 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
top
{
type wall;
faces
(
(1 4 5 2)
);
}
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
(
);
// ************************************************************************* //
Transport Properties
/*--------------------------------*- 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.92e-7;
// ************************************************************************* //
Velocity file
/*--------------------------------*- 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.0937 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.0937 0 0);
}
outlet
{
type zeroGradient;
}
axis
{
type empty;
}
top
{
type noSlip;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
Preesure file
/*--------------------------------*- 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.018;
}
axis
{
type empty;
}
top
{
type zeroGradient;
}
front
{
type wedge;
}
back
{
type wedge;
}
}
// ************************************************************************* //
Result obtained for Wedge BC at 4 degree of wedge angle
Mesh
Velocity distribution
Velocity at X=0.01m
Velocity at X=0.2m
Velocity at X=0.5m
Velocity at X=0.9m
Velocity at X=1.2m
Velocity at X=2.4m
Velocity at exit X=2.8m
From the above graph it show that ,as fluid is entered in to the pipe & it\'s travel up to entrance length or hydrodynamic length i.e up to x=2.4 m so. there is slightaly development of parabolic nature of flow but its not constant. but after x=2.5m there is velocity is fully developed &velocity is reached at maximum value at nearest to the centre point of pipe i.e Radius or y distance=0.
Pressure at x=2 m
from above plot it shows that as theres increase length x -direction pressure is constant.
Code for plot the graph of shear stress in Matlab
%Code for calcualte the shear stress graph form 0 to 2.82m length
% define input variable
mu=0.89e-3; % dynamic viscosity
D=0.020;
R=linspace(0, (D/2), 1000);
dR=R(2)-R(1);
for i=1:length(R)
du=u(i+1)-u(i);
dU=abs(du);
tau(i)=mu*(dU/dR);
plot(R,tau)
xlabel(\'Radius\')
ylabel(\'Shear stress\')
legend(\'Shear stress at x=2.82m \')
title(\'change in Shear stress at x=2.82m\')
grid on
end
Shear stress at X=2.82m
From the above plot we can see that there is shear stress along y-axis i.e on vertical raduis. so , at centre point of pipe at R=0 shear stress is very low ,but it increases at rdial distance increases.
Result Table
Parameter |
Theoretical |
Computational |
Error in % |
Max. Velocity |
0.1874 |
0.18426 |
1.7 |
Shear stress |
3.32 |
3.279 |
1.28 |
Pressure drop |
0.01876 |
0.018023 |
3.92 |
conclusion
1. velocity is maximum at centre of pipe & minimum at wall surface
2. pressure drop is higher at entrance of pipe & its get constant after entrance length.
3. shear stress is maximum at wall surafce , while it minimum at centre of pipe
4. Verify the all result of hagen poiseuille with simulation result.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 10: Project 1 - FULL HYDRO case set up (PFI)
Title: Simulation of Full Hydro 4-Stroke PFI(Port fuel injection) Objective: 1. To understand the entire case setup 2. Simulation of PFI Engine in paraview 3. To calculate the engine…
09 Sep 2020 12:40 PM IST
No-hydro simulation of PFI (Port fuel injection) Engine in CONVERGE CFD
Title: No-hydro simulation by Surface preparation & boundry flagging in CONVERGE CFD Objective : 1. To Understand the boundry flagging & surface preparation on PFI 2. To perform the No-Hydro simulation of PFI Engine …
01 Sep 2020 01:40 PM IST
Literature review on RANS derivation & its Analysis
Title: Literature review on RANS derivation & its Analysis Objective: 1. Derive the RANS derivation 2. Importance of RANS Theory: The Reynolds-averaged Navier–Stokes equations (or RANS equations) are time-averaged equations…
21 Aug 2020 09:19 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.