On this page

Introduction

These lecture notes are created using Jupyter book. The notes contain live code examples that can be modified and run. The idea is for the user to get an interactive experience that hopefully will make the education both more interesting, as well as better quality. Learning by doing, programming is understanding. The notes are best read with html online. However, they can still be downloaded as a single pdf from the PDF button on the right.

On all html pages in these notes there are some buttons in the top right corner. The last button lets you download the page you are currently surfing as a jupyter notebook or a pdf. The notebook can then be opened, modified and run locally, if you are in an environment with jupyter installed. However, the different pages in these lecture notes are connected, with some links going from one page to another. So you probably want to open all these notebooks in a folder where they all live together. To this end you can for example clone the github repository (third link above) where these notes are stored. The notebooks can then be run if you have a proper environment. However, if you do not have a proper jupyter environment, then there is also first button, which looks like a rocket. The rockets first link will take you to Binder, where you will have all notebooks available in the same good environment. This means, in particular, that the environment will have FEniCS installed for you.

Please note that if you read these notes in jupyter, then some equations and figures will look weird, or unrendered, still in their source, or latex form. This is because all equations in need of reference (especially across different pages) must be written in MyST Markdown format. This gives nice equations and references in html and pdf, but the notebooks unfortunately look unrendered. It is not wrong, it is just that jupyter still does not know how to render MyST Markdown.

So what about these live computational cells? On most pages of these notes there are computational cells, where code can be typed and executed, like this:

a = 'Hello world!'
print(a)
Hello world!

Confused? Well, that’s probably because the variable a was declared in the hidden cell above (press Click to show). In notebooks the cells are connected, and a variable defined in one cell will be available in consecutive cells.

If you are reading these notes in jupyter, then these cells are simply regular code cells. However, on the web (if this note you are reading is an html-file) the cells appear first to be dead, and you will be unable to edit them, which is a drag:-( Luckily, at this point you can turn again to the rocket button and press Live Code. This will in turn load a Binder environment that makes it possible to run the cells interactively, while still remaining in the html-version of this book, without moving to Binder. Please note that the first time a binder image is requested for a new version of this book, it may take some time to build and the Waiting for kernel… message seems to be hanging. However, after loading the first time, subsequent runs on this and other pages should be much faster.

Finally, note that in these lecture notes we will make extensive use of FEniCS as a tool for solving the various partial differential equations that arise. FEniCS makes use of the finite element method (FEM), and some knowledge about FEM is an advantage, yet no requirement, when reading these notes. We import all functionality of FEniCS by importing from dolfin, as seen below. Note that dolfin is the C++ module of FEniCS, which has been wrapped and made usable from Python. But note that this import must be done on each notebook. It is not enough to import dolfin here, and then use it on consecutive pages, like the Couette chapter. For this reason you’ll also find the following code bit also on, e.g., the Implementation section in the Couette notes.

from dolfin import *