1 


2 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3 
% 
% 
4 
% Copyright (c) 20032009 by University of Queensland 
% Copyright (c) 20032010 by University of Queensland 
5 
% Earth Systems Science Computational Center (ESSCC) 
% Earth Systems Science Computational Center (ESSCC) 
6 
% http://www.uq.edu.au/esscc 
% http://www.uq.edu.au/esscc 
7 
% 
% 
255 
% 
% 
256 
The following PYTHON code is for the RayleighTaylor instability problem, which is available in the example directory as 'RT2D.py'. This script uses the 'StokesProblemCartesian' class for solving the Stokes equation, along with the incompressibility condition. A class called 'LevelSet' is also used, which performs the advection and reinitialization procedures to track the movement of the interface of the fluids. The details and use of these classes are described in Chapter \ref{MODELS CHAPTER} (Models Chapter). 
The following PYTHON code is for the RayleighTaylor instability problem, which is available in the example directory as 'RT2D.py'. This script uses the 'StokesProblemCartesian' class for solving the Stokes equation, along with the incompressibility condition. A class called 'LevelSet' is also used, which performs the advection and reinitialization procedures to track the movement of the interface of the fluids. The details and use of these classes are described in Chapter \ref{MODELS CHAPTER} (Models Chapter). 
257 


258 
The script starts off by importing the necessary classes. The physical properties of the two fluids are defined, such as density and viscosity. Acceleration due to gravity is taken as 10.0 $ms^{2}$. Solver settings are set for solving the Stokes problem, with the number of timesteps, solver tolerance, maximum solver iterations, and the option to use the Uzawa scheme or not; the default solver is the PCG solver. A regular mesh is defined with 200$\times$200 elements. Level set parameters are set for the reinitialization procedure, such as the convergence tolerance, number of reinitialization steps, the frequency of the reinitialization, for example, every third timestep, and the smoothing parameter to smooth the physical properties across the interface. A noslip boundary condition is set for the top and bottom of the domain, while on the left and righthand sides there is a slip condition. The initial interface between the two fluids is defined as in Figure \ref{RT2DSETUP}. Instances of the StokesProblemCartesian and LevelSet class are created. The iteration throughout the timesteps involves the update of the physical parameters of the fluids; the initialization of the boundary conditions, viscosity, and body forces; the solving of the Stokes problem for velocity and pressure; then the level set procedure. The output of the level set function, velocity and pressure is saved to file. The timestep size is selected based on the Courant condition. Due to the number of elements in the computational mesh, the simulation may take a long time to complete on a desktop computer, so it is recommended to run it on the super computer. At present, the fine mesh is required to capture the details of the fluid motion and for numerical stability. 
The script starts off by importing the necessary classes. The physical properties of the two fluids are defined, such as density and viscosity. 
259 

Acceleration due to gravity is taken as 10.0 $ms^{2}$. 
260 

Solver settings are set for solving the Stokes problem, with the number of timesteps, solver tolerance, maximum solver iterations, 
261 

and the option to use the Uzawa scheme or not; the default solver is the PCG solver. A regular mesh is defined with 200$\times$200 elements. 
262 

Level set parameters are set for the reinitialization procedure, such as the convergence tolerance, number of 
263 

reinitialization steps, the frequency of the reinitialization, for example, every third timestep, and the smoothing 
264 

parameter to smooth the physical properties across the interface. 
265 

A noslip boundary condition is set for the top and bottom of the domain, while on the left and righthand sides 
266 

there is a slip condition. 
267 

The initial interface between the two fluids is defined as in Figure \ref{RT2DSETUP}. Instances of the StokesProblemCartesian and LevelSet class are created. 
268 

The iteration throughout the timesteps involves the update of the physical parameters of the fluids; the initialization of 
269 

the boundary conditions, viscosity, and body forces; the solving of the Stokes problem for velocity and pressure; then the 
270 

level set procedure. 
271 

The output of the level set function, velocity and pressure is saved to file. 
272 

The timestep size is selected based on the Courant condition. 
273 

Due to the number of elements in the computational mesh, the simulation may take a long time to complete on a desktop computer, 
274 

so it is preferable to run it on the super computer. 
275 

At present, the fine mesh is required to capture the details of the fluid motion and for numerical stability. 
276 
% 
% 
277 
\begin{python} 
\begin{python} 
278 

