Challenge

Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation

Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation

Aim:- Simulate for the below mentioned angles using both symmetry and wedge boundary conditions and validate them with HP equations.

  • `10^@`
  • `25^@`
  • `45^@`

DESCRIPTION:-

  • The project simulates the various angles of symmety and wedge boundary conditions.
  • The flow is axi-symmetric flow i.e. the flow is symmetric to the axis of pipe.
  • Hence to reduce the complexity, simulate a section of various angle i.e. symmetry or wedge from which flow will be simulated.
  • MATLAB scripting is done to generate automatically comutational mesh by a wedge angel of 10, 25 & 45 deg.
  • Creating blockMeshDict file by the programe writen in MATLAB and then replacing it with the file which is to be present in run folder.
  • The folder is coppied to frun folder from the foam folder where we have to choose the solver, here the solver is icoFoam which is present in incompressible folder.
  • As it is uses to solve the incompressible laminar by Navier-stroke equation to simulate the flow through pipe.
  • Once the wedge is simulaed in run folder use paraFoam to gain the results, and observe the velocity profile of flow at hydrodynamic entrance length of the pipe and at fully devloped flow.
  • The data from the CFD simulations obtained from the Hegen-Poiseuille Equations to ensure the fidelity results.

CODE FOR FILE PARSING

clear all 
close all
clc

%input
Re=2100;
%length
L=3;
%dia
D=0.02;
theta= input('wedge angle=');
rho=997;
mu=0.89*1e-3;
R=D/2;

L_e= 0.058*Re*D;

meshx=200;
meshy=20;
meshz=1;
gradex=1;
gradey=0.2;
gradez=1;

V_avg= (Re*mu)/(rho*D);
V_max= 2*V_avg;
delta_p=(32*mu*L*V_avg)/(D^2);
kin_p=(delta_p)/(rho);

%determining the vertices of wdge
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))];

f1=fopen('blockMeshDict.txt','w');

fprintf(f1,'%s','/*--------------------------------*- C++ -*----------------------------------*');
fprintf(f1,'\n  =========                 |');
fprintf(f1,'\n  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox');
fprintf(f1,'\n   \\    /   O peration     | Website:  https://openfoam.org');
fprintf(f1,'\n    \\  /    A nd           | Version:  8');
fprintf(f1,'\n     \\/     M anipulation  |');
fprintf(f1,'\n*---------------------------------------------------------------------------*/');
fprintf(f1,'\nFoamFile');
fprintf(f1,'\n{');
fprintf(f1,'\n  version     2.0;') 
fprintf(f1,'\n  format      ascii;')
fprintf(f1,'\n  class       dictionary;')
fprintf(f1,'\n  object      blockMeshDict;')
fprintf(f1,'\n}');
fprintf(f1,'\n%s','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f1,'\nconvertToMeters 1;');
fprintf(f1,'\nvertices');
fprintf(f1,'\n(');
fprintf(f1,'\n(%f %f %f)',v0(1),v0(2),v0(3));
fprintf(f1,'\n(%f %f %f)',v1(1),v1(2),v1(3));
fprintf(f1,'\n(%f %f %f)',v2(1),v2(2),v2(3));
fprintf(f1,'\n(%f %f %f)',v3(1),v3(2),v3(3));
fprintf(f1,'\n(%f %f %f)',v4(1),v4(2),v4(3));
fprintf(f1,'\n(%f %f %f)',v5(1),v5(2),v5(3));
fprintf(f1,'\n);');
fprintf(f1,'\nblocks');
fprintf(f1,'\n(');
fprintf(f1,' hex (0 3 5 2 0 3 4 1) (%d %d %d ) simpleGrading (%f %f %f)',meshx,meshy,meshz,gradex,gradey,gradez);
fprintf(f1,');');
fprintf(f1,'\nedges');
fprintf(f1,'\n(');
fprintf(f1,'\n arc 1 2 (%f %f %f)',0,R,0);
fprintf(f1,'\n arc 4 5 (%f %f %f)',L,R,0);
fprintf(f1,'\n);');

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



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

blockMeshDict 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;
	object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0.000000 0.000000 0.000000)
