import matplotlib.pyplot as plt
import pandas as pd
from tclab import TCLab, clock, Historian, Plotter
Step Testing
Run the next cell if you only want to simulate TCLab
from tclab import setup
= setup(connected=False, speedup=20) TCLab
Executing the Step Test
Verify an Initial Steady State
A step test assumes the system is initially at steady state. In the case of the Temperature Control Lab, the initial steady with no power input would be room temperature. It generally takes 10 minutes or more to reach steady state. We’ll do a measurement to confirm the initial temperature.
= TCLab()
lab print(lab.T1, lab.T1)
lab.close()
TCLab version 1.0.0
Simulated TCLab
20.949499999999997 20.949499999999997
TCLab Model disconnected successfully.
Conduct the Experiment
# experimental parameters
= 50
Q1 = 800
tfinal
# perform experiment
with TCLab() as lab:
= Historian(lab.sources)
h = Plotter(h, tfinal)
p 0)
lab.Q1(for t in clock(tfinal):
p.update(t) lab.Q1(Q1)
TCLab Model disconnected successfully.
Verify the experimental data
h.columns
['Time', 'T1', 'T2', 'Q1', 'Q2']
try:
= h.t
t = h.T1
T1 = h.T2
T2 = h.Q1
Q1 = h.Q2
Q2 except:
= h.fields
t, T1, T2, Q1, Q2
plt.plot(t, T1, t, T2, t, Q1, t, Q2)'T1','T2','Q1','Q2'])
plt.legend(['time / seconds')
plt.xlabel( plt.grid()
Convert to a DataFrame
import pandas as pd
= pd.DataFrame([t, T1, T2, Q1]).T
df = ['Time', 'T1', 'T2', 'Q1']
df.columns = df.set_index('Time')
df =True) df.plot(grid
Save DataFrame as a .csv file
'Step_Test_Data.csv') df.to_csv(
Verify the data file
'Step_Test_Data.csv').set_index('Time').plot(grid=True) pd.read_csv(
df.head()
T1 | T2 | Q1 | |
---|---|---|---|
Time | |||
0.00 | 20.6272 | 20.6272 | 0.0 |
9.00 | 20.9495 | 20.9495 | 50.0 |
10.00 | 20.9495 | 20.9495 | 50.0 |
12.01 | 20.9495 | 20.9495 | 50.0 |
13.00 | 20.9495 | 20.9495 | 50.0 |
df.tail()
T1 | T2 | Q1 | |
---|---|---|---|
Time | |||
795.01 | 50.6011 | 25.784 | 50.0 |
796.00 | 50.6011 | 25.784 | 50.0 |
798.01 | 50.6011 | 25.784 | 50.0 |
799.01 | 50.6011 | 25.784 | 50.0 |
800.01 | 50.6011 | 25.784 | 50.0 |