Switch to simpler initialization

This commit is contained in:
Dimitri Lozeve 2020-12-07 19:36:50 +01:00
parent 87c866eaed
commit c9215fdee9
4 changed files with 506 additions and 578 deletions

View file

@ -2,75 +2,4 @@
Reaction-Diffusion system simulation using the Gray-Scott model, in [[https://www.dyalog.com/][Dyalog APL]].
#+begin_src
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺ ⌺⌺⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺ ⌺⌺⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺
⌺⌺ ⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺
⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺
⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺ ⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺⌺ ⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺
⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺ ⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺ ⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺⌺
#+end_src
[[img.png]]

View file

@ -8,13 +8,12 @@
⍝ Parameters
dt da db f k←1.0 0.16 0.08 0.060 0.062
⍝ Initialization
N←200
A←0.8+0.2×?N N0
A[((N÷2)-10)+20;((N÷2)-10)+20]←0.5
B←0.2×?N N0
B[((N÷2)-10)+20;((N÷2)-10)+20]←0.25
N←500
A←N N1
B←0.1×?N N0
B[((N÷2)-10)+20;((N÷2)-10)+20]←1
⍝ Run
steps←10000
steps←20000
Ap Bp←(update⍣steps)A B
⍝ ' ⌺'[Ap>0.5]
⍝ Export to image file

BIN
img.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Before After
Before After

1000
img.pnm

File diff suppressed because it is too large Load diff