3
The choice of $k$ is restricted also by the discretization of the source term. To see it, rewrite your scheme to
\begin{equation}
u_m^{n+1} = \left(1 - \frac{k(1-x_m)}{h} - k(1-x_m)\right) u_m^n + \frac{k (1-x_m)}{h} u_{m+1}^n \,.
\end{equation}
You need
$$
1 - \frac{k(1-x_m)}{h} - k(1-x_m) \ge 0
$$
for all $x_m$. Taking $x_m=0$ (the worst case scenario) you ...
2
I've identified a few "problems":
Your analytical solution isn't quite correct. The correct analytical solution to the "infinite domain" advection equation is supposed to be $u(t,x) = u_0(x-at)$. Because you have periodic boundaries, you need to properly account for this by making sure $x-at$ is properly wrapped.
I replaced your ...
1
I found a few issues with your implmentation:
you should replace $t$ by $dt$ in your discrete equation (both in your code and in the question), otherwise it makes no sense !
the second part of your equation (with $a$) seems incomplete or wrong, and there's a mix between $F$ and $f$. Moreover, you flux evaluation is wrong: Fplus should read 0.5*Up**2 for ...
1
It turns out that the main problem here was that I thought just naively extending the 1D advection
$$ \rho^{n+1}_{i} = \rho^n_{i} + u\frac{\Delta t}{\Delta x}(\rho^n_{i-1/2} - \rho^n_{i+1/2}) $$
to 2D just by adding the $y$ term like this:
$$ \rho^{n+1}_{i,j} = \rho^n_{i,j} + u\frac{\Delta t}{\Delta x}(\rho^n_{i-1/2,j} - \rho^n_{i+1/2,j}) + v\frac{\Delta t}...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
advection × 75finite-difference × 31
pde × 27
hyperbolic-pde × 13
fluid-dynamics × 12
boundary-conditions × 12
stability × 9
numerics × 8
python × 5
advection-diffusion × 5
diffusion × 5
crank-nicolson × 5
navier-stokes × 4
finite-element × 3
matlab × 3
finite-volume × 3
implicit-methods × 3
conservation × 3
eigenvalues × 2
convergence × 2
discretization × 2
discontinuous-galerkin × 2
spectral-method × 2
optimization × 1
computational-physics × 1