I am relatively new in COM interfacing with MATLAB and I wanted to know if there was an "elegant" way of extracting all element properties in the active circuit without using DSSText.Command. In other words, is there a single line of code I can type in MATLAB using the COM objects available? If not, I I would assume I would have to loop through each individual element and then extract the properties.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, there is an instruction in MATLAB to explore all the properties and methods available for the existing clases of an Object (in this case OpenDSS). Try the following script:
What I get is very much like the object browser for the OpenDSS engine in VBA and it provided more insight on how I can utilize the objects available with MATLAB. However, I'm finding myself building my own circuit element specifications table with a while loop, rather than assigning all the properties of the circuit element of interest with a single line of code.
For example, I want to grab all the transformer properties defined in the system
Ideally, here's what I would have to type as pseudocode
DSSCircuit.Transformers.AllProperties ! all the Transformers properties
What I'm actually doing:
transformer=DSSCircuit.Transformers;transCount=transformer.First;x=[];whiletransCount>0x=[x[{transformer.Name};transformer.kV; transformer.kva ... OTHER SPECS]]transCount=transformer.Next;end
Is there a way I can do the pseudocode written above?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In this case, you will obtain the name of all the properties of the active element in a variant which must be transformed to an array of strings. Then you will be able to ask for each property using a for or while loop to sweep the array.
I hope this helps
Best regards
Davis
Last edit: Davis Montenegro 2015-07-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unfortunately, that only applies to PCelements and "Variable" refers to whatever state variables the programmer chose to expose.
You can do as Davis said in his previous post and loop through the properties for each circuit element. I'm not sure what you are using this for, but when I did this for EPRI's DG Screener program I needed to do it to populate edit boxes on a form. I simply did it with a series of text commands. Here is the actual code (in Delphi) from one of these routines:
So it uses the query command, "?", and constructs a command from the device name and the property name. Then it picks up the result and puts it in the property text box. "GlobalResult" is a function that calls the Result property of the Text interface.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the input/suggestions. I'm extract all the element properties just fine until I try to extract bus voltages.
For reference purposes I am using the EPRI Test Circuit ckt 5.
First, I solve the circuit. Then, I extract the bus names.
BusNames=DSSCircuit.AllBusNames;
BusNames is a 2998 x1 cell
Finally, I extract the bus voltage magnitudes
BusVMag=DSSCircuit.AllBusVmag;
BusVMag is a vector, 1 x 3437
I expected BusVMag to be the same size as BusNames because each bus is unqiue, therefore having equal dimensions as BusVMag. Why is it that there are 439 additional voltages in BusVMag? I am assuming the discrepancy is due to the nodes per individual bus.
If that is the case, do I assume the first 3 voltages of a 3 node bus are respectively, nodes 1, nodes 2, and nodes 3?
Last edit: Dennis 2015-07-31
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What you are getting are the voltages in all the nodes, so, to get the names of the nodes use the property AllNodeNames instead of AllBusNames. This way the number of elements is going to match. Remember, a bus can have several nodes.
Best regards
Davis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to get the looses value of watt and vars for two condition.
with XHL =10% and %Rs=[0.4, 0.4] or %loadloss = 0.8 ( % noloadloss = 0)
with XHL =10% and %loadloss = 0 ( % noloadloss = 0)
In both conditions the var values are same but the watt values are different. Watt value is significant for condition 1 and insignificant for condition 2.
Now the question is how do I vailid such results??
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a simple enough problem that you can confirm the losses by hand calculations. Take the currents openDSS computes and compute the active and reactive power losses by hand or better yet use a spreadsheet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you please check whether the snippet below in getting the line losses is appropriate for a single line and if yes how do I compute the next line?
line=DSSCircuit.Lines;
ActiveElement=DSSCircuit.ActiveCktElement;
LineCount=line.First;
MyLineLossesArray = ActiveElement.Losses;
P(i) = MyLineLossesArray(1);
W = P';
Q(i) = MyLineLossesArray(2);
Va = Q';
Thanks!
Last edit: Shiva 2015-11-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
LineCount=line.First;WhileLineCount>0MyLineLossesArray=ActiveElement.Losses;P(i)=MyLineLossesArray(1);W=P';Q(i) = MyLineLossesArray(2);Va=Q';... Do something with W and Va ...LineCount=line.Next;End
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello All,
I am relatively new in COM interfacing with MATLAB and I wanted to know if there was an "elegant" way of extracting all element properties in the active circuit without using DSSText.Command. In other words, is there a single line of code I can type in MATLAB using the COM objects available? If not, I I would assume I would have to loop through each individual element and then extract the properties.
Thanks.
Hi,
Yes, there is an instruction in MATLAB to explore all the properties and methods available for the existing clases of an Object (in this case OpenDSS). Try the following script:
Obj = actxserver('OpenDSSEngine.DSS');
get(Obj)
inspect(Obj)
methodsview(Obj)
This will display all the methods and properties within OpenDSS.
Best regards
Davis
Davis,
What I get is very much like the object browser for the OpenDSS engine in VBA and it provided more insight on how I can utilize the objects available with MATLAB. However, I'm finding myself building my own circuit element specifications table with a while loop, rather than assigning all the properties of the circuit element of interest with a single line of code.
For example, I want to grab all the transformer properties defined in the system
Ideally, here's what I would have to type as pseudocode
What I'm actually doing:
Is there a way I can do the pseudocode written above?
Hi,
You can do also that by using the activecktelement reference,for example, consider the code that you proposed above:
transformer=DSSCircuit.Transformers;
ActiveElement=DSSCircuit.ActiveCktElement;
transCount=transformer.First;
properties=ActiveElement.AllPropertyNames;
In this case, you will obtain the name of all the properties of the active element in a variant which must be transformed to an array of strings. Then you will be able to ask for each property using a for or while loop to sweep the array.
I hope this helps
Best regards
Davis
Last edit: Davis Montenegro 2015-07-30
You can also try with the following properties for the ActiveCktElement class:
ActiveElement.AllVariableNames
ActiveElement.AllVariableValues
Best regards
Davis
Unfortunately, that only applies to PCelements and "Variable" refers to whatever state variables the programmer chose to expose.
You can do as Davis said in his previous post and loop through the properties for each circuit element. I'm not sure what you are using this for, but when I did this for EPRI's DG Screener program I needed to do it to populate edit boxes on a form. I simply did it with a series of text commands. Here is the actual code (in Delphi) from one of these routines:
So it uses the query command, "?", and constructs a command from the device name and the property name. Then it picks up the result and puts it in the property text box. "GlobalResult" is a function that calls the Result property of the Text interface.
Thank you for the input/suggestions. I'm extract all the element properties just fine until I try to extract bus voltages.
For reference purposes I am using the EPRI Test Circuit ckt 5.
First, I solve the circuit. Then, I extract the bus names.
BusNames is a 2998 x1 cell
Finally, I extract the bus voltage magnitudes
BusVMag is a vector, 1 x 3437
I expected BusVMag to be the same size as BusNames because each bus is unqiue, therefore having equal dimensions as BusVMag. Why is it that there are 439 additional voltages in BusVMag? I am assuming the discrepancy is due to the nodes per individual bus.
If that is the case, do I assume the first 3 voltages of a 3 node bus are respectively, nodes 1, nodes 2, and nodes 3?
Last edit: Dennis 2015-07-31
Hi,
What you are getting are the voltages in all the nodes, so, to get the names of the nodes use the property AllNodeNames instead of AllBusNames. This way the number of elements is going to match. Remember, a bus can have several nodes.
Best regards
Davis
Hi,
I want to extract the losses incur in the transformer and I wrote a snippet below.
transformer=DSSCircuit.Transformers;
ActiveElement=DSSCircuit.ActiveCktElement;
transCount=transformer.First;
properties=ActiveElement.AllPropertyNames;
From here how to get the % loadlosses of the transformer?
Thanks
Here's what I would do, using your notation:
Thansk Mr. Roger!
I tried to get the looses value of watt and vars for two condition.
In both conditions the var values are same but the watt values are different. Watt value is significant for condition 1 and insignificant for condition 2.
Now the question is how do I vailid such results??
Thanks
It makes sense to me.
This is a simple enough problem that you can confirm the losses by hand calculations. Take the currents openDSS computes and compute the active and reactive power losses by hand or better yet use a spreadsheet.
Thanks Roger!
Basically I used the below snippet to compute the total line losses but I am interested in computing a single line.
Could you please check whether the snippet below in getting the line losses is appropriate for a single line and if yes how do I compute the next line?
Thanks!
Last edit: Shiva 2015-11-26
Using your notation:
Thanks Roger it works and now I am able to find the losses in each line and is consistent with the hand calculation.