People who code: we want your input. Take the Survey

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
-1
votes
0answers
17 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 ...
3
votes
0answers
45 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 ...
0
votes
0answers
30 views

Upper bound for function involving exponential function [closed]

Prove:$$(1+|\xi|)^{2\rho}\exp(-a\xi^2t)\leq Constant(\rho,a)(1+t^{-1/2})^{2\rho}$$, where $$-\infty<\xi<\infty,a>0,t>0,\rho>0.$$ Many thanks!
3
votes
1answer
86 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
32 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
2answers
123 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 ...
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
vote
2answers
169 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 ...
1
vote
2answers
85 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
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
21 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
43 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
44 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}{...
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
72 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(\...
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
1answer
101 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
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)...
0
votes
1answer
60 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
17 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
58 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 ...
1
vote
0answers
38 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
0answers
67 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-\...
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
42 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 ...
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 ...
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
105 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, ...
0
votes
1answer
87 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 ...
0
votes
0answers
102 views

“This DAE appears to be of index greater than 1” daeic12 (line76) error code

Hi I am trying to solve a set of pde converted into ODE and DAE using central finite difference method. I have used the MATLAB 'solve' command to determine the coefficients of fictitious nodes for ...
0
votes
1answer
86 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, ...
0
votes
1answer
69 views

Technique to find the CFL condition using the Galerkin method in space and finite-difference in time?

I am using the Galerkin method (Discontinuous to be precise) to discretize in space the scalar linear wave equation and the explicit second order centered finite difference scheme to discretize in ...
4
votes
1answer
122 views

Backwards Difference Implicit Method for Nonlinear Parabolic PDE in Python

Original Stack Overflow Question: https://stackoverflow.com/questions/65683788/indexerror-index-31-is-out-of-bounds-for-axis-1-with-size-31?noredirect=1#comment116218335_65683788 PDE: u_t = u_xx + u(...
1
vote
0answers
46 views

Integrating a wavelike equation with absorbing boundary conditions

I am trying to numerically solve the following equation: $\frac{\partial^{2} \phi}{\partial t^{2}}-\frac{\partial^{2} \phi}{\partial x^{2}}+V(x) \phi(x, t)=0$ On some domain, with: $\phi(x, 0) = I(x)$ ...
7
votes
1answer
153 views

Which finite difference better approximates $uu'$?

I want to approximate $uu'$ with a finite difference. On the one hand, it seems to be $$(uu')_i=u_i\frac{u_{i+1}-u_{i-1}}{2\Delta t}=\frac{u_iu_{i+1}-u_iu_{i-1}}{2\Delta t}$$ On the other hand, $$(uu')...
-1
votes
1answer
74 views

Numerical solution of the advection equation with Crank–Nicolson finite difference method

I need to implement a numerical scheme for the solution of the one-dimensional advection equation $$\\\frac{\partial u}{\partial t} + C(x, t) \frac{\partial u}{\partial x} = 0 \\\\$$ $$ \\ C(x,t) = \...
0
votes
0answers
38 views

Devising Convergent Numerical Scheme for PDE

I'm currently looking at the PDE \begin{align*} u_t + \left[x(1-y) - (1-x)\right]u_x - (1-y) u_y + (z-xy) u_z = (z-xy) u_{xy} - (1-x)u& \\ \end{align*} with \begin{align*} u(x,y,z,0) = 1& \\ ...
2
votes
1answer
65 views

Fix for FD WENO method for multi-component compressible flows

I'm solving two-dimensional four-component compressible Navier-Stokes equations with finite-difference WENO approach. The equations are pretty standard: $$ \frac{\partial U}{\partial t} + \frac{\...
0
votes
0answers
64 views

How to make a directed graph symmetric?

Say I have a directed graph given as an adjacency matrix $A$ in CSR format represented by the arrays ia (row indexes) and ja (...
1
vote
2answers
142 views

How to apply central difference to viscous fluxes in 2D Navier-Stokes equations?

I'm trying to solve 2D unsteady compressible Navier-Stokes equations with finite-difference or finite-volume method. Here is the system, it's pretty standard: $$ \frac{\partial U}{\partial t} + \frac{...
1
vote
1answer
79 views

Finite Difference for Advection Equation With Source

I'm trying to find a convergent finite difference scheme for the PDE \begin{equation} \begin{split} u_t + (x-1) u_x &= (x-1)u, \hspace{.5cm} x \in [0,1] \\ u(x,0) &= 1 \\ u(1,t) &= 1. \\ \...

1
2 3 4 5
15