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
3
votes
4answers
1k 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 ...
0
votes
2answers
91 views

Continuation of solution to $-\nabla\cdot (k(x,y)\nabla u)=f$

I'm trying to solve the following problem, I had previously opened another discussion for the implementation and well, it seems that it has turned out well, it can be found here. I need to calculate ...
2
votes
1answer
235 views

Is there a simple way to avoid carbuncles for FD WENO methods?

I have implemented finite-difference WENO scheme for Euler equations (with some variants - WENO-JS, WENO-Z, WENO-M, different flux splitting). It works well, but have problem with so-called carbuncles ...
3
votes
1answer
90 views

How to find the optimum finite difference method for derivatives?

Related to: What are the negatives of using higher order finite diference schemes? Problem: I have some discrete data of a trajectory $x_t$ with errors $\delta x_t$ of a physical system sampled at ...
-1
votes
0answers
25 views

second order finite function for 2D function in Python

My task is to Implement the derivative with the 2nd order finite difference for 2D functions. Evaluate the accuracy of the numerical derivatives of J(x,y) at the point (x = 5, y = −2) by determining ...
0
votes
2answers
207 views

Implementing routine for $-\nabla\cdot (k(x,y) \nabla u)=f$ in Matlab

I am solving the Poisson Equation for 2D given by the following expression: $$-\nabla\cdot (k(x,y) \nabla u)=f$$ in a rectangle with Dirichlet conditions on the boundary using Matlab. In principle I ...
3
votes
0answers
50 views

Solving PDEs: What is the best way to deal with non-banded/dense jacobians?

I have a system of PDEs describing atmospheric chemistry and transport. I use finite-differences to make my system of PDEs into a system of ~10,000 ODEs. I then integrate the ODEs forward in time with ...
3
votes
1answer
87 views

Calculating the Jacobian for a function containing a derivative

I have the equation $F(t) = \phi u + \frac{1}{2}\frac{d^2u}{dt^2} + u^3$ and broadly speaking, my task is to calculate the $\phi$ and $u(t)$ such that $F(t) = 0$. I am testing out a new algorithm to ...
0
votes
0answers
33 views

Expression for numerical amplification factor for Euler time integration and CD2 scheme for one degree hyperbolic function

