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.

0
votes
1answer
38 views

Numerical solution of non-linear first order partial differential equation (HJB)

I am trying to solve a simple optimal control problem using the Hamilton-Jacobi-Bellman equation, numerically in Python. This is proving to be rather difficult as I end up having to solve the ...
0
votes
1answer
41 views

Changing the domain of a 3D Finite Difference code from cube to sphere

I have an explicit FD (Finite Difference) code for diffusion/heat on a PDE in a cuboid domain, and it works fine. I would like to update the discretized equations and change the code so as to solve ...
1
vote
1answer
33 views

Mapping derivative information in uniform to non-uniform grid

I'm having two sets of grids. One is uniform and another one is not uniform. I will calculate the derivative in uniform grid points and I like to transfer(map) the derivative to the non-uniform grid ...
0
votes
1answer
60 views

Solving advection equation - periodic conditions - using roll python function [on hold]

The original post was on stackoverflow : I transfert it here. I have to solve numerically the advection equation with periodic boundaries conditions : u(t,0) = u(t,L) with L the length of system to ...
2
votes
0answers
52 views

2d wave equation with finite differences blowing up

I am (naively) trying to solve the 2d wave equation with finite differences. But the system blows up instantly. For simplicity I set the constant $c=1$, then I am left with $$\Delta u =u_{tt}.$$ I ...
0
votes
1answer
70 views

Impose Neumann Boundary Condition in advection-diffusion equation 1D

when solving the advection equation in 1D that is: $$ \frac{\partial u}{\partial t} + c\frac{\partial u}{\partial x} = 0 $$ with $ u'(t,0) = 0$ and $u(t,L) = 0$ , $u(0,x) = u_{0} $ one numerical ...
0
votes
1answer
40 views

Applying neumann boundary conditions to diffusion equation solution in python [duplicate]

For the diffusion equation $$ \frac{\partial u(x,t)}{\partial t} = D \frac{\partial ^2 u(x,t)}{\partial x^2} + Cu(x,t) $$ with the boundary conditions $u(-\frac{L}{2},t)=u(\frac{L}{2},t)=0$ I've ...
0
votes
0answers
38 views

System of BVPs with unbalanced BCs

I have a system of ODEs forming a BVP. I was thinking of using Finite Difference to solve it but for some functions I do not have the BCs on both sides (though in total they are enough to make the ...
3
votes
0answers
28 views

Guide for finite-difference schemes for Hamilton-Jacobi-Bellman Equations

I need to solve a simple, low-dimensional Hamilton-Jacobi-Bellman equation. Is there a simple guide for doing this numerically using finite-difference schemes? I found a few research articles ...
1
vote
1answer
75 views

Grid dependence of a numerical model

Statement of the problem Suppose, we consider the following model $$ \begin{array}{l} (1)~\mathbf{u}_t + \mathbf{F(u)}_x = \mathbf{S}(\mathbf{u},\mathbf{w}), \\ (2)~\mathbf{w}_x = \mathbf{P}(\mathbf{...
3
votes
2answers
120 views

Asymptotic error of forward Euler

I'm trying to understand the asymptotic error behaviour of forward Euler (finite difference method), as timesteps are decreased (refined), so I feel trust in the method of manufactured solutions (MMS)....
-1
votes
0answers
34 views

Lax-Friedrich's Method in Conservative Form. (Burger's equation)

I don't understand how to calculate conservative form in general. So the idea is that you imitate the integral for Finite-Volume methods. Then your flux cannot be evaluated in your node but in your ...
0
votes
1answer
35 views

Elliptic PDE: Proving that a 2nd order accurate discretization of the 2nd derivative of the unknown is 2nd order accurate for the unknown itself

For an ODE: $\frac{dy}{dt}=f(y(t),t)$ The Euler Explicit scheme reads: $y_{n+1}=y_{n}+\Delta tf_n$ and it can be easily shown with a Taylor expension that: $y_{n+1}=y_{n}+\Delta t \frac{dy}{dt}|...
2
votes
0answers
78 views

Factorize laplacian in terms of first derivative matrix

I am trying to factorize the following Laplacian matrix in terms of $ D^TD$, D is the first derivative matrix. The tridiagonal form of the secon derivative matrix using Neumann boundary condition is ...
-1
votes
0answers
43 views

Solving a system of ODEs and one PDE with bvp4c

knowing that bvp4c is based on Finite Differences, would it be possible to solve a system of ODEs with also a time and space dependent parameter? Thank you.
4
votes
1answer
92 views

Matrix Representation of a Discretization for a Partial Differential Equation

I want to discretize the following problem \begin{cases} \mu \nabla^2u+(\lambda+\mu)\nabla \nabla\cdot u = \rho \frac{\partial^2u }{\partial t^2 } + \beta \frac{\partial u}{\partial t}\\ u(...
-1
votes
0answers
18 views

discretizing the convection-diffusion equation using finite difference method

I am new to to the finite difference method and i want to understand how convection-diffusion equation is descritized in 2-D using central diffrences $\nabla .(\rho \vec{v} \Phi)=\nabla.(\Gamma \vec{\...
-1
votes
0answers
50 views

Question regarding implementation of boundary condition

I have the following code, which solves for the change in concentration of a species along the length of a channel of length L . The equation is , $ \frac{\partial C}{\partial t} = -v\frac{\partial C}...
2
votes
0answers
27 views

Numerical stability while modeling wave equation in staggered grid

I have modeled a simple wave equation given by: \begin{align} & \begin{cases} u_t = v_x \\ v_t = u_x \end{cases} \end{align} Boundary conditions given on interval $M=[-1,1]$ by: \begin{align} u(...
1
vote
0answers
77 views

Finite differences for the one-phase Stefan problem

I am trying to code the one-phase, one-dimensional Stefan problem using finite differences in Matlab, similarly to what has already been done in Mathematica (see https://mathematica.stackexchange.com/...
1
vote
0answers
68 views

why I cannot find explicit finite difference for elliptic equation

Let us think on the Poisson equation $\nabla^2 u(\bf{x})=\rho(x)$ with Neumann boundary conditions, with $\bf{x}=\it (x,y)$ in 2D. Here is a stencil with central differences in both $x$ and $y$ (...
2
votes
0answers
63 views

Efects from the boundary in advection equation [duplicate]

I am implementing the advection equation $u_x+(1/c)u_t=0$ following a Crank-Nicholson finite difference scheme. The equation for this is \begin{eqnarray*} -\frac{\gamma}{4} w_{n-3 j+1} + w_{n-2 j+1} ...
2
votes
1answer
53 views

PML boundary conditions

I set up two one-way wave equations for constant velocity $c$ in one-dimension. When I implement them I get a highly unstable (divergent) solution. I wonder if someone could give me a suggestion about ...
5
votes
3answers
109 views

Finite difference for 1D wave equation: why the spike initial data results in a noisy output?

I am using a second-order finite difference in space and time approximation for the 1D wave equation. No source but initial data: $I(x)=\mathrm{e}^{-400 (x-0.5)^2}$. Velocity $c=1$, $nx=501$, $nt=...
2
votes
0answers
24 views

Neumann boundary conditions in the Maccormack scheme

I am trying to solve the viscous Burger equation $$ \frac{\partial u}{\partial t} + u\frac{\partial u}{\partial x} = \mu \frac{\partial^2 u}{\partial x^2} $$ with Neumann boundary conditions. I am ...
-1
votes
1answer
131 views

How write a integration loop in fortran, leapfrog scheme to solvind PDE (advection)?

I want to resolve numerically this equation using of difference finite method with Leapfrog Scheme $$\frac{\partial{u}}{\partial t}+ v \frac{\partial{u}}{\partial x}= 0 $$ I'm trying to write a code ...
1
vote
1answer
119 views

Can a second-order ODE be “inconsistent” with its boundary conditions?

I am trying to solve a set of coupled, nonlinear ODEs. The only dependent variable is a 1-dimensional spatial coordinate, let's call it $x$. For now, I've managed to approximate away some of the ...
1
vote
1answer
76 views

Stability Criteria for Numerical Solution of Windkessel Ordinary Differential Equation

I'm trying to solve this equation (Windkessel equation) numerically as: $$C \frac{d P}{d t} + \frac{P}{R} = Q(t)$$ Where $C$ is compliance, $R$ is resistance, $P$ is pressure, and $Q(t)$ is a known ...
5
votes
1answer
126 views

Finite Differencing schemes for Convection-Diffusion equation

I'm using the Convection(/advection)-Diffusion(-Reaction) equation to calculate the temperature over time in different hydraulic parts like a pipe or a heat exchanger. The flow/convection is always 1D,...
2
votes
1answer
150 views

Solve 3-D Heat equation with Neumann boundaries

I want to solve the Poisson PDE for heat flow in a 3-D solid cube with given dimensions $x$, $y$, and $z$: $$\rho C\frac{\partial T}{\partial t} = k \Delta T$$ The cube is irradiated with a constant ...
2
votes
1answer
58 views

Is there Von Neumann stability analysis for 9-point laplacian like we have for the 5-point Laplacian?

For spatial accuracy in 2-D Laplace equation, a 9-point stencil is better than a 5-point one. $$\partial_tq= r\left(\partial^2_x q + \partial^2_y q\right)$$ for FTCS (forward-time, central-space) ...
0
votes
1answer
99 views

Eigenvalue problem with periodic boundary conditions: Are my eigenvalues correct?

I am using a (central) finite difference scheme to solve the eigenvalue problem $$-\frac{d^2}{dx^2}u = \lambda u$$ with periodic boundary conditions on a unit interval. I use arpack's zndrv1 and ...
2
votes
0answers
35 views

Finite difference Neumann boundary conditions: uneven weighting of edge nodes?

Originally asked this on math.stackexchange, but I figure it's also appropriate here. I'm reading through some finite difference code for a diffusion equation and came across something odd for the ...
0
votes
0answers
44 views

Scheme to solve Maxwell's equations coupled to charge continuity equation?

Seems like most better known schemes don't handle this particular situation, so could someone suggest a good finite difference scheme to solve the following coupled equations (Maxwell+continuity ...
4
votes
1answer
75 views

Convergence rate Jacobi/Gauss-Seidel with mesh resolution

In the book A Multigrid Tutorial - Briggs, Henson. McCormick in the beginning of Chapter 3, it is mentioned that ...because the convergence factor behaves as 1-$O(h^{2})$, the coarse grid ...
1
vote
0answers
45 views

What is the finite-difference representation of the Laplacian operator with periodic boundary conditions? [duplicate]

I am using a central-difference scheme to solve the eigenvalue problem $$\frac{d^2}{dx^2}u = \lambda u$$ on a unit interval with periodic boundary conditions. My understanding is the eigenvectors $...
4
votes
2answers
152 views

Why is my simulation of a first-order wave equation not stable?

According to the equation $$ \frac{\partial y}{\partial t} = -a\frac{\partial y}{\partial x} $$ I simulated this in python. I used center differentiation, and I determined step size based on Von-...
4
votes
0answers
131 views

A good 2D finite difference for the continuity equation

How could I go about solving the continuity equation below in 2D? $$\frac{\partial \rho}{\partial t} + \nabla \cdot \left(\rho u\right)=0$$ I saw that a similar question was posted here: A good ...
0
votes
0answers
113 views

Neumann Boundary with ADI-method (FDM); how do I implement this?

I am modelling the Heat equation in 2D in Python. I am using finite difference methods, more specifically the Alternating Direction Implicit method. The model works quite well with Dirichlet boundary ...
7
votes
1answer
135 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 ...
1
vote
0answers
70 views

Finite difference methods for coupled 2nd order nonlinear pdes

I have a system of coupled nonlinear PDEs that I cannot figure out how to solve in a smart way using FDM, so I was hoping someone here might have a clue. The equations go as: \begin{align*} \frac{1}{...
0
votes
2answers
99 views

Conservative formulation for compact finite difference schemes

At the Section 4.2 of this paper (which is very well known in the computational fluid dynamic community), the author claims that it is enough, for the compact finite difference formulation in eq. 4.2....
0
votes
0answers
65 views

Discretize master equation

I'm trying to solve the following equation numerically using finite difference method. $\frac{\partial P}{\partial t} = -\frac{\partial}{\partial x_1}[F_1(x_1,x_2)P] - \frac{\partial}{\partial x_2}[ ...
2
votes
1answer
54 views

Discretisation of logarithmic derivative: Deriving the formula

I'm reading a paper where they use a discrete approximation of a logarithmic mass growth rate as follows: $$ \frac{d \log M}{d \log t} \approx \frac{(t_B + t_A)(M_B - M_A)}{(t_B - t_A)(M_B + M_A)}$$ ...
1
vote
0answers
35 views

Limit to volume change in a discretized mathematical model?

I have set up a mathematical model describing the diffusion of ozone out of a gas bubble. The bubble is surrounded by a thin gas film. So actually, the model describes the diffusion of ozone through ...
1
vote
1answer
205 views

second derivative with non-uniform spacing

I am trying to derive the formula for the second-order second derivative of the function $f(z)$ in the case of non-uniform spacings. I start by considering that, around $z=\zeta_k$: $$f(z)=f(\zeta_k)...
2
votes
1answer
63 views

normal derivatives where normal vector is ill-defined

I have to calculate the normal derivative of a function $f(i,j)$ on a domain with an irregular boundary. Let's say something like this: x x x x 0 x 0 0 0 0 0 0 ...
3
votes
0answers
56 views

Solving numerically a linearized system of elliptic (?) Navier-Stokes equation (Shallow Water Derived)

For my PhD Thesis, my advisor asked me to build a solver inspired from the article "Optimal Control Theory Applied to an Objective Analysis of a Tidal Current Mapping by HF Radar, J-L Devenon, 1989". ...
3
votes
1answer
62 views

Closed boundary conditions in finite difference method for diffusive-advective equation

I am implementing a finite difference method in solving the diffusive-advective equation: $$ u_t + v \cdot u_x = D\cdot u_{xx} $$ (v, D are constants). Planning to use the operator splitting method (...
0
votes
0answers
77 views

Neumann boundary condition FD implementation for instationnary diffusion equation

I am trying to solve this diffusion equation : $\dfrac{\partial D\dfrac{\partial f}{\partial x}}{\partial x}+S = \dfrac{\partial f}{\partial t}$ ($D$ is not constant and varies according to $x$) with ...