Questions tagged [differential-equations]

For questions about solving, analyzing, or creating differential equations to model some system. If possible, include specific tags about the type of differential equation (e.g. [tag:pde], [tag:ode], [tag:stochastic-ode]).

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 views

Numerical code to solve LLG is not preserving norm

I am new to this thread. I am trying to do a simple exercise on solving LLG equation. The equation reads: $\frac{d\vec{m}}{dt} = -\gamma(\vec{m} \times\vec{H})$. The expected output for an input state ...
0 votes
0 answers
35 views

Can the Crank-Nicolson Method Be used to Solve The Schrodinger Equation with a Time Varying Potential?

I have been following an excellent article about how to use the Crank-Nicolson method to solve the Schrodinger equation. In the article it starts with a $V(x, y, t)$ but the potential seems to become ...
  • 11
0 votes
0 answers
23 views

Numerov Method with Time Varying Potential

Is it possible to use the Numerov method to solve the Time Dependent Schrodinger Equation ($\frac{i\partial\Psi(x, y, z, t)}{\partial t} = \nabla^2\Psi(x, y, z, t) + \Psi(x, y, z, t)V(x, y, z, t)$) ...
  • 11
0 votes
0 answers
20 views

Translating poisson equation to sfepy code

As the title suggests, I am trying to convert the Poisson equation: Into sfepy code that can solve the differential euqation problem numerically. I am trying to modify the tutorial on lienar ...
  • 165
3 votes
1 answer
89 views

unconditionally stable schemes better than conditionally stable ones in accuracy?

Let's consider two finite difference schemes for PDEs/ODEs. One is conditionally stable, the other is unconditionally stable. People always prefer unconditionally stable ones to conditionally stable ...
  • 187
0 votes
1 answer
114 views

Nonlinear Robin boundary condition involving square root

If you have a nonlinear second-order boundary value problem where the domain of the problem is $x \in [a,b]$, the boundary conditions imposed are the Robins condition at $x=a$ and the Dirichlet ...
0 votes
0 answers
89 views

ValueError: array must not contain infs or NaNs; When using solve_ivp in the scipy library

I am solving an initial value problem using solve_ivp. The problem consists of computing the concentration profile of a set of reactions over time, given the initial concentrations and some of the ...
  • 23
1 vote
0 answers
45 views

Solving PDE on a non-uniform grid with Crank-Nicolson scheme

I am solving a 1D diffusion-type equation with the finite-difference Crank-Nicolson (CN) scheme, and I need to densify the spatial grid around the central point. One could change the spatial variable ...
1 vote
0 answers
59 views

Finite-difference produces a derivative off by one order

