15 
\section{RayleighTaylor Instability} 
\section{RayleighTaylor Instability} 
16 
\label{LEVELSET CHAP} 
\label{LEVELSET CHAP} 
17 


18 
In this chapter we will implement the Level Set Method in Escript for tracking the interface between two fluids for Computational Fluid Dynamics (CFD). 
In this chapter we will implement the Level Set Method in Escript for tracking the interface between two fluids for Computational Fluid Dynamics (CFD). The method is tested with a RayleighTaylor Instability problem, which is an instability of the interface between two fluids with differing densities. \\ 
19 
Normally in Earth science problems two or more fluids in a system with different properties are of interest. For example, lava dome growth in volcanology, with the contrast of the two mediums as being lava and air. The interface between the two mediums is often referred to as a free surface (free boundary value problem); the problem arises due to the large differences in densities between the lava and air, with their ratio being around 2000, and so the interface between the two fluids move with respect to each other. 
Normally in Earth science problems two or more fluids in a system with different properties are of interest. For example, lava dome growth in volcanology, with the contrast of the two mediums as being lava and air. The interface between the two mediums is often referred to as a free surface (free boundary value problem); the problem arises due to the large differences in densities between the lava and air, with their ratio being around 2000, and so the interface between the two fluids move with respect to each other. 
20 
%and so the lava with the much higher density is able to move independently with respect to the air, and the interface between the two fluids is not constrained. 
%and so the lava with the much higher density is able to move independently with respect to the air, and the interface between the two fluids is not constrained. 
21 
There are a number of numerical techniques to define and track the free surfaces. One of these methods, which is conceptually the simplest, is to construct a Lagrangian grid which moves with the fluid, and so it tracks the free surface. The limitation of this method is that it cannot track surfaces that break apart or intersect. Another limitation is that the elements in the grid can become severely distorted, resulting in numerical instability. The Arbitrary LagrangianEulerian (ALE) method for CFD in moving domains is used to overcome this problem by remeshing, but there is an overhead in computational time, and it results in a loss of accuracy due to the process of mapping the state variables every remesh by interpolation. 
There are a number of numerical techniques to define and track the free surfaces. One of these methods, which is conceptually the simplest, is to construct a Lagrangian grid which moves with the fluid, and so it tracks the free surface. The limitation of this method is that it cannot track surfaces that break apart or intersect. Another limitation is that the elements in the grid can become severely distorted, resulting in numerical instability. The Arbitrary LagrangianEulerian (ALE) method for CFD in moving domains is used to overcome this problem by remeshing, but there is an overhead in computational time, and it results in a loss of accuracy due to the process of mapping the state variables every remesh by interpolation. 
22 


23 
There is a technique to overcome these limitations called the Level Set Method, for tracking interfaces between two fluids. The advantages of the method is that CFD can be performed on a fixed Cartesian mesh, and therefore problems with remeshing can be avoided. The field equations for calculating variables such as velocity and pressure are solved on the the same mesh. The Level Set Method is based upon the implicit representation of the interface by a continuous function. The function takes the form as a signed distance function, $\phi(x)$, of the interface in a Eulerian coordinate system. For example, the zero isocontour of the unit circle $\phi(x)=x^2 + y^2 1$ is the set of all points where $\phi(x)=0$. 
There is a technique to overcome these limitations called the Level Set Method, for tracking interfaces between two fluids. The advantages of the method is that CFD can be performed on a fixed Cartesian mesh, and therefore problems with remeshing can be avoided. The field equations for calculating variables such as velocity and pressure are solved on the the same mesh. The Level Set Method is based upon the implicit representation of the interface by a continuous function. The function takes the form as a signed distance function, $\phi(x)$, of the interface in a Eulerian coordinate system. For example, the zero isocontour of the unit circle $\phi(x)=x^2 + y^2 1$ is the set of all points where $\phi(x)=0$. Refer to Figure \ref{UNITCIRCLE}. 
24 
% 
% 
25 
\begin{figure} 
\begin{figure} 
26 
\center 
\center 
27 
\scalebox{0.5}{\includegraphics{figures/unitcircle.eps}} 
\scalebox{0.7}{\includegraphics{figures/unitcircle.eps}} 
28 
\caption{Implicit representation of the curve $x^2 + y^2 = 1$.} 
\caption{Implicit representation of the curve $x^2 + y^2 = 1$.} 
29 
\label{UNITCIRCLE} 
\label{UNITCIRCLE} 
30 
\end{figure} 
\end{figure} 
31 
% 
% 
32 
The implicit representation can be used to define the interior and exterior of a fluid region. Since the isocontour at $\phi(x)=0$ has been defined as the interface, a point in the domain can be determined if its inside or outside of the interface, by looking at the local sign of $\phi(x)$. A point is inside the interface when $\phi(x)<0$, and outside the interface when $\phi(x)>0$. Parameters values such as density and viscosity can then be defined for two different mediums, depending on which side of the interface they are located. The displacement of the interface at the zero isocontour of $\phi(x)$ is calculated each time step by using the velocity field. This is achieved my solving the advection equation: 
The implicit representation can be used to define the interior and exterior of a fluid region. Since the isocontour at $\phi(x)=0$ has been defined as the interface, a point in the domain can be determined if its inside or outside of the interface, by looking at the local sign of $\phi(x)$. For example, a point is inside the interface when $\phi(x)<0$, and outside the interface when $\phi(x)>0$. Parameters values such as density and viscosity can then be defined for two different mediums, depending on which side of the interface they are located. 
33 


34 


35 

\subsection{Calculation of the Displacement of the Interface} 
36 


37 

The displacement of the interface at the zero isocontour of $\phi(x)$ is calculated each timestep by using the velocity field. This is achieved my solving the advection equation: 
38 

% 
39 
\begin{equation} 
\begin{equation} 
40 
\frac{\partial \phi}{\partial t} + \vec{v} \cdot \nabla \phi = 0, 
\frac{\partial \phi}{\partial t} + \vec{v} \cdot \nabla \phi = 0, 
41 
\label{ADVECTION} 
\label{ADVECTION} 
42 
\end{equation} 
\end{equation} 
43 

% 
44 
where $\vec{v}$ is the velocity field. The advection equation is solved using a midpoint method, which is a two step procedure: 
where $\vec{v}$ is the velocity field. The advection equation is solved using a midpoint method, which is a two step procedure: 
45 


46 
Firstly, $\phi^{1/2}$ is calculated solving: 
Firstly, $\phi^{1/2}$ is calculated solving: 
47 

% 
48 
\begin{equation} 
\begin{equation} 
49 
\frac{\phi^{1/2}  \phi^{}}{dt/2} + \vec{v} \cdot \nabla \phi^{} = 0. 
\frac{\phi^{1/2}  \phi^{}}{dt/2} + \vec{v} \cdot \nabla \phi^{} = 0. 
50 
\label{MIDPOINT FIST} 
\label{MIDPOINT FIST} 
51 
\end{equation} 
\end{equation} 
52 

% 
53 
Secondly, using $\phi^{1/2}$, $\phi^{+}$ is calculated solving: 
Secondly, using $\phi^{1/2}$, $\phi^{+}$ is calculated solving: 
54 

% 
55 
\begin{equation} 
\begin{equation} 
56 
\frac{\phi^{+}  \phi^{}}{dt} + \vec{v} \cdot \nabla \phi^{1/2} = 0. 
\frac{\phi^{+}  \phi^{}}{dt} + \vec{v} \cdot \nabla \phi^{1/2} = 0. 
57 
\label{MIDPOINT SECOND} 
\label{MIDPOINT SECOND} 
58 
\end{equation} 
\end{equation} 
59 

% 
60 
For more details on the midpoint procedure see reference \cite{BOURGOUIN2006}. In certain situations the midpoint procedure has been shown to produce artifacts in the numerical solutions. A more robust procedure is to use the TaylorGalerkin scheme with the presence of diffusion, which gives more stable solutions. The expression is derived by either inserting Equation (\ref{MIDPOINT FIST}) into Equation (\ref{MIDPOINT SECOND}), or by expanding $\phi$ into a Taylor series: 
For more details on the midpoint procedure see reference \cite{BOURGOUIN2006}. In certain situations the midpoint procedure has been shown to produce artifacts in the numerical solutions. A more robust procedure is to use the TaylorGalerkin scheme with the presence of diffusion, which gives more stable solutions. The expression is derived by either inserting Equation (\ref{MIDPOINT FIST}) into Equation (\ref{MIDPOINT SECOND}), or by expanding $\phi$ into a Taylor series: 
61 

% 
62 
\begin{equation} 
\begin{equation} 
63 
\phi^{+} \simeq \phi^{} + dt\frac{\partial \phi^{}}{\partial t} + \frac{dt^2}{2}\frac{\partial^{2}\phi^{}}{\partial t^{2}}, 
\phi^{+} \simeq \phi^{} + dt\frac{\partial \phi^{}}{\partial t} + \frac{dt^2}{2}\frac{\partial^{2}\phi^{}}{\partial t^{2}}, 
64 
\label{TAYLOR EXPANSION} 
\label{TAYLOR EXPANSION} 
65 
\end{equation} 
\end{equation} 
66 

% 
67 
by inserting 
by inserting 
68 

% 
69 
\begin{equation} 
\begin{equation} 
70 
\frac{\partial \phi^{}}{\partial t} =  \vec{v} \cdot \nabla \phi^{}, 
\frac{\partial \phi^{}}{\partial t} =  \vec{v} \cdot \nabla \phi^{}, 
71 
\label{INSERT ADVECTION} 
\label{INSERT ADVECTION} 
72 
\end{equation} 
\end{equation} 
73 

% 
74 
and 
and 
75 

% 
76 
\begin{equation} 
\begin{equation} 
77 
\frac{\partial^{2} \phi^{}}{\partial t^{2}} = \frac{\partial}{\partial t}(\vec{v} \cdot \nabla \phi^{}) = \vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{}), 
\frac{\partial^{2} \phi^{}}{\partial t^{2}} = \frac{\partial}{\partial t}(\vec{v} \cdot \nabla \phi^{}) = \vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{}), 
78 
\label{SECOND ORDER} 
\label{SECOND ORDER} 
79 
\end{equation} 
\end{equation} 
80 

% 
81 
into Equation \ref{TAYLOR EXPANSION} 
into Equation (\ref{TAYLOR EXPANSION}) 
82 

% 
83 
\begin{equation} 
\begin{equation} 
84 
\phi^{+} = \phi^{}  dt\vec{v}\cdot \nabla \phi^{} + \frac{dt^2}{2}\vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{}). 
\phi^{+} = \phi^{}  dt\vec{v}\cdot \nabla \phi^{} + \frac{dt^2}{2}\vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{}). 
85 
\label{TAYLOR GALERKIN} 
\label{TAYLOR GALERKIN} 
86 
\end{equation} 
\end{equation} 



87 



The fluid dynamics is governed by the Stokes equations. In geophysical problems the velocity of fluids are low; that is, the inertial forces are small compared with the viscous forces, therefore the inertial terms in the NavierStokes equations can be ignored. For a body force $f$ the governing equations are given by: 

88 


89 

\subsection{Governing Equations for Fluid Flow} 
90 


91 

The fluid dynamics is governed by the Stokes equations. In geophysical problems the velocity of fluids are low; that is, the inertial forces are small compared with the viscous forces, therefore the inertial terms in the NavierStokes equations can be ignored. For a body force $f$ the governing equations are given by: 
92 

% 
93 
\begin{equation} 
\begin{equation} 
94 
\nabla \cdot (\eta(\nabla \vec{v} + \nabla^{T} \vec{v}))  \nabla p = f, 
\nabla \cdot (\eta(\nabla \vec{v} + \nabla^{T} \vec{v}))  \nabla p = f, 
95 
\label{GENERAL NAVIER STOKES} 
\label{GENERAL NAVIER STOKES} 
96 
\end{equation} 
\end{equation} 
97 

% 
98 
with the incompressibility condition 
with the incompressibility condition 
99 

% 
100 
\begin{equation} 
\begin{equation} 
101 
\nabla \cdot \vec{v} = 0. 
\nabla \cdot \vec{v} = 0. 
102 
\label{INCOMPRESSIBILITY} 
\label{INCOMPRESSIBILITY} 
103 
\end{equation} 
\end{equation} 
104 

% 
105 
where $p$, $\eta$ and $f$ are the pressure, viscosity and body forces, respectively. 
where $p$, $\eta$ and $f$ are the pressure, viscosity and body forces, respectively. 
106 
Alternatively, the Stokes equations can be represented in Einstein summation tensor notation (compact notation): 
Alternatively, the Stokes equations can be represented in Einstein summation tensor notation (compact notation): 
107 

% 
108 
\begin{equation} 
\begin{equation} 
109 
(\eta(v\hackscore{i,j} + v\hackscore{j,i})),\hackscore{j}  p,\hackscore{i} = f\hackscore{i}, 
(\eta(v\hackscore{i,j} + v\hackscore{j,i})),\hackscore{j}  p,\hackscore{i} = f\hackscore{i}, 
110 
\label{GENERAL NAVIER STOKES COM} 
\label{GENERAL NAVIER STOKES COM} 
111 
\end{equation} 
\end{equation} 
112 

% 
113 
with the incompressibility condition 
with the incompressibility condition 
114 

% 
115 
\begin{equation} 
\begin{equation} 
116 
v\hackscore{i,i} = 0. 
v\hackscore{i,i} = 0. 
117 
\label{INCOMPRESSIBILITY COM} 
\label{INCOMPRESSIBILITY COM} 
118 
\end{equation} 
\end{equation} 
119 

% 
120 
The subscript $,i$ denotes the derivative of the function with respect to $x\hackscore{i}$. A linear relationship between the deviatoric stress $\sigma^{'}\hackscore{ij}$ and the stretching $D\hackscore{ij} = \frac{1}{2}(v\hackscore{i,j} + v\hackscore{j,i})$ is defined as \cite{GROSS2006}: 
The subscript comma $i$ denotes the derivative of the function with respect to $x\hackscore{i}$. A linear relationship between the deviatoric stress $\sigma^{'}\hackscore{ij}$ and the stretching $D\hackscore{ij} = \frac{1}{2}(v\hackscore{i,j} + v\hackscore{j,i})$ is defined as \cite{GROSS2006}: 
121 

% 
122 
\begin{equation} 
\begin{equation} 
123 
\sigma^{'}\hackscore{ij} = 2\eta D^{'}\hackscore{ij}, 
\sigma^{'}\hackscore{ij} = 2\eta D^{'}\hackscore{ij}, 
124 
\label{STRESS} 
\label{STRESS} 
125 
\end{equation} 
\end{equation} 
126 

% 
127 
where the deviatoric stretching $D^{'}\hackscore{ij}$ is defined as 
where the deviatoric stretching $D^{'}\hackscore{ij}$ is defined as 
128 

% 
129 
\begin{equation} 
\begin{equation} 
130 
D^{'}\hackscore{ij} = D^{'}\hackscore{ij}  \frac{1}{3}D\hackscore{kk}\delta\hackscore{ij}. 
D^{'}\hackscore{ij} = D^{'}\hackscore{ij}  \frac{1}{3}D\hackscore{kk}\delta\hackscore{ij}. 
131 
\label{DEVIATORIC STRETCHING} 
\label{DEVIATORIC STRETCHING} 
132 
\end{equation} 
\end{equation} 
133 

% 
134 
The $\delta\hackscore{ij}$ is the Kronecker $\delta$symbol, which is a matrix with ones for its diagonal entries ($i = j$) and zeros for the remaining entries ($i \neq j$). The body force $f$ in Equation (\ref{GENERAL NAVIER STOKES COM}) is the gravity acting in the $x\hackscore{3}$ direction and is given as $f = g \rho \delta\hackscore{i3}$. 
where $\delta\hackscore{ij}$ is the Kronecker $\delta$symbol, which is a matrix with ones for its diagonal entries ($i = j$) and zeros for the remaining entries ($i \neq j$). The body force $f$ in Equation (\ref{GENERAL NAVIER STOKES COM}) is the gravity acting in the $x\hackscore{3}$ direction and is given as $f = g \rho \delta\hackscore{i3}$. 



135 
The Stokes equations is a saddle point problem, and can be solved using a Uzawa scheme. A class called StokesProblemCartesian in Escript can be used to solve for velocity and pressure. 
The Stokes equations is a saddle point problem, and can be solved using a Uzawa scheme. A class called StokesProblemCartesian in Escript can be used to solve for velocity and pressure. 
136 
In order to keep numerical stability, the time step size needs to be below a certain value, known as the Courant number. The Courant number is defined as: 
In order to keep numerical stability, the timestep size needs to be below a certain value, known as the Courant number. The Courant number is defined as: 
137 

% 
138 
\begin{equation} 
\begin{equation} 
139 
C = \frac{v \delta t}{h}. 
C = \frac{v \delta t}{h}. 
140 
\label{COURANT} 
\label{COURANT} 
141 
\end{equation} 
\end{equation} 
142 

% 
143 

where $\delta t$, $v$, and $h$ are the timestep, velocity, and the width of an element in the mesh, respectively. The velocity $v$ may be chosen as the maximum velocity in the domain. In this problem the Courant number is taken to be 0.4 \cite{BOURGOUIN2006}. 
144 



where $\delta t$, $v$, and $h$ are the time step, velocity, and the width of an element in the mesh, respectively. The velocity $v$ may be chosen as the maximum velocity in the domain. In this problem the Courant number is taken to be 0.4 \cite{BOURGOUIN2006}. 

145 


146 
As the computation of the distance function progresses, it becomes distorted, and so it needs to be updated in order to stay regular. This process is known as the reinitialization procedure. The aim is to iteratively find a solution to the reinitialization equation: 
\subsection{Reinitialization of Interface} 
147 


148 

As the computation of the distance function progresses, it becomes distorted, and so it needs to be updated in order to stay regular. This process is known as the reinitialization procedure. The aim is to iteratively find a solution to the reinitialization equation: 
149 

% 
150 
\begin{equation} 
\begin{equation} 
151 
\frac{\partial \psi}{\partial \tau} + sign(\psi)(1  \nabla \psi) = 0. 
\frac{\partial \psi}{\partial \tau} + sign(\psi)(1  \nabla \psi) = 0. 
152 
\label{REINITIALISATION} 
\label{REINITIALISATION} 
153 
\end{equation} 
\end{equation} 
154 

% 
155 
where $\tau$ is artificial time. This equation is solved to meet the definition of the level set function, $\lvert \nabla \psi \rvert = 1$; the normalization condition. However, it has been shown that in using this reinitialization procedure it is prone to mass loss and inconsistent positioning of the interface \cite{SUCKALE2008}. 
where $\tau$ is artificial time. This equation is solved to meet the definition of the level set function, $\lvert \nabla \psi \rvert = 1$; the normalization condition. However, it has been shown that in using this reinitialization procedure it is prone to mass loss and inconsistent positioning of the interface \cite{SUCKALE2008}. 
156 



The RayleighTaylor instability problem is used as a benchmark to validate CFD implementations \cite{VANKEKEN1997}. Figure \ref{RT2DSETUP} shows the setup of the problem. A rectangular domain with two different fluids is considered, with the greater density fluid on the top and the lighter density fluid on the bottom. The viscosities of the two fluids are equal (isoviscos). An initial perturbation is given to the interface of $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The aspect ratio, $\lambda = L/H = 0.9142$, is chosen such that it gives the greatest disturbance of the fluids. 

157 


158 

\subsection{Benchmark Problem} 
159 


160 

The RayleighTaylor instability problem is used as a benchmark to validate CFD implementations \cite{VANKEKEN1997}. Figure \ref{RT2DSETUP} shows the setup of the problem. A rectangular domain with two different fluids is considered, with the greater density fluid on the top and the lighter density fluid on the bottom. The viscosities of the two fluids are equal (isoviscos). An initial perturbation is given to the interface of $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The aspect ratio, $\lambda = L/H = 0.9142$, is chosen such that it gives the greatest disturbance of the fluids. 
161 

% 
162 
\begin{figure} 
\begin{figure} 
163 
\center 
\center 
164 
\scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}} 
\scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}} 