项目作者: barkm

项目描述 :
Grey-box method for modelling a reaction-advection-diffusion system
高级语言: Python
项目地址: git://github.com/barkm/grey-box.git
创建时间: 2018-10-07T09:13:31Z
项目社区:https://github.com/barkm/grey-box

开源协议:

下载


grey-box

Grey-box method for modelling a reaction-advection-diffusion system.

Background

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.



Installation

The necessary dependencies can be installed with Conda

  1. git clone https://github.com/barkm/grey-box
  2. conda env create -n grey-box -f environment.yml
  3. conda activate grey-box

Instructions

Generate data

Generate data by simulating the reaction-advection-diffusion system

  1. python generate_data.py

The simulations can be plotted by running

  1. python plot_simulation.py data/training.npz # plot training data
  2. python plot_simulation.py data/validation.npz # plot validation data
  3. python plot_simulation.py data/test.npz # plot test data

Train the model

The grey-box model can then be trained on the generated data by running

  1. python train.py

Note that the training may take several hours to complete.

The progress of the training can be inspected by running

  1. python plot_results.py

To resume a training session, simply run the training script again.

Test the model

The grey-box model can be used to simulate the system by running

  1. python test.py

The simulation can then be plotted by running

  1. python plot_simulation.py result/prediction.npz

and compared with the ground truth data by running

  1. python plot_simulation.py result/prediction.npz data/test.npz

References

Barkman, Patrik. “Grey-box modelling of distributed parameter systems.” (2018).