Skip to main content

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
0 answers
106 views

Reaction diffusion equation

I have an issue when I run this code which illustrates the 2D Fisher KPP equation for boundary condition u=0 and initial condition is equal to 1 if (x,y)=(0,0) and0 otherwise , isue finite diffrence ...
RIM's user avatar
  • 65
1 vote
0 answers
51 views

How to constrain two PDE variables to be the same value on boundary?

I have a 4 pdes for 4 variables: v, v2, ua, and p. I would like to specify that v==v2 on the left and right boundaries at all times. Here are the equations: I discretise the system using PDEtoODE. ...
Ariana Fenris's user avatar
2 votes
1 answer
223 views

Finite difference method in 2D [closed]

We look for $u(x, y, t)$ satisfying $$ \frac{\partial u}{\partial t}=\lambda_1 \frac{\partial^2 u}{\partial x^2}+\lambda_2 \frac{\partial^2 u}{\partial y^2}+\mu u(1-u), \quad t>0, \quad(x, y) \in \...
RIM's user avatar
  • 65
0 votes
0 answers
36 views

NDSolve does not satisfy initial and boundary condition

I am using NDsolve to solve for a coupled pde system $vA[x,t]$ and $vU[x,t]$. I have initial condition for $vU[x,0]=2$, and the boundary condition as $\partial_x vU(0,t)=1$. I have accounted for these ...
questionerno8's user avatar
0 votes
0 answers
28 views

NDSolve does not take into account the boundary condition

I am using the following script to solve a coupled pde. I get the error "NDSolve has computed initial values that give a zero residual for the differential-algebraic system, but some components ...
questionerno8's user avatar
0 votes
0 answers
42 views

Solving system of coupled pdes with Neuman and Drichlet Bc

I am trying to solve a system of coupled PDEs. However, I have issues assigning initial and boundary values to the unknown field. I have checked and initial values satisfy the boundary conditions, and ...
questionerno8's user avatar
0 votes
1 answer
142 views

Solving coupled quasi-linear PDEs with boundary conditions

I realized that in this solution, changing one of the boundary conditions makes the answer invalid. I wonder if it is possible to modify the code in this answer to solve the following equations. $$ \...
questionerno8's user avatar
6 votes
1 answer
157 views

How do I couple an 1D PDE to a 2D Laplace equation?

Recently I've come across the following system governing the spreading of an evaporating droplet. The height of the droplet $h$ is defined by the following equation $$\frac{\partial h}{\partial t}=-\...
FLP's user avatar
  • 547
3 votes
1 answer
106 views

Problem with calculation of Lyapunov exponent

The code given by Chris K for Lyapunov Exponent does not work and gives lot of errors for the dynamical system given in equation(2) of this paper The dynamical equations: ...
Arssat's user avatar
  • 129
4 votes
1 answer
93 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
199 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
276 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
  • 45.5k
2 votes
1 answer
125 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
182 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
158 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
200 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
112 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
223 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.3k
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
98 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
  • 85
6 votes
0 answers
715 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
  • 45.5k
3 votes
3 answers
269 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
60 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
394 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
  • 189
5 votes
1 answer
137 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.9k
4 votes
1 answer
113 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
  • 867
4 votes
1 answer
197 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
298 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
260 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
  • 547
5 votes
0 answers
199 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
  • 547
5 votes
1 answer
335 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
  • 547
-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
975 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,268
2 votes
0 answers
56 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
489 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
  • 547
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
148 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
143 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
174 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
  • 233
21 votes
1 answer
521 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
  • 45.5k
5 votes
2 answers
776 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
242 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
42 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
234 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
962 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
91 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: ...
maddy's user avatar
  • 101
1 vote
1 answer
268 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
324 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
639 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
  • 45.5k