Assignments1

Seismic Exploration Methods - EAS 8803 - FH

Installation

The assignments require Julia and Python 3 to be installed (Python 2 will not work).

For Windows, I recommend to use docker as Devito does not support Windows.

Julia

To install julia follow

https://julialang.org/downloads/

And install Julia 1.5

Python

The recommended installation is via conda to have a stable environment.

https://conda.io/miniconda.html

Packages

For the assignments, you will need a few python and julia packages. Please follow these instructions to install all of the packages in the order described here.

First, install Devito using pip (or pip3), or see the Devito’s GitHub page for installation with Conda and further information. The current release of JUDI requires Python 3 and the current Devito version. Run all of the following commands from the (bash) terminal command line (not in the Julia REPL):

pip install --user git+https://github.com/devitocodes/devito.git

Then install matplotlib by

pip install matplotlib

If these commands don’t work, please replace pip by pip3 and try it again.

For reading and writing seismic SEG-Y data, JUDI uses the SegyIO package and matrix-free linear operators are based the Julia Operator LIbrary (JOLI), we can install these 2 packages via:

julia -e 'using Pkg; Pkg.add(url="https://github.com/slimgroup/SegyIO.jl.git")'
julia -e 'using Pkg; Pkg.add(url="https://github.com/slimgroup/JOLI.jl.git")'

Once Devito, SegyIO and JOLI are installed, you can install JUDI with Julia’s Pkg.add.

julia -e 'using Pkg; Pkg.add(url="https://github.com/slimgroup/JUDI.jl")'

Once you have JUDI installed, you need to point Julia’s PyCall package to the Python version for which we previously installed Devito. To do this, copy-paste the following commands into the (bash) terminal:

export PYTHON=$(which python)
julia -e 'using Pkg; Pkg.build("PyCall")'

Again, try which python3 if which python does not work.

You can verify your installation by running:

julia -e 'using Pkg; using JUDI; example=joinpath(dirname(pathof(JUDI)),"..","examples/scripts/modeling_basic_2D.jl");include(example);'

This command should finish without errors.

Docker Installation (not necessary for homework but important for project)

In this course, we will have a couple of coding assignments based on Julia, a fast, dynamic, reproducible composable and general open source programming language. You are encouraged to install Julia on your system following the script to run some basic coding experiments to explore its usage and applications in scientific computing community.

In particular, you will run numerical experiments for CO\(_2\) dynamics simulation (in case you need it) and seismic wave-based simulations with academically developed softwares. To help you run these software, we highly recommend you use Docker, a platform which builds a virtual machine/container for you with the docker image, which is set-up by us and equipped with pre-installed softwares. The docker image is quite necessary for you to run the software without the tedious installation process, and to provide you with an environment on which the software runs out of the box.

First install docker for your system following the instruction here,

https://www.docker.com/products/docker-desktop

Instead of having to install Python, Julia, Devito, JUDI, JutulDarcyRules and all the dependencies (these are the softwares that you will use for the numerical simulation) by yourself, you simply download the docker image and run it in a container. All you need to do is install docker, click the docker icon/app, open the terminal/command line (powershell in windows, also see this) on your system, and run:

docker run --platform linux/x86_64 --env JULIA_NUM_THREADS=4 -p 8888:8888 -v /path/on/your/machine:/notebooks apgahlot/eas-8803:v2.0

where /path/on/your/machine is an absolute path on your own local machine. Remember giving a folder path is important. For example, if I want to connect the folder called testdocker on the desktop of my laptop, I can do

docker run --platform linux/x86_64 --env JULIA_NUM_THREADS=4 -p 8888:8888 -v /Users/abhinav/Desktop/testdocker:/notebooks apgahlot/eas-8803:v2.0

This will download the image and launch a session that you can access from your internet browser. The command will display a link, which looks something like this:

Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://0e27b13128d4:8888/?token=84a95cf4319e8e68534f20c7c6474d9875f13c70270f35f4&token=84a95cf4319e8e68534f20c7c6474d9875f13c70270f35f4

Copy/paste this link and replace the address 0e27b13128d4:8888 with localhost:8888 (the link is created inside the docker container, which doesn’t know that you mapped this port to your localhost w/ port no. 8888). Then, you can create a notebook there by clicking new -> notebook -> julia 1.8.5 (or you can copy your previous notebooks to that folder, e.g., testdocker), and run the julia code in the jupyter notebook. Try running these packages in notebook for fun

using JutulDarcyRules
using LinearAlgebra
using PyPlot
using SlimPlotting
using JLD2, Polynomials, Images

Whatever you do on the docker container will be saved in the local testdocker folder. And then you need to copy the homework notebook once it is released to this folder and run your codes in that notebook.

Instead of a notebook, you can also launch an interactive session with a terminal by running:

docker run -it apgahlot/eas-8803:v2.0 /bin/bash

This will give you access to a terminal, in which you can start Julia/Python, run a couple of lines of code interactively. However, figures from PyPlot (the plotting package) sometimes do not render well from interactive julia sessions. Therefore, jupyter notebooks on docker are recommended for you to do the assignments.

Number of cores/threads

By default, the command

docker run --platform linux/x86_64 --env JULIA_NUM_THREADS=4 -p 8888:8888 -v /path/on/your/machine:/notebooks apgahlot/eas-8803:v2.0

will use 4 threads because in the above command JULIA_NUM_THREADS=4 is set. If you want to increase the number of threads to run your code faster, you need to know the number of threads on your machine and then set JULIA_NUM_THREADS equal to that number. To know the number of threads on your machine you can do:

For Mac, write on terminal: sysctl -n hw.logicalcpu

For Linux, write on terminal: lscpu

The number of threads = number of threads per core * No. of CPUs

For windows: Follow this link

Window Users

If you are using windows, you might need to enable hardware virtualization in their BIOS. You are suggested to look at here and here. If you have any question, please reach out to us ASAP.

New docker container for fluid-flow simulations

docker run --platform linux/x86_64 --env JULIA_NUM_THREADS=4 -p 8888:8888 -v /path/on/your/machine:/notebooks apgahlot/eas-8803:v1.0

Follow the same procedure as before to run new docker with the above command. Please note you will use this new docker image for HW4. (Later you will also need a package called MECurvelets which can be installed by using Pkg; Pkg.add(url="https://github.gatech.edu/SLIM/MECurvelets.jl"). We will help installing this package.)

Some Useful Material

Learn command line from Software Carpentry
Learn jupyter notebook
Learn Julia

Exercises

During the course you will work on exercises that you will find under Schedule each week.

Hand in

Please turn in your assignments as pdf files. The assignments should be send to Abhinav Ghalot. Late hand ins are not accepted.

Unless stated otherwise the labs are due one week after the assignments have been posted. For example, if a homework is posted before the lecture on Wednesday, you should submit your homework before the lecture on the next Wednesday in order for your homework to be considered as on-time. If you have difficulty on the homework and want to ask for extension, please email Dr. Felix Herrmann and cc TA in advance.

Feedback

We will give you feedback on the marking of the exercises.

Footnotes

  1. These assignments are subject to change throughout the semester. We will try to keep these updates to a minimum. ↩︎

Reuse