A Python library for discretizing continuous-time transfer functions with time delays
Project description
delay_sys
A Python library for discretizing continuous-time transfer functions with time delays.
Overview
delay_sys provides utilities for converting continuous-time control systems to discrete-time while incorporating deadtime delays. The library is built on top of the python-control package and offers a simple interface for system discretization with configurable delay handling.
Installation
Using pip
pip install delay_sys
Using uv (recommended for development)
git clone https://github.com/jamestjsp/delay_sys.git
cd delay_sys
uv sync
For development installation with pip:
git clone https://github.com/jamestjsp/delay_sys.git
cd delay_sys
pip install -e .
Command-line Interface
The package includes a demonstration command that shows step response comparison:
# Run the demonstration
uv run delay_sys
This will:
- Create a first-order continuous system G(s) = 1/(5s + 1)
- Discretize it with sampling time h = 0.5 minutes
- Add a deadtime of 2.0 minutes
- Display both systems and plot their step responses
Quick Start
import control as ct
import delay_sys
# Create a continuous-time transfer function
G = ct.tf([1], [1, 2, 1]) # 1/(s^2 + 2s + 1)
# Discretize with sampling time and deadtime
Gd = delay_sys.system(
continuous_sys=G,
sample_time=0.1,
deadtime=0.3,
method='zoh'
)
print(Gd)
API Reference
system(continuous_sys, sample_time, deadtime=0.0, method='zoh')
Discretizes a continuous-time transfer function and adds a time delay.
Parameters:
continuous_sys(control.TransferFunction): The continuous-time LTI system to be discretized and delayedsample_time(float): The sampling period for discretization. Must be positivedeadtime(float, optional): Deadtime in the same units assample_time. Defaults to 0.0method(str, optional): Discretization method ('zoh', 'tustin', etc.). Defaults to 'zoh'
Returns:
control.TransferFunction: A discrete-time transfer function with the specified delay
Raises:
ValueError: Ifsample_timeis not positive ordeadtimeis negativeTypeError: If the input system is not continuous-timeNotImplementedError: If the system is not SISO
Examples
Basic Discretization
import control as ct
import delay_sys
# First-order system
G = ct.tf([2], [1, 3])
Gd = delay_sys.system(G, sample_time=0.1)
With Deadtime
# Add 0.5 second deadtime
Gd_delayed = delay_sys.system(G, sample_time=0.1, deadtime=0.5)
Different Discretization Methods
# Using Tustin (bilinear) method
Gd_tustin = delay_sys.system(G, sample_time=0.1, method='tustin')
Features
- Multiple discretization methods: Supports all methods available in
python-control - Integer delay handling: Automatically rounds deadtime to nearest integer number of samples
- Input validation: Comprehensive error checking for invalid parameters
- SISO systems: Currently supports Single-Input Single-Output systems
Requirements
- Python >= 3.8
- control >= 0.9.0
- numpy >= 1.19.0
- matplotlib >= 3.0.0
Development
Using uv (recommended)
# Clone and setup
git clone https://github.com/jamestjsp/delay_sys.git
cd delay_sys
# Install dependencies and run
uv run delay_sys
# Run with specific Python files
uv run python -c "import delay_sys; print(delay_sys.system.__doc__)"
Traditional development setup
pip install -e .
python -m delay_sys
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file delay_sys-0.1.0.tar.gz.
File metadata
- Download URL: delay_sys-0.1.0.tar.gz
- Upload date:
- Size: 144.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c39346b970a96106c1fb5c5c5b1919fb0e03fbedcacdf492a17b5026e8f1cd02
|
|
| MD5 |
5a791fe00f52a850f06fed1a5f49e599
|
|
| BLAKE2b-256 |
82d2bb712efe8a1d50ce0c21dc157b6e18ea9f209eb13697851a3622139753ff
|
File details
Details for the file delay_sys-0.1.0-py3-none-any.whl.
File metadata
- Download URL: delay_sys-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32281656c71910498c0da11d28ada96808c4c349ce5121bb0b5e4247368dc8b7
|
|
| MD5 |
f96ebb7a876027141dbfa8d50b981f8a
|
|
| BLAKE2b-256 |
c88711c80b5711ddfbe52e21795942d4594b561ade4e4404c8d0d054e3a918b3
|