Hi All,
I am new to OpenDSS. I am building an application using OpenDSSEngine DLL library to process circuits based on data from GIS system. Right now I am facing a conceptual problem. After solving a circuit from a script side I can use commands like:
• Show Voltages LL
• Show Currents
• Show Losses
• Show Faults
Each of these commands will produce a report containing information I would like to use further in my application. How can I get these information when I solve my circuit in a DLL? Should I iterate elements of the circiut? Which elements?
A have replaced values with XXXX string in reports that I would like to retrieve in a code from sample reports stated below. Thank you in advance for your help.
LOSSES REPORT
Power Delivery Element Loss Report
Element kW Losses % of Power kvar Losses
"Transformer.TR1"5146.39900, 2.96 128660
"Line.LINE1" XXXX, 0.06 XXXX
"Line.LINE2" XXXX, 0.06 XXXX
"Line.LINE3" XXXX, 0.06 XXXX
LINE LOSSES= 338.5 kW
TRANSFORMER LOSSES= 5146.4 kW
TOTAL LOSSES= XXXX kW
TOTAL LOAD POWER = XXXX kW
Percent Losses for Circuit = 290.11 %
You didn't mention what scripting or programming language you are using, so I will give you the answer using VBA for Excel. Hopefully, you can translate this to matlab, or python, or whatever scripting or programming language you are using.
I am going to assume you are already connecting to the OpenDSS COM Server (OpenDSSengine.dll) successfully and have the following variables that represent interfaces into the OpenDSS COM Server:
DSSobj which is a handle to the DSS object: OpenDSSengine.DSS
DSSText which is a handle to the text interface: OpenDSSengine.Text
DSSCircuit which is a handle to the circuit interface: OpenDSSengine.Circuit
To get all of the voltages (and the bus-names) you could issue:
Set busnames = DSSCircuit.AllBusNames()
Set busvoltages = DSSCircuit.AllBusVmag()
This will give you a variant array of all busnames and a variant array of all bus voltage magnitudes from the last solution that you ran. The order of the voltages in the busvoltages array will be in the same order as the busnames array.
If you want complex voltages at each node on each bus, consider using:
Set busvolts = DSSCircuit.AllBusVolts()
For currents, you may consider doing the following after you run your fault study solution:
SetDSSElement=DSSCircuit.ActiveCktElementi=DSSCircuit.FirstPDElementDoWhilei>0ElementName=DSSElement.Name'Returns a complex array of currents into each conductor of each terminal curr = DSSElement.Currents i = DSSCircuit.NextPDElementLoop
There are plenty of examples of using the COM interface in the Examples subdirectory under C_Sharp, Excel, matlab, and python.
There's also documentation in the Doc sub-directory. See especially OpenDSSPrimer.pdf (pages 24-32 for COM). This was written by an OpenDSS user, who gratefully allows us to distribute it. It is very helpful.
If you don't see an Examples or Doc subdirectory under the folder where OpenDSS resides on your computer, you can also get these from the source-code respository on sourceforge. Just click on Code in the sourceforge toolbar, then click on trunk, then click on Distrib. You will see these folders.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Thank you for the reply. I have seen both documents: the ComDoc and Primer. I am writing the app in c# nad I need to process values in code, so I can't use export at all. Meanwhile I have managed to retreive currents and losses. I have managed to iterate elements of the Circuit with the following code:
for (int i=0; i < DSSCircuit.NumCktElements; i++)
{
CktElement cktElement = DSSCircuit.get_CktElements(i);
if (cktElement.Name.ToUpper() == "LINE.LINE1")
{
// ...
}
}
I still stuck with voltages in buses in "show Voltages LL" report :
The same iteration can be done with DSSCircuit.numBuses and DSSCircuit.Buses[] but I still cannot find the "xxxx" values displayed in the report. So far I have tried these bus property arrays:
SeqVoltages
puVoltages
puVLL
puVmagAngle
Voltages
Voc
CplxSeqVoltages
None of above shows the values I am looking for. Could you please help me finding them?
Thank you
Bolesław Maliszewski
Last edit: Bolesław Maliszewski 2015-04-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would think one of the values returned by SeqVoltages would give you the number you want. The values may come in the order: V0, V1, V2 where the second value in the array is what you want.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What I am looking for is for example the “239.6” value for sourcebus.
I am trying to get this value with the following code:
Bus bus = DSSCircuit.Buses[0];
listBox1.Items.Add("BUS - SeqVoltages");
double[] vals3 = (double[])bus.SeqVoltages;
foreach (double d in vals3)
{
listBox1.Items.Add(d.ToString());
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sequence voltages are reported in L-N voltage. Take the second value in the vals3 array and multiply by sqrt(3) to get L-L voltage.
All node voltages in OpenDSS are computed with respect to the zero voltage reference, which is usually the same as "ground" or "earth". So the node voltages are generally the same as Line-to-Neutral voltages, but not always depending on circuit connections. Show Voltages LL is a special report that prints the sequence voltages Line-to-Line. Show Voltages with show the sequence voltages Line-to-Neutral.
Try the report Show Voltages LN Nodes -- it will have all the voltages in actual kV in phase quantities, not symmetrical components.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
I am new to OpenDSS. I am building an application using OpenDSSEngine DLL library to process circuits based on data from GIS system. Right now I am facing a conceptual problem. After solving a circuit from a script side I can use commands like:
• Show Voltages LL
• Show Currents
• Show Losses
• Show Faults
Each of these commands will produce a report containing information I would like to use further in my application. How can I get these information when I solve my circuit in a DLL? Should I iterate elements of the circiut? Which elements?
A have replaced values with XXXX string in reports that I would like to retrieve in a code from sample reports stated below. Thank you in advance for your help.
SYMMETRICAL COMPONENT PHASE-PHASE VOLTAGES BY BUS (for 3-phase buses)
Bus Mag: V1 (kV) p.u. V2 (kV) %V2/V1 V0 (kV) %V0/V1
sourcebus XXXX 0 9.91E-008 4.137E-008 2.547E-014 1.063E-014
sub_bus XXXX 0 7.231E-008 4.369E-008 3.087E-014 1.865E-014
SYMMETRICAL COMPONENT CURRENTS BY CIRCUIT ELEMENT (first 3 phases)
Element Term I1 I2 %I2/I1 I0 %I0/I1 %Normal %Emergency
"VSOURCE.SOURCE" 1 XXXX 1.7491E-007 0.00 2.8173E-008 0.00 0.00 0.00
"VSOURCE.SOURCE1" 1 XXXX 3.6018E-007 0.00 6.3307E-010 0.00 0.00 0.00
LOSSES REPORT
Power Delivery Element Loss Report
Element kW Losses % of Power kvar Losses
"Transformer.TR1"5146.39900, 2.96 128660
"Line.LINE1" XXXX, 0.06 XXXX
"Line.LINE2" XXXX, 0.06 XXXX
"Line.LINE3" XXXX, 0.06 XXXX
LINE LOSSES= 338.5 kW
TRANSFORMER LOSSES= 5146.4 kW
TOTAL LOSSES= XXXX kW
TOTAL LOAD POWER = XXXX kW
Percent Losses for Circuit = 290.11 %
FAULT STUDY REPORT
ALL-Node Fault Currents
Bus Node 1 X/R Node 2 X/R Node 3 X/R ... (Amps)
"SOURCEBUS", XXXX, 4.2, XXXX, 4.2, XXXX, 4.2 -"SUB_BUS", 3565, 5.3, 3565, 5.3, 3565, 5.3
"LOADBUS1", 3574, 5.3, 3574, 5.3, 3574, 5.3
ONE-Node to ground Faults
pu Node Voltages (L-N Volts if no base)
Bus Node Amps Node 1 Node 2 Node 3 ...
"SOURCEBUS" 1 XXXX 0.0 145919.2 148187.8
"SOURCEBUS" 2 XXXX 148187.8 0.0 145919.2
Bolesław Maliszewski
Research and Development Manager
Software Development Department
If you are using Matlab you could consider using an Export command which will produce a csv file that you can import using the csvread function.
Otherwise there are several properties in the com interface that will give you these values directly. There is a documentation file in the doc folder
You didn't mention what scripting or programming language you are using, so I will give you the answer using VBA for Excel. Hopefully, you can translate this to matlab, or python, or whatever scripting or programming language you are using.
I am going to assume you are already connecting to the OpenDSS COM Server (OpenDSSengine.dll) successfully and have the following variables that represent interfaces into the OpenDSS COM Server:
DSSobj which is a handle to the DSS object: OpenDSSengine.DSS
DSSText which is a handle to the text interface: OpenDSSengine.Text
DSSCircuit which is a handle to the circuit interface: OpenDSSengine.Circuit
To get all of the voltages (and the bus-names) you could issue:
This will give you a variant array of all busnames and a variant array of all bus voltage magnitudes from the last solution that you ran. The order of the voltages in the busvoltages array will be in the same order as the busnames array.
If you want complex voltages at each node on each bus, consider using:
For currents, you may consider doing the following after you run your fault study solution:
There are plenty of examples of using the COM interface in the Examples subdirectory under C_Sharp, Excel, matlab, and python.
There's also documentation in the Doc sub-directory. See especially OpenDSSPrimer.pdf (pages 24-32 for COM). This was written by an OpenDSS user, who gratefully allows us to distribute it. It is very helpful.
If you don't see an Examples or Doc subdirectory under the folder where OpenDSS resides on your computer, you can also get these from the source-code respository on sourceforge. Just click on Code in the sourceforge toolbar, then click on trunk, then click on Distrib. You will see these folders.
Thanks
Hi,
Thank you for the reply. I have seen both documents: the ComDoc and Primer. I am writing the app in c# nad I need to process values in code, so I can't use export at all. Meanwhile I have managed to retreive currents and losses. I have managed to iterate elements of the Circuit with the following code:
for (int i=0; i < DSSCircuit.NumCktElements; i++)
{
CktElement cktElement = DSSCircuit.get_CktElements(i);
if (cktElement.Name.ToUpper() == "LINE.LINE1")
{
// ...
}
}
I still stuck with voltages in buses in "show Voltages LL" report :
SYMMETRICAL COMPONENT PHASE-PHASE VOLTAGES BY BUS (for 3-phase buses)
Bus Mag: V1 (kV) p.u. V2 (kV) %V2/V1 V0 (kV) %V0/V1
sourcebus XXXX 0 9.91E-008 4.137E-008 2.547E-014 1.063E-014
sub_bus XXXX 0 7.231E-008 4.369E-008 3.087E-014 1.865E-014
The same iteration can be done with DSSCircuit.numBuses and DSSCircuit.Buses[] but I still cannot find the "xxxx" values displayed in the report. So far I have tried these bus property arrays:
None of above shows the values I am looking for. Could you please help me finding them?
Thank you
Bolesław Maliszewski
Last edit: Bolesław Maliszewski 2015-04-17
I would think one of the values returned by SeqVoltages would give you the number you want. The values may come in the order: V0, V1, V2 where the second value in the array is what you want.
Hi Roger,
I have tried the values from SeqVoltages and those does not match. Let me explain what I do now.
I have created a circuit with the code below:
DSSText.Command = "clear";
DSSText.Command = "New Circuit.Simple";
DSSText.Command = "Edit Vsource.Source BasekV=220 pu=1.05 ISC3=3000 ISC1=2500";
DSSText.Command = "New Transformer.TR1 Buses=[SourceBus, Sub_Bus] Conns=[Wye Delta ] kVs= [220 115] kVAs=[20000 20000] XHL=10";
DSSText.Command = "New Linecode.336ACSR R1=0.058 X1=.1206 R0=.1784 X0=.4047 C1=3.4 C0=1.6 Units=km";
DSSText.Command = "New Line.LINE1 Bus1=Sub_Bus Bus2=LoadBus1 Linecode=336ACSR Length=1 Units=km";
DSSText.Command = "New Line.LINE2 Bus1=LoadBus1 Bus2=LoadBus2 Linecode=336ACSR Length=1 Units=km";
DSSText.Command = "New Line.LINE3 Bus1=LoadBus2 Bus2=LoadBus3 Linecode=336ACSR Length=1 Units=km";
DSSText.Command = "New Vsource.Source1 Bus1=LoadBus3 BasekV=210 pu=1.02 Angle=20 ISC3=3000 ISC1=2500";
DSSText.Command = "New Load.LOAD1 Bus1=LoadBus3 kV=115 kW=1000 PF=.95";
When I execute command: DSSText.Command = "Show Voltages LL"; I get the following results:
SYMMETRICAL COMPONENT PHASE-PHASE VOLTAGES BY BUS (for 3-phase buses)
Bus Mag: V1 (kV) p.u. V2 (kV) %V2/V1 V0 (kV) %V0/V1
sourcebus 239.6 0 9.91E-008 4.137E-008 2.623E-014 1.095E-014
sub_bus 165.5 0 7.231E-008 4.369E-008 2.301E-014 1.39E-014
loadbus1 165.7 0 7.238E-008 4.368E-008 2.301E-014 1.389E-014
loadbus2 165.9 0 7.244E-008 4.368E-008 1.959E-014 1.181E-014
loadbus3 166 0 7.251E-008 4.367E-008 2.058E-014 1.239E-014
What I am looking for is for example the “239.6” value for sourcebus.
I am trying to get this value with the following code:
Bus bus = DSSCircuit.Buses[0];
listBox1.Items.Add("BUS - SeqVoltages");
double[] vals3 = (double[])bus.SeqVoltages;
foreach (double d in vals3)
{
listBox1.Items.Add(d.ToString());
}
Sequence voltages are reported in L-N voltage. Take the second value in the vals3 array and multiply by sqrt(3) to get L-L voltage.
All node voltages in OpenDSS are computed with respect to the zero voltage reference, which is usually the same as "ground" or "earth". So the node voltages are generally the same as Line-to-Neutral voltages, but not always depending on circuit connections. Show Voltages LL is a special report that prints the sequence voltages Line-to-Line. Show Voltages with show the sequence voltages Line-to-Neutral.
Try the report Show Voltages LN Nodes -- it will have all the voltages in actual kV in phase quantities, not symmetrical components.