# A note on convergence # Energy and Energy Error We use the nonlinear Schrodinger equation in the standard notation. $ i \frac{\partial \psi}{\partial x} + \frac{1}{2} \frac{\partial ^2 \psi}{\partial t^2} + \psi |\psi|^2 = 0 $ $\psi$ is a function that lives in a so-called Schwarz space $\mathcal{S}$ and we seek a functional $\mathcal{F}: \mathcal{S} \rightarrow \mathbb{C}$ that maps $\psi$ to a complex number $f$ for all values of $x$, i.e. the functional $\mathcal{F}$ should be constant of motion. The cubic NLS is a completely integrable equation, meaning it has an infinite number of such functionals (the integrals of motion) which are in involution (i.e. their poisson brackets with each other vanish). One such example is the energy, which is given by (for a periodic system with period $T$ in the transverse $t$-direction): $ E[\psi(x)] = -\frac{1}{2 T} \int_{0}^{T} dt \psi^*(x,t) \left(\frac{\partial^2}{\partial t^2} + |\psi(x,t)|^2 \right) \psi(x,t),\\ = T[\psi(x)] + V[\psi(x)] $ Where $T[\psi(x)]$ is the kinetic energy functional and $V[\psi(x)]$ is the potential energy functional. The energy is an integral of motion, thus: $ E[\psi(x)] = E[\psi(x = 0)] \equiv E_0 \, \forall \, x $ We define the energy error numerically as: $ \delta E(x) = E[\psi(x)] - E_0 $ We can also define an integrated energy error up to a certain point $x_{max}$ (usually $x_{max}$ is the length of the simulation, and we assume all simulations start at $x = 0$): $ I_{\delta E}(x_{max}) = \int_{0}^{x_{max}} \delta E(x) dx $ In code we can simply compute the energies as follows (python): ```python self.pe[i] = np.sum(-0.5*abs(self.psi[:,i])**4)/np.sum(abs(self.psi[:,i])**2) psi_k = np.fft.fftshift(np.fft.fft(self.psi[:,i]))/self.N_t self.ke[i] = np.sum(0.5*self.k**2*abs(psi_k)**2)/np.sum(abs(psi_k)**2) ``` # Some Calculations Here, I recreate figure 5 from our most recent paper draft. I use $N_t = 512$, so the results might be slightly different from the figures in the paper (I am not sure what value these use). We use the initial profile from Akhmediev _et al._'s paper: $ \psi_0 \equiv \psi(x=0,t) = e^{i\pi x/10}(1 + 0.002 \cos(\pi x/10)) $ ==This $\psi_0$ is not normalized== ![clipboard.png](vklmrl7pt-clipboard.png) Equivalent to Fig. 5(a) (i.e. 2nd order symplectic, dx=1e-4) ![clipboard.png](peXcKQ4c--clipboard.png) Equivalent to Fig. 5(b) (i.e. 2nd order symplectic, dx=5e-5) ![clipboard.png](R05Xeju5P-clipboard.png) Equivalent to Fig. 5(c) (i.e. 4th order symplectic, dx=1e-4) One can see clearly that the energy error peak heights in Fig (b) are far more uniform than in Fig (a), which has the numerical artefact third order wave. However, having relatively uniform energy error peaks is _not_ a convergence criteria, even legitimate higher order breathers will lead to a very large jump (several orders of magnitude) in the energy error, as shown in the figure below for a legitimate 3rd order breather. ![Third order breather using 2S, dx = 1e-3, N_t = 256](DgF26a1Rs-clipboard.png) ![clipboard.png](1s0aF405u-clipboard.png)! One can clearly see that the peak in the energy error corresponding to the AB3 dwarfs the energy error caused by the smaller peaks, i.e. $\delta E \sim |\psi|$, so this methodology is not useful for catching numerical fluke peaks. ==Why does the energy error look so weird for 4S?== ## Integrated Energy Error $I_{\delta E}$ vs $dx$ Here I show a log-log graph of the integrated energy error vs dx for a certain calculation. The results are as expected. We just need to define some criteria where we consider a calculation "converged enough". ![clipboard.png](74T027UnR-clipboard.png) # A sketch for convergence criteria 1. Ensure the height of the first peak in your simulation matches the prediction of the peak-height formula to at least 4 decimal places. We need to make this statement more precise. 2. The integrated/peak energy error should fit some criteria. But what criteria? When can we say a calculation is "converged enough"== Keep in mind that the energy error can change signs, especially at higher-order peaks, so we need to be careful in using the integrated energy error since some contributions will cancel out. # To Do - [x] Check fourth order algorithm energy error curves - [x] Check legitimate higher-order peaks and their energy error - [x] Check why my results are slightly different from Stanko's