Gray-Scottでの反応拡散系なチューリングパターン

 投稿者:moonlight  投稿日:2017年12月29日(金)11時58分56秒
  Macでも使えて重宝しているので
最近作ったものを上げてみます。
面白い。

OPTION BASE 0
!LET wd=16
LET wd=8
LET dlt=0.1
LET epr=0.1
LET duv=0.00095
LET dvv=0.0035
LET fv=0.09
LET kv=0.06
LET wdv=wd/epr
! Graphical Setting
SET WINDOW 0,wdv,0,wdv
SET POINT STYLE 7
LET cvmx=100
FOR ci=0 TO cvmx
   SET COLOR MIX(ci) 1-ci/cvmx,0,ci/cvmx
   SET COLOR MIX(ci+cvmx) 0,ci/cvmx,1-ci/cvmx
NEXT ci
DIM u(wdv,wdv),v(wdv,wdv),un(wdv,wdv),vn(wdv,wdv)
! loop
FOR tt=0 TO 0
! init
   FOR x=0 TO wdv-1
      FOR y=0 TO wdv-1
         LET u(x,y)=RND
         LET v(x,y)=RND
      NEXT y
   NEXT x
   ! main
   FOR t=0 TO 2000
      IF MOD(t,100)=0 THEN PRINT t
      ! draw
      SET DRAW MODE HIDDEN
      CLEAR
      FOR x=0 TO wdv-1
         FOR y=0 TO wdv-1
         !         SET POINT COLOR MIN(INT(u(x,y)*cvmx),cvmx)
            SET POINT COLOR INT(u(x,y)*cvmx)
            PLOT POINTS: x,y
         NEXT y
      NEXT x
      SET DRAW MODE EXPLICIT
      !
      FOR x=0 TO wdv-1
         LET lx=MOD(x-1+wdv,wdv)
         LET rx=MOD(x+1,wdv)
         FOR y=0 TO wdv-1
            LET ly=MOD(y-1+wdv,wdv)
            LET hy=MOD(y+1,wdv)
            LET dltepru=(u(x,hy)+u(x,ly)+u(lx,y)+u(rx,y)-4*u(x,y))/(epr*epr)
            LET un(x,y)=u(x,y)+dlt*(duv*dltepru+u(x,y)*u(x,y)*v(x,y)-(fv+kv)*u(x,y))
            LET dlteprv=(v(x,hy)+v(x,ly)+v(lx,y)+v(rx,y)-4*v(x,y))/(epr*epr)
            LET vn(x,y)=v(x,y)+dlt*(dvv*dlteprv-u(x,y)*u(x,y)*v(x,y)+fv*(1-v(x,y)))
         NEXT y
      NEXT x
      LET umax=un(0,0)
      LET umin=un(0,0)
      FOR x=0 TO wdv-1
         FOR y=0 TO wdv-1
            LET u(x,y)=un(x,y)
            LET v(x,y)=vn(x,y)
            IF umax<u(x,y) THEN
               LET umax=u(x,y)
            ELSEIF umin>u(x,y) THEN
               LET umin=u(x,y)
            END IF
         NEXT y
      NEXT x
      !   PRINT  t,umax,umin
   NEXT t
NEXT tt
END
 

戻る