Challenge

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

Assignment name- Simulation of Flow through a pipe in Open Foam (part 2)

Objective-

  • To developed a program in MATLAB for file parsing
  • Simulation of open pipe (symmetry boundary condition) and obtained the results
  • How parameter changes with respect to change in angles.

Analytical solution

Changes between wedge boundary and symmetry boundary condition

  • We only change your angle in file parsing i.e. I mentioned theta is variable for file parsing. (Angle 10,25,45)
  • Used cosd instead of cos because we need to put angle in degree and d is suggest degree and in MATLAB, we used d while entering the value angle in degree
  • We changed only type as symmetry instead of wedge in blockMeshDict file, pressure and velocity file.

MATLAB program

clear all

close all

clc

%%%file preraising for openFoam in matlab

%%simulation of openpipe needed some information

%%flow is laminar

%%input Varibles

%Renoyled number

Re=2100;

%density of water(consider fluid is water)

rho=997;

%Diameter of pipe

D=0.02;

%Radius of pipe

R=D/2;

%entrance length

Le=0.06*Re*D;

%total length

L=Le+0.3;

%dynamic viscosity

dv=0.89e-3;

%kinematic viscosity

kv=dv/rho;

%average velocity

V_avg=(dv*Re)/(rho*D);

%maximum velocity

V_max=2*V_avg;

%wedge angle

theta=25;%(not consider value of theta greater than 5)

%%vertices of open pipe for blockmeshDict

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

% please take precaution I am using Captial V for velocity and small v for vertex)

%%calculating shear stress

r=linspace(0,(D/2),500);

for i=1:length(r)

tau(i)=2*dv*V_max*abs(r(i))/R^2;

end

figure(1)

plot(r,tau)

xlabel('Radius of pipe')

ylabel('shear sdtress')

title('shear stress')

legend('shear stress')

%header of script file

h1='/*--------------------------------*- C++ -*----------------------------------*\';

h2= '========= |';

h3= '\\ / F ield | OpenFOAM: The Open Source CFD Toolbox';

h4= '\\ / O peration | Website: https://openfoam.org';

h5= '\\ / A nd | Version: 9';

h6= '\\/ M anipulation |';

h7='\*---------------------------------------------------------------------------*/';

h8='FoamFile';

h9='{';

h10= 'format ascii;';

h11= 'class dictionary;';

h12 = 'object blockMeshDict;';

h13='}';

h14='// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';

%generated block mesh directory start file prasing

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,'\n');

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

fprintf(f1,'\n');

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,'\n');

fprintf(f1,'%s\n','convertToMeters 1;');

%vertices

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

fprintf(f1,'\n');

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

fprintf(f1,'\t(%d %d %d)\n',v0(1),v0(2),v0(3));

fprintf(f1,'\t(%d %d %d)\n',v1(1),v1(2),v1(3));

fprintf(f1,'\t(%d %d %d)\n',v2(1),v2(2),v2(3));

fprintf(f1,'\t(%d %d %d)\n',v3(1),v3(2),v3(3));

fprintf(f1,'\t(%d %d %d)\n',v4(1),v4(2),v4(3));

fprintf(f1,'\t(%d %d %d)\n',v5(1),v5(2),v5(3));

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

%%blocks

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

fprintf(f1,'\n');

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

fprintf(f1,'\t hex(0 3 4 1 0 3 5 2)(%d %d %d) simpleGrading (1 0.2 1)\n',300,30,1);

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

%edges

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

fprintf(f1,'\n');

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

fprintf(f1,'\t arc 1 2 (%d %d %d)\n',0,R,0);

fprintf(f1,'\t arc 4 5 (%d %d %d)\n',L,R,0);

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

%%boundary

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

fprintf(f1,'\n');

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

%axis

fprintf(f1,'\n');

fprintf(f1,'\t axis\n\t{\n');

fprintf(f1,'\t type empty;\n');

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

fprintf(f1,'\t(%d %d %d %d)\n',0,3,3,0);

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

%top wall

fprintf(f1,'\n');

fprintf(f1,'\t wall\n\t{\n');

fprintf(f1,'\t type wall;\n');

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

fprintf(f1,'\t(%d %d %d %d)\n',1,4,5,2);

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

%inlet

fprintf(f1,'\n');

fprintf(f1,'\t inlet\n\t{\n');

fprintf(f1,'\t type patch;\n');

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

fprintf(f1,'\t(%d %d %d %d)\n',0,1,2,0);

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

%outlet

fprintf(f1,'\n');

fprintf(f1,'\t outlet\n\t{\n');

fprintf(f1,'\t type patch;\n');

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

fprintf(f1,'\t(%d %d %d %d)\n',3,5,4,3);

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

%frontAndback

fprintf(f1,'\n');

fprintf(f1,'\t front\n \t{\n');

fprintf(f1,'\t type wedge;\n');

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

fprintf(f1,'\t(%d %d %d %d)\n',0,3,4,1);

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

fprintf(f1,'\n');

fprintf(f1,'\t back\n\t{\n');

fprintf(f1,'\t type wedge;\n');

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

fprintf(f1,'\t(%d %d %d %d)\n',0,2,5,3);

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

% all boundary condition is given

fprintf(f1,'\n');

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

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

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

fclose(f1);

Theta=25 degree

Pressure directory

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

outlet
{
type fixedValue;
value uniform 0.018;
}
wall
{
type zeroGradient;

}
front
{
type symmetry;
}
back
{
type symmetry;
}
}

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

Velocity directory

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

boundaryField
{
axis
{
type empty;
}
inlet
{
type fixedValue;
value uniform (0.0937 0 0);
}

outlet
{
type zeroGradient;
}
wall
{
type fixedValue;
value uniform (0 0 0);
}

front
{
type symmetry;
}
back
{
type symmetry;
}
}

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

Block mesh directory

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

convertToMeters 1;

vertices
(
(0 0 0)
(0 9.9762960e-03 -2.164396e-03)
(0 9.9762960e-03 2.164396e-03)
(2.820000e+00 0 0)
(2.820000e+00 9.9762960e-03 -2.164396e-03)
(2.820000e+00 9.9762960e-03 2.164396e-03)
);

blocks
(
hex (0 3 4 1 0 3 5 2) (300 30 1) simpleGrading (1 0.1 1)
);

edges
(
arc 1 2 (0 1.000000e-02 0)
arc 4 5 (2.820000e+00 1.000000e-02 0)
);

boundary
(
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
wall
{
type wall;
faces
(
(1 4 5 2)
);
}

inlet
{
type patch;
faces
(
(0 1 2 0)
);
}

outlet
{
type patch;
faces
(
(3 5 4 3)
);
}

front
{
type symmetry;
faces
(
(0 3 4 1)
);
}

back
{
type symmetry;
faces
(
(0 2 5 3)
);
}
);

mergePatchPairs
(

);
// ************************************************************************* //

Control directory

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

deltaT 0.01;

writeControl timeStep;

writeInterval 10;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

runTimeModifiable true;


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

Transport directory

/*--------------------------------*- 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.917e-7;


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

Velocity profile at 25 degree

Post processing result screenshot (angle 25degree)

Comparison chart

Conclusions

  • Above chart give you detailed explanation and comparisons between analytical solution and wedge BC and Symmetry BC
  • With increasing the value of wedge angle courant number is increases
  • From above table we can say that symmetric BC plays important role in accuracy in the solution
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.