Code Monkey home page Code Monkey logo

dysys's Introduction

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.

dysys's People

Contributors

ricopicone avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.