project work: implementation of 6-dof on axialturbine ... · project work: implementation of 6-dof...

22
CFD with OpenSource software A course at Chalmers University of Technology Taught by H˚ akan Nilsson Project work: Implementation of 6-DoF on axialTurbine tutorial case Developed for foam-extend-3.2 Author: Barlev Nagawkar Peer reviewed by: Vignesh Pandian akan Nilsson Disclaimer: This is a student project work, done as part of a course where OpenFOAM and some other OpenSource software are introduced to the students. Any reader should be aware that it might not be free of errors. Still, it might be useful for someone who would like learn some details similar to the ones presented in the report and in the accompanying files. The material has gone through a review process. The role of the reviewer is to go through the tutorial and make sure that it works, that it is possible to follow, and to some extent correct the writing. The reviewer has no responsibility for the contents. January 22, 2016

Upload: vanquynh

Post on 28-Jul-2018

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

CFD with OpenSource software

A course at Chalmers University of TechnologyTaught by Hakan Nilsson

Project work:

Implementation of 6-DoF on axialTurbinetutorial case

Developed for foam-extend-3.2

Author:Barlev Nagawkar

Peer reviewed by:Vignesh Pandian

Hakan Nilsson

Disclaimer: This is a student project work, done as part of a course where OpenFOAM and someother OpenSource software are introduced to the students. Any reader should be aware that it

might not be free of errors. Still, it might be useful for someone who would like learn some detailssimilar to the ones presented in the report and in the accompanying files. The material has gone

through a review process. The role of the reviewer is to go through the tutorial and make sure thatit works, that it is possible to follow, and to some extent correct the writing. The reviewer has no

responsibility for the contents.

January 22, 2016

Page 2: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

Learning outcomes

The reader will learn:

• how to modify and set up the movingCylinders case to show the Magnus effect

• how to implement rigid body motion in the axialTurbine and movingCylinders tutorial similarto the wingMotion tutorial

• how to use the pointDisplacement file in the 0 directory

• how to modify the turboFvMesh class for the axialTurbine Tutoral to implement rigid bodymotion

1

Page 3: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

Contents

1 Six degrees of freedom 31.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 A tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2.1 Description of movingCylinders tutorial . . . . . . . . . . . . . . . . . . . . . 41.2.2 Modification to implement six-DoF . . . . . . . . . . . . . . . . . . . . . . . . 41.2.3 Modification of boundary condition . . . . . . . . . . . . . . . . . . . . . . . . 71.2.4 Running the case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2 The axialTurbine case 92.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 Case description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.3 Modifying the case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.3.1 Changes to the constant directory . . . . . . . . . . . . . . . . . . . . . . . . 112.3.2 Changes to the 0 orig directory . . . . . . . . . . . . . . . . . . . . . . . . . . 112.3.3 Changes to the system directory . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.4 Running the case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3 An Implementation 143.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2 Modifying the class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.2.1 Copying and changes to class . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2.2 Changes to turboSixDofFvMesh.C . . . . . . . . . . . . . . . . . . . . . . . . 153.2.3 Changes to turboSixDofFvMesh.H . . . . . . . . . . . . . . . . . . . . . . . . 173.2.4 Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.3 Modifying the axialTurbine case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.4 Running the case and Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2

Page 4: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

Chapter 1

Six degrees of freedom

1.1 Introduction

The position and orientation of a rigid body in space is defined by three components of translationand three components of rotation, which means that it has six degrees of freedom. By calculatingthe forces on a body, the rigid body motion can be solved. This is implemented in OpenFOAMwhere the forces are calculated on a rigid body and the motion is solved. By doing so we can obtaina better understanding or better results for the interaction of fluids and solid bodies. In OpenFOAMthe implementation of six DoF involves mesh motion.

The purpose of this project is to implement and evaluate the use of the sixDOF library for theaxialTurbine tutorial using foam-extend-3.2. These libraries and classes are used to solve rigid bodymotion of single or multiple bodies. There are two types of implementations of sixDOF in foam-extend-3.2. One which is a class based on the ODE library and the other is a function object. Thefirst one is called sixDOFsolver and is located in:

$FOAM_SRC/ODE/sixDOF

There are two tutorials for this and they are located in:

$FOAM_TUTORIALS/basic/sixDOFSolver/sixDOFMotion

$FOAM_TUTORIALS/basic/sixDOFSolver/springDamper

No mesh is used in the sixDOFSolver and the computational data that is generated is written to adictionary. The sixDOFSolver uses the sixDOFbodies class where the bodies are are specified andsixDoFqODE solves the rigid body motion equations and updates the dictionary for the specifiedbodies.

The other implementation is called sixDoFRigidbodyDisplacement and is located in:

$FOAM_SRC/postProcessing/functionObjects/forces/pointPatchFields/derived/

There are a few tutorials that can be found in:

$FOAM_TUTORIALS/multiphase/interDyMFoam/ras/floatingObject

$FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion

This calculates the displacement of boundary patches and morphs the mesh. This is the one that isused in the tutorials of this project.

1.2 A tutorial

Here an example of how to implement six DoF motion on a simple case is shown. The purpose ofthis is to give the reader some idea of how the sixDOF library can be used. The movingCylinders

3

Page 5: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

1.2. A TUTORIAL CHAPTER 1. SIX DEGREES OF FREEDOM

tutorial is used here. In the original case multiTopoBodyFvMesh is used and the two cylinders aremade to oscillate in the vertical or y direction with different amplitude and periods. This case waschosen only for the sake of simplicity as to avoid making a new geometry and mesh.

1.2.1 Description of movingCylinders tutorial

The mesh is shown in the figure 1.1

Figure 1.1: Mesh.

The inlet to the doamin is on the left and the outlet is on the right. The fluid is air. Thefirst cylinder is given a rotatingWallvelocity boundary condition. Here only the first cylinder(one tothe left) is required. The second cylinder is kept just for simplicity. The second cylinder could beremoved but then the blockMeshDict would need to be modified and this is avoided for the tutorial.The first cylinder is only allowed to move in the y/vertical direction. When an object, typicallycircular in cross section, rotates in a flow field there will be a velocity difference on each side. Hereit will be on the top and bottom of the cylinder. The difference of the flow velocity on the surfaceof the object will result in a pressure difference which will cause the object to move in the directionperpendicular to the flow. This is the phenomenon of Magnus effect.

1.2.2 Modification to implement six-DoF

Start by opening a new terminal and activating the foam-extend-3.2 environment. Then copyingthe case form the tutorial folders and making changes to each directory.

cd $FOAM_RUN

cp -r $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/movingCylinders \

sixDofMovingCylinder

cd sixDofMovingCylinder

To implemement six DoF we need to change the dynamicMeshDict in the constant directory. Herethe dynamicMeshDict is taken from the wingMotion case.

rm constant/dynamicMeshDict

cp -r $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/\

wingMotion2D_pimpleDyMFoam/constant/dynamicMeshDict constant/dynamicMeshDict

sed -i s/wing/firstCyl/g constant/dynamicMeshDict

For the case to work you need to remove the following line form the dynamicMeshDict. If youdon’t remove this the solver will give a warning saying that the library didn’t give any new entries.

motionSolverLibs ("libfvMotionSolver.so");

4

Page 6: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

1.2. A TUTORIAL CHAPTER 1. SIX DEGREES OF FREEDOM

The six DoF needs to be specified and this is done in the pointDisplacement file. Hence apointDisplacement file must be added to the 0 directory. It is easy to copy this file from thewingMotion case and make the changes.

cp -r $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/\

wingMotion2D_pimpleDyMFoam/0.org/pointDisplacement 0/pointDisplacement

Once copied the the modifications made to the file would be as shown below:

FoamFile

{

version 2.0;

format ascii;

class pointVectorField;

location "0.01";

object pointDisplacement;

}

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

dimensions [0 1 0 0 0 0 0];

internalField uniform (0 0 0);

boundaryField

{

firstCyl

{

type sixDoFRigidBodyDisplacement;

mass 2;

centreOfMass (0 0 0);

momentOfInertia (0.00169 0.00169 0.000048);

orientation

(

1 0 0

0 1 0

0 0 1

);

velocity (0 0 0);

acceleration (0 0 0);

angularMomentum (0 0 0);

torque (0 0 0);

rhoName rhoInf;

rhoInf 1;

report on;

constraints

{

maxIterations 500;

fixedLine1

{

sixDoFRigidBodyMotionConstraint fixedLine;

tolerance 1e-9;

relaxationFactor 0.7;

fixedLineCoeffs

{

refPoint (0 0 0);

5

Page 7: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

1.2. A TUTORIAL CHAPTER 1. SIX DEGREES OF FREEDOM

direction (0 1 0); //Allow vertical movement

}

}

}

value uniform (0 0 0);

}

defualtFaces

{

type empty;

}

".*"

{

type fixedValue;

value uniform (0 0 0);

}

}

In the above file we need to specify the first cylinder as a rigid body. This mean specifying itsmass, center of mass, moment of inertia, orientation. The mass chosen is 2 kg and the momentof inertia is calculated from the basic equations for a cylinder. The radius of the cylinder andthe center was obtained from the blockMeshDict file. We also can specify if they rigid body hassome prescribed motion. Here we set everything to zero. This maybe contradictory as we want thecylinder to rotated about its center. This is implemented through a rotaingWallVelocity boundarycondition and will be shown later. We can also chose to constrain the motion of the cylinder in acertain translation or rotational direction. Here we chose allow only translation in the vertical or ydirection and this can be seen under directions which is under constraints. The remaining are setto a fixedValue and as this is a 2D case, the front and back walls are set to empty.

The calculations for mesh motion need to be made. This is done by specifying the cellDisplace-ment solver in system/fvSolution directory. The following is to be added after the specification forU under solvers:

cellDisplacement

{

solver GAMG;

tolerance 1e-5;

relTol 0;

smoother GaussSeidel;

cacheAgglomeration true;

nCellsInCoarsestLevel 10;

agglomerator faceAreaPair;

mergeLevels 1;

}

In system/fvSchemes under laplacian scheme, add the following line:

laplacian(diffusivity,cellDisplacement) Gauss linear limited 0.5;

The forces library needs to be specified somewhere for the case to work. In the pointDisplacementfile, the patchField type for the firstCyl is set as sixDoFRigidBodyDisplacement. This comes is underthe forces library and hence for the solver to work it must be specified in the controlDict. If notdone so the solver will complain that patchField type sixDoFRigidBodyDisplacement is undefined.In the system/controlDict file add the following line at the end.

libs ("libforces.so");

6

Page 8: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

1.2. A TUTORIAL CHAPTER 1. SIX DEGREES OF FREEDOM

1.2.3 Modification of boundary condition

The velocity boundary conditions for the cylinders need to be changed in the 0/U file. The changesmade should look like these:

firstCyl

{

type rotatingWallVelocity;

origin (0 0 0);

axis (0 0 1);

omega 210;

value uniform (0 0 0);

}

secondCyl

{

type fixedValue;

value uniform (0 0 0);

}

For the rotatingWallVelocity boundary condition the origin is constant and it isn’t moving with thecylinder. This mean that the velocity is no longer tangential to the wall of the cylinder. However,the displacement of the cylinder for this case is small and we will not make any changes to theboundary condition.

The case is now ready to run.

1.2.4 Running the case

Run the case using the Allrun scripts as follows:

./Allrun >& log &

The first cylinder (on the left) is rotating in the anti-clockwise direction which was implementedby applying a rotaingWallVelocity boundary condition. This means that there will be a differenceof fluid velocity on the top and bottom surface of the cylinder. There will be higher velocity onthe bottom and lower velocity on the top. Due to the velocity differences there will be a pressuredifference which will cause the cylinder to move in the downward direction. Figure 1.2 shows thepressure contour at the end 0f 10s. It can be seen there is a lower pressure on the bottom of thecylinder.

The displacement of the cylinder may not be easily visible at 10 seconds but a slight deformationof mesh is visible. It is advised that the reader either run the simulation longer or increase the inletvelocity. It should be noted that the Reynolds number for the current simulation is 1400. So if thereader chooses to increase the velocity, a turbulence model should be implemented.

Figure 1.3 shows the cell displacement in the y direction at 10s. The displacement above andbelow the cylinder are symmetrical which confirms that the cylinder has moved down. However thecell displacement is not symmetrical to the left and right of the cylinder. This has to do with themesh on both sides of the cylinder and shouldn’t be confused with the movement in the horizontaldirection.

7

Page 9: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

1.2. A TUTORIAL CHAPTER 1. SIX DEGREES OF FREEDOM

Figure 1.2: Pressure contour

Figure 1.3: Cell displacement magnitude

8

Page 10: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

Chapter 2

The axialTurbine case

2.1 Introduction

Here sixDofRigidbodyDisplacement is implemented similarly to the way it was for the movingCylin-ders tutorial. The axialTurbine case is found in the tutorial folder at:

$FOAM_TUTORIAL/incompressible/pimpleDyMFoam/axialTurbine

This case uses the turboFvMesh class to specify a rotation to cells that need to be rotated. Thisclass is implemented in the dynamicMeshDict which looks like the following:

dynamicFvMesh turboFvMesh;

turboFvMeshCoeffs

{

coordinateSystem

{

type cylindrical;

origin (0 0 0);

axis (0 0 1);

direction (1 0 0);

}

rpm

{

rotor -95.49578;

}

slider

{

RUINLET -95.49578;

RUOUTLET -95.49578;

RUCYCLIC1 -95.49578;

RUCYCLIC2 -95.49578;

}

}

Here rotor is a cell zone created from the blockMeshDict and it is given a constant rotation. Insteadof specifying a rpm value, six-DoF will be used to calculate the forces on the blade of the turbine togive a rigid body motion.

9

Page 11: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

2.2. CASE DESCRIPTION CHAPTER 2. THE AXIALTURBINE CASE

2.2 Case description

Figure 2.1 shows the geometry of the case. The RUHUB, RUBLADE, RUINLET, RUOUTLET andRUSHROUD are the boundaries of the rotor zone.

Figure 2.1: Geometry of the case

Figure 2.2: Mesh

Figure 2.2 shows the mesh of the case. The domain is only a section between a pair of bladeswith a cyclic boundary condition. This can be seen by comparing figure 2.1 and 2.2

2.3 Modifying the case

As usual start by activating the foam-extend 3.2 environment and copying the case from the tutorialsdirectory

cd $FOAM_RUN

cp -r $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/axialTurbine \

sixDofAxialTurbine

cd sixDofAxialTurbine

10

Page 12: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

2.3. MODIFYING THE CASE CHAPTER 2. THE AXIALTURBINE CASE

2.3.1 Changes to the constant directory

As in the previous tutorial we will start by replacing the dynamicMeshDict with the one from thewingMotion case.

rm constant/dynamicMeshDict

cp -r $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/\

wingMotion2D_pimpleDyMFoam/constant/dynamicMeshDict constant/dynamicMeshDict

sed -i s/wing/RUBLADE/g constant/dynamicMeshDict

The dynamicMeshDict looks like:

dynamicFvMesh dynamicMotionSolverFvMesh;

solver displacementLaplacian;

diffusivity inverseDistance (RUBLADE);

2.3.2 Changes to the 0 orig directory

A pointDisplacement file needs to be created in this directory and is done as before. Copy it fromthe wingMotion case and make changes.

cp -r $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/wingMotion/\

wingMotion2D_pimpleDyMFoam/0.org/pointDisplacement 0_orig/pointDisplacement

Once this is done, the change to be made should look as follows:

FoamFile

{

version 2.0;

format ascii;

class pointVectorField;

location "0.0175";

object pointDisplacement;

}

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

dimensions [0 1 0 0 0 0 0];

internalField uniform (0 0 0);

boundaryField

{

RUBLADE

{

type sixDoFRigidBodyDisplacement;

mass 10;

centreOfMass (0 0 0);

momentOfInertia (0.05 0.02 0.025);

orientation

(

1 0 0

0 1 0

0 0 1

);

velocity (0 0 0);

11

Page 13: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

2.3. MODIFYING THE CASE CHAPTER 2. THE AXIALTURBINE CASE

acceleration (0 0 0);

angularMomentum (0 0 0);

torque (0 0 0);

rhoName rhoInf;

rhoInf 1;

g (0 0 -9.81)

report on;

constraints

{

maxIterations 500;

zAxis

{

sixDoFRigidBodyMotionConstraint fixedAxis;

tolerance 1e-06;

relaxationFactor 0.07;

fixedAxisCoeffs

{

axis ( 0 0 1 );

}

}

}

value uniform (0 0 0);

}

".*"

{

type fixedValue;

value uniform (0 0 0);

}

}

