Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [finite-difference]

Referring to the discretization of derivatives by Finite differences, and its applications to numerical solutions of partial differential equations.

15
votes
4answers
1k views

How to reorder variables to produce a banded matrix of minimum bandwidth?

I'm trying to solve a 2D Poisson equation by finite differences. In the process, I obtain a sparse matrix with only $5$ variables in each equation. For example, if the variables were $U$, then the ...
32
votes
2answers
4k views

Strange oscillation when solving the advection equation by finite-difference with fully closed Neumann boundary conditions (reflection at boundaries)

I am trying to solving the advection equation but have a strange oscillation appearing in the solution when the wave reflects from the boundaries. If anybody has seen this artefact before I would be ...
15
votes
2answers
16k views

Writing the Poisson equation finite-difference matrix with Neumann boundary conditions

I am interested in solving the Poisson equation using the finite-difference approach. I would like to better understand how to write the matrix equation with Neumann boundary conditions. Would someone ...
6
votes
2answers
4k views

Poisson equation finite-difference with pure Neumann boundary conditions

I'm trying to solve a 1D Poisson equation with pure Neumann boundary conditions. I've found many discussions of this problem, e.g. 1) Poisson equation with Neumann boundary conditions 2) Writing the ...
5
votes
2answers
457 views

What heuristics can be used to minimize the asymptotic matrix bandwidth of a 5-point Laplacian discretization?

I can see that there are multiple heuristics to achieve a matrix with minimum bandwidth. As heuristics, they can't guarantee an optimal solution in polynomial time (after all, the problem is NP-...
22
votes
2answers
4k views

A good finite difference for the continuity equation

What would be a good finite difference discretization for the following equation: $\frac{\partial \rho}{\partial t} + \nabla \cdot \left(\rho u\right)=0$? We can take the 1D case: $\frac{\partial \...
4
votes
2answers
2k views

The meaning of conservative discretization in Galerkin FEM and Discontinuous Galerkin

I do understand the meanning of "conservative discretization" within the FVM/FDM framework, indeed it is well explained in this post. Now, according to the table in this slide (pp.8), it concludes: ...
2
votes
1answer
301 views

Finite difference discretization on a circle

I am trying to discretize the differential operator $\frac{d^2}{dx^2}$ acting on $S^1 = [0,1]$ using finitely many points around a circle at $0, \frac{1}{N}, \frac{2}{N}, \dots, \frac{N-1}{N}$. Here ...
21
votes
4answers
13k views

How can I numerically differentiate an unevenly sampled function?

Standard finite difference formulas are usable to numerically compute a derivative under the expectation that you have function values $f(x_k)$ at evenly spaced points, so that $h \equiv x_{k+1} - x_k$...
11
votes
6answers
5k views

Finite differences on domains with irregular boundaries

Can anybody help me to find the books on numerical solutions(finite difference and Crank–Nicolson methods) of Poisson and diffusion equations including examples on irregular geometry, such as a domain ...
6
votes
2answers
4k views

How can I prove numerical diffusion in upwind scheme for transport equation

I was just implementing the upwind scheme for a linear transport equation $u_t + cu_x = 0$ where $c=0.5$ and I saw that the solution was indeed advected but over time it starts to diffuse. Can anyone ...
4
votes
1answer
2k views

Comparison of Lattice Boltzmann Method vs Traditional Navier-Stokes based Methods

I have a choice of two options, analysing and implementing Lattice Boltzmann methods or traditional Navier Stokes based methods. I'm a CFD newbie and I have a rough idea (though not rigorous enough to ...
5
votes
1answer
977 views

method of frozen coefficients and its relation to von Neumann stability analysis

I am considering two equations $$u_t=a(x)u_{xx}$$ and $$v_t=b(x)v_x$$ as classical representatives of the parabolic and hyperbolic family of equations. If $a(x)=a$ and $b(x)=b$ were constants, to show ...
5
votes
1answer
2k views

Finite Difference Method Neumann Boundary Condition with Variable Coefficients

Disclaimer In the process of typing up this question, I determine its solution. Since I went through the trouble of typing up the question in its entirety, I will post its answer as well. It may ...
5
votes
3answers
2k views

Discrete Poisson Equation with Pure Neumann Boundary Conditions

I'm trying to implement the Helmholtz-Hodge Decomposition in 2D, which states that a vector field is composed by a rotational free component, a divergence free component and a harmonic component. ...
3
votes
1answer
4k views

Why a finite difference scheme would give second order of accuracy in norm L2 but 1.5 with L1 (while 1 with Linf)?

My finite difference scheme for the 2D Euler equations is second order accurate in theory, since all the terms are second order accurate, with the advective terms being third order. So I expect a rate ...
20
votes
3answers
11k views

Recommendation for Finite Difference Method in Scientific Python

For a project I am working on (in hyperbolic PDEs) I would like to get some rough handle on the behavior by looking at some numerics. I am, however, not a very good programmer. Can you recommend ...
14
votes
4answers
6k views

Boundary conditions for the advection equation discretized by a finite difference method

I am trying to find some resources to help explain how to choose boundary conditions when using finite difference methods to solve PDEs. The books and notes which I currently have access to all say ...
9
votes
5answers
619 views

How can I derive a bound on the spurious oscillations in the numerical solution of the 1D advection equation?

Suppose I had the following periodic 1D advection problem: $\frac{\partial u}{\partial t} + c\frac{\partial u}{\partial x} = 0$ in $\Omega=[0,1]$ $u(0,t)=u(1,t)$ $u(x,0)=g(x)$ where $g(x)$ has a ...
7
votes
1answer
365 views

CFL condition in polar coordinates

In this question, I suggested that the Couran-Friedrichs-Lewy (CFL) condition for the wave equation in polar coordinates reads $$C = 2c\frac{\Delta t}{\Delta r \Delta \phi} \leq C_\max \enspace ,$$ ...
11
votes
4answers
1k views

Numerical derivative and finite difference coefficients: any update of the Fornberg method?

When one want to compute numerical derivatives, the method presented by Bengt Fornberg here (and reported here) is very convenient (both precise and simple to implement). As the original paper date ...
6
votes
1answer
2k views

Trouble implementing Neumann boundary conditions because the ghost points cannot be eliminated

Neumann boundary conditions are implemented by introducing ghost points outside the domain and then using the boundary conditions to eliminate the ghost points. For example, see this question. I ...
6
votes
2answers
196 views

Why naively chopped finite difference matrix works for different ODE boundary conditions

We know finite difference method (FDM) can replace $y''(x)$ as $\frac{1}{h^2}[y(x+h)+y(x-h)-2y(x)]$ or so. One naive way to write down the matrix of the differential operator is like the following, ...
3
votes
1answer
2k views

Iteratively solving 3D Poisson equation in MATLAB

I have written a function that sets up a sparse matrix A and RHS b for the 3D Poisson equation in a relatively efficient way. The set-up is nothing fancy: I have extended the 2D 5-point stencil to an ...
9
votes
1answer
3k views

Are there any numerical advantages in solving symmetric matrix compared to matrices without symmetry?

I'm applying finite-difference method to a system of 3 coupled equations. Two of the equations are not coupled, however the third equation couples to both the other two. I noticed that by changing the ...
8
votes
1answer
8k views

Matlab solution for implicit finite difference heat equation with kinetic reactions

I am trying to model heat conduction within a wood cylinder using implicit finite difference methods. The general heat equation that I'm using for cylindrical and spherical shapes is: Where p is the ...
4
votes
1answer
3k views

Poisson equation with Neumann boundary conditions

I'm trying to solve the Poisson equation with pure Neumann boundary conditions, $$ \nabla^2\phi = \rho \quad in \quad \Omega\\ \mathbf{\nabla}\phi \cdot \mathbf{n} = 0 \quad on \quad \partial \Omega $$...
3
votes
1answer
2k views

Meaning of CFL condition on parabolic problems

I've been studying this FEM theory and for the parabolic problems, there's the analysis of stability of the $\theta$-method. I followed the analysis and they get this CFL (Courant-Friedrich-Lewy) ...
1
vote
1answer
2k views

how to measure the error of a finite difference method

Suppose I am solving a pde with a solution known with a finite-difference method. I can represent it as $A_hu_h=f$ for some approximating matrix $A_h$. And I define the discrete norm in which I will ...
14
votes
3answers
6k views

How to impose boundary conditions in finite difference methods

I have a problem when I want to use the high order center difference approximation: $$\left(\frac{-u_{i+2,j}+16u_{i+1,j}-30u_{i,j}+16u_{i-1,j}-u_{i-2,j}}{12}\right)$$ for the Poisson equation $$(...
13
votes
3answers
756 views

What are the basic principles behind generating a moving mesh?

I am interested in implementing an moving mesh for an advection-diffusion problem. Adaptive Moving Mesh Methods gives a good example of how to do this for Burger's equation in 1D using finite-...
8
votes
2answers
1k views

What does the Von Neumann's stability analysis tell us about non-linear finite difference equations?

I am reading a paper [1] where they solve the following non-linear equation \begin{equation} u_t + u_x + uu_x - u_{xxt} = 0 \end{equation} using finite difference methods. They also analyse the ...
7
votes
1answer
529 views

Conservative finite-difference expression for the advection equation

Following on from the earlier question I am trying to derive a finite-difference scheme for the advection equation which is conservative. It was suggested that for advection equation with variable ...
7
votes
1answer
173 views

Non-hermitian discretizations in quantum mechanics

Consider the Schroedinger equation $$\left(-\frac12\frac{\partial^2}{\partial x^2} + V(x) \right) \psi(x) = E \psi(x)$$ The usual way to solve it is to introduce a discretization of $\psi(x)$. This ...
6
votes
1answer
254 views

Error implementing Robin boundary conditions in toy ODE problem

I am attempting to solve the following ODE problem: $$-u''+ u = x$$ $$u(0) = 0$$ $$u'(1) = -u(1)$$ The exact solution is: $u(x) = e^{-x-1} - e^{x-1} + x$ I have a Dirichlet at $x = 0$ and a Robin ...
4
votes
1answer
2k views

Von Newman stability analysis for 2D acoustic wave equation explicit

Von Newman stability analysis for acoustic wave equation explicit centered differences: 2nd order time and space (N 2)'th order: \begin{eqnarray} U_{jk}^{n+1} = \left( \frac{\Delta t V_{jk} }{\...
4
votes
2answers
4k views

Error in result of finite-difference approximation when refining

I have calculated the first derivative of following equation using Euler method (first order), Three point Finite Difference method (second order) and Four point Finite Difference method (third order)....
3
votes
1answer
567 views

Generating a non-uniform grid

I am interested in generating a 1D non-uniform grid on the interval [0, L] with N points, where a region of width $\sigma$ and ...
2
votes
2answers
349 views

Precision loss in Matrix-Vector product when applying Finite-Difference scheme

I am applying a 6th order Finite-Difference differentiation scheme as seen in http://www.scholarpedia.org/article/Method_of_lines/example_implementation/dss006 There seems to be severe numerical/...
2
votes
1answer
2k views

Correct way of computing norm $L_2$ for a finite difference scheme

I am computing the rate of convergence of my finite difference scheme in norm $L_2$. Which is the correct way to compute it? This: \begin{align} L_2 &= \frac{1}{N}\sqrt{\sum_{j=1}^N(u^{...
2
votes
2answers
377 views

Analytical Solution to the acoustic / scalar (Inhomogeneous) wave equation with source term

The acoustic wave equation in 2D is $$\frac{\partial^2}{\partial t^2}p(x,z,t) = c(x,z)^2\left[\frac{\partial^2}{\partial x^2}p(x,z,t) + \frac{\partial^2}{\partial z^2}p(x,z,t)\right] + s(x,z,t) \...
2
votes
1answer
1k views

Implicit heat diffusion with kinetic reactions

I am using the implicit finite difference method to discretize the 1-D transient heat diffusion equation for solid spherical and cylindrical shapes: $$ \frac{1}{\alpha}\frac{\partial T}{\partial t} = ...
10
votes
2answers
846 views

Is the maximum/minimum principle of the heat equation maintained by the Crank-Nicolson discretization?

I'm using the Crank-Nicolson finite difference scheme to solve a 1D heat equation. I'm wondering if the maximum/minimum principle of the heat equation (i.e. that the maximum/minimum occurs at the ...
8
votes
1answer
1k views

Shortley-Weller finite difference method

can you give me a link for a good and simple explanation of the Shortley-Weller finite-difference scheme? I tried to google it but all I get is (inaccessible) academic publications. I also tried ...
6
votes
1answer
200 views

Does mean removal increase accuracy of numerical differentiation?

I wish to compute the derivative of a vector through numerical differentiation. Let's say, we use a standard 2nd order central difference scheme, to arrive at a differentiation matrix, and apply it on ...
5
votes
1answer
2k views

Stability of numerical method for 1D Burger's equation

I am trying to solve 1D viscous Burger's equation numerically and I cannot apply von Neumann analysis because the equation is non-linear. How do I predict the stability criteria for my system? I also ...
5
votes
1answer
222 views

Convergence of Jacobi's method for a semilinear elliptic PDE

I have an iterative finite difference scheme for the Poisson equation $$ \nabla^2 u=-\rho $$ It's the Jacobi method, which has the form (for 1D systems) $$ u^{n+1}_{i} = \frac{1}{2}(u^n_{i+1} + u^n_{...
4
votes
2answers
3k views

Testing 1D Poisson Solver

I'm trying to test a simple 1D Poisson solver to show that a finite difference method converges with $\mathcal{O}(h^2)$ and that using a deferred correction for the input function yields a convergence ...
4
votes
1answer
898 views

FEM: which is the correct way to impose Dirichlet B.C

I know the Neumann B.C. is implicit in FEM language. However, I have seen at least two ways to impose Dirichlet B.C. e.g. for the following problem 1D, $$\nabla^2 u + \nabla u= 0, u_{left}= 1, u_{...
4
votes
2answers
1k views

choice of the norm for the error of the numerical method

When I read books on finite differences they often end up using discrete $L^2$ norm for estimating the error as it naturally arises from weak formulation. I was wondering if people do that in Sobolev ...