-
Notifications
You must be signed in to change notification settings - Fork 0
/
tf_response.py
71 lines (62 loc) · 3.21 KB
/
tf_response.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import numpy as np
import control as ct
def buck_response(d: float, vin: float, inductor: float, capacitor: float, resistor: float):
"""
Buck Converter transfer function response.
:param d: duty cycle.
:param vin: input voltage of converter
:param inductor: inductor value of converter
:param capacitor: capacitor value of converter
:param resistor: output resistor value
:return: list of time vector and response of the system
"""
# num_vd = np.array([vin/d])
# den_vd = np.array([(np.sqrt(inductor*capacitor))**2, np.sqrt(inductor*capacitor)/(resistor*np.sqrt(capacitor/inductor)), 1])
# num_vd = np.array([vin/(d*inductor*capacitor)])
# den_vd = np.array([1, 1/(resistor*capacitor), 1/(inductor*capacitor)])
num_vg = np.array([d*vin/(inductor*capacitor)])
den_vg = np.array([1, 1/(resistor*capacitor), 1/(inductor*capacitor)])
sys = ct.tf(num_vg, den_vg)
print('H(s) = ', sys)
t, y = ct.step_response(sys)
return [t, y, sys]
def boost_response(d: float, vin: float, inductor: float, capacitor: float, resistor: float):
"""
Boost Converter transfer function response.
:param d: duty cycle.
:param vin: input voltage of converter
:param inductor: inductor value of converter
:param capacitor: capacitor value of converter
:param resistor: output resistor value
:return: list of time vector and response of the system
"""
# num_vd = np.array([-(vin/(1-d))*(inductor/((1-d)**2)*resistor), vin/(1-d)])
# den_vd = np.array([(np.sqrt(inductor*capacitor)/(1-d))**2, np.sqrt(inductor*capacitor)/((1-d)**2*resistor*np.sqrt(capacitor/inductor)), 1])
# num_vd = np.array([-vin/((1-d)*resistor*capacitor), (vin*(1-d))/(inductor*capacitor)])
# den_vd = np.array([1, 1/(resistor*capacitor), (1-d)**2/(inductor*capacitor)])
num_vg = np.array([(1-d)*vin/(inductor*capacitor)])
den_vg = np.array([1, 1/(resistor*capacitor), (1-d)**2/(inductor*capacitor)])
sys = ct.tf(num_vg, den_vg)
print('H(s) = ', sys)
t, y = ct.step_response(sys)
return [t, y, sys]
def buckboost_response(d: float, vin: float, inductor: float, capacitor: float, resistor: float):
"""
Buck Boost Converter transfer function response.
:param d: duty cycle.
:param vin: input voltage of converter
:param inductor: inductor value of converter
:param capacitor: capacitor value of converter
:param resistor: output resistor value
:return: list of time vector and response of the system
"""
# num_vd = np.array([-(vin/(d*(1-d)**2))*(inductor*d/((1-d)**2)*resistor), vin/(d*(1-d)**2)])
# den_vd = np.array([(np.sqrt(inductor*capacitor)/(1-d))**2, np.sqrt(inductor*capacitor)/((1-d)**2*resistor*np.sqrt(capacitor/inductor)), 1])
# num_vd = np.array([-1/((1-d)**2*resistor*capacitor), 1/(d*inductor*capacitor)])
# den_vd = np.array([1, 1/(resistor*capacitor), (1-d)**2/(inductor*capacitor)])
num_vg = np.array([-((1-d)*d)*vin/(inductor*capacitor)])
den_vg = np.array([1, 1/(resistor*capacitor), (1-d)**2/(inductor*capacitor)])
sys = ct.tf(num_vg, den_vg)
print('H(s) = ', sys)
t, y = ct.step_response(sys)
return [t, y, sys]