There are a few things to note from the above code.

1. Here the mass is set to 10 kg and is chosen at random.

2. the moment of inertia about the z axis is calculated on the basis of the mass and a guessedvalue of radius of gyration. The values in the other two axis are also guessed. This is done tosee if the test if the case runs. Making drastic changes to these values will obviously not work.

3. Under constraints, zAxis is for allowing rotation about the z axis.

4. Here the rotation is applied only to the rotor blades patches which is not a good approach asthe mesh will distort and this is shown later in the report.

2.3.3 Changes to the system directory

Cell displacement solver needs to be added in the fvSolution file. Add the following lines undersolvers at the end (after the specification of k|epsilon).

cellDisplacement

{

solver PCG;

preconditioner DIC;

tolerance 1e-07;

12

Page 14: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

2.4. RUNNING THE CASE CHAPTER 2. THE AXIALTURBINE CASE

relTol 0.01;

}

Add the following line at the end of the controlDict file:

libs ( "libforces.so" );

If we ran the case at now at a certain point the k and epsilon will show zero number of iterationswill diverge. So to make the case to run we will force k and epsilon to iterate at least once. In thethe fvSolution file, under ”(k|epsilon)” a minimum iteration of 1 should be added. This is done byusing minIter so the specification of k and epsilon look like:

"(k|epsilon)"

{

solver PBiCG;

preconditioner DILU;

tolerance 1e-06;

relTol 0.1;

minIter 1;

}

2.4 Running the case

Before running the case change the endTime to 3 or more in the system/controlDict file. To run thecase, use the Allrun script

./Allrun >& log &

Figure 2.3 shows the pressure contour at 3 seconds. More importantly, the mesh deformation isvisible. It can be seen that the RUBLADE patch has rotated. There was a floating point error at3 seconds of simulating time. In this type of implementation, the sixDoFRigidbodyDisplacementfunction object calculates the forces on the patch specified (RUBLADE) and then deforms the mesh.This will then destroy the mesh.

Figure 2.3: Pressure contour at 3 sec

13

Page 15: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

Chapter 3

An Implementation

3.1 Introduction

This section shows how to use the code that calculates the forces and moments in the sixDoFRigid-bodyDisplacement function object to calculate an rpm in the turboFvMesh. This is taken fromthe tutorial by Erik Krane [1] and is simplified here for our purpose. The changes made will bepointed out in this chapter. The main change made is that an initial rpm is not specified and iscalculated. This mean that the user will not input a value. An input of mass and a guessed valueof radius of gyration is used to calculate the moment of inertia from the dynamicMeshDict. Also noextracted shaft moment is used in the calculation. We can obtain a similar result from Erik’s workbuy inputting a zero rpm, but that would need to be entered in the dynamicMeshDict.

3.2 Modifying the class

Open a new terminal and start by activating the foam-extend 3.2 environment.

3.2.1 Copying and changes to class

We start by copying the original class into the user directory and then rename the original class andchange the name inside the files as well.

cd $WM_PROJECT_DIR

cp -r --parents src/dynamicMesh/dynamicFvMesh/turboFvMesh $WM_PROJECT_USER_DIR

cd $WM_PROJECT_USER_DIR/src/dynamicMesh/dynamicFvMesh

mv turboFvMesh turboSixDofFvMesh

cd turboSixDofFvMesh

mv turboFvMesh.C turboSixDofFvMesh.C

mv turboFvMesh.H turboSixDofFvMesh.H

rm dynamicMeshDict *.dep

sed -i s/turboFvMesh/turboSixDofFvMesh/g turboSixDofFvMesh.*

Now we create the Make directory which will contain files and options files.

cd ..

mkdir Make

touch Make/files

touch Make/options

