The 1D Burgers equation is solved using explicit spatial discretization (upwind and central difference) with periodic boundary conditions on the domain (0,2). The 2D case is solved on a square domain of 2X2 and both explicit and implicit methods are used for the diffusive terms. Dirichlet boundary conditions are used along the edges of the domain.

Thanks Suraj for the effort. Unfortunately, I think there is a small error in this script. It is about the periodic boundary condition using the auxiliary variables ip,im. I think ip(nx) should be equal to index 2 ,i.e. ip(nx)=2. For im(1) it should be equal to nx-1, i.e. im(1)=nx-1.

Another issue that I do not understand is the if condition in the solution for loop, I am not sure what is it about, if you can explain?