First-order linear system with time delay as DDEProblem?

I’m new to the diffeq landscape and am working on solving a First Order Plus Dead Time (FOPDT) model:

\tau_p \frac{dy(t)}{dt} = -y(t) + K_p u\left(t-\theta_p\right)

I have data for y(t) and data for u(t) and am having trouble figuring out how to translate this to the DifferentialEquations package. Here’s my translation from what I see in the beginner docs for ODEs:

  • y(t) \rightarrow variable u
  • \tau_p, K_p, \theta_p \rightarrow parameters p
  • start and end time of data as a tuple \rightarrow t
  • u(t) \rightarrow ??

I’m unsure of what to do with u(t) from the FOPDT definition here. I wouldn’t think of it as a parameter since it’s actually just raw data. I did see a python implementation for solving an FOPDT and they ended up taking the data and making an interpolation function via scipy.interpolate.interp1d and passing that as a parameter to the odeint method of scipy.

Given that the FOPDT model has a time delay (u(t-\theta_p)) I thought this may be a good use case for a Delay Differential Equation (DDEProblem). However, I’m unsure if this is the proper use of a DDEProblem since u(t) is what I want historical values of and not past values of the diffeq’s solution.

This may seem a bit vague but I’m hoping someone could lead me in the right direction. Thanks for the help.

1 Like

Your way of thinking looks fine to me. This is a first order, linear, inhomogeneous ODE of the form \dot{y}(t) = Ay(t) + f(t) with

A:=-\tau_p^{-1}, \qquad f(t) := \tau_p^{-1}K_p u(t - \theta_p)

and not a DDE. If you want to solve the associated initial-value problem on an interval [t_0,t_1] then it is necessary to know u on the translated interval [t_0 - \theta_p, t_1 - \theta_p]. This can be done by variation-of-constants, i.e.

u(t) = e^{(t - t_0)A}u(t_0) + \int_{t_0}^te^{(t- \tau)A}f(\tau)\,d\tau, \qquad t_0 \le t \le t_1.

You can calculate the integral using numerical quadrature and knowledge of the u. For comparison and as a test, you can also feed the ODE to your preferred ODE solver and compare the results.

2 Likes

Incidentally, what exactly constitutes a parameter may depend on context. We are used to thinking of parameters as points in \mathbb{R} or perhaps \mathbb{R}^n, but sometimes it can be very useful to think of functions such as f (defined via u) as parameters as well, especially if you are interested in how the behavior of the solution y changed when we perturb f.

Thanks @sgjanssens! That clears things up a bit. I’ll go ahead and use DifferentialEquations ODEProblem with f (defined via u) as an additional parameter and look into cross-checking it with calculating the integral as well.