Add support for continuous delay systems#1148
Add support for continuous delay systems#1148MythasNauveili wants to merge 19 commits intopython-control:mainfrom
Conversation
…m to solve delay ODE in timeresp. Add litlle tests about timereps
…n the DDE integration
implemented only basic dde solving based on Skogestad python
…improve doc and julia notebook. Clean the code
…alize with json file. Fix scalar multiplication
…ests. TODO: clean dde file, test functions in it, and reloacate dde response tests. More tests also like mimo force response are needed
murrayrm
left a comment
There was a problem hiding this comment.
Initial round of comments. I haven't yet checked functionality, but found a few style issues that should be updated.
control/dde.py
Outdated
| U = _check_convert_array( | ||
| U, legal_shapes, "Parameter `U`: ", squeeze=False, transpose=transpose | ||
| ) | ||
| print("U shape: ", U.shape) |
There was a problem hiding this comment.
This looks like a debugging statement that was left in the code?
control/dde.py
Outdated
| discontinuity_times.remove(t_stop) | ||
| local_t_eval = [t for t in T if current_t < t <= t_stop] | ||
|
|
||
| print("Integrate bewtween ", current_t, " and ", t_stop) |
control/__init__.py
Outdated
|
|
||
| # Allow access to phase_plane functions as ct.phaseplot.fcn or ct.pp.fcn | ||
| from . import phaseplot as phaseplot | ||
|
|
There was a problem hiding this comment.
Was there a reason to add an extraneous blank line here?
There was a problem hiding this comment.
no, blank line is removed in the last commit
control/dde.py
Outdated
| ) | ||
|
|
||
|
|
||
| def pchip_interp_u(T, U): |
There was a problem hiding this comment.
This looks like it is probably an internal function. If so, add underscore to start of function name.
control/dde.py
Outdated
| return np.array([negative_wrapper(PchipInterpolator(T, ui)) for ui in U]) | ||
|
|
||
|
|
||
| class DdeHistory: |
There was a problem hiding this comment.
This might be better named DDEHistory (since DDE is a standard abbreviation, like LTI)?
Also, if this is an internal class, begin the class name with an underscore.
There was a problem hiding this comment.
Changed the name and added the underscore
control/delaylti.py
Outdated
|
|
||
| Notes | ||
| ----- | ||
| The way to create a DelayLTI object is by multiplying a transfert |
control/delaylti.py
Outdated
| It's possible to MIMO delayed systems from arrays of SISO delayed systems, | ||
| see function mimo_delay |
There was a problem hiding this comment.
It's possible to MIMO → It is possible to create
Also missing a period at the end.
control/delaylti.py
Outdated
|
|
||
| # Poles and zeros functions for DelayLTI are not supported by julia ControlSystems.jl | ||
| # might not be accurate for delayLTI, to be discussed | ||
| # Here the poles and zeros computed are the ones of the system without taking into accoutn the delay |
There was a problem hiding this comment.
Typo + may be longer than 78 char (PEP8).
control/delaylti.py
Outdated
| # Check dimensions of K | ||
| if K.shape != (self.nu, self.ny): | ||
| raise ValueError( | ||
| f"Feedback gain K has incompatible shape. Expected ({self.nu}, {self.ny}), got {K.shape}." |
There was a problem hiding this comment.
Update to avoid line with more than 78 characters and put closing parenthesis at end of string, for consistency with current code base.
control/delaylti.py
Outdated
| def issiso(self): | ||
| """Check if the system is single-input, single-output.""" | ||
| # Based on EXTERNAL dimensions | ||
| return self.nu == 1 and self.ny == 1 |
There was a problem hiding this comment.
This should be handled by the parent class (InputOutputSystem).
There was a problem hiding this comment.
This is now moved to InputOutputSystem
|
This would be a great contribution, @MythasNauveili. Thanks for working on it! There are some issues with unit tests. In addition to the failed ruff and doctest checks, it looks like some of the standard tests might be hanging. Not sure if that is due to the new code or if something is messed up in the GitHub actions. I'll try to come back and take a look at that later. In the meantime, some style things to adjust in your next pass. |
|
Thanks for the first feedback @murrayrm. I tried to fix the most in the two last commits. For the tests hanging, it might be because of debug plots that I did not disable in |
|
@MythasNauveili There are still two unit tests failing. Click on the links above to see the issues. The ruff checks should be straightforward. For the doctest, it looks like something is printing out spurious information; not sure where that is happening. |
|
@murrayrm it might be ok now, I just removed a forgotten debug print in |
This PR introduces initial support for linear time-invariant (LTI) systems with time delays in
python-control, inspired by the capabilities of ControlSystems.jl package, and theInternalDelay.pyscript from Skogestad-Python.Key features
TransferFunctionobject with adelay(tau)object or anexp(-tau*s)expression:PartitionedStateSpacerepresentation (implemented inpartitionedssp.py). TheDelayLTIclass (indelaylti.py) serves as the core object for these systems.DelayLTIobjects.Implementation Details:
solve_ivp, was implemented indde.py.control/julia/compute_tests.jl) using ControlSystems.jl has been added to generate reference results, which are exported to a JSON file. These results are used in the test suite (control/tests/delay_lti_test.pyandcontrol/tests/dde_test.py) to benchmark the accuracy of theDelayLTIimplementation and DDE solver.Current Scope and Limitations:
Discussion Points:
This PR represents the initial groundwork for this feature. I'm submitting this draft to share these first steps and would appreciate feedback on:
DelayLTI,PartitionedStateSpace).I'm aware there is still work to be done for this feature to be ready for a full release, but I believe this provides a solid foundation.