Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
28

The equation you're solving does not permit right-going solutions, so there is no such thing as a reflecting boundary condition for this equation. If you consider the characteristics, you'll realize that you can only impose a boundary condition at the right boundary. You are trying to impose a homogeneous Dirichlet boundary condition at the left boundary, ...


19

Starting with the advection equation is conservative form, $$ \frac{\partial u}{\partial t} = -\frac{\partial (\boldsymbol{v} u)}{\partial x} + s(x,t) $$ The Crank-Nicolson method consists of a time averaged centered difference. $$\frac{u_{j}^{n+1} - u_{j}^{n}}{\Delta t} = -\boldsymbol{v} \left[ \frac{1-\beta}{2\Delta x} \left( u_{j+1}^{n} - u_{j-1}^{n} \...


15

I think that one of your problems is that (as you observed in your comments) Neumann conditions are not the conditions you are looking for, in the sense that they do not imply the conservation of your quantity. To find the correct condition, rewrite your PDE as $$ \frac{\partial \phi}{\partial t} = \frac{\partial}{\partial x}\left( D\frac{\partial \phi}{\...


15

The fundamental quantity in transport is the flux, $\mathbf v u$ for advection. The divergence theorem states that $$\int_\Omega \nabla\cdot (\mathbf v u) = \int_{\partial \Omega} (\mathbf v u) \cdot \mathbf n . $$ An equation is conservative when it is preserves this equality. Dropping to 1D with $\Omega = (a,b)$ and using the equation $u_t + (\mathbf v ...


15

This is a well-framed question and a very useful thing to understand. Korrok is correct to refer you to von Neumann analysis and LeVeque's book. I can add a bit more to that. I'd like to write a detailed answer, but at the moment I only have time for a short one: With $\alpha=\beta=1/2$, you get a method that is absolutely stable for arbitrarily large ...


15

It's quite common in computational fluid dynamics to use implicit schemes similar to what you propose. The ones I know of are based on compact finite difference formulas (not simply on replacing $n$ with $n+1$ in existing schemes). For instance, one of the most widely used schemes was developed by Lele in 1992 in this paper with >2500 citations. Such ...


12

Sloede's response is very thorough and correct. I just wanted to add a few points to make it easier to grasp. Basically, any wave equation has an inherent wave speed and direction. For a one-dimensional wave equation: $$ u_t + a u_x = 0 $$ the wave speed is the constant $a$ which determines not only the speed at which the information is propagating in the ...


12

There is no reason that you cannot do what you wrote. One of the reasons that this is uncommon is that there for hyperbolic (advection) type problems the domain of dependence is finite. Thus an explicit methods makes sense from a computational efficiency standpoint. The implicit scheme you have written will require solving a linear system, albeit in the ...


11

The first order upwind method is monotone; it does not introduce spurious oscillations. But it is only first order accurate, resulting in so much numerical diffusion as to be unusable for many purposes. Godunov's Theorem states that linear spatial discretizations of higher than first order cannot be monotone. To rigorously control oscillations, we use Total ...


10

Generally speaking, you'll want to use an implicit method for parabolic equations (the diffusion part) -- explicit schemes for parabolic PDE need to have a very short timestep to be stable. Conversely, for the hyperbolic part (advection) you'll want an explicit method as it's cheaper and doesn't disrupt the symmetry of the linear system you have to solve by ...


8

I see several issues: The DFT computed with fft puts the zero mode at the beginning of the array, and if you want to compute the derivative, it is necessary to apply fftshift/ifftshift to the array N to make sure the derivative is correct. It is easy to see for yourself what the correct expression is by working it out with pen and paper, and see also the ...


6

Let me give a part of your answer, I would need some more indications from your side to answer you fully. So please read, and write some comments so that I can complete my answer. About notations in numerical methods There are a few mistakes in the way you write your equations. These are only details, but for someone who is used to it, it can a bit ...


6

Numerical diffusion arises from a first-order finite difference approximation to the spatial derivative $\partial u/\partial x$. To see how this is the case, examine the Taylor series expansion for $u_{i+1}$: $$ u(x_{i+1}) = u(x_{i}) + \left.\frac{\partial u}{\partial x}\right|_{x_i} (\Delta x) + \frac{1}{2} \left. \frac{\partial^2 u}{\partial x^2}\right|_{...


6

One way or the other, you need to stabilize every discretization for this equation. Traditionally, this was done using methods such as artificial viscosity or its slightly smarter sibling SUPG. But there are many other alternatives to make things work if you'd like to stick with the FEM framework -- e.g., discontinuous Galerkin methods. My summary of this ...


6

The stationary equation you show transports information from the right to the left via the advection term; it also diffuses slightly. If you switch off the diffusion term altogether, then you only have transport from the right to the left, and you need to also drop the boundary condition at the left: because information is from the right to the left, nothing ...


6

Okay. Let's begin with the first situation. Your equation is: $$ \frac{\partial f}{\partial t}+v\frac{\partial f}{\partial x}=0\tag{1}$$ $\textbf{Previous comments}$ There are plenty of webs that can explain you what happens with the error when you does not choose properly the values of your mesh to approximate the derivatives in an equation (Von Neumann ...


5

Look at the cell Péclet number $$\mathrm{Pe}_h = h v / K$$ where $h$ is mesh size, $v$ is the magnitude of velocity, and $K$ is diffusivity. It is analogous to cell Reynolds number for the momentum equation and is small when "thermal diffusivity is large compared to advection". It is common common in macro-scale fluid dynamics that thermal diffusivity $K$...


5

General answer Your problem is that you do not set (or even specify) the boundary conditions at all - your numerical problem is ill-defined. Generally, there are two possible ways to specify the boundary conditions: Set the boundary conditions by specifying $u_{0}$ and $u_{101}$ externally, e.g. through the exact solution. Change the numerical stencil so ...


5

Linear finite difference discretization of a 1D problem with periodic boundaries leads to a discretization of the form $$U^{n+1} = LU^n$$ where $L$ is a circulant matrix. The eigenvectors of any circulant matrix are discrete Fourier modes $$v_j = \exp(ijh\xi)$$ (here $h$ is the grid spacing and $\xi$ is the wavenumber, which ranges from zero up to the ...


5

Level set methods are really only one particular case of advection PDEs which you can solve with any of the modern PDE toolboxes such as deal.II (disclaimer: that's my own library), fenics, libmesh, ... What makes it a level set method is that you the evaluate the solution function to find that surface where, for example, the solution equals zero. I'd try to ...


5

Bluntly speaking, SUPG and alike and RANS are different approaches to different problems that, however, have the same name - instability - and the same phenomenology - the failure of numerical routines. RANS is used to cope with turbulence as an instability of the equation. If a flow is or becomes turbulent the describing equations are instable, e.g. ...


5

Eigenvalues with zero eigenvalue correspond to purely oscillatory modes. You can see it by diagonalising the system. Your matrix $A$ can be written as \begin{equation} A = P \Sigma P^{-1} \end{equation} where $\Sigma$ is a diagonal matrix with entries $\lambda_n$ corresponding to the eigenvalues of $Q$. You can now transform your ODE to \begin{equation} dQ/...


5

Your image of the numerical domain of dependence is correct. But try to also draw the analytical domain of dependence, maybe this could help you to better understand what is going on. Note that the analytic solution of $u_t+au_x=0$ is $u(t,x)=u_0(x-at)$. So the slope of the actual dependence is $a$. The CFL condition just says that the numerical dependence ...


5

Your equation can be written in the following fashion (any spatial derivative approximation is valid), once space is discretised: $$\frac{1}{c}\frac{du_i}{dt}=-\left(\frac{\partial u}{\partial x}\right)_i(t) + v_i(t) \tag{*}$$ Keep in mind that $v_i(t) = v(x_i,t)$. Now the system of equations depends only on time $t$ you can apply Crack Nicholson method to ...


4

The answer is yes. Drift diffusion = advection-diffusion. You will find this rather frequently: different disciplines, trying to describe the phenomena in their field, assign names to the equations they derive that have meaning for this discipline. Other disciplines come up with the same equations, in different contexts, and name them differently. It's still ...


4

Your description "the function $h(y,x)$ gives the proportion of the mass $u(y,t)$ at position $y$ that moves to position $x$ in space in a small unit of time" seems to indicate a slight misunderstanding of derivatives. Since the term on the left of your equation ($\partial_t u$) is a time derivative, the "small unit of time" must be infinitesimally small. ...


4

In 1-D, the first discretization you've presented is correct. The matrix equation does not look right, though. For starters, it's not clear what your boundary conditions would be or how you would incorporate them. In $N$ dimensions, the advection equation looks like \begin{align} \frac{\partial{u}}{\partial{t}} + \sum_{i=1}^{N}\frac{\partial}{\partial{x^{i}...


4

This is actually a standard modeling problem if you consider the medium that flows through the network to be incompressible (e.g., liquids, or gases at low velocity). Then, you formulate everything in terms of fluxes (liters or kg per second) rather than in discrete parcels. The key realization is that the flux that goes into one end of the pipe equals the ...


4

That's not a simple question in my opinion. It is like if you were doing an experiment in a box and you just want to simulate the center of it. But obviously, the solution in the center of the box depends on what happens in the rest of the box. That is probably why it is a difficult problem to state. I have no definite answer to this question, but I still ...


4

You solve the 1D-advection equation with c a constant velocity : $$ \frac{\partial u}{\partial t} + c\frac{\partial u}{\partial x}=0~~~~~~~~(1) $$ When you discretize this equation (with an explicit scheme in time and an upwind scheme in space for instance), you get : $$ \frac{u_i^{n+1} - u_i^n}{\Delta t}+\frac{u_i^n-u_{i-1}^{n}}{\Delta x} = 0 ~~~~~~~~(2) $$ ...


Only top voted, non community-wiki answers of a minimum length are eligible