In Make/files add the following lines:

turboSixDofFvMesh/turboSixDofFvMesh.C

LIB = $(FOAM_USER_LIBBIN)/libmyDynamicFvMesh

14

Page 16: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

3.2. MODIFYING THE CLASS CHAPTER 3. AN IMPLEMENTATION

In Make/options add the following:

EXE_INC = \

-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \

-I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \

-I$(LIB_SRC)/finiteVolume/lnInclude \

-I$(LIB_SRC)/postProcessing/functionObjects/forces/lnInclude \

-I$(LIB_SRC)/meshTools/lnInclude

LIB_LIBS = \

-ldynamicMesh \

-ldynamicFvMesh \

-lfiniteVolume \

-lforces \

-lmeshTools

At this point it is good to compile the code and check if everything is fine. This done by typingthe following in the terminal.

wclean

wmake libso

3.2.2 Changes to turboSixDofFvMesh.C

We can now make changes to the files inside the turboSixDofFvMesh class. The reader can use geditto make the changes to the turboSixDofFvMesh.C file. This is done by typing:

cd turboSixDofFvMesh

gedit turboSixDofFvMesh.C

Add the header to calculate the forces (after line 34):

#include "forces.H"

The rpm is constant and is prevented from being updated for each time step. The forces needto be calculated to update the rpm each time step. To do this, few things need to be removed.Startby removing ’const’ from the following line

void Foam::turboSixDofFvMesh::calcMovingPoints() const

Remove the the following code (between line 57 and 62):

if (movingPointsPtr_)

{

FatalErrorIn("void turboFvMesh :: calcMovingMasks () const")

<< "point mask already calculated"

<< abort(FatalError);

}

The next line in the code is ”// Retrieve the cell zone Names”” and this should be on line 58.Delete a space or add depending on how you have removed the above code. Now add the part thatcalculates the rpm from the forces. Delete the code between lines 71 and 81 and add the followingafter the line ”scalar rpm” which is on line number 67.

scalar alpha;

const scalar Pi(3.14159265359);

forAll (cellZoneNames,cellZoneI)

