Main Content

Build Custom Blocks Using the Three-Phase Electrical Domain

Simscape™ Foundation domains include a three-phase electrical domain. You can use this domain to develop your own custom three-phase blocks using Simscape language. To refer to this domain in your custom component declarations, use the following syntax:

foundation.electrical.three_phase

Additionally, the ThreePhaseExamples library, included in the Simscape Electrical™ product examples, contains a Fundamental library, a Transforms library, and the following custom three-phase components:

  • Permanent Magnet Synchronous Motor

  • Synchronous Machine

  • Synchronous Machine (simplified)

  • Zigzag Transformer

You can use these simplified example models to write your own custom component files.

To open the custom library, at the MATLAB® command prompt, type ThreePhaseExamples_lib. Double-click any block in the library to open its dialog box, and then click the Source code link in the block dialog box to open the Simscape source file for this block in the MATLAB Editor.

To customize the block for your application, edit the source file and save it under another name.

For example, you can create a folder called +MyMachines and save the source files for your customized machines in this folder. Create this folder in your working directory, or in another directory that is on the MATLAB path. Running the ssc_build command on this package generates the MyMachines_lib library model. This library contains all your custom machine blocks and is located in the same directory where you have created the +MyMachines folder. Open the MyMachines_lib library by double-clicking it or by typing its name at the MATLAB command prompt.

For more information on packaging and deploying Simscape component files, see Building Custom Block Libraries.

Things to keep in mind when writing component files:

  • If you create a custom component by modifying an existing one, do not forget to change the name of the component and the name of the resulting block.

  • The component name must be the same as the name of the Simscape file. For example, if you plan to save your component in a file called MyComponent.ssc, change the declaration line in the file:

    component MyComponent
    
  • The comment line immediately following the component declaration (that is, the first line beginning with the % character) defines the name of the block, as it appears in the custom library next to the block icon and at the top of the block dialog box. If you do not specify this comment, then the component name serves as the block name. The block name must be unique within the subpackage (sublibrary) where it resides.

  • Additional comments, below the line specifying the block name, are interpreted as the block description. You do not have to modify them when copying an existing file, but if you change the way the component works, it makes sense to reflect the change in the block description. The block description is for informational purposes only.

  • When modifying component equations, if you introduce additional terms, make sure to add the appropriate variables or parameters to the component declaration section. For example, if you add zero-sequence dynamics to the component equations, declare an additional parameter for stator zero-sequence inductance, L0, and an additional variable for the initial stator zero-sequence magnetic flux linkage.

The Custom Synchronous Machine tutorial shows how you can modify the Synchronous Machine component file and customize it for use in your applications. For more information on writing customized component files, see Custom Components.

Related Topics