Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#Source-only model
#参考:三浦岳、発生の数理、京都大学学術出版会、2015、p36-43
#julia v0.6
using Plots
gr()
dx=0.05
dt=0.1
u0=zeros(1/dx) #初期濃度
up=zeros(1/dx);up[1]=1.0 #産生濃度
Du=0.01
function left(arr)
prepend!(collect(Iterators.take(arr,length(arr)-1)),arr[1])
end
function right(arr)
append!(collect(Iterators.drop(arr,1)),arr[end])
end
function diffusion(arr)
Du*(left(arr)-arr+right(arr)-arr)/dx/dx
end
function dudt(arr)
arr+dt*(up+diffusion(arr))
end
u=u0
anim = @animate for g=0:150
plot(u,
xticks=0:1:20,
ylim=(0.0,2.5),
yticks=0.0:0.1:2.5,
seriestype=:bar,
title="gen = $g")
u=dudt(u)
end
@time gif(anim, "tmp/diff01.gif", fps = 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment