Grey-box method for modelling a reaction-advection-diffusion system.
Consider a chemical reaction in which the reactants A and B react to give the product C according to the chemical reaction
α A + β B ⟶ γ C
where α, β and γ are referred to as stoichometric coefficients. The rate of this reaction is given by the reaction rate R.
The reaction takes place in a channel in which a fluid flows from left to right. The chemicals are then transported through the fluid by advection and diffusion. This can be modelled by the reaction-advection-diffusion equations
ċ1 + w · ∇ c1 - D ∇ 2 c 1 = - α R(c1, c2) + g1
ċ2 + w · ∇ c2 - D ∇ 2 c 2 = - β R(c1, c2) + g2
ċ3 + w · ∇ c3 - D ∇ 2 c 3 = γ R(c1, c2) + g3
where c1 = [A], c2 = [B], c3 = [C] denote the concentrations of the chemicals, w is an advective velocity field and D is the diffusion constant. The source terms g1, g2, g2 correspond to dissolving chemicals into the fluid.
Now assume that the coefficients α, β, γ and the reaction rate R are unknown.
The grey-box method implemented in this repository combines the reaction-advection-diffusion equations with a neural network to model the system. By measuring the concentrations of the chemicals in the fluid, the parameters of the network can be adjusted so as to model the stoichometric coefficients and the reaction rate.
In the animation below we can see the two reactants A and B react in the channel to give the product C downstream. The black dots correspond to sensors through which the concentrations c1, c2 and c3 can me measured.
The necessary dependencies can be installed with Conda
git clone https://github.com/barkm/grey-box
conda env create -n grey-box -f environment.yml
conda activate grey-box
Generate data by simulating the reaction-advection-diffusion system
python generate_data.py
The simulations can be plotted by running
python plot_simulation.py data/training.npz # plot training data
python plot_simulation.py data/validation.npz # plot validation data
python plot_simulation.py data/test.npz # plot test data
The grey-box model can then be trained on the generated data by running
python train.py
Note that the training may take several hours to complete.
The progress of the training can be inspected by running
python plot_results.py
To resume a training session, simply run the training script again.
The grey-box model can be used to simulate the system by running
python test.py
The simulation can then be plotted by running
python plot_simulation.py result/prediction.npz
and compared with the ground truth data by running
python plot_simulation.py result/prediction.npz data/test.npz
Barkman, Patrik. "Grey-box modelling of distributed parameter systems." (2018).