I have a nonlinear 2nd order boundary value differential equation where I used finite-difference method (central finite-difference) to solve it. $$z''(x)-\frac{\frac{1}{100} z(x)^4 \left(2 z'(x)^2+12\...
0 votes
1 answer
137 views

Solving a partial integro-differential equation numerically

I am trying to find the solutions for a probability density $p(x,t)$, governed by, $$ \frac{\partial p(x,t)}{\partial t} =\int_{-\infty}^\infty dx' \; \Lambda(x-x')\frac{\partial^2 p(x',t)}{\partial x'...
  • 201
1 vote
2 answers
109 views

Calculate the derivative of the finite-difference method result

I have a nonlinear boundary ODE, $$y'' + 3 y y' = 0, \qquad y(0) = 0, y(2)=1 $$ I want to solve this using the finite-difference method. I obtained the result for the data set of $y(x)$ (including the ...
3 votes
1 answer
99 views

Wrong Boundary Conditions Result Using Wavelet Collocation

I have a functional $S$, $$S = \int_{x_0}^{x_b} dx \frac{1}{z(x)^d} \sqrt{1 + \frac{z'(x)^2}{f(z)}}, \qquad f(z) = 1-\left(\frac{z(x)}{z_h}\right)^{d+1} $$ where $d=3$ is the dimension and $z_h$ is ...
4 votes
3 answers
937 views

How can I numerically integrate the Kepler problem?

I tried to solve a simple Kepler problem numerically. I have discrete time steps, a starting position $(x_0,y_0)$ and starting velocity $(u_0, v_0)$. I used this iteration by calculating the forces ...
  • 151
2 votes
1 answer
92 views

Deterministic SIR metapopulation model and coupling behavior

Context: I am trying to reproduce a figure from Keeling 2007 that illustrates time lags that can occur between the peaks (maximum) of the infected solutions for two subpopulations of a metapopulation ...
2 votes
1 answer
206 views

Python bifurcation diagram of seasonally forced epidemiological models

TL:DR How can one implement a bifurcation diagram of a seasonally forced epidemiological model such as SEIR (susceptible, exposed, infected, recovered) in Python? I already know how to implement the ...
1 vote
1 answer
122 views

(Regular) Coulomb wave function

I'm looking for a way to implement the regular Coulomb wave function in python. This function is a solution to \begin{align} \frac{\text{d}^2\,u}{\text{d}z^2}+\left(1-\frac{2\eta}{z}-\frac{\ell(\ell+1)...
2 votes
0 answers
101 views

Numerical precision on tricky coupled nonlinear boundary value problem on infinite interval

I am trying to solve with high precision the following coupled system $(f,h)$ on $[0,\infty]$: $$-h''-\frac{1}{r}h'+\lambda_c h(f^2-1)+4\lambda_h h^3=0$$ $$-f''-\frac{1}{r}f'+\frac{1}{r^2}f+ f(-\...
  • 33
1 vote
1 answer
64 views

Boundary value problem solver fails on trivial case

I am trying to solve a boundary value problem on $[0, \infty]$, using scipy's scipy.integrate.solve_bvp and I am seeing that the solutions are not converging even ...
  • 33
4 votes
0 answers
64 views

SINDy Vs standard methods for system identification

I have been trying to understand the recently proposed Sparse Identification of Nonlinear Dynamics SINDy. Despite several attempts, I seem to fail to understand the difference between SINDy and the ...
  • 810
0 votes
1 answer
80 views

Passing additional arguments to `odeint` from `torchdiffeq` to solve an IVP

In Python I use the package torchdiffeq (as provided here) to solve initial value problems. Given an arbitrary function ...
2 votes
1 answer
53 views

Solving constrained odes's using inbuilt solvers in Matlab/Octave

I would like to solve a set of coupled second order differential equations using inbuilt Matlab/Octave subroutines. These equations arise when trying to model sliding of mass ($m_2$) over a wedge of ...
0 votes
0 answers
67 views

Solving a system of PDEs with an ODE

I want to solve the following system of equations which consists two PDEs and one ODE: \begin{align} \rho_t+v\rho_x &= 0; \newline Y_t+vY_x &= 0 ;\newline v_t &= -\frac{1}{(\...
1 vote
1 answer
55 views

How to solve advective equation with source term depending on variable

I have the following equation $$ \dfrac{\partial s}{\partial t} + \nabla \cdot \left( \vec{v} s\right) = f(s) $$ Where $f(s)$ is an explicit source term that depends on $s$, e.g., ($\sin(s)\;cos(s)$). ...
1 vote
1 answer
122 views

Differential equation for radioactive cooling in fortran

Today I'm trying to evaluate this differential equation for internal energy in a gas in Fortran: $$ \frac{du}{dt} = - \frac{n_H^2}{\rho}\frac{\Lambda}{n_H^2} $$ Where nH is the density of hydrogen in ...
7 votes
1 answer
186 views

How does non-dimensionalization improve the behavior of ODE solvers?

I have a set of coupled ODEs that I'm solving numerically. The independent variable is time and runs from values of $10^{15}$ to $10^{17}$ in units of seconds. The state variables in their usual ...
2 votes
0 answers
97 views

Numerical solution to integro-differential equation

The time dynamics of an atom interacting with a reservoir of spectral density $J(\omega)$ are obtained by solving the following integro-differential equation: $$ \frac{\mathrm{d}c(t)}{\mathrm{d}t} = - ...
  • 21
0 votes
0 answers
115 views

Solving differential equations with fast oscillations using odeint

I have wrote this code to solve an equation , I know the behavior of this function has very rapid oscillations, when I RUN it gives bogus values for some "m[x]" and some "t"'s, ...
  • 11
2 votes
1 answer
71 views

Numerical computation of Lyapunov exponents: how to find convergence or non-convergence efficiently?

I am wondering what are the standards for convergence of Lyapunov exponents (and Kaplan-Yorke dimension)? For example, I have a MATLAB code to calculate Lyapunov exponents for the classic Lorenz ...
1 vote
0 answers
29 views

How to classify ODE equilibria that are stable but slowly changing in value with time?

I'm numerically solving a system of coupled ODEs where time is the independent variable. At each time, I can solve for the equilibrium values of my state variables where their respective derivatives ...
1 vote
1 answer
92 views

Accurately solving system of differential equations

So I am trying to solve two equations simultaneously. The goal is to find values for $\frac{de}{dt}$ and $\frac{d}{dt}$ which are the rates of change of the variables $a$ and $e$. I am then ...
1 vote
0 answers
68 views

Implementation of integration schemes for ordinary differential equations in Python and peformance comparison

I look for a book/manual where I can find implementations of different integration schemes for ordinary differential equations (like 4-th order Runge-Kutta) in Python with Numba. To be more specific, ...
0 votes
0 answers
78 views

How to estimate stability and stiffness of a system of coupled ODEs?

I'm running into issues with Python/Julia ODE solvers requiring prohibitively small timesteps to evolve a system of 4 coupled ODEs (the order of magnitude of the state variables and time unit span ~40-...
2 votes
1 answer
234 views

2nd order differential equation coupled to integro-differential equation in python

I'm trying to solve the following equations numerically in python $$\begin{align} 12\pi\int_0^\infty drf(r)\phi(r)r^4&=E\\ f(r)-\frac{1}{2\mu}\bigg(\frac{d^2\phi(r)}{dr^2}+\frac{2}{r}\frac{d\phi(r)...
3 votes
1 answer
436 views

Boundary value problem with singularity and boundary condition at infinity

I'm trying to solve the following boundary value problem on $[0,\infty]$: $$f^{\prime \prime}=-\frac{1}{r} f^{\prime}+\frac{1}{r^{2}} f+m^{2} f+2 \lambda f^{3}$$ $$f(0)=0 \ ; f(\infty)=\sqrt{-m^2/(2\...
0 votes
1 answer
211 views

How to deal with solving coupled ODE systems where variables are updated multiple times within each timestep?

I'm solving a system of coupled ODEs using Euler integration for simplicity. To make this concrete, please see the (extremely simplified) minimal working example below in Python. Imagine we have a box ...
1 vote
0 answers
79 views

Well-conditioned pseudospectral for computing eigenvalues to (partial) differential equations

I am working on writing a Chebyshev pseudospectral method (see for example "Chebsyhev and Fourier spectral methods" by John Boyd) to solve for the eigenvalues of differential equations of ...
0 votes
0 answers
20 views

Transparent Boundary Conditions relationship with intermediate BCs in ADI-PR method

I have read some materials about ADI - PR method with the aim to understand how to put boundary conditions in my 2D scheme which solves the Time-Dependent Schrodinger Equation. All the theory I read ...
  • 131
0 votes
0 answers
138 views

Finite difference solver for the 2D Poisson's equation with an integral boundary condition

I wanted to attempt an implementation of a finite-difference-based solver for the 2D elctrostatic Poisson equation when metallic objects are present. Also, I hope to take as input, the location of ...
2 votes
1 answer
195 views

solving a Algebraic Differential Equation in Julia using modelingToolKit.JL

I'm trying to solve a differential algebraic equation in Julia's modelingTookKit.JL, where the vector field has the form f(X) = 0. I found an example of a DAE in the below link modelingToolkit.JL DAE](...
2 votes
1 answer
134 views

DG method for solving Hyperbolic Partial Differential Equation with Dirichlet Boundary Conditions

Consider the following partial differential equation \begin{align} \frac{\partial u}{\partial t}+\frac{\partial f}{\partial x} &= g(x,t), \ \ x\in \Omega = [x_{L},x_{R}] \\ u(x,0) &= u_{0}(x) ...
3 votes
1 answer
397 views

How to solve a BVP with known parameters?

I need to solve a boundary value problem (BVP) of second order, where the equation depends on several know parameters, which are geometric parameters and material constants. I would like to solve this ...
3 votes
1 answer
215 views

Solving DAE in Julia using GPUs

I'm trying to solve a Differential Algebraic Equation (DAE) in Julia which is very computationally expensive using GPUs. I'm brand new to Julia and don't have much experience coding with GPUs. The ...
0 votes
0 answers
92 views

Solve simultaneous differential equations with embedded functions and a parameter estimation

The aim is to solve the below equations and plot $m$ with time, i.e. $\frac{dm}{dt}$ $k$ is unknown and needs to be estimated. For the parameter estimation, the below values in the table for m versus ...
3 votes
2 answers
340 views

Is there a Python version of the ODE tool pplane?

This is the same question as this one, except for Python instead of Mathematica. Basically, the MATLAB software PPLANE is a staple in ODE courses. Is there a Python equivalent? I don't know much about ...
2 votes
1 answer
97 views

Implicit integrator for ODE with quadratic right-hand side

I have an ODE for an unknown $x(t):[0,\infty)\to\mathbb R^n$ of the following form: $$ x_i'(t)=a_i^\top x(t) + x(t)^\top Q_i x(t), $$ for $i\in\{1,\ldots,n\}$. Here, the vectors $a_i\in\mathbb R^n$ ...
1 vote
2 answers
675 views

Recommendations for ODE solvers for stiff equations

I'm continuing the research of a former Ph.D. student in my group requiring the solution of a system of ODEs. On a technical note, they wrote: The system of Boltzmann equations behaves numerically ...
2 votes
0 answers
121 views

Floquet theory for periodic delay differential equations: current numerical routines

I would like to determine the stability of a system of periodic delay differential equations (a seasonal host-parasite model). I've tried to implement the method described in Lemma 2.5 in this paper: ...
  • 21
2 votes
1 answer
2k views

solve_ivp from scipy does not integrate the whole range of tspan

I'm trying to use solve_ivp from scipy in Python to solve an IVP. I specified the tspan ...
1 vote
1 answer
164 views

Logistic growth curve using scipy is not quite right

I'm trying to fit a simple logistic growth model to dummy data using Python's Scipy package. The code is shown below, along with the output that I get. The correct ...
9 votes
1 answer
754 views

How to solve a second order differential equation (diffusion) with boundary conditions using Python

I am having trouble implementing a model from a publication. Huang, K-L.; Holsen, T.M.; Selman, J.R. Ind. Eng. Chem. Res. 2003, 42, 15, 3620–3625 scihub link: https://sci-hub.se/10.1021/ie030109q I ...