Periodic heat and transport comparison (source code)

= Periodic heat and transport comparison
{title2=$u_H=1+e^{-t}\cos x+0.4e^{-9t}\cos(3x),\quad u_T=g(x-t)$}

Use dimensionless $x$ and $t$, the <periodic domain> $[0,2\pi]$, and the same <initial condition>
$$
g(x)=1+\cos x+0.4\cos(3x).
$$
With zero <PDE source term>, compare the <heat equation> $u_t=u_{xx}$ and the <transport equation> $u_t+u_x=0$. Their exact solutions are
$$
u_H(x,t)=1+e^{-t}\cos x+0.4e^{-9t}\cos(3x),\qquad u_T(x,t)=1+\cos(x-t)+0.4\cos(3(x-t)).
$$
Each <cosine> satisfies $\partial_x^2\cos(nx)=-n^2\cos(nx)$, so the <heat equation> reduces its amplitude according to $A_n'=-n^2A_n$. The <superposition principle> combines the constant and two <Fourier modes>. The <transport equation> shifts the argument of the entire profile. Both formulas meet the <initial condition> and matching <periodic boundary conditions> exactly.https://web.stanford.edu/class/math220b/handouts/heateqn.pdf[Stanford Math 220B heat-equation notes, periodic boundary conditions]{ref}

At $t=1$, the heat amplitudes are approximately $0.368$ and $0.0000494$: the small ripples disappear much sooner than the broad variation. The <transport equation> retains amplitudes $1$ and $0.4$, shifting the profile right by one unit with wraparound. Both preserve spatial average $1$, but only the <heat equation> approaches the uniform profile. This gives <diffusion> its usefulness for smoothing uneven <temperatures>, while the <transport equation> models a profile carried by a flow. The signed profile can represent a scaled <temperature> deviation.

\Image[/pde-transport-vs-diffusion.png]
{title=Exact evolution of one periodic profile: transport translates while diffusion preferentially removes short wavelengths}

To restore units, let physical position be $X=\ell x$ and time be $T=\tau t$. For $U_T=D U_{XX}$, the dimensionless coefficient is $D\tau/\ell^2$, with $D$ measured in length squared per time. For $U_T+cU_X=0$, it is $c\tau/\ell$, with $c$ measured in length per time. Both plotted coefficients equal one when $D=\ell^2/\tau$ and $c=\ell/\tau$. Thus the example compares specified models on the same scales, rather than identifying <diffusivity> with <velocity>.