Questions tagged [finite-difference-method]

Tag for the usage of "FiniteDifference" Method embedded in NDSolve and implementation of finite difference method (fdm) in mathematica.

Filter by
Sorted by
Tagged with
3
votes
0answers
134 views

PDE with strange boundary conditions

What is the right way to solve the following equation from scratch under mathematica: $$\begin{aligned} u_t(t,x)-u_{xx}(t,x)&=f(t,x), &(t,x) &\in (0,1)\times (0,1),\\(u_t(t,x)-u_{x}(t,x))\...
1
vote
1answer
66 views

Solidification Problems in MMA

can we define such intial value and BCs for a solidification problem in MMA using Finite Element: 1.) initial value:=1 for a plate 2.) in this plate we have to define dirichlet bcs for a whole ...
1
vote
1answer
58 views

Random intial conditions using finite element method

How can we define the initial value for Cahn-Hilliard problem (links) using FEM in MMA? Complete test code (I am using MIXED formulation for C1 Problem): ...
18
votes
3answers
354 views

Generate coefficient array from general formula of linear equation system

This is a problem coming out in the implementation of finite difference method (FDM). Here is a toy example. Suppose we want to solve the boundary value problem (BVP) $$y''(x)=\sin(x),\ y(0)=0,\ y(...
5
votes
2answers
171 views

Solving linear coupled PDEs by FDM

I am trying to solve some linear, coupled PDEs for perturbative analysis (first order in time, 3rd order in space), for which I then plan to take the global spatial maxima of their magnitudes and plot ...
3
votes
1answer
216 views

Solution of Burgers equation with some initial data

Consider the Burgers equation $$\partial_t u + \partial_x\left(u^2/2 \right) = 0, \quad u(0, x) = u_0(x).$$ eq = D[u[t, x], t] + D[u[t,x]^2/2, x] == 0 How ...
8
votes
3answers
439 views

New things and limitations in Version 12 numerical differential equation solver?

This question is intended to be a place to summarize users' exemplary experience in solving differential equation with the NDSolve family in MMA’s latest version 12....
5
votes
2answers
384 views

Numerical methods to solve a continuity equation

What numerical methods can be used to study the initial value problem for the continuity equation where $ u = u(t, x) $ $$ u_t + \nabla\cdot(\boldsymbol b u) = 0, \qquad t \in [0,T], \quad x=(x_1,x_2)...
3
votes
2answers
265 views

NDSolve error in 2-D heat equation

I'm trying to solve the following PDE by Mathematica in 2-D case in the unit disk using polar cordinates, where $\Omega$ is a bounded domain of $\mathbb{R}^n$, $\Gamma =\partial \Omega$ is the ...
10
votes
1answer
209 views

FiniteElement v.s. TensorProductGrid: which is reliable for Schrödinger equation with periodic b.c.?

This is a problem comes up in the discussion under this post and I think it's worth starting a new question for it. I suspect the underlying issue is the same as in this post, but not sure. Consider ...
1
vote
1answer
88 views

Solution of differential equation and then draw a graph

I have two differential equations: $da/dt = a (.3 a^{-3} + .7)^{1/2}$ and $d \tau /dt = 1/a$. The initial conditions are $t = 0$; $a = 1$ and $\tau = 0$, respectively. How can I solve the ...
1
vote
1answer
141 views

How can solve this partial differential equation (PDE) and plot?

How can plot and solve this partial differential equation in mathematica? $$ K \frac{\partial^2 T}{\partial x^2}- h (T-T_m) = \frac{\partial T}{\partial t} $$ $ Tm = 25 $ $ k= 47 $ $ h= 1.5 $ ...
7
votes
1answer
302 views

Solve PDEs with finite difference scheme by modifying NDSolve-based solver

Motivation As discussed here, NDSolve uses different difference orders for various spatial derivatives and the implicit design could cause trouble in certain cases....
2
votes
1answer
157 views

Using NIntegrate in Finite Difference Derivative method

I'm trying to solve a second order differential equation using the code given by @xzczd here which is based on this. What this ...
9
votes
1answer
201 views

How to find the differentiation matrix based on FEM?

Assume that I have a non-equidistant grid of $n$ nodes, as follows: ClearAll["Global`*"]; n = 10; SeedRandom[123]; nx = Sort@RandomReal[{-1, 6}, n] If I want to ...
10
votes
2answers
529 views

Stiff BVP of nonlinear ODE, alternative/ enhancement to shooting method

Question: I have been trying to solve this coupled ODE set. \begin{align} ( \frac{ \mu^2}{B} +1 ) \Phi^2 + \frac{1}{A} {\Phi^{\prime 2}} + \frac{1}{2}\lambda \Phi^4 - \frac{A'}{r A^...
5
votes
1answer
137 views

How to control DifferenceOrder in NDEigenvalue for an ODE?

I am trying to solve the eigenvalue problem of a 1st-order ODE system using NDEigenvalue. It should be finite difference method for ODE. And I want to tune the the ...
2
votes
1answer
113 views

Oscillations on solution of finite difference equation

In a previous post on the solution of an ODE with a boundary conditon at infinty I had some excelent help from xzczd and am now returning with a further problem along the same lines. I have used the ...
1
vote
1answer
101 views

How to invert Differences[list, order] with order >1?

Differences order 1 can be invert using FoldList[], but does not work with higher orders. For Example ...
3
votes
1answer
414 views

Schemes for nonlinear advection equation

I am working in the traffic flow problem using the Lighthill-Whitham-Richards model together with the Greenshields equation. The equation of that model is this: $$ \frac{\partial\rho}{\partial t}+v_{...
3
votes
2answers
304 views

Why ODE's naive finite difference matrix works well for different boundary conditions

We know finite difference method (FDM) can replace $y''(x)$ as $\frac{1}{h^2}[y(x+h)+y(x-h)-2y(x)]$ or so. The naive way to write down the matrix of the differential operator is like the following, ...
0
votes
0answers
323 views

Derivative of list of points: DifferentiatorFilter versus DerivativeFilter

I need to calculate the derivative from a list of experimental points. Mathematica has two functions which seem to do this: DifferentiatorFilter and DerivativeFilter. Which one is better for ...
1
vote
0answers
66 views

Optimizing finding the offset diagonals for a 2D Finite Difference Method

It is possible to collapse a conventional 2D PDE (in our case the Schrödinger equation) into one dimension by having each set of points be taken as a one dimensional list of $n$ lattice points and the ...
2
votes
1answer
287 views

2D inhomogeneous biharmonic equation with wedged edge

I'm solving bending of rectangular plate while, boundary conditions are I have found similar problem solved: datavoreconsulting.com/programming-tips/numerically-solving-pdes-mathematica-finite-...
3
votes
0answers
406 views

NDSolve`FiniteDifferenceDerivative how does it work? [closed]

I'm referring to Paritosh Mokhasi's blog post, where he uses, along with some other things, the...let's call it a function (?)... NDSolve`FiniteDifferenceDerivative. I was able to use it exactly the ...
2
votes
0answers
192 views

Solving nonlinear diffusion equation by NDSolve

I have checked all issues regarding to solving nonlinear PDE numerically. I however try to solve following equation via NDSolve function and get some troubles. And this is my code for above-...
1
vote
2answers
152 views

NDSolve problem

I am trying to solve numerically this differential equation s := NDSolve[{y''[x] + ω[x]*y[x] - 1/(y[x])^3 == 0, y[0] == 1, y'[0] == 0.3}, y, {x, 0, 10}] where <...
1
vote
1answer
155 views

Eigenvalues of 3D Laplacian on a spherical segment

To study the change in Laplacian eigenvalues on a spherical segment, I constructed a table of spherical segments using the code from here. I discretized the output using ...
3
votes
0answers
120 views

Coupled parabolic differential equations with time delay

Is it possible for NDSolve to solve delay partial differential equations with simple Neumann boundary conditions? An example I have is as below: ...
5
votes
1answer
562 views

Heat equation with nonlinear boundary condition involving time-derivative

The governing equation is shown as follows: I first try to employ the NDSolve, but it seems that Mathematica can not handle the fourth boundary condition. ...
7
votes
3answers
303 views

What is the best way to track the gradient to a local minimum?

Given a function of multiple variables, and some initial conditions, I would like an efficient way to track the gradient to the local minimum of that function. Two options spring to mind — to either ...
0
votes
0answers
284 views

Poisson equation with numerical right hand side

I run into the following problem. Linear Poisson equation works OK, eg, ...
4
votes
1answer
283 views

Laplace equation in a gapped rectangular domain with finite difference method

I have a situation that is shown by this picture: For this situation I have this code. ...
7
votes
1answer
589 views

Free Convective Heat Transfer of Non-Newtonian Power Law Fluids from a Vertical Plate

I am trying to solve a set of PDEs mentioned in this paper with NDSolve but facing quite a few issues. The PDE system is: ...
2
votes
0answers
344 views

Robin conditions using Finite Difference [closed]

I'm trying to solve the drift-diffusion equation $$\frac{\partial\rho}{\partial t} = \frac{\partial^2 \rho}{\partial x^2} + \frac{\partial \rho}{\partial x} \rho(x,t)$$ using a finite difference ...
0
votes
1answer
215 views

Why do I get this nonsensical result for NDSolve with a delay-differential-algebraic system?

I have the following delay-differential-algebraic system: \begin{align} c(t) =& \kappa\min (1, \tfrac{\beta}{\alpha} a(t)), \tag{1a}\\ a(t) =& \left\{ \begin{array}{lcl} \frac{\alpha}{\...
0
votes
0answers
283 views

FDM - Fluid Flow tutorial

I was reading a very nice post: http://blog.wolfram.com/2013/07/09/using-mathematica-to-simulate-and-visualize-fluid-flow-in-a-box/ But i am stuck for hours at the point where the author writes: <...
1
vote
0answers
154 views

Solving lengthy higher order pde using finite difference

I am attempting to solve a very massive pde (latex expression given below). I have done some work with finite difference before for relatively simple equations (like heat diffusion or the wave ...
7
votes
2answers
508 views

Updating a parameter each time step within a Finite Difference scheme?

So I am solving a PDE for a function $h(\theta,t)$ via finite difference scheme. The PDE has a function $Q$ in it, which I wish to update each time step depending on where $h$ lies. Firstly, let us ...
14
votes
2answers
911 views

Finite difference method not converging to correct steady state or conserving area?

I am working with the following PDE, which is an advection-diffusion type equation. It describes the movement of a fluid-fluid interface inside an annulus of inner radius $R_1$ and outer $R_2$ under ...
1
vote
0answers
135 views

Speeding up solving nonlinear Schroedinger equation in 3D with NDSolve with periodic boundary conditions

I have a question on speeding up solving nonlinear Schroedinger equation in 3D with NDSolve with periodic boundary conditions. I build the ODE system with NDSolve...
5
votes
1answer
178 views

Kernel crashes when computing finite difference mixed derivative with respect to y & z but works fine when computing with respect to x & y or x & z?

Bug introduced in 8.0.4 or earlier, fixed in 11.0.0. I am using Mathematica 10.4.0 on Ubuntu 16.04. I am trying to solve a set of differential equations using finite difference method on an NxNxN ...
11
votes
1answer
512 views

NDSolve`FiniteDifferenceDerivative gives wrong result when the precision is not MachinePrecision

Bug introduced in 8 or earlier and persisting through 11.0.1 or later I want to get a pseudospectral differentiation matrix by NDSolve`FiniteDifferenceDerivative. ...
3
votes
1answer
307 views

Finite Difference - heat generation in a square (square within a square)

I am trying to develop a code that will allow me to solve the following problem. Lets say that I have a square block, inside that square block I have a smaller square box thats at a certain ...
2
votes
1answer
172 views

FiniteDifferenceDerivative of complex function in 2D--bug?

I want to compute partial derivatives of complex functions via finite difference approximation on two dimensional grid using NDsolve`FiniteDifferenceDerivative ...
1
vote
1answer
741 views

Partial differential equation, Finite difference Method

For my research project I am trying to solve following partial differential equation in Mathematica (V[r]*ψ[u, v])/4 + Derivative[1, 1][ψ][u, v] == 0 with ...
1
vote
0answers
349 views

How to derive finite-difference scheme automatically on a quite general stencil

Info This question is a generalization of the following one Derivation of numerical scheme for linear transport equation on a variable stencil. Statement of a problem Linear scalar hyperbolic (...
1
vote
1answer
199 views

Finite Difference equations - slow computations

The following code I have written runs very slow, in fact, so slow that it does not finish computation. ...
5
votes
1answer
644 views

How to vary finite difference approximation order in `NDSolve` at boundaries

According to here, NDSolve, when using the method of lines, creates partial derivatives in the spacial coordinate (lets talk just about one spacial coordinate for ...
1
vote
1answer
336 views

Poisson PDE in a rectangular domain

I found a solution for this problem, but this is in Scilab and I never use Scilab. Can anyone can help me to translate it in Mathematica? Here is the Link:http://imechanica.org/files/TorqueR.pdf I ...