# Recent Posts

• ## PhD defense preparations: spikning

The date of my PhD defense is approaching rapidly. Wednesday May 19th at 15:00 I will be presenting my thesis “Multiscale models and simulations for diffusion and interaction in heterogeneous domains”. Both the physical and the digital version of the thesis have been published today, and the latter is available here.

• ## deal.II.scale - deal.II implementation for multiscale PDE

As supplementary material of this paper and this licentiate thesis, I developed a finite element implementation in deal.II. The code (together with installation instructions) is on GitHub. This post contains a global overview of the code and its features. A more practical post on usage and implementation details is forthcoming.

This project (finite element analysis for multiscale PDE) is a collaborative effort involving Adrian Muntean, Omar Lakkis and Chandrasekhar Venkataraman, Martin Lind and me. The code itself, for better or worse, is my responsibility.

• ## Role-based access control in JupyterHub

As mentioned before, I’m currently involved in working on JupyterHub through Simula Research Laboratory. In this post, I describe my activities there in some more detail.

Currently, I’m mostly involved on working on the implementation of role-based access control RBAC) for the JupyterHub API, collaborating mainly with @minrk and @IvanaH8.

• ## Talk on crowd evacuation dynamics models

In the week of 13 November, the UNMC (Bogota, Colombia) organised their sixth colloquium on applied mathematics. I was invited to give a talk on mathematical models in evacuation dynamics. The full talk is available on YouTube.

• ## Joining the JupyterHub team

Since October 1st, I’m part of the Project Jupyter team to work on JupyterHub. Project Jupyter mainly occupies itself with the development of open source programming tools and open standards. Perhaps their most well-known project is Jupyter Notebook, a browser interface for programming languages.

JupyterHub, another project, facilitates the setup of a Jupyter Notebook server for multiple users. This allows any organisation to setup and maintain a programming environment for their users or members, relieving them of the burden to have their own computing resources or maintain their installations.

• ## An introduction to entropy (or: how physics likes to gamble)

In this post we discuss the concept of entropy in the context of statistical mechanics. While it is self-contained, it serves as a primer to a follow-up post describing the results of a recent paper.

Take a look at the video clip below. It shows a number of particles bouncing around in two chambers, connected by a tunnel. Each particle is unaware of the rest, and is reflected off the wall as if it was a billiard on a pool table. Initially, the collective behaviour of the particles looks unstructured and random. Keep looking, however, and something interesting happens…

• ## Game of Life with p5.js; an interpretation

Game of life is one of the first implemented computer simulations, proposed by John Conway in the 1940s. The simulation was proposed as an experiment to model an evolving population. The population is represented by a set of squares in a grid followed through a period in time, where each square represents an individual. Individuals can be either dead or alive, depending on the previous state of their neighbours.

Starting from a chosen initial population, the Game of Life evolves according to the following rules.

• A live cell remains alive if it has 2 or 3 neighbours who are also alive, otherwise it dies.
• A dead cell becomes alive if it has 3 neighbours, otherwise it stays dead.

The classical Game of Life is often displayed on a grid where living individuals are black cells and dead individuals are white cells, evolving over time.

As a play on this concept, the Game of Life animation displayed below follows the same concepts, but living individuals have different colors, are presented in circles and slowly fade out. Additionally, by clicking/touching the animation, new shapes are introduced in the animation.

• ## Telegram-alert, a Telegram-based notification service

From time to time it happens I have to run a simulation that takes more than a few hours to run. Not knowing in advance when the simulation is finished and the results are available, I either frantically check every half hour to see if it is done, or forget about it until hours later. Both situations are less than ideal, so last week I wrote a script that allows me to send notifications from the shell to my phone, using a Telegram bot.

• ## Research visit: La Sapienza

In November 2019, I will visit La Sapienza, University of Rome for a period of 5 weeks, hosted by dr. Emilio Cirillo, professor of mathematical physics. Together with him and dr. Matteo Colangeli, we are planning to perform research on the statistical mechanics of particles in complex domains. Both being experts in statistical physics, they have a lot of experience with the modelling and analysis of large particle systems and our aim is that in this time period, we will be able to make some contributions to the understanding of systems exhibiting uphill diffusion, where particles move from equilibrium to polarized situations.

If all goes well, a preprint should be available soon, and a blog post a little later.

• ## Workshop: Crowds modelling and control

This week I will be attending the Crowds: Modelling and Control workshop in Marseille, France. I will be talking about evacuation dynamics in building environments, based on work in this paper and this book chapter.

• ## Poster showcase

An overview of my recent work in the direction of crowd dynamics. Click here for the PDF.

• ## Research visit: Sussex

In February 2019, I will be a visiting fellow at the University of Sussex for a period of 4 weeks, hosted by dr. Omar Lakkis. Omar L. has a lot of expertise in finite element methods and techniques for error analysis and mesh refinement, and under his guidance I will be working in the direction of scientific computing.

Specifically, I plan to do the numerical analysis for the multiscale system of equations analysed in my licentiate thesis, implement the model in a finite element simulation framework and see how it behaves in practice.

With the University of Sussex being a hub of research in applied analysis, I’m looking forward to get in touch with all different kinds of mathematicians.

• ## Podcast: the how and why of applied mathematical research

This week I am starring in our university’s podcast. Forskningspodden (also on iTunes), a podcast hosted by Karlstad University Press, invites their researchers from all areas to introduce and discuss their work.

During a 20 minute session (in English) we talk about some aspects of research in applied mathematics, as well as the contributions in my licentiate thesis. If you are curious, tune in!

• ## Knowledge-based crowd dynamics in evolving evacuation scenarios

Recently, we published a new article on the evacuation dynamics of human crowds in building environments: Effects of environment knowledge in evacuation scenarios involving fire and smoke: a multiscale modelling and simulation approach, in the journal Fire Technology. In this article, we investigate what happens if we mix two kinds of individuals: people who know their surroundings and the fastest way to the exit (called residents), and people who are unfamiliar with the environment and who will follow others in their attempt to evacuate (called visitors). The goal of this investigation is to gain insight in how knowledge of environment impacts evacuation dynamics.

• ## Defense: Licentiate thesis

My licentiate thesis has been published and is freely available! The defense will take place September 5th. If you are interested and have the possibility of joining, drop me a line: it is open for anyone who wants to attend.

• ## Obstructed flow: particle flux through a permeable membrane

Imagine a group of ducklings on one end of a corridor. When a bell sounds, all of them will waddle towards the other end of the corridor, as chaotically and unorganised as ducklings usually waddle. Now imagine that you would like to guide these ducklings by placing objects in the corridor. Is it possible to strategically introduce obstacles in the corridor in order to reduce the time it takes them to get to the other end? The answer is: yes, under specific circumstances.

Together with researchers from Sapienza University and Giustino Fortunato University (Rome, Italy), we are investigating models of flow through obstructed spaces. Our most recent investigation has led to this paper, currently submitted for publication.

• ## AIMS Conference

This week I will be attending the AIMS conference on dynamical systems and differential equations in Taiwan. I have one talk on two-scale pressure models, and one on evacuation dynamics, both on July 6th. If you are attending as well, feel free to join!

• ## Modelling the effectivity of pollution-reducing asphalt

This is a showcase of a recent project I worked on with colleagues from our mathematics department. In addition to describing the mathematical techniques we used, I want to demonstrate how mathematics can be used to gain insight in real life situations.

I have tried to make this post as accessible as possible. If you are interested in the details; a preprint is available here, it will be published in Acta Polytechnica in early 2019.

The municipality of a small German city approached us regarding the following issue. Nitric oxides are air polluting chemicals emitted by motor vehicles and are, among others, harmful to the ozone layer. In a framework of measures to reduce the air pollution, the municipality had decided to install photovoltaic asphalt, asphalt coated with a special substance that actively converts nitric oxides like $\textrm{NO}$ and $\textrm{NO}_2$ to nitrate ($\textrm{NO}_3^-$), which clings to the surface of the asphalt until the rain washes it away. Because these nitrates are not airborne, air pollution is reduced.

Due to extensive measurements, there was a lot of information available on $\textrm{NO}$ concentration prior to, as well as after the installation of the new asphalt.

