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
4 votes
1 answer
84 views

Numerical Solution for a Non-Linear Functional Fractional Differential Equation (FFDE)

I tried solve non-linear Functional-Fractional Differential Equation (FFDE) with this method, but it works on only for range: $x\in \{0,1\}$. I what extend the solution range for example for general ...
Mariusz Iwaniuk's user avatar
3 votes
1 answer
162 views

Two-directional vibration of Euler–Bernoulli beam with Lagrange multiplier

Background I'm going to investigate a beam-pendulum coupling system (in this question I won't consider the pendulum though), that is, a spherical pendulum is suspended on the tip of a cantilever beam. ...
rnotlnglgq's user avatar
  • 3,740
7 votes
2 answers
253 views

How to improve FDM solver for unsteady viscous flow?

To solve the problem that is discussed in the paper Finite Difference Analysis of Time-Dependent Viscous Nanofluid Flow Between Parallel Plates we developed FDM solver based on the code from the blog ...
Alex Trounev's user avatar
  • 43.3k
2 votes
1 answer
114 views

Method of lines - Dirichlet and mixed BC

I have a dissolution problem to solve with two equations (everything is in dimensionless form - concentration, time and distance - EDIT: that came from the second Fick's law, where the distance was ...
Larissa Santos's user avatar
2 votes
2 answers
177 views

Badly conditioned matrix for boundary ODE

I have a coupled boundary ODE with dependent variables $u=u(x)$ and $z=z(x)$, $$u'' - \frac{1}{z} \left( -3 + u'^2 (3 - c\; e^{-g u} z^4) - 6 u' z' \right) = 0\tag{1}$$ $$z'' + c\; e^{-g u} z^3 (-3 + ...
mathemania's user avatar
2 votes
0 answers
152 views

Problem with pdetoode for two coupled PDEs

I tried to adapt a code for a single equation to solve the following system using 'pdetoode' Updated answer ...
S. Maths's user avatar
  • 203
3 votes
1 answer
188 views

Numerical solution of the Richards' equation

I am trying to solve Richards' equation to model fluid flow in soil. The governing partial differential equation, initial condition, and boundary conditions are: The analytical solution of the ...
Tayfun's user avatar
  • 31
0 votes
3 answers
111 views

Generalize the code to more variables

I have this code it runs and gives me the solution. How can I make it more compact and If I want it to extend(generalize) it to more variables how can I do it. I had asked a similar question here (...
Learner's user avatar
  • 219
5 votes
2 answers
212 views

Crafting a replacement rule to convert derivatives to finite differences

I need to construct a replacement rule to replace (first) derivatives with centered finite differences. What I've got so far is ...
Chris K's user avatar
  • 20.1k
1 vote
1 answer
106 views

A way to generalize my code for this non linear ODE problem

I am trying to solve the differential equation $y''(x) = y(x)+\sin[y'(x)]$ using "Fixed Point Iteration" over the interval $[0,1].$ Now using central difference method I arrived at the ...
Learner's user avatar
  • 219
1 vote
0 answers
91 views

Solve system of ODE by fractional finite difference method

I am trying to solve the following system using fractional finite difference method: where e=0.1, a=1.3, m=0.3, p=10, g=3, k=1 and s1, s2, s3 it was mentioned in this paper that it is calculated ...
ahmed's user avatar
  • 75
6 votes
0 answers
571 views

Code for quasi 1D nozzle flows

The quasi-one-dimensional model describing the flow of compressible gas in rocket nozzles is very common. The corresponding equations have a divergent non dimensional form $ \frac{\partial \mathbf{U}}...
Alex Trounev's user avatar
  • 43.3k
3 votes
3 answers
253 views

Apply central difference formula to a variable twice

I am working with finite difference methods analytically and I would like to be able to perform operations on subscripted variables. I would like to generate the following expression by applying a ...
Hefaestion's user avatar
0 votes
0 answers
57 views

Explicit modified midpoint (Gragg smoothing)

In the "StifnessSwitching" method the default numerical scheme for the non-stiff solver is Explicit modified midpoint (Gragg smoothing) with a decreasing step size. I decided to study the ...
Van's user avatar
  • 13
1 vote
1 answer
385 views

Difficulty in solving a differential equation with custom solver for a different initial condition

This is a follow-up question to this previous post by @FLP, in which an interesting system of equations was solved with the useful pdetoode developed by @xzczd. I have tried to solve this problem with ...
lxy's user avatar
  • 165
5 votes
1 answer
124 views

Spalart-Allmaras turbulence model

In this post Alex gives an implementation of the Spalart-Allmaras turbulence model [1, 2]. The example produces reasonable results, as far as I can tell. However, the implementation Alex uses deviates ...
user21's user avatar
  • 39.4k
4 votes
1 answer
106 views

Finite Element analysis: distribution of sine wave over a distance

I am trying to solve the following one-dimensional problem: (to better understand and extend the FEM for a more complex problem), ...
a019's user avatar
  • 845
4 votes
1 answer
191 views

NDSolveValue gives up without warning or solution on PDEtoODE system

I have the following pair of PDEs that I want to solve in the half-space x>=0:  I followed this post to decompose the 4th-order height equation into two 2nd-order ones to respect the hyperbolic ...
Ariana Fenris's user avatar
4 votes
1 answer
272 views

How To Implement Discrete Fractional Differentiation in Mathematica

This question was borne out of my attempt to answer this question. How to calculate fractional differences of a timeseries? To recreate this in Matheamatica I wrote this code ...
Daniel Berkowitz's user avatar
2 votes
1 answer
242 views

Speeding up NDSolve to reasonable speeds to solve a coupled PDE system

Problem Statement I am planning to solve a PDE system which consists of a fluid droplet spreading on a non-Newtonian substrate. The system consists of the following equations: $$\frac{\partial p_1}{\...
FLP's user avatar
  • 475
5 votes
0 answers
187 views

Resolving singularity in convection-diffusion equation using pdetoode

Building on the system of equations in this post, I attempted to solve an additional convection-diffusion equation describing the concentration of solute in the lens, which affects its spreading. ...
FLP's user avatar
  • 475
5 votes
1 answer
329 views

NDSolve refuses to initialise when solving an integro-differential equation with custom pdetoode solver scheme

Problem Background Recently I'm attempting to replicate the result of the following research paper on the Nonlocal description of Evaporating Drops. The equation of motion of a evaporating, spreading ...
FLP's user avatar
  • 475
-1 votes
1 answer
71 views

Need help with the functions to use for this problem [closed]

Consider the following example. Suppose there is a thin rod which is insulated along its length. Suppose that the temperature is initially zero everywhere, and that the left end is suddenly heated and ...
MaxJ.'s user avatar
  • 25
8 votes
3 answers
905 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 ...
thils's user avatar
  • 3,228
2 votes
0 answers
54 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 ...
user95273's user avatar
  • 135
5 votes
1 answer
476 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 ...
FLP's user avatar
  • 475
0 votes
0 answers
60 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 ...
Franco Brondo's user avatar
3 votes
1 answer
143 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 ...
user95273's user avatar
  • 135
0 votes
1 answer
140 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
164 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 ...
Mjoseph's user avatar
  • 221
21 votes
1 answer
508 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 ...
Alex Trounev's user avatar
  • 43.3k
5 votes
2 answers
757 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 ...
little star's user avatar
2 votes
1 answer
233 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}$...
Jose Enrique Aroca's user avatar
0 votes
0 answers
41 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 ...
JBuck's user avatar
  • 199
0 votes
0 answers
40 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 ...
JBuck's user avatar
  • 199
4 votes
1 answer
224 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, <...
SAC's user avatar
  • 1,335
7 votes
2 answers
882 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}...
Jose Enrique Aroca's user avatar
1 vote
0 answers
90 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: ...
Madhurima Chakraborty's user avatar
1 vote
1 answer
256 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 ...
Mahmoud Hassan's user avatar
0 votes
1 answer
292 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://...
BH2019's user avatar
  • 5
18 votes
1 answer
625 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 ...
Alex Trounev's user avatar
  • 43.3k
1 vote
0 answers
57 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 ...
curious_coder17's user avatar
3 votes
1 answer
1k 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 ...
R110's user avatar
  • 125
1 vote
1 answer
172 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: ...
Ymir's user avatar
  • 58
1 vote
1 answer
132 views

Boundary condition do not satisfied

...
Mathematicain's user avatar
0 votes
1 answer
459 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 ...
CR36's user avatar
  • 127
7 votes
3 answers
1k 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 ...
Vefhug's user avatar
  • 421
1 vote
0 answers
123 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 ...
Bogus's user avatar
  • 25
5 votes
2 answers
258 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 ...
Vefhug's user avatar
  • 421
2 votes
1 answer
147 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 ...
Vefhug's user avatar
  • 421