Partition Simscape Models Containing a Large Network into Multiple Smaller Networks
This example shows how to partition a solar power inverter model that contains a single, large Simscape™ network into multiple networks. After you partition the network, you can run the Simscape HDL Workflow Advisor to generate the HDL implementation model. To learn how you run the Advisor for the model, see Generate HDL Code for Simscape Models with Multiple Networks.
Why Partition a Simscape Network
When your Simscape model contains many switching elements, the state-space representation can contain a large number of modes. The Simscape HDL Workflow Advisor simulates the Simscape model to calculate the number of modes that are relevant. Certain Simscape models can have a large number of modes that are relevant. The generated HDL implementation model for such a large design can consume a significantly large number of resources, and the generated HDL implementation md may even fail to synthesize on the target FPGA device. To reduce the number of modes, you can partition the Simscape network in your model into multiple networks, and then run the Simscape HDL Workflow Advisor.
Solar Power Inverter Model with Single Network
To open the solar power inverter example model, run:
open_system('sschdlexSolarInverterSingleNetworkExample') set_param('sschdlexSolarInverterSingleNetworkExample', 'SimulationCommand', 'Update')
The model consists of four parts: solar panel, boost controller, inverter controller, and a boost converter and full bridge inverter. The solar panel is modeled in Simulink® by using lookup tables. The boost controller and inverter controller provide the control signals for the boost converter and the full bridge inverter which is an H-bridge.
To see the boost converter and inverter, open the Network subsystem.
Run Simscape HDL Workflow Advisor
1. To open the Simscape HDL Workflow Advisor for the model, enter:
2. Run the workflow to the Extract discretize equations task. You see that the state-space representation uses around
86 modes, which is a large number of modes.
Such a large number of modes can consume a significantly large number of hardware resources, and may even cause the DUT subsystem in the HDL implementation model to fail to synthesize on the target FPGA device.
Generate HDL Implementation Model and View Resource Consumption
To see the resource consumption:
1. Run the Generate implementation model task. After the task passes, you see a link to the HDL implementation model
gmStateSpaceHDL_sschdlexSolarInverterSingle. Click the link to open the HDL implementation model.
The model contains an HDL Subsystem block that models the state-space equations for the Simscape network. Open the generated HDL implementation model
2. Enable generation of the resource utilization report.
hdlset_param('gmStateSpaceHDL_sschdlexSolarInverterSingle', 'ResourceReport', 'on')
3. Run the
makehdl function to generate code for the HDL Subsystem block.
4. As you generate HDL code, open the Code Generation Report. The resource utilization report indicates a large amount of multipliers, adders, and registers that might be consumed on the target FPGA device.
Partition Solar Inverter Network into Multiple Simscape Networks
To reduce the number of modes, you can partition the Simscape network inside the Network subsystem into two Simscape networks. To partition the network into multiple networks you can use a Network Coupler (Current-Voltage) (Simscape) block. The Network Coupler (Current-Voltage) block provides a starting point for you to split a Simscape™ network into two coupled networks at an electrical connection.
1. Identify the boundary for partitioning the network into multiple networks. To produce a Simscape model that contains multiple networks and effectively reduces the number of modes in the state-space representation, choose a boundary that produces identical or near identical partitions. That is, the number of switching elements on either side of the boundary are identical or nearly identical.
For the solar power inverter, you can choose the DC link capacitor between the H-bridge inverter and the boost converter as the boundary for partitioning the network.
2. After you partition the network, prepare the modified Simscape model for compatibility with the Simscape HDL Workflow Advisor. Use a Solver Configuration block for each of the network as the Simscape HDL Workflow Advisor uses the Solver Configuration block to identify each unique network in your Simscape model.
Solar Power Inverter Model with Multiple Networks
The single network model is now partitioned into multiple networks. To open the model containing multiple networks, enter:
To learn how you run the Simscape HDL Workflow Advisor and generate HDL code for this model, see Generate HDL Code for Simscape Models with Multiple Networks.