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
0answers
37 views

Staggered grids applied to the Hyperbolic PDE

Let the PDE be defined as \begin{align} & \begin{cases} u_t = v_x \\ v_t = u_x \end{cases}\; \; -1 \lt x \lt 1, t \ge 0 \\ & u(-1,t) = u(1,t) = 0 \end{align} Initial conditions for $u$ and $...
2
votes
0answers
56 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
52 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
95 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
19 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
120 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
116 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
75 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
110 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
130 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
52 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
76 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
29 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
38 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
66 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
43 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
142 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
117 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
65 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
122 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
62 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
98 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
64 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
53 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
124 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
54 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
56 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
66 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 ...
1
vote
0answers
42 views

Global truncation error behavior at fixed time step

I am trying to solve the following diffusion equation problem: $\frac{\partial f}{\partial t}=\frac{\partial (D\frac{\partial f}{\partial x})}{\partial x}+S$ $D=1+x^{2}+\sin(x)$ $f(x,0)=1 , f(0,t)...
1
vote
2answers
307 views

Implementing no-flux boundary condition reaction-diffusion PDE

I'm having trouble figuring out how to implement boundary conditions for this problem: \begin{align} \frac{\partial n}{\partial t} &= D_n\nabla^2n - \nabla\cdot\left(\frac{\chi}{1+\alpha c}n\nabla ...
1
vote
3answers
71 views

Discretization Error amplification instead of stagnation to machine precision

I wrote a code on Python 2.7.5 to solve numerically the following differential equation. $\frac{\partial^2f}{\partial x^2}=-S$ $S=\pi^{2}\sin(\pi x)$ S is chosen that way in order to have $f= \sin(\...
2
votes
0answers
52 views

Finite differenced eigenvalue prob. of inhomogeneous boundary conditions?

I am basically asking about eigenvalue problems of differential equations using some finite difference method (FDM). Usually the system is subject to some boundary conditions (BC), e.g., Dirichlet or ...
0
votes
0answers
78 views

Should ghost cells/nodes be coupled?

This is more of a theoretical question regarding the concept of ghost cells. When handling Neumann boundary conditions, ghost cells (in FVM) or nodes (in FD) are typically introduced. Essentially, ...
1
vote
1answer
183 views

Applying Neumann boundaries to Crank-Nicolson solution in python

Consider the heat equation $$u_t = \kappa u_{xx}$$ with boundary conditions of $$u(x,0)=0\\ u(0,t)=100\\ u(l,t)=0$$ Numerical analysis by pyton can be done with ...
1
vote
1answer
69 views

finite differences on a slanted grid — advection diffusion equation

I used pretty much all my expertise with finite differences to solve an advection-diffusion equation with space-dependent coefficient with a grid in the $x$,$z$ domain with regular spacings. Something ...
3
votes
1answer
70 views

Numerical Lax-Wendroff scheme order of convergence on Burgers equation

I was suggested to move that question here. The question to be as follows. Statement of the problem Is it possible to achieve the second order of convergence (OOC) of Lax-Wendroff (LxW) scheme ...
1
vote
1answer
47 views

Problems with deriving an equation for a finite-difference scheme given in the journal paper

I'm reading this paper and trying to follow everything that the author has done. A Comparative Study of Finite Volume Method and Finite Difference Method for Convection-Diffusion Problem But there ...
1
vote
0answers
32 views

Convergence rate assesment in space/time

I am solving a hyperbolic PDE (e.g. the shallow water equations) which depends upon $x$ and $t$. Typically, the overall convergence rate is calculated by comparing the numerical error in different ...
0
votes
1answer
39 views

Finite difference time domain and dynamic permittivity

Since the permittivity of any material is usually complex function of temperature, frequency, density, etc. I was wondering if it is possible to use a dynamic permittivity which changes as a function ...
0
votes
1answer
101 views

Unphysical Behaviour Characteristic-Wise WENO5-Z

I am currently working on a scheme that uses finite differences WENO5-Z with 3rd Order Runge-Kutta time integration for solving the Euler equations. The code projects the conserved variables and ...
0
votes
1answer
45 views

Trying to solve a wave-like equation

I'm trying to solve an equation whose solutions I know are plane waves but there are a few nuances. First, the equation is of the form $$ \partial^2_t \psi + A(r)\partial^2_r \psi +B(r) \partial_r \...
0
votes
0answers
29 views

1D Helmholtz Equation Eigenmodes [duplicate]

I'm trying to simulate a 1D parallel plate waveguide. This is the eigenvalue problem: $$\left(\frac{d^2}{dx^2} + \omega^2\mu_0\epsilon_0\right)E = \beta^2E$$ As a matrix problem, if my 1D domain is ...
4
votes
0answers
93 views

How to account for the interface between two different phases in a discretized diffusion model?

I have tried to set up a model for the diffusion of a gas into a liquid. The two media are next to each other and the geometry is spherical because the system should simulate the diffusion out of a ...
1
vote
2answers
116 views

Mass conservation in 1d diffusion by method of lines

I am solving the 1D diffusion equation by discretization using the method of lines. My problem is that I don't manage to ensure mass conservation. I have read many similar questions about the topic ...
0
votes
0answers
86 views

How can I solve wave equation(2d) for circular rod in cylindrical coordinates?(in finite difference scheme)

i have a problem with stability wave equation in finite difference method for cylindrical coordinates. the equation is: and when i run it in matlab,this is the result: Does anyone know where the ...
0
votes
1answer
57 views

Multi-point axisymmetric boundary condition for Euler equations

I'm solving 2D axisymmetrical Euler's equations in conservative form: $$ \frac{\partial U}{\partial t} + \frac{\partial F(U)}{\partial x} + \frac{\partial G(U)}{\partial r} = H(U) $$ where $$ U = \...
3
votes
1answer
213 views

Finite difference method basic implementation on Octave

Trying to study the error of FDM for a second order derivative versus step size I calculated the coefficients and validated them, but the output has errors for small step sizes. The function in ...
1
vote
2answers
116 views

Find classical solution of transport equation with FDM

We know the classical solution of transport equation is determined by one initial (boundary?) condition, for example, the solution of $$\frac{\partial u(t,x)}{\partial t}+\frac{\partial u(t,x)}{\...