Their question was if we could estimate the influence of the different environmental measures in this particular scenario, to help them make future decisions based on a validated approach. To answer this question, we created a mathematical model that incorporated the major elements that play a role in this process, so that different scenarios could be explored and emission reducing measures could be compared.

• ## Antennae - Python implementation of ant trail networks

Ants are funny creatures. In spite of their (seemingly) limited cognitive and sensory abilities, they are able to build large complex structures, fight off enemy colonies, and collectively carry large objects.

Ants are able to communicate by giving off pheromones, a chemical that triggers a reaction once picked up by another ant. One of the ways pheromones come into play is when ants spread out to forage for food. Once they find a food source, they carry it back to the nest, all the while leaving a pheromone trail that will lead other ants to the same location. Because of the way the pheromone is deposited, ants are able to construct the shortest route to the food source without prior information about the layout of their environment.

Although inherently a biological question, various mathematicians have tried to express this behaviour in mathematical structures, and not without success. I implemented one of these concepts in Python. You can download it here.

• ## Structure of Mercurial: a crowd simulation framework

To support my research in crowd dynamics models, I am developing a simulation framework: Mercurial. The aim is to simplify the testing of new models and see how they perform in different scenarios. At this stage, the framework is still a prototype, but I try to keep it as accessible and maintainable as possible.

Mercurial is written in Python 3. This makes for rapid prototyping, but can become a computational burden if not designed with caution. Therefore, almost all intensive computations are vectorised using the NumPy library or are deferred to a lower level implementation in Fortran.

In the rest of this post I describe the structure of the simulation. Information on how to install and use it can be found here.

• ## What is crowd dynamics?

This is the first post in a series of entries on the modelling of crowd dynamics.

In this post I give a short introduction into a topic of my research: crowd dynamics. Crowd dynamics is a very multidisciplinary field of research; contributions come from a great many fields in social science and natural science. I will be sticking to my background and focus mainly on mathematical, physical and computer-science aspects. For the interested reader I have included links to Wikipedia pages of related concepts.

## Definition

Crowd dynamics is the term used for describing the behaviour and interaction of groups of people moving in a certain environment. The main goal of crowd dynamics research is to identify the factors that control these dynamics (analysis), and to be able to predict crowd motion in new scenarios (simulation).

As you can imagine, crowd simulation serves many purposes, like

• Preventing crowd disasters at a large public event.
• Optimizing the layout of a supermarket.
• Designing evacuation strategies for a building.
• Creating realistic animations in a game.

The dynamics of crowds vary from situation to situation. Pedestrians in traffic have different goals and therefore different patterns than people in shopping malls. Compare across cultures, and you will find even more diversity. This makes the modelling and simulation of crowds a challenge that requires more than just a mathematical understanding of how people move from A to B.

• ## IPython - an improved shell for Python

[IPython][1] is an alternative to the default Python interpreter. It was created to make scripting and prototyping in the programs in the Python language more easy and has gradually developed new technologies to improve Python, as well as other programming languages. Some of its key features are syntax highlighting and tab completion for variables, modules and files in an interactive Python session, and notebooks that allow a mixture of code, output, and descriptions (see for instance [this][2] one).

You can install IPython through your package manager (e.g. pip or conda). IPython has loads of options. Although it is well documented, the manual is so long I postponed reading it for years. Now that I did, I decided it was time to share the highlights that improved my workflow.

• ## Implementation of a weighted distance transform

I recently finished a Python module for computing weighted or generalized distance transforms (available here). I needed it for the motion planner in my crowd simulation Mercurial and I couldn’t find it online, so I implemented it in Fortran so F2PY could wrap it for me. This post goes into details of the algorithm and how to use the module.

• ## Getting started with scientific Python on Mac and Linux

This post elaborates on a couple of ways to install Python libraries Numpy/Scipy/Matplotlib for Linux and Mac. This is something I seem to have to do every so often, and although the process should be straightforward, the details elude me each time. May this serve as a reminder to future me (and others).

Note: For all platforms (including Windows) it is possible to install compiled binaries as well. I won’t go into this here, because I prefer the use of package managers. They take care of compiling the software, putting it in the right place and updating so you don’t have to worry about it.

• ## Crowds and populations: a visual exploration

No formulas or commands in this post. Instead, I uploaded a couple of video clips I recorded in various places, showcasing dynamics in different kinds of populations. They are a bit amateurish, but they should be able to demonstrate the complexity present in population dynamics. Each scenario has a bit of context describing a mathematical model associated with it.

## 1. Crossing pedestrians

The first clip was shot in the Shibuya crossing in Tokyo, Japan. It is known for being one of the most crowded intersections in the world. Two special features of the crossing: it has more than 4 lanes, and the traffic lights give way to pedestrians from all directions at the same time.

• ## A practical introduction to the Finite Element Method

This notebook provides a demonstration of the Finite Element Method, a technique to obtain a numerical solution of a partial differential equation. This is by no means a complete introduction, but serves more as a numerical example of how the technique works in practice. For more detail on the mathematics behind it, there are numerous books and resources online; for open-source implementations, you can check out FEniCS, DUNE, deal.II and many others.

## Description

We are looking for the solution to the partial differential equation

$-\Delta u=f$

on a domain $\Omega$. Here, $\Delta$ is the Laplace operator and $f$ is a known function. We assume that on the boundary of our domain $\partial \Omega$, $u$ takes value $0$.

• ## ENUMATH Conference

Next week I will be attending the ENUMATH, a conference on numerical methods and applications, in Norway. I have a presentation on two-scale pressure model on September 26th. If you are attending as well, feel free to join me!

• ## Open-source command-line tools for images and movies

A while back, I discovered a couple of command-line image manipulation tools: ImageMagick and FFmpeg. They fit nicely in my simulation development workflow, and take a lot of pain out of reproducing graphic output. Put the commands in a script, and it’s easy to re-obtain images and movies after running simulations with different parameters.

To use convert, install the ImageMagick toolbox. For ffmpeg, install the FFmpeg library. On Ubuntu:

sudo apt-get install imagemagick
sudo apt-get install ffmpeg


Binaries are also available for Windows and Mac.

Below follows a list of examples I find useful. All commands are valid bash/zsh.

• ## How to communicate data between Fortran and Python

In a previous post, I discussed extending: how to build custom Fortran modules you can run in a Python script. If you just want to post-process or plot your Fortran results, you can opt to simply output your data in a readable format, so that you can read it in other languages (e.g. Python, Matlab, C++).

This post lists three ways to output Fortran data: the quick way, the classic way, and the sustainable way.

• ## Extending Python with Fortran

If you use Python for scientific programming you’ll probably find that as long as you can use NumPy, SciPy, and other optimized libraries, scripts can be developed and executed swiftly.

The routines from these libraries are often composed in low-level programming languages (like C or assembly), avoiding the overhead from the dynamic and interpreted nature of Python.

However, it can happen that some of the algorithms you are implementing require operations not supported in these libraries. For example: if you use NumPy, but run into an algorithm that is difficult to expressed in a vectorized form, you might have to resort to pure Python. This can become a huge bottleneck in the execution of your script.

It is possible to create your own Python module from a lower-level programming language. This is called extending Python. This means you write the bottleneck algorithm in the low-level language, compile it in a Python-friendly way and use it in your script like any other module. This post shows how to use the tool F2PY from SciPy to create an extension from Fortran.

• ## Mercurial: simulation framework for crowd dynamics

Recently, I wrote something about my graduation project. Part of this project was the development of a simulation framework, Mercurial. The goal of Mercurial is to facilitate the implementation of different hybrid particle simulation methods, and to test them on simple but existing use cases with different environments. You can find the code on GitHub here, together with instructions on how to use it.

If you are interested in the structure of the code, check this post. This simulation was also used in my research internship at LOC7000, to evaluate evacuation scenarios on Dutch music festival Lowlands and see if the safety measures could be analyzed in a quantitative manner.

The framework is built in Python. The simulation creates an environment from a scene file and reads in the parameters from a configuration file. Alternatively, a simple drawing tool is included to create new environments.