Co-Simulation with Scripting for Changing Thermal Parameters During Simulation

This thread presents three example models that use scripted co-simulation in PLECS to modify thermal or electrical parameters during runtime. All examples demonstrate similar scripting concepts but target different applications.

Rg_change
The simulation runs until a specified current threshold is reached. At that point, the simulation is paused, all states are saved, and the IGBT parameters Rgon and Rgoff are updated. The run then continues until a second (adjusted) current threshold is reached, where it stops again.

thermal_domain_tutorial.plecs (31.1 KB)

simulation_script.py (1.5 KB)

C3M0120090D.xml (7.7 KB)

C3D08060A.xml (2.4 KB)

thermal_chain
Instead of using a current threshold, the thermal chain parameters are overwritten after a fixed simulation time.

buck_converter_with_thermal_model.plecs (29.5 KB)

simulation_script.py (1.3 KB)

IGBT.xml (3.2 KB)

Diode.xml (2.6 KB)

xml_values
Uses an IGBT subsystem with an additional Thermal Chain tab.

  • If left empty, values are taken from the associated XML file.

  • If specified, they override the XML values in the mask initialization (Ctrl+MInitialization).

A script simulates for a given time, then overwrites the thermal chain and continues the run.

buck_converter_with_thermal_model.plecs (36.5 KB)

simulation_script.py (1.4 KB)

IGBT.xml (3.2 KB)

Diode.xml (2.6 KB)

Tip
For easier access to XML files, place them in a subfolder in the same location as the .plecs file, and name the subfolder <MODEL_NAME>_plecs (e.g. thermal_domain_tutorial_plecs).

Remarks
Although these examples focus on thermal simulations, the workflow can be applied to many other use cases. Each model includes both internal Octave scripts and equivalent Python scripts.

2 Likes