Questions tagged [ode]

An ODE (ordinary differential equation, in contrast to partial differential equation) is a differential equation containing a function or functions of exactly one independent variable.

An ODE (ordinary differential equation, in contrast to partial differential equation) is a differential equation containing a function or functions of exactly one independent variable. Equations of this type can be solved numerically or analytically.

1902 questions
8
votes
1 answer

Does scipy.integrate.ode.set_solout work?

The scipy.integrate.ode interface to integration routines provides a method for stopping the integration if a constraint is violated at any step, set_solout. However, I cannot get this method to work, even in the simplest examples. Here's one…
Ted Pudlik
  • 665
  • 8
  • 26
7
votes
1 answer

Convert a numpy array to iterator

I want to use an array as argument of a function which will be used to solve an ODE function. def ode(x, t, read_tau, tau_arr): q_ib = x[0:4] omega = x[4:7] dq_ib = 0.5 * np.dot(gen_omega(omega), q_ib) + read_tau(tau_arr) return…
Lion Lai
  • 1,862
  • 2
  • 20
  • 41
7
votes
1 answer

How do I use pylab to plot a phase plane for pendulum motion?

I have code that will work for plotting the following predator prey model: dx/dt = x − xy, dy/dt = −y + xy from pylab import * xvalues, yvalues = meshgrid(arange(0, 3, 0.1), arange(0, 3, 0.1)) xdot = xvalues - xvalues * yvalues ydot = - yvalues +…
skrooms
  • 143
  • 2
  • 7
7
votes
1 answer

use of fft, ifft and fftshift in matlab

I am trying to implement the split-step fourier method to solve the nonlinear schrodinger equation in optics. It basically treats the linear part and nonlinear part separately. It solves the linear part by using fourier transform and the nonlinear…
Physicist
  • 2,848
  • 8
  • 33
  • 62
7
votes
1 answer

Solve ODE in Python with a time-delay

Can anybody give me some advice how to solve an ODE in Python that has a time-delay implemented in it? I can't seem to figure out how to do it using scipy.integrate.odeint. What I am looking for should look like: # the constants in the equation b =…
ThePiIsALie
  • 71
  • 1
  • 4
7
votes
2 answers

What is the mass matrix in ode solvers in MATLAB?

Without using a mass matrix, ode solvers like ode45 can solve y'=f(t,y). But there is an option of mass matrix in ode solvers for problems that involve a "mass" matrix, M(t,y)y'=f(t,y). What exactly is the "mass" matrix? Does this term come from the…
Ka Wa Yip
  • 2,546
  • 3
  • 22
  • 35
7
votes
2 answers

Using numba.jit with scipy.integrate.ode

Using numba.jit to speed up right-hand-side calculations for odeint from scipy.integrate works fine: from scipy.integrate import ode, odeint from numba import jit @jit def rhs(t, X): return 1 X = odeint(rhs, 0, np.linspace(0, 1, 11)) However…
germannp
  • 197
  • 4
  • 15
7
votes
2 answers

Solve an implicit ODE (differential algebraic equation DAE)

I'm trying to solve a second order ODE using odeint from scipy. The issue I'm having is the function is implicitly coupled to the second order term, as seen in the simplified snippet (please ignore the pretend physics of the example): import numpy…
Shaun_M
  • 93
  • 1
  • 1
  • 7
7
votes
2 answers

Matlab: Is it possible to numerically solve a system of ode's with a mixture of initial and terminal conditions?

I'm trying to use ode45 to solve a system of ODE's: [X,Y]= ode45(@sys,[0, T],y0); where, function dy = sys(t,y) dy(1) = f_1(y) dy(2) = f_2(y) dy(3) = f_3(y) end The problem is that the function ode45 requires that y0 be…
Vokram
  • 2,097
  • 4
  • 19
  • 27
7
votes
4 answers

Haskell - Optimizing differential equation solver

I'm learning Haskell and am trying to write code as fast as I can do in C. For this exercise, I'm writing a Euler integrator for a simple one-dimensional physical system. The C code is compiled with GCC 4.5.4 and -O3. It runs in 1.166 seconds. The…
Charles Welton
  • 841
  • 7
  • 14
6
votes
1 answer

Matlab ode45. How to change a parameter inside it while calling it?

I'm new with Matlab. I hope you can help me. I have to solve a system of ODEs using ODE45 function. Here is the function which describes my equitions. function dNdt = rateEquations(t, y) %populations of corresponding state Ng = y(1); Ns =…
jacksonslsmg4
  • 211
  • 1
  • 5
  • 10
6
votes
1 answer

vector faster than double*: why?

Here's a loop that I've tried with std::vector and with plain old double*. For 10 million elements, the vector version consistently runs in about 80% of the time that the double* version takes; for pretty much any value of N, vector is…
Hector
  • 63
  • 1
  • 3
6
votes
2 answers

GEKKO Infeasible system of ODE equations of a fed-batch Bioreactor

I am new to GEKKO and also to modeling bioreactors, so I might be missing something obvious. I have a system of 10 ODEs that describe a fed-batch bioreactor. All constants are given. The picture below shows the expected behavior of this model…
Felipe Mello
  • 395
  • 2
  • 8
6
votes
1 answer

Solving ODE with large set of initial conditions in parallel through Python

I am trying to use scipy.integrate.ode or scipy.integrate.odeint to solve a system of ODE for a large set of (more than a thousand) initial conditions, however it is extremely slow by performing loops, and scipy does not seem to provide options for…
Sato
  • 1,013
  • 1
  • 12
  • 27
6
votes
2 answers

scipy.integrate.ode with two coupled ODEs?

I'm currently trying to use SciPy's integrate.ode package to solve a pair of first-order ODEs that are coupled: say, the Lotka-Volterra predator-prey equation. However, this means during the integration loop I have to update the parameters I'm…
Magsol
  • 4,640
  • 11
  • 46
  • 68