I currently have a code that solves $u_t+ cu_x=0$ with periodic boundary conditions, and constant $c$ (using an upwind method). I'm wondering how I would alter this code to solve something of the form $$u_t +c(x) u_x=0.$$ I'm thinking it will look of like

$$u_i^{j+1}=u_i^j-c_i \Delta t \left(\frac{u_i^j-u_{i-1}^j}{\Delta x} \right),$$ where $c_i=c(x_i)$?

I know that generally, the upwind scheme is stable for $c \frac{\Delta t}{\Delta x} \leq 1$. How would this change with a variable $c$? Am I better off using another method?

  • 2
    $\begingroup$ Your thinking is right, for variable C you can encounter CFL violation at a specific location, and that would set the time step limit for the whole thing. This situation often happens for non-uniform grids, if one cell is small then the CFL condition there would constrain the time step for the whole calculation. $\endgroup$ Oct 22, 2020 at 19:04
  • $\begingroup$ hm okay thank you! that's a bit concerning since I will be using a non-uniform grid, I'll look into the CFL condition. $\endgroup$
    – lrs417
    Oct 23, 2020 at 0:10
  • $\begingroup$ make sure that your advection field $c(x)$ is solenoidal, i.e. $\nabla \cdot c(x) = 0$, otherwise you will find that the advective effects will transport mass into or out of a region! In the absence of diffusion this would produce blowup. $\endgroup$
    – MPIchael
    Oct 23, 2020 at 8:10


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.