logoiMonad.com


Chaotic scattering with Povray

Posted in povray, science by zoo on the July 27th, 2008

In this post I will talk about the four-sphere scattering system. This is one of the simples examples of chaotic scattering. We can envision scattering as a small particle (electron for example) that moves toward a fixed target (group of atoms), interacts with it, and then leaves the region. These systems can have multiple exit modes and typically have fractal phase space boundaries separating the sets of initial conditions (basins) going to the various exits. In many cases, the scattering may have exceedingly complex behavior. Chaotic scattering problems are studied intensively recently. There are connections between them and chaotic behavior in quantum systems, periodic orbit theory and Poincaré recurrence theorem.

I have read a paper on chaotic scattering long time ago and decided to reproduce the experiment described in it (sorry, lost the original reference but you can search for “chaotic scattering”). In original paper leasers and mirror spheres are used but I have no spare lasers around so I decided to simulate experiment with Povray.

Experiment:
Basically we put 4 spheres together that have surfaces perfectly reflecting the light. They are arranged in the vertices of tetrahedron in the way that each sphere is touching the other 3 (fig. 1). We can use light beam, point it at the one face of the tetrahedron and look at the other 3 faces. It is expected that light will scatter multiple times between spheres and escape from one of the 4 faces chaotically which consequently led to fractal image similar to Sierpiński triangle.
I have used another approach. Camera is positioned to look at one tetrahedron face. All faces are illuminated by infinite surfaces colored differently. When light escapes from given point of the first face there can be only one source where it is coming from (ask yourself why?). Color of the point depend from the color of the source surface.

four-spheres

fig. 1 - Spheres arrangement

This is the code I used for the spheres definition:

#declare Sphere_Color = color rgb < 1.0, 1.0, 1.0> ;

#declare SphereObject = sphere {
< 0 , 0 , 0 > , 1
texture { finish { DefaultFinish } }
}
#declare R = 3.00000;
#declare CRadius = R * 0.866025 ;
#declare s4 = union {
object { SphereObject // C_1
pigment { Sphere_Color }
scale CRadius
translate <0.000000*R,1.000000*R,0.000000*R>
}
object { SphereObject // C_2
pigment { Sphere_Color }
scale CRadius
translate <0.866025*R,-0.500000*R,0.000000*R>
}
object { SphereObject // C_3
pigment { Sphere_Color }
scale CRadius
translate <-0.866025*R,-0.500000*R,0.000000*R>
}
object { SphereObject // C_4
pigment { Sphere_Color }
scale CRadius
translate <0.000000*R,0.000000*R,-1.43*R>
}
}

You can check the spheres coordinates, one of them is probably not touching others, but it is not so important and the fractal behavior can be seen in this case too.

This is the definition of light emitting planes:

#declare RR = -10000;
#declare IN = 0.9;
#declare Lightplane1 = plane {<0.000000*RR,1.000000*RR,1.802776*RR>, 1
pigment {color rgb <0.70, 0.01, 0.01>}
finish { PlaneFinish }
}

#declare Lightplane2 = plane {<0.866025*RR,-0.500000*RR,1.802776*RR>, 1
pigment {color rgb <0.93, 0.70, 0.01>}
finish { PlaneFinish }
}

#declare Lightplane3 = plane {<-0.866025*RR,-0.500000*RR,1.802776*RR >, 1
pigment {color rgb <0.45, 0.35, 0.01>}
finish { PlaneFinish }
}

#declare Lightplane4 = plane { < 0,0,1 >, 100
pigment {color rgb <0.45, 0.05, 0.45>}
finish { PlaneFinish }
}

light_source {
< 0.000000 * RR, 1.000000 * RR, 1.802776 * RR >
color rgb < IN, IN, IN >
looks_like { Lightplane1 }
photons {refraction off reflection on}
}

light_source {
< 0.866025 * RR,-0.500000 * RR, 1.802776 * RR >
color rgb < IN, IN, IN >
looks_like { Lightplane2 }
photons {refraction off reflection on}
}

light_source {
< -0.866025 * RR,-0.500000 * RR, 1.802776 * RR >
color rgb < IN, IN, IN >
looks_like { Lightplane3 }
photons {refraction off reflection on}
}

light_source {
<0, 0, 0>
color rgb < IN, IN, IN >
looks_like { Lightplane4 }
photons {refraction off reflection on}
}

Here you can play a lot with the “plane finish” and colors. I have used the following settings:

#declare PlaneFinish = finish {
ambient 0.6
diffuse 0.2
reflection 0.1
brilliance 0.3
specular 0.4
}

Also fully reflecting spheres are defined with:

#declare DefaultFinish = finish {
ambient 0.0
diffuse 0.00
specular 1.0
roughness 0.01
metallic
reflection {
1.0
metallic
}
}

I found that adding a little “roughness” helps to the realistic view of the sphere surfaces.

During the rendering light rays reflects multiple times from sphere surfaces. Povray have some restrictions on how many times to reflect a ray before it stops. This is controlled by max_trace_level and (since version 3.0) adc_bailout value settings. I have set max_trace_level to maximum of 256. This leads to very long time to render some frames.

Some raytraced images:

Here pattern like Sierpiński triangle is observed. This pattern is appearing because each sphere reflect other 3 spheres that are arranged in triangle.

The best way to see and zoom fractals is to play with the camera zooming and look_at. I have prepared also .INI file to control rendering options and create animation.


Google direct link video

Video Encoding:

Animation is created from 3000 frames. To render them I used two separate rendering processes each rendering different frames on different computing core. New version 3.7 (beta) of Povray now supports SMP and multi-core systems and will make this easier.

Each frame is saved in TGA format and video is encoded with mencoder.

This is basic set of encoding options:
mencoder mf://*.tga -mf w=480:h=360:fps=25:type=tga -ovc lavc -oac copy -o out.avi

Quality of resulting movie is not high so I played a little with the options and
finally used this set
mencoder mf://*.tga -mf w=400:h=304:fps=25:type=tga -ovc lavc -lavcopts
vcodec=mpeg4:mbd=2:trell:v4mv:last_pred=2:dia=-1:
vmax_b_frames=1:cmp=3:subcmp=3:precmp=0:keyint=2:
sc_threshold=-100000:psnr -oac copy -o out.avi

Probably there can be found better combination. The most important seems to be
the keyint option that sets the maximum interval between keyframes in frames. These options give PSNR (Peak signal-to-noise ratio) of approximately 38 dB. Sadly google process the videos that are uploaded and most of quality is lost.

POV code and INI file.

Roman Cheplyaka - Hpysics demo

Posted in Haskell, functional programming by zoo on the July 11th, 2008

Roman Cheplyaka have posted a short video demonstrating the physics engine in Haskell he is working on during his Summer of Code Project - Hphysics


YouTube direct link video

More information about progress on this project can be found on his blog: Building physics engine in Data Parallel Haskell

More: Hphysics project

Concurrent and multicore programming in Haskell

Posted in Haskell, functional programming by zoo on the July 5th, 2008

Bryan O’Sullivan Lecture on writing programs in Haskell for multicore systems.

Bryan is is also a co-author of the upcoming O’Reilly book Real World Haskell

Open standard for parallel computing across GPUs and CPUs

Posted in GPU by zoo on the July 5th, 2008

There is new initiative to create open standarts for parallel computing across GPUs and CPUs. I think this will be the next step in GPU computing. As I underspend this will be new open standard (something like OpenGL) that will be portable across different platforms. The name of the new standard is Open Computing Language (OpenCL):

Khronos™ Group announced today the formation of a new Compute Working Group to create royalty-free, open standards for programming heterogeneous data and task parallel computing across GPUs and CPUs…”

It is targeted at C language but I do not think there will be any obstacles to use it from other languages too.

More on the Khronos Web Page