Skip to content

TBMT42 Labs: General info and optional getting started exercise

The exercises in this course will primarily be done in Python, but some sections will also be done in MATLAB. Both the Python and MATLAB parts will require that you have a valid C++ compiler installed. Note that you should be able to use the same compiler for both Python and MATLAB (if installed as in the Python instructions). The Python parts will mostly use a package that we have developed: SUND. Mostly, the Python code will be run on your own computer, but you can (in most cases, and in some cases only) run it on Google Colab which is an online Python environment.

We have put together a collection of the software needed and the steps to install both Python and MATLAB here:

Quick installation of most relevant Python packages (if you are already familiar with Python and pip)

Setup an environment if needed. Then run:

For Linux/Mac users:

pip install matplotlib scipy numpy python-dateutil https://isbgroup.eu/sund-toolbox/releases/sund-1.2.18.tar.gz

For Windows users:

pip install matplotlib scipy numpy python-dateutil https://isbgroup.eu/sund-toolbox/releases/sund-1.2.18.tar.gz

Try to install a simple model

Save this simple model file and add the file to your working repository. Now try to install the model using SUND to see that everything works as intended. First, start python by calling python in your terminal (note that mac users might need to call python3 instead).

python

Secondly, run the following bash commands to try to install the "simple_model".

import sund
sund.installModel('simple_model.txt')

If everything worked you should get the print out Model 'simple_model' succesfully installed.

  • Install MATLAB (remember to install a compiler if you didn't do it in the first step)
    • For this course, you need the following MATLAB/MathWorks toolboxes: Simulink, Simscape, Simscape electrical, Curve Fitting Toolbox, Simulink Design Optimization, Image Processing Toolbox, Optimization toolbox, Global optimization toolbox.
  • An editor/IDE that you like writing code in. We like Visual Studio Code (VS Code) if you have no other preference

If you feel like you need to freshen up your coding knowledge, before or during the lab exercise, we recommend that you check out Google's Python class. If you are having troubles with how to use SUND, we recommend that you check our introductory SUND exercise.