Simulations with Python
Notes written by Skill-Lync from the recording · Updated 17 Nov 2026
What this workshop covers
This simulations with Python workshop explains model-based design, plant modelling and the MIL, SIL, PIL and HIL steps used to verify control software. Recorded by Skill-Lync in January 2021, it starts from what simulation is used for in industry: finding components that work within tolerance, testing the software that runs on an embedded controller, recreating real conditions such as a solar inverter's sunrise-to-sunset day in the lab, and rapid control prototyping.
The core of the session is the four-step model-based design loop: model the plant, design the controller, simulate both together, then generate code and deploy it on the target. The instructor separates data-driven plant models (system identification) from physical models built from differential equations, then explains model-in-the-loop, software-in-the-loop, processor-in-the-loop and hardware-in-the-loop testing and why HIL needs a plant model that runs in real time. It ends with job roles and a case study of current control in a grid-tied solar inverter.
Despite the title, no Python code is written or run: the instructor argues that plant models and controllers are just equations and so can be built in Python as well as MATLAB/Simulink. It suits electrical and controls students who want the vocabulary of model-based design before learning a tool.
Chapters
- 0:00 What simulation is used for in electrical and auto work
- 2:44 Model-based design as the current industry trend
- 3:40 Plant models: system identification vs physics
- 5:28 Controller design, closed-loop simulation, deployment
- 8:41 Model, software and processor in the loop
- 10:55 Hardware in the loop and real-time constraints
- 13:43 Job roles and skills for simulation engineers
- 16:03 Case study: grid-tied solar inverter as a HIL plant
- 19:08 Inverter current controller as a Python candidate
Key points from the session
- Model-based design is a four-step loop: model the plant (the thing being controlled, such as an induction motor), synthesise a controller, simulate plant and controller together, then generate code for the target. Controller problems send you back to step two and plant model problems back to step one.
- A data-driven plant model uses system identification: measured inputs and outputs (for a motor, currents, voltages and rpm) are fed to an algorithm that estimates a model reproducing that data. A physical model writes the plant's behaviour as differential equations, keeping only the parts of the system you need.
- Model-in-the-loop tests only the control logic against the simulated plant and records its inputs and outputs. Software-in-the-loop runs the generated code with those recorded signals to check the code behaves like the model. Processor-in-the-loop runs that code on the actual processor in closed loop with the simulated plant.
- Hardware-in-the-loop runs the plant model on a real-time simulator wired to the production controller, so one second of simulated time must finish in one second, unlike an offline Simulink motor run that can take 15-20 minutes for a second or two. The trade-off is plant model accuracy against meeting real time.
- The instructor names MathWorks for model-based design software and dSPACE, Speedgoat, Typhoon HIL and National Instruments for real-time HIL hardware.
- In the grid-tied solar inverter case study the plant is the PV array, the boost converter, the DC link capacitors, the inverter, the LC filter and the grid, while the controller holds the MPPT, boost control and inverter control logic, including a current controller fed back from inverter output current and grid voltage.
- Entry roles listed are HIL engineer, verification engineer, model-based developer, embedded software developer and software engineer in test; the instructor says the entry bar is basic maths, domain knowledge and some programming, and that debugging and problem solving matter most.
What is the difference between MIL, SIL, PIL and HIL testing?
They are successive verification steps in model-based design. MIL checks the controller model against a simulated plant. SIL runs the generated code in simulation. PIL runs that code on the real processor with a simulated plant. HIL connects the real controller to a plant model running on a real-time simulator that behaves like actual hardware.
Can Python be used instead of MATLAB for control simulation?
The instructor argues yes: a physical plant model is a set of differential equations and a controller is mathematics, so both can be written and tested in Python, for example the current controller of a grid-tied inverter. The session explains the method but does not demonstrate any Python code, so treat it as a conceptual introduction.
Why does hardware-in-the-loop need a real-time plant model?
In HIL the physical controller exchanges signals with the simulated plant as if it were real hardware, so the simulation must keep pace with the clock: one second of plant behaviour has to be computed in one second. That forces a balance between a detailed, accurate plant model and one simple enough to run in real time.
Where to go next
A 24 Jan 2021 workshop recording from Skill-Lync on CFD. For a structured course with projects on this topic, see Skill-Lync's mechanical engineering courses.