friedrich-alexander-universitat erlangen … · friedrich-alexander-universitat erlangen-n urnberg...

56
FRIEDRICH-ALEXANDER-UNIVERSIT ¨ AT ERLANGEN-N ¨ URNBERG INSTITUT F ¨ UR INFORMATIK (MATHEMATISCHE MASCHINEN UND DATENVERARBEITUNG) Lehrstuhl f¨ ur Informatik 10 (Systemsimulation) Investigation of Mixture Modelling for the Lattice Boltzmann Method Dominik Geuß Master Thesis

Upload: doanh

Post on 25-May-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-NURNBERGINSTITUT FUR INFORMATIK (MATHEMATISCHE MASCHINEN UND DATENVERARBEITUNG)

Lehrstuhl fur Informatik 10 (Systemsimulation)

Investigation of Mixture Modelling for the Lattice BoltzmannMethod

Dominik Geuß

Master Thesis

Page 2: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Investigation of Mixture Modelling for the Lattice BoltzmannMethod

Dominik GeußMaster Thesis

Aufgabensteller: Prof. Dr. Ulrich Rude

Betreuer: Dipl.-Inf. Christian Feichtinger

Bearbeitungszeitraum: 10. Dezember 2007 - 24. Juni 2008

Page 3: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Erklarung:

Ich versichere, dass ich die Arbeit ohne fremde Hilfe und ohne Benutzung anderer als der angege-benen Quellen angefertigt habe und dass die Arbeit in gleicher oder ahnlicher Form noch keineranderen Prufungsbehorde vorgelegen hat und von dieser als Teil einer Prufungsleistung angenom-men wurde. Alle Ausfuhrungen, die wortlich oder sinngemaß ubernommen wurden, sind als solchegekennzeichnet.

Erlangen, den 23. Juni 2008 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 4: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Abstract

In the field of physical chemistry, multicomponent mixture modeling plays an important role. Oneissue that comes up is the closure of the diffusion flux, when a single-fluid approach is chosen.In this thesis, two constitutive relations for the diffusive transport are discussed. Among thesetwo models the Fickian formulation is the more popular, which was derived from binary mixtureexperiments, whereas the Maxwell-Stefan relations were developed based on kinetic theory. Bothmodels are discretized in two dimensions using the finite difference method. The resulting equationsare implemented in C++ and the fluid flow simulation is implemented using the Lattice BoltzmannMethod. The numerical experiments serve to verify the implementation and to demonstrate thelimited validity of Fick’s law of diffusion with respect to multicomponent mixtures.

Kurzfassung

Im Bereich der physikalischen Chemie spielt Modellierung von Mehrkomponentenmischungen einegroße Rolle. Fur einen single-fluid Ansatz stellt hierbei der diffusive Transport ein Problem dar.Im Rahmen dieser Arbeit werden zwei Modelle fur den Diffusionsfluss vorgestellt. Das bekanntereModell ist das Ficksche Diffusionsgesetz, welches sich von Experimenten mit binaren Mischungenableiten lasst, wohingegen das Maxwell-Stefan Modell anhand der kinetischen Theorie entwickeltwurde. Fur eine Diskretisierung der beiden Modelle in zwei Raumdimensionen wird die Methodeder Finiten Differenzen verwendet. Die daraus resultierenden Gleichungssysteme wurden mittels derProgrammiersprace C++ implementiert, wobei das Stromungsfeld anhand der Lattice BoltzmannMethode berechnet wird. Die durchgefuhrten numerischen Experimente dienen zum einen derVerifizierung der Implementation und zum anderen dazu den beschrankten Gultigkeitsbereich desFickschen Gesetzes in Bezug auf Mehrkomponentenmischungen zu demonstieren.

Page 5: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Contents

1 Introduction 1

2 Lattice Boltzmann method 22.1 Introduction to the LBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.2 Theory of the LBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.3 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Theory 63.1 General scalar transport equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.2 Species transport equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.3 Modeling the diffusion flux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.3.1 Fick’s first law of diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.3.2 Maxwell-Stefan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4 Discretization using the finite difference method 154.1 Temporal discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2 Formulations based on Fick’s law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.2.1 First order spatial discretization . . . . . . . . . . . . . . . . . . . . . . . . . 164.2.2 High Order Compact scheme for the transport equation . . . . . . . . . . . . 18

4.3 Formulation based on the Maxwell-Stefan relations . . . . . . . . . . . . . . . . . . . 204.3.1 First order discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.3.2 An attempt to apply the HOC scheme to Maxwell-Stefan . . . . . . . . . . . 22

5 Implementation 245.1 General remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.2 Solving the species transport equation . . . . . . . . . . . . . . . . . . . . . . . . . . 26

5.2.1 Implementation of Fick’s Law with first order accuracy . . . . . . . . . . . . 265.2.2 Higher order compact scheme . . . . . . . . . . . . . . . . . . . . . . . . . . 285.2.3 Implementation of the Maxwell-Stefan formulation . . . . . . . . . . . . . . . 32

6 Results 376.1 Measurement of the binary diffusion coefficient . . . . . . . . . . . . . . . . . . . . . 386.2 Measurement of numerical diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416.3 Solvent test case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

7 Conclusion 48

8 Acknowledgements 49

i

Page 6: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 1

Introduction

In computational fluid dynamics the simulation of mixtures represents a challenging task. Withinthese mixtures, the diffusion flux can be modelled by two common constitutive relations. The firstone is called Fick’s Law of diffusion and was derived from binary mixture experiments by AdolfFick. The second mathematical formulation was developed by Maxwell and Stefan based on kinetictheory. Among these two models the Fickian formulation is the more popular, but its validity isrestricted to binary mixtures. When Fick’s law of diffusion is applied to mixtures containing morethan two components, physical consistent behavior can only be expected for a few limiting cases.One of them is the so called solvent case, where one component is in large excess of all the others.Therefore, the dilute species in the mixture essentially interact with the solvent only and Fick’sLaw can be applied. Whereas, when the species concentrations are no longer negligible, then theMaxwell-Stefan model has to be applied. This model accounts for the interactions among all thespecies and provides a description for an arbitrary number of components and their concentrations.This constituive relation results in a coupled system of equations, which is more costly to solve thanthe Fickian formulation.In the scope of this thesis both models are investigated. The individual species in a mixture areregarded as passive scalars, thus, the overall mixture velocity is not influenced by changes in thespecies concentrations. Therefore, the calculation of the flow field can be detached from the mixtureproblem. The velocity distribution is computed by the Lattice Boltzmann Method (LBM), whichis adressed in Chapter 2.The partial differential equation (PDE) governing the mass transport will be the subject of Chapter3. Some general remarks concerning the characteristics of PDE’s are given and subsequently thespecies transport equation as well as the required units of measurement are introduced. Further,Fick’s law of diffusion and the Maxwell-Stefan relations are derived in this Chapter.In Chapter 4 the discretization of the developed equations will be presented by means of the finitedifference (FD) method. The Crank-Nicolson method is used to approximate the time derivative.For the Fickian mixture model a discretization scheme of first and fourth order spatial accuracy isdeveloped. The discretization of the Maxwell-Stefan relations is discussed by means of a first orderspatial accuracy and the mathematical problems arising during the derivation of a higher order FDscheme are adressed.The implementation details of the derived equations are illustrated in Chapter 5 by means of anumber of code examples. These range from general remarks concering the data structure to adetailed explanation of the coupled system of equations generated by the Maxwell-Stefan model.In addition, the utilized external code libraries are also introduced.Results of the numerical experiments are provided in Chapter 6. The first test focuses on the validimplementation of the different models. This is done by comparison of the measured diffusivityto the theoretical one. Thereafter, the impact of convection is investigated in order to providea measure for the resulting numerical diffusion. By analyzing the solvent test case, the validitydomain of Fick’s law is illustrated and compared to that of the Maxwell-Stefan relations.Finally, Chapter 7 concludes this thesis by a discussion of the reached goals. In addition, some ideasfor further research are listed to accomplish higher order accuracy for the Maxwell-Stefan relations.

1

Page 7: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 2

Lattice Boltzmann method

2.1 Introduction to the LBM

The Lattice Boltzmann method (LBM) is one approach to solve fluid dynamic problems numeri-cally and is regarded as a mesoscopic approach. On the microscopic level there is the moleculardynamics simulation. Here, the time evolution of a set of interacting atoms is followed by numeri-cally integrating their equations of motion. The macroscopic point of view assumes the change ofmomentum in a control volume to be equal to the sum of forces acting on it. This approach leadsto the well-known Navier-Stokes equations (NS). Assuming an incompressible fluid, the equationsfor mass and momentum conservation read:

∂ui∂xi

= 0 (Continuity equation) (2.1)

∂uj∂t

+ ui∂uj∂xi

= − ∂P∂xj

− 1Re

∂2uj∂xi∂xi

+ gj (Momentum equation) (2.2)

The left hand side of the momentum equation describes the change of momentum in the fluid,whereas the right hand side denotes the acting forces like pressure gradient, viscous term andgravity. The dimensionless Reynolds number Re is a measure for the relation of inertia forces toviscous forces. At low Reynolds numbers viscous forces are dominant, thus leading to laminar flow,whereas at high Reynolds numbers turbulent flow occurs, dominated by inertial forces.For small deviations from the thermodynamic equilibrium using a multiscale analysis it can beshown that the LBM asymptotically approximates the Navier Stokes equations with a second orderspatial and first order temporal accuracy [11]. The LBM was developed based on the lattice-gascellular automata (LGCA), where flows are considered to be composed of fluid portions or fictiveparticles, which are located at certain points in space. These fluid portions propagate at differentspeeds in different directions on a fixed lattice. During each time step they move according to theircurrent momentum vector. If the situation occurs in which two particles end up on the same latticesite, they collide and change their velocities according to specific rules. These collision rules dictatethat number, mass and momentum of the colliding particles are conserved. The idea is to mimicthe complex dynamical system behavior with repeatedly applying these simple rules of propagationand collision. For more information regarding the LGCA see [21].

2.2 Theory of the LBM

The Lattice Boltzmann method was introduced to overcome some drawbacks of the LGCA mostlydue to the boolean representation of the particles [18]. So instead of dealing with individual particlesthe LBM replaces the boolean LGCA occupation number by an averaged particle distributionfunction f = f(x, ξ, t) represented by a floating point number. Here x is the spatial position, ξdenotes the particle velocity vector and t represents the time. Hence, the Boltzmann equationreads:

δf

δt+ ξ∇ f = Q ( f ), (2.3)

2

Page 8: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

where the first term on left hand side describes the time variation of the particle distributionfunction, the second term denotes the spatial variation while on the right hand side the collisionterm models the interaction of the molecules. The complicated nonlinear integral collision operatoris often substituted by simplified expression. The most popular kinetic model was proposed byBhatnagar, Gross and Krook, see [13] for detailed information. With this approximation of thecollision operator, Eq. (2.3) becomes:

δf

δt+ ξ∇ f = −ω(f− feq), (2.4)

where feq is the local equilibrium distribution function parametrized by the local conserved quan-tities, density ρ∗ and velocity u∗. The reciprocal of ω is called single step relaxation time, alsodefining the viscosity of the fluid by:

ν∗ =(

1ω− 0.5

)c2sδt, (2.5)

here cs denotes the speed of sound and dictates how fast the information is transported throughthe grid. By relating cs to the flow velocity the Mach number is obtained:

Ma =u

cs(2.6)

For the spatial discretization the continuous microscopic velocities are replaced by a set of discrete

NENNW

S SESE

EW

e2

e3

e1

e4

e5e6

e7e8

Figure 2.1: D2Q9 discrete velocity model

velocities. Depending on the number of discrete velocities one can set up several lattice models.The classification is done by means of the DnQm scheme proposed by Qian et al [14] . Here Dnstands for n dimensions while Qm denotes the m discrete velocities. For the 2-dimensional case theD2Q9 lattice model is used, as shown in Figure 2.1. Each cell in the lattice contains one stationarystate for fluid particles at rest, four velocity directions along the Cartesian axes and four diagonalvelocities. The fluid particles are only allowed to move along the eight discrete velocity directions toneighboring lattice cells or to rest in this cell. The number of fluid particles moving in each latticedirection is dictated by the fluid velocity and density in this cell. Eq. (2.7) shows the velocitydiscretized formulation of Eq. (2.4) by limiting the space to a lattice and the velocity space to aset of discrete velocities eα replacing the continuous ξ:

δfαδt

+ eα∇fα = −ω(fα − feqα ) (2.7)

3

Page 9: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

According to [7] the derivation of the local equilibrium distribution function feqα is conducted,assuming Kn << 1 and Ma << 1, where Kn represents the Knudsen number. This dimensionlessparameter relates the molecular mean free path length to a representative physical length scale.With that feqα is obtained by Taylor expansion of the Maxwellian distribution. It describes astate, in which further collisions would not affect the particle distribution. The local equilibriumdistribution function reads:

feqα = wαρ[1 +3c2

(eα · u∗) +9

2c4(eα · u∗)2 − 3

2c2u∗2], α = 1, ...,m (2.8)

where wα is a weighting factor, m is the number of discrete directions and eα is the corespondingdiscrete velocity vector. In addition u∗ = (u∗, v∗) denotes the macroscopic lattice velocity, ρ is thehydrodynamic density and c = δx

δt refers to the lattice speed, where δx is the lattice constant andδt the time step. Usually the lattice speed is parametrized to 1. For the D2Q9 model the weightingfactors and the discrete velocity vectors become:

wα =

4919136

eα =

(0, 0) α = 0(±1, 0)c, (0,±1)c α = 1, 2, 3, 4(±1,±1)c α = 5, 6, 7, 8

(2.9)

The macroscopic parameters such as density ρ and momentum ρu result from the hydrodynamicmoments of the particle distribution function and are determined by:

ρ =∑α

fα (2.10)

andρu =

∑α

eαfα (2.11)

The mapping of physical parameters into dimensionless lattice parameters is done using the followingequations:

ν∗ = νδt

δx2(2.12)

u∗ = uδt

δx(2.13)

L∗ =L

δx(2.14)

The transient term is discretized based on a forward finite difference scheme and including thespatial discretization, Eq. (2.7) results in:

fα(xi + eαδt, t+ δt)− fα(xi, t) = −ω[fα(xi, t)− feqα (xi, t)] (2.15)

Finally Eq. (2.15) can be split up and solved in two steps.Collision step:

fα(xi, t) = fα(xi, t)− ω[fα(xi, t)− feqα (xi, t)] (2.16)

Streaming step:fα(xi + eαδt, t+ δt) = fα(xi, t) (2.17)

In the collision step the post collision distribution function fα is calculated according to the oldtimestep. The propagation of the particles to the neighboring cells is carried out in the streamingstep.

4

Page 10: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

2.3 Boundary conditions

In the present work the species transport equation is solved only on rectangular domains. There-fore only a few different boundary conditions are required for the LBM. In case of a channel flowsetup, the inflow and the outflow was modeled by imposing a constant velocity at the streamwiseboundaries. The no-slip condition at solid boundaries was realized by introducing the bounce backcondition at the channel walls. In addition, for simulating a infinite domain in one or two dimen-sions, periodic boundary conditions were used.

The no-slip condition for viscous fluids states that at a solid boundary, the fluid will have a zerovelocity relative to the wall. In terms of the LBM this is taken care for by the so called bounce-backmethod:

fα(xi, t+ δt) = fα(xi, t), (2.18)

where fα(xi, t) denotes the number of particles heading in direction eα towards the boundary afterthe collision step and fα(xi, t+ δt) refers to the same amount of particles that were bounced backinto the opposite direction eα.

At an inflow cell xinflow the constant velocity u′ is given and the particle distributions pointinginto the domain are calculated by:

fα(xinflow, t+ δt) = ωαρ[1 +3c2

(eα · u′) +9

2c4(eα · u′)2 − 3

2c2u′2], (2.19)

where ρ is assumed to be equal to 1.0 at the inflow. Similarly, the outflow cells are handeld.

With periodic boundary conditions, for boundary cells, the neighboring cells are on the oppositeboundary. For example, in a channel flow setup particle distributions pointing outside the domainare relocated to enter again at oppositing boundary.

fα(xstart, t+ δt) = fα(xend, t). (2.20)

Here xend denotes an boundary cell, with eα pointing outside the computational domain. Thisparticle distribution is assigned to enter the computational domain at position xstart keeping theoriginal direction, now pointing inside.

5

Page 11: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 3

Theory

In this chapter the mathematical background describing the mass transport problem is provided. Atfirst, the different terms composing the general transport equation are outlined and a dimensionlessmeasure, relating the convection of a flow to its diffusion rate, is introduced. Further, required con-centration measures in the field of chemical species transport are given and the emerging equationsare presented. Finally the physical mechanism of diffusion is explained and two different modelsdescribing the diffusion flux for the single-fluid approach are introduced.

3.1 General scalar transport equation

Most transport processes in nature can be modeled by the general scalar transport equation, whichis a second-order partial differential equation (PDE) governing the temporal and spatial variation ofa transported quantity Φ. Like any other differential equation the general scalar transport equationexpresses a certain conservation principle.

The general scalar transport equation in Cartesian coordinates reads:

∂ρΦ∂t︸︷︷︸I

+∇ρuΦ︸ ︷︷ ︸II

−∇(ΓΦ∇Φ)︸ ︷︷ ︸III

= qΦ︸︷︷︸IV

, (3.1)

where Φ is the conserved variable being transported.

The fundamental terms can be described by:

Term I : transient term, liable for the temporal variation in the control volumeTerm II : convective term, accounts for the transport of Φ due to an existing velocity fieldTerm III : diffusive term, describes the transport of Φ due to its gradientTerm IV : source term, allows for sources or sinks of Φ

The transport equation is composed from different types of PDE’s. In order to classify thesetypes, the general formulation of a linear PDE with constant coefficients is considered. In a twodimensional space the equation reads:

A∂2Φ∂x2

+B∂2Φ∂x∂y

+ C∂2Φ∂y2

+D∂Φ∂x

+ E∂Φ∂y

+ FΦ +G = 0 (3.2)

The equation is said to be

elliptic for B2 − 4AC < 0parabolic for B2 − 4AC = 0hyperbolic for B2 − 4AC > 0

(3.3)

Detailed information concering the classification of partial differential equations can be found in[6]. In most engineering situations, the equation reveals mixed behavior, with the diffusion termstending to bring in elliptic influences, while the transient and convection terms exert parabolic or

6

Page 12: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

hyperbolic influences. In the absence of a dissipative term, the equation is considered as hyperbolic.Whereas, if smoothing due to diffusion is present, the PDE is said to be of parabolic type. In factthe character of a PDE for a given system may depend on the location in the system.For the different characters of the transport equation the dimensionless Peclet number provides aviable measure. It is defined by the quotient of the rate of convection over the rate of diffusion.

Pe =uL

Γ, (3.4)

where u is the positive velocity along a coordinate axis, L is a characteristic length scale and Γ isthe diffusivity. For Pe� 1, diffusion is dominant and information spreads out faster in all spatialdimensions than it moves downstream. In case of vanishing convection, i.e. Pe = 0, the equationcollapses to the parabolic diffusion equation. For Pe � 1 the convection is dominant and theinformation is mainly transported in flow direction.By taking the momentum to be the variable transported, one is able to recover the well-knownNavier-Stokes equations, already stated in Eq. (2.2). Another application of the general scalartransport equation is the mass transport equation for a chemical species, which will be discussedin the following.

3.2 Species transport equation

In chemical engineering applications frequently mathematical models, describing the physical trans-port processes of multicomponent mixtures, are the subject of interest. For the most part, thesemixtures contain three or more chemical species. Hence, the species transport equation has toreproduce the molecular and convective transport processes of each individual species within agiven physical system. To do this basically two units of measurement are used, depending on theapplication. When chemical reactions are under consideration, the equation is written in molarunits. Whereas, if the transport equation is solved with respect to the mass conservation, usuallymass based quantities are utilized. Introducing some standard measures necessary for specifying achemical species k:

• mass of species mk

• control volume V

• molar mass Mk

• velocity of species uk

And the mass based concentration measures are given by:

• mass concentration βi = mi

V

• mixture mass density ρt =∑ni=1 βi

• mass fraction ζi = βi

ρt, hence

∑ni=1 ζi = 1

• mass average velocity v =∑ni=1 ζiui

In a multicomponent mixture, the various chemical species are moving with different velocities ukand without chemical reactions, the species mass may be considered as a conserved quantity. Thus,the transport equation for a species k reads:

∂βk∂t

+∇(βkuk) = 0 (3.5)

Depending on the number of physical dimensions dim, additional equations have to be provided forthe unknown uk. If n is the number of species, this results in system of n × (1 + dim) equationsto be solved. Modeling a multispecies flow by means of the previous equation is called multi-fluidapproach. The number of equations required to model a multicomponent mixture can be decreasedby introducing the mass diffusion flux.

jk = βk(uk − v) (3.6)

7

Page 13: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Rearranging Eq. (3.6) and inserting the expression into Eq. (3.5) results in:

∂βk∂t

+∇(βkv) = −∇jk (3.7)

If some suitable expression for jk is provided, this leads to a system of N + dim equations andis called single-fluid approach. The closure of the diffusion flux is achieved by phenomenologicalcorrelations, like Fick’s first law or the Maxwell-Stefan relations, which will be discussed in Sec.(3.3). A further simplification can be obtained by neglecting the divergence of the average velocity,thus Eq. (3.7) transforms to:

∂βk∂t

+ v · ∇(βk) = −∇jk (3.8)

In this case the mixture components are treated as a single homogeneous fluid and consequentlythe dynamics of a single species is described only be tracing the corresponding concentration fora given velocity field. This strategy is called the passive-scalar approach. Rewriting Eq. (3.8) interms of the mass fraction yields:

ρt

(∂ζk∂t

+ v · ∇ζk)

= −∇jk (3.9)

As already mentioned mixtures are described by molar or mass based units of measurements. Gen-erally, both notations are equivalent. But for the closure of the diffusive flux there is a fundamentaldifference. While the derivation of Fick’s Law of diffusion is still possible in both notations, this isnot the case in terms of the Maxwell-Stefan relations. The latter is based on a balancing betweena driving force and the friction among the number of different molecules in the mixture. Hence,molar quantities are required to derive the equations. The molar units of measure are:

• molar concentration ci = βiMi

• mixture molar concentration ct =∑ni=1 ci

• mole fraction χi = ci

ct, hence

∑ni=1 χi = 1

• molar average velocity u =∑ni=1 χiui

• molar diffusion flux J i = ci(ui − u)

The transport equation written in terms molar quantities yields:

ct

(∂χi∂t

+ u · ∇χi)

= −∇ · J i (3.10)

Assuming the absence of chemical reactions within the considered volume, the following relationshold:

n∑i=1

ji = 0 (3.11)

n∑i=1

J i = 0 (3.12)

Above equations state, that only n − 1 of the n diffusion fluxes are independent and therefore Jncan be eliminated by:

Jn = −J1 − J2 − . . .− Jn−1

= −n−1∑i=1

J i (3.13)

The same relation can be used to replace the mass diffusion flux jn.

8

Page 14: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

3.3 Modeling the diffusion flux

Diffusion is the movement of molecules from an area of high concentration to an area of low con-centration until a uniform distribution of the molecules is reached. The mechanism of diffusion israndom molecular motion, called ”Brownian motion”. The diffusion flux can be expressed as therelative velocity difference between the species individual velocity and the average mixture velocity,already stated in Eq. (3.6). In contrast to the multi-fluid approach for the single-fluid approachthe individual species velocities remain unknown and therefore it is inevitable to provide a phe-nomenological model for the diffusive flux. Formally, the driving force for the diffusion flux of aspecies is the gradient of the chemical potential. For nearly ideal mixtures the chemical potentialcan be approximated by the concentration gradient of a species. This approximation will be usedto derive the expressions for the diffusion models below.

3.3.1 Fick’s first law of diffusion

The derivation is done using a mass based notation and refers to one presented in [5]. Here, a boxor control volume, initially divided into two parts, is considered. Each part of the box has a heightand depth of δy = δz = 1 and a width of length δx. Initially, the left side of the control volumeis filled exclusively with yellow molecules of type 1. The right part of the box is filled with bluemolecules of type 2, demonstrated in Fig. (3.1). Since the control volume has unit height, the areaA perpendicular to the direction of the diffusion is one unit square. All molecules in the box are

x

z

y

Figure 3.1: Initial configuration of molecules in control volume

subjected to random motion. The probability of a molecule passing through A will be denoted as kand is proportional to the molecules random motion and to the average number of molecules nearthe surface. Let ml

1 be the total mass of molecules 1 on the left side of the control volume and mr1

equal the mass in the right half. The amount of mass transferred from left to right during a timeinterval δt is equal to kml

1, while the amount transferred from right to left during the same periodis kmr

1. The mass flux from left to right across A is equal to (kml1 − kmr

1) divided by δt and canbe expressed by:

j1 =k

δt(ml

1 −mr1) (3.14)

In order to write the mass flux in terms of concentrations, the mass of the molecules is divided bythe volume:

βl1 =ml

1

δx · δy · δz(3.15)

9

Page 15: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Since the height and depth are both equal to one, previous equation collapses to:

βl1 =ml

1

δx(3.16)

The same holds true for the mass concentration of the blue molecules and therefore:

βr1 =mr

1

δx(3.17)

Replacing the mass in Eq. (3.14) by (β · δx) yields:

j1 = kδt (β

l1δx− βr1δx) (3.18)

=(kδt

)δx(βl1 − βr1) (3.19)

Furthermore, let βl1 and βr1 be the average mass concentrations defined at the center of each partof the control volume. Separated by a distance δx, their coordinates are x and x+ δx respectively.Inserting this in Eq. (3.18) leads to:

j1 =(k

δt

)δx (β1(x)− β1(x+ δx)) (3.20)

By applying a first order Taylor series approximation, the difference in the mass concentration atx and x+ δx can be written as the product of the concentration gradient ∂β

∂x and the distance δx.

limδx→0

(β(x+ δx)− β(x))δx

= −∂β∂x, (3.21)

As a result, the net flux is given by

j1 = −(k

δt

)(δx)2 ∂β1

∂x. (3.22)

The value of(kδt

)(δx)2 is generally prescribed for each pair of species, it is called binary diffusion

coefficient D. It is proportional to the velocity of the diffusing particles, which depends on thetemperature, viscosity of the fluid and the size of the particles according to the Stokes-Einsteinrelation. Therefore it can be assumed to be constant in the volume under consideration. Formolecules of type 1 Fick’s first law of diffusion reads:

j1 = −D12∂β1

∂x(3.23)

Written in terms of molar quantities results in, Eq. (3.23) becomes:

J1 = −ctD12∂χ1

∂x(3.24)

If the diffusion flux is derived with respect to the molecules of type 2, this results in:

J2 = −ctD21∂χ2

∂x(3.25)

Using the relation stated in Eq. (3.11) for the binary mixture yields:

n∑i=1

ji = j1 + j2 = 0 (3.26)

and with the mass fraction β1 + β2 summing up to 1, it can be shown that there is only oneindependent flux and only one diffusion coefficient:

D12 = D21 = D (3.27)

10

Page 16: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Therefore, the indices of the binary diffusion coefficient can be dropped. Inserting this constitutiverelation for the closure of the diffusion flux into Eq. (3.10) yields:

ct

(∂χi∂t

+ u · ∇χi)

= −ctD∆χi, (3.28)

where Eq. (3.28) represents the final equation that is to be solved for the simulation of a binarymixture. When mixtures containing three or more species are under consideration, the applicationof Fick’s law is restricted to only a few limiting cases, like the solvent case, see Sec. (6.3). Acomponent of a mixture is called solvent, if its concentration is predominant in comparison withthe other components. In this case Fick’s law accounts for the interaction between the solvent andthe solute only, since the dissolved species do not encounter other molecules than the one of thesolvent. Whereas, if all species are present in a comparable amount, the interactions between allthe involved species must be accounted for. This is addressed by the Maxwell-Stefan relations,introduced below.

3.3.2 Maxwell-Stefan

The basic idea of the Maxwell-Stefan formulation can be pictured as a dynamic equilibrium betweenthe tendency of a component to diffuse in the direction of decreasing concentration driven by theconcentration gradient and the tendency of the component to be forced in the reverse direction byinterference with the other diffusing components in the mixture. This interference is proportionalto the total number of molecules present in the control volume and to the amount of momentumthat is transferred among the molecules in each collision. Hence, the momentum transfer due tomolecular collisions between several species may be regarded as frictional force. For reasons ofsimplicity, the derivation of the Maxwell-Stefan relations will be conducted for a binary system andrefers to the one presented in [16]. Afterwards an extension for the treatment of a multicomponentmixture will be introduced using a matrix formulation. The balance between friction and driving

m1u1

m2

u2

Figure 3.2: Illustration of inter-species frictional drag

force can be expressed as proportional relation, which reads:

driving force ∝ ( momentum exchanged in each collision × number of collisions ) (3.29)

The occurrence of collisions between species 1 and 2 depends on the number of species 1 moleculesc1 = ctχ1 and species 2 molecules c2 = ctχ2 present in the control volume. Therefore, the collisionrate is proportional to the product of the mole fractions χ1χ2.

To determine the amount of momentum exchanged during a collision, the molecules are consid-ered as rigid bodies and the collision is assumed to be elastic. Hence, the conservation of linearmomentum requires that:

m1(u1 − u′1) = −m2(u2 − u′2), (3.30)

11

Page 17: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

where u′1 and u′2 are the velocities after collision. The average amount of momentum exchangedby a single collision equals:

4momentum =m1m2(u1 − u2)

m1 +m2(3.31)

The forces acting on the control volume are distinguished between surface and body forces. Pressuregradients or shear stresses because of velocity gradients are called surface forces, whereas gravityor electrical fields are denoted as body forces. For reasons of simplicity, only the pressure actingon the control volume will be considered to derive an expression for the driving force d1, causingmolecules of species 1 to diffuse through the control volume. Further, the control volume is assumedto rest under isobaric conditions. Hence, there is no net force due to a pressure difference actingon the mixture as a whole, i.e. PA|x = PA|x+δx. In Fig. (3.3), the initial distribution of moleculesis illustrated. Due to the non-uniform distribution, there is a difference in the partial pressure. Forspecies 1 the partial pressure at position x is p1 = Pχ1|x and at x+ δx the partial pressure equals−Pχ1|x+δx. If the difference in partial pressure is multiplied by A, the driving force d1 follows as:

