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
0
votes
0answers
30 views

Solving a system of nonlinear ODE error [closed]

I find out that when I'm trying to solve a system of nonlinear 2nd order ODE numerically with NDSolve with that code: ...
14
votes
1answer
257 views

Stable fluids code for electromagnetic mixture application

This code has been translated from the original Jos Stam code and improved with some Mathematica functions. It solves problem of viscous incompressible flow with electromagnetic force in a rectangle ...
1
vote
0answers
38 views

Defining general recurrence expression and extracting coefficient

I'm new to Mathematica and I wish to solve a difference equation which is defined by the relation: $y_{i-1}-2y_{i} +y_{i+1} = f(x_i,y_i),\\y_0 = a, y_n = b.$. Where $x_i$ is given for all $i$. I want ...
0
votes
1answer
76 views

How to calculate fractional differences of a timeseries?

I have a timeseries I am looking to transform with fractional differences per the following description: The idea being to retain the essence of stationarity of, say, a log transformed integer series ...
1
vote
1answer
100 views

Solving the Stefan Problem with WhenEvent

The formulation of the problem: I tried to solve it with MOL and the method of V.R. Voller: The script: ...
0
votes
1answer
76 views

Solving System of Equations

I want to solve a huge system of equations which is generated using the Finite-Difference-Method. The Problem with that system is that it is badly conditioned and so ...
6
votes
3answers
502 views

Time dependent Schrödinger equation in 2D

I have the following Schrödinger equation in $2D$: \begin{cases} \partial_t \Psi(x,t) = V(x,t) \Psi(x,t) \quad x \in [-10,10]^2\\ \Psi(x,0)=\exp( \frac{1}{2} (-x^2+y^2)) \end{cases} where the ...
5
votes
2answers
209 views

NonLinear system for chemotaxis

I want to solve the chemotaxis mode, given by the next non-linear system: It is taken from Murray's book: equation (11.30) at pag. 408 $$\frac{\partial n}{\partial t} = D \frac{\partial^2 n}{\partial ...
2
votes
1answer
99 views

Solving the PDE $\partial_t u = \partial_x (u^2 \partial_xu)$

I'm trying to use Mathematica to solve the following equation $$\partial_t u = \partial_x (u^2 \partial_xu)$$ with $$u(0,t)=u(1,t)=0$$ and $$u_0(x)=\sin(\pi x)$$ in order to check a numerical method I ...
0
votes
0answers
44 views

ItoProcess with WhiteNoiseProcess

Is there a way to use ItoProcess with a white noise process, instead of the usual WienerProcess? If I just naively use ...
2
votes
2answers
184 views

How to solve Nonlinear coupled ODEs using DSolve

I cannot solve such a system of coupled ODEs in MMA 12.1 using DSolve. i.e. output is equal to the input equations ... (see the attached figure) Here, each solution is labeled according to the name of ...
5
votes
1answer
206 views

1-D PDE with nonlinear ODE as boundary condition

Recently, I am trying to solve a 1-D PDE with a nonlinear boundary condition using the function NDSolveValue. However, it seems that MMA (12) cannot solve it directly with some computational issues. ...
3
votes
0answers
229 views

Problem computing a cylindrical Heat equation with a parameter alpha

i have been struggling to compute a particular instance of cylindrical 3D heat equation. Here is my code : ...
1
vote
2answers
489 views

Finite difference method for 1D wave equation

I want to solve the following 1D wave equation: utt = uxx with t > 0, 0 <= x <= 5 and ...
1
vote
1answer
343 views

Finite difference method for 1D heat equation

I have solve the following 1D heat equation: ut=uxx, t>0,0<=x<=5, with ic=u(x,0)=x^2, and bcs:u(0,t)=2t;u(5,t)=2t+25: ...
0
votes
0answers
135 views

Problem with definition of boundary problem

My procedure for solving coupled 1 + 1 (spatial + temporal) PDE system: (Note: I have graphs of the correct solution with which I compare my result. See figure below text.) 1) I determine the ...
1
vote
1answer
520 views

Finite difference method for 1D Poisson equation with mixed boundary conditions [duplicate]

I have solved the following 1D Poisson equation using finite difference method: u'' = 6 x; u'(0) = 0; u(1) = 1; where h = 1/3; i.e., I found u(0), u(1/3) and u(...
5
votes
2answers
279 views

Finite difference method for 1D Poisson equation

I want to solve the following 1D Poisson equation using finite difference method: $$u'' = 6 x,\ u' (0) = 0,\ u (1) = 1$$ where $h=1/3$ i.e I need to find $u(0)$, $u(1/3)$ and $u(2/3)$. I construct ...
1
vote
1answer
129 views

Symbolic solution of an iterative system

I am not an expert in Mathematica. I want to keep off from tedious calculation I want to solve (in symbolic sens) this system: $\quad AU^{j+1}+BU^{j}=F^{j}$ where: $*$ ${U}^{j}$ a $(N;1)$ vector $\...
2
votes
1answer
175 views

Error in the solution of PDE with NDsolve and method of lines [closed]

I am trying to solve a system of the partial differential equation with the help of NDSolve and method of lines. Mathematica code for the above-described problem is ...
8
votes
1answer
254 views

Nonlinear elasticity PDE in Mathematica 12

Mathematica 12, Windows 10. I am trying to solve a PDE in one spatial dimension $R$ and time $t$. I need a solution for displacement $r(R,t)$, radial Cauchy stress $T_{RR}(R,t)$, and radial growth $\...
1
vote
2answers
101 views

Testing the accuracy of numerically computed derivatives

I am calculating approximate derivatives by using NDSolve`FiniteDifferenceDerivative, so this works: ...
1
vote
0answers
83 views

Noisy numerical finite difference calculated by NDSolve`FiniteDifferenceDerivative [closed]

I met a problem when playing with the numerical difference provided by mathematica. My aim is to test the accuracy of the high-order numerical derivative. The code is below ...
1
vote
1answer
65 views

Elimination of numerical error in initial data

Elimination of numerical error in initial data can be crucial for its subsequent evolution. In the following simple example ...
4
votes
1answer
98 views

TemporalDiscretization in MethodOfLines

When solving ODE's one can use options like MaxStepFraction to control the number of grid points. When solving PDE's ...
0
votes
1answer
151 views

PDE-DirichletCondition needs to be linear

I am trying to solve the following multi-field problem in MMA 12, however, this probelm cannot be solved, i.e., error: DirichletCondition [...] needs to be linear. I attached the code here: <...
2
votes
1answer
229 views

Solving multi-field problems in MMA 11.3

Based on the PDE model proposed by @Schumacher Solving a second order coupled PDE system, the one dimensional multi-field Problem I would like to solve such benchmark test: namely: u(x): ...
1
vote
1answer
206 views

Solving IDE system using FDM based on NDSolve`FiniteDifferenceDerivative

I wanted to solve the following system of integro-differential equations (IDEs) using finite difference method (FDM). $y_1''(t)+t^2y_1(t)-y_2''(t)+\int\limits_0^t[(t-x)y_1(x)+y_2(x)]\mathrm{d}x=(2+t^...
1
vote
1answer
97 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
76 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): ...
19
votes
3answers
524 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(1)=...
6
votes
2answers
294 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 ...
4
votes
1answer
437 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
507 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....
6
votes
2answers
747 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
395 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
307 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
119 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
216 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 $ ...
10
votes
1answer
608 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
232 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
396 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
734 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
174 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
296 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
104 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 ...
5
votes
1answer
757 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
398 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, ...
2
votes
0answers
921 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 ...