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

Is it possible to solve a differential equation with a user-defined variable mesh in NDSolve?

For some differential equations, its solution may evolve to a cusp, for example, singular behavior. One may want to introduce additional mesh points near the cusp to accurately follow the solution ...
user avatar
0 votes
1 answer
102 views

Mathematica doesn't solve linear system of equations that emerges from finite difference method [closed]

I want to solve the ODE $$u''(x)+u(x)=e^{-x^2}$$ $$u(0)=u(10)=0$$ using finite difference method. I divide the interval $[0,10]$ uniformly by $x_i=0+ih$ using step size $h=\frac{10}{11}$. By ...
user avatar
2 votes
1 answer
77 views

Solving for Coefficients in a System of Linear Equations Using Mathematica

I'm currently using Matlab to solve a two-dimensional PDE in a rectangular domain using finite differences. Without going into too much detail (although I'd be happy to if necessary), I have the ...
user avatar
  • 199
18 votes
1 answer
348 views

3D stable fluids algorithm to simulate transition from laminar to turbulent flow

This algorithm is 3D extension of our 2D algorithm published on this page and here. We suppose that with this code we can simulate transition from laminar to turbulent flow. In this example we compute ...
user avatar
  • 33.8k
5 votes
2 answers
585 views

Numerical solutions of active 1D wave equations

I would like to solve the following PDE with finite difference method. The PDE is from the following paper, (https://arxiv.org/pdf/1911.11823.pdf). I would like to implement the algorithm for the left ...
user avatar
  • 61
2 votes
1 answer
140 views

Finite difference method for solving coupled differential equations

I am trying to solve the following coupled differential equations: $\dot{c}_{1}(t)=-\int_0^t \alpha_{1}(t,s)c_{1}(s)+\beta_{1}(t,s)c_{2}(s)\,ds-\frac{i}{\hbar}\lambda c_2(t)e^{+i(\omega_1-\omega_2) t}$...
user avatar
0 votes
0 answers
33 views

Mean error of finite differences derivative

I wrote a module that computes the 4-th order finite difference derivative of a function at $N$ equidistant points of an interval and the difference between the exact and numerical value at those ...
user avatar
  • 199
0 votes
0 answers
25 views

NDSolve SetDelayed error

I'm trying to calculate the first derivative of a function at a number of points using the 4-th order finite difference matrix, and then multiplying it with the function values at that point. I wrote ...
user avatar
  • 199
4 votes
1 answer
133 views

How to solve Coupled a Parabolic and Elliptic PDE in NDSolve?

I want to solve a mixed PDE Parabolic-Elliptic system in 3-dimension (rectangular coordinate), as shown below: The respective code version with parameters value, boundary and initial conditions is, <...
user avatar
  • 1,100
7 votes
2 answers
310 views

Finite difference method to solve coupled differential equations

I am trying to solve the following coupled differential equations: $\dot{c}_1(t)=-\int_0^tf(t-s)c_1(s)+g(t-s)c_2(s)ds$, $\dot{c}_2(t)=-\int_0^tg(t-s)c_1(s)+f(t-s)c_2(s)ds$, where $f(t-s)=\frac{\sqrt{2}...
user avatar
1 vote
0 answers
71 views

solving ordinary coupled differential equation

I have a set of 8 ordinary differential equations containing matrices which I need to solve using initial conditions. I have written the equations in this form: ...
user avatar
1 vote
1 answer
173 views

NonStandard finite difference for BMBB equation

I am trying to implement the following scheme mentioned in the paper "NUMERICAL SOLUTIONS OF BENJAMIN-BONA-MAHONY-BURGERS EQUATION VIA NONSTANDARD FINITE DIFFERENCE SCHEME " What is ...
user avatar
0 votes
1 answer
95 views

Method of lines in a single PDE

After solving this following PDE in NDSolve, now I have to use the method of lines to solve it and then compare the results. I was following the tutorial from Wolfram for Method of lines (https://...
user avatar
  • 5
18 votes
1 answer
446 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 ...
user avatar
  • 33.8k
1 vote
0 answers
54 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 ...
user avatar
2 votes
1 answer
269 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 ...
user avatar
  • 95
1 vote
1 answer
124 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: ...
user avatar
  • 58
1 vote
1 answer
98 views

Boundary condition do not satisfied

...
user avatar
0 votes
1 answer
238 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 ...
user avatar
  • 117
6 votes
3 answers
817 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 ...
user avatar
  • 401
1 vote
0 answers
80 views

How do I code an L2 Norm for a Finite Difference Scheme?

I have to compute the L2 norm of a Finite Difference Scheme applied to a second order differential equation. I set up the code to perform the Scheme with n = 20 and n = 200, and my input is ...
user avatar
  • 25
5 votes
2 answers
224 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 ...
user avatar
  • 401
2 votes
1 answer
125 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 ...
user avatar
  • 401
0 votes
0 answers
58 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 ...
user avatar
  • 3,286
2 votes
2 answers
232 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 ...
user avatar
  • 1,624
5 votes
1 answer
282 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. ...
user avatar
  • 331
3 votes
0 answers
247 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 : ...
user avatar
1 vote
2 answers
1k 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 ...
user avatar
  • 703
1 vote
1 answer
661 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: ...
user avatar
  • 703
0 votes
0 answers
143 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 ...
user avatar
  • 65
1 vote
1 answer
1k 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(...
user avatar
  • 703
5 votes
2 answers
431 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 ...
user avatar
  • 703
1 vote
1 answer
135 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 $\...
user avatar
2 votes
1 answer
187 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 ...
user avatar
8 votes
1 answer
293 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 $\...
user avatar
1 vote
2 answers
119 views

Testing the accuracy of numerically computed derivatives

I am calculating approximate derivatives by using NDSolve`FiniteDifferenceDerivative, so this works: ...
user avatar
  • 45
1 vote
0 answers
97 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 ...
user avatar
  • 163
1 vote
1 answer
70 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 ...
user avatar
4 votes
1 answer
146 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 ...
user avatar
0 votes
1 answer
164 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: <...
user avatar
  • 1,624
2 votes
1 answer
238 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): ...
user avatar
  • 1,624
1 vote
1 answer
260 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^...
user avatar
1 vote
1 answer
101 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 ...
user avatar
  • 1,624
1 vote
1 answer
97 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): ...
user avatar
  • 1,624
19 votes
3 answers
567 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)=...
user avatar
  • 51.6k
6 votes
2 answers
362 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 ...
user avatar
6 votes
1 answer
523 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 ...
user avatar
8 votes
3 answers
534 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....
user avatar
  • 4,006
6 votes
2 answers
898 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)...
user avatar
  • 269
3 votes
2 answers
463 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 ...
user avatar
  • 175