Not: Teknik sınırlamalar nedeniyle, bu gibi yüksek çözünürlüklü GIF resimlerinin küçük resimlerinde animasyon yoktur.
Bu dosya Wikimedia Commons deposunda bulunmaktadır ve diğer projeler tarafından kullanılıyor olabilir.
Aşağıda dosya açıklama sayfasındaki açıklama gösteriliyor.
Özet
AçıklamaGreen's function animation.gif
English: An intuitive animation that shows how Green's functions that solve a differential equation subject to a point-like source can be superposed to solve it subject to an arbitrary source.
using LinearAlgebra
using Plots
using Printf
function solve(f; x1=0, x2=1)
N = length(f)
x = Array(range(x1, x2, length=N))
h = x[2] - x[1]
diag = fill(+2/h^2, N-2)
semidiag = fill(-1/h^2, N-3)
L = Tridiagonal(semidiag, diag, semidiag)
u = L \ f[2:end-1]
u = cat([0], u, [0], dims=1)
return x, u
end
function animate()
# Store all Green's function solutions
N = 101
U = zeros(N, N)
p = plot()
for i in 1:N
f = [i == j ? 1 : 0 for j in 1:N]
x, u = solve(f)
U[i,:] = u
plot!(p, u)
end
# Solve a real problem
f1 = exp.(-(x.-0.5).^2 / (2*0.01))
x, u1 = solve(f1)
u = zeros(N)
barw = x[2]-x[1] # plot bars with no gap between them
anim = @animate for i in 1:N
y = @sprintf("%.2f", (i-1) / (N-1)) # as string
f2 = [i == j ? 1 : 0 for j in 1:N]
x, u2 = solve(f2)
u += u2 * f1[i]
colors = [i == j ? :black : :red for j in 1:N]
# for some reason, only (1599, 1600) gives a height that is divisible by 2 during mp4 generation
plot(layout=(2, 2), size=(1599, 1600), xlims=(0,1), xticks=([0, 0.5, 1], ["\$0\$", "\$x\$", "\$1\$"]), yticks=nothing, bar_width=barw, titlefontsize=40, tickfontsize=40, framestyle=:box, grid=false, legend=nothing, margin=10Plots.mm, top_margin=0Plots.mm)
# Plot point-source and Green's function solution
bar!(subplot=1, x[i:i], f2[i:i], color=:green, linecolor=:green, bar_width=barw, ylims=(0, 1.10), title="\$\\delta(x-$y)\$")
bar!(subplot=2, x, u2, color=:darkgreen, linecolor=:darkgreen, bar_width=barw, ylims=(0, 0.02), title="\$G(x,$y)\$")
# Plot full source and full solution
bar!(subplot=3, x[1:i], f1[1:i], color=:blue, linecolor=:blue, bar_width=barw, ylims=(0, 1.10), title="\$ \\hat{L}\\,(x) u(x) = f(x < $y) \$")
bar!(subplot=3, x[i+1:end], f1[i+1:end], color=:lightgrey, linecolor=:lightgrey, bar_width=barw, ylims=(0, 1.10))
bar!(subplot=4, x, u1, color=:lightgrey, linecolor=:lightgrey, bar_width=barw, ylims=(0, 0.06))
bar!(subplot=4, x, u, color=:darkblue, linecolor=:darkblue, bar_width=barw, ylims=(0, 0.06), title="\$ u(x) = {\\int}_{0}^{$y} \\! f(x') \\, G(x,x') \\, \\mathrm{d} x' \$")
end
mp4(anim, "green.mp4", fps=5)
run(`ffmpeg -i green.mp4 -vf "fps=10,scale=640:640:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 green.gif`)
end
animate()
Lisanslama
Ben, bu işin telif sahibi, burada işi aşağıdaki lisans altında yayımlıyorum:
atıf – Esere yazar veya lisans sahibi tarafından belirtilen (ancak sizi ya da eseri kullanımınızı desteklediklerini ileri sürmeyecek bir) şekilde atıfta bulunmalısınız.
benzer paylaşım – Maddeyi yeniden düzenler, dönüştürür veya inşa ederseniz, katkılarınızı özgünüyle aynı veya uyumlu lisans altında dağıtmanız gerekir.