Using Julia for teaching and research in the Geosciences
- 1Johannes-Gutenberg University Mainz, Institute of Geosciences, Mainz, Germany (kaus@uni-mainz.de)
- 2Department of Earth Sciences, ETH Zürich, Zürich, Switzerland
Julia is a relatively new scientific computing language with which you can write code that is nearly as fast as Fortran or C, but being a dynamic language, it remains very compact. Since the language is newer than say Python, many of the shortcomings of earlier languages have been fixed. Installing and updating packages with external dependencies is straightforward, for example, and exact reproducibility of computational results can be done by uploading a single additional file.
Here we will discuss our recent experiences with using Julia for teaching and research:
- The binarybuilder package simplifies the precompilation of non-Julia open-source packages (C, C++, Fortran), allowing cross-compilation for Apple, Linux, and Windows. Uploaded centrally, these precompiled binaries can be effortlessly installed via the Julia package manager. This expedites the setup of complex research code in teaching, reducing the time spent on package installation during the initial lecture to just a matter of minutes. Examples where this was recently implemented was GMT.jl (the Julia interface to the Generic Mapping Tools) which now comes with precompiled version of GMT. Likewise, we provide precompiled packages for LaMEM (a parallel 3D geodynamic code) and MAGEMin (a new thermodynamic code).
- It is quite easy to call such binary packages, either by calling the executable itself or by automatically creating wrapper (using Clang.jl) and calling the functions within dynamic libraries directly from julia.
- There is a large and ever-growing ecosystem of existing packages that are useful for computational geosciences. Whereas it is still not as mature as in Python or MATLAB, much of what is required in our daily life is already there, including plotting, machine learning, data I/O.
- It is easy to develop additional packages, and testing is build-in the language (and CI/CD is free on GitHub for open-source packages). That encourages users to implement tests and helps maintaining packages.
- Packages can talk to each other in a straightforward manner, which facilitates building composable software stacks.
- There is great support for GPU computing.
- It is possible to create GUI’s that run in a webbrowser (for example by using Dash.jl). Recent examples where we used that is in InteractiveGeodynamics.jl (which provides user interfaces to simulate typical geodynamic problems such as convection), GeoDataPicker.jl (a 2D/3D tool to analyze and visualize geodynamic data) and MAGEMin_app (a web-based tool to compute phase diagrams).
- It can directly be used in Jupyter notebooks (as the “Ju” in its name stands for Julia).
- It is easy for students to start writing simple codes without having to think about definition of types or having to load packages to create vectors or matrixes, which makes it well-suited for teaching quantitative classes. In many cases, these simple codes already run very fast, as the Julia compiler does an excellent job in optimisations. With a few additional tricks (ensuring type stability and reducing allocations) the simple examples can be turned into a high-performance code that runs at nearly the speed of the more classical languages, while having the advantage to still be very compact and readable.
We will highlight these aspects including with interactive demos.
How to cite: Kaus, B., de Montserrat, A., Riel, N., and Aellig, P.: Using Julia for teaching and research in the Geosciences, EGU General Assembly 2024, Vienna, Austria, 14–19 Apr 2024, EGU24-16725, https://doi.org/10.5194/egusphere-egu24-16725, 2024.