K φ° Δt/h2 delay fps

Schrödinger equation on 256×256 square grid. |Ψ|2 for the travelling wave packet is plotted. Colors correspond to the wave function phase. Ψ = 0 at the square border. Data are stored in buffers.

The main kernel (see Schrödinger equation)

constant int n = 256, m = 255, sh = 8;

__kernel void kRelax(global float2* in0, global float2* in2,
    global float2* outp, float cx, float cy){
  int x = get_global_id(0),  y = get_global_id(1),  ny = y<<sh;
  if (x >= m || y >= m) return;
  float2 t = in2[x + ny] + in0[x + 1 + ny] + in0[x - 1 + ny] +
    in0[x + ((y + 1)<<sh)] + in0[x + ((y - 1)<<sh)];
  outp[x + ny] = (float2)(cx*t.x - cy*t.y, cy*t.x + cx*t.y);
}
See also Script with textures.
WebCL Demos     updated 5 Nov 2011