Skip to content

Instantly share code, notes, and snippets.

@SoTaInverSpinel
Created September 19, 2018 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SoTaInverSpinel/0e6a3635b43217987bb9469bf1880d2a to your computer and use it in GitHub Desktop.
Save SoTaInverSpinel/0e6a3635b43217987bb9469bf1880d2a to your computer and use it in GitHub Desktop.
#1D-Turing pattern
#参考:三浦岳、発生の数理、京都大学学術出版会、2015、6.3
#julia v0.6
using Plots
gr()
dx=0.02
dt=0.01
N=convert(Int,1/dx)
dp=0.0002
dq=0.01
pInitial=rand(N)*0.01 #50-element Array
qInitial=rand(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
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
#pqAfterDt(pInitial,qInitial)
p=pInitial
q=qInitial
anim = @animate for m=0:6000
plot([p,q],
#xticks=0:1:20,
ylim=(-0.7,0.7),
yticks=-0.0:0.1:0.7,
#seriestype=:bar,
title="gen = $m",
label=["Activator","Inhibitor"])
p,q=pqAfterDt(p,q)
end every 30
@time gif(anim,"tmp/6_3_Turing_pattern.gif",fps=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment