-
Notifications
You must be signed in to change notification settings - Fork 0
/
fopdt_model.py
31 lines (29 loc) · 819 Bytes
/
fopdt_model.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
######################################################
# FOPDT model #
######################################################
import numpy as np
import matplotlib.pyplot as plt
Kp = 1 # degC/%
tauP = 130.0 # seconds
thetaP = 13 # seconds (integer)
Tss = 30 # degC (ambient temperature)
Qss = 0 # % heater
dt = 1 #1s
Tpl = []
Tpl.append(30)
i = 1
tMax = 8*60
nSamples = tMax/dt
# Simulate one time step with linear FOPDT model
z = np.exp(-dt/tauP)
Q1 = np.ones(int(nSamples)) * 0
Q1[30:] = 70.0
while (i <= nSamples):
Tpl.append((Tpl[i-1]-Tss) * z + (Q1[max(0, i-int(thetaP)-1)]-Qss)*(1-z)*Kp + Tss)
i += 1
time = np.linspace(0, tMax, int(nSamples))
plt.plot(time, Tpl[0:480])
plt.grid()
plt.xlabel('time (s)')
plt.ylabel('y (output)')
plt.show()