Laozhainan

Droplets versus the past

This phantasmagorical battle for fulfillment, fought against my past self, will have you at the edge of your seat. The stakes are – as usual – abstract.

In a broader sense, this article is about the obscene appreciation of rainy days.

Throughout, as of now, 47% of my life, I have had a fascination with simulation. The act of putting simplified laws of nature into code, solving equations to reproduce a slice of reality. Apart from a sense of fulfillment and a nice little animation, going through this process can give you a wonderfully intimate understanding of the thing you simulated. What better way to understand the double pendulum than to become a god of double pendula?

Depending on what you are simulating, however, challenges arise. Computers can be incredibly versatile in solving equations that are futile to attack with pen and paper. But they can only calculate in discrete steps. Spaghetti have to be approximated by chains, smooth pizza dough is bound to become a grid. Sometimes, the world of chains and grids behaves similar enough, sometimes making them act along requires devilish skills that much surpass what is needed to understand the underlying physical problem.

When I would encounter such problems and fail and they are sufficiently interesting, I would file them as a “nemesis” to be tackled later by a future version of me with better skills. Generally, this has worked splendidly. Over time, the number of nemeses has been reduced and the number of skills has been increased to a level that makes me fall asleep at night sometimes with a self-satisfied smile.

A dramatic counterexample – and the tantalizing subject matter of this article – came into being 33% of my life ago while riding a train on a rainy day and looking not out of the window but at the window. The result was the simulation shown in the picture above.

Droplets land on the pane. They stick to it and leave a trail as they get pulled down by gravity. Leaving the trail decreases their size and slows them down to a stop. Alternatively, if they can make use of a preexisting trail, they accelerate without hinderance and quickly leave to the bottom.

The simple way my past self devised to simulate the height-profile of water on the window is to take a collection of particles and a grid of values. The particles are like paint brushes that feel the acceleration of gravity and leave a trail on the grid of values as they go. Each time they paint something, they slow down and shrink a little. If there is already something painted, they do not paint more. The grid of values does nothing but slowly remove all the paint. On top of it add some random noise to simulate dirt and avoid completely straight lines.

The resulting height profile can then be used as a video texture in blender to simulate all the refraction for the nice visual effect – not part of the challenge.

That work is in the past. At the end of last year, looking at the droplets in my shower, I got the idea to do better. I would capture the missing phenomena, particulary the way old trails contract and can separate into new droplets, using a slightly more complex model. With my current skills it would be trivial to do so. Additionally, so I thought, I would write an article – this article – on the website to document my process and explain my approach on the different levels of detail of description, delivering to you a salient nugget of inspiring education.

What followed was a flow state. Very excited about the possibilities to throw advanced methods at the problem, I first tried to extend the particle-grid approach by additional dynamics of the grid. It quickly became clear, however, that adding such dynamics makes it exceedingly hard to couple the particles to it in a sensible way. In the next try, I instead ventured to perform the whole simulation on a grid without particles. This means that the existence of droplets is no longer put in by hand. Instead, it has to arise naturally from the simulation of the surface tension of the water film.

The mathematical tool needed to simulate the dynamics of surface tension is a nonlinear partial differential equation. In terms of the pizza grid analogy, these guys are the absolutely cursed devil’s food. Their grid versions more often than not tends to behave wildly different from what you want, and the act of convincing them to behave like smooth pizza crosses from science into art and from art into eldritch incantation. It is not my specialty.

For more than two months, I spent my every free time minute on this project, trying to cut through the difficulties with intuition and the experience I had accumulated. In the end, I failed. The regime I was interested in, of droplets leaving trails is one where this kind of approach gets very challenging. Droplets like to form sharp boundaries both in height and in flow velocity. Sharpness is poison in the world between pizza and grids. It calls out to the gridlike qualities of the system and detracts from the doughiness, leading to instability. I could not find a way to fix these instabilities and get the results I was hoping for.

The failed attempts of my simulation. A kind of worm that goes up into flames when their cursed existence on this mortal plane is denied by the laws of nature.

I would have choosen one of the runs that look at least a bit like water or do not display the instabilities glaringly. I would have put it through blender to get the nice visuals from above. I would have explained the code of the old version of the simulation and given you context on how exactly I modelled this. But I had to extricate myself from this. After so much time used on the project, I was feeling quite unhappy and I cannot touch it now without the danger of sinking a lot more unhappy time in it.

The lesson is to never underestimate simplicity. My past self (guided by its inabilities) found a wonderfully economic simplification to make a convincing simulation of rain on a pane. Sometimes, the hubris stemming from increased abilities can drive you into the opposite direction of undertaking the apparently easy task of improving on simplicity. You pay the prize of a perfectionist pursuit with diminishing or negative returns.

You too should simulate something. I cannot give you a detailed guide to improve your skills today, but I can give you some motivation: It is awesome, do it! But maybe not drops on a pane with partial differential equations. Start with the solar system.

Ti’s comment: Despite all of this, the exploration may still have been worthwhile. The present example might just turn into a new nemesis to be tackled three years down the line.

Another thing I wanted to include in the ideal article this could have been is the following. If you read this far and are going to vote AfD in the next election in Germany, please write me an e-mail. I would like to understand if and why people who enjoy this kind of article would do that.