Algodoo/Phun generator in Ruby

I played a bit with a fun physics simulator Algodoo. After just a few simulations I bought the thing to support the briliant idea. There is also free Phun which lags behing the commercial version.
Julia created a shower simulation:

The pity thing is that the external interfaces of Algodoo are quite limited. At least you can edit the phn file. I wrote a simple Algodoo generator in Ruby to streamline the editing. You can add geoms easily like this

ph.addGeom('Box', :pos => [1,2], :size => [2,3])

I was wondering if Algodoo breaks sweat with few hundert objects, so I prepared a compaction simulation (1000 objects). Typical scenario: Prepare phn file as a template (extract with Total Commander), modify over and over again using a script like this one:

require 'phun'
include Math
ph = Phun::Phn.new("Compaction0.phn" )
defs = {:restitution => 0.5 }
s, n = 0, 0
500.times do
  pos = Array.rand(2, 2, -2)
  size = Array.rand(2, 0.2, 0.02)
  ph.addGeom('Box', :pos => pos, :angle => 0, :size => size, :defs => defs)
  s += size[0] * size[1]
  n += 1
end
500.times do
  pos = Array.rand(2, 2, -2)
  r = 0.01 + (0.10*rand)
  s += 3.14*r*r
  n += 1
  ph.addGeom('Circle', :pos => pos, :radius => r, :angle => 0, :defs => defs)
end
printf "%d bodies, total surface %g, mean = %g\n", n, s, s/n
ph.write(ph.dir + "Compaction.phn")

And this are the results:

You can get the code here.
The bodies are quite elastic; the thing feels more like rubber, less like stones.