def testPade(self):
     """Call pade()"""
     pade(1, 1)
     pade(1, 2)
     pade(5, 4)
"""

from control import matlab
import numpy as np

Kt = 10  # Steady-State gain
J = 25  # Time Constant
Cm = 4  # Dead time ここでは使用しない
num = [Kt]  # 分子の係数
dem = [J, 1]  # 分母の係数

P = matlab.tf(num, dem)

#pade近似を表現,前提として5秒のむだ時間を設定
#まずパデ近似の分子、分母を求める
num2, dem2 = matlab.pade(5,2)
num4, dem4 = matlab.pade(5,4)
num6, dem6 = matlab.pade(5,6)
num8, dem8 = matlab.pade(5,8)
num10, dem10 = matlab.pade(5,10)
#pade近似の分子、分母を伝達関数の形に変換
P2 = matlab.tf(num2,dem2)
P4 = matlab.tf(num4,dem4)
P6 = matlab.tf(num6,dem6)
P8 = matlab.tf(num8,dem8)
P10 = matlab.tf(num10,dem10)
#最後にstep応答を行う
time= 100
t = np.linspace(0,time,1000)
y2,T = matlab.step(P2,t)
y4,T = matlab.step(P4,t)
Exemple #3
0
import numpy as np
from control import matlab
from matplotlib import pyplot as plt
from matplotlib import animation

m = 1000
c = 100
G = matlab.tf([1], [m, c])

t_delay = 0.5
n_pade = 10
(num_pade, den_pade) = matlab.pade(t_delay, n_pade)
G_delay = matlab.tf(num_pade, den_pade)

G = matlab.series(G_delay, G)

# Kp = 2000
# Ki = 0
# Kd = 0
# num = [Kd, Kp, Ki]
# den = [1, 0]
# K = matlab.tf(num, den)
#
# sys = matlab.feedback(K*G, 1)

t = np.linspace(0, 20, 2000)
target = []
for i in t:
    if i < 2.0:
        target.append(0.0)
    else:
Exemple #4
0
#parameters
Kc = .52  #controller gain
td = 0  #controller time constant, realized this was not needed for this model
Tf = 1  #throughput time delay, from when ordered to when arrived
d = 5770  #demand
r = 11270  #production schedule to leave 5500 in inventory at all time

taus = .000000000001  #used for 'f' to set s very small so it doesnt matter
f = control.tf(
    [1], [taus, 1]
)  #transfer function to get the units to balance, basically equals 1 yest gets the 's' values to be equal on num and denom

# transfer functions
K = Kc * control.tf([td, 1], [1])  #PD controller transfer function

num, den = control.pade(Tf, 3)
P = control.tf(num, den)  #time delay transfer function

Kv = control.tf([1], [1, 0])  #step response transfer function

Hud = ((K * Kv) / (1 + K * P * Kv)
       )  #Transfer function from the production to the demand (disturbance)
Hur = (K * f / (1 + K * P * Kv)
       )  #transfer function from the production to set point

Ys = ((P * K * Kv) /
      (1 + P * K * Kv)) * r - (1 / (1 + P * K * Kv)) * d  #Change in production
Us = ((K * Kv) /
      (1 + K * P * Kv)) * r - (K * Kv /
                               (1 + K * P * Kv)) * d  #change in inventory