In [4]:
using PyPlot
using PyCall
@pyimport matplotlib.animation as anim


INFO: Loading help data...

Ejemplo Hector


In [64]:
#Voy a crear una matriz grandota donde la primer entrada es el tiempo, ustede háganlo más eficiente sin usar tanta memoria
Lx=20 #Posiciones en x
Ly=20 #Posiciones en y
N=20 #Tiempos
P=zeros(N,Lx,Ly)
P[1,Lx/2,Ly/2]=1 #Empezamos en la casilla (1,1)

for i in 2:N #Loop tiempo
    for j in 1:Lx #Loop en x
        for k in 1:Ly #Loop en y
            if j==1
                if k==1
                    P[i,j,k]=1/4*(P[i-1,j+1,k]+P[i-1,j,k+1])
                elseif k==Ly
                    P[i,j,k]=1/4*(P[i-1,j,k-1]+P[i-1,j+1,k])
                else
                    P[i,j,k]=1/4*(P[i-1,j,k-1]+P[i-1,j+1,k]+P[i-1,j,k+1])
                end
            elseif j==Lx
                if k==1
                    P[i,j,k]=1/4*(P[i-1,j-1,k]+P[i-1,j,k+1])
                elseif k==Ly
                    P[i,j,k]=1/4*(P[i-1,j,k-1]+P[i-1,j-1,k])
                else
                    P[i,j,k]=1/4*(P[i-1,j,k-1]+P[i-1,j-1,k]+P[i-1,j,k+1])
                end
            else
                if k==1
                    P[i,j,k]=1/4*(P[i-1,j-1,k]+P[i-1,j+1,k]+P[i-1,j,k+1])
                elseif k==Ly
                    P[i,j,k]=1/4*(P[i-1,j-1,k]+P[i-1,j,k-1]+P[i-1,j+1,k])
                else
                    P[i,j,k]=1/4*(P[i-1,j-1,k]+P[i-1,j,k-1]+P[i-1,j+1,k]+P[i-1,j,k+1])
                end
            end
        end
    end
end

In [65]:
#Crear un arreglo de la matriz en cada tiempo
ani=Any[]
for k in 1:20
    push!(ani,squeeze(P[k,:,:],1))
end

In [66]:
fig=figure(figsize=(3,3))
ims = [[imshow(ani[i])] for i=1:20] ;



In [71]:
fin = anim.ArtistAnimation(fig, ims, interval=100, blit=true) 
fin[:save]("caminante2D.mp4", extra_args=["-vcodec", "libx264", "-pix_fmt", "yuv420p"])
display("text/html", string("""<video autoplay controls><source src="data:video/x-m4v;base64,""",base64(open(readbytes,"caminante2D.mp4")),"""" type="video/mp4"></video>"""))


Histeresis


In [5]:
using Histeresis

In [23]:
L = 20
R = 2
espin = -1
H_set = 15

m = edo_inicial(L,R,espin)

edos = microEstados_aumenta_H!(m,H_set,espin) ;

In [29]:
fig=figure(figsize=(3,3))
cuadros = [[imshow(edos[i], interpolation="none", vmin=-1, vmax=1)] for i=1:length(edos)] ;



In [30]:
fin = anim.ArtistAnimation(fig, cuadros, interval=200, blit=true) 
fin[:save]("histeresis.mp4", extra_args=["-vcodec", "libx264", "-pix_fmt", "yuv420p"])
display("text/html", string("""<video autoplay controls><source src="data:video/x-m4v;base64,""",base64(open(readbytes,"histeresis.mp4")),"""" type="video/mp4"></video>"""))



In [ ]: