Heat on a Torus
The cells of a power diagram make a mesh for finite volumes: one unknown per cell, and one flux per facet. On a torus, the facets across the period are fluxes like the others. The cell complex gives everything the scheme needs:
- the volumes of the cells;
- for each facet, its area and its two seeds;
- the vector from one seed to the other. With a periodicity, this points to the image of the second seed that the facet faces.
We solve the heat equation on the unit torus,
with the classical two-point flux: the flux through the facet
where
The mesh
The seeds are spread on the torus by a Lloyd quantization with the same periodicity. The positions it returns stay next to where they started, so % 1.0 brings them back into the square.
import numpy as np
import scipy.sparse as sp
import sdot
positions = np.asarray( sdot.quantization( sdot.Box( nb_dims = 2 ), 1500, seed = 0, periodicity = True ) ) % 1.0
pd = sdot.PowerDiagram( positions, boundaries = sdot.box_half_spaces( [ 0, 0 ], [ 1, 1 ] ), periodicity = True )
cx = pd.cell_complex()The scheme
Each facet adds its transmissibility to the matrix
n = len( positions )
a, b = cx.facets.sides.T
keep = a != b
a, b = a[ keep ], b[ keep ]
t = cx.facets.measures[ keep ] / np.linalg.norm( cx.facets.seed_vectors[ keep ], axis = 1 )
L = sp.coo_matrix( ( np.concatenate( [ t, t, -t, -t ] ),
( np.concatenate( [ a, b, a, b ] ), np.concatenate( [ a, b, b, a ] ) ) ), shape = ( n, n ) ).tocsr()
M = sp.diags( cx.cells.measures )Below, a hot disc and a cold band diffuse. The disc sits across the corner of the square, so it is a single disc on the torus. Each flux leaves one cell and enters another, so the total heat
Use the slider at the top of the viewer (or the play button) to go through time.
Convergence
The mode
| cells | decay of the scheme | exact | relative error |
|---|---|---|---|
| 250 | 0.67706 | 0.67409 | |
| 1000 | 0.67483 | 0.67409 | |
| 4000 | 0.67427 | 0.67409 |
Each time the number of cells is multiplied by 4, the cell size
The figures and the table are generated by docs/examples/finite_volumes.py.