Fitxer:Green's function animation.gif

Fitxer original(640 × 640 píxels, mida del fitxer: 1,69 Mo, tipus MIME: image/gif, en bucle, 202 fotogrames, 20 s)

Descripció a Commons

Resum

Descripció
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.
Data
Font Treball propi
Autor Hersle

Julia code

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()

Llicència

Jo, el titular dels drets d'autor d'aquest treball, el public sota la següent llicència:
w:ca:Creative Commons
reconeixement compartir igual
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
Sou lliure de:
  • compartir – copiar, distribuir i comunicar públicament l'obra
  • adaptar – fer-ne obres derivades
Amb les condicions següents:
  • reconeixement – Heu de donar la informació adequada sobre l'autor, proporcionar un enllaç a la llicència i indicar si s'han realitzat canvis. Podeu fer-ho amb qualsevol mitjà raonable, però de cap manera no suggereixi que l'autor us dóna suport o aprova l'ús que en feu.
  • compartir igual – Si modifiqueu, transformeu, o generareu amb el material, haureu de distribuir les vostres contribucions sota una llicència similar o una de compatible com l'original

Llegendes

Afegeix una explicació d'una línia del que representa aquest fitxer

Elements representats en aquest fitxer

representa l'entitat

Algun valor sense element de Wikidata

Algun valor sense element de Wikidata

Historial del fitxer

Cliqueu una data/hora per veure el fitxer tal com era aleshores.

Data/horaMiniaturaDimensionsUsuari/aComentari
actual23:27, 21 des 2022Miniatura per a la versió del 23:27, 21 des 2022640 × 640 (1,69 Mo)HersleShow changing source values
19:36, 16 juny 2021Miniatura per a la versió del 19:36, 16 juny 2021640 × 640 (754 Ko)HersleReduced size to enable automatic animation
14:48, 16 juny 2021Miniatura per a la versió del 14:48, 16 juny 2021960 × 961 (1,3 Mo)HersleCross-wiki upload from en.wikipedia.org

La pàgina següent utilitza aquest fitxer:

Ús global del fitxer

Utilització d'aquest fitxer en altres wikis: