Solution (source code)

= Solution

Write $\alpha=\pi/\sqrt3$ and $L=\alpha^2+\pi^2=4\pi^2/3$. The primary <streamfunction> mode describes a single roll spanning the box, while the first magnetic mode describes the distortion of the vertical field by that roll. The second magnetic mode is independent of height and has twice the horizontal <wavenumber>, as generated by interaction of the first two modes. Take
$$
\psi=P(t)\sin(\alpha x)\sin(\pi z),\qquad
A=B(t)\sin(\alpha x)\cos(\pi z)+C(t)\sin(2\alpha x).
$$
These satisfy all the stated <boundary conditions>: the sine factors vanish on the vertical walls, $\psi$ and its <Laplacian> vanish on every wall, and $A_z$ vanishes at the horizontal walls.

Let $J(f,g)=f_xg_z-f_zg_x$. Since $\nabla^4\psi=L^2\psi$, $J(\psi,\nabla^4\psi)=0$. The magnetic Jacobians are
$$
J(\psi,B\sin(\alpha x)\cos(\pi z))
=-\frac{\alpha\pi PB}{2}\sin(2\alpha x),
$$
and
$$
J(\psi,C\sin(2\alpha x))
=\alpha\pi PC[\sin(\alpha x)-\sin(3\alpha x)]\cos(\pi z).
$$
Projecting onto the three retained <Fourier modes> and discarding the generated third horizontal harmonic yields, in the original time,
$$
\dot P=-\sigma LP+\sigma R\frac{\alpha^2}{L^2}P-\sigma\zeta Q\pi B,
$$
$$
\dot B=\pi P-\zeta LB-\alpha\pi PC,\qquad
\dot C=-4\zeta\alpha^2 C+\frac{\alpha\pi}{2}PB.
$$
Here $4\alpha^2=L$, so the second magnetic mode has the same linear diffusion rate as the first.

Choose $\tau=Lt$ and normalize the <amplitudes> by
$$
P=4\sqrt2\,a,\qquad B=\frac{3\sqrt2}{\pi}b,\qquad C=\frac{\sqrt3}{\pi}c.
$$
For example the coefficient of $a$ in $b'$ is $(\pi/L)(4\sqrt2)/(3\sqrt2/\pi)=1$, and that of $ab$ in $c'$ is $3$. The linear momentum coefficients become $r=R\alpha^2/L^3=9R/(64\pi^4)$ and $q=Q\pi^2/L^2=9Q/(16\pi^2)$. Therefore
$$
\boxed{a'=\sigma(r-1)a-\sigma\zeta qb,\qquad
b'=a-\zeta b-ac,\qquad c'=-\zeta c+3ab.}
$$
This is <three-mode porous magnetoconvection>. Because the nonlinear magnetic advection generates a discarded harmonic, it is a Galerkin approximation, not an exact three-dimensional invariant subspace of the <partial differential equations>.