Learning Scientific Programming with Python (2nd edition)
P7.5.3: The two-dimensional advection equation
Question P7.5.3
The two-dimensional advection equation may be written $$ \frac{\partial U}{\partial t} = -v_x\frac{\partial U}{\partial x} - v_y\frac{\partial U}{\partial y}, $$ where $\boldsymbol{v} = (v_x, v_y)$ is the vector velocity field giving the velocity components $v_x$ and $v_y$, which may vary as a function of position, $(x, y)$. In a similar way to the approach taken in Example E7.23, this equation may be discretized and solved numerically. With forward-differences in time and central-differences in space, we have $$ u_{i,j}^{(n+1)} = u_{i,j}^{(n)} - \Delta t \left[ v_{x;i,j}\frac{u_{i+1,j}^{(n)} - u_{i-1,j}^{(n)}}{2\Delta x} + v_{y;i,j}\frac{u_{i,j+1}^{(n)} - u_{i,j-1}^{(n)}}{2\Delta y}\right]. $$ Implement this approximate numerical solution on the domain $0\le x < 10, 0\le y< 10$ discretized with $\Delta x = \Delta y = 0.1$ with the initial condition $$ u_0(x,y) = \exp\left( - \frac{(x-c_x)^2 + (y-c_y)^2}{\alpha^2}\right), $$ where $(c_x, c_y) = (5, 5)$ and $\alpha = 2$. Take the velocity field to be a circulation at constant speed $0.05$ about an origin at $(7,5)$.