We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [finite-difference]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
51 views

How suitable is multigrid method for time-dependent PDEs?

For elliptic PDEs (Poisson-type), the multigrid method is very sufficient, but how about time-dependent problems (i.e parabolic or hyperbolic PDEs)? Is it efficient to solve such problems using a ...
0
votes
1answer
73 views

Need an example Legendre-Gauss-Radau pseudospectral differentiation matrix or Matlab code

I'm trying to implement various kinds of pseudospectral methods for direct optimization in Matlab using IPOPT. I've got some working Legendre-Gauss-Lobatto code, but would like to use the flipped ...
1
vote
0answers
41 views

Can the standard multigrid performance be used for time-dependent PDEs?

Consider a time dependent pde(i.e u(x,t)).I know when only space-coarsening is used the standard multigrid performance can be applied but what if instead we use only time-coarsening?Can we apply the ...
1
vote
2answers
134 views

Lattice Boltzmann methods vs Navier stokes/ other eulerian methods for *water* simulation

Note, there is already a question here, however the answers don't answer the original question, let alone specific considerations when dealing with nearly in-compressible fluids (water). Another ...
1
vote
1answer
63 views

Simulating advection - diffusion problem in a network of 1D pipe

I'm interested in solving the following advection-diffusion system in a 1D network of pipes. $$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2} - v\frac{\partial C}{\partial x}$$ ...
1
vote
1answer
115 views

Solving nonlinear PDE with finite difference based on Newton-Krylov

I am now working on solving MHD equations with finite difference method, which include nonlinear equations: $$ \frac{\partial\rho}{\partial t}+\nabla\cdot\left[\left(\rho_0+\rho\right){v}\right]-\...
1
vote
0answers
22 views

Solving a system of PDEs with no-flux boundary conditions (finite difference discretization)

I am interested in solving a system of linear PDEs with the finite difference method and I'm having trouble to solve the no-flux boundary condition correctly. \begin{align} \frac{\partial n}{\partial ...
0
votes
0answers
35 views

Imposing decaying boundary conditions on a non linear ode

I am trying to solve $a^{2}y''=y+y^3$ numerically. This equation models a potential and goes to $\infty $ for $x\to0$ hence I get the singularity to be of order $\frac{1}{x}$ by keeping only the y^{3} ...
-1
votes
0answers
73 views

Solving one dimensional diffusion equation

This is a followup to my previous post here. I'm solving a 1 D diffusion equation using Dirichlet boundary conditions on both the boundaries, left and right. $$\frac{\partial C}{\partial t} = D\...
1
vote
0answers
54 views

Solving diffusion equation using finite difference method

I am solving an 1-dimensional diffusion equation with Neumann boundary condition at outlet and constant concentration, C, at the inlet. In the end, I want to observe how the concentration diffuses ...
-2
votes
0answers
63 views

2D Heat equation - MatLab implementation (FD in space, Expl. Euler in time)

I'm trying to solve the heat equation in 2D in $\Omega=[0,1] \times [0,1]$, with homogeneous Dirichlet boundary conditions, and initial condition $u(x,y,0)=\sin(2 \pi x y)$ i.e. \begin{cases} u_t=u_{...
1
vote
1answer
399 views

Assembling sparse matrix in PETSC for Poisson equation

I am a novice at PETSC, and I have been trying to write an FVM code for steady heat conduction in 2D using PETSC (square, regular grid, Dirichlet boundaries) Since the large matrix , say A, will be ...
2
votes
1answer
36 views

Stability of a finite-difference scheme for the reaction-diffusion equation

I currently need to solve numerically the following reaction-diffusion equation: $$\partial_tu=\partial^2_xu+u-u^2$$ For this purpose, I use the following numerical scheme (Crank-Nicolson??): $$ \...
0
votes
1answer
74 views

Implementing structured grid boundary conditions using NumPy arrays?

I am making a toy code in Python to solve the advection equation $$u_t + cu_x = 0$$ with, for example, periodic boundary conditions. Background information The numerical grid is specified like this: ...
1
vote
1answer
51 views

Should the derivative of an array be calculated array by array or element by element in CFD codes?

I am making my own finite difference computational magnetohydrodynamic code in Fortran 90. Looking at other codes they appear to calculate for example their $x$-derivatives, bb of their variables, e.g....
2
votes
1answer
46 views

Confusion about Zabusky and Kruskal's stepper for the KdV equation

In Zabusky and Kruskal's paper about solitons, they derive the following update for the Korteweg de Vries equation (their footnote 6): \begin{align*} u_{i}^{j+1} = u_{i}^{j-1} - \frac{1}{3} \frac{k}{...
2
votes
1answer
69 views

1-D boundary value problem: How implement mixed boundary conditions using a FD method?

I have been given a convection-diffusion ODE modeling the steady state temperature of a pipe (through which flows a fluid) as $$-\frac{d}{dz}\left(\kappa \frac{dT}{dz} \right)+v\rho C\frac{dT}{dz}=Q(...
1
vote
0answers
25 views

Finite difference/element method : time step and spatial resolution close to a finite singularity

I'm using the finite element method (FEM), but my question is quite a global question. It's related to this question but it is not the same. Let's assume we have this equation : $$\partial_t c - u\...
3
votes
0answers
80 views

numerical instabilities in Fluid Dynamics, Finite Element Method

I'm looking for references to understand where the numerical instabilities come from in hydrodynamics in general, and notably when the Péclet number: $Pe>1$. I'm using the finite element method. ...
1
vote
0answers
38 views

Predictor-Corrector vs. Deferred Difference Corrections

I want to use the Numerov method but keep higher-order terms from the Taylor expansions. In the literature, I found the term "Deferred Difference Corrections" for the procedure of first solving the ...
3
votes
1answer
127 views

Why do many people use FDM method to solve Stokes equations, i.e., saddle point matrix?

For numerical methods of the Stokes equations, with appropriate boundary: $$-\nabla^{2} \vec{u}+\nabla p=\overrightarrow{0}$$ $$\nabla \cdot \vec{u}=0$$ one may use FDM (finite difference method) ...
1
vote
1answer
343 views

Difficult bug in my 2D Compressible Euler solver

For the past few days, I have been writing a numerical solver for the 2D compressible Euler equations for an ideal gas. My numerical method has been the Local Lax Friedrichs or "Rusanov's method." ...
0
votes
1answer
168 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
1answer
593 views

Finite Difference Method Limitations/Stability Criteria

Is it possible to solve an equation with only a single derivative such as: $$\frac{\partial U(x,t)}{\partial t} = A - BU(x,t)$$ with finite difference methods? I ask as I am trying to solve the ...
1
vote
1answer
104 views

How to obtain linear tridiagonal system from PDE

I'm trying to re-solve the governing equations in hydraulic fracturing modeling as instructed step by step in a paper. After (A-9), the author stated that by substituting A-6, A-8 and A-9 into ...
2
votes
0answers
83 views

Implementation of boundary conditions for 1D Euler equations

I'm trying to solve 1D Euler equations with gravity in spherical coordinates using a finite-difference TVD MacCormack method on a non-uniform grid of $N$ components, following the method provided in ...
1
vote
1answer
281 views

Suitable finite difference method for a convection-diffusion system?

I am trying to solve a system of PDEs $H_{t} = \frac{0.3}{0.7} - \frac{0.005 B f(h(H))}{\theta} - \frac{0.3 f(h(H))}{0.7} + \frac{500}{0.7} (HH_x)_x + (HH_y)_y$ $N_t = \frac{N_{in} - 0.002 [N] B f(h(...
2
votes
0answers
42 views

Verification on pressure predictor method for CFD code

I have developed a python code for a lid-drive cavity model. However, my results are not converging. The algorithm of my code looks like this: Euler Momentum Equation looks like this: $$\frac{u^{n+1}...
21
votes
5answers
14k 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$...
1
vote
0answers
62 views

FDM discretization of equation on the boundary

In order to simulate the following equation using FDM $$u_t(t,x)-u_{xx}(t,x)=0, \quad (t,x) \in (0,1)\times (0,1)$$ $$(u_t(t,x)-u_{x}(t,x))\rvert_{x=0}=0, \quad t \in (0,1)$$ $$(u_t(t,x)+u_{x}(t,x))\...
3
votes
2answers
99 views

Damped Harmonic Oscillation. Efficient algorithm to find the parameters resulting in threshold oscillation amplitude

Let's assume, that we have damped harmonic oscillation of a body in the form of a cone, immersed in a liquid. Equilibrium condition of the body is: $$m\overrightarrow{a} = \overrightarrow{F_\text{...
1
vote
0answers
47 views

WENO scheme on curvilinear coordinates

I've been developing a curvilinear FVM code. So far I've implemented the PPM scheme and am looking into adding WENO schemes. So far I've been discretizing the grid metrics using a second-order central....
2
votes
4answers
750 views

Finite difference for mixed derivatives on nonuniform grid

I need to have a finite difference stencil for the mixed derivative $$f_{xy}$$ on nonuniform grids such as this one: Since I could not find a stencil in the literature, I tried to derive it by my ...
3
votes
0answers
300 views

Efficient assembly of finite element matrix(coupled equations case)

I noticed this post, where spalloc and sparse are recommended for efficient assembly in Matlab. I personally use sparse ...
1
vote
1answer
142 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 ...
1
vote
1answer
75 views

Perfectly matched layer simulation with two vibrating sources

I'm doing PML simulation, and while I was looking for correct geometry for my layers of propagation, I got a question. My device has two vibration sources, and this vibration will propagate through ...
3
votes
1answer
117 views

Comparison between FEM and FDM methods for flow simulations

What are the main differences between finite element and finite difference approach for incompressible flow simulations? I have a vague idea about how FE methods rely on minimizing the residual over ...
2
votes
1answer
90 views

What method of Finite difference is this?

I am reviewing Numerical Recipes method on solving ODEs via relaxation (Chapter 18.3 in the 3rd edition) and they chose a finite difference method I am unfamiliar with (Equation 18.3.2): \begin{...
1
vote
1answer
45 views

Interpolating the gradient of a cylindrically symmetric potential field that's 'supposed to' obey the Laplace equation?

The script below tries to implement a Jacobi iterative relaxation of a potential field for an electrostatic lens. It's hot-off-the-press and I've just started to debug and look for things to test it ...
1
vote
0answers
31 views

Dealing with spurious oscillations in particle tracking methods

I work on modelling high intensity discharge xenon-filled lamps. The model governing the discharge is quite complex and sadly includes fluid dynamics. After some time, I managed to implement a finite-...
1
vote
1answer
82 views

Finite difference methods

I am currently applying the finite difference method to the solution of the diffusion equation. I think that a problem has occurred, and is as follows, my explicit method is the most accurate when ...
1
vote
1answer
439 views

Singular matrix for 2D Stokes flow in finite differences

I have a problem by solving stokes flow in 2D by finite differences. I am using a marker and cell method, my scheme is ...
0
votes
0answers
91 views

Second derivative using Fornberg finite difference method

I have some discrete data, non-equispaced in x, y=f(x). I want to use a numerical finite difference method to calculate the second derivatives of y, at some point. I am using the Fornberg method, ...
0
votes
0answers
37 views

Neumann boundary conditions on arbitrary surface for finite difference diffusion

I am facing the following problem, formulated in practical terms: I have a region $\Omega$ in two or three dimensions, represented as a binary mask, and an initial density $u_0$ within that region ...
2
votes
0answers
38 views

How to determine the order of convergence of the Euler-Maruyama method?

This question is originally posted in Quant.StackExchange but has been unanswered for some time so I ask in here. To make this simple let us consider the Geometric Brownian Motions (GBM). My ...
3
votes
2answers
106 views

Finite difference for a highly nonlinear equation - The wind within the forest

Based on the Navier-Stokes equations and a few parameterizations, the horizontal steady-state wind $u(z)$ within a forest of height H satisfies: $$ a\left(\frac{du}{dz}\right)^2 + b\frac{du}{dz} \...
1
vote
2answers
325 views

Can I model laminar incompressible fluid flow and heat transfer in MATLAB's PDE toolbox?

I have a system of PDEs in cylindrical coordinates that needs to be solved: 1. Continuity equation 2. Incompressible Navier stokes ( in r & z coordinates) 3. Heat transfer equation with both ...
0
votes
1answer
72 views

Dirichlet boundary conditions in the 1D Heat Equation

Please consider the assignment I have uploaded on the picture. I am confused about the functions $g_L(t)$, $g_R(t)$ and $\eta(x)$. What are they and how do I find them... My question: Is it possbile ...
0
votes
1answer
87 views

Good C, C++ library for efficient grid search / tuples, ideally with bindings to Eigen

I have a $q$-dimensional grid, known at run, not compile-time, that has $50$ points in each direction and hence $50^3$ combinations that I would like to first build and then call a function with each ...
0
votes
1answer
126 views

Numerically solving a non-linear PDE

I have this non-linear partial differential equation. $$ \frac{\partial C}{\partial t}=\left(\frac{\partial C}{\partial x}\right)^2+C\frac{\partial^2 C}{\partial x^2} $$ I want to use the finite ...