"""Complete original maps from the pump plane to its viscous invariant space."""
from pathlib import Path
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.patches import FancyBboxPatch
P=Path(__file__).resolve().parent
fig,ax=plt.subplots(figsize=(14,7))
fig.subplots_adjust(left=.03,right=.97,bottom=.10,top=.88)
ax.set(xlim=(0,14),ylim=(0,8));ax.axis('off')
ax.add_patch(FancyBboxPatch((.2,1.1),13.6,6.4,boxstyle='round,pad=.10',fc='#edf5f5',ec='#157b80',lw=2))
ax.text(7,6.65,r'$\mathcal{K}=\overline{\mathrm{span}_{\mathbb{R}}\{\Delta^j\Phi_1,\Delta^j\Phi_2:j\geq0\}}^{\,L^2}$',ha='center',fontsize=20)
ax.text(7,5.9,'The actual infinite-dimensional space generated by diffusion',ha='center',fontsize=13)
ax.add_patch(FancyBboxPatch((.8,3),4.6,2,boxstyle='round,pad=.08',fc='white',ec='#194b64',lw=2))
ax.text(3.1,4.5,r'$S=\mathrm{span}_{\mathbb{R}}\{\Phi_1,\Phi_2\}$',ha='center',fontsize=17)
ax.text(3.1,3.8,r'$P_Su=\frac{\langle u,\Phi_1\rangle}{A}\Phi_1+\frac{\langle u,\Phi_2\rangle}{B}\Phi_2$',ha='center',fontsize=15)
ax.annotate('',xy=(8,4),xytext=(5.6,4),arrowprops=dict(arrowstyle='->',color='#bc5b11',lw=2.5))
ax.text(6.8,4.4,r'$(I-P_S)\Delta$',ha='center',fontsize=15,color='#a84f0b')
ax.text(10.6,4.5,r'$g_1=\Delta\Phi_1+\frac{G}{A}\Phi_1$',ha='center',fontsize=18)
ax.text(10.6,3.65,r'$\|g_1\|_2^2=\|\Delta\Phi_1\|_2^2-\frac{G^2}{A}>0$',ha='center',fontsize=15)
ax.text(7,2.45,r'$\Delta\mathcal{K}\subset\mathcal{K},\qquad e^{\nu t\Delta}\mathcal{K}\subset\mathcal{K},\qquad C_{\rm pump}(\mathcal{K},\mathcal{K})\subset S$',ha='center',fontsize=16)
ax.text(7,1.65,r'$u_t=\nu\Delta u+C_{\rm pump}(u,u),\quad \|u(t)\|_2\leq e^{-4\pi^2\nu r_0^2t}\|u_0\|_2$',ha='center',fontsize=17)
ax.text(7,.6,r'$A=\|\Phi_1\|_2^2,\quad B=\|\Phi_2\|_2^2,\quad G=\|\nabla\Phi_1\|_2^2,\quad r_0=q^{n_*}(1-\delta)$',ha='center',fontsize=14)
fig.suptitle('Diffusion leaves the two-field plane and defines its exact receiving space',fontsize=19)
fig.text(.5,.035,'Exercise 5, EX20–EX29: complete construction and global viscous proof. Boxes show inclusions, not a finite-dimensional picture of the whole space.',ha='center',fontsize=10)
fig.text(.5,.008,'Human comparison: Tao, arXiv:1402.0290v3, local-cascade definition at lines 450–474. This invariant-space calculation is an editorial derivation.',ha='center',fontsize=10)
for ext in ['png','svg']:fig.savefig(P/f'original-viscous-pump-space.{ext}',dpi=160)
print('Rendered original viscous-pump space.')
