Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#2D-Turing pattern陽解法
#参考:三浦岳、発生の数理、京都大学学術出版会、2015、6.6
#julia v0.6
using Plots
gr()
dx=0.04
dt=0.02
N=convert(Int,1/dx)
dp=0.0002
dq=0.01
pInitial=rand(N,N)*0.01
qInitial=rand(N,N)*0.01
f(p,q)=0.6*p-q-p.^3
g(p,q)=1.5*p-2*q
diffusion(v)=circshift(v,1)+circshift(v,-1)-2*v+circshift(v,(0,1))+circshift(v,(0,-1))-2*v
diffusionP(v)=dp*diffusion(v)/(dx*dx)
diffusionQ(v)=dq*diffusion(v)/(dx*dx)
function pqAfterDt(p,q)
p=p+dt*(f(p,q)+diffusionP(p))
q=q+dt*(g(p,q)+diffusionQ(q))
return p,q
end
p=pInitial
q=qInitial
#to t=60
anim = @animate for m=0:3000
t=round(m*dt,3)
heatmap(p,
#xticks=0:1:20,
#ylim=(-0.7,0.7),
#yticks=-0.0:0.1:0.7,
#seriestype=:bar,
title="t = $t ",
aspect_ratio=:equal
)
p,q=pqAfterDt(p,q)
end every 25
@time gif(anim,"tmp/6_6_2D_pattern.gif",fps=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment