Hard spheres in a box

import Pkg
Pkg.add(url="https://github.com/pnavaro/Uchiyama.jl")
    Updating git-repo `https://github.com/pnavaro/Uchiyama.jl`
   Resolving package versions...
     Project No packages added to or removed from `~/work/Uchiyama.jl/Uchiyama.jl/docs/Project.toml`
    Manifest No packages added to or removed from `~/work/Uchiyama.jl/Uchiyama.jl/docs/Manifest.toml`
using Plots
using Random
using Uchiyama


n = 50 # number of particles
ϵ = 0.02
c = trunc(Int, 200ϵ) # marker size

rng = MersenneTwister(1234)

hs = HardSpheres(rng, n, ϵ)
pc = ParticleCollisions(hs)
bc = BoxCollisions(hs)

steps = 1000

anim = @animate for _ in 1:steps

    dt = step!(hs, pc, bc)

    p = plot(size  = (200,200),
             xlims = (0,1),
             ylims = (0,1),
             grid  = false,
             axis  = nothing,
             framestyle= :box,
             legend=false,
             widen = false)

    scatter!( getindex.(hs.q,1),
              getindex.(hs.q,2),
              markershape  = :circle,
              markersize   = c,
              aspect_ratio = :equal)

end every 10

gif(anim, joinpath(@__DIR__, "hard_spheres.gif"), fps = 10)
Example block output

This page was generated using Literate.jl.