Stack Exchange Network

Stack Exchange network consists of 174 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.

31
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 ...
24
votes
5answers
1k views

Why do equi-spaced points behave badly?

Experiment description: In Lagrange interpolation, the exact equation is sampled at $N$ points (polynomial order $N - 1$) and it is interpolated at 101 points. Here $N$ is varied from 2 to 64. Each ...
22
votes
2answers
3k 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 \...
20
votes
3answers
10k 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 ...
20
votes
5answers
12k 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$...
15
votes
4answers
4k views

uniform vs. non-uniform grid

It is probably a student level question but I can't exactly make it cleat to myself. Why is it more accurate to use non-uniform grids in the numerical methods? I am thinking in the context of some ...
15
votes
2answers
5k views

Implicit finite difference schemes for advection equation

There are numerous FD schemes for the advection equation $\frac{\partial T}{\partial t}+u\frac{\partial T}{\partial x}=0$ discuss in the web. For instance here: http://farside.ph.utexas.edu/teaching/...
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 ...
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 ...
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 $$(...
14
votes
2answers
15k 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 ...
14
votes
4answers
1k views

Illustrative examples of mimetic finite difference methods

As much as I try to find a concise explanation on the internet, I can't seem to grasp the concept of a mimetic finite difference, or how it even relates to standard finite differences. It would be ...
13
votes
2answers
1k views

Alternatives to von neumann stability analysis for finite difference methods

I'm working on solving the coupled one-dimensional poroelasticity equations (biot's model), given as: $$-(\lambda+ 2\mu) \frac{\partial^2 u}{\partial x^2} + \frac{\partial p}{\partial x} = 0$$ $$\...
13
votes
3answers
730 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-...
11
votes
3answers
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 ...
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 ...
11
votes
2answers
794 views

How do you improve the accuracy of a finite difference method for finding the eigensystem of a singular linear ODE

I am attempting to solve an equation of the type: $ \left( -\tfrac{\partial^2}{\partial x^2} - f\left(x\right) \right) \psi(x) = \lambda \psi(x) $ Where $f(x)$ has a simple pole at $0$, for the ...
11
votes
2answers
1k views

Solid mechanics with finite differences: How to handle “corner nodes”?

I have a question concerning coding boundary conditions for solid mechanics (linear elasticity). In the special case I have to use finite differences (3D). I am very new to this topic, so perhaps some ...
10
votes
3answers
2k views

How to deal with curved boundary condition when using finite difference method?

I'm trying to learn about numerically solving PDE by myself. I've been beginning with finite difference method(FDM) for some time because I heard that FDM is the fundament of numerous numerical ...
10
votes
2answers
700 views

Finite difference scheme for “wave equation”, method of characteristics

Consider the following problem $$ W_{uv} = F $$ where the forcing term can depend on $u,v$ (see Edit 1 below for the formulation), and $W$ and its first derivatives. This is a 1+1 dimensional wave ...
10
votes
2answers
814 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 ...
10
votes
1answer
1k views

Optimal transport warping implementation in Matlab

I am implementing the paper "Optimal Mass Transport for Registration and Warping", my goal being to put it online as I just cannot find any eulerian mass transportation code online and this would be ...
9
votes
4answers
1k views

When we use Bernstein polynomials in application

When it is preferable to use Bernstein polynomials to approximate a continuous function instead of using the only following preliminary Numerical Analysis methods: "Lagrange Polynomials", "Simple ...
9
votes
4answers
565 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 ...
9
votes
1answer
5k views

How to approximate the condition number of a large matrix?

How do I approximate the condition number of a large matrix $G$, if $G$ is a combination of Fourier transforms $F$ (non-uniform or uniform), finite differences $R$, and diagonal matrices $S$? The ...
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 ...
9
votes
2answers
971 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 ...
8
votes
3answers
198 views

Stability criterion for waves in anisotropic solids

The equations of motion for an elastic solid are given by $$\begin{align} &\nabla \cdot \boldsymbol{\sigma} + \mathbf{f} = \rho \ddot{\mathbf{u}}\\ &\boldsymbol{\sigma} = \mathbb{C}\...
8
votes
1answer
484 views

Finite difference recursion and higher order

This may be a trivial question, but I've always wondered... For the classical, central finite difference schemes, if I'm interested in determining the second derivative, does applying the first ...
8
votes
1answer
314 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 ,$$ ...
8
votes
1answer
1k views

Automatically generating finite difference matrices for systems of PDEs

Suppose that you have a system of PDEs to solve. At least for simplicity, let's assume it's time independent, quasi-linear (linear in its derivatives) solved on a rectangular grid in (x,y) space, and ...
8
votes
1answer
1k views

Finite difference coordinate transformation for spherical polar coordinates

I have part of a problem that is described by the momentum conservation equation: $\frac{\partial \rho}{\partial t} + \frac{1}{\sin\theta} \frac{\partial}{\partial \theta}(\rho u \sin \theta) =0$ ...
8
votes
1answer
484 views

Finite difference scheme for compressible nonisothermal flow in porous media

My challenge is to solve the following system of equations, which describe gas combustion in porous media: 1) Continuity $\varepsilon \frac{\partial \rho_g}{\partial t} +\frac{\partial}{\partial x} \...
8
votes
3answers
982 views

Laplacian eigenmodes on a semi-circular region with finite-difference method

The computation of eigenmodes of a semi-circular membrane reduces to the following eigenvalue problem $$\nabla^2u=k^2u\;,$$ where the region of interest is a semi-circle defined by $r\in[0,1]$ and $\...
7
votes
3answers
6k views

Use of machine learning in computational fluid dynamics

Background: I have only built one working numeric solution to 2d Navier-Stokes, for a course. It was a solution for lid-driven cavity flow. The course, however, discussed a number of schemas for ...
7
votes
3answers
348 views

ODE $x''(t)+\eta x'(t)+x(t)=0$ with the $\eta$ extremely small

I want to numerically solve the damped oscillator equation $$\frac{d^2x}{dt^2}+\eta\frac{dx}{dt}+x=0 .$$ Usually it's very easy to solve this kind of ODE analytically and numerically. But now the ...
7
votes
3answers
748 views

analyze stability on a nonuniform grid

Assume you have a stability constraint between the space distance in time and space, for example, with an explicit Euler method for $u_t=u_{xx}$ we know $\tau\leq h^2/2$. That is, one can do stability ...
7
votes
2answers
218 views

How can I obtain a one dimensional finite difference formula for $U_{xx}$ with unevenly spaced nodes?

I know that if I had evenly spaced points, I can use $U_{xx}\approx \frac{U_{i-1}-2U_{i}+U_{i+1}}{dx^2}$. But if my gridpoints are unevenly spaced, I assume that I can obtain the finite difference ...
7
votes
4answers
871 views

Finite Difference Method Stability

The diffusion equation is: $ \frac{\partial T}{\partial t} = \alpha \left( \frac{\partial^2 T}{\partial x^2} \right) $ An explicit finite difference approach can be used to solve this, forward in ...
7
votes
1answer
482 views

Nonlinear wave equation - Finite element or finite difference

I would like to know the which is more advantageous when it comes to solving nonlinear hyperbolic equations, Finite Element or Finite difference methods? Which method will be better in capturing ...
7
votes
1answer
141 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 ...
7
votes
1answer
607 views

Stability analysis of Heun's method

I am using Heun's method with a third order upwind spatial scheme, which is suggested by Shao (2008) to be used for solving the horizontal advection part of the advection-diffusion equation. This is ...
7
votes
1answer
219 views

Gaussian Numerical Differentiation

Gaussian quadrature improves on Newton-Cotes formulas by allowing the abscissas to vary along with the weights in order to integrate higher order polynomials. Can this idea be extended to numerical ...
7
votes
2answers
954 views

Convergence/stagnation of BiCGStab(l)

I am solving 3D time-harmonic Maxwell FDFD problems (which result in huge sparse linear systems) using BiCGStab(l). I have tried out a bunch of different methods and for my specific use case, it seems ...
7
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 ...
7
votes
3answers
699 views

Largest eigenvalue of FD discrete Laplacian

Is there good approximation for largest (in magnitude) eigenvalue for discrete Laplacian ($\nabla^2$) obtained from nonuniform structured grid (like that)? Of course, one can always use general ...
7
votes
1answer
198 views

finite difference : why should we solve linear equation at each step

I'm trying to simulate the growth of a brain tumor using a 3d reaction-diffusion model $ \partial_{t}u = \nabla.{(D\nabla{u}) } + ku.(1-u)$ , knowing the initial distribution of tumor $u^0$, the non-...
7
votes
1answer
196 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 ...
7
votes
1answer
5k views

Schroedinger/Diffusion equation with Crank-Nicolson in Python/SciPy

I tried to make the question as detailed as possible. I have an extremely simple solver written for the Schroedinger equation but with imaginary time, which transforms it basically into the diffusion ...
7
votes
2answers
5k views

2nd order centered finite-difference approximation of $u_{xy}$

The problem is to find a 2nd order finite difference approximation of the partial derivative uxy, where u is a function of x and y. Page 5 of this pdf I found does a centered difference approximation ...