Shallow Water Equations:Variable Bed Topography Adam Riley Computer Science (with Industry) 2011/2012

Similar documents
Partial Differential Equations

Mid-Year Report. Discontinuous Galerkin Euler Equation Solver. Friday, December 14, Andrey Andreyev. Advisor: Dr.

1.2 Numerical Solutions of Flow Problems

Driven Cavity Example

NIA CFD Seminar, October 4, 2011 Hyperbolic Seminar, NASA Langley, October 17, 2011

Module 1: Introduction to Finite Difference Method and Fundamentals of CFD Lecture 13: The Lecture deals with:

An Investigation into Iterative Methods for Solving Elliptic PDE s Andrew M Brown Computer Science/Maths Session (2000/2001)

CFD MODELING FOR PNEUMATIC CONVEYING

Realistic Animation of Fluids

CS205b/CME306. Lecture 9

Computer Project 3. AA Computational Fluid Dyanmics University of Washington. Mishaal Aleem March 17, 2015

INTERNATIONAL JOURNAL OF CIVIL AND STRUCTURAL ENGINEERING Volume 2, No 3, 2012

Lagrangian and Eulerian Representations of Fluid Flow: Kinematics and the Equations of Motion

Final Report. Discontinuous Galerkin Compressible Euler Equation Solver. May 14, Andrey Andreyev. Adviser: Dr. James Baeder

Physics Tutorial 2: Numerical Integration Methods

Introduction to C omputational F luid Dynamics. D. Murrin

Essay 1: Dimensional Analysis of Models and Data Sets: Similarity Solutions

Homework 4A Due November 7th IN CLASS

Development of a Maxwell Equation Solver for Application to Two Fluid Plasma Models. C. Aberle, A. Hakim, and U. Shumlak

NUMERICAL INVESTIGATION OF THE FLOW BEHAVIOR INTO THE INLET GUIDE VANE SYSTEM (IGV)

BACK AND FORTH ERROR COMPENSATION AND CORRECTION METHODS FOR REMOVING ERRORS INDUCED BY UNEVEN GRADIENTS OF THE LEVEL SET FUNCTION

Faculty of Mechanical and Manufacturing Engineering, University Tun Hussein Onn Malaysia (UTHM), Parit Raja, Batu Pahat, Johor, Malaysia

Modeling and simulation the incompressible flow through pipelines 3D solution for the Navier-Stokes equations

Literature Report. Daniël Pols. 23 May 2018

Shallow Water Simulations on Graphics Hardware

Debojyoti Ghosh. Adviser: Dr. James Baeder Alfred Gessow Rotorcraft Center Department of Aerospace Engineering

The Immersed Interface Method

CHAPTER 6 Parametric Spline Curves

Lecture 1: Finite Volume WENO Schemes Chi-Wang Shu

Numerical Methods for (Time-Dependent) HJ PDEs

Chapter 6. Semi-Lagrangian Methods

Post Processing, Visualization, and Sample Output

Coupling of STAR-CCM+ to Other Theoretical or Numerical Solutions. Milovan Perić

A new multidimensional-type reconstruction and limiting procedure for unstructured (cell-centered) FVs solving hyperbolic conservation laws

Strömningslära Fluid Dynamics. Computer laboratories using COMSOL v4.4

Lagrangian methods and Smoothed Particle Hydrodynamics (SPH) Computation in Astrophysics Seminar (Spring 2006) L. J. Dursi

computational Fluid Dynamics - Prof. V. Esfahanian

Nonlinear Potential Flow Solver Development in OpenFOAM

Chapter 6. Petrov-Galerkin Formulations for Advection Diffusion Equation

Introduction to ANSYS CFX

Realistic Animation of Fluids

Shallow Water Equations

Realtime Water Simulation on GPU. Nuttapong Chentanez NVIDIA Research

Investigating The Stability of The Balance-force Continuum Surface Force Model of Surface Tension In Interfacial Flow

Domain Decomposition: Computational Fluid Dynamics

Thompson/Ocean 420/Winter 2005 Internal Gravity Waves 1

Domain Decomposition: Computational Fluid Dynamics

Shallow Water Equation simulation with Sparse Grid Combination Technique

Medical Image Segmentation using Level Sets

Traveling Wave Analysis of Partial Differential Equations

Adarsh Krishnamurthy (cs184-bb) Bela Stepanova (cs184-bs)

NUMERICAL SIMULATION OF THE SHALLOW WATER EQUATIONS USING A TIME-CENTERED SPLIT-IMPLICIT METHOD

Solution for Euler Equations Lagrangian and Eulerian Descriptions

The Level Set Method applied to Structural Topology Optimization

A Review of the Implicit Motion Solver Algorithm in OpenFOAM to Simulate a Heaving Buoy

Tutorial 1. Introduction to Using FLUENT: Fluid Flow and Heat Transfer in a Mixing Elbow

The WENO Method in the Context of Earlier Methods To approximate, in a physically correct way, [3] the solution to a conservation law of the form u t

Wave Hydro Dynamics Prof. V. Sundar Department of Ocean Engineering Indian Institute of Technology, Madras

ENERGY-224 Reservoir Simulation Project Report. Ala Alzayer

Development of the Compliant Mooring Line Model for FLOW-3D

First Steps - Ball Valve Design

Simulating Shallow Water on GPUs Programming of Heterogeneous Systems in Physics

Solution for Euler Equations Lagrangian and Eulerian Descriptions

NUMERICAL VISCOSITY. Convergent Science White Paper. COPYRIGHT 2017 CONVERGENT SCIENCE. All rights reserved.

Three Dimensional Numerical Simulation of Turbulent Flow Over Spillways

ATM 298, Spring 2013 Lecture 4 Numerical Methods: Horizontal DiscreDzaDons April 10, Paul A. Ullrich (HH 251)

On the order of accuracy and numerical performance of two classes of finite volume WENO schemes

FAST ALGORITHMS FOR CALCULATIONS OF VISCOUS INCOMPRESSIBLE FLOWS USING THE ARTIFICIAL COMPRESSIBILITY METHOD

A Hybrid Magnetic Field Solver Using a Combined Finite Element/Boundary Element Field Solver

Homogenization and numerical Upscaling. Unsaturated flow and two-phase flow

Axisymmetric Viscous Flow Modeling for Meridional Flow Calculation in Aerodynamic Design of Half-Ducted Blade Rows

Microwell Mixing with Surface Tension

Program: Advanced Certificate Program

Multigrid Solvers in CFD. David Emerson. Scientific Computing Department STFC Daresbury Laboratory Daresbury, Warrington, WA4 4AD, UK

FLUENT Secondary flow in a teacup Author: John M. Cimbala, Penn State University Latest revision: 26 January 2016

COMPUTATIONAL FLUID DYNAMICS ANALYSIS OF ORIFICE PLATE METERING SITUATIONS UNDER ABNORMAL CONFIGURATIONS

Parallel Adaptive Tsunami Modelling with Triangular Discontinuous Galerkin Schemes

Commercial Implementations of Optimization Software and its Application to Fluid Dynamics Problems

MESHLESS SOLUTION OF INCOMPRESSIBLE FLOW OVER BACKWARD-FACING STEP

Revision of the SolidWorks Variable Pressure Simulation Tutorial J.E. Akin, Rice University, Mechanical Engineering. Introduction

Approximating Square Roots

Simulation of Flow Development in a Pipe

Continued Investigation of Small-Scale Air-Sea Coupled Dynamics Using CBLAST Data

Simulating Sinkage & Trim for Planing Boat Hulls. A Fluent Dynamic Mesh 6DOF Tutorial

Using RecurDyn. Contents

FEMLAB Exercise 1 for ChE366

Optimizing Bio-Inspired Flow Channel Design on Bipolar Plates of PEM Fuel Cells

Fluid Simulation. [Thürey 10] [Pfaff 10] [Chentanez 11]

MATHEMATICAL ANALYSIS, MODELING AND OPTIMIZATION OF COMPLEX HEAT TRANSFER PROCESSES

Stream Function-Vorticity CFD Solver MAE 6263

CHAPTER 1. Introduction

Multi-Mesh CFD. Chris Roy Chip Jackson (1 st year PhD student) Aerospace and Ocean Engineering Department Virginia Tech

CFD Project Workflow Guide

The Study of Ship Motions in Regular Waves using a Mesh-Free Numerical Method

Lab 9: FLUENT: Transient Natural Convection Between Concentric Cylinders

Domain Decomposition: Computational Fluid Dynamics

Computational Fluid Dynamics for Engineers

An added mass partitioned algorithm for rigid bodies and incompressible flows

Module 1 Lecture Notes 2. Optimization Problem and Model Formulation

and to the following students who assisted in the creation of the Fluid Dynamics tutorials:

Transcription:

Shallow Water Equations:Variable Bed Topography Adam Riley Computer Science (with Industry) 011/01 The candidate confirms that the work submitted is their own and the appropriate credit has been given where reference has been made to the work of others. I understand that failure to attribute material which is obtained from another source may be considered as plagiarism. (Signature of student)

Summary The shallow water equations are a system of nonlinear partial difference equations used to model water flow, commonly used in coastal regions and rivers. Whilst generally well understood, with many simulation tools available, the equations contain many assumptions which limit the effectiveness of the computational models created. One such assumption is that of the bed topography, allowing only flat beds to be modelled. By adding additional terms to the equations, assumptions such as this can be relaxed, increasing the possible usage of the equations. The aim of this project is to implement an additional term, modelling variable bed topography, while preserving the physical features of the equations. To do this a balance must be created between the terms influencing the velocity of the water level, taking care not to create any addition forces. i

Acknowledgements I would like to thank my project supervisor, Matthew Hubbard, for his seemingly limitless patience with regards to even the simplest of mathematical issues and also his ability to translate literature into an understandable format. I would also like to thank my family and friends for their continued support and help in keeping me sane throughout the project. ii

Contents 1 Introduction 1 1.1 Aim........................................... 1 1. Objectives........................................ 1 1.3 Minimum Requirements................................ 1.3.1 Possible Extensions............................... 1.3. Relevance to Degree Programme........................ Background Research 3.1 Computational Fluid Dynamics............................. 3.1.1 Context..................................... 3.1. Applications.................................. 4. Shallow Water Equations................................ 4..1 Overview.................................... 4.. Potential Issues................................. 6.3 Scalar Advection Equation............................... 6.4 Burger s Equation.................................... 7.5 Computational Modelling................................ 7.5.1 Possible Methods................................ 7.5. Finite Difference Method............................ 7.5.3 Finite Volume Method............................. 8.5.4 Possible Schemes................................ 8.5.4.1 Upwind Scheme........................... 9.5.4. Lax-Friedrichs Scheme....................... 9.5.4.3 Lax-Wendroff Scheme........................ 9.5.5 Possible Solutions............................... 9 3 Methodology 11 3.1 Introduction....................................... 11 3. Plan........................................... 11 3.3 Iterations........................................ 13 iii

3.3.1 Linear Scalar Equation............................. 13 3.3.1.1 Initial Framework Requirements.................. 13 3.3. Non-linear Scalar Equation........................... 14 3.3.3 Non-linear Scalar Equation with Source Terms................ 14 3.3.3.1 New Framework Requirements................... 14 3.3.4 Non-linear System of Equations........................ 15 3.3.4.1 New Framework Requirements................... 15 3.3.5 Non-linear System of Equations with Source Terms.............. 15 3.3.5.1 New Framework Requirements................... 15 3.4 Testing.......................................... 15 3.4.1 Initial Conditions................................ 16 3.4.1.1 Smooth Profile............................ 16 3.4.1. Sharp Profile............................. 16 3.4. Boundary Conditions.............................. 17 3.5 Schedule......................................... 17 3.5.1 Milestones................................... 17 4 Implementation 0 4.1 Programming Language................................. 0 4. Scalar Advection Equation............................... 1 4..1 Upwind Scheme................................ 1 4.. Lax-Friedrich Scheme............................. 1 4..3 Lax-Wendroff Scheme............................. 4..3.1 First Step............................... 4..3. Second step............................. 4..4 Summary.................................... 4..5 Lax-Friedrich Scheme - Finite Volume Method................ 3 4.3 Burger s Equation.................................... 4 4.4 Artificial Equation................................... 5 4.4.1 First Attempt.................................. 5 4.4. Second Attempt................................. 5 4.4.3 Possible Solutions............................... 6 4.4.4 Finite Volume Method............................. 7 4.4.5 Summary.................................... 8 4.5 Shallow Water Equations................................ 9 4.5.0.1 Boundary Conditions........................ 30 4.6 Shallow Water Equations with Source Terms...................... 31 4.6.1 First Attempt.................................. 31 4.6. Second Attempt................................. 31 iv

5 Results & Evaluation 33 5.1 Scalar Advection Equation............................... 33 5.1.1 CFL Condition................................. 33 5.1. Results..................................... 33 5.1..1 Upwind Scheme........................... 35 5.1.. Lax-Friedrich Scheme........................ 36 5.1..3 Lax-Wendroff Scheme........................ 37 5.1.3 Summary.................................... 38 5.1.4 Evaluation................................... 38 5. Burger s Equation.................................... 38 5..1 Results..................................... 39 5.. Evaluation................................... 39 5.3 Artificial Equation................................... 40 5.3.1 Results..................................... 41 5.3. Evaluation................................... 4 5.4 Shallow Water Equations................................ 4 5.4.1 Results..................................... 43 5.4. Evaluation................................... 43 5.5 Shallow Water Equations with Variable Bed Topography............... 45 5.5.1 Results..................................... 45 5.5. Evaluation................................... 46 5.6 Conclusion....................................... 47 Bibliography 48 A Personal Reflection 50 B Materials Used 5 C Ethical Issues 53 D Revised Schedule 54 v

Chapter 1 Introduction 1.1 Aim To implement a well balanced computational model of the shallow water system of equations with a variable bed topography. 1. Objectives The objectives of the project are to: Understand the use of the shallow water equations and the benefits of computational models. To gain an understanding of partial differential equations and the mathematics used to solve such equations. Research the numerical methods used to approximate partial differential equations and the differences between them. To understand the issues when creating a computational model and the best methods to avoid these. To implement a series of equations, of increasing complexity, that build towards the shallow water equations with source terms. Evaluate the numerical methods used to create the models, in comparison to both exact solutions and known solutions from relevant literature. 1

1.3 Minimum Requirements The minimum requirements are: Implement an approximation for the scalar advection equation in 1 dimension. Implement an approximation of the shallow water system of equations without source terms in 1 dimension. Analyse the accuracy of the methods used. 1.3.1 Possible Extensions The possible extensions are: Implement an approximation of the shallow water system of equations with source terms in 1 dimension. Expand the computational model to higher dimensions while maintaining accurate results. Implement the shallow water equations using higher order schemes to increase accuracy. Add additional terms to the equations to relax assumptions such as the transport of sediment. 1.3. Relevance to Degree Programme The project builds upon both MJ1: Computational Modelling and TC3: Parallel Scientific Computing where the finite difference method was first introduced as a technique to approximate a possible solution to a mathematical problem. While TC3 looked at both parabolic and ecliptic partial differential equations, the project will extend this to look at hyperbolic equations.

Chapter Background Research.1 Computational Fluid Dynamics.1.1 Context Computational Fluid Dynamics(CFD) has grown from the research areas of both Fluid Dynamics and Computer Science and forms the main area of research for this project. For many years engineers have attempted to understand the characteristics of fluid flows with the hope of being able to accurately predict the properties that make up each trait. With the emergence of readily available computational power, the study of fluid flow has become easier and more effective. This has caused a major increase in the research of numerical techniques to actually solve the equations that are known to represent fluid dynamics. [7] In its most basic form CFD takes mathematical equations representing fluid flow, generally in the form of partial differential equations, and replaces them with numbers which allow us to advance forward in both space and time, giving us a numerical description at a given point [5]. There are three main stages needed to achieve this, these are: the theoretical model, the mathematical model, and the computational model. The theoretical model is the initial stage in which a theory is devised with the ability to predict all behaviours of a certain situation. The mathematical model stage represents these theories in mathematical equations. Finally the computational model is created, in which discretization methods are used to approximate these equations at discrete points in both time and space [7], allowing for algorithms to be successfully developed to solve the mathematical equations. The creation of a computational model is my main area of research for this project and therefore I will be investigating in detail the discretization methods used to transition to this from a mathematical model. 3

.1. Applications CFD has allowed for the creation of many accurate computation models that represent the behaviour of fluids. These can be applied to different situations such as the design of pipe systems, coastal modelling, and tsunami modelling [7, 18]. With regards to tsunami modelling, there are very obvious benefits associated with the use of computation models as they allow for the risk free simulation of otherwise lethal situations. Predictions can then be made on the best possible prevention techniques to minimise the loss of life, infrastructure, and property of the affected communities. Advantages also include the ability to accurately recreate past situations, such as the tsunami which drastically affected Thailand on the 6th December 004. Within simulation tools, variables can be set to constant values without any interference allowing for greater control, unlike if the event was recreated physically [7]. It is also worth noting that it would be infeasible to recreate situations such as the tsunami mentioned due to the resources that would be necessary and the costs involved. Fluid simulation tools allow for a feasible solution.. Shallow Water Equations..1 Overview The shallow water equations are a non-linear system of hyperbolic partial differential equations used to describe free surface flows. They are derived from the Navier-Stokes equations, a more complex set of equations to describe the motion of fluid, and assume that the vertical length scale is small in comparison to the horizontal equivalent [3, 15]. While being a relatively simple mathematical model, the equations are deemed suitable for use in applications, for example the early stages of a tsunami where the profile of the wave fits within the assumption of the equations due to the size of the wave with respect to the depth of the ocean. In one dimension they take the form: d t + du x = 0 (.1) ( ) du + gd d t + = 0 (.) x In the equations the depth of water is represented by d while u represents the flow velocity and g represents acceleration due to gravity. Finally t represents time while x is the representation of space. As previously mentioned the system of equations are hyperbolic, which simply can be thought of in one dimension as a time-dependant, conservative physical process while not converging towards a steady state [13, 1]. Like many important problems within mathematical physics, the equations in- 4

volve conservation laws [1]. With regards to the shallow water equations, the conservation of mass and conservation of momentum are accounted for. Equation.1 can be thought of as representing mass while equation. similarly momentum [3]. Unfortunately the equations assume a flat bed in the above state. To relax this assumption a source term, gdz x, needs to be added to equation., allowing for a variable bed topography. This takes the form: d t + d t + du x = 0 (.3) ( ) du + gd x = gd b x (.4) The only new term is that of the bed, b, representing the height of bed at point i. The above system still makes some assumptions though such that both wind and the earth s Coriolis force, essentially the effect of the earth rotating, have no effect on the free surface of the fluid although this is appropriate for the scope of the project [15]. Figure.1: Cross-section of a river 5

.. Potential Issues By adding a source term to the shallow water equations, the variable bed topography, it is of vital importance to maintain the accuracy of the model being used. Sang-Hoen Lee and Nigel G. Wright [19] explain the need for an exact balance between flux and source terms, stating how numerical errors can occur when approximating values unless the computational model is well balanced. This would cause obvious problems when attempting to model a state of equilibrium as this state is dependant on the solution being balanced. For example, flat still water [10] depends on: (d + b) x = 0 (.5) When thought about physically this makes sense as the depth of the water would adjust itself based on the height of the bed directly below it, levelling out naturally due to the gravitational force acting upon it. To achieve a well balanced solution it is necessary for the source and flux terms to be approximated using the same data and also for the discretization to be performed in the same manner for both terms. This can be difficult though as source terms are often complicatedly defined and discretization methods designed for use without source terms [19]. A second potential issue to consider is how to maintain the conservative nature of the shallow water equations. The conservation equation of mass states how mass can be neither artificially created or destroyed, while Newton s second law of motion states how the total momentum must be the sum of all the forces applied to the mass [7]. It is essential to the accuracy of the model that these laws are still valid once an approximation has been made..3 Scalar Advection Equation The scalar advection equation is widely regarded as the simplest true partial differential equation and as such is a good example to use when learning about discretization methods [13, 9].It is a linear homogeneous hyperbolic equation which takes the form: u t + a u x = 0 (.6) where a is a nonzero constant representing velocity. The equation allows exact solutions to be calculated extremely easily [13], therefore analysis of the methods used can be simply formulated. 6

.4 Burger s Equation Burger s equation is also a scalar homogeneous equation although, unlike the scalar advection equation, it is non-linear and therefore the velocity is calculated based on u itself rather than stated like in equation.6 [?]. It takes the form: u t + F(u) = 0 x for t > t 0 (.7) Where F(u) = u Burger s equation can also be defined in another form as: u t + u u x = 0 (.8) This second form can be proven as equivalent by the chain rule and it shows the similarity to the form of scalar advection equation, only equation.7, known as the inviscid form, is conservative and as this is an aim of the project only this form shall be considered..5 Computational Modelling.5.1 Possible Methods To convert a mathematical model, such as the shallow water equations, to a computational model a discretization method is needed so values within the domain can be approximated. There are three main approaches which are: finite difference method, finite volume method, and the finite element method. Each method allows the problem to be split into a set of discrete values in both space and time [7]. For this project two of the methods mentioned will be considered, the finite difference method and the finite volume method. The finite element method, while possible, is not recommended for hyperbolic PDEs due to it originally being designed with parabolic and elliptic equations in mind [0]..5. Finite Difference Method Introduced by Euler in the 18th century, the finite difference method is the oldest method for discretizing PDEs [7]. It is also the easiest method to use with regards to simple geometries, such as a one dimensional uniform line which will be used for the project. The method layers a grid over the problem domain, essentially sampling the continuous data at each grid point. This replaces the partial 7

derivatives by approximations, of which can be used to further approximate in time. Figure.: Finite difference method on a 1 dimensional uniform grid. Each point in figure. can be thought of as the density at that given point..5.3 Finite Volume Method The finite volume method is arguably the most common method used within CFD [19]. The method possesses a physical meaning which relates nicely to hyperbolic PDEs. The method splits the problem domain into a finite number of contiguous control volumes and as such the conservation equations are applied to each [7]. In the example of a one dimensional uniform grid, the method can simply be thought of as having a flow in value and a flow out value. These values appear on the boundaries of the control volumes. Figure.3: Finite volume method on a 1 dimensional uniform grid. We can see by comparing Figures. and.3 how the finite volume method can be thought of as looking at the whole space rather than just at set points. While both methods produce a finite set of values, each point within the finite volume method shares a boundary with its neighbouring point. Because of this, unlike the finite difference method, the method can not artificially create or destroy any mass and as such ensures the approximation is conservative [7]. The finite volume method is also better suited to varying geometries and therefore would be a better method to use if considering whether to expand past one dimension..5.4 Possible Schemes Once a mathematical model has been discretized we are able to approximate new values assuming both initial and boundary conditions have been stated. Using either the finite difference method or finite volume method, a scheme is necessary to decide which other points within the domain will influence our approximation. There are three possible schemes which can be applied to either approximation method. These are the first-order upwind, Lax-Friedrichs, and Lax-Wendroff schemes. While other schemes could provide better levels of accuracy, for the scope of the project these are suitable. 8

.5.4.1 Upwind Scheme The first-order upwind scheme is extremely simple when applied to a scalar equation although there is extra complexity when used with a system of equations [1]. The scheme approximates both space and time. Space is approximated by using the values upwind, in the opposite direction of the flow. This is a natural approach when considering water as you would general expect to look upstream to make any form of prediction. Time is is approximated using the explicit forward Euler method [13]. The scheme is first order accurate with respect to both space and time..5.4. Lax-Friedrichs Scheme Like the Upwind scheme, the Lax-Friedrichs scheme is first order accurate with respect to both space and time. The scheme itself is popular for use with general nonlinear flux functions [1]. The scheme approximates space using a central difference approach using all neighbouring nodes to predict a new value. With regards to time, the scheme again looks at neighbouring values to predict forward in time. Due to the scheme taking into account more values than the upwind scheme, the approximations made normally smooth out any discontinuous values..5.4.3 Lax-Wendroff Scheme Unlike the first two schemes, the Lax-Wendroff scheme is second order accurate with regards to both space and time. Unfortunately though the scheme has a tendency to produce unwanted oscillations around areas of discontinuous values [9]. The scheme can also be thought of as a two step method, first approximating half a step in time forward before using these results to produce the final approximation [1]. While the increase in accuracy would be good for an overall solution, the unnecessary complexity only complicates the two main issues to be solved, as such the scheme won t be considered for the majority of the project..5.5 Possible Solutions Several potential solutions to balancing source and flux terms have been suggested within the field of CFD [6, 10]. The possibility of modifying the source terms into the form of a flux is one method [19]. By doing this, simple schemes designed for no source terms should still be able to be applied as the equations will take the homogeneous form of the shallow water equations once again. This is done by first applying the scheme to the flux term as the scheme had been initially designed and then attempting to approximate the source terms in a similar fashion. This method, if done correctly, preserves the properties of scheme such as conservation. This allows common schemes already proven for the homogeneous version of the shallow water equations to be implemented, minimising the potential for error as much research has been done into the successful schemes. S.H.Lee and N.G.Wright implement these using the finite volume method, as a way to ensure conservation although higher order schemes such as Riemann solver-based schemes are used. 9

Another potential solution is to model the local energy loss terms associated with a varying bed topography [6]. Values represent the change in bed height at each boundary of x allowing the surface gradient method to be implemented to reconstruct the water depth level for each node. Again this is implemented using a higher order Riemann Solver, resulting in an accurate computational model. A third method is introduced by R.J.Leveque based on the wave-propagation algorithm [17]. A new discontinuity is introduced at each node which when calculated using the finite volume method gives a value for either cell boundary with the idea that the left boundary minus the right boundary will equal the source term when calculated. As such the approximation for the source term can be created based on this assumption. Again this method bases the approximation of the source term on the way in which the flux term has been approximated. The method though does not work with fractional step methods, limiting the possible schemes that can be used. The solution does prove that a steady state can be held, and as such the conservative property is maintained in this case. The method that will be attempted is that of approximating the source terms in the most similar fashion possible to the flux term in hope that when the terms are equal they will cancel out. This will be done using the finite volume method in an attempt to ensure the scheme implemented is also conservative. 10

Chapter 3 Methodology 3.1 Introduction To produce a computational model of the shallow water Equations discussed in Chapter it is of vital importance that an appropriate plan is created, allowing the project to progress at a steady rate while still maintaining a high standard of work. During the background research stage of my project several different software process models were investigated including the Waterfall and Iterative Development models [4]. While each different model offered advantages in how to undertake my project, none was a perfect fit. This was due to the project being relatively short term, involving only one developer. Many of the methodologies, such as the Waterfall model, are designed with large teams in mind and as such included extra steps to compensate for this. Rather than select one predefined methodology, elements from different ones have been used to form the most logical plan of work. 3. Plan Drawing inspiration from the Iterative Development model a plan has been created involving several intermediate stages between an initial prototype and the final implementation of the shallow water equations. Each iteration will add a new element to the initial prototype allowing for a steady progression in difficulty and simpler error identification due to a smaller number of new features, in turn resulting in more efficient debugging sessions, essential for short term projects. As the shallow water equations are relatively difficult, to begin with other PDEs will also be used, mentioned in Chapter, which have similar characteristics. In brief, each iteration will involve either 11

a modification of a current equation or a new different equation/system of equations which allows for new features to be explored. Based on this, the framework produced for the initial prototype may also be updated to incorporate new requirements at each stage. When designing a plan it has become apparent that several different paths could be taken, both producing the same end product, differing only by the order in which each stage is completed. Figure 3.1 shows two different options available: Figure 3.1: Possible iteration paths. The iterative nature of the plan allows for either source terms to be introduced as a new concept first 1

or the transition from a scalar equation to a system. The decision to explore how source terms can be treated first has been made, following the left-hand side path of Figure 3.1, due to the fact that the project s main goal is to investigate how to balance the flux and source terms of the PDEs. This means that if any issues do arise that slow the project down, the area can still be explored to some degree. Also by looking at this feature first, it should assist with the ongoing research of the project as key ideas can be trialled at an earlier stage to help gain a greater understanding. 3.3 Iterations 3.3.1 Linear Scalar Equation The first iteration will be an initial prototype which will allow for the basic framework of code to be created and several different schemes to be tested. For this reason, the scalar advection equation will be used due to it simplistic nature. While implementing the PDE will be a useful exercise, the focus will primarily be on the implementation of the framework to reduce additional work in future iterations. This iteration will also allow for some preliminary results to be shown during the presentation to the Scientific Computing research group. The schemes which will be used to create the computational model are: Upwind Scheme Lax-Friedrich Scheme Lax-Wendroff Scheme Each scheme will be implemented using the finite difference method, with the possibility of the finite volume method also being implemented to demonstrate its advantageous conservative properties although this will be considered only as an extra, and be dependent on the level of background research completed. At this stage a decision will be made as to which scheme will be used for the remaining iterations of the project. 3.3.1.1 Initial Framework Requirements Input for all variables including the calculations of the size of dt and dx from the given maximum and minimum values of x and the number of specified time steps and final time. Arrays should be created to store u at both the current and previous time-step. No scheme requires previous values more than one time-step back and therefore older values can be disregarded to save memory. The ability to specify initial conditions for u. Boundary conditions must be present. For the basic framework both left and right boundaries will be set to zero although this should hopefully be improved in further iterations. 13

The framework should advance forward in time plotting the resulting U at each time-step to create a graph with an animation-like effect. All graphs should be labelled appropriately including a legend where necessary and correct axis titles. In the case where exact solutions are known, these should be calculated for the desired output time and plotted alongside the computational model. 3.3. Non-linear Scalar Equation The conservative inviscid form of Burger s Equation will be used for the second iteration as the nonlinear attributes associated with the Shallow Water equations are present. The equation will also provide a solid base for the third iteration of the project. The finite difference method will be used to implement the equation while no new framework requirements are needed for this iteration. 3.3.3 Non-linear Scalar Equation with Source Terms An artificial equation, designed by Matthew Hubbard, will be used here based on Burger s equation. The equation differs as source terms are present and takes the form: u t + F(u) = S x for t > t 0 (3.1) Where F(u) = u and S = u b x While the equation has no real physical meaning, it will hopefully allow for the creation of a wellbalanced scheme, with the goal of a steady state, where the profile of u will not change from the predefined initial conditions throughout time, being introduced when u is equal to b. At this stage, the equation will definitely be implemented using both the finite difference and finite volume methods. The finite difference method will be used first to ease the transition from the second iteration before converting the solution to finite volume form. The finite difference method is used until this point due to its simplicity, allowing for an easy introduction to the implementation, although as the finite volume method ensures conservation, it is vital it is introduced before the equation becomes too difficult, again to allow for an easier introduction to the method. 3.3.3.1 New Framework Requirements An additional array should be created to store the new source term, b. 14

3.3.4 Non-linear System of Equations For this iteration the transition to a system of PDEs will take place, using the homogeneous form of the shallow water equations as the system of choice to implement. At this point only the finite volume method shall be implemented. While the step up to a system of equations should not provide too many new challenges, this iteration will allow for any bugs to be discovered, and corrected, before the most difficult step of balancing the flux and source terms is introduced for a system. 3.3.4.1 New Framework Requirements New arrays should be created to store both momentum, du, and the water depth level, d. A new variable to store the value of gravity. Boundary conditions should be improved by adding the option of a reflective boundary in addition to simply letting the flow appear to continue outside of the specified domain. 3.3.5 Non-linear System of Equations with Source Terms Finally the Shallow Water equations with source terms representing a variable bed topography will be implemented using the finite volume method. This iteration should consist of features from each of the previous iterations as the system of equations is similar in theory to a system combining the scalar advection equation with the artificial equation used during the third iteration. Because of this reason, the choice of equations in previous iterations is further justified. 3.3.5.1 New Framework Requirements A new array should be introduced to store the bed level at each node. The ability to specify initial conditions for the bed, b. The profile of the bed should be plotted to the graph alongside the water depth level to visualise the solution. 3.4 Testing During the implementation stage of the project basic testing will take place at the end of each stage to confirm the completion of an iteration while a full evaluation of each model will take place once the final model has been implemented, detailed in Chapter 5. Basic testing will consist of a qualitative evaluation based on two different sets of initial conditions. These conditions can also be applied to the bed profile in the final stage. While the implementation of the models will aim to be as computationally efficient as possible, this is not the main aim of the project as faster, more complex schemes are known to exist. Due to this reason, each iteration will be deemed acceptably efficient as long as 15

the script can be run in a reasonable amount of time within the Dec-10 lab environment. Extra testing will be done during the initial prototype stage in order to decide which scheme to use for the future iterations. This will involve calculating the root mean square of the error in comparison to the calculated exact solution. This will be explained in more detail in Chapter 5. 3.4.1 Initial Conditions Two different sets of initial conditions shall be used to test each stage. These will be a smooth case and a sharp, discontinuous case. By applying the two varying conditions all possible conditions for the models should be covered as the smooth profile should show the regular behaviour that can be expected from the literature while the sharp profile will be used to test for any non-physical artifacts due to the fact that oscillations, a common source of negative values, are more likely near areas of discontinuous data. 3.4.1.1 Smooth Profile (cosπ(x 3 u init = ) ) if 1 x 0 otherwise (3.) Figure 3.: Initial profile for smooth test case. 3.4.1. Sharp Profile 1 if 1 x u init = 0 otherwise (3.3) 16

Figure 3.3: Initial profile for discontinuous test case. 3.4. Boundary Conditions To begin with the boundary conditions used will take the form of Dirichlet boundary conditions[11]. The values will be set to zero to simulate any flow continuing outside of the specified domain. Due to this reason all initial conditions shall be configured at a suitable distance from the boundary to avoid any possible issues although the boundaries will be tested fully during the final evaluation, allowing for the profile to be positioned anywhere within the domain. 3.5 Schedule A schedule has been created, showing the projected timescale of each task, to assist with the time management of the project. A decision was made to structure the project such that both implementation and background research tasks would run along side each other based on the discussion offered during the Scientific Computing seminars. This approach was preferred as the implementation tasks would aid the understanding of the overall problem and therefore allowed a greater understanding of relevant literature. Any modifications to the schedule will be presented in Appendix D. 3.5.1 Milestones Three milestones have been set for the project as a method of being able to measure the amount of progress made, and whether the schedule needs to be revised. The milestones relate to the overall objectives set in Chapter 1. They are as follows: 17

1. Week 5 - Research Group Presentation: The linear scalar equation should have been implemented with presentable results against an exact solution.. Week 6 - Mid Project Report: Background research into PDEs and what methods are used are used to approximate them should be completed. 3. Week 1 - Progress Meeting: All implementations should be available to demonstrate. While the first two milestones were achieved, the third was incomplete due to a small number of bugs within the final implementation still remaining at the time of the meeting. This did not affect the overall progress of the project though as solutions were found as a result of the meeting, allowing progress to be maintained. 18

Task Week Minimum Aims and Requirements Background Reading Numerical Methods Shallow Water Equations Mathematical Understanding Presentation Mid Project Report Implementation Scalar Advection Equation Scalar Equation with Source terms Shallow Water Equations without Source terms Shallow Water Equations with Source terms Shallow Water Equations ( nd iteration) Analysis of Methods Evalution of Methods Write-up Introduction Background Research Methodology Implementation Evaluation Contingency 1 3 4 5 6 7 8 9 10 11 1 13 14 15 16 Figure 3.4: Project Schedule 19

Chapter 4 Implementation 4.1 Programming Language Before the implementation began, a decision had to made with regards to which language would be used to implement the computational models produced. The choice was initially narrowed down to three possibilities: MATLAB C Java Both MATLAB and C are common within the scientific computing community, offering a a wide range of mathematical functions with a high level of accuracy, while experience of Java had been gained throughout the course, nullifying the need to learn the fundamental concepts and syntax of the language once more. Due to this, Java was selected to build the prototype although it was clear this was a flawed choice as the time gained was soon lost due to the level of accuracy to represent numbers causing rounding errors when t was too small a value. Also with no simple tools available to visualise the data, there was a need to write the data to a file which could then be plotted by MATLAB. This would also not allow for the animation-like effect as only the final values would be passed, rather than for each time step as this would have resulted in overly large files. As a result of these points, the decision was made to use MATLAB as the ability to handle maths easily plus the ability to plot data using in-built functions outweighed the need to learn the necessary syntax. While C was considered due to its faster speed, little previous experience with language meant it was not a 0

suitable choice. Also while the speed would have been an obvious advantage, the efficiency of the computational models is not the focus of the project. 4. Scalar Advection Equation As this was the first iteration of implementation, the initial framework was first created. This was completed within the allotted time(within the scalar advection equation task of the schedule), with few issues. The framework is designed around two main loops, a time loop and a space loop, within the space loop. An animation-like effect was then easily created by plotting the results at the end of each time step. 4..1 Upwind Scheme The first scheme to be implemented was the upwind scheme. As it was assumed the flow would always be directed left to right, this took the form: u n+1 i u n i t + a un i un i 1 x = 0 where a > 0 (4.1) which when rearranged allowed u n+1 i to be updated for the next time step: u n+1 i = u n i ta un i un i 1 x As the upwind scheme produces its approximation by looking upstream if a was less than zero, the scheme would take a different form: (4.) u n+1 i u n i t + a un i un i+1 x = 0 where a < 0 (4.3) which when rearranged allowed u n+1 i to be updated for the next time step: u n+1 i = u n i ta un i un i+1 x This is because the flow would now travel from right to left. The only difference is how the space approximation is made, evaluating point i + 1 rather than i 1. In the case of a equal to zero, either scheme would be appropriate as the space approximation would be cancelled out although this simulation is unlikely to be run as the result can easily be formulated by the mathematical model. (4.4) 4.. Lax-Friedrich Scheme The second scheme to be implemented was the Lax-Friedrich scheme, this took the form: 1

u n+1 i un i+1 +un i 1 + a un i+1 un i 1 = 0 (4.5) t x which when rearranged allowed u n+1 i u n+1 i to be updated for the next time step: = un i+1 + un i 1 a t ( ) u n i+1 u n i 1 x (4.6) 4..3 Lax-Wendroff Scheme The final scheme to be implemented was the Lax-Wendroff scheme which involved two steps as u n+ 1 i+ 1 first had to be calculated. While u n+ 1 should also have to be calculated, this was simply done due to i 1 the fact that the right boundary at point i was also the left boundary at point i + 1, and therefore could be stored for the next iteration within the space loop. 4..3.1 First Step u n+ 1 i+ 1 un i +un i+1 1 t + aun i+1 aun i x = 0 (4.7) which when rearranged allowed u n+ 1 i 1 u n+ 1 i+ 1 to be updated for the second step: = un i + un i+1 t ( ) au n i+1 au n i x (4.8) 4..3. Second step When approximated the second step took the form: u n+1 i u n i t + au n+ 1 i+ 1 au n+ 1 i 1 x = 0 (4.9) which when rearranged finally allowed u n+1 i u n+1 i = u n i a t x to be updated for the next time step: ( ) u n+ 1 u n+ 1 i+ 1 i 1 (4.10) 4..4 Summary Based on the results of these three schemes, which are documented within Chapter 5, the Lax- Friedrich scheme was chosen to be used for all future iterations. While the Lax-Wendroff scheme performed the best overall, oscillations were formed on the tail of both profiles, as seen in figure 4.1

a common trait of the scheme, which would likely cause non-physical artifacts when used with the shallow water equations. Due to this reason this scheme was disregarded. While the upwind scheme also out performed the Lax-Friedrich scheme, a requirement of the scheme is the direction of the flow which while simple in this case, is much more complex for the shallow water equations. On the other hand the Lax-Friedrich scheme takes information from both sides of point i, therefore there is no need to compute the direction of the flow making the transition between equations smoother. Also as the main aim of the project is to form a well-balanced, conservative scheme, the choice of scheme is not essentially vital to the process as the concepts should be transferable to more accurate scheme then the three trialled here. Figure 4.1: Possible non-physical artifacts created by the Lax-Wendroff Scheme. 4..5 Lax-Friedrich Scheme - Finite Volume Method As a simple introduction to thinking about the equations in a finite volume sense, the decision was made to implement the scalar advection equation using the finite volume method. This would also prove if the computational model produced by the finite difference method, 4.6, was in fact conservative. When applied the equation took the form: 3

u n+1 i un i+1 +un i 1 t + u n+1 i un i+1 +un i 1 t f n i+ 1 f n i 1 x = 0 where f (u) = au (4.11) f = (au) i+1+au i i+ 1 f i 1 = (au) i+au i 1 + a x ( u n i+1 un i 1 ) = 0 which when rearranged finally allowed u n+1 i u n+1 i = un i+1 + un i 1 to be updated for the next time step: a t ( ) u n i+1 u n i 1 x (4.1) As can be seen when comparing equations 4.6 and 4.1, they are identical, proving that the finite difference method produced a conservative scheme. While the method was successful on this occasion, this is not always the case and therefore the finite volume method also continued to be used throughout the future iterations. 4.3 Burger s Equation The finite difference method was again used first to implement a computational model of Burger s equation using the Lax-Friedrich scheme. This took the form: u n+1 i un i+1 +un i 1 + ( u )n i+1 ( u t x )n i 1 = 0 (4.13) which when rearranged allowed u n+1 i u n+1 i to be updated for the next time step: = un i+1 + un i 1 t ((u ni+1) (u ni 1) ) 4 x (4.14) As this model was implemented ahead of schedule the finite volume method was again used to test the conservative property of the model. Similar to the scalar advection equation, when the method was applied the outcome matched the finite difference implementation, equation 4.13, thus proving the scheme was conservative. 4

4.4 Artificial Equation 4.4.1 First Attempt As this equation is essentially Burger s equation with an added source term, the same approximation was made with regards to both time and the flux term as equation 4.13, with the only new approximation being that of the new source term which was done naively to begin with to see how well this would perform. As such the value u within the source term was approximated as simply the current value of u at point i. All this was done using the finite difference method at this stage. This took the form: u n+1 i un i+1 +un i 1 + ( u )n i+1 ( u t x )n i 1 = u n i b n i+1 bn i 1 x (4.15) Initial testing of this computational model though showed no balance property for the scheme as when b was equal to u the profile for both the smooth and sharp cases did not show the expected outcomes, for either profile not to move. Due to this a second attempt was made, approximating the source term in the most similar fashion to the flux term as possible. 4.4. Second Attempt To attempt this method the way in which the flux term was approximated was firstly evaluated to see if it could be approximated in a way that would suit the source term without taking away from the accuracy of the current method. This was done by separating the squared values into two via factorisation, with the second mirroring the way in which b was approximated during the first attempt, only in this case approximating u. This took the form: t ((u ni+1) (u ni 1) ) = t 4 x ( u n i+1 u n i 1 )( u n i+1 u n ) i 1 x (4.16) From this, the source term was able to be approximated in a similar way. Now approximating u in the same way as the flux term meaning that the only difference between the flux and source term was that the flux term approximated u while the source term approximated b. This meant that in theory if b was equal to u then a perfect balance would be created as expected. This all took the form: u n+1 i un i+1 +un i 1 + t ( u n i+1 u n i 1 )( u n i+1 u n ) i 1 = x ( u n i+1 u n i 1 )( b n i+1 b n ) i 1 x (4.17) which when rearranged allowed u n+1 i to be updated for the next time step: 5

ui n+1 = un i+1 + un i 1 t ( u n i+1 u n i 1 )( u n i+1 u n ) i 1 + t x ( u n i+1 u n i 1 )( b n i+1 b n ) i 1 x (4.18) When implemented the computational model successfully produced the well-balanced property expected, the initial profiles for both the smooth and sharp cases did not move to the right as they would if the scheme was still not balanced. Unfortunately initial testing highlighted an error in the use of the Lax-Friedrich scheme when attempting to create a well balanced scheme. When the flux and source terms cancelled one another out the approximation left takes the form: u n+1 i = un i+1 + un i 1 (4.19) This meant that when b was equal to u, both test profiles would smooth out due to the average of approximations either side of point i being used to approximate the new value at point i. While this solution would be accurate in the case of a straight line as the profile, as the average would still be equal to the current value of u at point i, this is a unique case and as such a solution was necessary to provide an accurate model. 4.4.3 Possible Solutions One possible solution to the smoothing problem was to implement a different scheme where the time approximation included the term u n i. One option was the upwind scheme although due to issues already discussed this was not an ideal solution. Instead the concept of η was introduced as a possible fix []. This would allow for the term u n i to be introduced, satisfying the current problem, whilst also introducing the new term η to the time approximation. When implemented this took the form: u n i+1 + un i 1 = u n i + ηn i+1 ηn i + η n i 1 where η = u b and u b = constant (4.0) When the new time approximation was used within equation 4.18, the scheme still possessed the wellbalanced property between the flux and source terms previously implemented and now successfully showed the correct behaviour, no change to the initial profile, when b was equal to u. This is because as η is equal to b u, when these are the same value, they cancel out meaning η is zero. Simply leaving the desired term u n i on the RHS. Due to this unexpected discover, more time then expected was taken to complete the task, meaning the initial schedule was revised to reflect this. This can be seen in Appendix D. Also at this stage 6

the original framework used was updated to a much cleaner format including initial conditions being set outside of the main loops and both loops now iterating based on whole numbers as apposed to the value of t and x respectively. The main addition was the inclusion of ghost cells, as a method for handling boundary conditions. This involved two extra nodes being created either side of the specified domain. While not plotted, this meant the nodes could be updated for each time step, allowing for more complex boundary conditions to be implemented if necessary, and the need for only one set of equations within the main loops, minimising errors. 4.4.4 Finite Volume Method The artificial equation was also implemented using the finite volume method as this would ease the transition to the shallow water equations where only the finite volume method was used. As a balance again had to be created between the flux and source terms, the flux term was evaluated first whilst the time approximation remained unchanged from equation 4.0. This allowed for the source term approximation to be created to match that form of the flux term. The flux term took the form: f f i+ 1 i 1 x where f = u (4.1) (( 1 u ) ( i+ u )) 1 i 1 x where u i± 1 = u i + u i±1 The flux term was then again factorised, producing a representation that also suited the format of the source term. This took the form: ( u n + u n )( i+ 1 i u n u n ) 1 i+ 1 i 1 x Meaning that the source term could be approximated in similar form, only replacing the approximation of u at point i with that of b. This took the form: ( u n + u n )( i+ (ub x ) i = 1 i b n b n ) 1 i+ 1 i 1 where b x i± 1 = b i + b i±1 (4.) which when added to the time approximation and flux term allowed u n+1 i time step: to be updated for the next ui n+1 = u n i + ηn i+1 ηn i + ηi 1 n ( u n u n )( i+ t 1 i u n u n ) ( 1 i+ 1 i u n u n )( 1 i+ + t 1 i b n b n ) 1 i+ 1 i 1 x x (4.3) 7