None Notebook

This notebook contains material from cbe30338-2021; content is available on Github.

< 2.3 First Order Model for a Single Heater | Contents | Tag Index | 3.0 Feedback Control >

Open in Colab

Download

2.4 Model Identification for the Temperature Control Lab

Models are essential for feedback control. It may be difficult to understand where and how the model was incorporated into the control system design, and the model may be just a simplistic cause-and-effect understanding of process operation, but be assured that somewhere in the control system is an embedded understanding of process operation.

The notebook is deep dive in creating models for the dynamic response of the Temperature Control Lab to power inputs and external disturbances. The survey of models include:

2.4.1 Accessing experimental data

Data acquired through normal process operation or experimentation will normally be accessed from a process database. Here we demonstrate reading data stored previously stored in a .csv file by a process historian.

2.4.1.1 Read data into a Pandas DataFrame

Pandas is one of the most important and widely used Python libraries for data analysis and manipulation. Here we use the library to access a .csv file containing previously collected data from a step test of the Temperature Control Lab.


Study Question: "Break free from Excel". This exercise demonstrates a technique that you may find useful in your other coursework, particularly the Junior and Senior lab courses. The code cell below contains a link that will export data stored in a Google Sheet as a .csv file. The file was previously created and share access set for viewing by anyone with a link. Use the Pandas library to read the data into a data frame, display the data table, set the data frame index to the column labeled Time, and plot the data.


2.4.2 Comparing experimental data to model predictions

2.4.3 Empirical Modeling

2.4.3.1 First order gain and time constant

We previously derived a model for the response T1 of the Temperature Control Lab to a constant input $\bar{u}_1$ as

$$\frac{dT_1}{dt} = -\frac{1}{\tau}(T_1 - T_{amb})+ \frac{K}{\tau}\bar{u}_1$$

where the gain $K$ and the time constant $\tau$ are given by the

\begin{align} \tau = \frac{C_p}{U_a} \qquad K = \frac{\alpha P_1}{U_a} \end{align}

Assuming the system starts with an initial condition $T_1(0) = T_{amb}$, the solution to the differential equation of the system is

\begin{align} T_1(t) & = T_{amb} + K\bar{u}_{1}(1 - e^{-(t-t_0)/\tau}) \end{align}

Given estimates of $K$ and $\tau$, we can construct the preedicted response and compare to the experimental observed response.


Study Question: By trial and error, attempt to find values for the gain $K$ and time constant $\tau$ that provide a useful prediction of the experimentally measured response.


Obviously, it would useful to have some way of finding 'optimal' values for $K$ and $\tau$. In this cell we use the least_squares routine from scipy.optimize to find optimal values of the parameters.

2.4.3.2 First order with time delay

A first-order with time delay (or 'dead time') are frequenty used in process control to model the delitreous

\begin{align} T_1(t) & = T_{amb} + K\bar{u}_{1}(1 - e^{-(t-t_{delay})/\tau}) \end{align}$$\frac{dT_1}{dt} = -\frac{1}{\tau}T_1 + \frac{K}{\tau}u_1(t-t_{delay}) + \frac{1}{\tau}T_{amb}$$

2.4.4 First order Energy balance model

We previously developed a model comprising a single differential equation for the temperature response of a heater/sensor assembly. Given $u_1(t)$ and an initial condition $T_{amb}$, the heater/sensor temperature is given by

$$\frac{dT_1}{dt} = -\frac{U_a}{C_p}T_1 + \frac{\alpha P_1}{C_p} u_1(t) + \frac{U_a}{C_p}T_{amb}$$

Several of the key parameters are known. These include $\alpha$ which was determined by direct measurement, $P1$ which is set in the Arduino firmware. We assume the ambient temperature $T_{amb}$ is measurable and known.

The unknown parameters are the heat capacity $C_p$ and heat transfer coefficient $U_a$. We wish to find values of the unknown parameters that allow the model response to mimic responses measured by experiment.

Here we show a simulation of this model.

The unknown parameters are the heat capacity $C_p$ and heat transfer coefficient $U_a$. We wish to find values of the unknown parameters that allow the model response to mimic responses measured by experiment.

Here we show a simulation of this model.

2.4.5 Find the best fit

2.4.6 Second-order model

2.4.6.1 Dynamics of the Heater/Sensor System

The previous results are not yet fully satisfactory. We're still missing the initial 'lag' in response of the measured temperature.

For this third model, we consider the possibility that the heater and sensor may not be at the same temperature. In other words, that the heater/sensor assembly is not at a uniform temperature. To account for this possibility, we introduce $T_{H,1}$ to denote the temperature of heater one and $T_{S,1}$ to denote the temperature of the corresponding sensor. We'll further assume that sensor mainly exchanges heat with the heater, and the dominant heat transfer to the surroundings is through the heat sink attached to the heater.

This motivates a model

\begin{align} C^H_p\frac{dT_{H,1}}{dt} & = U_a(T_{amb} - T_{H,1}) + U_b(T_{S,1} - T_{H,1}) + \alpha P_1u_1\\ C^S_p\frac{dT_{S,1}}{dt} & = U_b(T_{H,1} - T_{S,1}) \end{align}

where $C^H_p$ and $C^S_p$ are the gross heat capacities of the heater and sensor, respectively, and $U_b$ is a new heat transfer coefficient characterizing the exchange of heat between the heater and sensor.

\begin{align} \frac{dT_{H,1}}{dt} & = -\frac{U_a+U_b}{C^H_p}T_{H,1} + \frac{U_b}{C^H_p}T_{S,1} + \frac{\alpha P_1}{C^H_p}u_1 + \frac{U_a}{C^H_p}T_{amb}\\ \frac{dT_{S,1}}{dt} & = \frac{U_b}{C^S_p}(T_{H,1} - T_{S,1}) \end{align}

Where measured temperature, that is, the temperature recorded by the Arduino, $T_1$ is given by

$$T_1 = T_{S,1}$$

2.4.6.2 Best fit

2.4.7 Fourth-Order Multi-Input Multi-Output Model

2.4.7.1 Model derivation

\begin{align} C^H_p\frac{dT_{H,1}}{dt} & = U_a(T_{amb} - T_{H,1}) + U_b(T_{S,1} - T_{H,1}) + U_c(T_{H,2}-T_{H,1}) + \alpha P_1u_1\\ C^S_p\frac{dT_{S,1}}{dt} & = U_b(T_{H,1} - T_{S,1}) \\ C^H_p\frac{dT_{H,2}}{dt} & = U_a(T_{amb} - T_{H,2}) + U_b(T_{S,2} - T_{H,2}) + U_c(T_{H,1}-T_{H,2}) + \alpha P_2 u_2\\ C^S_p\frac{dT_{S,2}}{dt} & = U_b(T_{H,2} - T_{S,2}) \end{align}

where

\begin{align} T_1 & = T_{S,1} \\ T_2 & = T_{S,2} \end{align}

2.4.7.2 Standard form

\begin{align} \frac{dT_{H,1}}{dt} & = -(\frac{U_a+U_b+U_c}{C^H_p})T_{H,1} + \frac{U_b}{C^H_p}T_{S,1} + \frac{U_c}{C^H_p}T_{H,2} + \frac{\alpha P_1}{C^H_p}u_1 + \frac{U_a}{C^H_p}T_{amb}\\ \frac{dT_{S,1}}{dt} & = \frac{U_b}{C^S_p}(T_{H,1} - T_{S,1}) \\ \frac{dT_{H,2}}{dt} & = -(\frac{U_a+U_b+U_c}{C^H_p})T_{H,2} + \frac{U_b}{C^H_p}T_{S,2} + \frac{U_c}{C^H_p}T_{H,1} + \frac{\alpha P_2}{C^H_p}u_2 + \frac{U_a}{C^H_p}T_{amb}\\ \frac{dT_{S,2}}{dt} & = \frac{U_b}{C^S_p}(T_{H,2} - T_{S,2}) \end{align}

where

\begin{align} T_1 & = T_{S,1} \\ T_2 & = T_{S,2} \end{align}

2.4.8 Lab Assignment 2: Identification of a Multi-input, Multi-output Model for the Temperature Control Laboratory

Create one or more notebooks to show your results for the following exercises. The model you develop in this exercise will be used in the remainder of the semester for simulation and control design for your copy of the Temperature Control Laboratory.

2.4.8.1 Exercise 1.

Write two python functions, one called u1(t) and the other u2(t), that create the following input signals that will be used to test the Temperature Control Lab.

Develop these functions, and plot the results for t=-100 to t=1800 (yes, beyond the end of the experiment) showing correct performance.

2.4.8.2 Exercise 2.

Use the functions created in Exercise 1 to obtain experimental data for your Temperature Control Lab. This will take some time (about 1/2 hour if everything works perfectly). Record T1, T2, Q1, Q2 using the Historian. Be careful to ...

Save this data to a .csv file.

2.4.8.3 Exercise 3.

To avoid overwriting or damaging the data you collected in Exercise 2, create a separate notebook for model fitting. Fit two models to your data:

< 2.3 First Order Model for a Single Heater | Contents | Tag Index | 3.0 Feedback Control >

Open in Colab

Download