This repo is belong to Control System class contains with Automated Routh Table Calculator based on Python. This code 100% original made by my hand :), please leave some notes if you're going to use it. Thanks!
Libraries that used in this program is ```numpy``` and ```pandas```. ```numpy``` works to define and perform array while ```pandas``` is the final form after ```numpy.array``` to simplify the presentation. They imported by write..
The constructor ```__init__``` takes string of coefficiens from polynomial, extract the number, and load into class variable. It also define ```self.deg``` variable to save array's length, reducing number to calling ```len()``` function
This function only takes one number from user and append it to ```self.den``` which defined as gain (constant). Also ```self.deg``` will increase by one
```calc_routh(self)``` as the core process of this class contains initialization and process about Routh Stability Process. Firstly, it define an empty zero (basically it filled with zeros) and iteratively being inserted by ```self.den``` (refering to Routh Table principle). After that, each cell will be updated by calculating Routh Table formula. Routh Table defined as ```numpy.ndarray``` and converted to ```pandas.DataFrame``` to simplify the presentation of table. ```self.show_tab()``` is called to print the Routh Table and ```self.is_stable()``` to check system's stability.
This function print the Routh Table, should be called only if Routh Table is generated by ```calc_routh```
```
def get_table(self):
return self.df
```
This function return ```pandas.DataFrame``` contained by Routh Table
```
def is_stable(self):
flag = True
for item in self.df[0]:
if item <0:flag =False
return flag
```
This function check the first column's value from Routh Table. The system is define as stable if and only if all the value is positive, else it's unstable
```
def get_poly(self, x):
total = 0
for i in range(self.deg):
total += self.den[self.deg-i-1]*(x**i)
print(total)
return total
```
This function initialize ```x``` value as variable on ```self.den``` polynomial and return the total
It takes coefficient of polynomial and K from user, insert it into ```RouthStability``` class as constructor parameter, insert the K value, and generate Routh Table. The result can be found below: