By Justin Eladio Bueno MG Research Assistant

MATLAB OpenDSS COM Interface

When it comes to analyzing power distribution systems, OpenDSS is one of the most useful tools for comprehensive electrical power system simulation. OpenDSS is an open-source software package that supports rms sinusoidal steady-state analysis, which is commonly used on electric utility power distribution systems [1]. The models implemented in this tool for electrical networks are quasi-static, which means that the analysis does not consider the transients resulting in a much faster simulation, but less precise, in comparison to models based on electromagnetic transients. Another disadvantage of OpenDSS simulation is restricted versatility because the diversity of tools within the software is limited.

Figure 1. OpenDSS – Core Attributes

On the other hand, an example of transient-based modelling is MATLAB-Simulink simulations. This type of simulation not only is more precise, it also is more open to the inclusion of multiple algorithms, such as a fault detection power system simulation. Nonetheless, as the magnitude of the network increases the simulation becomes much slower, as it is computationally costly, and the complexity of the simulation becomes hard to comprehend. This means that there is a necessity, combining the benefits of both types of simulation to get a sufficiently fast, precise and versatile simulation tool. Here is where the MATLAB-OpenDSS COM interface comes into play.

Matlab-OpenDSS COM
Figure 2. Co-simulation of MATLAB and OpenDSS [Source: [9]]

The MATLAB-OpenDSS COM interface comes from one of the main characteristics of the OpenDSS software; it is customizable for user-defined applications. Based on this attribute, custom processes can be modeled using modern programming languages, in which MATLAB is included [2]. To sum it all concisely, the MATLAB-OpenDSS COM interface is a portable compilation and execution of OpenDSS commands without using the OpenDSS interface. This means that MATLAB code can interact with OpenDSS files, not only compiling and executing, but also editing them; for example, lines can be connected or disconnected without modifying the files directly. This blog will show the previous work and an example implementation of the MATLAB-OpenDSS COM interface.

Literature review – Implementation of the MATLAB-OpenDSS COM Interface

In recent years, the MATLAB-OpenDSS COM interface has been used for numerous applications and studies. In first place, it is worth mentioning that previous studies have been performed to test or demonstrate the effectiveness of this tool. “MatLab-OpenDSS Co-Simulation Environment: An Alternative Tool to Investigate DSG Connection” and “Simulation of Modern Distribution Systems Using Matlab and OpenDSS” are examples of articles in this category.

The first one serves the purpose of presenting the COM interface as a hybrid simulation tool combining electromagnetic transient and quasi-static models to obtain faster and more accurate results. The functionality is demonstrated by the integration of three photovoltaic generators in different points of a distribution network. The paper leaves as conclusion that, for precise simulations of power systems of great magnitude, the hybrid simulator is the best option [3].

The latter article presents an application of the COM interface by simulating a distribution system in which photovoltaic solar generation is added. The benefit the presents the interface is that MATLAB can manage the needed calculations related to photovoltaic generation such as irradiance and temperature. Then, the results are sent for the power calculations to OpenDSS [4]. As it can be noted, in both the previous articles, photovoltaic generation is mentioned, this is also the case for other academic papers, as the solar photovoltaic power generation, for better accuracy, must be processed in a versatile programming language like MATLAB. This is one of the main benefits of the tool.

Most of the previous work in which the COM interface makes an apparition is about examining the effects that solar power has in a distribution network. In 2018, two articles were published, and both applications were about the reconfiguration of a distribution network adding photovoltaic generation. One of them proposed the analysis of the reconfiguration of distribution networks with distributed generators using the method of branch exchange to define the best topology in two situations: conventional networks with no additional generation sources and distribution networks with photovoltaic distributed generators [5]. The other presented the impact of connecting a photovoltaic system without storage to distribution networks using the 13-bus IEEE test case [6]. Here the solar power calculations are the main reason of having the COM interface. Nonetheless, another great benefit of the COM interface comes in the reconfiguration, since using MATLAB allows a greater level of automation when compiling and running multiple configurations.

Finally, even though the photovoltaic power stays as the common denominator in most of the academic papers mentioning the COM interface, there are applications and studies where the advantages of the tool appear in different ways. The best case is an article that discusses the effect of aggregate linear load to harmonic studies via simulations using different load models to test the impact and sensitivity of the system’s impedance and the resultant harmonic voltages [7]. In this paper, the aggregate linear load models are the most important reason of using the COM interface. Another example is an article that presents the modelling and analysis of an electrical network with photovoltaic generators. In this case, the COM interface is taken advantage for the simulation of advanced functionalities of active power and Volt/Var control [8].

Comprehensive example – MG Research PUCMM

The best approach to better understand the MATLAB-OpenDSS COM interface is by testing an example and piece by piece decode and analyze the purpose of each part. By the revision of the help files included in the OpenDSS installation, the commands for the COM interface are included and explained. In first place, for any case of using the COM interface, the script in MATLAB should start in the following manner:

DSSObj = actxserver('OpenDSSEngine.DSS');
if ~DSSObj.Start(0)
    disp('Unable to start the OpenDSS Engine')
DSSText = DSSObj.Text; 
DSSCircuit = DSSObj.ActiveCircuit;

The first line serves the purpose of creating an object the connects with the OpenDSS engine, this allows to run all the OpenDSS capabilities inside of the MATLAB script. Next, the conditional includes a method of the object that was just created (Start). As its name may indicate, the start method initiates the OpenDSS engine. Also, the method returns a Boolean value indicating if the starting process was successful. The last two lines are properties of the object, the first one (Text) returns a text interface where commands can be sent and result messages can be received, and the second (ActiveCircuit) return a circuit interface that points to the active circuit. The next line is a demonstration of what can be done with the text interface:

DSSText.Command = 'Compile C:\Users\USER\OneDrive\Escritorio\USAID\OpenDSS\13Bus\IEEE13Nodeckt.dss';

By simply assigning the same syntax of an OpenDSS command to the command property of the text interface, it is executed by the engine. In this example, it executes the compilation of an OpenDSS file. This is a common step in most of the applications of the COM interface. The example script is based on reconfiguration of the 13-bus IEEE test case. For this purpose, the following cases were considered.

  • Case #1. No changes to the network (Generator at 1MW, all loads connected and at preset power consumption).
  • Case #2. Opening switch 671692.
  • Case #3. Disconnecting the generator.
  • Case #4. Increasing the power generation of GEN632.
  • Case #5. Decreasing power consumption of load 671 to 10% of preset value.

The commands for this example are opening and closing and setting values, these commands in the different cases are the following:

Case #2
DSSText.Command = 'Open Line.671692';
Case #3
DSSText.Command = 'Close Line.671692';
DSSText.Command = 'Open Line.GENSW';
Case #4
DSSText.Command = 'Close Line.GENSW';
DSSText.Command = ' = 10000';
Case #5
DSSText.Command = ' = 1000';
DSSText.Command = ' = 115.5';
DSSText.Command = 'Load.671.kvar = 66';

Another set of important command lies in solving the power flow for the modified network and obtaining the data. For this application, losses and power data were exported into .csv files and, using the MATLAB scripts, the data was imported to the example script. The commands for solving and exporting are shown next:

DSSText.Command = 'solve mode=snap';
DSSText.Command = 'Solve';
DSSText.Command = 'Export Losses Exported\TEST_LOSSES.csv';
DSSText.Command = 'Export Powers MVA Exported\TEST_POWERS.csv';

The first two lines set the solving mode and run the solving command, the last two export the resulting data into a folder (Exported). With these, for each of the cases, total loss and total power data were recollected so to present it in the succeeding way:

Figure 3. Total Losses for each case. Source: Created by the author in MATLAB.
Figure 4. Total Power for each case. Source: Created by the author in MATLAB.

Why using MATLAB-OpenDSS COM Interface?

What can we take from the MATLAB-OpenDSS COM Interface? It is not sufficient to say this tool is just a way to run OpenDSS in a MATLAB script. As seen until now, the COM interface has been broadly used to take advantage of the resources of a versatile and accurate high-level programming language like MATLAB and a fast and easy electrical network simulator like OpenDSS. This tool is not only great for studies where photovoltaic power is involved, it also offers a great simplification and improvement when it comes to advanced functionality and automation. In the line of research of microgrids, the optimization of the network configuration is a key element, especially when there are renewable energy generation involved, like solar and wind power. The COM interface provides an easy and accurate way of considering the necessary calculation to model the generation of this sources by using the resources that come with a programming language like MATLAB. Also, when it comes to optimizing a configuration of the network by an optimization algorithm, in order to test it a model of the network, the algorithm itself has to be able to change the network model. This is what can be done thanks to the COM interface. Running an advanced functionality like running an algorithm and modifying and compiling every new network configuration in the fastest and most accurate way possible.


[1] R. E. De Jesús-Grullón, “Modeling of Distribution Networks with High Renewables Penetration in Open-Source Software (OpenDSS + QGIS),” 2 September 2022. [Online]. Available: [Accessed 18 February 2023].

[2] EPRI, “OpenDSS,” [Online]. Available: [Accessed 18 February 2023].

[3] T. S. Theodoro, P. G. Barbosa, M. A. Tomim, A. C. S. de Lima and M. T. C. de Barros, “MatLab-OpenDSS co-simulation environment: An alternative tool to investigate DSG connection,” in Simposio Brasileiro de Sistemas Eletricos (SBSE), 2018.

[4] J. Tello-Maita, A. Marulanda and A. Pavas, “Simulation of Modern Distribution Systems Using Matlab and OpenDSS,” in FISE-IEEE/CIGRE Conference – Living the energy Transition (FISE/CIGRE),, 2019.

[5] R. C. Marques, H. S. Eichkoff and A. P. C. de Mello, “Analysis of the distribution network reconfiguration using the OpenDSS® software,” in Simposio Brasileiro de Sistemas Electricos, 2018.

[6] J. A. Ruíz-Garzón, D. J. González-Tristancho and F. C. Espinosa-González, “Impact of changing location and power of a PV system in electrical distribution networks, integrating MATLAB and OpenDSS,” DYNA, vol. 85, no. 205, pp. 125-131, April 2018.

[7] F. L. Vieira, P. F. Ribeiro, B. D. Bonatto and T. E. C. Oliveira, “Harmonic Studies in OpenDSS Considering Renewable DG and Aggregate Linear Load Models,” in 13th IEEE International Conference on Industry Applications (INDUSCON), 2018.

[8] Meghasai, S. Monger, R. Vega and H. Krishnaswami, “Simulation of smart functionalities of photovoltaic inverters by interfacing OpenDSS and Matlab,” in IEEE 16th Workshop on Control and Modeling for Power Electronics (COMPEL), 2015.

[9] G. W. Chang, N. C. Chinh, and C. Sinatra, “Equilibrium Optimizer-Based Approach of PV Generation Planning in a Distribution System for Maximizing Hosting Capacity,” IEEE Access, vol. 10, pp. 118108–118122, 2022, doi: 10.1109/ACCESS.2022.3220256.

Want to learn more about the research? Subscribed to our blog.

RA – Justin Bueno

This article is derived from the Subject Data funded in whole or part by NAS and USAID under the USAID Prime Award Number AID-OAA-A-11-00012. Any opinions, findings, conclusions, or recommendations expressed in this article are those of the authors alone and do not necessarily reflect the views of USAID or NAS.

One thought on “Implementation of MATLAB-OpenDSS COM Interface for Distribution Network Analysis

Leave a Reply

Your email address will not be published. Required fields are marked *