I am using a Finite Difference scheme to solve a simple PDE in conserved form:$$\partial_t u = \partial_x (\partial_x u +au\partial_x u) = (1+a)\partial_x^2u +a(\partial_x u)^2 $$$$\frac{u_n+1,j - u_n,j}{dt} = (1+a) \frac{u_n+1,j+1 - 2 u_n+1,j + u_n+1,j-1}{dx^2} + a \bigg(\frac{u_n,j+1-u_n,j-1}{2 dx}\bigg)^2$$As you see, I use a fully implicit scheme for the diffusive part, and an explicit scheme for the first derivative bits (squared). It can easily be seen that the PDE states the conservation of the integral of $u(x,t)$, because:$$\partial_t \int_0^L u(x,t)dx=\int_0^L\partial_x(\partial_x u +au\partial_x u)dx=[\partial_x u +au\partial_x u]_0^L$$So if I impose Neumann boundary conditions, $$\partial_xu\bigg|_{0,L}=0$$ the integral of $u(x,t)$ must be conserved. I implement the Neumann BC saying that:which is second order (notice that I use three points to derive this, it is equivalent to approximating the function $u(x,t)$ at the boundary with a parabola)Now, when I solve and plot, I hardly see any conservation of the integral of $u(x,t)$. Is there something I am missing?The profile of u(x,t) (different colors different times):The integral of $u$ and its maximum over [0,L]:The quantity inside the $\partial_x(...)$ (different curves different times):
Conservation Law in Finite difference Scheme
numerical analysis