Mandyoc, a finite element simulator for the mantle

Mandyoc is a finite element code written on top of the PETSc library to simulate thermo-chemical convection of the Earth's mantle. Different linear and non-linear rheologies can be adopted, appropriately simulating the strain and stress pattern in the Earth's crust and mantle, both in extensional or collisional tectonics.

In this opportunity, we will present a showcase to simulate the evolution of divergent margins taking into account the plastic rheology and the sin-rift geodynamics. So we'll explain how to create the input file for this scenario, run the model using Mandyoc and plot the results.


Before the tutorial

Make sure you've done these things before the tutorial on Monday:

  1. Sign-up for the Software Underground Slack
  2. Join the channel t22-mon-mandyoc. This is where all communication will happen.
  3. Set up your computer (instructions below). We will not have time to solve many computer issues during the tutorial so make sure you do this ahead of time. If you need any help, ask at the Slack channel.


  • Some knowledge of Python is assumed (for example, you might want to attend this or this tutorial).
  • All coding will be done in Jupyter notebooks. We'll explain how they work briefly but it will help if you've used them before.
  • We'll also use numpy, pandas and matplotlib. You don't need to be an expert in these tools but some familiarity will help.


There are a few things you'll need to follow the tutorial:

  1. A working Python installation (Anaconda or Miniconda).
  2. The Mandyoc tutorial conda environment installed.
  3. A web browser that works with Jupyter notebooks. (basically anything except Internet Explorer)
  4. Install Mandyoc following the installation instruction on its website.

To get things setup, please do the following.

If you have any trouble, please ask for help in the t22-mon-mandyoc channel on the Software Underground slack.

Windows users: When you see "terminal" in the instructions, this means the "Anaconda Prompt" program for you.

Step 1

Install a Python distribution:

In this tutorial, we will be using the Anaconda Python distribution along with the conda package manager. If you already have Anaconda or Miniconda installed, you can skip this step.

If not, please follow the instructions for getting Anaconda up and running in your system: https://docs.anaconda.com/anaconda/install/

Step 2

Create the t22-mon-mandyoc conda environment:

  1. Download the environment.yml file from here (right-click and select "Save page as" or similar)
  2. Make sure that the file is called environment.yml. Windows sometimes adds a .txt to the end, which you should remove.
  3. Open a terminal (Anaconda Prompt if you are running Windows). The following steps should be done in the terminal.
  4. Navigate to the folder that has the downloaded environment file (if you don't know how to do this, take a moment to read the Software Carpentry lesson on the Unix shell).
  5. Create the conda environment by running conda env create --file environment.yml (this will download and install all of the packages used in the tutorial).

Step 3

Start JupyterLab:

  1. Windows users: Make sure you set a default browser that is not Internet Explorer.
  2. Activate the conda environment: conda activate t22-mon-mandyoc
  3. Start the JupyterLab server: jupyter lab
  4. Jupyter should open in your default web browser. We'll start from here in the tutorial and create a new notebook together.

Step 4

Go to the Mandyoc website and follow the instruction to install Mandyoc in your computer.