A rod with a flame

A flame is held to one end of a rod and taken away: the heat moves into the rod, and reaches the far end long after.

import sympy as sp
import pdemagic as pm

x, t = sp.symbols("x t", real=True)
T = sp.Function("T")(x, t)
flame = sp.exp(-(((t - 0.5) / 0.15) ** 2))

rod = pm.Problem(
    sp.Eq(T.diff(t), T.diff(x, 2) / 10),
    domain=pm.Box({x: (0, 1)}),
    time=(t, 0, 2),
    initial={T: 0},
    boundary={(x, 0): sp.Eq(T, flame), (x, 1): sp.Eq(T.diff(x), 0)},
)
plan = pm.plan(rod)
plan.grid.shape = [64]
pm.solve(rod, plan).plot(time=[0.3, 0.5, 0.7, 1.0, 2.0])
The figure that the example above draws. The figure that the example above draws.

What it shows

The heat equation in a rod between two walls, \(T_t = \tfrac{1}{10} T_{xx}\). What is given on a face may depend on time: the left end follows the flame, which is hottest at \(t = 0.5\), and the right end is insulated. At \(t = 0.7\) the flame is going out, the end has cooled with it, and the hottest place has moved into the rod. At \(t = 2\) the rod is warmest near its far end. The end that was heated is cold again, and the heat that is left flows back out through it.

What pdemagic decided

The planner chose exact propagation in the modes of the box (mode_propagator), on Chebyshev points. Because the flame changes in time, it takes 64 steps between two of the 21 recorded times, in which the value at the end is interpolated in time. The planner’s 24 points hold this solution to ten digits. The plan asks for 64, so that the lines of the picture are smooth.

More