In [6]:
#Import the needed Packages
import pandas as pd
import numpy as np
# Import Plotly
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
from plotly.graph_objs import *
import plotly
plotly.offline.init_notebook_mode()
# Define the TUBS Colorscale for 10 Colors
# TUBS Rot, Gelb, Orange, Hellgrün, Grün, Dunkelgrün, Hellblau, Blau, Dunkelblau, Violett
TUBScolorscale=['rgba(190,30,60,0.9)',
'rgba(255,200,42,0.9)',
'rgba(225,109,0,0.9)',
'rgba(172,193,58,0.9)',
'rgba(109,131,0,0.9)',
'rgba(0,83,74,0.9)',
'rgba(102,180,211,0.9)',
'rgba(0,112,155,0.9)',
'rgba(0,63,87,0.9)',
'rgba(138,48,127,0.9)']
# Define the height & width of the plots
height = 400 # approx 11 cm
width = 600 # approx 15 cm
# Define the Font size
FontSize = 12
In [7]:
# Load the Data
FanTemp = pd.read_excel("KTL_Fedele_Minimal.xlsx", sheetname=0)
FanPres = pd.read_excel("KTL_Fedele_Minimal.xlsx", sheetname=1)
ValTemp = pd.read_excel("KTL_Fedele_Minimal.xlsx", sheetname=2)
ValPres = pd.read_excel("KTL_Fedele_Minimal.xlsx", sheetname=3)
In [8]:
# Get the Temperature Data
T = FanTemp.columns.values
# Get the Gain
K1 = FanTemp.loc['K'].values
K2 = FanPres.loc['K'].values
K3 = ValTemp.loc['K'].values
K4 = ValPres.loc['K'].values
# Get the Time Constants
T1 = FanTemp.loc['T'].values
T2 = FanPres.loc['T'].values
T3 = ValTemp.loc['T'].values
T4 = ValPres.loc['T'].values
# Get the Time Delay
L1 = FanTemp.loc['L'].values
L2 = FanPres.loc['L'].values
L3 = ValTemp.loc['L'].values
L4 = ValPres.loc['L'].values
In [19]:
# Define the Plot Layout
layout1 = dict(autosize = False,
width = width, # approx 15 cm
height = height, # approx 11 cm
font=dict(family='Nexus'), # TUBS Font
# Change here for title etc
yaxis = dict(
zeroline = False,
title = 'System Gain',
#range = [1.2,1.35],
autotick = True,
ticks='outside',
#tick0 = 1.2,
#dtick = 0.05,
showgrid = True ),
xaxis = dict(
zeroline = False,
title = 'Operating points in [K]',
range = [272,308],
autotick = False,
ticks='outside',
tick0 = 273,
dtick = 2,
showgrid = True
),
legend=dict(
orientation = "h",
x = 0.1,
y = 1.3,
traceorder='normal',
font=dict(
family='Nexus',
size=FontSize,
color='#000'
)#,
#bgcolor='#E2E2E2',
#bordercolor='#FFFFFF',
#borderwidth=2
)
)
In [20]:
# Make a Scatter Plot of the Gains
trace1 = Scatter(x = T, y = K1,
name ='Fan to Temperature',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[0],
width = 1
#dash = 'dash'
))
trace2 = Scatter(x = T, y = K2,
name ='Fan to Pressure',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[1],
width = 1
#dash = 'dash'
))
trace3 = Scatter(x = T, y = K3,
name ='Valve to Temperature',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[2],
width = 1
#dash = 'dash'
))
trace4 = Scatter(x = T, y = K4, name ='Valve to Pressure', mode = 'lines+markers', line = dict(
color = TUBScolorscale[3],
width = 1
#dash = 'dash'
))
fig = dict(data=[trace1, trace2, trace3, trace4], layout=layout1)
iplot(fig)
In [21]:
# Define the Plot Layout
layout2 = dict(autosize = False,
width = width, # approx 20 cm
height = height, # approx 11 cm
font=dict(family='Nexus'), # TUBS Font
# Change here for title etc
yaxis = dict(
zeroline = False,
title = 'System Time Constant [s]',
#range = [1.2,1.35],
autotick = True,
ticks='outside',
#tick0 = 1.2,
#dtick = 0.05,
showgrid = True ),
xaxis = dict(
zeroline = False,
title = 'Operating points in [K]',
range = [272,308],
autotick = False,
ticks='outside',
tick0 = 273,
dtick = 2,
showgrid = True
),
legend=dict(
x = 0,
y = 1.3,
orientation = "h",
traceorder='normal',
font=dict(
family='Nexus',
size=FontSize,
color='#000'
)
)
)
In [22]:
# Make a Scatter Plot of the Time Constants
trace1 = Scatter(x = T, y = T1,
name ='Fan to Temperature',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[0],
width = 1
#dash = 'dash'
))
trace2 = Scatter(x = T, y = T2,
name ='Fan to Pressure',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[1],
width = 1
#dash = 'dash'
))
trace3 = Scatter(x = T, y = T3,
name ='Valve to Temperature',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[2],
width = 1
#dash = 'dash'
))
trace4 = Scatter(x = T, y = T4,
name ='Valve to Pressure',
mode = 'lines+markers', line = dict(
color = TUBScolorscale[3],
width = 1
#dash = 'dash'
))
fig = dict(data=[trace1, trace2, trace3, trace4], layout=layout2)
iplot(fig)
In [27]:
# Define the Plot Layout
layout3 = dict(autosize = False,
width = width,
height = height,
font=dict(family='Nexus', size = FontSize), # TUBS Font
# Change here for title etc
yaxis = dict(
zeroline = False,
title = 'System Time Delay [s]',
#range = [1.2,1.35],
autotick = True,
ticks='outside',
#tick0 = 1.2,
#dtick = 0.05,
showgrid = True ),
xaxis = dict(
zeroline = False,
title = 'Operating points in [K]',
range = [272,308],
autotick = False,
ticks='outside',
tick0 = 273,
dtick = 2,
showgrid = True
),
legend=dict(
x = 0,
y = 1.3,
orientation = "h",
traceorder='normal',
font=dict(
family='Nexus',
size=FontSize,
color='#000'
)
)
)
In [28]:
# Make a Scatter Plot of the Time Delays
trace1 = Scatter(x = T, y = L1,
name ='Fan to Temperature',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[0],
width = 1
#dash = 'dash'
))
trace2 = Scatter(x = T, y = L2,
name ='Fan to Pressure',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[1],
width = 1
#dash = 'dash'
))
trace3 = Scatter(x = T, y = L3,
name ='Valve to Temperature',
mode = 'lines+markers',
line = dict(
color = TUBScolorscale[2],
width = 1
#dash = 'dash'
))
trace4 = Scatter(x = T, y = L4,
name ='Valve to Pressure',
mode = 'lines+markers', line = dict(
color = TUBScolorscale[3],
width = 1
#dash = 'dash'
))
fig = dict(data=[trace1, trace2, trace3, trace4], layout=layout3)
iplot(fig)
In [29]:
# Define the Plot Layout
layout4 = dict(autosize = False,
width = width,
height = height,
font=dict(family='Nexus'), # TUBS Font
# Change here for title etc
yaxis = dict(
zeroline = False,
title = 'System Coupling',
#range = [1.2,1.35],
autotick = True,
ticks='outside',
#tick0 = 1.2,
#dtick = 0.05,
showgrid = True ),
xaxis = dict(
zeroline = False,
title = 'Operating points in [K]',
range = [272,308],
autotick = False,
ticks='outside',
tick0 = 273,
dtick = 2,
showgrid = True
),
legend=dict(
x = 0,
y = 1.3,
orientation = "h",
traceorder='normal',
font=dict(
family='Nexus',
size=12,
color='#000'
)
)
)
In [41]:
# Make a Scatter Plot of the Couplings
trace1 = Scatter(x = T, y = K2*(L1+T1-L2-T2),
line = dict(
color = TUBScolorscale[0],
width = 1
#dash = 'dash'
),
name ='Valve to Temperature',
mode = 'lines+markers')
trace2 = Scatter(x = T, y = K3*(L4+T4-L3-T3),
line = dict(
color = TUBScolorscale[1],
width = 1
#dash = 'dash'
),
name ='Fan to Pressure',
mode = 'lines+markers')
fig = dict(data=[trace1, trace2], layout=layout4)
iplot(fig)
In [33]:
# Make a Scatter Plot of the Couplings - Aström
trace1 = Scatter(x = T, y = (K1*K2/(K1*K4-K2*K3))*(L1+T1-L2-T2), name ='Valve to Temperature', mode = 'lines+markers')
trace2 = Scatter(x = T, y = (K3*K4/(K1*K4-K2*K3))*(L4+T4-L3-T3), name ='Fan to Pressure', mode = 'lines+markers')
fig = dict(data=[trace1, trace2], layout=layout4)
iplot(fig)
In [34]:
# Define the Plot Layout
layout5 = dict(autosize = False,
width = width,
height = height,
font=dict(family='Nexus'), # TUBS Font
# Change here for title etc
yaxis = dict(
zeroline = False,
title = 'Controller Gain',
#range = [1.2,1.35],
autotick = True,
ticks='outside',
#tick0 = 1.2,
#dtick = 0.05,
showgrid = True ),
xaxis = dict(
zeroline = False,
title = 'Operating points in [K]',
range = [272,308],
autotick = False,
ticks='outside',
tick0 = 273,
dtick = 2,
showgrid = True
),
legend=dict(
x = 0,
y = 1.3,
orientation = "h",
traceorder='normal',
font=dict(
family='Nexus',
size=12,
color='#000'
)
)
)
In [35]:
# Define the controller proportional and integral gain
P1 = 0.15/K1 + (0.35 - (L1*T1)/(L1+T1)**2)*T1/K1/L1
P2 = 0.15/K4 + (0.35 - (L4*T4)/(L4+T4)**2)*T4/K4/L4
I1 = 0.35*L1+13*L1*T1**2/(T1**2+12*L1*T1+7*L1**2)
I2 = 0.35*L4+13*L4*T4**2/(T4**2+12*L4*T4+7*L4**2)
In [36]:
# Make a Scatter Plot of the Couplings - Aström
trace1 = Scatter(x = T, y = P1, name ='Valve Controller', mode = 'lines+markers')
trace2 = Scatter(x = T, y = P2, name ='Fan Controller', mode = 'lines+markers')
fig = dict(data=[trace1, trace2], layout=layout5)
iplot(fig)
In [37]:
# Make a Scatter Plot of the Couplings - Aström
trace1 = Scatter(x = T, y = I1, name ='Valve Controller', mode = 'lines+markers')
trace2 = Scatter(x = T, y = I2, name ='Fan Controller', mode = 'lines+markers')
fig = dict(data=[trace1, trace2], layout=layout5)
iplot(fig)
In [42]:
len(T)
Out[42]:
In [ ]: