Introduction to Finite Differences
and
Spring 2021
Finite Elements in the Geosciences
Instructors:
More Information:
Over the last
several decades, computing has played an
increasingly important role in the earth sciences. This trend has developed
along with the rapid increase in computational power
available to scientists, as well as the increasing
availability of numerical codes that can be used to
solve problems. However, to use these numerical
codes effectively, scientists must have a basic
understanding of how these codes work. This class
will introduce students to basic numerical
approaches to solving problems in the earth
sciences. We will focus primarily on finite
difference and finite element methods. Example
problems will be insprired by
the solid earth geopysics, but will be general enough
that the understanding gained from this class can
be used in broader fields of the earth sciences.
Required Texts:
Recommended Texts:
Class Meetings:
Tentative Future Schedule (subject to change):
Homework: To catch up to speed on programming in Python, we
will read the first several chapters of S20 and/or LL20. Please tell
us which book you find more useful for this introduction.
Summary: We decided to proceed using LL20,
starting with Chapter 6. The earlier chapters of LL20 and the
entirety of S20 are useful references for implementing Python code,
and it would be useful to read them and implement some of the
examples. We do not plan to go through these chapters in detail,
unless we need to learn something specific from them.
Homework: For next time, read LL20 Chapter 6:
Computing Integrals and Testing Code. Carefully and write your own
Python codes to implement the examples in this chapter. For a
specific exercise, compute the integral of the sine function from 0
to pi (as in exercise 6.4a on page 169) using your own code to
implement the trapezoidal and midpoint methods. Make your own
version of the table on page 145, showing how the solution changes
as you increase n. For a bonus application, try implementing the
monte carlo method to solve this integral. Be prepared to share your
code, and to demonstrate how it works, with the group (e.g., using
share screen on Zoom).
Read Ahead: Next time, we will continue with LL20
Chapters 7 and 8. It would be a good idea to familiarize yourself
with these chapters in advance of our next meeting.
Summary: We talked about methods for numerical
integration (LL20 Chapter 6), using trapezoid rule and the midpoint method. We
discussed the monte carlo method, and generally talked about
programming techniques.
Homework: For next time, read LL20 Sections 8.1-8.3.
These sections give an introduction to writing code to solve
ordinary differential equations, with applications to exponential
problems. Please write code to implement the problems discussed in
these sections. Exercises 8.1-8.3 on pages 273-274 will help with
this.
Summary: We went through LL20, sections 8.1 to 8.3
and discussed some examples from the exercises assigned.
Homework: For next time, read sections 8.4 and 8.5 of LL20
(osciallating problems), and do exercises 8.9 and 8.11.
Summary: We went through LL20, sections 8.4 to
8.5. We reviewed the differences between the Forward Euler method and
more advanced finite difference methods such as Euler-Cromer (first
order) or Runge-Kutta (second or even fourth order) methods. We tested
our codes to see how the solution is affect by changing resolution.
Homework: For next time, read chapter 9 of LL20
(partial differential equations) and prepare a coding solution for exercise
9.2b.
Summary: We went through LL20, chapter 9. We
reviewed the diffusion equation, and how it is implemented in
finite-differences. We payed special attention to the boundary
conditions, including how they are implemented in the finite
difference solution. We discussed the temporal resolution (time step
size) that is necessary to obtain a stable solution, for a given spatial
resolution.
Homework: For next time, we begin the LL17 book,
which goes into more detail about finite difference methods. We start
with Chapter 1 (vibrational problems), sections 1.1 to 1.7. The book
goes into more detail than we need about some of the methods. Thus,
you can pass through the following subsections relatively quickly:
1.3.2-1.3.5, 1.4.6, 1.5.6, 1.74.
We will not assign an exercise this week, so we can focus on the
methods. However, it would be good to familiarize yourself with some
of the codes associated with this chapter, and try to get some of them
to work. Here is the website that provides some code for this book: [LL17
codes]
Note that the relevant code for this chapter can be found using the
"vib" link.
Summary: We went through LL17, chapter 1. We
discussed the stability or instability of finite difference solutions
to the vibrational ODE, how we can determine if a solution is stable,
and the conditions that make a solution unstable. We discussed the
different solution schemes (e.g., Centered Finite Difference, Forward
Euler, Backward Euler, Crank-Nicolson, Runge-Kutta, Forward-Backward
Euler-Cromer) and their implementation.
Homework: For next time, we continue with the LL17 book,
moving into solutions to the wave equation in Chapter 2. In
particular, we will discuss sections 2.1 to 2.4 in detail, but we will
omit sections 2.2.3, 2.2.4, 2.3.4, and 2.4.4. To practice
implementation, let's do exercises 2.1 and 2.4 (in section 2.5). Also,
let's read sections 2.6.1 to 2.6.3 (about reflecting boundary
conditions), section 2.7 (about variable wave velocity), and section
2.11 (about FD methods in 2D and 3D).
Summary: We went through LL17, chapter 2. We
discussed using a stencil to implement a finite difference solution to
the wave equation in 1 dimension (and also in 2 dimensions). The
discussed the importance of the Courant condition, which specifies the
relationship between spatial and temporal resolutions, and leads to an
unstable solution if it is violated. We implented standing waves using
a finite difference scheme, and discussed implementation of boundary conditions.
Homework: For next time, we will finish our reading
of the LL17 book, looking at the diffusion equation (Chapter 3) and
advection (Chapter 4). For Chapter 3, let's read sections 3.1 and 3.2,
as well as 3.5.1 to 3.3.5 (heterogeneous media) and 3.6.1-3.6.2 (two
dimensions). For Chapter 4, we will read sections 4.1.1 to 4.1.4.
Summary: We went through LL17, sections 3.1-3.2,
3.5, 3.6, and 4.1. In doing so we discussed the diffusion equation and
in particular the difference between the explicity solution (which we
used before for the wave equation) and the implicity solution. The
implicity solution is useful for the diffusion equation because it
allows for longer timesteps for a given spatial resolution (larger F
parameter). However, the implicit solution requires inversion of a
generally sparse or banded matrix, and there are efficient ways to do
this. The advection equation (section 4.1) is most readily solved with
a simple upwind differences scheme.
Homework: For next time, we start with finite
elements using the LM19 book. Let's read chapter 1, and chapter 2
sections 2.1-2.4, as well as a quick look at section 2.5. We have a
three-part exercise: (a) Write your own numerical integration program
(as we did early in the semester) to reproduce the example in section
2.2.3 and plot the result (you should get something similar to figure
2.2). (b) Now apply this same numerical integration method to
approximate the function y=exp(x^2) using a linear function in the
span [0,2]. (c) Finally, find the analytical expressions for the 3
Lagrange polynomials of order 2 for an element with points at [0.,
0.5, 1.0], and plot them.
Summary: We will cover LM19, chapters 1 and 2.
Summary: We will cover LM19, chapter 3 (sections
3.1, 3.2, 3.5 and the beginning of 3.6).
Summary: We will cover LM19, sections 4.1
(approximating differential equations) and 5.1 (computing with
finite elements) and 6.1 (time-dependence).
(project writeups will be due a few days before)