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

Solution of Cahn-Hilliard equation

I need to solve the Cahn-Hilliard equation $$\frac{\partial u}{\partial t} = \Delta(f(u) - \epsilon^2\Delta u), \hspace{.5cm}(x, t)\in \Omega\times(0, T],$$ using mixed formulation \begin{equation}\...
0
votes
1answer
54 views

3D laplacian operator

I have been unable to find the equivalent of the 5-point stencil finite differences for the Laplacian operator. In 2 dimensions for me it is clear that, using the finite difference method: $$ \nabla_{...
1
vote
1answer
52 views

Parity for artificial dissipation term in a finite-difference solution

I have a doubt regarding the signal of the dissipative term in a finite difference solution for an equation of the form $$ \frac{\partial u}{\partial x}+f(x)=0, u(0)=0 $$ In which $f$ is an odd ...
0
votes
0answers
40 views

numerical solution to pde on an ellipse

Looking for advice on discretization (preferably finite difference) schemes for pdes on curves in general, but in this case it is an ellipse (so given by $(a\cos(r), b\sin(r)$). The problem is the ...
0
votes
2answers
46 views

No flux Neumann boundary condition for non-stationary PDE equivalent to Dirichlet boundary?

When using no flux Neumann boundary conditions (i.e. zero derivative to the normal on the boundary) in a non-stationary PDE, I don't seem to recognize the difference to using Dirichlet boundary ...
2
votes
1answer
70 views

Method of Lines: How to simplify Jacobian with periodic BCs?

Consider the advection equation $$\frac{\partial u}{\partial t}+c(x)\frac{\partial u}{\partial x}=0.$$ With periodic boundary condtitions in $x$ with period $L$, i.e. $u(x,t)=u(x+L,t)$ and initial ...
7
votes
3answers
312 views

Finite-difference software for solving custom equations

Are there any good, easy to use, software for simulating the evolution of systems of generic differential equations? I know there are custom programs for various specific circumstances (such as ...
1
vote
1answer
52 views

Problems with manufactured solutions for 1D inviscid burgers' equation

I'm having an issue with the easiest example of a nonlinear 1D PDE, the (inviscid) burgers' equation: $u_t + uu_x = 0,~~(1)$ which can be rewritten as some convection equation $u_t + f(u)_x = 0$ with ...
1
vote
0answers
54 views

1-D Conduction Steady state heat transfer using FD

I have tried to solve 1-D Conduction Steady state heat transfer problems in Matlab (see below). Here is the 1-D model: T''[x] == 0, T[0] == 100, T'[100] == 0 ...
4
votes
1answer
81 views

Imposing no flux boundary conditions on variants of the Cahn-Hilliard equation using Finite Differences in Python

I have been looking into simulations of phase separation in variants of the Cahn-Hilliard system and have been running into issues with implementing no flux boundary conditions on certain variants. ...
0
votes
0answers
25 views

Choosing appropriate timestep for FDTD and PIC algorithms

I'm doing some particle-in-cell (PIC) simulations of propagation of short pulses in plasmas with a widely used code. This code uses Yee's field solver. So, the timestep must be lower than the Courant ...
1
vote
2answers
187 views

Solve wave equation with discontinuous coefficients numerically?

I would like to solve the following equation $$\frac{\partial^2 y}{\partial t^2} - c^2(x,t)\frac{\partial^2 y}{\partial x^2}=0,$$ for $y=y(x,t)$ numerically. The wave speed, $c(x,t)$, is of the form $$...
7
votes
1answer
357 views

When and when not to use automatic differentiation

I am just learning (more) about automatic differentiation (AD) and at this stage it kind of seems like black magic to me. The second paragraph of its Wikipedia article makes it sound too good to be ...
0
votes
0answers
54 views

Preconditioning the $[1 \quad-2 \quad 1]$ Finite Difference matrix

Let $A$ be the well known tridiagonal matrix coming from the 1D Finite difference discretization of the Laplacian, with stencil $\frac{[1 \quad-2 \quad 1]}{h^2}$. The system $Ax = b$ is very large, so ...
0
votes
1answer
38 views

How to calculate error in successive over relaxation for PDE?

I am trying to solve the Poisson equation numerically using the FDM method in C++. But I have a little confusion with the iterative process. I understand that the number of iterations should go until ...
0
votes
1answer
83 views

Which scheme for inhomogeneous convection-diffusion equation with highly variable coefficients?

I have a 1D convection-diffusion equation $\sigma_t = a(x,t) \sigma_{xx}+b(x,t)\sigma_x+f(x,t)$ defined on the unit interval, with nonzero Neumann boundary conditions at both ends. It should be noted ...
2
votes
1answer
61 views

Effect on methods like Crank-Nicolson of adding a potential term, changing heat equation to Schrodinger equation

I'm studying up on methods for numerically solving the Schrodinger equation. The Schrodinger equation with a zero potential is formally identical to the heat equation in the sense that we just make ...
1
vote
2answers
149 views

$P0$ elements for $H1$

Are there $P0$ (zero degree/constant element) nonconforming methods for approximating solutions in $H1$? More specifically, I have the equation: $$u-f - T\Delta u = 0$$ Which can be interpreted as ...
2
votes
2answers
105 views

Finite difference method having a discontinuity

I am trying to understand the FDM which is a widely used method solving differential equations by using approximation below. $$\dfrac{\partial u}{\partial x}=\dfrac{u(i+1)-u(i-1)}{2\Delta x}$$ How can ...
3
votes
0answers
39 views

Numerical calculation of the Berry connection

I'm doing some numerical calculations involving Hermitian matrices, and derivatives of the eigenvectors. Essentially, I have an n x n, Hermitian matrix H(x), which is dependent on some continuous ...
1
vote
1answer
49 views

2D heat equation in both steady state and Transient state using iterative solvers

While solving a 2D heat equation in both steady-state and Transient state using iterative solvers like Jacobi, Gauss seidel, SOR. Should the answers, I mean the converged results of Temperature ...
3
votes
1answer
89 views

Finite difference methods in cylindrical and spherical co-ordinate systems

I am quite familiar with finite difference schemes in cartesian coordinates. The key point here is that every point in the cartesian grid is treated equally as the spacing between consecutive points ...
0
votes
1answer
30 views

How to fill matrix entries for two-dimensional implicit finite-difference for the general case

If I have derived a finite-difference formula for a 2D problem, for example something like: $af_{i,j}+bf_{i-1,j}+cf_{i,j-1}+df_{i-1,j-1}=g_{i,j}$ where f is the unknown function on a grid and ...
1
vote
1answer
94 views

Numerical methods that can be written in flux conservative form

I have a system of non-linear PDEs that I expect to have shocks as well as the appearance of Gibbs phenomena (spurious oscillations that form near the shock) for 2nd-order methods or higher. I have ...
1
vote
0answers
45 views

When to discretize nonlinear Poisson Equation

I am trying to solve a nonlinear poisson equation of the form: $u_{xx} + f(u_y)u_{yy} = 0$. In trying to get a handle on this problem, it seems like there are two approaches. I could either ...
4
votes
2answers
113 views

Kronecker product representation of the finite difference laplacian

The laplacian equation when discretized gives a system of linear equations that can then be solved. See the answer to this question: https://math.stackexchange.com/questions/3120948/discretization-...
1
vote
1answer
76 views

Finite Difference libray C++

What is the best FD library (or collection of libraries) for C++ codes? I am looking for some data structure implementation that offers the possibility to do parallel computations on adaptively ...
1
vote
1answer
167 views

Order of accuracy for finite-difference on nonuniform grid

If we evaluate the first derivative of a function F(x) on a 1D grid {$x_i$} by central difference at $x=x_i$ as $$ \frac{dF}{dx} \approx \frac{F_{i+1} - F_{i-1}}{x_{i+1} -x_{i-1}} $$ then it is known ...
0
votes
1answer
65 views

FDM on nonlinear PDEs

I'm working with a 2D Navier Stokes PDE in the unstabilized version - the equation is a linear equation of the type $\frac{∂u}{∂t} = F(u,t)$. In order to perform time discretization with FDM (finite ...
1
vote
0answers
21 views

Convection equation expanded in Legendre polynomials

In some areas of physics, for example radiation transport in plasmas, it is beneficial to re-express the convection equation in terms of a Legendre polynomial expansion. This results in a set of ...
0
votes
1answer
30 views

Norm of operator in finite element discretization of Heat equation

I am solving the heat equation discretized spatially via FEM and temporally via backward Euler. I get the system $$M \dot{u} = K u +f$$ where $u$ is a vector representing the solution at spatial ...
11
votes
8answers
5k views

What programming language should I choose and why?

I am a mechanical engineer, intermediated/advanced level in MATLAB and MATHEMATICA, and beginner in Python. I intend to get a PhD in aeroelasticity (FEM + CFD) and coding my own program. I intend to ...
2
votes
0answers
40 views

How does the “Stable Fluids” algorithm by Jos Stam relate to the SIMPLE and PISO algorithms?

The "Stable Fluids" paper (*) by Jos Stam starts by acknowledging that "Our method cannot be found in the computational fluids literature, since it is custom made for computer graphics applications. ...
1
vote
0answers
26 views

von Neumann analysis: computation of maximum value of amplification factor

In this question I adress the stability property of a numerical scheme (a FDM described below) to the problem $$ \begin{align} u_{t} &= \alpha u_{xx}+\beta u_{xxxx}, & &x\in\mathbb{R},\;t&...
1
vote
1answer
83 views

Efficient Arbitrary Order Finite Differences in 1D

I am implementing on Matlab a high-order finite differences scheme to approximate the first derivative of $f(x_i)$ given $x = [x(1), x(2),..., x(i),..., x(n)]$ and $f = [f(x(1)),..,f(x(n))]$ with $x$ ...
2
votes
3answers
159 views

How is central difference scheme second-order accurate?

In an arbitrarily unstructured mesh, shown in the figure below, in the context of finite volume method, I want to obtain an approximation of $\phi_f$, where $N$ and $P$ are cell centers of adjacent ...
2
votes
0answers
42 views

How to determine the finite difference coefficient matrix in 2D with periodic BC?

I'm solving a PDE in matlab using ode15s, and since the spatial dimension is 2, and number of variables grow large very quickly, I need to supply the structure of ...
2
votes
1answer
76 views

Crank-Nicholson scheme for transport equation

This is my attempt to find the approximate solution of the folowing transport equation $$\left\{\begin{array}{ll} \partial_{t} u+\partial_{x} u= (x^2-x)t+x^3/3-x^2/2, & t \in(0,0.4), x \in(0,1) \\ ...
0
votes
1answer
119 views

Time complexity of numerical finite differences

I have a function $f:\mathbb R^N\to \mathbb R$ and I would like to compute all the partial derivatives of $f$ w.r.t. the $N$ input. What is the computational complexity using the (ones-sided) finite ...
1
vote
2answers
52 views

What space-time points should a known coefficient function be evaluated at when using the Lax-Friedrichs scheme to solve the transport equation?

For a scalar quantity $u = u(x, t)$, I'm considering the transport equation \begin{align} u_t + au_x &= 0, \qquad{x\in[0, L], \ t\in[0, T]} \\ u(0, t) &= u_{\text{in}}, \\ u(x, 0) &= f(x). ...
3
votes
0answers
45 views

Spectral solver on em-pic

I'm recently studying for the spectral solver to implement EM-PIC code. I read an article and have some questions. Many PIC codes uses spectral solver to overcome numerical artifacts on FDTD. In the ...
1
vote
1answer
80 views

What is the maximum attainable accuracy with a given set of $\alpha,\beta$?

I am using LeVeque's book: https://faculty.washington.edu/rjl/fdmbook/ Suppose I want to compute $u''$ using FDM with $\alpha=\beta=2$ (centered) so the FDM is $$ u''=\sum_{m = - \alpha}^\beta a_mu(...
2
votes
0answers
32 views

Convergent Finite Difference Scheme for Parabolic Equation

Consider the PDE $$u_t = b_{11}u_{xx} + 2b_{12}u_{xy} + b_{22}u_{yy},$$ where $b_{11}, b_{22} > 0$, and $b_{12}^2 < b_1b_2$. In Strikwerda's book, the ADI scehme \begin{align*} \left( 1 - \frac{...
1
vote
1answer
56 views

Solving the pulse propagation using four different FDTD methods gives four different results - Which to trust?

I'd like to simulate the propagation of a pulse, and have different options for solving that. On the one hand, I can use the non-linear schrödinger equation $$\partial_zE=\frac{i}{2k_0}\nabla^2_\perp ...
0
votes
1answer
126 views

Simple Harmonic Motion using the leapfrog method

I have to use the leapfrog method to solve the simple harmonic oscillator and I having trouble writing it in code. This is what we were given in class $$ \frac{v_{n+1/2}-v_{n-1/2}}{\Delta t}=-\omega_0^...
2
votes
0answers
53 views

Numerical errors due to terms of the form $\frac{1}{r}$ (r goes to 0 at the boundary) while using finite difference method

I am trying to solve a system of differential equations using finite difference method. There are few terms of the form $\frac{A(r)}{r}$, both $A(r)$ and r go to zero at the boundary. Analytically ...
1
vote
0answers
63 views

Are linear, CTCS codes always stable?

I would like to solve some equations which basically look like this $$\frac{\partial u}{\partial x}=F\left(v,\frac{\partial v}{\partial y},\frac{\partial^2 v}{\partial y^2}\right),$$ $$\frac{\partial ...
0
votes
1answer
59 views

Solve convection-diffusion equation with a non-linear source term

I would like to solve this equation (which is adapted in my case, a plug flow reactor when a reaction occurs): $ \frac{df}{dt} = D \frac{d²f}{dz²} - u \frac{df}{dz} + r(z,t) $ with $r(z,t)= - k f^{n}...
2
votes
1answer
192 views

Order of Accuracy Measurements on 1D Advection Methods

I am trying to learn about basics of computational fluid dynamics, at the moment on the simple example of linear advection in 1D. I am am currently testing the theoretical predictions of the order of ...
0
votes
1answer
30 views

Truncation error plot with weird issue

I have a function f(x) = sin(x)/x^3 whose first derivative I am trying to estimate using 1st, 2nd and 4th order Finite Difference schemes. I tried to plot the ...

1
2 3 4 5
14