{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lab Assignment 1: Step Test of a First-Order System\n", "\n", "This notebook outlines a process for fitting a first-order model of a heater/sensor assembly to data taken during a step test. The learning goals for this notebook are:\n", "\n", "* Read and plot a previously saved step test data using the `Pandas` library.\n", "* By inspection, identify the gain and dominant time constant of the step test.\n", "* Simulate the response of a first-order model to step test.\n", "* Through iteration, adjust model parameters to fit the first order model to step test data. \n", "* Understand the relationship of model parameters to gain and time constant.\n", "* Determine if a first-order model provides an adequate description of the observed response." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Background and Starter Code" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### First-order lumped model for heater/sensor device.\n", "\n", "We have previously developed a first-order model for one heater/sensor pair on the temperature control lab device. An energy balance gives\n", "\n", "\\begin{align}\n", "C_p\\frac{dT_1}{dt} & = U_a(T_{amb} - T_1) + \\alpha P_1u_1 \\\\\n", "\\end{align}\n", "\n", "where $T_1$ is the average temperature of heater/sensor one, $T_{amb}$ is the ambient temperature of the surroundings. The unknown parameters are the heat capacity $C_p$ and the heat transfer coefficient $U_a$.\n", "\n", "The parameters describing the heat input are as follows:\n", "\n", "* $\\alpha$ is a system calibration constant The measured value of $\\alpha$ is 0.16 milliwatts per unit of $P_1$ per percent.\n", "* $P_1$ is a constant integer value in the range 0 to 255 that controls the operating range of heater 1. It is set using the `tclab` library.\n", "* $u_1$ is a floating point value in the range 0 to 100 that specify the percentage of available power for heater 1.\n", "\n", "For example, if $P_1 = 255$ and $u_1 = 100$, then the total applied power is\n", "\n", "$$\\alpha_1 P_1 u_1 = 0.16 \\times 200 \\times 50 = 4080\\ \\text{milliwatts} = 4.08\\ \\text{watts}$$\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reading previously saved experimental data\n", "\n", "A step test was performed where the temperature control laboratory was initially at steady state at ambient temperature. The heater range $P_1$ was set to 200, then heater 1 was set to 50% of full range with $\\bar{u}_1 = 50$. Temperatures $T_1$ and $T_2$ were recorded for 800 seconds. The has been saved to the course Github repository where it can be located with the url\n", "\n", "[https://raw.githubusercontent.com/jckantor/CBE30338-book/main/tclab/data/tclab-data.csv](\"https://raw.githubusercontent.com/jckantor/CBE30338-book/main/notebooks/data/step-test-data.csv\")\n", "\n", "The following cell reads the step test data using the `Pandas` library. The data is stored in a Pandas DataFrame called `data`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | T1 | \n", "T2 | \n", "Q1 | \n", "Q2 | \n", "
---|---|---|---|---|
Time | \n", "\n", " | \n", " | \n", " | \n", " |
0.00 | \n", "23.81 | \n", "23.48 | \n", "50.0 | \n", "0.0 | \n", "
1.00 | \n", "23.81 | \n", "23.48 | \n", "50.0 | \n", "0.0 | \n", "
2.00 | \n", "23.81 | \n", "23.48 | \n", "50.0 | \n", "0.0 | \n", "
3.00 | \n", "23.81 | \n", "23.48 | \n", "50.0 | \n", "0.0 | \n", "
4.01 | \n", "23.81 | \n", "23.48 | \n", "50.0 | \n", "0.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
796.00 | \n", "54.75 | \n", "34.44 | \n", "50.0 | \n", "0.0 | \n", "
797.00 | \n", "54.75 | \n", "34.44 | \n", "50.0 | \n", "0.0 | \n", "
798.01 | \n", "54.75 | \n", "34.76 | \n", "50.0 | \n", "0.0 | \n", "
799.00 | \n", "54.75 | \n", "34.76 | \n", "50.0 | \n", "0.0 | \n", "
800.00 | \n", "54.75 | \n", "34.76 | \n", "50.0 | \n", "0.0 | \n", "
800 rows × 4 columns
\n", "