Finite element modelling in the clouds
The finite element method (FEM) is widely used in engineering to represent mechanisms in space and time. Its mathematical basis is pretty complicated, but some Python packages facilitate problem definition and solving. But don't think FEM is easy even with the simplest FEM package : deep learning is popcorn compared to FEM.
Once you decide you need FEM in your toolbox, you can use a commercial software, or one of the numerous open source packages waiting to be downloaded, most of them not coming with a graphical user interface. To let you interact dynamically with your models, most open source tools, like FEniCS, are written in Python. And to allow running most of the job fast, FEM packages rely on low level programming languages like C++ and FORTRAN. Sometimes, installing a working environment is subjected to bugs.
Introducing… 🥁 a FEniCS setup on Nextjournal. Nextjournal offers cloud science computing environments with a notebook interface. As usual, there are free and paid plans, but for now they offer a low restrictive free plan, so you can use a FEniCS computing environment for free, under a fair use policy.
Andrea Amantini, from Nextjournal, and I created a fully functional computing environment for FEniCS version 2019.1 with two lines of code.
Install your own environment
You can install FEniCS yourself in a basic Python environment by creating a new notebook, selecting Python, creating a Bash cell type, then paste
conda install -c conda-forge fenics=2019.1 pip install dijitso
conda command installs FEniCS with all its dependencies. But the
conda installation of
dijitso, a Python module on which FEniCS depends, looks for a non-existing cache directory. The
pip command installs
dijitso correctly. To run this command, you will need to change the Machine type to a 7.5 GB RAM to avoid memory errors (Gear > Machine Type > 2 vCPUs, 7.5 GB RAM). While you are there, make sure that the Protocol is set to Jupyter, since the Nextjournal protocol don't seem to be able to plot the results.
Use the image
A quicker way is to benefit from the super-powers of Nextjournal by using an already functional environment that I published.
Create a notebook with a Python environment (or any other). Click on the gear. Under Environment, click on Import environment…, then Load all profiles, then search for essicolo, which is my username. Then select FEniCS 2019.1. You will now be able to run
from fenics import * then begin coding.
If you need an extra package, check first if it's already installed by creating a Bash cell, then run
conda list. If it's not there, you can install it with
pip in a Bash cell.
Check out the first FEniCS tutorial and enjoy!