The Theory of Reaction-Diffusion Equations

Complex and beautiful patterns, including ones very similar to those appearing on many animals in nature, can be generated from a chemical model where two reactants are simultaneously reacting with each other and diffusing through the system. In the most common of these models, known as the Grey-Scott Model, the reaction scheme is

U + 2V → 3V

V → P

i.e. one molecule of reactant U and two of reactant V react to create three molecules of reactant V, and occasionally molecules of reactant V convert to the inert product P. This first reaction 'feeds' reactant U into the system, and the second reaction 'kills' molecules of reactant V, removing them from the system. The rate constants f and k, respectively, set the speed of each of these reactions.

When both reactants diffuse through the system, with diffusion rates and , respectively, the concentrations u and v of each reactant change with time as a set of partial differential equations. These partial differential equations can be solved numerically to simulate chemical systems. Varying the four rate constants — , , f, and k — changes the pattern generated by the system. We are also able to change the stoichiometry of the reaction scheme and vary boundary conditions.

Our Visualizations

We visualize our reaction-diffusion simulator in two different ways — using matplotlib, to allow for scientists to easily visualize problems directly in a jupyter notebook, and with pygame, to allow for increased interactivity, such as drawing initial concentrations of each reactanta with the mouse.

Machine Learning

We wanted to see if we could teach a convolutional neural network (CNN) to predict the rate constants , , f, and k from an image of the final steady state of a given system. We trained the network on a training set of 18000 images, varying all 4 rate constants, and, while we weren't able to predict patterns exactly, we did predict general morphologies from final states. We are also able to feed our program images of real animal patterns; the next step is to teach our CNN to predict reaction-diffusion rate constants from real-world images.

Challenges I ran into

Because of the nature of reaction-diffusion data — two different substances, each of which could have concentrations ranging from 0 to 1 in each spatial pixel, visualizing the data effectively was surprisingly difficult! We tried several different colour mapping schemes, eventually deciding to individually map each pixel to RGB values in the pygame simulation. Also, machine learning is hard! Generating a large enough dataset, and training our CNN, was a long and difficult process.

What's next for Interactive Reaction-Diffusion Simulations

There are several ways we can deepen the problem we treat. We can change the grid on which our system operates to, for example, a hexagonal close-packed array. Imposing different fixed boundary conditions, such as limiting our system to a 2D circle or other complex shape, would also make the evolution of the patterns interesting. We would also like to extend our real-world ML. In its final state, we would love to be able to input an arbitrary image of an animal pattern, and see the evolution through time that would lead to that pattern.

Built With

Share this project:

Updates