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.

0
votes
0answers
16 views

Non-linear Boundary Value Problem. How to compute the Jacobian?

Consider a Boundary Value Problem: $$ \delta u''+u(u'-1) =0 \Leftrightarrow u''=\frac{-u(u'-1)}{\delta}=:f(t,u',u), \\ u(0)=a, u(1)=b $$ $\delta,a,b$ are known parameters. I want to implement Newton'...
0
votes
0answers
13 views

Attempting SOR and conjugate gradient with 2D BVP, is there something wrong with the problem? Or will matrix be ill-conditioned?

The goal is to use a Laplace equation to solve: $$a(x,y)(u_{xx} + u_{yy}) = f(x,y)$$ with boundary condition $u=0$ on the boundary $x:[-1,1] , y:[-1,1]$. The problem is that we are supposed to work ...
0
votes
1answer
78 views

How to make a less diffusive code to solve 2D advection equation?

I would like to solve the following differential equation numerically in 2D, $$\frac{\partial z^-}{\partial t}+(\vec{B}\cdot\vec{\nabla})z^-=0,$$ see Wikipedia if you are curious about what the ...
0
votes
0answers
17 views

Implicit finite difference flow across across multiple cells

I am interested in solving a simple equilibration flow on a finite difference grid (i.e., non-uniform initial potentials/heads $p^t$, all boundaries no-flow). It is relatively easy to set up an ...
0
votes
1answer
74 views

Actual global error vs theoretical global error: How to combine theory with practice

I have implemented an Adams Bashforth 4 method to solve an Initial Value Problem for an ODE and I am testing it against the test equation: $y'=\lambda y$ with $y(0)=1$ with the exact solution: $y(t)=...
1
vote
0answers
22 views

Boundary Conditions involving exponential functions of nodal unknowns

I am fairly new to Computational Engineering and I have mainly been exposed to using the Finite Difference Method to produce Linear Systems and solve them using Iterative Methods. I am trying to ...
-2
votes
0answers
96 views

Finite Difference Solver Heat Equation

I am trying to write a finite difference solver for the heat equation in Python using FTCS implicit scheme. My details are below; $\frac{\partial{T}}{\partial{t}} = \frac{\partial^2{T}}{\partial{z}^2}...
0
votes
1answer
41 views

Discretization Neumann boundary condition

I'm currently working with the following Poisson equation with mixed boundary conditions, including a Neumann boundary condition. $$\Delta u = f\\ u(x,0) = g_1(x), 0<x<1\\u(0,y) = g_2(y), 0<...
2
votes
1answer
69 views

Numerical integration of Fokker-Planck equation allowing for negative drift?

The Fokker-Planck equation (a.k.a Kolmogorov forward equation or Smoluchowski equation) describes the evolution of a probability density function and numerical integration of the FPE should conserve ...
2
votes
0answers
48 views

Unusual boundary conditions on Matlab

I'm trying to solve the following PDE by Matlab, $$ u_t-\Delta u = 0, \quad \text{in}\quad \Omega\times (0,T) \tag{1} $$ $$ u_t-\Delta_\Gamma u + \partial_\nu u=0,\quad \text{on}\quad \Gamma\times(0,...
3
votes
0answers
83 views

WENO5 scheme in a staggered grid

I'm trying to use the finite-difference WENO scheme to solve the 2D density conservation law with axial symmetry (coordinates $r,z$): $\frac{\partial \rho}{\partial t}+\nabla \cdot (\rho \vec{v}) = \...
2
votes
0answers
81 views

Can I take advantage of a nearly banded A in AX=b?

I am working on a 1D drift-driffusion problem in a finite-difference (FD) approach. I hade 3 equations per node ($3N$ in total): electron continuity $E_i$, Poisson $P_i$, hole continuity $H_i$. With ...
1
vote
0answers
27 views

Hydrogen-like wavefunction as starting guess for atomic solver?

I've been looking into radial solvers for quantum wave equations (Schroedinger and Dirac). In both cases, the suggestion seems to be to go with the "shooting method", with integration schemes of ...
2
votes
3answers
193 views

How does a stiff equation solver work?

I am trying to understand how stiff differential equations are solved. For instance the equation, $$\frac{\partial y}{\partial t} = \alpha\frac{\partial ^2 y}{\partial z^2}$$ can be solved using ...
0
votes
1answer
132 views

Python Finite Difference Schemes for 1D Heat Equation: How to express for loop using numpy expression

Hello all, I've recently been introduced to Python and Numpy, and am still a beginner in applying it for numerical methods. I've been performing simple 1D diffusion computations. I suppose my ...
1
vote
1answer
46 views

Finite difference - Explicit / Implicit / Crank Nicolson - Does the implicit method require the least memory?

Examine a dynamic 2D heat equation $\dot{u} = \Delta u$ with zero boundary temperature. A standard finite difference approach is used on a rectangle using a $n\times n$ grid. For the resulting linear ...
2
votes
1answer
112 views

Analytical Solution of Transport Equation

I'm looking at the analytical solution of the convection-diffusion equation $$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2}-v\frac{\partial C}{\partial x}$$ with initial ...
1
vote
2answers
63 views

TVD for temporal dicretisation

I have come across schemes where TVD (with flux limiters) is used for spatial discretisation along with Runge-kutta for Temporal discretisation. Can TVD be used for Temporal discretisation? If so ...
2
votes
0answers
50 views

How to implement register blocking for 3D finite-difference stencil computations

I am in need to optimize the performance of the 3D solver that integrates a system of equations for seismic wave propagation. Unsurprisingly, the function that implements the finite-difference stencil ...
0
votes
1answer
55 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
48 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
59 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
159 views

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

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
65 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
126 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
220 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 ...
3
votes
0answers
33 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
80 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
140 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)....
0
votes
1answer
39 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
89 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 ...
4
votes
1answer
100 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(...
2
votes
0answers
30 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
91 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
72 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
65 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
58 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
138 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
38 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 ...
0
votes
1answer
151 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
126 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
78 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
149 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
157 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
65 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
142 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
38 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 ...
4
votes
1answer
98 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
47 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
169 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-...