DSIM API for Use with MATLAB
DSIM provides Application Programming Interface (API) functions that can be accessed through MATLAB, covering various stages such as circuit modification, simulation control, and data post-processing. These interface functions enable users to leverage MATLAB's M language for tasks such as parameter design, multi-scenario testing, and the development of custom features.
DSIM API (MATLAB) Supports the Following Interfaces:
The following demonstrates how to perform PI parameter sweep for a three-phase PWM rectifier circuit using the DSIM API (MATLAB). The example shows parameter sweep of the PI module under a specific operating condition, where the proportional gain Kp is scanned over 8 sets (from 0.005 to 3), and the time constant T is scanned over 7 sets (from 1e-3 to 500e-3), resulting in 56 simulation runs (parameter settings are shown in the picture below).
How to Perform PI Parameter Sweep Using DSIM API (MATLAB)
This example uses a three-phase PWM rectifier circuit and employs a dual-loop control with a voltage outer loop and a current inner loop. The schematic is shown below. In the example, the API is used to perform a parameter sweep on the outer loop PI parameters, and the simulation results of the rectifier output DC voltage are analyzed. The inner loop parameters are fixed: proportional gain Kp=0.005 and time constant T=1e−3.
The MATLAB script is executed on a personal computer, and the parameter sweep process (56 sets of parameters) can be completed within one minute. The execution results are shown below. From the results, it can be observed that after the inner loop PI parameters are determined, when the time constant T exceeds 50e−3, the impact on the DC output voltage becomes negligible, as the time constant is too slow. Therefore, a time constant of T=10e−3 is chosen. Once the time constant T is determined, if the proportional gain Kp is too small, it may lead to instability or slow response speed. On the other hand, if Kp is too large, it may cause instability or excessive overshoot. To achieve an optimal balance between overshoot and response speed, a proportional gain of Kp=0.5 is chosen.
Analysis of PI Parameter Sweep Results Using DSIM API (MATLAB)
|
Creation and release of handle
|
Create handle from schematic; Set simulation schematic; Release handle
|
|
Schematic operations
|
Get element parameter value; Set element parameter value; Get parameter file content; Set parameter file content; Get subcircuit variable value; Set subcircuit variable value; Get simulation control parameter; Modify simulation control parameter; Save schematic
|
|
Simulation process
|
Get simulation curve; Set output curve; Start simulation; Pause simulation; Continue simulation; Cancel simulation; Get Simulation Status
|
|
Data operation
|
Get curve name; Get specified curve data; Get all curve data; Delete specified curve data; Delete all curve data; Delete curve file
|
| Other |
View schematic; View curve; Get curve file data
|
For more information, please refer to "Tutorial - DSIM API Document (MATLAB)". (The tutorial is attached at the bottom of this page for download.)
* Tutorial-DSIM API Document (MATLAB), and script for MATLAB:
-
2025-12-26 Tutorial - DSIM API Document(MATLAB).pdf
끂26 299.74 KB -
2024-12-27 PI_sweep_en.m.zip
끂2 2.99 KB
The sweep frequency procedure is as follows: for each time constant T(i) and different proportional gains Kp, simulations are performed. After completing the simulation for one time constant, the next time constant T(i+1) is used with different proportional gains for further simulations.
For each set of PI parameters, the following steps need to be performed on the circuit: create handle by file, set the proportional gain Kp and time constant T, save the schematic as a new file, set the output curve, and start the simulation.