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
1 answer
69 views

A question related with $p$-Laplacian and conjugate gradient method

I have the following energy functional of $p$-Laplacian equation: $$ E(u) = \frac{1}{p} \int_{\Omega} |\nabla u|^p dx $$ for $2.8 \leq p \leq 5$. My goal is to minimize the energy functional by using ...
2 votes
0 answers
63 views

Poisson equation solution in a semiconductor structure

I am trying to solve the $\textbf{1-D}$ Poisson equation for a semiconductor structure at equilibrium (There is no external bias applied). $\textbf{Background}$ \begin{equation} \frac{d^2V}{dx^2} = -\...
  • 33
0 votes
1 answer
48 views

On solving a first order nonlinear differential equation

It all starts with this Cauchy problem: $$ \begin{cases} \sin(2x(t)) -\cos(3x'(t)) = x(t) + x'(t) \\ x(0) = 1 \\ \end{cases} \quad \quad \text{with} \; t \in [0,10]\,. $$ Not knowing which way to turn,...
  • 103
2 votes
2 answers
87 views

Solving 2D Poisson equation with nonhomogeneous boundary conditions (Dirichlet) and a source

I am a physicist who is fairly new to numerical analysis, currently, I am trying to simulate a non-linear paraxial equation, and part of my calculation involves solving a 2D Poisson equation with ...
0 votes
0 answers
38 views

Solving Laplace for Velocity Potential in Constricted Channel

I am trying to solve the 2D Laplace equation numerically to give the velocity potential of a fluid flowing in a channel with a constriction: $u_{xx}+u_{yy}=0$ There is a constriction in the channel at ...
2 votes
0 answers
64 views

Scipy.root not converging even when provided with initial guesses very close to solution

I've made a previous question here and also in SO wondering why only the fsolve solver converges for the simple one dimensional unsteady conduction problem $$ \frac{\partial T}{\partial t} = \alpha \...
  • 123
0 votes
2 answers
112 views

Why is this scipy.root code not converging?

I'm running a test problem to set up larger problems. Solving the simple unsteady heat equation via finite differences: $$ \frac{\partial T}{\partial t} = \alpha \frac{\partial^2T}{\partial x^2}$$ $\...
  • 123
1 vote
0 answers
44 views

How to include zero flux boundary conditions?

I am trying to solve the following differential equation in the domain of $\theta \in [0, 2 \pi]$ using finite differences scheme: For $0< \theta \leq \pi$ \begin{align} \rho_i^{n+1}=\rho_i^{n}+D\...
  • 111
1 vote
0 answers
50 views

A staggered grid for an eigenvalue problem (linear stability analysis)

I'm interested in extending the concept of a staggered grid (commonly used to solve the incompressible Navier-Stokes equations) to a linear stability analysis context. For example, we can consider ...
2 votes
1 answer
129 views

Computing numerical derivatives

I am trying to create a sweeping surface, for which I need the frenet frame of a curve. I am trying to compute this for arbitrary curves but for testing I am just using the parametric unit half circle....
  • 225
0 votes
0 answers
91 views

discrete definition of curl $ \nabla \times \vec{A}$ on a 3D grid?

I have the data for 3D vector field $\vec{A}$ (with components $\vec{A_1}$, $\vec{A_2}$ and $\vec{A_3}$) sampled on a 3D grid with integer indices i, j and k. Assuming that only the third component $\...
1 vote
1 answer
98 views

Discretization of Poisson's equation with 2d permittivity tensor

I have to discretize a generalized Poisson equation in 2D which is $$\nabla\cdot(\varepsilon \nabla \phi )=-\rho$$ My problem is that here $\varepsilon$ is $2\times2$ permittivity tensor where $$\...
0 votes
0 answers
70 views

2D wave equation is numerically unstable using Finite Difference Method

I'm working with simulating both the heat and wave equation in 2D in a Python code. When simulating the heat equation, I learned about the CFL which I used to get a numerical stable solution. I found ...
  • 101
1 vote
1 answer
110 views

Non-Uniform Grids: Approximation Quality: First Order Finite Difference vs. First Order Finite Volume

Consider the advection/transport equation in 1D with constant velocity $a(x) \equiv 1$ $$u_t(t,x) + u_x(t,x) = 0$$ on a, say, periodic domain. On uniform grids $$ \{x_i\}_{i = 1, \dots, N}, \quad x_{i ...
  • 829
4 votes
1 answer
105 views

unconditionally stable schemes better than conditionally stable ones in accuracy?

Let's consider two finite difference schemes for PDEs/ODEs. One is conditionally stable, the other is unconditionally stable. People always prefer unconditionally stable ones to conditionally stable ...
  • 207
2 votes
0 answers
61 views

Compact Finite Differences for the Heat Equation with Robin Boundary Conditions

I am trying to solve the Heat equation with Robin Boundary condition: $$ u_t(x,t) = u_{xx}(x,t), \\ u(x,0) = g(x), \\ u(0,t) + u_x(0,t) = h_0(t), \\ u(1,t) + u_x(1,t) = h_1(t)$$ for $ 0\leq x\leq1$ ...
  • 21
1 vote
1 answer
76 views

Simulating First Order Hyperbolic PDE with Finite Difference Scheme

I am trying to simulate a hyperbolic PDE with some control given by the following: $$u_t(x, t) = u_x(x, t) + \theta(x) u(0, t)$$ with boundary conditions: $$u(1, t) = U(t) = \int_0^1 k(1-y) u(y, t)dy$$...
0 votes
1 answer
69 views

Choice of grid generation for FDM discretisation methods

I'm currently revisiting some FDM schemes for convection-diffusion equations in 1D, 2D and 3D and getting up to speed with the industry-standard methods again. The application is derivatives pricing, ...
0 votes
1 answer
127 views

Nonlinear Robin boundary condition involving square root

If you have a nonlinear second-order boundary value problem where the domain of the problem is $x \in [a,b]$, the boundary conditions imposed are the Robins condition at $x=a$ and the Dirichlet ...
1 vote
0 answers
99 views

Solving PDE on a non-uniform grid with Crank-Nicolson scheme

I am solving a 1D diffusion-type equation with the finite-difference Crank-Nicolson (CN) scheme, and I need to densify the spatial grid around the central point. One could change the spatial variable ...
1 vote
0 answers
60 views

Finite-difference produces a derivative off by one order

I have a nonlinear 2nd order boundary value differential equation where I used finite-difference method (central finite-difference) to solve it. $$z''(x)-\frac{\frac{1}{100} z(x)^4 \left(2 z'(x)^2+12\...
0 votes
0 answers
79 views

Best approach to solve this system of equations?

I have the following 1D (in space, that is) system of equations I would like to solve: \begin{equation} \rho_{fs}\frac{\partial x_{fs}}{\partial t} = h_m\left(W_a - W_{fs}\right) - D_{eff}\left(\...
  • 9
1 vote
2 answers
114 views

Calculate the derivative of the finite-difference method result

I have a nonlinear boundary ODE, $$y'' + 3 y y' = 0, \qquad y(0) = 0, y(2)=1 $$ I want to solve this using the finite-difference method. I obtained the result for the data set of $y(x)$ (including the ...
0 votes
0 answers
90 views

Solving compressible euler equations in non-conservative form

I am trying to solve the following compressible 1D system of equations in two non-conservative form PDEs for $\rho, Y$ and one ODE for $v$ \begin{align} \rho_t+(v+Q)\rho_x &= -\rho q(Y,T,\rho)-...
  • 11
1 vote
1 answer
65 views

blown up solution for linear advection in upwind method with finite difference

I am going to solve this advection equation regarding the flow simulation of an energy tower \begin{equation} Y_t+ v(t) Y_x =0 \end{equation} with the following boundary conditions which depend on ...
  • 11
0 votes
2 answers
106 views

Practical implementation of the discrete compatibility condtion

I've recently started looking into writing a finite-differences-based solver for the Poisson equation of the form $$\nabla\left(\varepsilon\nabla\varphi\right)=\rho$$ in 2D for arbitrary geometries (...
  • 53
0 votes
0 answers
57 views

Can I use MOL to solve 2D steady state PDE in terms of r and z spatial coordinates?

recently I need to solve a 2D steady state PDE equation. It’s not time dependent, and the only two independent variables are z and r direction. So far for this solution, I was thinking using Method ...
2 votes
2 answers
114 views

Poisson equation with discontinuous variable coefficient

Trying to solve numerically the 2D Poisson equation with variable diffusion coefficient $K$, that in general can be discontinuous. $$ \frac{\partial}{\partial x} ( K(x,y)\frac{\partial C}{\partial x}) ...
  • 435
0 votes
1 answer
108 views

How to correctly plot Order of accuracy for different finite difference schemes

I have implemented Upwind, Lax, Lax-Wendroff, Leapfrog and macCormak method for the linear advection equation with Dirichlet boundary conditions. I am trying to create the order of accuracy plots for ...
  • 1
3 votes
0 answers
113 views

Simplest way to "monotonize" MacCromack method

The MacCormack finite-difference "predictor-corrector" method is well known to generate spurious oscillations near solution discontinuities such as shock waves in gas dynamics equations. Or ...
  • 337
0 votes
0 answers
42 views

Unstable FDTD for axisymmetrical wave propagation

I am writing a 2.5D axisymmetric FDTD solver for Maxwell equations. It operates on three fields on staggered grids ($E_r$, $E_z$, $B_\varphi$). As a test problem, I am considering a cylindrical ...
3 votes
1 answer
130 views

ON the Kronecker product form of the laplacian matrix

It's well known that if we use 2nd order, centered, finite differences for the Laplace operator, we have that the matrix can be written as $$K=I \otimes A + A \otimes I $$ where $I$ is the identity ...
  • 211
1 vote
1 answer
164 views

Convergence stall when solving 2D Poisson PDE with pure Neumann boundaries (finite differences)

I recently started coding a small library of 2D PDE solvers (time dependent and time independent), and my first attempt was a 2D Poisson equation of the form: $$\nabla(\epsilon\nabla\varphi)=\nabla\...
  • 53
0 votes
0 answers
69 views

Solving a system of PDEs with an ODE

I want to solve the following system of equations which consists two PDEs and one ODE: \begin{align} \rho_t+v\rho_x &= 0; \newline Y_t+vY_x &= 0 ;\newline v_t &= -\frac{1}{(\...
0 votes
1 answer
157 views

What's Kane S. Yee who invented FDTD in Chinese?

I'm not sure if the question suits this section of StackExchange, but I think the chance to get the answer is highest here (compared with other forums). So I hope more tolerance could be shown towrad ...
  • 302
4 votes
1 answer
170 views

Does DCT diagonalize the FD discretisation of the Laplacian with Neumann boundary conditions?

If one has the Poisson problem (assume $\int_{\Omega} f = 0$ and $\int_{\Omega} u = 0$): \begin{alignat}{3} \Delta u(x) &= f(x), &\quad&x\in\Omega \\ \partial_nu(x) &= 0, &\quad&...
1 vote
1 answer
59 views

How to solve advective equation with source term depending on variable

I have the following equation $$ \dfrac{\partial s}{\partial t} + \nabla \cdot \left( \vec{v} s\right) = f(s) $$ Where $f(s)$ is an explicit source term that depends on $s$, e.g., ($\sin(s)\;cos(s)$). ...
4 votes
0 answers
83 views

Solving simplified 1D plasma fluid equations with finite difference

The following two equations represent a simple model of a plasma where ions are immobile. $$n\frac{\partial u}{\partial t}+nu\frac{\partial u}{\partial x}=n\frac{d\phi}{dx}-\theta\frac{\partial n}{\...
  • 141
2 votes
1 answer
680 views

How do you handle the singularity in polar or cylindrical coordinates?

Governing equations in polar or cylindrical coordinates often have terms with $\frac{1}{r}$ involved. At $r = 0$, such terms blow up to become a "singularity." The Cartesian version of such ...
  • 29
0 votes
1 answer
80 views

finding discretization error in Burger equation

I was reading the paper given in the link http://www.unige.ch/~hairer/preprints/parareal.pdf and I have a problem in understanding in page 10 for the Burger equation on implementing Parareal method ...
  • 41
4 votes
1 answer
163 views

How can I check mass conservation when solving the advection equation using an upwind scheme?

My question is how to keep track of the "mass" being advected out of a model domain, for the 1-D advection equation, and an upwind differencing scheme. Following is the background Consider ...
3 votes
0 answers
58 views

Dense factorization specialized for RBF-FD method

In RBF-FD methods (see Fornberg & Flyer. A Primer on Radial Basis Functions with Application to the Geosciences. SIAM, 2015. Chapter 5.), the finite-difference stencil coefficients for a set of ...
  • 342
0 votes
0 answers
51 views

How to define a stretched coordinate perfectly matched layer (PML) parameters for maximum absorbtion?

I have written a MATLAB code for solving Maxwell's equations (electromagnetic wave propagation) in 3D with perfectly matched layer (PML) boundaries. I am using a stretched coordinate PML, but I see ...
1 vote
0 answers
37 views

Calculating the species mass consumption from implicit reaction-term in diffusion-reaction equation

The 1D diffusion equation with a chemical source term has the following form: $$\frac{\partial Y}{\partial t} = D \frac{\partial^2 Y}{\partial x^2} - k Y,$$ where $Y$ is the molar concentration of the ...
1 vote
0 answers
31 views

How does Tannehill impose boundary conditions when coding the Parabolized Navier Stokes on an Implicit Finite Differences Scheme?

I'm trying to implement the scheme he describes on his book "Computational Fluid Mechanics and Heat Transfer" on Chap.9 and I'm having trouble imposing BC. I don’t get how he imposes them. I ...
  • 11
2 votes
1 answer
117 views

"A posteriori" estimates for finite difference methods

Suppose I have a PDE in a rectangular domain that I am solving numerically via a finite difference method. How do I answer the question, "How fine do I need to make the grid to so that my ...
  • 105
2 votes
1 answer
258 views

Numerical solution of 2D wave equation using Fourier transform and finite differences

This is the $2$-dimensional wave equation $$ u_{tt} = u_{xx} + u_{yy} $$ with initial condition $u(x,y,0)=f(x,y)$ and $u_{t}(x,y,0) = 0$. The inverse Fourier transform used is $$ u(x,y,t) = \iint \hat{...
1 vote
1 answer
222 views

A question on the Poisson equation with Neumann and periodic boundary conditions on a rectangular region

I am trying to solve the following PDE by using finite difference \begin{eqnarray*} \Delta u&=& f ~~on~~(0,1)\times(0,1)\\ \frac{\partial u}{\partial y}(x,0)&=&0=\frac{\partial u}{\...
1 vote
0 answers
149 views

Closed (Robin) boundaries in advection-diffusion equation with FDM

I am solving the equation $$ \frac{\partial \phi}{\partial t} = \frac{\partial}{\partial x} \left( D \frac{\partial \phi}{\partial x} + v\phi \right) $$ using finite differences. I want to include ...
1 vote
1 answer
113 views

constructing a symmetric matrix for finite difference

I come across the following operator in a paper $\mathcal{I}\psi = \psi_{xxxx} + (r~\psi_x)_x$, where $\psi=\psi(x)$ and $r=r(x)$. Periodic boundary condition is employed. It claims that the operator $...
  • 217

1
2 3 4 5
17