Begin Python with TCLab

The Begin Python with TCLab is an introduction and review of basic Python programming with 12 lessons that can be completed in 2-3 hours (15-20 minutes each).

The course is designed to start from no programming experience and guide a self-paced learner through the basics of Python. The 12 modules are IPython notebooks that are run from a Jupyter Notebook. The tutorials start with how to install Anaconda and use the hands-on lab kit. The exercises are interactive and there are solution videos for each module for those who need additional help.

  1. Overview
  2. Debugging
  3. Variables
  4. Printing
  5. Classes and Objects
  6. Functions
  7. Loops
  8. Input
  9. If Statements
  10. Lists and Tuples
  11. Dictionaries
  12. Plotting

After completing this course, there are next courses that build upon the basic Python programming experience.

Temperature Control Lab

The final project is a review of all course material with real data from temperature sensors in the Temperature Control Lab (TCLab). The temperatures are adjusted with heaters that are adjusted with the TCLab. This lab hardware is also used in the Process Dynamics and Control Course and the Dynamic Optimization Course.

TCLab Digital Twin

If no hardware is available, use TCLabModel() in the place of TCLab(). The emulator (digital twin) can be run faster than real-time as shown below:

import tclab
import numpy as np

tclab_hardware = False
if tclab_hardware:
    mlab = tclab.TCLab      # Physical hardware
else:
    speedup = 100           # Emulator (digital twin) speed-up
    mlab = tclab.setup(connected=False, speedup=speedup)

n = 500
tm = np.linspace(0,2*n,n+1)

# Connect to TCLab
with mlab() as lab:
    # set heater values
    lab.Q1(70)
    lab.Q2(20)
    for t in tclab.clock(tm[-1]+1, 2):
        print('Time: ' + str(t) + \
              ' T1: ' + str(round(lab.T1,2)) + \
              ' T2: ' + str(round(lab.T2,2)))

Change tclab_hardware from False to True to use the physical hardware.


Generative AI and the Course Projects

The TCLab projects (A, B, C) are where the whole course pattern comes together: AI-assisted, student-owned. You may use Generative AI for code scaffolding, debugging, plotting, and report drafting - and you remain the engineer of record for every number, plot, and conclusion. Two hard rules:

  • Real data only. Every temperature trace in your report comes from your own TCLab run (or from tclab.TCLabModel(), clearly labeled as simulated if you do not have hardware). Never let an AI invent, smooth, or "reconstruct" data - a fabricated data set in a lab report is a professional integrity violation, not a shortcut.
  • Specify, generate, verify, defend. If AI writes code for you, you write the spec, you test the code against a case you can check by hand, and your report must be able to defend every choice (model form, step size, initial guesses) without "the AI chose it."
"I am starting TCLab Project {A/B/C}: {paste the task list from the notebook}. Do not write the solution. Help me build a workplan: the data runs I need (heater levels, durations, sample rates), the analysis steps, the checks that verify each step (hand calculation, residual, limiting case), and the order to do them. Then ask me 3 questions to make sure I understand the physics of the heater-sensor system before I collect anything."
"Here are my project results: {paste your fit parameters / interpolation comparison / energy-balance ODE vs data plot description}. Do NOT redo the analysis. Review it as a skeptical lab instructor: is the regression form justified by the residuals, does my ODE solution's deviation from measured data look like model error or data error, do my parameter values have physical units and plausible magnitudes, and which single claim in my report is weakest? Then ask me to defend that claim."

Tip: Projects B and C reuse everything: interpolation vs regression (class 18), fsolve for the steady-state energy balance (class 17), and odeint against measured temperatures (class 19). When the transient model misses the data, resist retuning blindly - ask which assumption (lumped mass, constant ambient, radiation ignored) fails first, and say so in the report. Disclose in the report where AI assisted and what you did to verify each assisted step.

What to Turn In (add to each project report)

Beyond the notebook deliverables, add a half page answering:

  1. Where did AI assist (code, debugging, drafting), and what specific verification did you run on each assisted piece?
  2. Show one hand calculation that anchors your results (steady-state energy balance, a single Euler step, or a fit residual) and confirm your code agrees.
  3. From the skeptical-review prompt: what was your weakest claim, and how did you strengthen or qualify it?
  4. If your model and data disagree: which physical assumption do you blame, and what experiment would test it?

Course Information

Excel and VBA

Python

MATLAB

MathCAD

Related Courses

Admin