d 1 d 2A A

x

Figure 3.3: Exemplary distribution of yellow particles driven by d1 and blue particles by d2

d1 = A(p1|x − p1|x+δx) (3.32)

The previous equation is divided by the volume V = Aδx.

d1

V=

(p1|x − p1|x+δx)δx

(3.33)

Further, the difference in partial pressure at x and x + δx can be written as the product of thedistance δx and the gradient of the partial pressure.

d1

V= limδx→0

(p1|x − p1|x+δx)δx

= −∂p1

∂x(3.34)

Expanding Eq. (3.34) to all spatial dimensions yields:

d1

V= −∇p1 (3.35)

Now, the relation stated in Eq. (3.29) can be transformed into an equation by introducing aproportionality coefficient f12:

∇p1 = −f12χ1χ2(u1 − u2), (3.36)

12

Page 18: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

where ∇p1 is the driving force moving molecules of species 1 through the molecules of species 2 andf12 acts as a drag coefficient. Under the assumption of isobaric pressure, the previous equation canbe divided by the total pressure:

∇χ1 = −χ1χ2(u1 − u2)D12

, (3.37)

where D12 = P/f12 is called the Maxwell-Stefan binary diffusion coefficient. In terms of species 2Eq. (3.37) reads:

∇χ2 = −χ1χ2(u2 − u1)D21

(3.38)

Since ∇χ1 +∇χ2 = 0 it follows that Maxwell-Stefan binary diffusion coefficients are symmetric, i.e.D12 = D21. The reformulation of Eq. (3.37) in terms of the molar diffusion flux leads to:

∇χ1 = − (χ1J2 − χ2J1)ctD12

. (3.39)

Using Eq. (3.12) and the property χ1 + χ2 = 1 for the flux formulation yields:

∇χ1 = − (χ1J2 − χ2J1)ctD12

(3.40)

= −J11

ctD12(3.41)

J1 = −ctD12∇χ1 (3.42)

Eq. (3.42) proofs that for a binary system the Maxwell-Stefan formulation reduces to an expressionequivalent to Fick’s Law with D12 = D. According to the results of kinetic theory the Maxwell-Stefan binary diffusion coefficients depend on the molecular weights of the considered species, onthe total pressure and temperature, see [8]. In the following the extension of the equations for thetreatment of multicomponent mixtures is provided.

Matrix formulation Due to Eq. (3.12) only n − 1 fluxes J i are independent in a n speciesmixture. For a multicomponent mixture Eq. (3.39) may be written as:

ct∇χi = −BiiJ i −n∑

k=1j 6=i

BijJ j , (3.43)

where the coefficients Bii and Bij are defined by:

Bii =χiDin

+n∑

k=1i6=k

χkDij

(3.44)

Bij(i 6=j) = −χi(

1Dij− 1Din

)(3.45)

Writting Eq. (3.44) and Eq. (3.45) in n− 1 dimensional matrix form yields:

ct(∇χ) = − [B] (J), (3.46)

where [B] is the binary Maxwell-Stefan diffusion resistance matrix of order n− 1.

[B] ≡

B11 B21 B31 · · · B1,n−1

B21 B22 B23 · · · B2,n−1

......

Bn−1,1 Bn−1,2 Bn−1,3 · · · Bn−1,n−1

(3.47)

13

Page 19: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

with elements given by Eq. (3.44) and Eq. (3.45). The column matrix (J) is

(J) ≡

J1

J2

...Jn−1

(3.48)

and (∇χ) is a column matrix of order n− 1 defined by

(∇χ) ≡

∇χ1

∇χ2...

∇χn−1

(3.49)

Multiplying Eq. (3.46) by the inverse of [B], the equation simplifies to:

(J) = −ct [B]−1 (∇χ) (3.50)

Eq. (3.50) is used for the determination of the diffusive fluxes. If the inverse of [B] is denoted by[E], then the resulting system of equation for a n species mixture can be written as:

ct

(∂χi∂t

+ u∇χi)

= ct

n−1∑j=1

∇[E]i,j∇χj

for i ∈ [1, ..., (n− 1)] (3.51)

ct

(∂χn∂t

+ u∇χn)

= −ct

n−1∑i=1

n−1∑j=1

∇[E]i,j∇χj

(3.52)

Here, Eq. (3.51) denotes the transport equation for (n − 1) species and Eq. (3.52) represents thelinear dependent species. An example of the calculus for a ternary mixture is provided in Sec.(4.3) as part of the discretization procedure. As can be seen, the diffusive flux depends on theconcentration gradients of all species present in the mixture. Therefore, the transport equation cannot be solved for a single species individually. Instead a coupled system of equations, composed byall species, has to be solved.

14

Page 20: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 4

Discretization using the finitedifference method

The finite difference scheme (FD) is a popular technique for constructing discrete approximationsfor partial differential equations (PDE). The continuous simulation domain is replaced by a discretegrid, which approximates the solution of the PDE at a finite number of nodes. By relating a gridpoint to the neighboring points, the continuous derivatives of the PDE are substituted by localdifference quotients. The deviation between the continuous derivative and the corresponding finitedifference expression is called local truncation error τ , which depends on the distance h betweenneighboring grid points. By analyzing the discrete expression the error is expected to behaveasymptotically proportional to hm, where m depends on the form of the difference operator. Afinite difference scheme can be derived by means of a Taylor series expansion around grid point xi.Assuming an equidistant grid, the expressions for Φi±1 at node xi±1 result in:

Φi+1 = Φi + h1!∂Φ∂x

∣∣∣∣i

+ h2

2!∂2Φ∂x2

∣∣∣∣i

+ h3

3!∂3Φ∂x3

∣∣∣∣i

+ . . . (4.1)

Φi−1 = Φi − h1!∂Φ∂x

∣∣∣∣i

+ h2

2!∂2Φ∂x2

∣∣∣∣i

− h3

3!∂3Φ∂x3

∣∣∣∣i

+ . . . , (4.2)

after subtracting Eq. (4.2) from (4.1) and rearranging the remaining terms, it is possible to formu-late the central difference scheme (CDS):

δxΦi =Φi+1 − Φi−1

2h+(−h

2

3!∂3Φ∂x3|i + . . .

)︸ ︷︷ ︸

τ=O(h2)

, (4.3)

where δx denotes the operator of the CDS applied to Φ at grid node xi. The accuracy of thisapproximation is of order O(h2). This means by reducing the stepsize h by a factor of two, thelocal truncation error would drop by a factor of four. Analogous to the derivation of the CDS, finitedifference schemes can be obtained for higher derivatives. Substituting all continuous derivativesby difference operators, the partial differential equation transforms to a system of equations, whichcan be computed using direct or iterative solution procedures, for further information see [4].

4.1 Temporal discretization

Similar to the finite difference approximations of spatial derivatives, difference operators for thetime derivative can be constructed. For this thesis, the Crank-Nicolson (CN) has been used todiscretize the transient term. The method is based on the trapezoidal rule in time, leading to atemporal accuracy of O(δt2). As an example, the Crank-Nicolson method is presented for a onedimensional convection-diffusion equation of the form

∂Φ∂t

= F

(Φ, x, t,

∂Φ∂x

,∂2Φ∂x2

), (4.4)

15

Page 21: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

where F denotes the finite difference operators for the spatial derivatives. The left hand side of Eq.(4.4) is replaced by Φn+1−Φn

δt and the right hand side is assumed to be evaluated at an arbitrarytime step ϑ, which has to fullfill tn < ϑ < tn+1. This time step can be adjusted by introducing aparameter µ, to interpolate between the time levels tn and tn+1. With that Eq. (4.4) becomes:

Φn+1 = Φn +[(1− µ)F

(Φn, x, tn,

∂Φn

∂x,∂2Φn

∂x2

)+ µF

(Φn+1, x, tn+1,

∂Φn+1

∂x,∂2Φn+1

∂x2

)]δt,

(4.5)where the CN method is achieved for µ = 1

2 . For µ = 0 the forward Euler scheme can be obtained,whereas µ = 1 leads to the backward Euler time integration. If µ 6= 0 the presented time dis-cretization results in an implicit scheme. Hence, to advance in time an implicit system of equationshas to be solved. For reasons of simplicity, the semi-discretized operator

[∂Φ∂t

]is introduced. This

operator represents a simplified notation of the time differencing scheme, given in Eq. (4.5). Usingthis notation, the distinction between the time levels is immanently assumed for F . By means of avon Neumann stability analysis it can be shown, that the CN method is unconditionally stable, see[4]. Therefore, only the so called Courant-Friedrich-Lewy condition limits the size of the time step.

CFL =uδt

h, CFL < 1 (4.6)

For a convection-diffusion equation this condition states, that for each grid point the physicaldomain of dependence must be contained in the numerical domain of dependence.

4.2 Formulations based on Fick’s law

When Fick’s Law is applied to model the diffusive flux, the numerical treatment is simplified. Sincethe diffusivity neither depends on the local species concentration nor on the state of other speciesin the mixture, it is regarded as a constant. Furthermore, the resulting equations are uncoupled.This is contrary to the numerical scheme emerging from the Maxwell-Stefan formulation. Thus, itis possible to solve the transport equation for each species individually.

4.2.1 First order spatial discretization

The numerical scheme presented below has been adopted from [12]. It demonstrates a first ap-proach for the discretization of the transport equation and can be regarded as the basis for furtherextensions like higher spatial accuracy or the implementation of the Maxwell-Stefan relations.

Convective part

A straightforward approach to discretize the convection term could be the usage of a central differ-ence scheme, as presented in Eq. (4.3). Despite its second order spatial accuracy, the deficiency ofthis method is its limited stability, demonstrated in [4]. When the region of stability is exceeded,numerical oscillations may occur. Reasons for this are possible discontinuities or shocks in the flowvariables, as well as convection dominated flow, i.e. Pe � 1. In order to circumvent this problemone-sided difference operators, so called upwind schemes, can be used. Here, depending on theflow direction backward differencing schemes (BDS) or forward differencing schemes (FDS) of O(h)spatial accuracy are applied.

δ−x Φi =Φi − Φi−1

h(4.7)

δ+x Φi =

Φi+1 − Φih

(4.8)

For a flow in positive x-direction the BDS would be adopted and vice versa. With that, informationis only transported in downstream direction, which mimics the hyperbolic character of convection.Constructing a method which can be applied, regardless of the flow direction, leads to the Donor-Cell scheme (DCS), presentend in [12]. In this case, the velocities kl at xi+ 1

2and kr at point xi− 1

2

are computed by linear interpolation, demonstrated in Fig. (4.1) and depending on the sign of kland kr the proper upstream point is determined.

16

Page 22: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

ui ui1ui−1 k l k r

Interpolation Interpolation

Figure 4.1: kl is interpolated at position i− 12 and kr at position i+ 1

2

kr =ui + ui+1

2, kl =

ui−1 + ui2

(4.9)

δ±x Φi =krΦr − klΦl

h, (4.10)

where Φr and Φl are chosen according to kr and kl:

Φr =

{Φi kr > 0Φi+1 kr < 0

, Φl =

{Φi−1 kl > 0Φi kl < 0

. (4.11)

Written without case distinction, the Donor-Cell scheme reads:

δ±x Φi =1

2h(kr(Φi + Φi+1)− kl(Φi−1 + Φi) + |kr|(Φi − Φi+1)− |kl|(Φi−1 − Φi)) (4.12)

To recover most of the accuracy of the CDS and to keep the stability of the (DCS), a hybrid schemeis used to approximate the convective term. Written for two spatial dimensions, the hybrid schemereads:

δ±x Φi,j = kr(Φi,j+Φi+1,j)−kl(Φi−1,j+Φi,j)2h + γ

|kr|(Φi,j−Φi+1,j)−|kl|(Φi−1,j−Φi,j)2h (4.13)

δ±y Φi,j = kt(Φi,j+Φi,j+1)−kb(Φi,j−1+Φi,j)2h + γ

|kt|(Φi,j−Φi,j+1)−|kb|(Φi,j−1−Φi,j)2h (4.14)

where 0 ≤ γ ≤ 1 is the weighting factor selecting between central and upwind differencing. Theinterpolated velocities in y-direction are given by:

kt =vj + vj+1

2, kb =

vj−1 + vj2

(4.15)

For γ = 0 the CDS is recovered and for γ = 1 the pure DCS is obtained, where the value of γ canbe estimated by:

γ ≥ maxi,j

(|uijδth|, |vijδt

h|)

(4.16)

Diffusive part

The derivation of a finite difference operator for the second derivative can be done by adding Eq.(4.1) to (4.2). With that, the first derivative cancels out and by rearranging the remaining termsit follows:

δ2xΦi =

Φi−1 − 2Φi + Φi+1

h2, (4.17)

which has a truncation error of O(h2). For the y-dimension the difference operator reads:

δ2yΦj =

Φj−1 − 2Φj + Φj+1

h2(4.18)

17

Page 23: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Discrete transport equation

On a two dimensional domain, the spatially discretized transport equation reads:[∂Φ∂t

]+ (ui,jδx + vi,jδy)Φi,j = D(δ2

x + δ2y)Φi,j (4.19)

where[∂Φ∂t

]represents the semi-discretized transient term. By inserting the time discretization

scheme, provided in sec. (4.1), the discrete transport equation transforms to:

Φn+1ij − Φnij

δt= [(1− µ)(−ui,jδ±x − vi,jδ±y +Dδ2

x +Dδ2y)Φnij

+µ(−ui,jδ±x − vi,jδ±y +Dδ2x +Dδ2

y)Φn+1ij ] (4.20)

Rearranging previous equation to separate the different time levels yields:

Φn+1ij − δt[µ(−ui,jδ±x − vi,jδ±y +Dδ2

x +Dδ2y)Φn+1

ij ] = Φnij + δt[(1− µ)(−ui,jδ±x − vi,jδ±y +Dδ2x +Dδ2

y)Φnij ]

The present differencing scheme for the convective term can introduce a significant amount ofnumerical diffusion. That is due to the local truncation error of O(h). An example for this can befound in [4]. Therefore also a higher order scheme was considered.

4.2.2 High Order Compact scheme for the transport equation

The High Order Compact (HOC) scheme denotes a class of finite difference formulations which canexceed second order spatial accuracy, while still maintaining a compact stencil. That means, theresulting difference operator depends only on neighboring grid points. For the derivation of theHOC scheme, first only the steady state convection-diffusion equation in two dimensions will beconsidered, as presented in [17]. The discretization of the transient term is introduced after thespatial discretization.

uδΦδx

+ vδΦδy−D

(∂2Φ∂x2

+∂2Φ∂y2

)= s, (4.21)

where s may contain sources or sinks. With the assumption of D > 0 and ∇D = 0, the equationcan be divided by the diffusivity D. Hence, the velocities u and v are rewritten as η = u

D andκ = v

D , while the source term becomes g = sD and Eq. (4.21) can be written as:

ηδΦδx

+ κδΦδy−(∂2Φ∂x2

+∂2Φ∂y2

)= g (4.22)

By replacing the first and second derivatives with the corresponding central differencing schemes,Eq. (4.22) becomes:

ηi,jδxΦi,j + κi,jδyΦi,j − δ2xΦi,j − δ2

yΦi,j − τi,j = gi,j . (4.23)

So far the scheme is of order O(h2) and the local truncation error is:

τi,j =[h2

12

(2η∂3Φ∂x3

+ 2κ∂3Φ∂y3

− ∂4Φ∂x4

− ∂4Φ∂y4

)]i,j

+O(h4) (4.24)

The increase in accuracy is obtained by approximating each derivative of the leading term of Eq.(4.24) and including them in the discrete equation. Relations for the derivatives of third and fourthorder can be constructed by differentiating the PDE in Eq. (4.21). For example the derivative ∂3Φ

∂x3

is considered. Differentiating Eq. (4.22) in x-direction yields:

∂3Φ∂x3

= − ∂3Φ∂x∂y2

+ η∂2Φ∂x2

+∂η

∂x

∂Φ∂x

+ κ∂2Φ∂x∂y

+∂κ

∂x

∂Φ∂x− ∂g

∂x(4.25)

The terms of the right hand side are replaced by suitable central difference approximations. There-fore Eq. (4.25) becomes:

∂3Φ∂x3

=[−δxδ2

y + ηi,jδ2x + δxηi,jδx + κi,jδxδy + δxκi,jδy

]Φi,j − δxgi,j +O(h2) (4.26)

18

Page 24: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Similar approximations for the other derivatives in Eq. (4.24) can be found in [17]. Thus, re-placing the derivatives in Eq. (4.24) by approximations of second order accuracy and subsequentsubstitution for τij in Eq. (4.23) yields a O(h4) formulation of the steady state convection-diffusionequation as:

−ai,jδ2xΦi,j−bi,jδ

2yΦi,j+Ci,jδxΦi,j+Di,jδyΦi,j−

h2

6[δ2xδ

2y − ηi,jδxδ2

y − κi,jδ2xδy − ci,jδxδy

]Φi,j = Gi,j ,

(4.27)where the coefficients are given by:

ai,j = 1 +h2

12(η2i,j − 2δxηi,j

)(4.28)

bi,j = 1 +h2

12(κ2i,j − 2δydi, j

)(4.29)

ci,j = δyηi,j − ηi,jκi,j + δxκi,j (4.30)

Ci,j = ηi,j +h2

12(δ2xηi,j − ηi,jδxηi,j − κi,jδyηi,j + δ2

yηi,j)

(4.31)

Di,j = κi,j +h2

12(δ2xκi,j − ηi,jδxκi,j − κi,jδyκi,j + δ2

yκi,j)

(4.32)

Gi,j = gi,j +h2

12(δ2xgi,j − ηi,jδxgi,j − κi,jδygi,j + δ2

ygi,j)

(4.33)

here, δx and δy represent the central difference scheme approximations of the first derivatives inx-dim and y-dim respectively. The difference operators for the cross-derivatives are of the form:

δxδyΦi,j :=Φi−1,j−1 − Φi+1,j−1 + Φi+1,j+1 − Φi−1,j+1

4h2(4.34)

δ2xδyΦi,j :=

Φi,j−1 − Φi,j+1

h3+−Φi−1,j−1 − Φi+1,j−1 + Φi+1,j+1 + Φi−1,j+1

2h3(4.35)

δxδ2yΦi,j :=

Φi−1,j − Φi+1,j

h3+−Φi−1,j−1 + Φi+1,j−1 + Φi+1,j+1 − Φi−1,j+1

2h3(4.36)

δ2xδ

2yΦi,j :=

4Φi,j − 2 (Φi−1,j + Φi+1,j + Φi,j−1 + Φi,j+1)h4

(4.37)

+Φi−1,j−1 + Φi+1,j−1 + Φi+1,j+1 + Φi−1,j+1

h4(4.38)

The transient term is introduced by substituting the right hand side of Eq. (4.21) with:

gi,j =1D

(si,j −

[∂Φ∂t

]i,j

), (4.39)

and by disregarding sources or sinks in the domain si,j = 0. For more information regarding themodification of the HOC scheme to evolutionary problems, see [19]. Again, the time discretizationscheme is adopted from sec. (4.1). Thus the equation, discretized in time and space, reads:

1D

[1 +

h2

12(δ2x − ηi,jδx − κi,jδy + δ2

y

)] [∂Φ∂t

]i,j

−ai,jδ2xΦi,j − bi,jδ

2yΦi,j + Ci,jδxΦi,j + Di,jδyΦi,j

−h2

6[δ2xδ

2y − ηi,jδxδ2

y − κi,jδ2xδy − ci,jδxδy

]Φi,j = 0 (4.40)

In contrast to Eq. (4.20), Eq. (4.40) represents an implicit system of equations, regardless ofthe value of µ. Furthermore, the coefficient matrix arising from the HOC discretization is notdiagonally dominant and as a result iterative methods such as successive over-relaxation (SOR)can not be used. In order to solve the system of equations the BiCGSTAB method is applied. Inorder to simplify the implementation of the HOC scheme, it makes sense to rewrite Eq. (4.40) in afactorized form, as presented in [10].

1∑k1=−1

1∑k2=−1

lhsi+k1,j+k2Φn+1i+k1,j+k2

=1∑

k1=−1

1∑k2=−1

rhsi+k1,j+k2Φni+k1,j+k2 , (4.41)

19

Page 25: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

where the coefficients of the left hand side are defined by:

lhsi+k1,j+k2 = 12µpi+k1,j+k2 + qi+k1,j+k2 (4.42)

and the coefficients for the right hand side are of the form:

rhsi+k1,j+k2 = 12(µ− 1)pi+k1,j+k2 + qi+k1,j+k2 (4.43)

Here, especially the lhs entries are of importance, as they are required to construct the coefficientmatrix for the iterative solver. The coefficients p and q for a grid point ij are given by:

SW : pi−1,j−1 = δt(− 1

6h2 − ηi,jh12h −

κi,jh12h + ci,j

24

); qi−1,j−1 = 0

SE : pi+1,j−1 = δt(− 1

6h2 + ηi,jh12h −

κi,jh12h −

ci,j

24

); qi+1,j−1 = 0

NW : pi−1,j+1 = δt(− 1

6h2 − ηi,jh12h + κi,jh

12h −ci,j

24

); qi−1,j+1 = 0

NE : pi+1,j+1 = δt(− 1

6h2 + ηi,jh12h + κi,jh

12h + ci,j

24

); qi+1,j+1 = 0

S : pi,j−1 = δt(

13h2 + κi,j

6h −bi,j

h2 − Di,j

2h

); qi,j−1 = 1

D

(1 + κi,jh

2

)N : pi,j+1 = δt

(1

3h2 − κi,j

6h −bi,j

h2 + Di,j

2h

); qi,j+1 = 1

D

(1− κi,jh

2

)E : pi+1,j = δt

(1

3h2 − ηi,j

6h −ai,j

h2 + Ci,j

2h

); qi+1,j = 1

D

(1− ηi,jh

2

)W : pi−1,j = δt

(1

3h2 + ηi,j

6h −ai,j

h2 − Ci,j

2h

); qi−1,j = 1

D

(1 + ηi,jh

2

)C : pi,j = δt

(− 2

3h2 + 2ai,j

h2 + 2bi,j

h2

); qi,j = 8

D

(4.44)

As already mentioned, the adsorption of the diffusivity is accompanied with the condition of anon-vanishing and spatially constant diffusivity. Hence, the HOC scheme presented above can notbe applied to the Maxwell-Stefan formulation without fundamental modifications.

4.3 Formulation based on the Maxwell-Stefan relations

The mathematical model describing the Maxwell-Stefan relations significantly differs from the for-mulation based on Fick’s Law. The main difference arises due to the fact that the diffusion fluxlocally depends on all species concentrations and on their gradients. From this, the non-linearityof the diffusive term and the coupling between the species transport equations results. In order toconsistently simulate a multispecies mixture, any numerical scheme must account for that. Firstthe Maxwell-Stefan relations are discretized by means of the first order discretization presented inSec. (4.2.1). The necessary modifications and extensions are pointed out in Sec. (4.3.1). Secondly,an attempt was made to adopt the HOC scheme to the Maxwell-Stefan model. The derivation ofthe HOC scheme is applied to the Maxwell-Stefan relations and the arising mathematical difficultiesare explained.

4.3.1 First order discretization

The Maxwell-Stefan relations do not affect the convective part of the transport equations and,therefore, the discretization scheme can be adopted from Sec. (4.2.1). Whereas, the differenceoperators given in Eq. (4.17) and Eq. (4.18) can not be applied, since the discretization of theMaxwell-Stefan relation results in a variable diffusivity for each grid point. This has to be accountedfor by introducing a suitable finite difference operator for the second derivative. Furthermore, thedistribution of the diffusivity coefficients may not be assumed to be smooth. Especially in thebeginning of an experiment, there may be large gradients of the species concentration. Thereforethe difference operator will interpolate an average diffusivity coefficient for two neighboring gridpoints. The difference operator for the gradient of the molar diffusion flux ∇J will be developedbelow.

20

Page 26: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Non-linear diffusion operator

For a generic transported value Φ and a dependent diffusion coefficient Γ(Φ), the second derivativein a two dimensional space reads:

∇(Γ∇Φ) =∂

∂x

(Γ∂Φ∂x

)+

∂y

(Γ∂Φ∂y

)(4.45)

Since Γ is a scalar function of Φ, its distribution can be non-uniform. As mentioned above, theremay be discontinuities in this distribution of the diffusion coefficients. To compensate for this aninterpolation of Γ is employed, as demonstrated in Fig. (4.2). This resembles a finite volumeapproach. For the x-dimension the interpolation rules are given by:

Γi+ 12 ,j

= Γi+1,j+Γi,j

2 (4.46)

Γi− 12 ,j

= Γi−1,j+Γi,j

2 (4.47)

Thus the difference operator results in:

δx(ΓδxΦ)i,j :=Γi− 1

2 ,jΦi−1,j − (Γi− 1

2 ,j+ Γi+ 1

2 ,j)Φi + Γi+ 1

2 ,jΦi+1,j

h2, (4.48)

and the differencing scheme for the y-dimension reads:

δy(ΓδyΦ)i,j :=Γi,j− 1

2Φi,j−1 − (Γi,j− 1

2+ Γi,j+ 1

2)Φi,j + Γi,j+ 1

2Φi,j+1

h2(4.49)

For this derivation the variable diffusivity coefficient Γ was assumed to be a scalar value. In order to

i

i i1i−1

i1 i−1

i−12

i12

Figure 4.2: The average diffusion coefficient is interpolated from neighboring grid points

apply this difference operator to the Maxwell-Stefan formulation, Γ is replaced by specific elementsof the inverted binary Maxwell-Stefan diffusion resistance matrix. This matrix is depending on allspecies in the mixture.

Application to Maxwell-Stefan

For demonstration purposes the discretization will be explained using a ternary mixture. As a firststep the binary Maxwell-Stefan diffusion resistance matrix is calculated according to Eq. (3.44) andEq. (3.45) for every grid point. The diffusion coefficients, required in Eq. (3.51) and Eq. (3.52), areobtained by inverting the matrix [B]. For a ternary mixture the binary Maxwell-Stefan diffusionresistance matrix at position ij is defined by:

[B]i,j =

χ(1)i,j

D13+

χ(2)i,j

D12+

χ(3)i,j

D13−χ(1)

i,j

(1D12− 1

D13

)−χ(2)

i,j

(1D21− 1

D23

(2)i,j

D23+

χ(1)i,j

D21+

χ(3)i,j

D23

, (4.50)

where the subscript indices i, j represents the spatial position and the superscript (k) typifies theconsidered species k. The inverse of [B] will be denoted as [E]. In order to explain the applicationof the non-linear difference operator to the MS formulation, the gradient of the diffusion flux forthe first species is considered. For the sake of clarity the gradient of the diffusion flux will bestated in detail only for the x-direction. From the right hand side of Eq. (3.51) it can be seen,

21

Page 27: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

that the gradient of the diffusion flux is the sum of the contributions from species 1 and species 2.Furthermore, the equation reveals which element of [E] corresponds to which species contribution.The gradient of species 1 is associated with element [E]1,1 and the gradient of species 2 correspondsto [E]1,2. Consequently, the gradient of the diffusion flux for species 1 reads:

δx([E](1,l)δxχ(l))∣∣(1)

l∈{1,2} =1h2

([E](1,1)

i−1,j + [E](1,1)i,j

2

(1)i−1,j

− 1h2

[([E](1,1)

i−1,j + [E](1,1)i,j

2

)+

([E](1,1)

i+1,j + [E](1,1)i,j

2

)]χ

(1)i,j

+1h2

([E](1,1)

i+1,j + [E](1,1)i,j

2

(1)i+1,j

+1h2

([E](1,2)

i−1,j + [E](1,2)i,j

2

(2)i−1,j

− 1h2

[([E](1,2)

i−1,j + [E](1,2)i,j

2

)+

([E](1,2)

i+1,j + [E](1,2)i,j

2

)]χ

(2)i,j

+1h2

([E](1,2)

i+1,j + [E](1,2)i,j

2

(2)i+1,j (4.51)

For the y-direction δy([E]δyχ(1)) is obtained by replacing species concentration gradients and theinterpolation of [E] in x-direction with the corresponding expressions in y-direction. For the secondspecies the formulations are determined equivalently. The gradient of the diffusion flux of the thirdspecies is expressed as an linear combination of the first two species, given by:

δx(J (3)) = −δx([E]δxχ(1))− δx([E]δxχ(2)) (4.52)δy(J (3)) = −δy([E]δyχ(1))− δy([E]δyχ(2)) (4.53)

Discrete transport equation

The discretization scheme for the transient term is again adopted from Sec. (4.1) and writtenin semi-discretized formulation. Hence, the finite difference approximation of Eq. (3.51) and Eq.(3.52) for a three component mixture reads:[

∂χ(1)

∂t

]+ (ui,jδx + vi,jδy)χ(1)

i,j = δx([E]δxχ(1)) + δy([E]δyχ(1)) (4.54)[∂χ(2)

∂t

]+ (ui,jδx + vi,jδy)χ(2)

i,j = δx([E]δxχ(2)) + δy([E]δyχ(2)) (4.55)[∂χ(3)

∂t

]+ (ui,jδx + vi,jδy)χ(3)

i,j = −δx([E]δxχ(1))− δx([E]δxχ(2))

−δy([E]δyχ(1))− δy([E]δyχ(2)) (4.56)

4.3.2 An attempt to apply the HOC scheme to Maxwell-Stefan

Under the presence of convection, finite difference schemes of first order accuracy suffer from signifi-cant numerical diffusion. The fact becomes even more disadvantageous, if one is to compare differentdiffusion models, like in the present thesis. Therefore, one goal of this thesis was to simulate theMaxwell-Stefan formulation using a higher order differencing scheme. But when the attempt wasmade to discretize the Maxwell-Stefan using the HOC scheme, the mathematical problems arisingcould not be solved within this thesis. The starting point of the derivation is a simplified form ofthe generic transport equation, which reads:

uδΦδx

+ vδΦδy− ∂

∂x

(Γ∂Φ∂x

)− ∂

∂y

(Γ∂Φ∂y

)= s, (4.57)

22

Page 28: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

where Γ denotes the diffusivity depending on Φ. According to the derivation of the HOC scheme,the derivatives are replaced by central difference operators. Consequently, Eq. (4.57) becomes:

ui,jδxΦi,j + vi,jδyΦi,j − δxΓi,jδxΦi,j − δyΓi,jδyΦi,j − τi,j = si,j (4.58)

In contrast to the derivation conducted for the Fickian formulation of the species transport equa-tion, here the truncation error can not be determined. Because the distribution of Γ may not beassumed to be smooth, as a consequence the Taylor series expansion can not be applied to obtainan expression for the local truncation error. So the standard derivation procedure of the HOCscheme is not transferable to the Maxwell-Stefan formulation. However, a possibility to achievehigher spatial accuracy could be to drop the concept of compact differencing schemes and try todiscretize the Maxwell-Stefan relations using non-compact ones. Even the transition from finitedifferencing schemes to finite volume methods sounds promising.

23

Page 29: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 5

Implementation

The implementation is based upon the waLBerla framework (widely applicable Lattice Boltzmannalgorithm from Erlangen) [3], developed at the Chair of System Simulation. From this project thebasic datalayout has been adopted. All field variables are implemented based on two or higher di-mensional arrays. For instance, the species concentration is stored in a 2-dimensional array, whereasthe inverse of the binary Maxwell-Stefan diffusion resistance matrix requires a 4-dimensional array.The Lattice Boltzmann method is solving the flow problem and the resulting velocity distributionis regarded as the average mixture velocity. This velocity is necessary to solve the species transportequation with the single-fluid approach. In order to reduce the implementational effort, only rectan-gular domains with periodic boundary conditions (BC) are considered for the species distributions.In the beginning of this chapter, some general remarks concerning the data layout, the speciesaccess function and the time loop will be given. Subsequently, the basic computation procedure tosolve the species transport equation is pointed out. For reasons of simplicity, the implementationwill be explained by means of the first order accuracy scheme using Fick’s Law (FoFi). Next, thenecessary modifications for Higher Order Compact scheme are addressed. Finally, the extensionsfor the simulation of the Maxwell-Stefan model are discussed.

5.1 General remarks

The required simulation parameters are provided by means of an input file. During initializationthe input file is evaluated and the parameters are transferred to a SimData struct. This structprovides all required input variables during runtime. The data structure for the Lattice Boltzmannmethod is realized by introducing the PDFField, where nine particle distribution functions arestored for each node. Due to the dependencies in the stream step two PDFField have been used.The resulting velocities in x- and y-direction are assigned to a VelField. For each species presentin the mixture a SpeciesField is created, providing scalar variables for the species mole fractionsin the computational domain. In case of the Fick’s Law with a first order accuracy one additionalSpeciesField is created to contain the right hand side. The implementation of the HOC schemerequires two vectors and a matrix to solve the linear system of equations (LSE). If the Maxwell-Stefan relations is chosen to calculate the diffusion flux, additionally a SquareMatrixField iscreated. This field contains the inverted binary Maxwell-Stefan diffusion resistance matrix for eachgrid point.

Data access

The local data dependencies of the implemented discretization schemes can be pictured as 5-pointstencil and 9-point stencil respectively. The 5-point stencil results from the O(h) discretization,whereas the 9-point stencil arises from the HOC scheme. The idea of a stencil based data access istransferred to the species load operation. For a given grid point at position i and j this functionprovides the possibility to address the surrounding grid points by means of an access direction.Thus, the data access during the solution of the transport equation is simplified. Additionally,this Get function also accounts for the boundary conditions. For instance, if a point on the eastboundary tries to access its eastern neighbor, the Get function returns the value of the point on

24

Page 30: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

the west boundary, due to the periodic boundary conditions. With that, the periodicity of thecomputational domain is realized. In Fig. (5.1) an example of the 5-point stencil (blue) at position[3,3] and the 9-point stencil (yellow) at position [8,3] is provided. Here, the 9-point stencil servesalso as an example for the boundary access.

j

i

C EW

S

N

SW

NW NE

SE

C EW

S

N

81 2 3 4 5 71

2

3

4

5

5-point stencil: Get(3,3,acdir)

Access direction C N S E WReturn Value Φ3,3 Φ3,4 Φ3,2 Φ4,3 Φ2,3

9-point stencil: Get(8,3,acdir)

Access direction C N S E W NW NE SW SEReturn Value Φ8,3 Φ8,4 Φ8,2 Φ1,3 Φ7,3 Φ7,4 Φ1,4 Φ7,2 Φ1,2

Figure 5.1: Return values of the Get function for the 5-point stencil at an interior point and for the9-point stencil at the right boundary

Main loop

After initialization the simulation starts by entering the time loop. In the beginning of each timestep the boundary conditions for the LBM are imposed. Thereafter the PDF’s are streamed fromthe source grid to the destination grid, where the velocity distribution is computed and written tothe VelField. Subsequently the particle collision is performed. At the end of a time step, the twogrids are swaped and the procedure is repeated. The species transport equations are solved afterthe LBM collision step. Depending on the chosen mixture model, the transport equations are solvedsequentially or as a coupled system using iterative techniques. In order to visualize the velocity fieldand the evolution of the species distribution, the WriteVisualizationOutput function supportsfile formats, that can be evaluated with xmgrace or ParaView.

25

Page 31: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Algorithm 5.1 Main LoopInitialization();

for(int t=0; t<sim.timesteps; ++t){

// Boundary Treatement for LBMBoundaryTreatementLBM();

// Stream StepStreamStep();

// Collision StepCollisionStep();

// Choose mixture model and solve transport equationsif(sim.mixture model){

SolveSingleSpeciesTransportEquation();}else{

SolveCoupledSystem();}

// Swap LBM gridsSwapLBMGrids();

// Write data visualization outputWriteVisualizationOutput();

}// End timeloop

5.2 Solving the species transport equation

Resulting from the discretization procedure, the species transport equation transforms into linearsystem of equations of the form Ax = b. In principal this LSE is solved by all three implementationsof the species transport equation. Whereas size and structure of the system significantly differs,depending on the chosen mixture model and the spatial discretization.

5.2.1 Implementation of Fick’s Law with first order accuracy

A simplified version of the procedure is presented in Alg. (5.2). For reasons of clarity, some partsof the code are shortened. For instance, instead of listing the five load operations for the 5-pointstencil explicitly, they are replaced by a comment. First, the current weighting factor for thehybrid Donor-Cell scheme is computed by CalculateDCSweighting(). This function traverses thespatial domain in order to find the current maximal velocity in the domain. Once this is done,the weighting factor is calculated by Eq. (4.16). In the following loop, all species of the mixtureare sequentially processed. In order to calculate the right hand side of the linear system, a spatialloop is performed. For the current grid point the local species concentrations are loaded. Similar,the velocities are accessed and the interpolated velocities for the Donor-Cell scheme are computed.Finally, the pseudo-function CalcRhs() denotes the computation according to the right side of Eq.(4.21). The result is stored in an auxiliary SpeciesField. Thereafter, the linear system of equationis solved by means of a successive over-relaxation method (SOR), see [15]. Once the solution reachesa given convergence criterion, the solver stops and the next species is processed.

26

Page 32: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Algorithm 5.2 Species transport equation of first order accuracySolveTransportEqFirstOrder(){

Real CC,CN,CE,CS,CW; // ConcentrationsReal UC,UE,UW,VC,VN,VS; // VelocitiesReal kr,kl,kt,kb; // DCS paramtersReal gamma = CalcDCSweighting(); // DCS weightingReal tmp=0;for(Uint cs=0;cs<sim.ns;++cs) { // Loop over mixture components

for(Uint i=1;i<=sim.Nx;++i){ // Spatial loop for right hand sidefor(Uint j=1;j<=sim.Ny;++j){

// Get Species Concentrations at i,j for CC,CN,CE,CS,CW// Get Velocities at i,j for UC,UE,UW,VC,VN,VE// Calculate Average Velocity kr,kl,kt,kbtmp=CalcRhs();species[sim.ns].Set(i,j,tmp); // Store rhs in auxiliary field}}Real pointres,sumres;for(Uint it=0;it<maxiterations;++it){ // Solve linear system using SOR

sumres=0; pointres=0;for(Uint i=1;i<=sim.Nx;++i){

for(Uint j=1;j<=sim.Ny;++j){pointres=0;// Get Species Concentrations at i,j for CC,CN,CE,CS,CW// Get Velocities at i,j for UC,UE,UW,VC,VN,VE// Calculate Average Velocity kr,kl,kt,kbtmp = SORkernel();species[cs].Set(i,j,tmp);// Calculate Residualpointres=CalcPointRes();sumres+=pointres*pointres;}}sumres=sqrt(sumres/(sim.Nx*sim.Ny));if(sumres<epsilon)break;}}}

27

Page 33: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

5.2.2 Higher order compact scheme

The HOC scheme results in a 9-point stencil and basically this is the only difference to the implemen-tation discussed in Sec. (5.2.1). Though analysis conducted in [17] reveals that, under the presenceof convection, the coefficient matrix, resulting from the HOC scheme, is not diagonal dominant.This fact prohibits the use of iterative solvers like the SOR method. Therefore, the BiCGSTABmethod is applied as proposed by [10] and in addition a diagonal preconditioning is done. In con-trast to the SOR, this iterative method requires the explicit formulation of the coefficient matrixA. An implementation of the BiCGSTAB method is contained in the iterative methods libraryIML++, see [1]. This library requires the matrix to be formulated as a sparse matrix. Therefore,additionally the sparse matrix library SparseLib++ is included to provide an implementation ofsparse matrices, see [2] for further information. Hence, also the solution and the right hand sidehave to be formulated in terms of vectors. A peculiarity of the SparseLib++ matrix implementation

A =

1 2 0 0 34 5 6 0 00 7 8 0 90 0 0 10 011 0 0 0 12

Coord_Matval() 1 2 3 4 5 6 7 8 9 10 11 12

rowind() 0 0 0 1 1 1 2 2 2 3 4 4colind() 0 1 4 0 1 2 1 2 4 3 0 4

CompRow_Matrowind() 0 3 6 9 10 12 - - - - - -

val() 1 2 3 4 5 6 7 8 9 10 11 12colind() 0 1 4 0 1 2 1 2 4 3 0 4

Figure 5.2: Illustration of a simple matrix and the corresponding setup vectors in coordinate andcompressed row storage format

complicates the setup process. It is not possible to introduce an additional non-zero entry, oncethe matrix is created. Thus, the exact position of all entries must be computed in advance andstored in setup vectors. Theses contain the values of the coefficients, their rows as well as theircorresponding column indices. The determination of the exact column indices for the coefficientsis a challenging part, since their location in the matrix must be in accordance with the periodicboundary condition. In order to keep the transition function as simple as possible, the coefficientmatrix is created using the coordinate storage format Coord_Mat, provided by SparseLib++. Thisformat represents a straightforward way to express a sparse matrix in terms of a vector notation.Figure (5.2) illustrates a simple matrix and the three required setup vectors to construct a matrixin the coordinate storage format and compressed row storage format CompRow_Mat. Subsequentlythe Coord_Mat is converted into the CompRow_Mat storage format, which is mandatory to create thediagonal preconditioning matrix. Thereafter, the linear system of equations can be solved.

Matrix setup

The transfer from the grid based data layout to the matrix-vector based formulation is realized bymeans of the AddNonZeroEntryHOC function, partly stated in Alg. (5.3). For a given grid pointthe function is invoked for every coefficient of the 9-point stencil. The coefficient’s position in thematrix is defined by its grid position and the access direction. The correct row index rowind()depends on i, j and on the number of grid points in x-direction Nx. The central coefficient is placedon the diagonal of the matrix, and therefore the column index colind() equals the row index. Theother coefficients of the stencil are positioned by adding or subtracting an offset relative to thediagonal entry. This combination of base index and relative offset is also used to determine theplacement of the coefficients in the setup vectors, where the nine coefficients of a grid point arestored consecutively. The vector base index vb depends on the current row of the matrix, while

28

Page 34: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

the offset is prescribed by the access direction. The effect of the periodic boundary conditions onthe structure of the matrix is illustrated in Fig. (5.3). Here, a grid point on the right edge of thecomputational domain is considered and the resulting matrix entries are presented. Except for theaccess to east directions, the positions of the coefficients are analogous to an interior grid point. Asshown in Fig. (5.1), the east neighbor of a point at (Nx, j) is, according to the periodic BC’s, thepoint at (1, j). Due to the sequential alignment of the solution vector, the corresponding offset is ofsize (−Nx + 1). Similarly, the offsets for the access in north east and south east direction become+1 and (−2Nx + 1) respectively.

row = (Nx-1)+(j-1)*Nx

C EW

S

N

SW

NW NE

SE

NS NWSE SW

N x−N x−1

E CW NE

−2⋅N x1

N x

col = row

Figure 5.3: Relative matrix offsets for an grid point at the right boundary

Solution procedure

In the beginning of Alg. (5.4) the required variables for the species concentration and the velocitiesare declared. The chosen iterative method requires the right hand side as well as the solution tobe written in vector notation. Therefore, two vectors of size (Nx · Ny) are created. To allocatethe memory for the matrix setup vectors, the number of non-zero entries in the matrix must bedetermined. Due to the stencil of the HOC scheme there are nine non-zero entries in each row.This results in total of (Nx ×Ny × 9) non-zero entries in the matrix.Even though the derivation of the HOC scheme is a complex task, thanks to the factorized formu-lation of the LSE, the implementation turns out to be a lot more comprehensible. This notation iseven more advantageous, since it provides the possibility to calculate the rhs and the lhs coefficientsconcurrently. First the required concentrations and velocities are loaded. The parameters p and qare determined, according to Eq. (4.44). With this parameters at hand, the rhs coefficients, givenin Eq. (4.43), are calculated. Subsequently, they are multiplied by the corresponding species con-centrations. The sum over all these products finally results in the value of the rhs for a grid pointi, j. The matrix coefficients result from Eq. (4.42) and are written to the storage vectors. Afterthe spatial loop has finished, the sparse matrix is created. The preconditioning matrix is computedand finally the BiCGSTAB solver is invoked. Once the solution has converged, it is written backto the grid and the next species is processed.

29

Page 35: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Algorithm 5.3 AddNonZeroEntry function for the HOC schemeint AddNonZeroEntryHOC(Real* val,int* colind,int* rowind,

Uint i,Uint j,Uint acdir,Real tmp){//Access directions C N S W E NW NE SW SEint soffset[ ]={0, sim.Nx, −sim.Nx, −1, 1, sim.Nx−1, sim.Nx+1, −sim.Nx−1, −sim.Nx+1};int voffset[ ]={0, 1, 2, 3, 4, 5, 6, 7, 8};int MatRow=(i−1) + (j−1)*sim.Nx;int di=MatRow; // Diagonal indexint vb=MatRow*9; // Vector base indexval[vb + voffset[acdir] ] = tmp ;rowind[ vb + voffset[acdir] ]=MatRow;// Determine the corresponing columnif(acdir==C){

colind[ vb + voffset[acdir] ]=MatRow; return 0;}// Boundary treatement. . .if( i==sim.Nx ){// Right edge of domain

switch (acdir){

case W: colind[ vb + voffset[acdir] ]= di+soffset[W]; return 0;case E: colind[ vb + voffset[acdir] ]= di − sim.Nx + 1; return 0;case NW: colind[ vb + voffset[acdir] ]= di+soffset[NW]; return 0;case N: colind[ vb + voffset[acdir] ]= di+soffset[N]; return 0;case NE: colind[ vb + voffset[acdir] ]= di + 1; return 0;case SW: colind[ vb + voffset[acdir] ]= di+soffset[SW]; return 0;case S: colind[ vb + voffset[acdir] ]= di+soffset[S]; return 0;case SE: colind[ vb + voffset[acdir] ]= di − 2*sim.Nx + 1; return 0;}}. . .// Interior pointscolind[ vb + voffset[acdir] ]=di + soffset[acdir]; return 0;

}

30

Page 36: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Algorithm 5.4 Species transport equation of fourth order accuracySolveHOC(){

Real CC,CN,CE,CS,CW,CNE,CNW,CSE,CSW; // ConcentrationsReal UC,UE,UW,UN,US,VC,VE,VW,VN,VS; // VelocitiesReal tmp=0;for(Uint cs=0;cs<sim.ns;++cs) { // Loop over mixture components

VECTOR double b(sim.Nx*sim.Ny,0.0);VECTOR double x(sim.Nx*sim.Ny, 0.0);

Real val[sim.Ny*sim.Nx*9];int rowind[sim.Ny*sim.Nx*9];int colind[sim.Ny*sim.Nx*9];

for(Uint i=1;i<=sim.Nx;++i){for(Uint j=1;j<=sim.Ny;++j){

// Get Species Concentrations at i,j for CC,CN,CE,CS,CW,CNE,CNW,CSE,CSW

// Get Velocities at i,j for UC,UE,UW,UN,US,VC,VE,VW,VN,VS divided by diffusivity

// Calculate p and q at i,j for directions C,N,E,S,W,NE,NW,SE,SW

Real rhs c,rhs n,rhs s,rhs e,rhs w,rhs ne,rhs nw,rhs se,rhs sw;//Calculate rhs values for directions C,N,E,S,W,NE,NW,SE,SW

tmp = rhs sw*CSW + rhs s*CS + rhs se*CSE + rhs w*CW + rhs c*CC+ rhs e*CE + rhs nw*CNW + rhs n*CN + rhs ne*CNE;

b[(i−1)+ (j−1)*sim.Nx]=tmp;Real lhs c,lhs n,lhs s,lhs e,lhs w,lhs ne,lhs nw,lhs se,lhs sw;// Calculate lhs coefficients for directions C,N,E,S,W,NE,NW,SE,SW

// Add non zero entries to setup vectors}}//Create matrixCoord Mat double preA(sim.Ny*sim.Nx,sim.Ny*sim.Nx,sim.Ny*sim.Nx*9,val,rowind,colind);CompRow Mat double A(preA); // Convert preA to CRS format, required for preconditionerReal tol=sim .epsilon; Uint iterations=sim .maxiterationsVECTOR double x(sim.Nx*sim.Ny, 0.0);DiagPreconditioner double D(A);BiCGSTAB(A, x, b, D, iterations, tol); // Solve system of equationsfor(Uint i=1;i<=sim.Nx;++i){

for(Uint j=1;j<=sim.Ny;++j){tmp=x[(i−1)+ (j−1)*sim.Nx];species[cs].Set(i,j,tmp);}}}}

31

Page 37: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

5.2.3 Implementation of the Maxwell-Stefan formulation

The matrix resulting from the coupled system of equation (CSE), stated in Eq. (3.51) and Eq.(3.52), can be characterized by different blocks interconnecting the species diffusion flux. Eachblock has a size of (Nx · Ny × Nx · Ny). For a mixture containing ns species, the CSE is of size(ns · Nx · Ny × ns · Nx · Ny) and contains 5 · Nx · Ny(ns + (ns − 1)2) non-zero entries. The maindiagonal blocks of the CSE matrix include the transient and convective parts for each species. Anillustration if the CSE matrix for a ternary mixture is provided in Fig.(5.4).

0 [1,11

i , j1

N x , N y

1 ][1,12

i , j2

N x , N y

2 ][1,13

i , j3

N x , N y

3 ]

⋯S⋯ W C E ⋯N⋯ ⋯S⋯W C E⋯N⋯

⋯S⋯W C E⋯N⋯

⋯S⋯W C E⋯N⋯⋯S⋯W C E⋯N⋯

0

[rhs1,1

1

rhs i , j1

rhsN x , N y

1 ][rhs1,1

2

rhs i , j2

rhsN x , N y

2 ][rhs1,1

3

rhs i , j3

rhsN x , N y

3 ]

⋯S⋯ W C E ⋯N⋯

⋯S⋯ W C E ⋯N⋯

Figure 5.4: Illustration of the coupled system of equations for a ternary mixture. The letters withoverbar denote the coefficients, which additionally contain the transient and convective parts of thetransport equation

Matrix setup

The AddNonZeroEntryMS function adopts the same principle to determine the coefficients position,like the one implemented for the HOC scheme. Once the position of the stencil’s center is calculated,the final position of the coefficients is determined by means of the access direction. Accounting forthe block structure, the row index is now calculated depending on the spatial position and thecurrent species cs, whereas the correct column index requires the interconnecting species ic instead.Mentioned above, the functional blocks of the CSE matrix represent the individual species. Theperiodic boundary conditions are imposed within these individual blocks. An example for thisis given in Fig. (5.5) on behalf of a ternary mixture. Here, the assembly of one matrix row isdescribed, which results from the transport equation of species 2. Due to the periodic BCs, theeastern coefficient is shifted to the left by (Nx − 1), thus, it is located next to south coefficient.Further, the number of non-zero entries depends on the row of the matrix. For the first (ns − 1)species, the number of non zero entries in each row is (ns− 1) · 5. Whereas the last species dependson the diffusive flux of all the other species, therefore the rows in the matrix contain ns · 5 entries.Due to this the correct index for the setup vectors, i.e. vb, needs to be calculated with respect tothe values of i, j, cs and ic.

32

Page 38: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Algorithm 5.5 AddNonZeroEntry function for the CSE matrixint AddNonZeroEntryMS(Real* val,int* colind,int* rowind,

Uint cs, Uint ic,Uint i,Uint j,Uint acdir,Real tmp){//Access Directions C N S W Eint soffset[ ] = {0, sim.Nx, −sim.Nx, −1, 1};int voffset[ ] = {0 , 1 , 2 , 3, 4};int vb; // Vector base indexint MatRow,MatCol;MatRow=(i−1) + (j−1)*sim.Nx + cs*sim.Nx*sim.Ny;MatCol=ic*(sim.Nx*sim.Ny) + (i−1) + (j−1)*sim.Nx;int vcsoffset=cs*(sim.ns−1)*sim.Nx*sim.Ny*5; // Vector offset to csint vicoffset=ic*5; // Vector offset to ic// Vector spatial offset, accounts for different number of non-zero entriesint vspoffset;if( cs != (sim.ns−1) ){

vspoffset=( (i−1) + (j−1)*sim.Nx )*(sim.ns−1)*5;}else{

vspoffset=( (i−1) + (j−1)*sim.Nx )*sim.ns*5;}vb=vcsoffset + vicoffset + vspoffset;val[vb + voffset[acdir] ] = tmp ;rowind[ vb + voffset[acdir] ]=MatRow;// Determine the corresponing columnif(acdir==C){

colind[ vb + voffset[acdir] ]=MatCol; return 0;}// Boundary treatement. . .if( i==sim.Nx ){// Right edge of domain

switch (acdir){

case W: colind[ vb + voffset[acdir] ]=MatCol+soffset[W]; return 0;case E: colind[ vb + voffset[acdir] ]=MatCol − sim.Nx + 1; return 0;case N: colind[ vb + voffset[acdir] ]=MatCol+soffset[N]; return 0;case S: colind[ vb + voffset[acdir] ]=MatCol+soffset[S]; return 0;}}. . .// Interior pointscolind[ vb + voffset[acdir] ]=MatCol + soffset[acdir]; return 0;

}

33

Page 39: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

C EW

S

N

C EW

S

N

CE W NS

CE W NS

species 1 species 2

row = (Nx-1)+(j-1)*Nx + Nx*Ny

col = (Nx-1)+(j-1)*Nx

col = Nx*Ny + (Nx-1)+(j-1)*Nx1

N x−N x−1

Figure 5.5: Incorporation of periodic boundary conditions in terms of matrix notation

Solution procedure

Since the discretization scheme for the convective term is adopted from Sec. (5.2.1), the weight-ing factor for the DCS scheme is determined first. Thereafter, the spatial domain is traversed tocalculate the binary Maxwell-Stefan diffusion resistance matrix [B] for each grid point. The corre-sponding formulas are given in Eq. (3.44) and Eq. (3.45). In the scope of this thesis only a moderatenumber of mixture components were under consideration and as a consequence the resulting diffu-sion resistance matrices are rather small. Due to this reason a direct method, based on the singularvalue decomposition (SVD), was chosen to invert the diffusion resistance matrices. This methodallows for inverting matrices, even if they have high condition numbers. The algorithm for the SVDhas been adopted from [20] and was slightly modified to suit the present data structure. Once thematrix is inverted, it is stored to the SquareMatrixField and the next grid point is processed untilall matrices are inverted.The calculation of the right hand side can be distinguished between the part concerning the (ns−1)species and the linear dependent one, which may also be called solvent species. For each grid pointthe contributions resulting from the transient and convective part are determined. An additionalloop over the (ns−1) species serves to calculate the gradient of the diffusion flux (GDF), analogousto Eq. (4.51). The sum of these three contributions are stored in the right hand side vector. In caseof the solvent species, again the transient and convective contributions are computed. Thereafter,the GDF’s from the (ns− 1) species are added, according to the right hand side of Eq. (3.52).The computation of the left hand side is also realized by two parts. In the first one the coefficientsfor the (ns− 1) species are determined. For the species cs, the spatial domain is traversed and bymeans of a loop over (ns − 1) species, the contributions to the GDF resulting from the intercon-necting species are calculated and subsequently assigned to the CSE. In case of cs == ic, i.e. on adiagonal block of the CSE matrix, the transient and convective parts are included as well. Again,the second part accounts for the solvent species. Inside a loop over all species the spatial domain istraversed once more. At this point the linear dependent GDF of the solvent is determined and theresulting coefficients are written to the CSE matrix. What is left are the transient and convectiveparts. If cs equals ic, they are assignend to the matrix.Once the setup vectors are complete, the sparse matrix is created. Like in the HOC scheme thesystem is solved by means of the BiCGSTAB method. After the solution has converged, it is writtenback to the grid and the next time step can be processed. The corresponding source code for theimplementation of the Maxwell-Stefan relations is listed in Alg. 5.6 and Alg. 5.7. For reasons ofclarity, recurring instructions are replaced by macros, which are defined beforehand.

34

Page 40: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Algorithm 5.6 Maxwell-Stefan implementation for the computation of the right hand side#define TIMECONVPART CC+sim.dt*(1−sim.mu)*(−(1/(2*sim.dx)*(kr*(CC+CE)−kl*(CW+CC)) \

+ gamma/(2*sim.dx)*(fabs(kr)*(CC−CE) − fabs(kl)*(CW−CC))) \− ( 1/(2*sim.dx)*(kn*(CC+CN) − ks*(CS+CC)) \+ gamma/(2*sim.dx)*(fabs(kn)*(CC−CN)− fabs(ks)*(CS−CC))))

#define CALCAVGE(row,col) E l=(msbfield.Get(i,j,W,row,col) + msbfield.Get(i,j,C,row,col))/2.0;\E r=(msbfield.Get(i,j,E,row,col) + msbfield.Get(i,j,C,row,col))/2.0;\E t=(msbfield.Get(i,j,N,row,col) + msbfield.Get(i,j,C,row,col))/2.0;\E b=(msbfield.Get(i,j,S,row,col) + msbfield.Get(i,j,C,row,col))/2.0;

#define ADDNONZEROENTRIES AddNonZeroEntryMS(val,colind,rowind,cs,ic,i,j,C,centralco); \AddNonZeroEntryMS(val,colind,rowind,cs,ic,i,j,N,northco); \AddNonZeroEntryMS(val,colind,rowind,cs,ic,i,j,S,southco); \AddNonZeroEntryMS(val,colind,rowind,cs,ic,i,j,W,westco); \AddNonZeroEntryMS(val,colind,rowind,cs,ic,i,j,E,eastco);

#define CALCGDF sim.dt*(1−sim.mu)*(( (E l*CW − (E l+E r)*CC + E r*CE) \+ (E t*CN − (E t+E b)*CC + E b*CS))/(sim.dx*sim.dx));

SolveCoupledSysEq(){Real CC,CN,CE,CS,CW; // ConcentrationsReal UC,UE,UW,VC,VN,VS; // VelocitiesReal kr,kl,kt,kb; // DCS paramtersReal gamma = CalcDCSweighting(); // DCS weightingReal E l,E r,E t,E b; // Inverse of BReal tmp=0;for(Uint i=1;i<=sim.Nx;++i){

for(Uint j=1;j<=sim.Ny;++j){// Calculate diffusion resistance matrix for i,jCalcInv(); // Invert B// Write Inverse to SquareMatrixField

} }VECTOR double b( sim.ns * sim.Nx * sim.Ny); // Create rhs vector for IML++for(Uint cs=0;cs<sim.ns−1;++cs) { // Calculate rhs for ns-1 species

for(Uint i=1;i<=sim.Nx;++i){for(Uint j=1;j<=sim.Ny;++j){

// Get Species Concentrations at i,j for cs// Get Velocities at i,j for UC,UE,UW,VC,VN,VE// Calculate Average Velocity kr,kl,kt,kbtmp=TIMECONVPART;for(Uint ic=0;ic<sim.ns−1;ic++){ // Interconnecting species

// Get Species Concentrations at i,j for icCALCAVGE(cs,ic)tmp +=CALCGDF}b[(i−1)+ (j−1)*sim.Nx + cs*sim.Nx*sim.Ny]=tmp;

} } }Uint cs = sim.ns−1;for(Uint i=1;i<=sim.Nx;++i){ // Calculate rhs for solvent

for(Uint j=1;j<=sim.Ny;++j){// Get Species Concentrations at i,j for CC,CN,CE,CS,CW// Get Velocities at i,j for UC,UE,UW,VC,VN,VE// Calculate Average Velocity kr,kl,kt,kbtmp=TIMECONVPART;for(Uint ic=0;ic<sim.ns−1;ic++){

// Get Species Concentrations at i,j for icfor(Uint row=0;row<sim.ns−1;row++){

CALCAVGE(row,ic)tmp −=CALCGDF

} }b[(i−1)+ (j−1)*sim.Nx + cs*sim.Nx*sim.Ny]=tmp;

} }

35

Page 41: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Algorithm 5.7 Maxwell-Stefan implementation of the lhsint num nonzeros =(sim.ns−1)*sim.Ny*sim.Nx*(sim.ns−1)*5 + sim.Ny*sim.Nx*sim.ns*5;Real val[num nonzeros]; // Create setup vectorsint rowind[num nonzeros];int colind[num nonzeros];Real centralco,eastco,westco,northco,southco;for(Uint cs=0;cs<sim.ns−1;++cs) { // Calc matrix coefficients for ns-1 species

for(Uint i=1;i<=sim.Nx;++i){for(Uint j=1;j<=sim.Ny;++j){

for(Uint ic=0;ic<sim.ns−1;ic++){CALCAVGE(cs,ic)eastco = sim.dt*sim.mu*( − E r/dxsq );westco = sim.dt*sim.mu*( − E l/dxsq );northco = sim.dt*sim.mu*( − E t/dxsq );southco = sim.dt*sim.mu*( − E b/dxsq );centralco = sim.dt*sim.mu*( (E l + E r + E t + E b)/dxsq );if(cs==ic){ // Calculate transient and convective part

// Get Velocities at i,j for UC,UE,UW,VC,VN,VE// Calculate Average Velocity kr,kl,kt,kbeastco = sim.dt*sim.mu*( (kr −gamma*fabs(kr)) / (2*sim.dx) − E r/dxsq);westco = sim.dt*sim.mu*(−(kl +gamma*fabs(kl)) / (2*sim.dx) − E l/dxsq);northco = sim.dt*sim.mu*( (kn −gamma*fabs(kn)) / (2*sim.dx) − E t/dxsq);southco = sim.dt*sim.mu*(−(ks +gamma*fabs(ks)) / (2*sim.dx) − E b/dxsq);centralco = 1 + sim.dt*sim.mu*( (kr − kl + gamma*fabs(kr) + gamma*fabs(kl)

+ kn − ks + gamma*fabs(kn)+ gamma*fabs(ks ))/(2*sim.dx)

+ (E l + E r + E t + E b)/dxsq );}ADDNONZEROENTRIES

} } } }cs = sim.ns−1;for(Uint ic=0;ic<sim.ns;ic++){ // Calc matrix coefficients for solvent species

for(Uint i=1;i<=sim.Nx;++i){for(Uint j=1;j<=sim.Ny;++j){

eastco = westco = northco = southco = centralco =0;for(Uint row=0;row<sim.ns−1;row++){

CALCAVGE(row,ic)eastco += sim.dt*sim.mu*( E r/dxsq );westco += sim.dt*sim.mu*( E l/dxsq );northco += sim.dt*sim.mu*( E t/dxsq );southco += sim.dt*sim.mu*( E b/dxsq );centralco −= sim.dt*sim.mu*( (E l + E r + E t + E b)/dxsq );}if(cs==ic){

// Get Velocities at i,j for UC,UE,UW,VC,VN,VE// Calculate Average Velocity kr,kl,kt,kbeastco = sim.dt*sim.mu*( (kr−gamma*fabs(kr)) / (2*sim.dx));westco = sim.dt*sim.mu*( − (kl + gamma*fabs(kl)) / (2*sim.dx));northco = sim.dt*sim.mu*( (kn−gamma*fabs(kn)) / (2*sim.dx));southco = sim.dt*sim.mu*( −(ks + gamma*fabs(ks)) / (2*sim.dx));centralco =1 + sim.dt*sim.mu*( (kr − kl + gamma*fabs(kr) + gamma*fabs(kl)

+ kn − ks + gamma*fabs(kn)+ gamma*fabs(ks ))/(2*sim.dx));}

ADDNONZERENTRIES} } }Coord Mat double preA(sim.ns*sim.Ny*sim.Nx,sim.ns*sim.Ny*sim.Nx,num nonzeros,val,rowind,colind);CompRow Mat double A(preA); // Convert preA to CRS format, required for preconditionerReal tol=sim.epsilon; Uint iterations=sim.maxiterations;VECTOR double x(sim.ns*sim.Nx*sim.Ny, 0.0);DiagPreconditioner double D(A);BiCGSTAB(A, x, b, D, iterations, tol); // Solve CSE// Write solution back to grid

}

36

Page 42: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 6

Results

For binary mixtures the Maxwell-Stefan model (MS) reduces to an expression equivalent to Fick’slaw and consequently the resulting diffusion coefficients (DiCo) are identical, i.e. Dαβ = D. Thisproperty is used to validate the different implementations. The occurring diffusion coefficient ismeasured during the simulation and compared to the theoretical one. The theoretical Fickiandiffusion coefficients, stated in literature, are, for the most part, determined by means of binaryexperiments. Whereas, in the MS model the binary diffusivities Dαβ depend on the system pressure,the temperature and on the molecular weights of species Mα and Mβ . Assuming isothermal andisobaric conditions, an approximation to relate both coefficients is stated in [8] and reads:

D ≈ Dα,β =(

1Mα

+1Mβ

)− 12

(6.1)

This equation is utilized for the adjustment of the molecular weights to match the Fickian diffusioncoefficient for a given experiment. During simulation, the diffusion coefficient is determined byinvestigating the decay characteristics of a Gaussian. In order to create a discrete initial distributionfor the species concentrations, the probability density function is used.

f(xi) =a

σ√

2πexp

(−1

2

(xi − µσ

)2), (6.2)

where µ accounts for the displacement, σ is liable for the width of the curve and a = σ√

2π · pvis used to determine its peak value pv. The diffusivity is calculated by tracking the change of thevariance over time, according to:

D =12∂(Var)∂t

(6.3)

The variance requires the mean value, which is given by:

x =Nx∑i=1

xi · (h ·xia

) (6.4)

and consequently, the variance of the distribution results from:

Var =Nx∑i=1

(xi − x)2(h · xia

) (6.5)

For the discrete time levels, Eq. (6.3) is approximated by:

D =12

[Varn −Varn−1

δt

](6.6)

This method of measurement is used for the numerical experiments conducted in Sec. (6.1) andSec. (6.2). In the first experiment the concentration distribution is assumed to be at rest, i.e. the

37

Page 43: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

velocity field is set to zero, whereas the second one investigates the impact of convection to themeasured diffusion coefficient. For all the experiments dealing with binary mixtures the secondspecies, i.e. the solvent, is neglected in the graphs, since its distribution can be deduced from therelation χ2 = 1−χ1. The last experiment deals with a ternary mixture and demonstrates the limitsof Fick’s law, when it is applied to multispecies mixtures. This chapter is intended to examinethe principal characteristics of the implemented mixture models. For this purpose physical unitsare not of prime importance and therefore all measures will be regarded to be dimensionless in thefollowing.

6.1 Measurement of the binary diffusion coefficient

The aim of this numerical experiment is to measure the occurring DiCo during the simulation, usingthe previously explained method. For this experiment external influences, like gravity or convection,are neglected. As a start some preliminary tests are conducted to determine the parameter range, forwhich the simulation provides reliable results. Thereafter, test scenarios with different theoreticaldiffusion coefficients are created. Each scenario is simulated by all three implemented algorithmsand the values of the measured DiCo are compared to each other.

Transient behavior

To investigate the transient behavior of the diffusion coefficient an initial concentration distributionis created by means of Eq. (6.2). Fig (6.1) shows the initial distribution for the parameters µ = 1,σ = 0.06 and pv = 0.5. The 1-dimensional domain is discretized by Nx = 320 grid points and a

0 40 80 120 160Position in grid points

0

0,1

0,2

0,3

0,4

0,5

Mol

e fr

actio

n

Initial distribution

Figure 6.1: Initial concentration distribution

step size of h = 0.0125. With a discrete time interval δt = 0.001 the evolution of the test setupis simulated for 40000 time steps. Some representative time levels are presented in Fig. (6.2). Ineach time step the diffusion coefficient is calculated and stored. The behavior of the measuredDiCo over time is illustrated in Fig. (6.3). It can be seen that the diffusion coefficient keepsconstant for the first 20000 time steps. Thenceforward, the measured values start to decrease. Thisphenomena is the result of the imposed boundary conditions. When the distribution reaches theperiodic BC’s, its profile starts to differ from a Gaussian. Hence, the used formula to calculate thevariance becomes invalid and the measurement has to be aborted. This effect applies analogously toall the implemented algorithms. The problem can be circumvented by enlarging the computationaldomain or by reducing the total simulation time. Since the measured DiCo is constant right afterthe beginning of the simulation, the measurements are made after only a few time steps.

38

Page 44: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

0 40 80 120 160Position in grid points

0

0,1

0,2

0,3

0,4

0,5

Mol

e fr

actio

n

Transient behavoir

t = 0

t = 5000

t = 10000

t = 20000 t = 30000t = 40000

Figure 6.2: Transient behavior for some representative time levels

0 10000 20000 30000 40000Time step

9,80e-04

9,85e-04

9,90e-04

9,95e-04

1,00e-03

1,01e-03

1,01e-03

1,02e-03

1,02e-03

Mea

sure

d di

ffus

ion

coef

fici

ent

Measured diffusivity over time

Figure 6.3: Measured diffusivity

Influence of the spatial resolution

This test case adopts the same setup from previous experiment, except for the step size. Here,the domain is discretized by variable number of grid points. The goal is to determine the minimalnumber of points necessary to approximate the Gaussian, for which a theoretical diffusion coefficientof 0.001 is correctly reproduced in the simulation. The measurement is done after 300 time steps.It can be seen from Fig. (6.4), that the measured DiCo is quasi identical to the theoretical valueup to a number of only 30 grid points. For 20 grid points the measurement reveals a deviation inthe order of one permille. In this case, the Gaussian is approximated with 5 grid points. If the gridis even more coarsened, then the distribution is approximated by only 4 points and the deviationto the theoretical value becomes apparent. Again, this behavior is equal for all implementations.

39

Page 45: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

320160

80 40 30 20 15 10

Number of total grid points

0,0009

0,001

0,0011

0,0012

0,0013

0,0014

0,0015

Mea

sure

d di

ffus

ion

coef

fici

ent

FoFiHOCMS

Influence of the spatial resolution

Figure 6.4: Measured diffusivity over a set of stepsizes

Parameter study for a set of diffusion coefficients

The goal of this experiment is to determine the range of diffusion coefficients, that are correctlyreproduced by the three different codes. For this test setup the Gaussian initial distribution as wellas the computational domain are adopted from the experiment concering the transient behavior.The theoretical values for the DiCo cover a interval ranging from 10−9 to 1. In this thesis most ofthe numerical experiments are conducted for diffusion coefficients in the order of 10−4 up to D = 1,thus, this range is examined more precisely. For the Maxwell-Stefan model these coefficients areconverted to the corresponding molecular weights using Eq. (6.1), where one species is assumed tohave a molecular weight of M = 1.1. The test scenarios are performed by all three implemented

1e-10 1e-09 1e-08 1e-07 1e-06 1e-05 0,0001 0,001 0,01 0,1 1theoretical D

1e-10

1e-09

1e-08

1e-07

1e-06

1e-05

0,0001

0,001

0,01

0,1

1

mea

sure

d D

1e-10 1e-09 1e-08 1e-07 1e-06 1e-05 0,0001 0,001 0,01 0,1 1theoretical D

1e-10

1e-09

1e-08

1e-07

1e-06

1e-05

0,0001

0,001

0,01

0,1

1

FoFiHOCMS

Measurement of the diffusion coefficient

Figure 6.5: Measured diffusivity over a set of diffusivities

algorithms. The diffusion coefficient is measured after 10 time steps of length δt = 0.001. Themeasured values are plotted over the theoretical ones in a logarithmic scaling, presented in Fig.(6.5). It can be seen that the values are in good agreement with each other throughout all ordersof magnitude.

40

Page 46: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

0 100 200 300Position in grid points

0

0,1

0,2

0,3

0,4

0,5

0,6

Mol

e fr

actio

n

Initial Gaussian and two resulting distributions

Initial setup

Result for u=2.0

Result for u=10.0

Figure 6.6: Initial step and two resulting distributions

6.2 Measurement of numerical diffusion

The phenomena of numerical diffusion arises from the upwinding scheme used to discretize theconvective term. This effect will be explained on behalf of the backward differencing scheme. Forthe x-direction the difference operator reads:

δ−x Φi =Φi − Φi−1

h+(h

2∂2Φ∂x2

∣∣∣∣i

− h2

6∂3Φ∂x3

∣∣∣∣i

+ . . .

)(6.7)

Here, the leading term of the truncation error is a second derivate multiplied by half the stepsize.This term acts as a additional diffusive term without a physical background. The magnitude ofnumerical diffusion depends on the step size and on the present velocity in the system. The goal ofthis experiment is to outline the influence of numerical diffusion to the first order implementationsof Fick’s law and the MS model and compare these results to the difference scheme of fourth orderaccuracy.The initial distribution of the experiment is created according to Eq. (6.2). The parameters forthe Gaussian are µ = 1, σ = 0.06 and pv = 0.5. The size of the computational domain is chosen tobe sufficiently large to ensure that the distribution does not reach the boundary during simulation.Now the domain has a length of 4 and for the first test case it is discretized with 320 grid points.The theoretical diffusion coefficient is set to 0.001. The measurement is done after 100 time stepsof length 0.001. Fig. (6.6) illustrates the test setup. In addition, two resulting distributions forvelocities of u = 2.0 and u = 10.0 are contained in the plot.The test series cover a set of velocities ranging from 0.0 to 10.0. This series are computed by all

implementations and the measured diffusion coefficients are plotted in Fig. (6.7). One can see thatthe values are quasi identical until a velocity of 0.1 is reached. If the velocity is further increased, thenumerical diffusion becomes apparent. While the HOC scheme maintains a nearly constant value,the measured DiCo starts to rise for both first order models. The measurands of the FoFi algorithmare in conformity with the Maxwell-Stefan code, because the discretization of the convective termis the same for both models. At a velocity of 0.2 the deviation from the theoretical D is in the orderof 1 percent and at a velocity of 0.5 the deviation is already around 10 percent. Increasing thevelocity to a value of 10 leads to strong overprediction of the diffusivity. In this case the numericaldiffusion exceeds the theoretical D by a factor of 50. For velocities higher than 3, also the measuredvalues from HOC scheme start fluctuate, where the maximal misprediction is around 10 percent.For a given velocity the only way to reduce the amount of numerical diffusion is to decrease thestep size. The effect of grid refinement to the numerical diffusion is presented in Fig. (6.8). With

41

Page 47: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

0,001 0,01 0,1 1 10velocity

0,0001

0,001

0,01

0,1

mea

sure

d D

0,001 0,01 0,1 1 10velocity

0,0001

0,001

0,01

0,1

FoFiHOCMStheoretical D

Measured diffusion coefficient over convection rateh=0.0125 and dt=0.001

Figure 6.7: Numerical diffusion with respect to the flow velocity

respect to convection the MS algorithm is analogous to the FoFi code and therefore only the latteris compared to the HOC scheme in this test case. The graphs labeled, with h=0.0125 are the sameas in the previous plot. Executing the test series with a grid discretized by 640 points leads tothe additional graph marked with h=0.00625. For this step size, also the time interval had to bedecreased in order to keep the consistency with the CFL-condition for all velocities. To highlightthe differences between the graphs a linear scaling is chosen. With that one can see that reducingthe step size by the a factor of 2, yields in a reduction of numerical diffusion by the same factor. Butthis reduction comes at the cost of doubled memory requirement and a higher computational effort.Further, the superior characteristics of high accuracy and vanishingly low numerical diffusion canbe observed. For more experiments regarding the HOC scheme, see [10].

0 1 2 3 4 5 6 7 8 9 10 11velocity

0

0,01

0,02

0,03

0,04

0,05

0,06

mea

sure

d D

0 10velocity

0

FoFi h=0.0125FoFi h=0.00625HOC h=0.0125theoretical D

Reducing the numerical diffusion

Figure 6.8: Numerical diffusion with respect to the stepsize

42

Page 48: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Basic performance considerations

Although no code optimizations have been made in the scope of this thesis, the general runtimecharacteristics will be outlined. For this, the elapsed wall clock time of the algorithms is measuredwith respect to different domain sizes. Above experiments were performed on a quasi 1-dimensionaldomain with 3 grid points in the y direction. Here, the problem size is scaled by successively increas-ing the number of grid points in y direction. The test setup is created according to the parametersprovided in Tab. (6.2), where the flow velocity is set to 0.1 and the initial species distributionis adopted from previous experiments. Even though it is not necessary for the Fickian mixture

Nx 320Ny 3, 10, 20, 40h 0.0125Nt 200δt 0.005

Table 6.1: Simulation parameters for runtime measurement

model, the solvents distribution is computed by all algorithms in order to provide comparable mea-sures. In addition, the first order implementation of Fick’s law was extended to incorporate theBiCGSTAB method as well, thus, both mixture models can be directly check against each other.Each combination of algorithm and problem size is executed 10 times and the average wall clocktimes are given in Tab. (6.2). It can be seen that all codes show approximately linear behavior

320 x 3 320 x 10 320 x 20 320 x 40FoFi SOR 0.20 0.68 1.32 2.61FoFi BiCGSTAB 0.43 1.56 3.06 5.97MS BiCGSTAB 0.71 2.55 4.75 9.41HOC BiCGSTAB 2.30 9.69 19.39 37.74

Table 6.2: Runtime in seconds for different problem sizes

and that the straightforward FoFi–SOR implementation outperforms all other algorithms. Obvi-ously, the additional effort for the transition from grid based to matrix–vector based data layout isone of the reasons. For the Maxwell–Stefan model, the inversion of the binary diffusion resistancematrices induces additional calculations, which results in a longer computation compared to theFoFi–BiCGSTAB algorithm. The HOC scheme is of higher complexity and consequently results inan increased runtime.

43

Page 49: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

6.3 Solvent test case

Within a multispecies mixture one species is called solvent if its concentration is in large excess ofall the others. In case of a ternary mixture this means that the relationship between the speciesconcentration can be written as:

χ1 −→ 0χ2 −→ 0χ3 −→ 1

where χ3 denotes the solvent species. In the following numerical experiments this mixture ratio isused.

Schematic setup

In order to simplify the test setup, an uniform distribution of solvent species χ3 = 1 − (χ1 + χ2)is assumed. Next, the dilute species 1 and 2 are initialized with individual base concentrations χ1

and χ2. A concentration difference is induced by locally raising the concentration of species 1 andconcurrently decreasing the concentration of species 2 by the same amount. To avoid discontinuitiesthis is done using a modified cosine function, which reads:

f(x′i) = pv · cos(

2πb

(x′i − x′max)), (6.8)

where x′ ∈ [−0.5, 0.5] is the normalized position, b accounts for the width of the curve, xmaxrepresents the center of the curve and pv depicts the maximal value. For the schematic setup,presented in Fig. (6.9), these parameters are:

peak position xmax 2.0peak value pv 0.5 · χ1

peak width b 0.5

0 80 xmax 240 320

Position in grid points

0

1

Mol

e fr

actio

n

Species 1Species 2Species 3

Schematic setup

χ3

χ1

χ2

b

pv

Solvent species

Figure 6.9: Initial setup for the solvent test case

44

Page 50: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

The 1-dimensional domain is discretized by Nx = 320 grid points, which have a distance of h =0.0125. The binary diffusion coefficients for Fick’s law are set to:

Fick’s law Maxwell-Stefanspecies 1 to solvent D13 = 0.001 M1 = 0.000001species 2 to solvent D23 = 0.05 M2 = 0.002506solvent − M2 = 1.000000

where the corresponding molecular weights for the MS model are calculated according to Eq. (6.1).In the following this basic setup is used to create the initial distribution for a pair of basevalues χ1

and χ2. The evolution of these distributions is now simulated for 200 time steps, where each stepis of size δt = 0.005. This is done for both mixture models and the results are plotted against eachother.

Test case with χ1 = 0.0002 and χ2 = 0.0001

For the first test case the chosen base concentrations are in the order of 10−4. The first graphin Fig.(6.10) shows the resulting species distribution calculated by the mixture models. Here, thesolvent species is omitted from the graph, because its distribution remains constant for the Fickianmodel and the minor fluctuations arising from the MS model are addressed later on. In the courseof the experiments it became apparent, that the largest differences between the models can beobserved for the distribution of species 2. Therefore, the second graph serves to illustrate therelative deviation of the Fick model to Maxwell-Stefan model. The deviation is calculated by:

deviation =

[(χ

(2)Fick

χ(2)MS

− 1

)· 100

](6.9)

It turns out, that the both models are in good agreement and the maximal deviation is less thantwo percent. This can be explained from a molecular point of view. Due to the low concentrations,there are only a few molecules of species 1 and 2 in the mixture. Hence, a molecule of species 1,

0 80 160 240 3200,0000

0,0001

0,0002

0,0003

Mol

e fr

actio

n

FoFi S1FoFi S2MS S1MS S2

Species distribution after 200 time steps

0 80 160 240 320Position in grid points

-2

0

2

Dev

iatio

n in

per

cent

Figure 6.10: Species distributions and relative deviation for base concentrations χ1 = 0.0002 andχ2 = 0.0001

for the most part, encounters molecules of the solvent species, whereas collisions between 1 and 2are extremely rare. Under this conditions the binary interactions between species 1 and the solventdominate the diffusion and as a result, Fick’s law can still be applied without causing a severedeviation.

45

Page 51: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

0 80 160 240 3200,000

0,002

0,004

0,006

0,008

0,010

Mol

e fr

actio

n

FoFi S1FoFi S2MS S1MS S2

Species distribution after 200 time steps

0 80 160 240 320Position in grid points

-10

0

10

20

30

Dev

iatio

n in

per

cent

Figure 6.11: Species distributions and relative deviation for base concentrations χ1 = 0.006 andχ2 = 0.003

Test case with χ1 = 0.006 and χ2 = 0.003

When the concentration of the dissolved species are increased, collisions between their molecules aremore frequent and the intrinsic limit of Fick’s law of diffusion becomes obvious. For a second testcase, the base concentrations are set to χ1 = 0.006 and χ2 = 0.003. The resulting distribution after200 time steps is presented in Fig. (6.11). From the first graph it can be seen, that the species 2distribution significantly differs between the mixture models. From the flatter curve of the Fickianmodel one can infer a higher diffusivity. The second graph reveals a deviation of more than 25percent between the models. From this it follows that Fick’s law can not reflect the moleculartransport processes in a multispecies mixture, where the dissolved species concentrations are in theorder of 10−3. In this case only the Maxwell-Stefan model is able to provide a physical consistentbehavior.

Osmotic diffusion

If the test case is conducted with base concentrations of χ1 = 0.3 and χ2 = 0.15, then MS modelreveals a physical phenomena, which also can not be modeled by Fick’s law due to its restrictionto binary interactions. But for the sake of completeness, the distributions resulting from bothmixture models are illustrated in Fig. (6.12). Here, the first plot shows the solvent species andthe second one contains species 1 and 2. Initially, the solvent species is homogeneously distributedand consequently there is no difference in concentration, see Fig. (6.9). Nevertheless, after the200 time steps small fluctuations in the distribution can be detected. To highlight this fluctuationsmore clearly, the first graph’s y-axis is scaled to match their magnitude. The occurrence of adiffusion flux in the absence of a concentration gradient is called osmotic diffusion and results fromthe mutual interactions among the species. This effect is a further indication for the possibilityof the MS model to consistently cover the molecular transport processes. Among other interestingphenomena, osmotic diffusion was also observed by an experiment conducted by Duncan and Toor,see [9] for further information, which is regarded as a reference experiment in the literature. Acomprehensive list of further experiments investigating the Maxwell-Stefan relations can be foundin [16].

46

Page 52: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

0 80 160 240 320Position in grid points

0,0

0,1

0,2

0,3

0,4

0,5

Mol

e fr

actio

n

FoFi S1FoFi S2MS S1MS S2

0 80 160 240 3200,54

0,55

0,56

Mol

e fr

actio

n FoFi solventMS solvent

Species distribution after 200 time steps

Figure 6.12: Osmotic diffusion of the solvent species

Basic performance considerations

For runtime measurements, the limiting case test setup with basevalues χ1 = 0.0002 and χ2 = 0.0001is used. The scaling of the problem size is done by increasing the number of grid points in y direction.Each combination of algorithm and problem size is executed 10 times and the average wall clocktimes are given in Tab. (6.3). Similar to the performance measurements, provided in Sec. (6.2),all codes reveal a nearly linear behavior. And again, the FoFi–SOR implementation turns out tobe the fastest one. With respect to further experiments, it would be of interest to investigate theruntime characteristics for mixtures containing more then three species. Because it can be assumedthat for a higher number of species the inversion of the diffusion resistance matrices dominate thecomputation in case of the Maxwell-Stefan approach.

320 x 3 320 x 10 320 x 20 320 x 40FoFi SOR 0.73 2.59 5.06 9.93FoFi BiCGSTAB 1.12 4.19 8.23 16.34MS BiCGSTAB 3.58 13.15 25.15 50.08HOC BiCGSTAB 4.53 16.26 30.93 60.48

Table 6.3: Runtime in seconds for different problem sizes

47

Page 53: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 7

Conclusion

In the scope of this thesis two constitutive relations describing the diffusion flux are investigatedand implemented. For this purpose a lot of interfaces have to be connected ranging from kinetictheory and pyhsical chemistry to the mathematics of partial differential equations and numericalanalysis. As said before, Fick’s law of diffusion is quite comprehensible but has the restriction to beonly defined for binary mixtures. The more sophisitcated Maxwell-Stefan model comes at the costof a challenging mathematical formulation, which may be one of the reasons why it is adressed byonly a few publications in physical chemistry. But this model is able to provide a physical consistentdescription for an arbitrary number of mixture componets at any concentration.As a first step both mixture models are discretized using a finite difference scheme of first orderspatial accuracy. For the Fickian model also a higher order compact finite difference scheme wasdeveloped. For the Maxwell-Stefan model it was found out that it is not possible to use thestraightforward approach in the derviation of the higher order compact finite difference scheme.The mathematical problems arise from the non-linearity of the diffusive term and could not besolved within this thesis.The numerical experiments serve to verify the implemented algorithms and to demonstrate thesuperior accuracy of the HOC scheme in the presence of convection. In addition, Fick’s law and theMaxwell-Stefan relations are compared by means of a ternary mixture and the limits of the Fickianmodel are outlined. The results show a good agreement with the expected values from theory.The present work represents a first step to advanced multispecies mixture simulation, but before itcan be applied to engineering problems, a lot of further research has to be done. A first step wouldbe to extend the code to three dimensions and secondly the implemention of further boundaryconditions like Dirchlet or von Neumann are required. But the most challenging step is to achieve ahigher spatial accuracy for the MS model. For this a modified derivation of the HOC scheme needsto be developed but from the present point of view the transition to different differencing schemes,like finite volumes, seems to be more promising.

48

Page 54: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Chapter 8

Acknowledgements

I would like to give my sincere thanks to Prof. Dr. Ulrich Rude for great support during my masterthesis. Further, special thanks go to my tutor Dipl.-Inf. Christian Feichtinger for many ideas duringimplementation and his motivations during writing. A big thank you to Dr. Ing. Harald Kostlerfor the answers on my numerous questions regarding numerics and for correcting. Thanks alsoto Phd. Pietro Asinari for giving a first insight to the Maxwell-Stefan theory and MSc. DanielRitter for correcting and ideas regarding some English formulations. Last but not least I thank mygirlfriend Stephanie for giving me encouragement, beeing patient with my complains and that I hadsomething to look forward to.

49

Page 55: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

Bibliography

[1] Iterative Methods Library in C++http://math.nist.gov/iml++/.

[2] Sparse Matrix Library in C++http://math.nist.gov/sparselib++/.

[3] widely applicable Lattice Boltzmann algorithm from Erlangenhttp://www10.informatik.uni-erlangen.de/Research/Projects/walberla/walberla.shtml.

[4] Michael Breuer. Numerische Stromungsmechanik - Vorlesungsskript, 2006.

[5] H. B. Fischer, E. J. List, J. Imberger, and N. H. Brooks. Mixing in Inland and Coastal Waters.Academic Press, 1979.

[6] Wolfgang Hackbusch. Theorie und Numerik elliptischer Differentialgleichungen. Teubner Stu-dienbcher, 2003.

[7] D. Hanel. Molekulare Gasdynamik. Springer-Verlag GmbH, 2004.

[8] ICMMES. Lattice Boltzmann Schemes for Homogeneous Mixture Flow Modeling, 2007.

[9] H. L. Toor J. B. Duncan. An experimental study of three component gas diffusion. AIChEJournal, 8:38–41, 1962.

[10] Anoop K. Dass Jiten C. Kalita, D. C. Dalal. A class of higher order compact schemes for theunsteady two-dimensional convection-diffusion equation with variable convection coefficients.International Journal for Numerical Methods in Fluids, 38(12):1111–1131, 2002.

[11] M. Junk, A. Klar, and L. S. Luo. Asymtotic analysis of the lattice boltzmann equation. J.Comput. Phys., 210(2):676 704, 2005.

[12] Tilman Neunhoeffer Michael Griebel, Thomas Dornseifer. Numerical simulation in fluid dy-namics: a practical introduction. SIAM, 1998.

[13] P. L. Bhatnagar, E. P. Gross, and M. Krook. A model for collision processes in gases. Phys.Rev., 94:511525, 1954.

[14] Y. H. Qian, D. D’Humieres, and P. Lallemand. Lattice bgk models for navier-stokes equation.EPL (Europhysics Letters), 17(6):479–484, 1992.

[15] J. Douglas Faires Richard L. Burden. Numerical Analysis. Brooks-Cole Publishing, 2001.

[16] R. Krishna Ross Taylor. Mulitcomponent Mass Transfer. Wiley, 1993.

[17] W. Spotz and G. Carey. High-order compact finite difference methods with applications toviscous flow, 1993.

[18] Sauro Succi. The Lattice Boltzmann Equation for Fluid Dynamics and Beyond. Oxford Uni-versity Press, 2001.

[19] G.F. Carey W.F. Spotz. Extension of high-order compact schemes to time dependent problems.Numerical Methods for Partial Differential Equations, 17:657–672, 2001.

50

Page 56: FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN … · FRIEDRICH-ALEXANDER-UNIVERSITAT ERLANGEN-N URNBERG ... The discretization of the Maxwell-Stefan relations is discussed by means of

[20] Saul A. Teukolsky William H. Press, Brian P. Flannery and William T. Vetterling. NumericalRecipes in C: The Art of Scientific Computing. Cambridge University Press.

[21] Dieter A. Wolf-Gladrow. Lattice-gas cellular automata and lattice Boltzmann models. Springer-Verlag GmbH, 2000.

51