(0.000000 0.009962 0.000872)
(0.000000 0.009962 -0.000872)
(3.000000 0.000000 0.000000)
(3.000000 0.009962 0.000872)
(3.000000 0.009962 -0.000872)
);
blocks
( hex (0 3 5 2 0 3 4 1) (200 20 1 ) simpleGrading (1.000000 0.200000 1.000000));
edges
(
 arc 1 2 (0.000000 0.010000 0.000000)
 arc 4 5 (3.000000 0.010000 0.000000)
);
boundary
(
    inlet
    {
	type patch;
	faces
	(
 	(0 1 2 0)
 	);
    }
    outlet
    {
	type patch;
	faces
	(
	(3 5 4 3)
	);
    }
    topwall
    {
	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
(
);
// ************************************************************************* //

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;


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

velocity file(U):-

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

    outlet
    {
        type            zeroGradient;
    }

    topwall
    {
        type            noSlip;
    }

    front
    {
        type            wedge;
    }

    back
    {
        type            wedge;
    }
    
    axis
    {
        type            empty;
    }
}

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

Pressure file(p):-

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

    topwall
    {
        type            zeroGradient;
    }

    front
    {
        type            wedge;
    }

    back
    {
        type            wedge;
    }
    
    axis
    {
        type            empty;
    }
}

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

transportProperties 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    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu              [0 2 -1 0 0 0 0] 0.892e-6;


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

RESULTS OF `10^@` :-

MESHING:

  • MESHING SIDE VIEW:

VELOCITY:-

  • Inlet velocity at initial time step
  • Velocity at center portion of pipe
  • Outlet velocity at final time step

PLOTTING :-

  • VELOCITY PLOTTING:
  • PRESSURE PLOTTING:
  • SHEAR-STRESS PLOTTING:

RESULTS OF `25^@` :-

MESHING

  • MESHING SIDE VIEW:

VELOCITY:-

  • Inlet velocity at initial time step
  • Velocity at center portion of pipe
  • Outlet velocity at final time step

PLOTTING

  • VELOCITY PLOTTING
  • PRESSURE PLOTTING
  • SHEAR-STRESS PLOTTING

RESULTS OF `45^@` :-

MESHING

  • MESHING SIDE VIEW:

VELOCITY:-

  • Inlet velocity at initial time step
  • Velocity at center portion of pipe
  • Outlet velocity at final time step

PLOTTING

  • VELOCITY PLOTTING
  • PRESSURE PLOTTING
  • SHEAR-STRESS PLOTTING
  • DERIVING SOLUTIONS FOR FLOW PARAMETERS

    • Known values;

    Re=2100;

    L=3m;

    D=0.02;

    `rho=997`

    `mu=8.92*10^-4`

    • Unknowns,
    • `V_(avg)`
    • `V_(max)`
    • `L_e`
    • `DeltaP`

    1. We have reynold's number

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

    `2100= (997*V_(avg)*0.02)/(8.92*10^-4)`

    `therefore V_(avg)=0.0937 m/s`

    2. We know that the maximum velocity is at the center of pipe

    `therefore V_(max) =2*V_(avg)`

    `therefore V_(max) =2*0.0937`

    `therefore V_(max) =0.1874m/s`

    3. Calculating hydrodynamic entrance length

    `L_e= 0.05*Re*D`

    `L_e= 0.05*2100*0.02`

    `L_e=2.1m`

    4. For calculating pressure drop we have hagen-poiseuille equation,

    `DeltaP= (32*mu*L*V_(avg))/D^2`

    `DeltaP= (32*8.92*10^-4*3*0.0937)/(0.02)^2`

    `DeltaP= 20.059 pa`

  • COMPARING BOTH THE RESULTS
WEDGE ANGEL Max Velocity (HP Eq.) Max. velocity simulated Max. shear stress
`10^@` 0.1874 0.1758 0.03106
`25^@` 0.1874 0.1762 0.03141
`45^@` 0.1874 0.1770 0.03304
  • CONCLUSION
  1. For simulating the symmetry BC with 45 deg takes more time as the but gives more accurate results as compared to 10 and 25 deg
  2. As there is increase in the angle there is also increase in velocity i.e symmetry with higher angle will give more accurate solutions.
  3. This is why symmetry BC is more accurate and better then wedge BC as it gives more accurate results, but it takes more to simulate as compared to wedge BC.
  4. As the wedge angle increases the courant number also increases this can be explained as the increase in the element size of the mesh as the number of element remains the same in the analysis. Thus, courant number is directly proportional to the element size.
  5. Velocity dipped to zero at the edges near the pipe wall for all cases testifies the no-slip BC
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.