Skip to content

Introduction to Julia and Trixi, a numerical simulation framework for hyperbolic PDEs

License

Notifications You must be signed in to change notification settings

trixi-framework/talk-2021-Introduction_to_Julia_and_Trixi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction to Julia and Trixi, a numerical simulation framework for hyperbolic PDEs

License: MIT nbviewer Binder

This is the companion repository for the talk

Introduction to Julia and Trixi, a numerical simulation framework for hyperbolic PDEs
Hendrik Ranocha
Applied Mathematics Seminar, University of Münster
Tuesday, 2021-04-27, 10:00 CEST
Announced online

Here you can find the presentation in form of a Jupyter notebook Talk.ipynb. This notebook contains a couple of additional slides not presented in the talk. There are also some additional Trixi elixirs (simulation setups) in the examples directory.

Abstract

Julia is a modern high-level programming language developed specifically with scientific computing in mind. Trixi is a numerical simulation framework for hyperbolic conservation laws written in Julia. A key objective for the framework is to be useful to both scientists and students. Therefore, next to having an extensible design with a fast implementation, Trixi is focused on being easy to use for new or inexperienced users, including the installation and postprocessing procedures.

This presentation is a live demonstration of Julia and Trixi. Firstly, we introduce Julia and demonstrate some of its design principles. This introduction is aimed at researchers in numerical analysis with previous programming experience. Next, we show how to use Trixi for setting up and running simulations, how to visualize the results, and how to extend Trixi with new functionality. We demonstrate how key design principles of Julia are used in Trixi and the Julia package ecosystem, e.g. to enable automatic differentiation through a complete simulation involving hyperbolic conservation laws.

The presentation is available as a Jupyter notebook at https://github.com/trixi-framework/talk-2021-Introduction_to_Julia_and_Trixi, including information how to set up everything. For more information about Trixi and how to use it, please visit Trixi on GitHub or refer to the official documentation.

Getting started

You can view a static version of the Jupyter notebook Talk.ipynb

  • directly on GitHub (select the notebook; this may fail sometimes)
  • or on nbviewer.jupyter.org (select the "render" badge at the top of this README)

These static versions do not contain output of the code cells.

Using mybinder.org

The easiest way to get started is to click on the Launch Binder badge above. This launches the notebook for interactive use in your browser without the need to download or install anything locally.

In this case, you can skip the rest of this Getting started section. A Jupyter instance will be started automagically in the cloud via mybinder.org, and the notebook will loaded directly from this repository.

Note: Depending on current usage and available resources, it typically takes 1-2 minutes to launch a notebook with mybinder.org (sometimes a little longer), so try to remain patient. Similarly, the first two cells of the notebook take much longer to execute than usual (around 1.5 minutes for the first Trixi simulation and about 1 minute for the first plot), since Julia compiles all methods "just-ahead-of-time" at first use. Subsequent runs will be much faster.

Setting up a local Julia/Jupyter installation

Alternatively, you can also clone this repository and open the notebook on your local machine. This is recommended if you already have a Julia & Jupyter setup or if you plan to try out Julia anyways.

Installing Julia and IJulia

To obtain Julia, go to julialang.org/downloads and download the latest stable release (v1.6.0 as of 2021-04-19; neither use the LTS release nor Julia Pro). Then, follow the platform-specific instructions to install Julia on your machine. Note that there is no need to compile anything if you are using Linux, MacOS, or Windows.

After the installation, open a terminal and start the Julia REPL (i.e., the interactive prompt) with

julia

To use the notebook, you also need to get the IJulia package, which provides a Julia backend for Jupyter. In the REPL, execute

using Pkg
Pkg.add("IJulia")

to install IJulia. For more details, especially on how to use an existing Jupyter installation, please refer to the IJulia documentation. From here on, we assume that you have a working installation of Julia, Jupyter, and the Julia kernel for Jupyter.

Installing the required Julia packages

To make the notebook fully reproducible, we have used Julia's package manager to pin all packages to a fixed release. This ensures that you always have a Julia environment in which all examples in this notebook work. Later you can always install the latest versions of Trixi and its dependencies by following the instructions in the Trixi documentation.

If you have not done it yet, clone the repository where this notebook is stored:

git clone https://github.com/trixi-framework/talk-2021-Introduction_to_Julia_and_Trixi.git

Then, navigate to your repository folder and open a Jupyter notebook.

cd talk-2021-Introduction_to_Julia_and_Trixi
jupyter notebook

The first few cells of the Jupyter notebook will enable you to download and build all required packages, including the ODE package OrdinaryDiffEq, the visualization package Plots, and of course Trixi. The information Julia's package manager needs for this to work is contained in the two files Project.toml and Manifest.toml.

As an alternative to running the examples in the notebook directly, you may also just view the notebook statically by opening it within Jupyter NBViewer.

General note: Make sure that you execute the examples (either in the notebook or in the REPL) in order, at least for the first time. Both the notebook and the Julia REPL maintain an internal state and and some snippets depend on earlier statements having been executed.

Displaying the presentation

To display the presentation as in the talk (skipping some cells/slides that provide further information), you need the Jupyter extension RISE, that you can install via

pip3 install --user RISE

After opening the Jupyter notebook, you can enter the RISE presentation mode with Alt + R.

Authors

This repository was initiated by Hendrik Ranocha.

License

The contents of this repository are licensed under the MIT license (see LICENSE.md).

The material in this repository is inspired by and partially derived from the talks