Skip to content

chany-ahn/groovy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

131 Commits
 
 
 
 
 
 

Repository files navigation

Interactive Reaction-Diffusion Models

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

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

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.

Our PDE Solver

Our numerical implementation of the reaction-diffusion model can be found in the evolve() function in the pde_solver.py python script. The user can vary many components of the model, including the boundary conditions, the spatial dimensions, the length of time over which it integrates, and the discrete Laplacian kernel used to perform the spatial derivation.

Matplotlib Visualization

We include a premade visualization of the PDE solution using the Matplotlib.pyplot library in the Basic_Plotting() function in the BasicPlotting.py python script. The output has been specifically designed for streamlined production of figures for scientific presentation. This function directly interfaces with our PDE solver so that parameters can be set locally before figure generation. The following are examples of the output files:

gif load failed

This is a Grey-Scott simulation with f = 0.0367, k = 0.0649 and fixed boundary conditions.

gif load failed

This is a Grey-Scott simulation with f = 0.055, k = 0.062 and fixed boundary conditions.

gif load failed

This is a simulation with the same parameters as above, but periodic boundary conditions imposed.

Pygame Visualization

We can continue to extend how we utilize these simulation and visualization techniques by creating a more interactive environment. The user can not only define their own parameters in terminal but can also draw different initial conditions by setting certain regions of the environment to have reactant U (red) and reactant V (blue). This way the user has a more involved method of manipulating initial conditions to observe how the PDE's evolve over time.

At the start, the program asks the user if they want to input their own boundary conditions. So the user uses the Left-Click to add reactant U and Right-Click to add reactant V.

These next images show the simulation of the diffusion-reaction with initial conditions (without user input boundary conditions). ru = 1.0, rv = 0.5, f = 0.055, k = 0.062.

This is the early stages of the evolution.

This is mid-way into the simulation.

This is the final image when all of the time steps have occurred.

Machine Learning

Once a steady state is reached for a Diffusion-Reaction simulation, the pattern that is formed is characteristic of the diffisuion and reaction parameters that were set for the evolution. Therefore, we can use a Convolutional Neural Network (CNN) to study the relevant structures in the images and solve the backwards problem, receiving final steady state images as inputs and predicting the system parameters.

It was first necessary to create a large database of 18,000 steady state systems.

Once this was done, it was possible to train the CNN. The training curves are shown below, where Early Stopping was implemented to avoid overfitting.

This model allows us to determine evolution parameters from steady states. To evaluate this qualitatively, we can take the CNN predictions and pump them back through the PDE solver, and visualize the difference between the steady state from the real parameters, and the steady state from the predicted parameters. Here are two examples from the test set.

gif load failed

gif load failed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors