51
Cite as: Surya Kaundinya,O.: Implementation of cavitation models into the multiphaseEulerFoam solver. In Proceedings of CFD with OpenSource Software, 2017, Edited by Nilsson. H., http://dx.doi.org/10.17196/OS_CFD#YEAR_2017} CFD with OpenSource software A course at Chalmers University of Technology Taught by H˚ akan Nilsson Implementation of cavitation models into the multiphaseEulerFoam solver Developed for OpenFOAM-v1706 Author: Surya Kaundinya Oruganti Volvo and Ecole Centrale de Lyon [email protected] Peer reviewed by: Henrik Grimler Ebrahim Ghahramani 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. December 21, 2017

Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Embed Size (px)

Citation preview

Page 1: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Cite as: Surya Kaundinya,O.: Implementation of cavitation models into the multiphaseEulerFoam solver.In Proceedings of CFD with OpenSource Software, 2017, Edited by Nilsson. H.,

http://dx.doi.org/10.17196/OS_CFD#YEAR_2017}

CFD with OpenSource software

A course at Chalmers University of TechnologyTaught by Hakan Nilsson

Implementation of cavitation models intothe multiphaseEulerFoam solver

Developed for OpenFOAM-v1706

Author:Surya Kaundinya OrugantiVolvo and Ecole Centrale de [email protected]

Peer reviewed by:Henrik Grimler

Ebrahim Ghahramani

Disclaimer: This is a student project work, done as part of a course where OpenFOAM and some otherOpenSource 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 onespresented 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.

December 21, 2017

Page 2: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Learning outcomes

The reader will learn:

How to use:

• the multiphaseEulerFoam solver for modelling cavitating flows.

The theory of:

• the formulation of the multiphaseEulerFoam solver.

• the formulation of cavitation models and the changes required for their implementation in themultiphaseEulerFoam solver.

How to implement:

• throttle3phase tutorial to model the influence of the third phase (i.e. air) on the cavitation offuel/liquid.

1

Page 3: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Prerequisites

In order to benefit from this report the reader is expected to have some prior knowledge on :

• the formulations of interFoam, interPhaseChangeFoam, twoPhaseEulerFoam and MULES inOpenFOAM.

• the dambreak tutorial of interFoam and throttle tutorial of cavitatingFoam.

2

Page 4: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Contents

1 Introduction 51.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.2 Selection of the solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 multiphaseEulerFoam 62.1 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2 damBreak4phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2.1 transportProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 multiphaseEulerFoam solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.4 Coupling VOF and multifluid Eulerian approaches . . . . . . . . . . . . . . . . . . . 10

2.4.1 multiphaseSystem.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.4.2 mulitphaseSystem.C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.5 Implementation of dragModel class in the solver . . . . . . . . . . . . . . . . . . . . 14

3 multiphaseChangeEulerFoam - an extension to cavitating flows 173.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2 interPhaseChangeFoam - an overview . . . . . . . . . . . . . . . . . . . . . . . . . . 173.3 Implementing phaseChangeModel class . . . . . . . . . . . . . . . . . . . . . . . . . . 18

3.3.1 Compiling the new solver without any changes . . . . . . . . . . . . . . . . . 183.3.2 Adding phaseChangeModel class . . . . . . . . . . . . . . . . . . . . . . . . . 193.3.3 Adding Kunz Cavitation model . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.4 Adding source terms to solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.4.1 Changes to multiphaseSytem.H file . . . . . . . . . . . . . . . . . . . . . . . 223.4.2 Changes to multiphaseSytem.C file . . . . . . . . . . . . . . . . . . . . . . . . 23

4 Tutorial 264.1 throttle3phase - Test case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.1.1 Meshing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.1.2 transportProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.1.3 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.1.4 setFieldsDict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.1.5 turbulenceProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.1.6 Solver settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

4.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

5 Appendix 345.1 Implementation of phaseChangeModel - the abstract class . . . . . . . . . . . . . . . 34

5.1.1 phaseChangeModel.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.1.2 phaseChangeModel.C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365.1.3 newPhaseChangeModel.C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5.2 Implementation of Kunz model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.2.1 Kunz.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.2.2 Kunz.C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3

Page 5: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

5.3 Changes to multiphaseSystem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405.3.1 multiphaseSystem.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405.3.2 multiphaseSystem.C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405.3.3 Adding source terms to pEqn.H . . . . . . . . . . . . . . . . . . . . . . . . . . 455.3.4 transportProperties used for tutorials . . . . . . . . . . . . . . . . . . . . . . 46

4

Page 6: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Chapter 1

Introduction

1.1 Background

In many multiphase flows, phase changes like evaporation, cavitation etc. are very important. Forexample in fuel injection systems, the fuel mixes with air and evaporates inside the cylinder. Atthe same time the fuel also cavitates inside the injector nozzle. In both cases we have a three phaseflow i.e air, fuel and fuel vapor. So far, the solver capabilities to model only two-phase flows usingeither VOF or Euler-Euler approaches has been the limiting factor in assessing the effects of thethird phase.This project is an unique attempt to develop a generic n-phase solver with phase changecapabilities to study the multiphase flows of fuel-injection systems.

1.2 Selection of the solver

OpenFoam has two different classes of solvers for modelling cavitation.

1. cavitatingFoam which is based on homogeneous relaxation method (HRM). The model calcu-lates the growth of cavitation using a barotropic equation of state which relates density andpressure.

2. interPhaseChangeFoam uses VOF approach to resolve the interface between the phases. Theliquid-vapor mass transfer (evaporation and condensation) is governed by the vapor transportequation. This model assumes an incompressible flow.

Both the solvers are for two phase flows. Previously an attempt has been made by Karrholm [1]to develop a solver in OpenFOAM specifically to model the three phase cavitating flows. It usesVOF to resolve the air/fuel interface and HRM approach for modelling the phase change from fuelto vapor. But in the recent versions of OpenFOAM, more generic approaches for modelling n-phaseflows like multiphaseEulerFoam have been developed. The solver is based on n-phase Eulerian multi-fluid method for individually solving the flow equations of each phase and uses the VOF interfacecapturing approach for selected phase pairs. By default, the solver is not capable of modelling thephase change from one phase to another. So in this paper an attempt is made to extend this solverfor modelling cavitating flows. In this process, a new solver i.e. multiphaseChangeEulerFoam hasbeen developed to consider the effects of phase change due to cavitation.This study is not restrictedspecifically for three phase cavitating flows. But it can be treated as a generic guideline to ex-tend the multiphaseEulerFoam solver for modelling any phase change phenomenon like evaporation,condensation etc. Before proceeding to the development of multiphaseChangeEulerFoam solver, ashort description of multiphaseEulerFoam is presented. The damBreak4phase tutorial is used inparallel to explain how the different formulations are implemented in the solver. Then a detailedexplanation of some of the important changes required to extend the multiphaseEulerFoam solverfor cavitating flows is presented. Finally, the throttle tutorial from cavitatingFoam solver is used totest the multiphaseChangeEulerFoam solver.

5

Page 7: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Chapter 2

multiphaseEulerFoam

2.1 Theory

The multiphaseEulerFoam solver enables simultaneous modelling of complex multiphase flows withdifferent flow regimes, as described by Wardle [2]. (i.e. both dispersed and segregated flows). Usu-ally the VOF interface capturing method is used to model the large fluid-fluid interfaces, whereasthe Euler multi-fluid approach is used for modelling the dispersed flow. The two approaches arecoupled by a simplified switching term, which is defined for each phase pair. Basically the solveris a combination of two multiphase solvers i.e. interFoam and twoPhaseEulerFoam with additionalsub-models to couple both the approaches.A detailed study on the VOF and multi-fluid Euler approaches is presented in the work of Rusche[3].For simplicity, only a short description of the governing equations for both the approaches is pre-sented here. The multi-fluid model equations for incompressible, isothermal flow are given by a setof mass and momentum equations for each phase k,

∂αk∂t

+ uk.∇(αk) = 0 (2.1)

∂(ρkαkuk)

∂t+ (ρkαkuk.∇)(uk) = −αk∇p+∇.(µkαk∇uk) + Fg + FD,k + Fst,k (2.2)

where the density, phase fraction, and velocity for phase k are given by ρk, αk, uk and Fg is thegravitational force. The two interfacial forces are the drag force FD,k and the surface tension forceFst,k . For selected phase pairs where the VOF method is used to resolve the interface, an additionalcompression term is added to their phase transport equation.

∂αk∂t

+ uk.∇(αk) +∇.(αk(1− αk)uc) = 0 (2.3)

uc is the artificial compression velocity term acting normal to the interface and is given by

uc = Cα∇αk|∇αk|

(2.4)

Here Cα is used as a binary switch for determining if interface compression is to be used or not. Bysetting Cα to 0, the solver is purely Euler-Euler in nature and considers the flow as dispersed flow.On the other hand when Cα is 1, the sharp interface between the phases is resolved using the VOFapproach. This makes the solver to consider the flow as segregated.

2.2 damBreak4phase

For easy understanding of the solver, the damBreak4phase tutorial is presented first. The tutorialis similar to damBreak tutorial of interFoam, but with 4 phases i.e. air, oil, water and mercury asshown in figure 2.1. The tutorial should be copied to user run directory.

6

Page 8: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Figure 2.1: damBreak4phase - initial condition

In figure 2.1, alphas is a scalar indicator referring to different phases i.e. 0 represents water, 1represents oil, 2 represents mercury, 3 represents air.

1 cp −r $FOAM TUTORIALS/mult iphase /multiphaseEulerFoam/damBreak4phase2 $WM PROJECT USER DIR/run3 cd $WM PROJECT USER DIR/run/damBreak4phase

2.2.1 transportProperties

The most interesting aspect of the solver is how it solves for more than 2 phases and how, for selectedphase pairs the VOF method is implemented. The answers to some of these questions can be foundin the transportProperties, where the properties of the multiphase system and the phase interfacesare defined. The transportProperties has two sections. The first one is the phases dictionary, wherethe individual phase properties are defined as shown below:

1 phases2 (3 water4 {5 nu 1e−06;6 kappa 1e−06;

7

Page 9: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

7 Cp 4195 ;8 rho 1000 ;9 diameterModel constant ;

10 cons tantCoe f f s11 {12 d 1e−3;13 }14 }15 o i l16 {17 nu 1e−06;18 kappa 1e−06;19 Cp 4195 ;20 rho 500 ;21 diameterModel constant ;22 cons tantCoe f f s23 {24 d 1e−3;25 }26 }27

28 . . . .29 . . . .30 ) ;

The second section defines the sub-models for different phase interfaces. Here the sigmas dictionaryis a list of surface tension values at different phase interfaces. Also the phase pairs for which theinterface tracking is used is defined using the dictionary interfaceCompression. The sigma valuesare defined only for those phase pairs where interface compression is used. The important pointto be noted here is that all these properties are not for single phase but are described for a phasepair (phase1 , phase2). It will be interesting to know, how the solver calculates these properties forselected phase pairs only. This will be explained in later sections from the source code.

1

2 sigmas3 (4 ( a i r water ) 0 .075 ( a i r o i l ) 0 .076 ( a i r mercury ) 0 .077 ) ;8

9 i n t e r faceCompres s i on10 (11 ( a i r water ) 112 ( a i r o i l ) 113 ( a i r mercury ) 114 ) ;

For the dambreak4phase test case, the interface compression is used only for phases in contact withair. If for a phase pair the interfaceCompression is not specified, then it assumes a default value of0. So all other phases are modelled as inter-dispersed. Also for each phase pair the drag modelshave to be defined. These drag models calculate the drag force coefficient (K) for each phase pair.For different phase pairs different drag models can be selected.

1 drag2 (3 ( a i r water )4 {5 type blended ;6

7 a i r8 {9 type Schil lerNaumann ;

10 r e s idua lPhaseFrac t i on 0 ;11 r e s i d u a l S l i p 0 ;12 }13 water

8

Page 10: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

14 {15 type Schil lerNaumann ;16 r e s idua lPhaseFrac t i on 0 ;17 r e s i d u a l S l i p 0 ;18 }19

20 r e s idua lPhaseFrac t i on 1e−3;21 r e s i d u a l S l i p 1e−3;22 }23

24 ( a i r o i l )25 {26 . . . .27 . . . .28 }29 ( a i r mercury )30 {31 . . . .32 . . . .33 }34 . . . .35 . . . .36 )

The simulation can be run by using the ./Allrun command. The distribution of different phases canbe seen in figure 2.2

Figure 2.2: Phase distribution at t=0.6s

2.3 multiphaseEulerFoam solver

The multiphaseEulerFoam solver files are located in :

1 $ FOAM SOLVERS/mult iphase /multiphaseEulerFoam

9

Page 11: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

The multiphaseEulerFoam.C is the main application file which provides an overview of sequentialexecution of the flow equations. The important lines of the code are shown below:

1 #inc lude ”multiphaseSystem .H”2 #inc lude ”phaseModel .H”3 #inc lude ”dragModel .H”4 #inc lude ”heatTransferModel .H”

phaseModel defines the properties of individual phases as shown in the phases dictionary of thetransportProperites file. The multiphaseSystem header file solves the phase transport equationsfor each individual phase.It also calculates the interface properties of different phase pairs. The lasttwo files i.e. dragModel and heatTransferModel define the parent class of different sub-models usedfor defining interfacial properties between each individual phase pairs. The following lines describethe PIMPLE algorithm which solves the flow equations.

1 // −−− Pressure−v e l o c i t y PIMPLE co r r e c t o r loop2 whi le ( pimple . loop ( ) )3 {4 // So lve s the turbu lence equat ion and c o r r e c t s the v i s c o s i t y5 turbulence−>c o r r e c t ( ) ;6

7 // So lve s the phase t ranspo r t equat ions o f each phase8 f l u i d . s o l v e ( ) ;9

10 // Ca l cu l a t e s the mixture dens i ty11 rho = f l u i d . rho ( ) ;12

13 #inc lude ”zonePhaseVolumes .H”14

15 // Momentum Pred i c to r s tep f o r each phase16 #inc lude ”UEqns .H”17

18 // −−− Pressure c o r r e c t o r loop19 whi le ( pimple . c o r r e c t ( ) )20 {21 #inc lude ”pEqn .H”22 }23 #inc lude ”DDtU.H”24 }

2.4 Coupling VOF and multifluid Eulerian approaches

From the PIMPLE algorithm it is evident that the phase transport equations are solved by fluid.solve()

function, where fluid is an object of the multiphaseSystem class. It is defined as shown below increateFields.H. So in the following sections a brief overview of the multiphaseSystem class ispresented.

1 multiphaseSystem f l u i d (U, phi ) ;

2.4.1 multiphaseSystem.H

The multiphaseSystem class is basically derived from transportModel class and extends it formodelling in-compressible multi-phase mixtures with built in solution for the phase fractions withinterface compression for interface-capturing.

1 #inc lude ” in compre s s i b l e / transportModel / transportModel .H”2 #inc lude ” IOdic t ionary .H”3

4 c l a s s multiphaseSystem :5 pub l i c IOdict ionary ,6 pub l i c transportModel

10

Page 12: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

As described in transportProperties file, the interface properties are described for phase pairsi.e. (phase1, phase2). In order to read and process the properties of phase pairs, a sub-classinterfacePair is defined.

1 i n t e r f a c ePa i r ( const phaseModel& alpha1 , const phaseModel& alpha2 ) :2 Pair<word>(alpha1 . name ( ) , alpha2 . name ( ) )3 {}

The interfacePair class has another sub-class symmHash which is a hash function. The symmHash

generates a unique key value for each phase pair. When a specific property value from the list ofinterfacePair’s has to be retrieved the symmHash indexes to the key generated for the specific phasepair.

1 c l a s s symmHash :2 pub l i c Hash<i n t e r f a c ePa i r>3 {4 pub l i c :5 symmHash ( )6 {}7

8 l a b e l operator ( ) ( const i n t e r f a c ePa i r& key ) const9 {

10 r e turn word : : hash ( ) ( key . f i r s t ( ) ) + word : : hash ( ) ( key . second ( ) ) ;11 }12 } ;

Here a hash table called as scalarCoeffSymmTable is defined as shown below. It is an array ofscalar values for different interfacePairs. Now for modelling the interface capturing at selected phasepairs, an object of hash table scalarCoeffSymmTable, cAlphas_ is created. For each interfacePairdefined, a key is generated by the symmHash function and using this key the corresponding Cα canbe retrieved.

1 typede f HashTable<s ca l a r , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>2 scalarCoeffSymmTable ;3 scalarCoeffSymmTable cAlphas ;

The phase transport equations of different phases are solved using the void functions solve andsolveAlphas.

1 void so lveAlphas ( ) ;2 void s o l v e ( ) ;

2.4.2 mulitphaseSystem.C

The multiphaseSystem class has several functions. But the focus of this section will be on read() ,solve() and solveAlphas() member functions.The read() member function reads the user inputdata from the transportProperties file as shown below:

1 bool Foam : : multiphaseSystem : : read ( )2 {3 i f ( r eg IOobject : : read ( ) )4 {5 bool readOK = true ;6 PtrList<entry> phaseData ( lookup ( ” phases ” ) ) ;7 l a b e l phase i = 0 ;8 f o r A l l I t e r ( PtrDict ionary<phaseModel>, phases , i t e r )9 {

10 readOK &= i t e r ( ) . read ( phaseData [ phase i ++]. d i c t ( ) ) ;11 }12 lookup ( ” sigmas ” ) >> s igmas ;13 lookup ( ” inte r faceCompres s i on ” ) >> cAlphas ;14 lookup ( ” v i r tua lMass ” ) >> Cvms ;15 r e turn readOK ;16 }17 e l s e18 {

11

Page 13: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

19 r e turn f a l s e ;20 }21 }

Here it can be seen that the entire list of interfaceCompression values defined for different phasepairs is stored in the hash table cAlphas_. Similarly the surface tension and virtual mass values arestored in the hash tables sigmas_ and Cvms_.The solve() function mainly performs the temporal sub-cycling of the phase transport equationsolution for a given time step.This usually ensures boundedness of the solution and also speeds upthe solution time for solving other transport equations. As shown below in solve() function, forevery sub-cycle the function solveAlphas() is called to solve the phase transport equations.

