Scipy-based delay differential equation (DDE) solver. See the docstrings and examples for more information.
First of all, I would like to say "Thanks!" to @Zulko for developing the ddeint. I was using the ddeint for solving a system of delay differential equations with multiple time delays. Unfortunately, I was not able to simulate the system with the available features of the ddeint. So I made some changes to it. In this version, alongside with ddeVar, the ddeVars object is introduced for making the state variables with multiple delay values available. ddeVars acts like a list of ddeVar objects. Subsequently, the history of each state variable for time values smaller than zero is given by a list of functions, instead of a function with an array in its output.
Let equations of the system be as below:
$$\dot{y}{1} \left( t \right) = y{1} \left( t - 1 \right)$$ $$\dot{y}{2} \left( t \right) = y{1} \left( t - 1 \right) + y_{2} \left( t - 0.2 \right)$$ $$\dot{y}{3} \left( t \right) = y{2} \left( t \right)$$
As it can be seen, three history functions for state variables are needed. Also, there are two delay values 1 and 0.2 in the equations. In order to write the model function we can use the code below:
from ddeint import ddeint
from numpy import linspace, array
def model(Y, t):
y2 = Y[1](t)
y1d = Y[0](t-1)
y2d = Y[1](t-0.2)
return array([y1d, y1d+y2d, y2])
The history functions are defined as:
g1 = lambda t : 1
g2 = lambda t : 1
g3 = lambda t : 1
Finally the system is solved as below:
tt = linspace(0,5,5000)
yy = ddeint(model, [g1, g2, g3], tt)
The output of the example system is represented below:
This example has been also solved using the Matlab function, dde23. The matlab output is also available here which approves the results:
ddeint can be installed by unzipping the source code in one directory and using this command:
(sudo) python setup.py install