Add reaction-diffusion in BQN, with video generation script

This commit is contained in:
Dimitri Lozeve 2023-10-03 13:38:33 +02:00
parent 2dd11ef413
commit c607954d34
5 changed files with 45 additions and 0 deletions

31
grayscott.bqn Normal file
View file

@ -0,0 +1,31 @@
PBM,PPM•Import"../bqn-graphics/pnm.bqn"
Inferno,Magma,Viridis•Import"../bqn-graphics/colormaps.bqn"
# Parameters
dtdadbfk1.0,0.16,0.08,0.060,0.062
n500 # image size
m10 # seed size at the center of the image
# Discrete Laplacian
Lapl(+´1¯1(˘)¨<)-4×
# Gray-Scott update
UpdateA{𝕨+dt×(da×Lapl 𝕨)+(-𝕨×𝕩2)+f×1-𝕨}
UpdateB{𝕩+dt×(db×Lapl 𝕩)+(𝕨×𝕩2)-𝕩×k+f}
Update(UpdateAUpdateB)´
# Initialization
ann1
Mask{𝕩𝕩(-𝕨𝕨+𝕩÷2)(2×𝕨𝕨)1}
b(m Mask n)0.1×nn•rand.Range 0
# Run
Step{stepsize 𝕊 iab:
•term.OutRaw"."
•term.Flush @
apbpUpdatestepsize ab
("out/step"(¯5•Fmt¨5-i)".pnm")•file.Chars (PPM 255×>Inferno¨1-a)@+10
(i+1)apbp
}
50 Step•_while_(600>) 0ab
•Out""