Simulating a PID in a DAE - how to simulate a DDAE?

I would like to run a PID controller with a nonlinear set of ODEs with 6 continous variables.

I thought I could do this with delay differential algebraic equaions, since in DelayDiffEq.jl it says

Covers neutral and retarded delay differential equations, and differential-algebraic equations.

I haven’t been able to find any tutorials for how to write a DDAE system, could someone point me in the right direction?

Or even better, suggest another way to simulate a PID controller with a set of DAEs

What have you tried? If you just define a DDAE in mass matrix form it should work. There’s tests on this.

Thanks Chris!

So I see this example, which is very useful and resolves how to simulate a DDAE.

I still don’t know how to simulate a PID controller which requires an integral term. The example above has a constant lag, and I’d be looking to compute an integral/sum over a fixed window of time into the past.

I can do this by sampling at a discrete number of constant lag points, but my solver is already relatively slow, and I was wondering if there is a more elegant way solving the problem

A PID controller is commonly simulated just by created in an integrated state, i.e. add the ODE Ix' = x and then Ix = Integral(x).

I used the example of the SIR model I linked above and a vector of constant lags summed over like in this example

I am not sure what you mean by Ix = Integral(x). I searched in the DifferentialEquations docs and github page and can’t find anything like that. The closest thing I found was Integrals.jl, but it doesn’t seem to have any examples that use DEs.

If you meant something specitic, then I would appreciate clarification. Otherwise, I have a working solution now.

thanks for your help