Last active
September 19, 2018 11:33
-
-
Save SoTaInverSpinel/1845dda2faa5fdd661345e28907504e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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