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
141 views

How to compute matrix representation of $\hat{y}\frac{\partial}{\partial x}$?

I have a 2-dimensional system which I would like to solve numerically (I'm using finite difference method right now), and its an eigenvalue problem. I have a term that looks like $H\psi(x,y) = [-\frac{...
4
votes
1answer
438 views

Thomas algorithm for 3D finite difference

For 1D finite difference, the resulting linear system is tri-diagonal and can be solved in O(n) using the Thomas algorithm. I am trying to solve a finite ...
1
vote
0answers
215 views

Finite Difference advection-reaction-diffusion in spherical coordinates, problem with Diffusion

I have a problem with the following equation: $$ V_r\frac{\partial C_A}{\partial r} + \frac{V_\theta}{r}\frac{\partial C_A}{\partial \theta} = \frac{2}{Pe_A} \left[ \frac{\partial ^2 C_A}{\partial r ...
0
votes
1answer
66 views

Difference Equation PDE in MatLab

I would like to program the following difference equation. Find numbers $v_{i,j}$ so that for $1\leq i\leq 4$, $0\leq j\leq 5$: $$ v_{i,j+1} = (0.1)v_{i+1,j} + (0.8)v_{i,j} + (0.1)v_{i-1,j} $$ In ...
1
vote
0answers
156 views

Algorithm for Adaptive Mesh Refinement

I am trying to implement Adaptive Mesh Refinement. I am not a Mathematics/Computational Science person so I will try to write the algorithm in a simpler way. I will be grateful if experts can comment ...
2
votes
1answer
431 views

Spectral methods, Spectral Volume methods, Spectral Difference methods

Could someone explain the link (if any) between the spectral methods (SM), as presented for example here and the so called spectral volume methods (SV) and spectral difference methods (SD) for CFD ? ...
1
vote
1answer
53 views

Transforming a 1D cartesian variable-coefficient diffusion code into a 1D adially symmetric one

So I have a code that I use which solves a 1D variable coefficient diffusion problem in cartesian coordinates: $\frac{\partial u}{\partial t}=\frac{\partial}{\partial x}\left(D(x)\frac{\partial u}{\...
1
vote
0answers
148 views

Spherical Advection Discretization (boundary nodes)

Consider the spherical advection problem: describing the conservation of a property $u$ in a closed spherical domain. $$ \frac{\partial u}{\partial t}+\frac{1}{r^2}\frac{\partial }{\partial r}\left(r^...
2
votes
1answer
513 views

Derivatives Approximation on non uniform grid

I was trying to approximate 1st derivative of a function $\phi$ on a non uniform grids: basically my aim is to do this on a uniform grid on the same domain, so I can calculate it on the "new" grid. ...
0
votes
1answer
35 views

choosing parameters for extrapolation method to give second order error

Edit: figure it out, made an error We are given that $$y' = f(y,t), y(t_0) = y_0$$ We want to use the following method $$ \begin{align} u^1_{n+1/2} &= u_n + \frac{h}{2}f(u_n, t_n)\\ u^1_{n+1} &...
1
vote
1answer
246 views

FD implementation of Absorbing Boundary condition for acoustic wave

I am simulating acoustic wave equation in which absorbing boundary condition has to be applied. It is applied in two ways Ist method is as mentioned in this paper. Boundary condition at bottom is (...
0
votes
1answer
256 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." ...
2
votes
1answer
177 views

What does it mean for a finite difference scheme to be $L^1$-stable?

I am trying to answer a question about a finite difference scheme. I need to show that the method is stable in the L1-norm. I can't find a single definition of what that means, so does anyone have a ...
0
votes
2answers
108 views

CHOLMOD implementation

I am working on a domain decomposition code in C that uses CHOLMOD to approximate grid values for a PDE in each sub-domain. The issue I have is that the methods use Matrix Market format, which is not ...
0
votes
1answer
243 views

Cauchy problem with a change of variables

Consider an advection-diffusion problem $$u_t+au_{xx}+bu_{x}=0,\quad x>0.$$ Now I want to remove the drift and rewrite the problem for the new domain. I use the change of variables $y=x-bt$, and ...
1
vote
1answer
113 views

Stability condition for explicit/implicit via non negative coefficients

To make stability proofs simpler, I can consider an explicit scheme written as $$V(n+1,i)=aV(n,i-1)+bV(n,i)+cV(n,i+1)$$ and one can show that if $a,b,c\ge 0$ and $a+b+c\le1$, then the explicit method ...
6
votes
2answers
538 views

Numerical Solution to Schrödinger Equation--Multiple Wells

I am trying to solve for the allowed wavefunctions and energies for a 1D quartic potential well. To do this I am using the patching method (https://engineering.dartmouth.edu/microeng/otherweb/...
2
votes
2answers
113 views

Combining trapezoidal rule with upwind scheme

I want to discretize and numerically solve the equation: \begin{equation} v(k)\dfrac{\partial f}{\partial z} + F(z)\dfrac{\partial f}{\partial k} = \alpha f(z,k) \,\,. \end{equation} Discretization ...
4
votes
0answers
169 views

Gradients of non-uniformly sampled data in 3D space

I have measurements of magnetic field on a 3d grid. My measurements are distributed on four x-y planes similar to what is shown in the image below. The measurements roughly follow a Cartesian grid but ...
4
votes
0answers
183 views

Stability analysis for a hyperbolic PDE on staggered grid

I am trying to understand the stability of a finite difference equation on the staggered grid. I could understand the Von Neumann stability analysis for the collocated grid for a simple acoustic ...
6
votes
1answer
366 views

Best practice for dealing with Dirichlet boundary conditions in finite-difference schemes: add artificial unknowns?

I know of at least two ways of dealing with Dirichlet boundary conditions in finite-difference schemes (and, to a lesser extent, finite-element schemes). Here I'm thinking of solving Poisson's ...
1
vote
1answer
236 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 ...
1
vote
0answers
73 views

Oscillations in Chorin's method due to the BC

I am pretty new to the CFD and I wanted to start with Chorin's projection. The starting problem is just a free jet flowing in the investigated area. I got terrible oscillations almost immediately and ...
1
vote
1answer
118 views

How to determine the truncation error with products and quotients

If I have an equation given by $$\displaystyle Y = \frac{a^2}{d^2}\frac{(1-c^2\frac{c}{a})}{(1-b^2)}$$ and I expand $a,b,c,d$ in a Taylor series, where $a$ is truncated at the $A^{th}$ order, $b$ is ...
0
votes
1answer
185 views

Heat Equation in 3D mass Matrix set-up

I am solving a 3D heat transfer equation with variable boundaries (insulated, convective, radiative or free) using a F.D.M. technique. My geometry of choice is a cube. The purpose of my work is to get ...
0
votes
2answers
428 views

Help implementing finite difference scheme for heat equation

I am trying to solve the following problem via a finite difference approximation: $u_t = k \, u_{xx}$, on $0 < x < L$ and $t > 0$; $u(0,t) = u(L,t) = 0$; $u(x,0) = f(x)$. I take $u(x,0) = ...
2
votes
1answer
235 views

finite difference frequency domain Eigenvalue matrix to get eigenmodes

I am using the FDFD method to calculate eigenmodes for an empty wave guide. It's a 1x1meter structure with a PEC boundary. (Here I have 6x6 points to make it simple). Sounds simple, but I can't get it ...
0
votes
2answers
148 views

What is wrong with my code for solving Poisson equation with one side Neumann boundary condition?

I wrote a Matlab code for solving 2D Poisson equation $u_{xx} + u_{yy} + f(x,y) = 0$ on $[a,b]\times [c,d]$ with neumann boundary condition on $x = b$ and the other boundary conditions are dirichlet,...
0
votes
1answer
98 views

Exact finite difference method for advection equation

I want to solve the advection equation: $u_t+au_x=0, a > 0$. Here is our method: $$U_j^{n+1}=U_{j-1}^n-\left(\frac{ak}{h}-1\right)(U_{j-1}^n - U_{j-2}^n)$$ I am trying to answer the following ...
5
votes
2answers
364 views

PetSc vs Sundials for serial numerical computations?

I am currently working on a physics problem that turns into a non-linear boundary value problem. I need an efficient numerical solver that I could run on my laptop with i5 dual core CPU. I am ...
3
votes
0answers
216 views

Corner Transport Upwind for Linear Advection in Arbitrary Velocity Field

I need to implement a 3D version of the Corner Transport Upwind (CTU) finite volume method (in python); and so I've been reading Leveque, "Finite Volume Methods for Hyperbolic Problems" which I think ...
1
vote
2answers
52 views

Approximate Neumann BVP operator by a matrix

I am considering approximating the operator of the BVP \begin{cases} -u''+u'=g,&\quad x\in [a,b]\\ u'(a)=-1, u'(b)=1, \end{cases} by a matrix. I tried to use the idea of finite difference ...
0
votes
1answer
66 views

Implementing temperature depending viscosity in a finite-difference scheme

I have a little question that might be basic for some experts, but right now, its not clear for me. I want to implement temperature depending viscosity in a finite difference scheme (incompressible ...
0
votes
1answer
91 views

Discretized matrix from the integral kernel function

Recently, I read a paper [1] and then I want to handle the two-dimensional linear integro-differential equation \begin{equation*} -\triangle u + q\Big(\frac{\partial u}{\partial x} + \frac{\partial u}{...
1
vote
0answers
50 views

Finite differences for incompressible viscous fluid equations

I am working with the equations for incompressible viscous fluid: $$ \partial_t \vec{\omega} + (\vec{u}\cdot\nabla)\vec{\omega} = \nu\nabla^2\vec{\omega} $$ $$ \nabla^2 \vec{\psi} = -\vec{\omega} $$ $...
1
vote
0answers
253 views

Collocated Grid Navier Stokes Solver

I want to solve Navier Stokes equations on a collocated grid. Earlier, I was using a MacCormick scheme based solver where I discretized predictor step in forward differences and corrector step in ...
1
vote
1answer
61 views

How to set the temperature at the vertices points for a rectangular domain?

Suppose I have to solve the 2-D heat equation in a rectangular domain using the finite difference method, for the boundary conditions say: $T_1$ is the temperature of the right side of the rectangle, ...
0
votes
1answer
317 views

Three body problem in C++

I am in a begginers programming course and we got a little project. I chose to simulate the three body problem using the Euler method. Even though the system is chaotic there are some special cases ...
3
votes
1answer
350 views

Second order interpolation scheme

On a grid I am having the values of a physical quantity say for example Temperature, at the E,W,N,S and P node all of them being calculated using a second order discretization scheme. I want a second ...
2
votes
1answer
355 views

How to define residual in multigrid approach?

I wish to solve the two-dimensional Navier Stokes equations using multigrid method on a collocated grid using the Predictor-Corrector method mentioned below. But first, let me elaborate on what I had ...
3
votes
1answer
282 views

Discretize Poisson equation with derivative of delta function as source

Consider the PDE \begin{equation} \frac{d^2}{dx^2} g(x) = \frac{d}{dx} \delta(x-x_0), \end{equation} with $x, x_0 \in [0,1]$ and $g(0)=g(1)=0$. What is the best method to discretise the derivative of ...
1
vote
0answers
206 views

Unwanted Oscillation in FDM simulation of elastic wave equation

I am using staggered grid FDTD for solving elastic wave equation. A description of which can be found at (geodynamics.usc.edu/~becker/teaching/557/reading/Virieux1987.pdf). I have generated a ...
3
votes
1answer
165 views

Is this finite difference approach correct?

I am solving incompressible 2D Navier-Stokes equations with zero y-component velocity. The geometry is a simple 2D pipe of a length $L$ and diameter $W$ and there is only two boundary conditions: Non-...
3
votes
1answer
189 views

Stability Criterion for this Explicit Scheme

I am solving an unsteady flow using the dual-time Navier-Stokes equation in which I write my momentum equation as: $$\frac{\partial u}{\partial \tau} + \frac{\partial u}{\partial t} + \frac{\partial u^...
1
vote
0answers
103 views

CFD implementation in software [closed]

I've been learning CFD theory for 4 months (which includes FEA, FDM AND FVM) and now I want to start running simulations. As a novice to CFD software, I would appreciate some advice on where to start, ...
1
vote
1answer
52 views

Suitable method for simulation of in-fiber interferometer

I am trying to simulate an optic-fiber sensor (in-fiber interferometer) to study its respond to temperature. The method I am using is finite-difference time-domain (FDTD), and I come out with a large ...
0
votes
1answer
209 views

Boundary conditions generalized eigenvalue problem

Consider the following eigenvalue problem \begin{equation} \mathcal {L} x(s) = \lambda x(s), \end{equation} where \begin{equation} \mathcal {L} = \alpha \partial^4_s + (s^2-1)\partial^2_s + s \...
3
votes
1answer
2k views

How do I program periodic boundary conditions? [duplicate]

Hi I have a code below that solves non linear coupled PDE's given Dirichlet boundary conditions. However I need to implement periodic boundary conditions. The periodic boundary conditions are ...
1
vote
0answers
78 views

Representing a 3D system in 2D (Electromagnetic modelling)

Ok so I'm a complete beginner in computational modelling (I use analytical methods of physics typically) but I would like to model an anisotropic, aperiodic (but not random) finite array of metallic ...
-1
votes
1answer
461 views

Stability analysis for coupled nonlinear system of partial differential equations

I'm trying to solve a nonlinear partial differential equation \begin{equation} L(u_{xxtt},u_{xx}u_{tt},u_{xt}^2,u_{xt},u_{tt})=0 \end{equation} using finite difference methods. In order to remove the ...