{

const labelList& cellAddr =

cellZones()[cellZones().findZoneID(cellZoneNames[cellZoneI])];

15

Page 17: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

3.2. MODIFYING THE CLASS CHAPTER 3. AN IMPLEMENTATION

if (dict_.subDict("rpm").found(cellZoneNames[cellZoneI]))

{

//Read input from dynamicMeshDict

const scalar mass = readScalar(

dict_.subDict("input").lookup("mass") );

const scalar rg = readScalar(

dict_.subDict("input").lookup("rg") );

const vector CofR =

dict_.subDict("coordinateSystem").lookup("origin");

const scalar rhoInf = readScalar(

dict_.subDict("input").lookup("rhoInf") );

const wordList patches =

dict_.subDict("forcePatches").lookup(cellZoneNames[cellZoneI]);

scalar Mflow;

scalar Iz;

//Calculate forces

dictionary forcesDict;

forcesDict.add("patches", patches);

forcesDict.add("rhoName", "rhoInf");

forcesDict.add("rhoInf", rhoInf);

forcesDict.add("CofR", CofR);

//Calculate rpm

forces F("forces", *this, forcesDict);

forces::forcesMoments fm = F.calcForcesMoment();

Mflow = fm.second().first().z()+fm.second().second().z();

Iz = mass*rg*rg;

alpha = ( Mflow )/Iz;

rpm = ((30/Pi)*alpha )*time().deltaT().value();

After this the following line should be on 109. Remove or add a blank line if need:

Info<< "Moving Cell Zone Name: " << cellZoneNames[cellZoneI]

The slider rpm also needs to be changed. Delete line 148 and replace with the following:

dict_.lookup(dict_.subDict("slider").lookup(faceZoneNames[faceZoneI]))

Just to confirm the above change, lines 144 to 152 should like as follows:

if (dict_.subDict("slider").found(faceZoneNames[faceZoneI]))

{

rpm = readScalar

(

dict_.lookup(dict_.subDict("slider").lookup(faceZoneNames[faceZoneI]))

);

Info<< "Moving Face Zone Name: " << faceZoneNames[faceZoneI]

<< " rpm: " << rpm << endl;

Also remove the second ’const’ and the if condition from the following (under member function,between line 237 and 245):

16

Page 18: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

3.3. MODIFYING THE AXIALTURBINE CASE CHAPTER 3. AN IMPLEMENTATION

const Foam:: vectorField& Foam::turboSixDofFvMesh::movingPoints ()

const

{

if (! movingPointsPtr_)

{

calcMovingPoints ();

}

return *movingPointsPtr_;

}

The above code should look like this:

const Foam:: vectorField& Foam::turboSixDofFvMesh::movingPoints ()

{

calcMovingPoints ();

return *movingPointsPtr_;

}

3.2.3 Changes to turboSixDofFvMesh.H

The const declaration should be removed from the following lines:

//- Calculate moving Points

void calcMovingPoints () const;

//- Return moving points

const vectorField& movingPoints () const;

3.2.4 Compiling

The case is now modified and ready to be compiled.

cd ..

wclean

wmake libso

3.3 Modifying the axialTurbine case

Start by copying the case from the tutorials directory.

cd $FOAM_RUN

cp -r $FOAM_TUTORIALS/incompressible/pimpleDyMFoam/axialTurbine \

./axialTurbineMod

cd axialTurbineMod

The dynamicMeshDict needs to be modified and should look as follows:

dynamicFvMesh turboSixDofFvMesh;

turboSixDofFvMeshCoeffs

{

coordinateSystem

{

type cylindrical;

origin (0 0 0);

axis (0 0 1);

17

Page 19: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

3.4. RUNNING THE CASE AND RESULTS CHAPTER 3. AN IMPLEMENTATION

direction (1 0 0);

}

rpm

{

rotor;

}

forcePatches

{

rotor ( RUBLADE );

}

input

{

rhoInf 1000;

mass 10;

rg 0.05;

}

slider

{

RUINLET "rotor";

RUOUTLET "rotor";

RUCYCLIC1 "rotor";

RUCYCLIC2 "rotor";

}

}

Here rotor is specified in the dynamicMeshDict so the class know what zone needs to be rotated.However the no value of rpm is entered and this is the main difference from the work done by Erik.For the case to use the new class the library needs to be specified in the controlDict file. Add thefollowing line to the end system/controlDict:

libs ("libmyDynamicFvMesh.so");

The following needs to be added in system/fvSolution for the case to run properly.

"(k|epsilon)"

{

solver PBiCG;

preconditioner DILU;

tolerance 1e-06;

relTol 0.1;

minIter 1;

}

3.4 Running the case and Results

Before running the case change the stop time to 3 in the system/controlDict file. Run the case byusing the Allrun script:

./Allrun >& log &

Figure 3.1 shows the pressure contour at 3 seconds. The rotation of cells in the rotor region isalso visible. It is interesting to note that the degree of rotation is about the same as that from figure

18

Page 20: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

3.4. RUNNING THE CASE AND RESULTS CHAPTER 3. AN IMPLEMENTATION

2.3 for the same mass and moment of inertia about the z-axis. Here the mesh is not distorted as inchapter two and a rpm value is calculated from the forces on the RUBLADE patch which is donesimilarly to that in the sixDoFRigidbodyDisplacement.

Figure 3.1: Pressure contour at 3 sec

19

Page 21: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

Study questions

1. In what way is six DoF implemented in foam-extend-3.2?

2. What is used to calculate the displacement of cells in a mesh and how is it implemented?

3. Where is the forces library specified when using sixDoFRigidBodyDisplacement?

4. Give one example each of where the Magnus effect is used in engineering and fluid dynamics.

5. What is pointDisplacement used for?

6.

20

Page 22: Project work: Implementation of 6-DoF on axialTurbine ... · Project work: Implementation of 6-DoF on axialTurbine tutorial case ... This is a student project work, done as part of

References

[1] Erik Krane, 2014, ”A tutorial on modification of the turboFvMesh class for flow-driven rotation.”

http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2014/Erik%20Krane/Documents/

A_tutorial_on_modification_of_the_turboFvMesh_class_for_flow-driven_rotation.pdf

21