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
8 votes
3 answers
358 views

Numerical solution for a non-linear Fractional Differential Equation (FDE)

As shown below, a neat explicit expression is obtained for F=2, however an exact solution is not present for 1< F < 2. How do we obtain numerical values for F = 1.5 (for instance)? There have ...
  • 3,036
2 votes
0 answers
45 views

Two small problems on the FiniteDifferenceDerivative in the tutorial?

In the tutorial for FiniteDifferenceDerivative of pseudospectral approximation, there is a nice example. I just show a snapshot The following line should define $11$ discrete wavenumbers over a ...
5 votes
1 answer
250 views

Error in Attempting Moving Boundary Fluid System

Recently I was attempting to solve a moving boundary fluid system on mathematica, which I have managed to convert into a coupled PDE-ODE system based on this helpful reference over here. The equations ...
  • 173
0 votes
0 answers
52 views

How to use Manipulate for Finite Differences

I want to improve my code using the command Manipulate and being able to see the calculus of averages as the indexes l and u are moved. I did a simple example of a 4x4 matrix with the boundary ...
3 votes
1 answer
93 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 ...
0 votes
1 answer
113 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
92 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 ...
  • 221
19 votes
1 answer
373 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 ...
  • 35.3k
5 votes
2 answers
605 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 ...
  • 61
2 votes
1 answer
162 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}$...
0 votes
0 answers
35 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 ...
  • 199
0 votes
0 answers
28 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 ...
  • 199
4 votes
1 answer
142 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, <...
  • 1,120
7 votes
2 answers
422 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}...
1 vote
0 answers
79 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: ...
1 vote
1 answer
196 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 ...
0 votes
1 answer
122 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://...
  • 5
18 votes
1 answer
481 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 ...
  • 35.3k
1 vote
0 answers
55 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 ...
2 votes
1 answer
356 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 ...
  • 115
1 vote
1 answer
128 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: ...
  • 58
1 vote
1 answer
104 views

Boundary condition do not satisfied

...
0 votes
1 answer
301 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 ...
  • 117
6 votes
3 answers
927 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 ...
  • 401
1 vote
0 answers
86 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 ...
  • 25
5 votes
2 answers
227 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 ...
  • 401
2 votes
1 answer
127 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 ...
  • 401
0 votes
0 answers
76 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 ...
  • 3,306
2 votes
2 answers
238 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 ...
  • 1,776
5 votes
1 answer
336 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. ...
  • 329
3 votes
0 answers
256 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
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 ...
  • 711
1 vote
1 answer
764 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: ...
  • 711
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 ...
  • 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(...
  • 711
5 votes
2 answers
469 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 ...
  • 711
1 vote
1 answer
137 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
1 answer
191 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
1 answer
302 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
2 answers
125 views

Testing the accuracy of numerically computed derivatives

I am calculating approximate derivatives by using NDSolve`FiniteDifferenceDerivative, so this works: ...
  • 45
2 votes
0 answers
105 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 ...
  • 173
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
156 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
169 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: <...
  • 1,776
2 votes
1 answer
247 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,776
1 vote
1 answer
287 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
1 answer
103 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,776
1 vote
1 answer
99 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): ...
  • 1,776
19 votes
3 answers
580 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)=...
  • 55.3k
6 votes
2 answers
399 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 ...