1 const Time& runTime = mesh . time ( ) ;2 const d i c t i ona ry& alphaContro l s = mesh . s o l v e rD i c t ( ” alpha ” ) ;3 l a b e l nAlphaSubCycles ( readLabel ( a lphaContro l s . lookup ( ”nAlphaSubCycles” ) ) ) ;4 f o r5 (6 subCycleTime alphaSubCycle7 (8 con s t ca s t<Time&>(runTime ) ,9 nAlphaSubCycles

10 ) ;11 !(++alphaSubCycle ) . end ( ) ;12 )13 {14 // So lve s the phase t ranspo r t equat ions15 so lveAlphas ( ) ;16 . . . .17 }

The function solveAlphas(), initially calculates the face transport flux term discretized by someuser defined discretization scheme for all the phases.

1 f o r A l l I t e r ( PtrDict ionary<phaseModel>, phases , i t e r )2 {3 phaseModel& phase = i t e r ( ) ;4 vo l S c a l a rF i e l d& alpha1 = phase ;5 alphaPhiCorrs . s e t6 (7 phasei ,8 new su r f a c e S c a l a rF i e l d9 (

10 ”phi ” + alpha1 . name ( ) + ”Corr” ,11 f v c : : f l u x12 (13 phi ,14 phase ,15 ” div ( phi , ” + alpha1 . name ( ) + ' ) '16 )17 )18 ) ;19 s u r f a c e S c a l a rF i e l d& alphaPhiCorr = alphaPhiCorrs [ phase i ] ;20 phase i++;21 }

Next the solver calculates the flux due to the relative velocity between the phases. Then the fluxterm due to interface compression is added for all the phases pairs where Cα is defined.

1 f o r A l l I t e r ( PtrDict ionary<phaseModel>, phases , i t e r 2 )2 {3 phaseModel& phase2 = i t e r 2 ( ) ;4 vo l S c a l a rF i e l d& alpha2 = phase2 ;5 i f (&phase2 == &phase1 ) cont inue ;6 s u r f a c e S c a l a rF i e l d ph i r ( phase1 . phi ( ) − phase2 . phi ( ) ) ;

For a given interfacePair (phase1, phase2) the function iterates over the hash table cAlphas_ tocheck if the interfacePair is listed in the interfaceCompression dictionary. Only if a Cα value isdefined for (phase1, phase2), it calculates the compression term as shown below:

12

Page 14: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

1 scalarCoeffSymmTable : : c o n s t i t e r a t o r cAlpha2 (3 cAlphas . f i nd ( i n t e r f a c ePa i r ( phase1 , phase2 ) )4 ) ;5 i f ( cAlpha != cAlphas . end ( ) )6 {7 s u r f a c e S c a l a rF i e l d phic8 (9 (mag( ph i ) + mag( ph i r ) ) /mesh . magSf ( )

10 ) ;11 phi r += min( cAlpha ( ) ∗phic , max( phic ) ) ∗nHatf ( phase1 , phase2 ) ;12 }

From the code it is implicitly evident that if Cα is not defined it is set to a default value of 0. Finallythe total flux transport term is calculated as shown below:

1 alphaPhiCorr += fvc : : f l u x2 (− f v c : : f l u x (−phir , phase2 , phirScheme ) , phase1 , phirScheme ) ;

Then the MULES solver is used to determine the phase fractions.A detailed description of MULESsolver can be found in thesis of Damian [4].Here only a short overview of the MULES algorithm andit’s implementation in OpenFoam will be outlined. MULES is based on flux corrected transporttechnique for solving hyperbolic equation. This approach ensures the boundedness of the temporalsolution by limiting the face fluxes.Consider hyperbolic equation of the form,

∂φ

∂t+∇.(F ) = 0 (2.5)

The values of the flux term F, are obtained by a bounded lower order method and a limited portionof the values are obtained by an unbounded high order method. The sequential solution procedurepresented in OpenFOAM’s context can be summarized as follows :

1. Calculate the transport flux term FH using a user defined higher order discretisation scheme .

2. Calculate the transport flux term FL using a lower order discretisation scheme. And thencalculate the corrected transport flux term FC using,

FC = λFH + (1− λ)FL (2.6)

where λ is the weighting factor or limiter term which determines the effect of high orderschemes in flux calculation.

3. Finally solve the hyperbolic equation using an explicit temporal scheme.

In OpenFOAM the MULES solver has three functions namely,

1. limiter() function calculates the weighting factors λ.

2. limit() function calculates the corrected face transport flux term based on λ values obtainedfrom limiter() function.

3. explicitSolve() function then solves the phase transport equation based on the correctedflux terms obtained from limit() function.

In the solveAlphas() function, the limit() and explicitSolve() functions of MULES are used.

1 MULES: : l im i t2 (3 1 .0/mesh . time ( ) . deltaT ( ) . va lue ( ) ,4 geometr icOneFie ld ( ) ,5 phase1 ,6 phi ,7 alphaPhiCorr ,8 z e r oF i e l d ( ) ,9 z e r oF i e l d ( ) ,

13

Page 15: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

10 1 ,11 0 ,12 t rue13 ) ;14

15 MULES: : e x p l i c i t S o l v e16 ( geometr icOneFie ld ( ) , phase1 , alphaPhi , z e r oF i e l d ( ) , z e r oF i e l d ( ) ) ;

2.5 Implementation of dragModel class in the solver

The inter-phase momentum transfer due to drag force(FD, k)can be written in a generic form,

FD,k = K(Ur)Ur

where K(Ur) is a force multiplier coefficient which is a function of Ur ,the relative velocity betweenthe phases. The different drag models calculate the multiplier term K using different formulations.So in the following discussion of the solution procedure, the exact formulation of different models isnot important. The focus will be on understanding how the drag models are implemented into thesolver. The drag coefficient is implemented as a virtual function.

1 v i r t u a l tmp<vo lS ca l a rF i e l d> K( const v o l S c a l a rF i e l d& Ur) const = 0 ;

The drag models are implemented as an individual library called the interfacialModels. The baseclass is the dragModel, which defines the generic structure of the derived classes, where the actualformulations of K are implemented. As the definition of K varies from one model to another it isdefined as a virtual function in the base class.Similar to the twoPhaseEulerFoam solver the differentdrag models are implemented into the solver using a run time selection mechanism which allows theuser to choose from different models available. The run time selection mechanism is defined in thebase class dragModel.H using declareRunTimeSelectionTable.

1 #inc lude ” runTimeSelect ionTables .H”2

3 //− Runtime type in fo rmat ion4 TypeName( ”dragModel” ) ;5

6 // Dec lare runtime con s t ru c t i on7

8 declareRunTimeSelect ionTable9 (

10 autoPtr ,11 dragModel ,12 d i c t i onary ,13 (14 const d i c t i ona ry& in t e r f a c eD i c t ,15 const phaseModel& phase1 ,16 const phaseModel& phase217 ) ,18 ( i n t e r f a c eD i c t , phase1 , phase2 )19 ) ;

The defineRunTimeSelectionTable is defined in dragModel.C file. It is the main function imple-menting the runtime selection changes to the base class.The new drag models i.e. derived classesare added to run time selection mechanism by addToRunTimeSelectionTable defined in the headerfile of the derived class as shown below.

1

2 def ineRunTimeSelect ionTable ( dragModel , d i c t i ona ry ) ;3

4 addToRunTimeSelectionTable5 (6 dragModel ,7 Schil lerNeumann , // an example f o r a dragModel8 d i c t i ona ry9 ) ;

14

Page 16: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

For each interfacePair, a different drag model can be selected and it is important to understand howthese different models are simultaneously implemented in the solver. For this purpose, similar to theimplementation of cAlphas_, two hash tables are defined for drag models in multiphaseSystem.H

. The dragModelTable maps the drag models defined in transportProperties to its correspondinginterfacePair. Similarly dragCoeffFields table is used to map the drag coefficients calculated bydifferent drag models to their corresponding interfacePairs. Also two functions dragModels() anddragCoeffs() have been defined to provide return access to all the models and coefficients definedin the hash tables.

1

2 typede f HashPtrTable<dragModel , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>3 dragModelTable ;4 typede f HashPtrTable<vo lS ca l a rF i e l d , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>5 dragCoe f fF i e l d s ;6

7 //− Return the tab l e o f drag models8 const dragModelTable& dragModels ( ) const9 {

10 r e turn dragModels ;11 }12 //− Return the drag c o e f f i c i e n t s f o r a l l o f the i n t e r f a c e s13 autoPtr<dragCoe f fF i e ld s> dragCoe f f s ( ) const ;

In order to map the drag coefficient values to the interfacePair’s, the dragCoeff() function firstiterates over dragModelTable. For each dragModel defined in the dragModelTable it calculates thedrag coefficient K(Ur). Then it maps the value of the drag coefficient to the corresponding inter-facePair for which the drag model is defined. This is done by insert(iter.key(), Kptr) function.The iter.key() is an index to the interfacePair and Kptr is the pointer to the corresponding dragcoefficient value obtained from the sub-models for drag.

1 Foam : : autoPtr<Foam : : multiphaseSystem : : d ragCoe f fF i e ld s>2 Foam : : multiphaseSystem : : dragCoe f f s ( ) const3 {4 autoPtr<dragCoe f fF i e ld s> dragCoe f f sPtr (new dragCoe f fF i e l d s ) ;5

6 f o rA l lCon s t I t e r ( dragModelTable , dragModels , i t e r )7 {8 const dragModel& dm = ∗ i t e r ( ) ;9 vo l S c a l a rF i e l d ∗ Kptr = dm.K

10 (11 max12 (13 mag(dm. phase1 ( ) .U( ) − dm. phase2 ( ) .U( ) ) ,14 dm. r e s i d u a l S l i p ( )15 )16 ) . ptr ( ) ;17 dragCoe f f sPtr ( ) . i n s e r t ( i t e r . key ( ) , Kptr ) ;18 }19 r e turn dragCoe f f sPtr ;20 }

Then the total drag on a given phase is calculated as the sum of individual drag forces. So anotherfunction dragCoeff is defined to calculate the net drag coefficient for a given phase.

1 tmp<vo lS ca l a rF i e l d> dragCoef f2 (3 const phaseModel& phase ,4 const d ragCoe f fF i e l d s& dragCoe f f s5 ) const ;

In the calculation of the net drag coefficient the function iterates over both the dragModelTable

and dragCoeffFields tables.For a given phase, the function checks the dragModelTable for the listof interfacePairs which contain it and then iterates over the dragCoeffFields table to add all thecorresponding drag coefficient values.

1 dragModelTable : : c o n s t i t e r a t o r dmIter = dragModels . begin ( ) ;

15

Page 17: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

2 dragCoe f fF i e l d s : : c o n s t i t e r a t o r d c I t e r = dragCoe f f s . begin ( ) ;3 f o r4 (5 ;6 dmIter != dragModels . end ( ) && dc I t e r != dragCoe f f s . end ( ) ;7 ++dmIter , ++dc I t e r8 )9 {

10 i f11 (12 &phase == &dmIter ( )−>phase1 ( )13 | | &phase == &dmIter ( )−>phase2 ( )14 )15 {16 tdragCoe f f . r e f ( ) += ∗ dc I t e r ( ) ;17 }18 }

Finally the drag coefficient is added to pressure correction equation in pEqn.H.

1 vo l S c a l a rF i e l d d ragCoe f f i2 (3 IOobject4 (5 ” dragCoe f f i ” ,6 runTime . timeName ( ) ,7 mesh8 ) ,9 f l u i d . dragCoef f ( phase , dragCoe f f s ( ) ) /phase . rho ( ) ,

10 zeroGradientFvPatchSca larFie ld : : typeName11 ) ;

16

Page 18: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Chapter 3

multiphaseChangeEulerFoam - anextension to cavitating flows

3.1 Introduction

This chapter provides an overview of the procedure to implement the phaseChangeModel class inthe interfacialModels library on similar lines to the implementation of dragModels. Also a shortoverview of how the source terms from the phaseChangeModel class are added to the phase transportequations in multiphaseSystemlibrary is presented. The phaseChangeModel class is based on thephaseChangeTwoPhaseMixture class located in interPhaseChangeFoam solver as shown below :

1

2 $FOAM SOLVERS/mult iphase / interphaseChangeFoam/phaseChangeTwoPhaseMixtures/phaseChangeTwoPhaseMixture/

But for accurate modelling of the physics, certain changes have to be made in it’s implementationin comparison to the interPhaseChangeFoam solver. All these changes will be discussed in detail.

3.2 interPhaseChangeFoam - an overview

For cavitating flows there is liquid-vapor mass transfer (evaporation and condensation).These masstransfer rates are added as a source term is phase transport equation as shown below.

∂αl∂t

+∇.(αl.uk) = αlα∗v + αvα

∗c (3.1)

Here αl, αv are phase fractions of the liquid and vapor phases. And α∗c , α∗v are the condensation

and evaporation rate coefficients of vapor and liquid phases. Different formulations use differentapproaches to calculate these mass transfer rates, which will not be presented here. Also a moredetailed description of the interPhaseChangeFoam solver can be found in the report of Manni [5]. Inthe interPhaseChangeFoam solver, the source terms are defined using the function vDotAlphal()inphaseChangeTwoPhaseMixture.H. The function is defined as a Pair type which has two values, i.ethe condenstation and vaporization rates respectively.

1 //− Return the vo lumetr i c condensat ion and vapo r i s a t i on r a t e s as a2 // c o e f f i c i e n t to mult ip ly (1 − a lpha l ) f o r the condensat ion ra t e3 // and a c o e f f i c i e n t to mult ip ly a lpha l f o r the vapo r i s a t i on ra t e4 Pair<tmp<vo lS ca l a rF i e l d>> vDotAlphal ( ) const ;

In the alphaEqn.H file the phase transport equation is solved using MULES, where the source termsare added as Sp and Su terms.

17

Page 19: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

1 Pair<tmp<vo lS ca l a rF i e l d>> vDotAlphal =2 mixture−>vDotAlphal ( ) ;3 const v o l S c a l a rF i e l d& vDotcAlphal = vDotAlphal [ 0 ] ( ) ;4 const v o l S c a l a rF i e l d& vDotvAlphal = vDotAlphal [ 1 ] ( ) ;5 const v o l S c a l a rF i e l d vDotvmcAlphal ( vDotvAlphal − vDotcAlphal ) ;6 MULES: : e x p l i c i t S o l v e7 (8 geometr icOneFie ld ( ) ,9 alpha1 ,

10 phi ,11 talphaPhiCorr . r e f ( ) ,12 vDotvmcAlphal , //Sp term13 ( divU∗ alpha1 + vDotcAlphal ) ( ) , //Su term14 1 ,15 016 ) ;

vDotvmcAlphal is the Sp term and is dervied in the following way. The phase transport equationin terms of Sp and Su is given by,

∂αl∂t

+∇.(αl.uk) = Sp.αl + Su (3.2)

For two phase flows the vapor phase fraction is directly calculated from the liquid phase fractionand is given by,

αv = 1− αl (3.3)

Replacing αv with αl and comparing the RHS terms for the two equations yeilds the Sp and Suterms as shown below:

Sp.αl + Su = αl.α∗v + αv.α

∗c = αl.α

∗v + (1− αl).α∗c = αl.(α

∗v − α∗c) + α∗c (3.4)

Sp = (α∗v − α∗c) (3.5)

Su = α∗c (3.6)

3.3 Implementing phaseChangeModel class

3.3.1 Compiling the new solver without any changes

In order to make changes to the multiphaseEulerFoam solver we need to copy it to user directoryusing following commands.

1 cp −r $FOAM SOLVER/mult iphase /multiphaseEulerFoam2 $WM PROJECT USER DIR/ app l i c a t i o n s /multiphaseChangeEulerFoam3 cd $WM PROJECT USER DIR/ app l i c a t i o n s /multiphaseChangeEulerFoam

As explained in previous chapter, the multiphaseEulerFoam solver has two libraries namely,

1 . / multiphaseSystem2 . / i n t e r f a c i a lMod e l s

Both these libraries are re-compiled using wmake command after making following changes to theirMake/files.

1 v i . / multiphaseSystem/Make/ f i l e s2 LIB = $ (FOAM USER LIBBIN) / l ibusermul t iphaseSystem3 wmake4

5 v i . / i n t e r f a c i a lMod e l s /Make/ f i l e s6 LIB = $ (FOAM USER LIBBIN) /7 l i bu s e r c ompr e s s i b l eMu l t i pha s eEu l e r i an In t e r f a c i a lMode l s8 wmake

18

Page 20: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Make following changes to the Make/files of the solver in user directory as shown below. Also replacethe old libraries with the above compiled new libraries in the Make/options file. Then compile thesolver using wmake command.

1 v i Make/ f i l e s2 EXE = $ (FOAM USER APPBIN) /multiphaseChangeEulerFoam3 wmake

3.3.2 Adding phaseChangeModel class

Copy the phaseChangeTwoPhaseMixture folder from interPhaseChangeFoam solver to interfacialMod-els folder in multiphaseEulerFoam solver. Rename the folder to phaseChangeModels. Similarlyrename the base class .C and .H file names to phaseChangeModel. Also replace phaseChangeT-woPhaseMixture with phaseChangeModel in all the files.

1 cp −r $FOAM SOLVERS/mul itphase / interPhaseChangeFoam/phaseChangeTwoPhaseMixture2 . / i n t e r f a c i a lMod e l s /3 cd . / i n t e r f a c i a lMod e l s /4 mv phaseChangeTwoPhaseMixture phaseChangeModels5 cd phaseChangeModels/6 mv phaseChangeTwoPhaseMixture/ phaseChangeModel/7 mv phaseChangeModel/phaseChangeTwoPhaseMixture .H phaseChangeModel/phaseChangeModel .H8 mv phaseChangeModel/phaseChangeTwoPhaseMixture .C phaseChangeModel/phaseChangeModel .C9 mv phaseChangeModel/newPaseChangeTwoPhaseMixture .C phaseChangeModel/

newPhaseChangeModel .C10 f i nd . −type f −exec sed − i ' s /phaseChangeTwoPhaseMixture/phaseChangeModel/g ' {} \ ;

The phaseChangeTwoPhaseMixture class is a transport model similar to multiphaseSystem classand is derived from incompressibleTwoPhaseMixture class. But here the phaseChangeModel is aclass in itself reading the transport properties from multiphaseSystem class. Also the declaration anddefinition of the class has to be adapted to the multiphaseEulerFoam solver. Some of the importantchanges made to the phaseChangeModel.H file are listed below. The complete code files can befound in the Appendix.

1. Adding the phase pair for which the phase change model is defined.

1 const phaseModel& phase1 ;2 const phaseModel& phase2 ;3

2. Adding the dictionary interfaceDict to define the phase change models for different phase pairs.

1 const d i c t i ona ry& i n t e r f a c eD i c t ;2

3. Adding a sub-dictionary phaseChangeCoeffs to define the model coeffients and parametersseperately for each model.

1 d i c t i ona ry phaseChangeCoef fs2

4. Changing the constructor and run time selection table parameters similar to that of dragModelbase class.

1

2 // Constructors3 //− Construct from components4 phaseChangeModel5 (6 const word& type ,7 const d i c t i ona ry& in t e r f a c eD i c t ,8 const phaseModel& phase1 ,9 const phaseModel& phase2

10 ) ;

19

Page 21: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

11 // Dec lare run−time cons t ruc to r s e l e c t i o n tab l e12 declareRunTimeSelect ionTable13 (14 autoPtr ,15 phaseChangeModel ,16 d i c t i onary ,17 (18 const d i c t i ona ry& in t e r f a c eD i c t ,19 const phaseModel& phase1 ,20 const phaseModel& phase221 ) ,22 ( i n t e r f a c eD i c t , phase1 , phase2 )23 ) ;24 // S e l e c t o r s25 //− Return a r e f e r e n c e to the s e l e c t e d phaseChange model26 s t a t i c autoPtr<phaseChangeModel> New27 (28 const d i c t i ona ry& in t e r f a c eD i c t ,29 const phaseModel& phase1 ,30 const phaseModel& phase231 ) ;32

5. Similarly the important changes made to the phaseChangeModel.C file are shown below :

1 Foam : : phaseChangeModel : : phaseChangeModel2 (3 const word& type ,4 const d i c t i ona ry& in t e r f a c eD i c t ,5 const phaseModel& phase1 ,6 const phaseModel& phase27 )8 :9 i n t e r f a c eD i c t ( i n t e r f a c eD i c t ) ,

10 phase1 ( phase1 ) ,11 phase2 ( phase2 ) ,12 pSat ( ”pSat” , dimPressure , i n t e r f a c eD i c t . lookup ( ”pSat” ) ) ,13 phaseChangeCoef fs ( i n t e r f a c eD i c t . opt iona lSubDict ( type + ”Coe f f s ” ) )14 {}

Note:

1. It is very important that phase1 should always be the liquid phase and phase2 should be thevapor phase.

2. phaseChangeCoeffs is a sub-dictionary used to define the cavitation model constants. Thelist of constants vary from model to model and hence are defined in the individual sub-modelfiles.

3. The changes made to newPhaseChangeModel.C file are not listed here, but can be intuitivelyunderstood by the reader from the code provided in Appendix.

4. Now recompile the interfacial model class by adding the bass class i.e. phaseChangeModel tothe Make/files.

1 v i . / i n t e r f a c i a lMod e l s /Make/ f i l e s2 phaseChangeModels/phaseChangeModel/phaseChangeModel .C3 phaseChangeModels/phaseChangeModel/newPhaseChangeModel .C4 wmake

3.3.3 Adding Kunz Cavitation model

The previous section describes how to add the phaseChagneModel base class. In order to testthe implementation, we need to implement a specific cavitation model as a derived class. For

20

Page 22: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

this purpose, the Kunz cavitation model will also be implemented. The evaporation(m+) andcondensation rates(m−) for the Kunz model are given as:

m+ =Cpρvαlmin(0, p− pv)

0.5ρlU2∞t∞

(3.7)

m− =Cdρvα

2l αv

t∞(3.8)

Cp, Cd,U∞ ,t∞ are empirical constants based on the mean flow. These model constants are definedby user and read by the solver using the sub-dictionary phaseChangeCoeffs. ρl,ρv are the density ofthe liquid and vapor, p is the pressure, pSat is the saturation pressure. In the phaseChangeModelsdirectory different cavitation models are available. Only Kunz model will be considered here toillustrate the changes required to be made.

1 cd . / i n t e r f a c i a lMod e l s /phaseChangeModels/Kunz/2

The full code is described in the Appendix. Here only the important changes required are listed.

1. Change the constructor declaration in Kunz.H file.

1 // Constructors2 //− Construct from components3 Kunz4 (5 const d i c t i ona ry& in t e r f a c eD i c t ,6 const phaseModel& phase1 ,7 const phaseModel& phase28 ) ;9

2. Change the runtime selection table definition in Kunz.C

1 namespace phaseChangeModels2 {3 defineTypeNameAndDebug (Kunz , 0) ;4 addToRunTimeSelectionTable ( phaseChangeModel , Kunz , d i c t i ona ry ) ;5 }6

3. Make necessary changes to the definition of the empirical constants in Kunz.C. Here the sub-dictionary phaseChangeCoeffs, is used to call the model constants.

1 Foam : : phaseChangeModels : : Kunz : : Kunz2 (3 const d i c t i ona ry& in t e r f a c eD i c t ,4 const phaseModel& phase1 ,5 const phaseModel& phase26 )7 :8 phaseChangeModel ( typeName , i n t e r f a c eD i c t , phase1 , phase2 ) ,9 UInf ( ”UInf” , dimVelocity , phaseChangeCoef fs . lookup ( ”UInf” ) ) ,

10 t I n f ( ” t I n f ” , dimTime , phaseChangeCoef fs . lookup ( ” t I n f ” ) ) ,11 Cc ( ”Cc” , dimless , phaseChangeCoef fs . lookup ( ”Cc” ) ) ,12 Cv ( ”Cv” , d imless , phaseChangeCoef fs . lookup ( ”Cv” ) ) ,13 p0 ( ”0” , pSat ( ) . d imensions ( ) , 0 . 0 ) ,14 mcCoeff ( Cc ∗phase2 . rho ( ) / t I n f ) ,15 mvCoeff (Cv ∗phase2 . rho ( ) / (0 . 5∗ phase1 . rho ( ) ∗ sqr ( UInf ) ∗ t I n f ) )16 {}17

4. Since the solver calculates the phase fractions individually, replace alpha1_ with phase1_ and1-alpha1_ to phase2_ in the member functions in Kunz.C.

21

Page 23: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

1 Foam : : Pair<Foam : : tmp<Foam : : vo lS ca l a rF i e l d>>2 Foam : : phaseChangeModels : : Kunz : : mDotAlphal ( ) const3 {4 const v o l S c a l a rF i e l d& p = phase1 . db ( ) . lookupObject<vo lS ca l a rF i e l d >(”p

” ) ;5 vo l S c a l a rF i e l d l imitedAlpha1 (min (max( phase1 , s c a l a r (0 ) ) , s c a l a r (1 ) ) ) ;6 r e turn Pair<tmp<vo lS ca l a rF i e l d>>7 (8 mcCoeff ∗ sqr ( l imitedAlpha1 )9 ∗max(p − pSat ( ) , p0 ) /max(p − pSat ( ) , 0 .01∗ pSat ( ) ) ,

10 mvCoeff ∗min(p − pSat ( ) , p0 )11 ) ;12 }13 Foam : : Pair<Foam : : tmp<Foam : : vo lS ca l a rF i e l d>>14 Foam : : phaseChangeModels : : Kunz : : mDotP( ) const15 {16 const v o l S c a l a rF i e l d& p = phase1 . db ( ) . lookupObject<vo lS ca l a rF i e l d >(”p”

) ;17 vo l S c a l a rF i e l d l imitedAlpha1 (min (max( phase1 , s c a l a r (0 ) ) , s c a l a r (1 ) ) ) ;18 vo l S c a l a rF i e l d l imitedAlpha2 (min (max( phase2 , s c a l a r (0 ) ) , s c a l a r (1 ) ) ) ;19 r e turn Pair<tmp<vo lS ca l a rF i e l d>>20 (21 mcCoeff ∗ sqr ( l imitedAlpha1 ) ∗( l imitedAlpha2 )22 ∗pos (p − pSat ( ) ) /max(p − pSat ( ) , 0 .01∗ pSat ( ) ) ,23 (−mvCoeff ) ∗ l imitedAlpha1 ∗neg (p − pSat ( ) )24 ) ;25 }

5. Then recompile the interfacialModels library by adding the Kunz.C file to Make/files.

1 v i . / i n t e r f a c i a lMod e l s /Make/ f i l e s2 phaseChangeModels/Kunz/Kunz .C

3.4 Adding source terms to solver

Having added the phase change models to the interfacialModels library, the next step is toimplement the mass transfer rate terms as source terms in the phase transport equation of thesolver. The implementation procedure is similar in concept to the implementation of drag coefficientterm. The following changes have to be made to include the source terms in the phase transportequation.

3.4.1 Changes to multiphaseSytem.H file

1. Include the phaseChangeModel.H file.

1 #inc lude ”phaseChangeModel .H”

2. Similar to dragModelTable and dragCoeffs, we create three hash tables pcTable, |cFields|andvFields. The pcTable contains the list of the phase pairs undergoing phase change. cFieldscontains the list of condensation rates values for each of the phase pair defined. SimilarlyvFields is list of vaporization rates for different phase pairs.

1 typede f HashPtrTable2 <phaseChangeModel , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash> pcTable ;3

4 typede f HashPtrTable5 <vo lS ca l a rF i e l d , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash> cF i e l d s ;6

7 typede f HashPtrTable8 <vo lS ca l a rF i e l d , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash> vF i e ld s ;

3. Create access functions to above define fields.

22

Page 24: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

1 pcTable pcModels ;2 const pcTable& pcModels ( ) const3 {4 r e turn pcModels ;5 }6 autoPtr<cF i e ld s> cCoe f f s ( ) const ;7 autoPtr<vFie lds> vCoe f f s ( ) const ;

4. Add two new functions pcSu and pcSp for calculating the source terms to be added to thephase transport equations.

1

2 tmp<vo lS ca l a rF i e l d> pcSp3 (4 const phaseModel& phase ,5 const cF i e l d s& cCoef f s ,6 const vF i e ld s& vCoe f f s7 ) const ;8

9 tmp<vo lS ca l a rF i e l d> pcSu10 (11 const phaseModel& phase ,12 const cF i e l d s& cCoef f s ,13 const vF i e ld s& vCoe f f s14 ) const ;

3.4.2 Changes to multiphaseSytem.C file

1. Firstly the vaporization and condensation coefficients calculated by the cavitation models haveto be mapped to the interfacePair for which the models are used. So we define the cCoeffs()

and vCoeffs() member functions similar to dragCoeffs(). Here the functions iterate overthe pcTable hash table and for every phase change model i.e. pcModels it calculates thecondensation and vaporisation rates. Then the values are assigned to the interfacePair byusing the insert(iter.key(), Kptr) function.

1 Foam : : autoPtr<Foam : : multiphaseSystem : : cF i e ld s>2 Foam : : multiphaseSystem : : cCoe f f s ( ) const3 {4 autoPtr<cF i e ld s> cCoe f f sPt r (new cF i e l d s ) ;5 f o rA l lCon s t I t e r ( pcTable , pcModels , i t e r )6 {7 const phaseChangeModel& pc = ∗ i t e r ( ) ;8 const Pair<tmp<vo lS ca l a rF i e l d>> vDotAlphal = pc . vDotAlphal ( ) ;9 vo l S c a l a rF i e l d ∗ Kptr = ( vDotAlphal [ 0 ] ) . ptr ( ) ;

10 cCoe f f sPt r ( ) . i n s e r t ( i t e r . key ( ) , Kptr ) ;11 }12 r e turn cCoe f f sPt r ;13 }14

15 Foam : : autoPtr<Foam : : multiphaseSystem : : vFie lds>16 Foam : : multiphaseSystem : : vCoe f f s ( ) const17 {18 autoPtr<vFie lds> vCoe f f sPtr (new vF i e ld s ) ;19 f o rA l lCon s t I t e r ( pcTable , pcModels , i t e r )20 {21 const phaseChangeModel& pv = ∗ i t e r ( ) ;22 Pair<tmp<vo lS ca l a rF i e l d>> vDotAlphal = pv . vDotAlphal ( ) ;23 vo l S c a l a rF i e l d ∗ Kptr = ( vDotAlphal [ 1 ] ) . ptr ( ) ;24 vCoe f f sPtr ( ) . i n s e r t ( i t e r . key ( ) , Kptr ) ;25 }26 r e turn vCoe f f sPtr ;27 }

2. Define pcSp and pcSu member functions similar to dragCoeff. Here it is important to note thatthe Sp and Su terms are different for liquid and vapor phases. So let us revisit the formulation

23

Page 25: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

of the phase transport equation for the liquid phase.

Sp.αl + Su = αl.α∗v + αv.α

∗c (3.9)

So for the liquid phase, n

Sp = α∗v (3.10)

Su = αv.α∗c (3.11)

On the other hand, for the vapor phase transport equation, the source terms will be negativeof the vaporization and condensation rates defined for liquid phase.

Sp.αl + Su = −αl.α∗v − αv.α∗c (3.12)

So for the vapor phase,

Sp = −α∗c (3.13)

Su = −αc.α∗v (3.14)

Here only the part of the code for implementation of the Sp term is shown. The code iteratesover the pcTable to check if any phase change model is defined for the given phase. If thephase is undergoing phase change then the corresponding condensation and vaporisation ratesare obtained from cFields() and vFields() hash tables. Then depending on whether thephase is liquid or vapor the source terms are calculated.

1

2 pcTable : : c o n s t i t e r a t o r p c I t e r =pcModels . begin ( ) ;3 cF i e l d s : : c o n s t i t e r a t o r c I t e r = cCoe f f s . begin ( ) ;4 vF i e ld s : : c o n s t i t e r a t o r v I t e r = vCoe f f s . begin ( ) ;5 f o r6 (7 ;8 pc I t e r != pcModels . end ( ) && c I t e r != cCoe f f s . end ( )9 && vI t e r != vCoe f f s . end ( ) ;

10 ++pcI te r , ++c I t e r , ++v I t e r11 )12 {13 i f ( &phase == &pc I t e r ( )−>phase1 ( ) | | &phase == &pc I t e r ( )−>phase2 ( ) )14 {15 i f (&phase == &pc I t e r ( )−>phase1 ( ) )16 {17 tpcSp−>r e f ( ) = ∗ v I t e r ( ) ;18 }19 i f (&phase == &pc I t e r ( )−>phase2 ( ) )20 {21 tpcSp−>r e f ( ) = −∗ c I t e r ( ) ;22 }23 }24 }

Note: The implementation of pcSu term is done similarly. The full code for implementationof both the terms is provided in the Appendix. The functions iterate over the pcTable andcalculates the Sp and Su terms depending on whether the phase is liquid or vapor. Hence itis very important to note that in the definition of the phaseChangeModel the first phase isalways liquid and second phase is vapor. If the order is not followed, It will be impossible forthe solver to differentiate between the phases and will lead to wrong formulation of Sp and Suterms.

24

Page 26: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

3. Finally add the Sp and Su terms in MULES::limit() and MULES::explicitSolve() functionsused in solveAlphas().

1 vo l S c a l a rF i e l d Sp( pcSp ( phase , cCoe f f s ( ) , vCoe f f s ( ) ) ) ;2 vo l S c a l a rF i e l d Su( pcSu ( phase , cCoe f f s ( ) , vCoe f f s ( ) ) ) ;3 MULES: : l im i t4 (5 1 .0/mesh . time ( ) . deltaT ( ) . va lue ( ) ,6 geometr icOneFie ld ( ) ,7 phase ,8 phi ,9 alphaPhiCorr ,

10 Sp ( ) ,11 Su ( ) ,12 1 ,13 0 ,14 t rue15 ) ;16 MULES: : e x p l i c i t S o l v e ( geometr icOneFie ld ( ) , phase , alphaPhi , Sp ( ) , Su ( ) ) ;

Then recompile multiphaseSystem library to include the changes described above. Similarly thephase change source terms have to be added to the momentum equation in pEqn.H. The formulationof the source terms to be added is shown below.

Sp.p+ Su = (αv,∗p − αc,∗p ) ∗ p− (αv,

∗p − αv,∗p ) ∗ psat (3.15)

So

Sp = (αv,∗p − αc,∗p) (3.16)

Su = −(αv,∗p − αc,∗p ) ∗ psat (3.17)

where αv,∗p, αc,

∗p are the volumetric vaporisation and condensation rate coefficients defined in the

phaseChangeModel class using the virtual function vDotP().

1

2 //− Return the vo lumetr i c condensat ion and vapo r i s a t i on r a t e s as3 // c o e f f i c i e n t s to mult ip ly (p − pSat )4 Pair<tmp<vo lS ca l a rF i e l d>> vDotP ( ) const

The implementation of the source terms is not described here as it will be repetitive. But the readercan find the implementation of code for these terms in Appendix.

25

Page 27: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Chapter 4

Tutorial

4.1 throttle3phase - Test case

A new tutorial has been created to simulate a 2D throttle nozzle. The tutorial is based on thethrottle tutorial case of cavitatingFoam solver. But a lot of changes have been made for adaptingthe model to multiphaseChangeEulerFoam solver. First copy the tutorial to run folder and renameit as throttle3phase.

1

2 cp −r $FOAM TUTORIALS/mult iphase / cavitatingFoam/RAS/ t h r o t t l e /3 $FOAMRUN/ th ro t t l e 3pha s e4 cd $FOAMRUN/ th ro t t l e 3pha s e

4.1.1 Meshing

Since the geometry of the test case is the same, it is meshed using the Allrun file. Before runningthe Allrun command the getApplication command has to be removed. The Allrun file should havethe following lines only.

1 re f ineMeshByCel lSet ( )2 {3 whi le [ $# −ge 1 ]4 do5 i f [ ! −e l og . re f ineMesh . $1 ]6 then7 echo ”Creat ing c e l l s e t f o r primary zone − $1”8 cp system/ topoSetDict . $1 system/ topoSetDict9 topoSet > l og . topoSet . $1 2>&1

10

11 echo ”Re f in ing primary zone − $1”12 re f ineMesh −d i c t system/ re f ineMeshDict −ove rwr i t e \13 > l og . re f ineMesh . $1 2>&114 f i15 s h i f t16 done17 }18 r e s t o r e 0D i r19 runAppl i cat ion blockMesh20 re f ineMeshByCel lSet 1 2 321

Here the test case uses different utilities like topoSet, refineMesh to use a locally refined mesh inregions closer to the channel as shown in figure 4.1. The topoSetDict and refineMeshDict filesrequired for refining the mesh locally can be found in the system folder.

26

Page 28: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Figure 4.1: Throttle case mesh

4.1.2 transportProperties

The full list of transport properties can be found in the appendix.

1. The first part of the transport properties defines the phase properties of the individual phases.

1 phases2 (3 water4 {5 nu 3 .8 e−06;6 kappa 1e−06;7 Cp 4195 ;8 rho 820 ;9 diameterModel constant ;

10 cons tantCoe f f s11 {12 d 1e−3;13 }14 }15 vapor16 {17 nu 4 .52 e−05;18 kappa 1e−06;19 Cp 4195 ;20 rho 0 . 1 2 ;21 diameterModel constant ;22 cons tantCoe f f s23 {24 d 1e−5;25 }26 }27 ) ;

2. It is assumed that air is dispersed in both vapor and water. And for water and vapor interfacethe VOF interface tracking is used. Hence Cα has been set to one only for (water, vapor) andthe corresponding surface tension value for this phase pair is declared.

1 sigmas2 (3 ( water vapor ) 0 .034 ) ;5

6 i n t e r faceCompres s i on7 (8 ( water vapor ) 19 ) ;

3. Finally the Kunz cavitation model is used for modelling the phase transfer from water tovapor. As mentioned in previous chapter the order of phase pair should be water and vaporrespectively.

27

Page 29: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

1 phaseChange2 (3 ( water vapor )4 {5 type Kunz ;6 pSat 2288 ;7 KunzCoeffs8 {9 UInf 2 0 . 0 ;

10 t I n f 0 . 0 0 5 ;11 Cc 1000 ;12 Cv 1000 ;13 }14 }15 ) ;

4.1.3 Boundary conditions

Since it is an Eulerian multifluid model solving the phase and momentum equations for each phase,the alpha and velocity boundary conditions have to be defined for each individual phases. Theimportant boundary conditions are :

1. alpha.water

1 i n t e r n a l F i e l d uniform 0 ;2 boundaryField3 {4 i n l e t5 {6 type i n l e tOu t l e t ;7 i n l e tVa lu e uniform 1 ;8 value uniform 1 ;9 }

10 ou t l e t11 {12 type c a l c u l a t ed ;13 value uniform 0 ;14 }15 }16

2. alpha.vapor

1 i n t e r n a l F i e l d uniform 0 ;2 boundaryField3 {4 i n l e t5 {6 type c a l c u l a t ed ;7 value uniform 0 ;8 }9 ou t l e t

10 {11 type c a l c u l a t ed ;12 value uniform 0 ;13 }14 }15

3. alpha.air

1 i n t e r n a l F i e l d uniform 0 ;2 boundaryField3 {4 i n l e t5 {

28

Page 30: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

6 type c a l c u l a t ed ;7 value uniform 0 ;8 }9 ou t l e t

10 {11 type i n l e tOu t l e t ;12 i n l e tVa lu e uniform 1 ;13 value uniform 1 ;14 }15

16 }17

4. pressure

1 i n t e r n a l F i e l d uniform 50 e5 ;2 boundaryField3 {4 i n l e t5 {6 type t o t a lP r e s s u r e ;7 p0 uniform 50 e5 ;8 }9 ou t l e t

10 {11 type f ixedValue ;12 value uniform 15 e5 ;13 }14 }15

5. U.* i.e. velocities for all phases

1 dimensions [ 0 1 −1 0 0 0 0 ] ;2 i n t e r n a l F i e l d uniform (0 0 0) ;3 boundaryField4 {5 i n l e t6 {7 type zeroGradient ;8 value uniform (0 0 0) ;9 }

10 ou t l e t11 {12 type zeroGradient ;13 value uniform (0 0 0) ;14 }15 }

4.1.4 setFieldsDict

Two different test cases were used to compare the influence of air on cavitation. In both cases theinlet side of the throttle is filled with pressurised water and the outlet with low pressure air asdescribed in boundary conditions. But in the first case it is considered that the throttle is filled withhigh pressure water as shown in figure 4.2.

29

Page 31: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Figure 4.2: Test case 1

Here in the figure 4.2, the alphas is a indicator of different phases i.e. 0 represent the water,1 represents the vapor and 2 represent the air. This kind of spatially non-uniform definition offields can be done using the setFieldDict utility located in the system folder. For the case 1 thesetFieldsDict is defined as shown below :

1 de f au l tF i e l dVa lue s2 (3 vo lSca l a rF i e ldVa lue alpha . a i r 14 vo lSca l a rF i e ldVa lue alpha . water 05 vo lSca l a rF i e ldVa lue alpha . vapor 06 vo lVectorFie ldValue U (0 0 0)7 ) ;8

9 r e g i on s10 (11 boxToCell12 {13 box ( 0 . 0 −2.5e−03 −0.15e−03) (5 e−3 2 .5 e−3 0 .15 e−3) ;14 f i e l dVa l u e s15 (16 vo lSca l a rF i e ldVa lue alpha . water 117 vo lSca l a rF i e ldVa lue alpha . vapor 018 vo lSca l a rF i e ldVa lue alpha . a i r 019 ) ;20 }21 ) ;

All the cells enclosed by the box region defined above will have the alpha.air set to 1 as initialcondition.Similarly in second case the throttle is filled with air as shown in figure 4.3.

Figure 4.3: Test case 2

And the setFieldsDict for case 2 is shown below :

30

Page 32: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

1 de f au l tF i e l dVa lue s2 (3 vo lSca l a rF i e ldVa lue alpha . a i r 14 vo lSca l a rF i e ldVa lue alpha . water 05 vo lSca l a rF i e ldVa lue alpha . vapor 06 vo lVectorFie ldValue U (0 0 0)7 ) ;8

9 r e g i on s10 (11 boxToCell12 {13 box ( 0 . 0 −2.5e−03 −0.15e−03) (5 e−3 2 .5 e−3 0 .15 e−3) ;14 f i e l dVa l u e s15 (16 vo lSca l a rF i e ldVa lue alpha . water 117 vo lSca l a rF i e ldVa lue alpha . vapor 018 vo lSca l a rF i e ldVa lue alpha . a i r 019 ) ;20 }21 ) ;

4.1.5 turbulenceProperties

The kOmegaSST model is used for modelling turbulence.

1 s imulat ionType RAS;2 RAS3 {4 RASModel kOmegaSST ;5 turbu lence on ;6 p r i n tCoe f f s on ;7 }8

4.1.6 Solver settings

1. fvSchemes - used for defining the discretisation schemes. It is important to select the divergenceschemes for all required terms, as it does not have a default scheme.

1 divSchemes2 {3 ” div \( phi , alpha .∗\ ) ” Gauss l im i t edL inea r 1 ;4 ” div \( phir , alpha .∗ , a lpha .∗\ ) ” Gauss l im i t edL in ea r 1 ;5 ” div \( alphaPhi .∗ ,U.∗\ ) ” Gauss l imitedLinearV 1 ;6 div (Rc) Gauss l i n e a r ;7 ” div \( phi .∗ ,U.∗\ ) ” Gauss l imitedLinearV 1 ;8 div ( phi , omega ) Gauss l im i t edL inea r 1 ;9 div ( phi , k ) Gauss l im i t edL inea r 1 ;

10 div ( ( ( rho∗nuEff ) ∗dev2 (T( grad (U) ) ) ) ) Gauss l i n e a r ;11 }12

2. fvSolution - used for defining solver settings.

1

2 ” alpha .∗ ”3 {4 nAlphaSubCycles 3 ;5 }6

7 p rgh8 {9 s o l v e r GAMG;

10 t o l e r an c e 0 ;

31

Page 33: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

11 r e lTo l 0 . 1 ;12 smoother GaussSe ide l ;13 }14

15 p rghFina l16 {17 s o l v e r PCG;18 pr e cond i t i on e r19 {20 pr e cond i t i on e r GAMG;21 t o l e r an c e 1e−7;22 r e lTo l 0 ;23 nVcycles 2 ;24 smoother GaussSe ide l ;25 }26 t o l e r an c e 1e−8;27 r e lTo l 0 ;28 maxIter 25 ;29 }30

31 ” pcorr .∗ ”32 {33 $p rghFina l ;34 t o l e r an c e 1e−08;35 r e lTo l 0 ;36 }37

38 ” (U | k | omega ) ”39 {40 s o l v e r smoothSolver ;41 smoother symGaussSeidel ;42 t o l e r an c e 1e−08;43 r e lTo l 0 . 1 ;44 nSweeps 1 ;45 }46

47 ” (U | k | omega ) Fina l ”48 {49 s o l v e r smoothSolver ;50 smoother symGaussSeidel ;51 t o l e r an c e 1e−08;52 r e lTo l 0 ;53 }54

55

4.2 Results

As mentioned in the introduction this paper is just an attempt to develop a n-phase solver to modelthree phase cavitating flows. The objective of this study is not to study the quantitative influenceof air on cavitation. But presenting the capability of the solver to capture the influence of air, makethis attempt more successful. So two test cases have been simulated to see the qualitative influenceof air on cavitation. In the first case the throttle is filled with water and the air is not presentinside the throttle. Since a high pressure water is already filled the throttle, the air cannot enterthe throttle and it’s effect om cavitation has to be negligible. Figure 4.4 shows the vapor volumefraction at t=2ms.

In the second case the throttle is initially filled with air. In this case, there must be a fraction ofair dispersed in the water inside the throttle and should influence the cavitation. The same can beseen from the figure 4.5, where the volume fraction of vapor is much higher compared to case 1.The volume fraction of air in the throttle in case 2 can be seen from the figure 4.6.Even though thevolume fraction of air is very low it can have significant effect on the vapor formation as shown inthis example.

32

Page 34: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Figure 4.4: Case 1 : Vapor volume fraction at t=2ms

Figure 4.5: Case 2 : Vapor volume fraction at t=2ms

Figure 4.6: Case 2 : volume fraction of air at t=2ms

33

Page 35: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Chapter 5

Appendix

The model files are added to the interfacialModels directory. The phaseChangeModels directory hastwo sub-directories i.e. phaseChangeModel and Kunz. The phaseChangeModel defines the abstractclass for cavitation models and Kunz class describes the implementation of Kunz cavitation model.

5.1 Implementation of phaseChangeModel - the abstract class

5.1.1 phaseChangeModel.H

1

2 #i f n d e f phaseChangeModel H3 #de f i n e phaseChangeModel H4

5 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //6

7 #inc lude ” d i c t i ona ry .H”8 #inc lude ”phaseModel .H”9 #inc lude ” type In fo .H”

10 #inc lude ” runTimeSelect ionTables .H”11 #inc lude ” autoPtr .H”12 #inc lude ”Pair .H”13

14 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //15 namespace Foam16 {17

18 /∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗\19 Class phaseChangeModel Dec la ra t i on20 \∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/21

22 c l a s s phaseChangeModel23 {24

25 protec ted :26

27 // Protected data28 const d i c t i ona ry& i n t e r f a c eD i c t ;29 const phaseModel& phase1 ;30 const phaseModel& phase2 ;31 d i c t i ona ry phaseChangeModelCoeffs ;32

33 //− Saturat ion vapour p r e s su r e34 dimens ionedSca lar pSat ;35

36

37 // Pr ivate Member Functions38

39 //− Disa l low copy cons t ruc t

34

Page 36: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

40 phaseChangeModel ( const phaseChangeModel&) ;41

42 //− Disa l low de f au l t b i tw i s e ass ignment43 void operator=(const phaseChangeModel&) ;44

45 pub l i c :46

47 //− Runtime type in fo rmat ion48 TypeName( ”phaseChangeModel” ) ;49

50

51 // Dec lare run−time cons t ruc to r s e l e c t i o n tab l e52

53 declareRunTimeSelect ionTable54 (55 autoPtr ,56 phaseChangeModel ,57 d i c t i onary ,58 (59 const d i c t i ona ry& in t e r f a c eD i c t ,60 const phaseModel& phase1 ,61 const phaseModel& phase262 ) ,63 ( i n t e r f a c eD i c t , phase1 , phase2 )64 ) ;65

66 // S e l e c t o r s67

68 //− Return a r e f e r e n c e to the s e l e c t e d phaseChange model69 s t a t i c autoPtr<phaseChangeModel> New70 (71 const d i c t i ona ry& in t e r f a c eD i c t ,72 const phaseModel& phase1 ,73 const phaseModel& phase274 ) ;75

76 // Constructors77

78 //− Construct from components79 phaseChangeModel80 (81 const word& type ,82 const d i c t i ona ry& in t e r f a c eD i c t ,83 const phaseModel& phase1 ,84 const phaseModel& phase285 ) ;86

87 //− Destructor88 v i r t u a l ˜phaseChangeModel ( )89 {}90

91 // Member Functions92

93 //− Return const−ac c e s s to the phase f r a c t i o n s94 const phaseModel& phase1 ( ) const95 {96 r e turn phase1 ;97 }98

99 const phaseModel& phase2 ( ) const100 {101 r e turn phase2 ;102 }103

104 //− Return const−ac c e s s to the s a tu ra t i on vapour p r e s su r e105 const d imens ionedSca lar& pSat ( ) const106 {107 r e turn pSat ;

35

Page 37: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

108 }109

110 //− Return the mass condensat ion and vapo r i s a t i on r a t e s as a111 // c o e f f i c i e n t to mult ip ly (1 − a lpha l ) f o r the condensat ion ra t e112 // and a c o e f f i c i e n t to mult ip ly a lpha l f o r the vapo r i s a t i on ra t e113 v i r t u a l Pair<tmp<vo lS ca l a rF i e l d>> mDotAlphal ( ) const = 0 ;114

115 //− Return the mass condensat ion and vapo r i s a t i on r a t e s as c o e f f i c i e n t s116 // to mult ip ly (p − pSat )117 v i r t u a l Pair<tmp<vo lS ca l a rF i e l d>> mDotP( ) const = 0 ;118

119 //− Return the vo lumetr i c condensat ion and vapo r i s a t i on r a t e s as a120 // c o e f f i c i e n t to mult ip ly (1 − a lpha l ) f o r the condensat ion ra t e121 // and a c o e f f i c i e n t to mult ip ly a lpha l f o r the vapo r i s a t i on ra t e122 Pair<tmp<vo lS ca l a rF i e l d>> vDotAlphal ( ) const ;123

124 //− Return the vo lumetr i c condensat ion and vapo r i s a t i on r a t e s as125 // c o e f f i c i e n t s to mult ip ly (p − pSat )126 Pair<tmp<vo lS ca l a rF i e l d>> vDotP ( ) const127 } ;128

129

130 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //131

132 } // End namespace Foam

5.1.2 phaseChangeModel.C

1 #inc lude ”phaseChangeModel .H”2

3 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ S t a t i c Data Members ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //4

5 namespace Foam6 {7 defineTypeNameAndDebug ( phaseChangeModel , 0) ;8 def ineRunTimeSelect ionTable ( phaseChangeModel , d i c t i ona ry ) ;9 }

10

11 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ Constructors ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //12

13 Foam : : phaseChangeModel : : phaseChangeModel14 (15 const word& type ,16 const d i c t i ona ry& in t e r f a c eD i c t ,17 const phaseModel& phase1 ,18 const phaseModel& phase219 )20 :21 i n t e r f a c eD i c t ( i n t e r f a c eD i c t ) ,22 phase1 ( phase1 ) ,23 phase2 ( phase2 ) ,24 phaseChangeModelCoeffs ( i n t e r f a c eD i c t . opt iona lSubDict ( type + ”Coe f f s ” ) ) ,25 pSat ( ”pSat” , dimPressure , i n t e r f a c eD i c t . lookup ( ”pSat” ) )26 {}27

28

29 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ Member Functions ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //30

31 Foam : : Pair<Foam : : tmp<Foam : : vo lS ca l a rF i e l d>>32 Foam : : phaseChangeModel : : vDotAlphal ( ) const33 {34 vo l S c a l a rF i e l d a lpha lCoe f f ( 1 . 0 / phase1 . rho ( ) − phase1 ∗ ( 1 . 0/ phase1 . rho ( ) − 1 .0/

phase2 . rho ( ) ) ) ;35 Pair<tmp<vo lS ca l a rF i e l d>> mDotAlphal = th i s−>mDotAlphal ( ) ;36

37 r e turn Pair<tmp<vo lS ca l a rF i e l d>>38 (39 a lpha lCoe f f ∗mDotAlphal [ 0 ] ,

36

Page 38: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

40 a lpha lCoe f f ∗mDotAlphal [ 1 ]41 ) ;42 }43

44 Foam : : Pair<Foam : : tmp<Foam : : vo lS ca l a rF i e l d>>45 Foam : : phaseChangeModel : : vDotP ( ) const46 {47 dimens ionedSca lar pCoef f ( 1 . 0/ phase1 . rho ( ) − 1 .0/ phase2 . rho ( ) ) ;48 Pair<tmp<vo lS ca l a rF i e l d>> mDotP = th i s−>mDotP( ) ;49

50 r e turn Pair<tmp<vo lS ca l a rF i e l d >>(pCoef f ∗mDotP [ 0 ] , pCoef f ∗mDotP [ 1 ] ) ;51 }

5.1.3 newPhaseChangeModel.C

1 #inc lude ”phaseChangeModel .H”2

3 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //4

5 Foam : : autoPtr<Foam : : phaseChangeModel>6 Foam : : phaseChangeModel : : New7 (8 const d i c t i ona ry& in t e r f a c eD i c t ,9 const phaseModel& phase1 ,

10 const phaseModel& phase211 )12 {13 word phaseChangeModelType ( i n t e r f a c eD i c t . lookup ( ” type” ) ) ;14

15 In f o << ” S e l e c t i n g phaseChangeModel f o r phase ”16 << phase1 . name ( )17 << ” : ”18 << phaseChangeModelType << endl ;19

20 d ic t i onaryConst ruc to rTab le : : i t e r a t o r c s t r I t e r =21 d ic t ionaryConst ructorTab lePtr −>f i nd ( phaseChangeModelType ) ;22

23 i f ( ! c s t r I t e r . found ( ) )24 {25 Fata lError InFunct ion26 << ”Unknown phaseChangeModel type ”27 << phaseChangeModelType << endl << endl28 << ”Val id phaseChangeModels are : ” << endl29 << d ic t ionaryConst ructorTab lePtr −>sortedToc ( )30 << e x i t ( Fata lError ) ;31 }32

33 r e turn c s t r I t e r ( ) ( i n t e r f a c eD i c t , phase1 , phase2 ) ;34 }

5.2 Implementation of Kunz model

5.2.1 Kunz.H

1 #i f n d e f Kunz H2 #de f i n e Kunz H3

4 #inc lude ”phaseChangeModel .H”5

6 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //7

8 namespace Foam9 {

10 namespace phaseChangeModels11 {12

13 /∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗\

37

Page 39: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

14 Class Kunz15 \∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/16

17 c l a s s Kunz18 :19 pub l i c phaseChangeModel20 {21 // Pr ivate data22

23 dimens ionedSca lar UInf ;24 dimens ionedSca lar t I n f ;25 dimens ionedSca lar Cc ;26 dimens ionedSca lar Cv ;27 dimens ionedSca lar p0 ;28 dimens ionedSca lar mcCoeff ;29 dimens ionedSca lar mvCoeff ;30

31

32 pub l i c :33

34 //− Runtime type in fo rmat ion35 TypeName( ”Kunz” ) ;36

37 // Constructors38

39 //− Construct from components40 Kunz41 (42 const d i c t i ona ry& in t e r f a c eD i c t ,43 const phaseModel& phase1 ,44 const phaseModel& phase245 ) ;46

47 //− Destructor48 v i r t u a l ˜Kunz ( )49 {}50

51 // Member Functions52

53 //− Return the mass condensat ion and vapo r i s a t i on r a t e s as a54 // c o e f f i c i e n t to mult ip ly (1 − a lpha l ) f o r the condensat ion ra t e55 // and a c o e f f i c i e n t to mult ip ly a lpha l f o r the vapo r i s a t i on ra t e56 v i r t u a l Pair<tmp<vo lS ca l a rF i e l d>> mDotAlphal ( ) const ;57

58 //− Return the mass condensat ion and vapo r i s a t i on r a t e s as c o e f f i c i e n t s59 // to mult ip ly (p − pSat )60 v i r t u a l Pair<tmp<vo lS ca l a rF i e l d>> mDotP( ) const ;61

62 } ;63

64

65 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //66

67 } // End namespace phaseChangeModels68 } // End namespace Foam69

70 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //71

72 #end i f73

74 // ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //

5.2.2 Kunz.C

1 #inc lude ”Kunz .H”2 #inc lude ”addToRunTimeSelectionTable .H”3

4 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ S t a t i c Data Members ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //

38

Page 40: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

5

6 namespace Foam7 {8 namespace phaseChangeModels9 {

10 defineTypeNameAndDebug (Kunz , 0) ;11 addToRunTimeSelectionTable ( phaseChangeModel , Kunz , d i c t i ona ry ) ;12 }13 }14

15 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ Constructors ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //16

17 Foam : : phaseChangeModels : : Kunz : : Kunz18 (19 const d i c t i ona ry& in t e r f a c eD i c t ,20 const phaseModel& phase1 ,21 const phaseModel& phase222 )23 :24 phaseChangeModel ( typeName , i n t e r f a c eD i c t , phase1 , phase2 ) ,25

26 UInf ( ”UInf” , dimVelocity , phaseChangeModelCoeffs . lookup ( ”UInf” ) ) ,27 t I n f ( ” t I n f ” , dimTime , phaseChangeModelCoeffs . lookup ( ” t I n f ” ) ) ,28 Cc ( ”Cc” , dimless , phaseChangeModelCoeffs . lookup ( ”Cc” ) ) ,29 Cv ( ”Cv” , d imless , phaseChangeModelCoeffs . lookup ( ”Cv” ) ) ,30

31 p0 ( ”0” , pSat ( ) . d imensions ( ) , 0 . 0 ) ,32

33 mcCoeff ( Cc ∗phase2 . rho ( ) / t I n f ) ,34 mvCoeff (Cv ∗phase2 . rho ( ) / (0 . 5∗ phase2 . rho ( ) ∗ sqr ( UInf ) ∗ t I n f ) )35 {36 }37

38

39 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ Member Functions ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //40

41 Foam : : Pair<Foam : : tmp<Foam : : vo lS ca l a rF i e l d>>42 Foam : : phaseChangeModels : : Kunz : : mDotAlphal ( ) const43 {44 const v o l S c a l a rF i e l d& p = phase1 . db ( ) . lookupObject<vo lS ca l a rF i e l d >(”p” ) ;45 vo l S c a l a rF i e l d l imitedAlpha1 (min (max( phase1 , s c a l a r (0 ) ) , s c a l a r (1 ) ) ) ;46

47 r e turn Pair<tmp<vo lS ca l a rF i e l d>>48 (49 mcCoeff ∗ sqr ( l imitedAlpha1 )50 ∗max(p − pSat ( ) , p0 ) /max(p − pSat ( ) , 0 .01∗ pSat ( ) ) ,51

52 mvCoeff ∗min(p − pSat ( ) , p0 )53 ) ;54 }55

56 Foam : : Pair<Foam : : tmp<Foam : : vo lS ca l a rF i e l d>>57 Foam : : phaseChangeModels : : Kunz : : mDotP( ) const58 {59 const v o l S c a l a rF i e l d& p = phase1 . db ( ) . lookupObject<vo lS ca l a rF i e l d >(”p” ) ;60 vo l S c a l a rF i e l d l imitedAlpha1 (min (max( phase1 , s c a l a r (0 ) ) , s c a l a r (1 ) ) ) ;61 vo l S c a l a rF i e l d l imitedAlpha2 (min (max( phase2 , s c a l a r (0 ) ) , s c a l a r (1 ) ) ) ;62 r e turn Pair<tmp<vo lS ca l a rF i e l d>>63 (64 mcCoeff ∗ sqr ( l imitedAlpha1 ) ∗( l imitedAlpha2 )65 ∗pos (p − pSat ( ) ) /max(p − pSat ( ) , 0 .01∗ pSat ( ) ) ,66

67 (−mvCoeff ) ∗ l imitedAlpha1 ∗neg (p − pSat ( ) )68 ) ;69 }70

71 // ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //

39

Page 41: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

5.3 Changes to multiphaseSystem class

5.3.1 multiphaseSystem.H

The following lines are added to the multiphaseSystem.H file.

1 // Add the phaseChangeModel c l a s s2 #inc lude ”phaseChangeModel .H”3

4 // Hash tab l e f o r l i s t o f c a v i t a t i o n models5 typede f HashPtrTable<phaseChangeModel , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>6 pcTable ;7 // Hash tab l e f o r condensat ion and vapo r i z a t i on c o e f f i c i e n t s8 typede f HashPtrTable<vo lS ca l a rF i e l d , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>9 cF i e l d s ;

10 typede f HashPtrTable<vo lS ca l a rF i e l d , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>11 vF i e ld s ;12 // Hash tab l e f o r source terms f o r pEqn13 typede f HashPtrTable<vo lS ca l a rF i e l d , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>14 pSatF ie lds ;15

16 typede f HashPtrTable<vo lS ca l a rF i e l d , i n t e r f a c ePa i r , i n t e r f a c ePa i r : : symmHash>17 pFie ld s ;18

19

20 //− Return the tab l e o f phase change models21 const pcTable& pcModels ( ) const22 {23 r e turn pcModels ;24 }25 //− Return the condensat ion r a t e s f o r a l l o f the i n t e r f a c e s26 autoPtr<cF i e ld s> cCoe f f s ( ) const ;27

28 //− Return the vapo r i z a t i on r a t e s f o r a l l o f the i n t e r f a c e s29 autoPtr<vFie lds> vCoe f f s ( ) const ;30

31 //− de f i n e the Su and Sp terms f o r alphaEqn32 tmp<vo lS ca l a rF i e l d> pcSp33 (34 const phaseModel& phase ,35 const cF i e l d s& cCoef f s ,36 const vF i e ld s& vCoe f f s37 ) const ;38

39 tmp<vo lS ca l a rF i e l d> pcSu40 (41 const phaseModel& phase ,42 const cF i e l d s& cCoef f s ,43 const vF i e ld s& vCoe f f s44 ) const ;45

46 //− de f i n e the Su and Sp terms f o r pEqn47

48 tmp<vo lS ca l a rF i e l d> pcPSp49 (50 const pF i e ld s& pCoef f s51 ) const ;52

53 tmp<vo lS ca l a rF i e l d> pcPSu54 (55 const pSatF ie lds& pSats56 ) const ;

5.3.2 multiphaseSystem.C

The following lines are added to the multiphaseSystem.C file.

40

Page 42: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

1 // Mapping the condensat ion and vapo r i s a t i on terms to i n t e r f a c e pa i r s2

3 Foam : : autoPtr<Foam : : multiphaseSystem : : cF i e ld s>4 Foam : : multiphaseSystem : : cCoe f f s ( ) const5 {6 autoPtr<cF i e ld s> cCoe f f sPt r (new cF i e l d s ) ;7

8 f o rA l lCon s t I t e r ( pcTable , pcModels , i t e r )9 {

10 const phaseChangeModel& pc = ∗ i t e r ( ) ;11 const Pair<tmp<vo lS ca l a rF i e l d>> vDotAlphal = pc . vDotAlphal ( ) ;12 vo l S c a l a rF i e l d ∗ Kptr = ( vDotAlphal [ 0 ] ) . ptr ( ) ;13 cCoe f f sPt r ( ) . i n s e r t ( i t e r . key ( ) , Kptr ) ;14 }15 r e turn cCoe f f sPt r ;16 }17

18 Foam : : autoPtr<Foam : : multiphaseSystem : : vFie lds>19 Foam : : multiphaseSystem : : vCoe f f s ( ) const20 {21 autoPtr<vFie lds> vCoe f f sPtr (new vF i e ld s ) ;22

23 f o rA l lCon s t I t e r ( pcTable , pcModels , i t e r )24 {25 const phaseChangeModel& pc = ∗ i t e r ( ) ;26 const Pair<tmp<vo lS ca l a rF i e l d>> vDotAlphal = pc . vDotAlphal ( ) ;27 vo l S c a l a rF i e l d ∗ Kptr = ( vDotAlphal [ 1 ] ) . ptr ( ) ;28 vCoe f f sPtr ( ) . i n s e r t ( i t e r . key ( ) , Kptr ) ;29 }30 r e turn vCoe f f sPtr ;31 }32

33 // Mapping phase change momentum t r a n s f e r terms to i n t e r f a c ePa i r −−−ed i t34 Foam : : autoPtr<Foam : : multiphaseSystem : : pFie lds>35 Foam : : multiphaseSystem : : pCoe f f s ( ) const36 {37 autoPtr<cF i e ld s> pCoef f sPtr (new pFie ld s ) ;38

39 f o rA l lCon s t I t e r ( pcTable , pcModels , i t e r )40 {41 const phaseChangeModel& pc = ∗ i t e r ( ) ;42 const Pair<tmp<vo lS ca l a rF i e l d>> vDotP = pc . vDotP ( ) ;43 vo l S c a l a rF i e l d ∗ Kptr = (vDotP[1]−vDotP [ 0 ] ) . ptr ( ) ;44 pCoef f sPtr ( ) . i n s e r t ( i t e r . key ( ) , Kptr ) ;45 }46 r e turn pCoef f sPtr ;47 }48

49

50

51 Foam : : autoPtr<Foam : : multiphaseSystem : : pSatFie lds>52 Foam : : multiphaseSystem : : pSats ( ) const53 {54 autoPtr<cF i e ld s> pSatsPtr (new pSatF ie lds ) ;55

56 f o rA l lCon s t I t e r ( pcTable , pcModels , i t e r )57 {58 const phaseChangeModel& pc = ∗ i t e r ( ) ;59 const Pair<tmp<vo lS ca l a rF i e l d>> vDotP = pc . vDotP ( ) ;60 const d imens ionedSca lar psat = pc . pSat ( ) ;61 vo l S c a l a rF i e l d ∗ Kptr = ( psat ∗(vDotP[1]−vDotP [ 0 ] ) ) . ptr ( ) ;62 pSatsPtr ( ) . i n s e r t ( i t e r . key ( ) , Kptr ) ;63 }64 r e turn pSatsPtr ;65 }66

67

68

41

Page 43: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

69 // Ca l cu la t i on o f the source terms in alphaEqn70

71 Foam : : tmp<Foam : : vo lS ca l a rF i e l d> Foam : : multiphaseSystem : : pcSp72 (73 const phaseModel& phase ,74 const cF i e l d s& cCoef f s ,75 const vF i e ld s& vCoe f f s76 ) const77 {78 tmp<vo lS ca l a rF i e l d> tpcSp79 (80 new vo l S c a l a rF i e l d81 (82 IOobject83 (84 ”pcSp” ,85 mesh . time ( ) . timeName ( ) ,86 mesh87 ) ,88 mesh ,89 dimens ionedSca lar90 (91 ”pcSp” ,92 d imle s s /dimTime ,93 094 )95 )96

97 ) ;98

99 pcTable : : c o n s t i t e r a t o r p c I t e r = pcModels . begin ( ) ;100 cF i e l d s : : c o n s t i t e r a t o r c I t e r = cCoe f f s . begin ( ) ;101 vF i e ld s : : c o n s t i t e r a t o r v I t e r = vCoe f f s . begin ( ) ;102 f o r103 (104 ;105 pc I t e r != pcModels . end ( ) && c I t e r != cCoe f f s . end ( ) && v I t e r != vCoe f f s . end ( )

;106 ++pcI te r , ++c I t e r ,++v I t e r107 )108 {109 i f110 (111 &phase == &pc I t e r ( )−>phase1 ( )112 | | &phase == &pc I t e r ( )−>phase2 ( )113 )114 {115 i f (&phase == &pc I t e r ( )−>phase1 ( ) )116 {117 const v o l S c a l a rF i e l d Sp = ∗ v I t e r ( ) ;118 tpcSp . r e f ( ) = Sp ;119 }120

121 i f (&phase == &pc I t e r ( )−>phase2 ( ) )122 {123 const v o l S c a l a rF i e l d Sp = ∗ c I t e r ( ) ;124 tpcSp . r e f ( ) = −Sp ;125 }126 }127 }128

129 r e turn tpcSp ;130 }131

132

133

134 Foam : : tmp<Foam : : vo lS ca l a rF i e l d> Foam : : multiphaseSystem : : pcSu135 (

42

Page 44: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

136 const phaseModel& phase ,137 const cF i e l d s& cCoef f s ,138 const vF i e ld s& vCoe f f s139 ) const140 {141 tmp<vo lS ca l a rF i e l d> tpcSu142 (143 new vo l S c a l a rF i e l d144 (145 IOobject146 (147 ”pcSu” ,148 mesh . time ( ) . timeName ( ) ,149 mesh150 ) ,151 mesh ,152 dimens ionedSca lar153 (154 ”pcSu” ,155 d imle s s /dimTime ,156 0157 )158 )159 ) ;160 pcTable : : c o n s t i t e r a t o r p c I t e r = pcModels . begin ( ) ;161 cF i e l d s : : c o n s t i t e r a t o r c I t e r = cCoe f f s . begin ( ) ;162 vF i e ld s : : c o n s t i t e r a t o r v I t e r = vCoe f f s . begin ( ) ;163 f o r164 (165 ;166 pc I t e r != pcModels . end ( ) && c I t e r != cCoe f f s . end ( ) && v I t e r != vCoe f f s . end ( )

;167 ++pcI te r , ++c I t e r ,++v I t e r168 )169 {170 const phaseModel ∗phasePtr = nu l l p t r ;171 i f172 (173 &phase == &pc I t e r ( )−>phase1 ( )174 | | &phase == &pc I t e r ( )−>phase2 ( )175 )176 {177 i f (&phase == &pc I t e r ( )−>phase1 ( ) )178 {179 phasePtr = &pc I t e r ( )−>phase2 ( ) ;180 const v o l S c a l a rF i e l d alpha = ∗phasePtr ;181 const v o l S c a l a rF i e l d Su = ∗ c I t e r ( ) ;182 tpcSu . r e f ( ) = Su∗ alpha ;183 }184

185 i f (&phase == &pc I t e r ( )−>phase2 ( ) )186 {187 phasePtr = &pc I t e r ( )−>phase1 ( ) ;188 const v o l S c a l a rF i e l d alpha = ∗phasePtr ;189 const v o l S c a l a rF i e l d Su = ∗ v I t e r ( ) ;190 tpcSu . r e f ( )= −Su∗ alpha ;191 }192 }193 }194

195 r e turn tpcSu ;196 }197

198

199

200

201

202

43

Page 45: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

203 // Edit − source terms to be added to the pEqn204

205 Foam : : tmp<Foam : : vo lS ca l a rF i e l d> Foam : : multiphaseSystem : : pcPSp206 (207 const pF i e ld s& pCoef f s208 ) const209 {210 tmp<vo lS ca l a rF i e l d> tpcPSp211 (212 new vo l S c a l a rF i e l d213 (214 IOobject215 (216 ”pcPSp” ,217 mesh . time ( ) . timeName ( ) ,218 mesh219 ) ,220 mesh ,221 dimens ionedSca lar222 (223 ”pcPSp” ,224 dimensionSet (−1 , 1 , 1 , 0 , 0) ,225 0226 )227 )228 ) ;229

230 pcTable : : c o n s t i t e r a t o r dmIter = pcModels . begin ( ) ;231 pFie ld s : : c o n s t i t e r a t o r d c I t e r = pCoef f s . begin ( ) ;232 f o r233 (234 ;235 dmIter != pcModels . end ( ) && dc I t e r != pCoe f f s . end ( ) ;236 ++dmIter , ++dc I t e r237 )238 {239 tpcPSp . r e f ( ) += ∗ dc I t e r ( ) ;240 }241

242 r e turn tpcPSp ;243 }244

245

246

247 Foam : : tmp<Foam : : vo lS ca l a rF i e l d> Foam : : multiphaseSystem : : pcPSu248 (249 const pSatF ie lds& pSats250 ) const251 {252 tmp<vo lS ca l a rF i e l d> tpcPSu253 (254 new vo l S c a l a rF i e l d255 (256 IOobject257 (258 ”pcPSu” ,259 mesh . time ( ) . timeName ( ) ,260 mesh261 ) ,262 mesh ,263 dimens ionedSca lar264 (265 ”pcPSu” ,266 dimensionSet (0 , 0 , −1, 0 , 0) ,267 0268 )269 )270 ) ;

44

Page 46: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

271

272 pcTable : : c o n s t i t e r a t o r pmIter = pcModels . begin ( ) ;273 pFie ld s : : c o n s t i t e r a t o r p c I t e r = pSats . begin ( ) ;274

275 f o r276 (277 ;278 pmIter != pcModels . end ( ) && pc I t e r != pSats . end ( ) ;279 ++pmIter , ++pc I t e r280 )281 {282 tpcPSu . r e f ( ) −= ∗ pc I t e r ( ) ;283 }284

285 r e turn tpcPSu ;286 }

In the solveAlphas() function the MULES functions have to modified to consider the source termsdefined above.

1 // Adding Sp and Su terms to MULES l im i t2 const v o l S c a l a rF i e l d Sp( pcSp ( phase , cCoe f f s ( ) , vCoe f f s ( ) ) ) ;3 const v o l S c a l a rF i e l d Su( pcSu ( phase , cCoe f f s ( ) , vCoe f f s ( ) ) ) ;4 MULES: : l im i t5 (6 1 .0/mesh . time ( ) . deltaT ( ) . va lue ( ) ,7 geometr icOneFie ld ( ) ,8 phase ,9 phi ,

10 alphaPhiCorr ,11 Sp ( ) ,12 Su ( ) ,13 1 ,14 0 ,15 t rue16 ) ;17

18 // Adding Sp and Su terms to MULES e x p l i c i t s o l v e19 const v o l S c a l a rF i e l d Sp( pcSp ( phase , cCoe f f s ( ) , vCoe f f s ( ) ) ) ;20 const v o l S c a l a rF i e l d Su( pcSu ( phase , cCoe f f s ( ) , vCoe f f s ( ) ) ) ;21 MULES: : e x p l i c i t S o l v e22 (23 geometr icOneFie ld ( ) ,24 phase ,25 alphaPhi ,26 Sp ( ) ,27 Su ( )28 ) ;

5.3.3 Adding source terms to pEqn.H

1

2 // ed i t −−− Adding the phase change source terms in momentum eqn3 const v o l S c a l a rF i e l d SpCoeff ( f l u i d . pcPSp( f l u i d . pCoe f f s ( ) ) ) ;4 const v o l S c a l a rF i e l d Su( f l u i d . pcPSu( f l u i d . pSats ( ) ) ) ;5

6 f vSca la rMatr ix pEqnIncomp7 (8 f v c : : d iv (phiHbyA)9 − fvm : : l a p l a c i a n ( rAUf , p rgh )

10 + Su11 + fvm : : Sp( SpCoeff , p rgh )12 ) ;

45

Page 47: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

5.3.4 transportProperties used for tutorials

1 phases2 (3 water4 {5 nu 3 .8 e−06;6 kappa 1e−06;7 Cp 4195 ;8 rho 820 ;9

10 diameterModel constant ;11 cons tantCoe f f s12 {13 d 1e−3;14 }15 }16

17 vapor18 {19 nu 4 .52 e−05;20 kappa 1e−06;21 Cp 4195 ;22 rho 0 . 1 2 ;23

24 diameterModel constant ;25 cons tantCoe f f s26 {27 d 1e−5;28 }29 }30

31 a i r32 {33 nu 1 .48 e−05;34 kappa 2 .63 e−2;35 Cp 1007 ;36 rho 1 ;37

38 diameterModel constant ;39 cons tantCoe f f s40 {41 d 1e−5;42 }43 }44 ) ;45

46 sigmas47 (48 ( water vapor ) 0 .0349 ) ;50

51 i n t e r faceCompres s i on52 (53 ( water vapor ) 154 ) ;55

56 v i r tua lMass57 (58 ) ;59

60 drag61 (62 ( water vapor )63 {64 type blended ;65

66 vapor

46

Page 48: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

67 {68 type Schil lerNaumann ;69 r e s idua lPhaseFrac t i on 0 ;70 r e s i d u a l S l i p 0 ;71 }72

73 water74 {75 type Schil lerNaumann ;76 r e s idua lPhaseFrac t i on 0 ;77 r e s i d u a l S l i p 0 ;78 }79

80 r e s idua lPhaseFrac t i on 1e−3;81 r e s i d u a l S l i p 1e−3;82 }83

84 ( a i r water )85 {86 type blended ;87

88 a i r89 {90 type Schil lerNaumann ;91 r e s idua lPhaseFrac t i on 0 ;92 r e s i d u a l S l i p 0 ;93 }94

95 water96 {97 type Schil lerNaumann ;98 r e s idua lPhaseFrac t i on 0 ;99 r e s i d u a l S l i p 0 ;

100 }101

102 r e s idua lPhaseFrac t i on 1e−3;103 r e s i d u a l S l i p 1e−3;104 }105

106 ( a i r vapor )107 {108 type blended ;109

110 a i r111 {112 type Schil lerNaumann ;113 r e s idua lPhaseFrac t i on 0 ;114 r e s i d u a l S l i p 0 ;115 }116

117 vapor118 {119 type Schil lerNaumann ;120 r e s idua lPhaseFrac t i on 0 ;121 r e s i d u a l S l i p 0 ;122 }123

124 r e s idua lPhaseFrac t i on 1e−3;125 r e s i d u a l S l i p 1e−3;126 }127 ) ;128 phaseChange129 (130 ( water vapor )131 {132 type Kunz ;133 pSat 2288 ;134 KunzCoeffs

47

Page 49: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

135 {136 UInf 2 0 . 0 ;137 t I n f 0 . 0 0 5 ; // L = 0 .1 m138 Cc 1000 ;139 Cv 1000 ;140 }141 }142 ) ;

48

Page 50: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

References

The detailed explanations for most of the concepts presented in this report can be found in thefollowing literature

1. Numerical modelling of diesel spray injection, turbulence interaction and combustion, PhDthesis, Fabian Peng Karrholm.

2. Hybrid multiphase CFD solver for coupled dispersed/segregated flows in liquid-liquid extrac-tion, Kent E.Wardle and H.G.Weller.

3. Computational fluid dynamics of dispersed two-phase flows at high phase fractions, PhD thesis,Henrik Rusche.

4. An extended mixture model for simultaneous treatment of short and long scale interfaces, PhDthesis, Santiago Damian.

5. An introduction to twoPhaseEulerFoam with addition of an heat exchange model,AlessandroManni OF course report.

49

Page 51: Implementation of cavitation models into the multiphaseEulerFoam solverhani/kurser/OS_CFD_2017/... · 2017-12-21 · Chapter 1 Introduction 1.1 Background In many multiphase ows,

Study questions

Theory

1. How can the multiphaseEulerFoam be used to resolve the disperesed and segregated flows?

2. How can we couple the VOF method with Euler-Euler approach?

Implementation

3. What are the different libraries in the multiphaseEulerFoam solver and what purpose do theyserve?

4. What is the logic on which the solver identifies the correct field value/model type for a givenphase pair?

5. What is the basic mechanism on which new cavitation models can be added to the solver?

Usage

6. What is the name of the dictionary that has to be added to include the cavitation models?

7. What is the order in which the interfacePair has to be defined for adding cavitation models?

50