Skip to main content

A package for working with system dynamics symbolically and numerically

Project description

PyPI

DySys

A Python package for system dynamics and control systems utilities (using numpy, sympy, and control)

Installation

This package now published on PyPI and can be installed with

pip install dysys

Usage

To import the package into a script, use

import dysys as ds

Symbolic State-Space Models

Create a symbolic state-space model:

A = [[-4, -3, 0], [0, -8, 4], [0, 0, -1]]
B = [[0], [1], [0]]
C = [[0, 1, 0]]
D = [[0]]
sys = ds.sss(A, B, C, D)  # Create a symbolic state-space model

Factoring a Transfer Function

import dysys as ds
import control
import matplotlib.pyplot as plt

Define a transfer function using the dysys package as follows:

H = ds.tf(
    [1_000_000, 300_000_000],  # Numerator coef's
    [1, 1030, 40200, 10_300_000, 100_000_000]  # Denominator coef's
)

Get a list of transfer functions that are the canonical factors of H{.py}:

factors = H.factor_canonical(check=True)  # Check that the factors are correct

Print the factors:

for factor in factors:
    print(factor)

$\frac{3}{1}$
$\frac{0.003333 s + 1}{1}$
$\frac{1 \times 10^{4}}{s^2 + 20 s + 1 \times 10^{4}}$
$\frac{1}{0.1 s + 1}$
$\frac{1}{0.001 s + 1}$

Generate a Bode plot:

control.bode_plot([H] + factors, dB=True, wrap_phase=True)
plt.gcf().legend(
    list(map(lambda x: x._repr_latex_()[1:-1], [H] + factors)), 
    loc="outside center right",
)
plt.show()

A Bode plot of each factor and the composite.

Issues

If you have issues, please report them on the issues page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dysys-0.1.7.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dysys-0.1.7-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file dysys-0.1.7.tar.gz.

File metadata

  • Download URL: dysys-0.1.7.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.8 Darwin/23.4.0

File hashes

Hashes for dysys-0.1.7.tar.gz
Algorithm Hash digest
SHA256 02a96807a0edaa2c6e3fd9d9a28b85593a0f22b6ca9779b2ba03771cc1f0ff64
MD5 742268bc81ddccf132690b41f0b8d1ff
BLAKE2b-256 7bc9fdb2343538f1d26677d461c71c3d8bfe253aa68b491497c55b4c28830666

See more details on using hashes here.

File details

Details for the file dysys-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: dysys-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.8 Darwin/23.4.0

File hashes

Hashes for dysys-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 0e042d33fa03c0de2fb90b07e848a3e58b21a4833ffb056f3971572145889fb0
MD5 94a750b7b30b61c48c21a6f45aa3ea61
BLAKE2b-256 2714be241bddd59e9a042c229c8cee74939567cd8866eb925f91a620f3264d2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page