Please try right-clicking on the PMSM block from the Simscape Electrical library and choose:
Simscape --> Block choice --> Show thermal port
There is already a thermal model builtin to this block.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!