In [1]:
# Import needed modules
import sympy as sp
import numpy as numpy
from sympy import init_printing
init_printing()
In [2]:
# Define the symbols
# Needed variables for LaPlace Transformation and the Frequency
s = sp.symbols('s', positive = True)
omega = sp.symbols('omega', positive = True, real = True)
# Needed for the plant
K, T, L = sp.symbols('K T L', positive = True, real = True)
# Define the error
R = sp.symbols('R', positive = True, real = True)
# Define a FOTD
def FOTD(x,y,z):
return x/(y*s+1)*sp.exp(-z*s)
In [ ]:
# Define the plant
G = FOTD(1,T,L)
# Get the series expansion for first order
GA1 = sp.series(G,s,0,2).removeO().subs(s,sp.I*omega)
# Second order
GA2 = sp.series(G,s,0,3).removeO().subs(s,sp.I*omega)
dG = sp.simplify(sp.Abs(GA1)-sp.Abs(GA2))
sp.solve(dG,omega)
In [ ]:
GA1p = sp.Abs(GA1.removeO().subs(T,10).subs(L,10).subs(s,sp.I*omega))
GA2p = sp.Abs(GA2.removeO().subs(T,10).subs(L,10).subs(s,sp.I*omega))
GA1p, GA2p
In [ ]:
sp.plot((GA1p,(omega,0,.1)),(GA2p,(omega,0,.1)))
In [ ]:
2./((20)**2+10**2)**(0.5)
In [ ]: