Multigrid algorithm below uses read/write to the same texture yet and do not work with DirectX 11 (Windows)

2D "mechanical" pacemaker

a k dt dx

it rel delay fps
On 2D plane positive u values are displayed by the red color, Ta by the green and stretching by the blue color. This script uses simple explicit algorithm and 512×512 float32 textures with the Neumann (CLAMP_TO_EDGE) boundary conditions. It makes 2 it time steps dt per frame. Use Alt- r, s keys to control the script (surprisingly they work in Firefox only).

Linear elasticity

For small deformations the equilibrium equation in the displacement formulation is [1]
(μ + λ)∇divu + μΔu + f = 0,     f = div(I Ta) = ∇Ta,
where u = (X, Y) is displacement of a point from equilibrium position, μ, λ are Lame parameters (we put μ = 1 ), Ta represents the active stress in cardiac tissue [2]
dTa/dt = ε(u) (kT u - Ta).
We consider tissue patch with fixed border uborder = 0. Using 2-nd order finite differences we obtain the approximate equation
(2 + λ)(Xi+1,j + Xi-1,j - 2Xi,j ) + Xi,j+1 + Xi,j-1 - 2Xi,j + (Yi+1,j+1 + Yi-1,j-1 - Yi+1,j-1 - Yi-1,j+1 )(1 + λ)/4 + h2Fxi,j = 0,
Fxi,j = (Tai+1,j - Tai-1,j )/2h
.     (*)

Multigrid algorithm

For weighted Jacobi relaxation [3] of (Xi,j , Yi,j ) on n×n grid we rewrite equations (*) as
2(3 + λ)Xi,j = (2 + λ)(Xi+1,j + Xi-1,j ) + Xi,j+1 + Xi,j-1 + (Yi+1,j+1 + Yi-1,j-1 - Yi+1,j-1 - Yi-1,j+1 )(1 + λ)/4 + h2Fxi,j
Multigrid algorithm is used next.

In this simulation λ = 1,   ω = 4/5. You can set all parameters in the script by hand.

[1] Linear elasticity (Wiki)
[2] M.P. Nasha, A.V. Panfilov   Electromechanical model of excitable tissue to study reentrant cardiac arrhythmias   Progress in Biophysics & Molecular Biology 85 (2004) 501.
[3] William L. Briggs, Van Emden Henson, Steve F. McCormick   A Multigrid Tutorial (look at "Tutorial Slides")

Heart rhythms     updated 2 Aug 2012