Created
September 19, 2018 11:37
-
-
Save SoTaInverSpinel/2daf543a248f3e16a84a86d534332b92 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-Sink model | |
#参考:三浦岳、発生の数理、京都大学学術出版会、2015、4.3 | |
#julia v0.6 | |
using Plots | |
gr() | |
dx=0.05 # | |
dt=0.1 #単位時間 | |
u0=zeros(1/dx) #初期濃度 | |
Du=0.01 | |
function fixConc(arr) | |
v=arr | |
v[1]=1.0 | |
v[end]=0.0 | |
return v | |
end | |
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) | |
fixConc(arr+dt*diffusion(arr)) | |
end | |
u=u0 | |
anim = @animate for g=0:250 | |
plot(u, | |
xticks=0:1:20, | |
ylim=(0.0,1.5), | |
yticks=0.0:0.1:1.5, | |
seriestype=:bar, | |
title="gen = $g") | |
u=dudt(u) | |
end | |
@time gif(anim, "tmp/diff02.gif", fps = 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment