https://github.com/dlozeve/reaction-diffusion
Reaction-Diffusion system simulation in Dyalog APL and BQN
https://github.com/dlozeve/reaction-diffusion
bqn dyalog-apl gray-scott netpbm reaction-diffusion
Last synced: 3 months ago
JSON representation
Reaction-Diffusion system simulation in Dyalog APL and BQN
- Host: GitHub
- URL: https://github.com/dlozeve/reaction-diffusion
- Owner: dlozeve
- Created: 2020-12-07T18:33:01.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-03T20:51:52.000Z (over 2 years ago)
- Last Synced: 2025-07-16T07:12:42.939Z (11 months ago)
- Topics: bqn, dyalog-apl, gray-scott, netpbm, reaction-diffusion
- Language: APL
- Homepage:
- Size: 930 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* Reaction-Diffusion Model
[[https://en.wikipedia.org/wiki/Reaction%E2%80%93diffusion_system][Reaction-Diffusion system]] simulation using the Gray-Scott model, in [[https://www.dyalog.com/][Dyalog APL]] and [[https://mlochbaum.github.io/BQN/index.html][BQN]].
[[img.png]]
** Running the Dyalog version
[[https://www.dyalog.com/download-zone.htm][Install Dyalog APL]] and [[https://en.wikipedia.org/wiki/Netpbm][Netpbm]] (~apt-get install netpbm~). Then run
~make~. This will create the =img.pnm= and =img.png= files in the
current directory.
The images are generated from APL by creating a [[https://en.wikipedia.org/wiki/Netpbm][Netpbm]] file, which are
nice because they are just plain-text. It is then converted to PNG
using ~pnmtopng~.
** Running the BQN version
Clone [[https://github.com/dlozeve/bqn-graphics][bqn-graphics]] at the same level than this repository. Run the
=./generate_animation.sh= script. It requires [[https://www.gnu.org/software/parallel/][GNU Parallel]], [[https://en.wikipedia.org/wiki/Netpbm][Netpbm]],
and ffmpeg.
PNM and PNG images are in the =out= directory, and the animation is in
=out.mp4=.
** Parameters
All the parameters are defined directly in [[grayscott.dyalog]].
The parameters of the model are:
- ~dt~: the time step,
- ~da~: the diffusion rate for A,
- ~db~: the diffusion rate for B,
- ~f~: the feed rate for A,
- ~k~: the kill rate for B.
Additionally, you can change ~N~, the size of the grid, and ~steps~,
the number of time steps to simulate.
Finally, the function ~mat2pbm~ exports to a bitmap (black and white)
format, while ~mat2pgm~ exports a grayscale image.
** References
[[http://www.karlsims.com/rd.html][This page]] gives a good explanation of the Gray-Scott model. [[https://github.com/EnvModelling/Env_modelling/blob/master/Spatio-temporal-modelling/Reaction_diffusion_2D.ipynb][This
notebook]] gives a nice example of implementation in Python with
Numpy. For even more details on the model and a classification of
pattern, see [[http://mrob.com/pub/comp/xmorphia/][this page]].