This is the expression to be derived but I am not getting the exact expression as given in the image. Is the given expression given for the implicit Euler method? Here $N_c = c (\delta t)/h$ and $\tan(...
0
votes
1answer
88 views

Implementing Dirichlet BC for the Advection-Diffusion equation using a second-order Upwind Scheme finite difference discretization

i am implementing a Matlab code to solve the following equation numerically : $$ (\frac{\partial c}{\partial t} =-D_{e} \frac{\partial^2 c}{\partial z^2} +U_{z}\frac{\partial c}{\partial z}) $$ with ...
1
vote
2answers
86 views

Stability condition FCTS method

The FTCS method comes from the discretization of a diffusion PDE like this: $$ a^{2} \frac{u_{i+1}^{k}-2 u_{i}^{k}+u_{i-1}^{k}}{\Delta x^{2}}=\frac{u_{i}^{k+1}-u_{i}^{k}}{\Delta t} $$ If I have the ...
1
vote
2answers
171 views

why is complex step differentation better than central differences

I came across this post at Cleve's Corner, where he shows that complex step differentiation is more accurate than central differences. The error in both methods is $O(h^2)$. So why exactly does ...
0
votes
0answers
21 views

Why does this Non-Standard FDTD implementation lead to infinite increase in the magnitude of an EM pulse?

I have been working on a Particle-In-Cell Framework in Python and have noticed an issue where the magnitude of a EM pulse increasing infinitely as the simulation updates. Currently, I am using the Non-...
-1
votes
1answer
55 views

Howo to implement complex step derivative for complex functions?

I have a complex analytic function of which I want to take the numerical derivative. \begin{align} f(z) &\equiv f(x,y) = u(x,y) + i v(x,y) \\ \frac{d f(z)}{d z} & = \lim_{h \to 0} \frac{f(z + ...
0
votes
2answers
81 views

Stability of the Forward-Time Central Space method, section 9.3 in LeVeque

I am reading section 9.3 in Leveque about stability. The explanations are very short and brief so I am asking for some help to understand and elaborations. The result of the section is that for FTCS ...
2
votes
1answer
126 views

How to discretize a non-linear PDE with boundary conditions and intial value

Consider this non linear PDE: $$u_t + c(u^2)_x =\alpha u_{xx} \text{ , } -1<x<1 , t>0 $$ with $$u(-1,t) = g_L(t) \text{ , } u(1,t) = g_R(t) \text{ and } u(x,0)=f(x) $$ where the 3 functions(...
0
votes
0answers
22 views

Reynolds boundary conditions

I came across this paper comparing various boundary conditions. I am particularly interested to understand how to obtain the Reynolds boundary conditions (refer to equation 28). $$\left( \frac{1}{c} \...
2
votes
1answer
45 views

How to demonstrate the order of convergence of FTBS method for solving a hyperbolic PDE

consider the Purely hyperbolic model problem $$u_t+au_x=0$$ $$u(-1,t)=u(1,t) \text{ (periodic boundary)}$$ $$u(x,0)=f(x)$$ with $f(y)=\sin(2\pi y)$. Furthermore the exact solution is given by $u(x,t)=...
2
votes
1answer
59 views

Solving the 2D Rectangular Waveguide PDE with a Neumann boundary condition for TE modes

I am trying to find the possible modes of a 2d rectangular waveguide by solving the equation, $$\Big(\frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} + \gamma^2 \Big)\psi = 0$$ where $...
1
vote
0answers
46 views

Why is this Advection-convection model with insulating boundary losing mass?

I am trying to model a 1-d advection-convection numerically, using an upwind scheme. I'm using the following equation to calculate the value of internal cells: $$C_x^{t+1} = C_x^{t} + D\frac{\Delta t}{...
2
votes
1answer
257 views

Minimal surface finite differences problem - Matlab assemble

I face to the following problem: $$(1+u_x^2)u_{yy} - 2u_xu_yu_{xy} + (1+u_y^2)u_{xx}=0.$$ Problem needs to be discretized and assembled. Does anybody know how to proceed in Matlab?
1
vote
0answers
45 views

Comparison between stability and accuracy of various Finite Difference schemes

I`m Analyzing the 1D convection equation (PDE) for stability, consistency, and accuracy. I know Both upwind schemes (explicit and implicit) show better stability with a higher number of waves for ...
4
votes
0answers
74 views

Stability of Crank-Nicholson for advection diffusion equation for spatial discretization other than finite differences second-order centered

Crank Nicholson is a time discretization method (see 4th equation here). From what I see around, you can use different space discretization, such as Finite elements. But for the linear advection-...
-3
votes
1answer
75 views

How to avoid negative concentration from numerical solution using FDM scheme?

$\frac{\partial C}{\partial t} + u \frac{\partial C}{\partial x} + w \frac{\partial C}{\partial x} = D \left(\frac{\partial^2C}{\partial x^2}+\frac{\partial^2C}{\partial y^2}\right)-C \cdot \left(\...
0
votes
1answer
571 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 ...
1
vote
0answers
51 views

Stability plot of upward difference implicit time

I am analyzing the stability of 1D convection (advection) equation as shown in the picture. When I derive the equations as shown I want to get rid of the complex number. I`m asking if those stability ...
0
votes
0answers
67 views

Pressure boundary conditions in Stokes Equation in 2D

I am solving the steady-state incompressible Stokes equations in 2D: \begin{equation} \frac{\partial u_x}{\partial x} + \frac{\partial u_y}{\partial y} = 0, \end{equation} \begin{equation} \mu\left[\...
0
votes
1answer
102 views

Discretization of a non-linear ODE using FDM isn't grid indepenent

I am trying to solve the ODE : $\frac{d^2T}{dx^2} = \omega_1 T+\omega_2 T^2$ + using different numerical methods. I have tried the following discretizations so far and none of them seem to be grid ...
1
vote
1answer
348 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(...
1
vote
0answers
37 views

discretization of advection diffusion with variable coefficients

I am looking for help to find a somewhat stable FD numerical scheme for the advection diffusion equation posed on a curve $(x(r),y(r))$. The equation becomes $$u_t=\alpha(r) u_r +\beta(r) u_{rr}+f(r,t)...
1
vote
1answer
135 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(...
0
votes
1answer
61 views

High Running Time and Suboptimal Accuracy of 2D Wave Equation Solver with Finite Differences

Im trying to solve the following 2D wave equation: $$u_{tt} = u_{xx} + u_{yy}, \hspace{3mm} u(x,y,0) = \cos(4 \pi x) \sin(4 \pi y), \hspace{3mm} u_t(x,y,0) = 0$$ with the periodic boundary condition ...
0
votes
0answers
18 views

(FD WENO) Correct symmetry boundary condition for Euler equations

I'm trying to solve 2D Euler equations in axisymmetric formulation with finite-difference WENO scheme. I found some info on high-order boundary conditions for plane formulation (in this thesis, for ...
0
votes
1answer
59 views

2 point BVP solver: how to compute errors

Background I am working with chapter 2 in LeVeque's book: https://faculty.washington.edu/rjl/fdmbook/ I have build my own solver in Python to solve the 2 point BVP: $$ \epsilon u''+u(u'-1) =0 , \\ u(0)...
0
votes
1answer
107 views

Trouble Implementing 1d Wave Equation Finite Difference Solver

Im trying to solve the 1d Wave Equation on $x \in \mathbb{R}, t > 0$: $$u_{tt} = c^2u_{xx}, \hspace{5mm} u(x,0) = \cos(4 \pi x), \hspace{5mm} u_t(x,0) = 0$$ with $c = 1$ and a periodic boundary ...
2
votes
0answers
61 views

Divergence on wave equation simulation

I'm currenly working on my own PDE solver for non-linear simulations in python. I've done succesfully simulations for KdV and Fisher's equation, but now I'm playing with second order derivatives in ...
0
votes
1answer
77 views

Incorporating heat flux into Laplace Equation

I need to find the temperature distribution of a square plate using the Laplace equation by using FDM: $$ \frac{d^2T}{dx^2} + \frac{d^2T}{dy^2} = 0$$ But there is a heat flux entering from the top ...
8
votes
1answer
9k views

Matlab solution for implicit finite difference heat equation with kinetic reactions

I am trying to model heat conduction within a wood cylinder using implicit finite difference methods. The general heat equation that I'm using for cylindrical and spherical shapes is: Where p is the ...
1
vote
0answers
39 views

Results blow up when number of intervals is increases (Yee algorithm FDTD, dielectric sphere)

I have been trying to write a program that analyses EM wave scattering by a dielectric sphere for a project. The reference is Sadiku's book Numerical Methods in electromagnetics Edition 3. Now the ...
2
votes
1answer
276 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]-\...
2
votes
0answers
68 views

Linearising Nonlinear Coupled Partial Differential Equations - Alfvénic Diffusion

I am trying to solve the following coupled partial differential equations with a finite difference scheme: $$\partial_tf+v\partial_zf+\partial_z\frac{1}{W}\partial_zf=0$$ $$\partial_tW+v\partial_zW-\...
3
votes
1answer
74 views

Maintain unitary time evolution for a nonlinear ODE

I want to solve a nonlinear ODE of matrix $A(t)$ $$\mathrm{i}\dot A = A(t)M(t),\:\mathrm{with}\: M(t)=A^\dagger(t)H(t)A(t)$$ where $H(t)$ and hence $M(t)$ are Hermitian. Therefore, I presume the time ...
2
votes
0answers
42 views

How to solve this boundary value problem which has more unknown than equation on MATLAB

I need your helps about solving the problem below with MATLAB. I am trying to solve 2D Stress Wave Propagation problem by using FDTD(Finite difference time domain) method on the cylindrical coord. I ...
0
votes
0answers
30 views

velocity in CFL condition

I am studying the evolution of the density and velocity field of a core in a molecular cloud in 1 D. I defined the radial grid (let us say x between 100 and 101) and the time grid. I am using the ...
0
votes
0answers
43 views

Numerical dispersion in FDTD

I was reading the book "Computational Electrodynamics: The FDTD method" by Taflove and Hagness, probably the most cited book when it comes to the FDTD method in Electromagnetics. In the ...
0
votes
0answers
89 views

Why does FDTD and FIT disregard Gauss's law?

This is a reformulation of a question I asked a couple of days ago. I'm posting it again because I believe the previous post was very unclear, I will probably delete the previous question. My question ...
0
votes
1answer
106 views

Verification of order of convergence of Implicit Euler Method to numerically solve Black-Scholes PDE

I'm trying to verify the order of convergence for implicit Euler method to numerically solve Black-Scholes PDE. Theory says that it should be $O(\Delta t + \Delta S^2).$ My code is working absolutely ...
0
votes
0answers
43 views

When to stop iterations in SOR solver for 3D Poisson equation

I'm writing a solver (in C) for 3D incompressible fluids, using the finite-differences method, and I'm finding a somewhat surprising behaviour: the solver provides "good-looking" solutions, ...
8
votes
2answers
8k views

Use of machine learning in computational fluid dynamics

Background: I have only built one working numeric solution to 2d Navier-Stokes, for a course. It was a solution for lid-driven cavity flow. The course, however, discussed a number of schemas for ...
0
votes
1answer
89 views

Compute 1st derivative with backward difference approximation in python

I am trying to write a function to compute 1st derivative with backward difference approximation. $ u'(x_i) = \frac{u(x_i) - u(x_i - \Delta_x)}{\Delta x} \equiv D_- u(x_i).$ And for the first point, ...

1
2 3 4 5
15