Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Power System Automation and Monitoring
pyVolt
pyVolt
Commits
f005ca76
Commit
f005ca76
authored
Apr 17, 2019
by
martin.moraga
Browse files
fixed some errors in the last commit
parent
9bb92f9b
Changes
5
Hide whitespace changes
Inline
Side-by-side
acs/state_estimation/__init__.py
View file @
f005ca76
__all__
=
[
"bc_powerflow"
,
"bc_state_estimator"
,
"nv_powerflow"
,
"nv_state_estimator"
,
"network"
,
"nv_powerflow_cim"
]
\ No newline at end of file
__all__
=
[
"bc_powerflow"
,
"bc_state_estimator"
,
"nv_powerflow"
,
"nv_state_estimator"
,
"network"
,
"nv_powerflow_cim"
,
"results"
]
\ No newline at end of file
acs/state_estimation/network.py
View file @
f005ca76
...
...
@@ -84,13 +84,8 @@ class System():
for
uuid
,
element
in
res
.
items
():
if
element
.
__class__
.
__name__
==
"ACLineSegment"
:
length
=
element
.
length
if
length
==
0.0
:
length
=
1.0
bR
=
element
.
r
*
length
bX
=
element
.
x
*
length
self
.
bR
.
append
(
bR
)
self
.
bX
.
append
(
bX
)
self
.
bR
.
append
(
element
.
r
)
self
.
bX
.
append
(
element
.
x
)
for
node
in
self
.
nodes
:
if
element
.
startNodeID
==
node
.
uuid
:
startNode
=
node
...
...
@@ -101,8 +96,10 @@ class System():
break
base_voltage
=
element
.
BaseVoltage
.
nominalVoltage
self
.
branches
.
append
(
Branch
(
bR
,
bX
,
startNode
,
endNode
,
base_voltage
,
base_apparent_power
))
self
.
branches
.
append
(
Branch
(
r
=
element
.
r
,
x
=
element
.
x
,
start_node
=
startNode
,
end_node
=
endNode
,
base_voltage
=
base_voltage
,
base_apparent_power
=
base_apparent_power
))
elif
element
.
__class__
.
__name__
==
"PowerTransformer"
:
bR
=
element
.
primaryConnection
.
r
bX
=
element
.
primaryConnection
.
x
...
...
@@ -119,7 +116,8 @@ class System():
#base voltage = high voltage side (=primaryConnection)
base_voltage
=
element
.
primaryConnection
.
BaseVoltage
.
nominalVoltage
self
.
branches
.
append
(
Branch
(
bR
,
bX
,
startNode
,
endNode
,
base_voltage
,
base_apparent_power
))
self
.
branches
.
append
(
Branch
(
r
=
bR
,
x
=
bX
,
start_node
=
startNode
,
end_node
=
endNode
,
base_voltage
=
base_voltage
,
base_apparent_power
=
base_apparent_power
))
else
:
continue
...
...
@@ -147,10 +145,10 @@ class System():
for
branch
in
self
.
branches
:
fr
=
branch
.
start_node
.
index
to
=
branch
.
end_node
.
index
self
.
Ymatrix
[
fr
][
to
]
-=
branch
.
y
self
.
Ymatrix
[
to
][
fr
]
-=
branch
.
y
self
.
Ymatrix
[
fr
][
fr
]
+=
branch
.
y
self
.
Ymatrix
[
to
][
to
]
+=
branch
.
y
self
.
Ymatrix
[
fr
][
to
]
-=
branch
.
y
_pu
self
.
Ymatrix
[
to
][
fr
]
-=
branch
.
y
_pu
self
.
Ymatrix
[
fr
][
fr
]
+=
branch
.
y
_pu
self
.
Ymatrix
[
to
][
to
]
+=
branch
.
y
_pu
self
.
Adjacencies
[
fr
].
append
(
to
+
1
)
#to + 1???
self
.
Adjacencies
[
to
].
append
(
fr
+
1
)
#fr + 1???
...
...
acs/state_estimation/nv_powerflow_cim.py
View file @
f005ca76
import
sys
import
math
import
numpy
as
np
from
network
import
BusType
import
r
esults
from
.
network
import
BusType
from
.results
import
R
esults
def
solve
(
system
):
"""It performs Power Flow by using rectangular node voltage state variables."""
...
...
@@ -19,8 +19,8 @@ def solve(system):
i2
=
i
+
nodes_num
type
=
system
.
nodes
[
i
].
type
if
type
is
BusType
.
SLACK
:
z
[
m
]
=
np
.
real
(
system
.
nodes
[
i
].
voltage
)
z
[
m
+
1
]
=
np
.
imag
(
system
.
nodes
[
i
].
voltage
)
z
[
m
]
=
np
.
real
(
system
.
nodes
[
i
].
voltage
_pu
)
z
[
m
+
1
]
=
np
.
imag
(
system
.
nodes
[
i
].
voltage
_pu
)
H
[
m
][
i
]
=
1
H
[
m
+
1
][
i2
]
=
1
elif
type
is
BusType
.
PQ
:
...
...
@@ -61,12 +61,12 @@ def solve(system):
h
[
m
]
=
np
.
inner
(
H
[
m
],
State
)
h
[
m
+
1
]
=
np
.
inner
(
H
[
m
+
1
],
State
)
elif
type
is
BusType
.
PQ
:
z
[
m
]
=
(
np
.
real
(
system
.
nodes
[
i
].
power
)
*
np
.
real
(
V
[
i
])
+
np
.
imag
(
system
.
nodes
[
i
].
power
)
*
np
.
imag
(
V
[
i
]))
/
(
np
.
abs
(
V
[
i
])
**
2
)
z
[
m
+
1
]
=
(
np
.
real
(
system
.
nodes
[
i
].
power
)
*
np
.
imag
(
V
[
i
])
-
np
.
imag
(
system
.
nodes
[
i
].
power
)
*
np
.
real
(
V
[
i
]))
/
(
np
.
abs
(
V
[
i
])
**
2
)
z
[
m
]
=
(
np
.
real
(
system
.
nodes
[
i
].
power
_pu
)
*
np
.
real
(
V
[
i
])
+
np
.
imag
(
system
.
nodes
[
i
].
power
_pu
)
*
np
.
imag
(
V
[
i
]))
/
(
np
.
abs
(
V
[
i
])
**
2
)
z
[
m
+
1
]
=
(
np
.
real
(
system
.
nodes
[
i
].
power
_pu
)
*
np
.
imag
(
V
[
i
])
-
np
.
imag
(
system
.
nodes
[
i
].
power
_pu
)
*
np
.
real
(
V
[
i
]))
/
(
np
.
abs
(
V
[
i
])
**
2
)
h
[
m
]
=
np
.
inner
(
H
[
m
],
State
)
h
[
m
+
1
]
=
np
.
inner
(
H
[
m
+
1
],
State
)
elif
type
is
BusType
.
PV
:
z
[
m
]
=
(
np
.
real
(
system
.
nodes
[
i
].
power
)
*
np
.
real
(
V
[
i
])
+
np
.
imag
(
system
.
nodes
[
i
].
power
)
*
np
.
imag
(
V
[
i
]))(
np
.
abs
(
V
[
i
])
**
2
)
z
[
m
]
=
(
np
.
real
(
system
.
nodes
[
i
].
power
_pu
)
*
np
.
real
(
V
[
i
])
+
np
.
imag
(
system
.
nodes
[
i
].
power
_pu
)
*
np
.
imag
(
V
[
i
]))(
np
.
abs
(
V
[
i
])
**
2
)
h
[
m
]
=
np
.
inner
(
H
[
m
],
State
)
h
[
m
+
1
]
=
np
.
abs
(
V
[
i
])
H
[
m
+
1
][
i
]
=
np
.
cos
(
np
.
angle
(
V
[
i
]))
...
...
@@ -82,7 +82,7 @@ def solve(system):
num_iter
=
num_iter
+
1
# calculate all the other quantities of the grid
powerflow_results
=
results
.
Results
(
system
)
powerflow_results
=
Results
(
system
)
powerflow_results
.
load_voltages
(
V
)
powerflow_results
.
calculate_all
()
...
...
acs/state_estimation/results.py
View file @
f005ca76
import
numpy
as
np
import
cmath
import
sys
sys
.
path
.
append
(
"../../../dataprocessing"
)
from
villas.dataprocessing.readtools
import
*
from
villas.dataprocessing.readtools
import
read_timeseries_dpsim
class
ResultsNode
():
def
__init__
(
self
,
topo_node
):
...
...
@@ -190,4 +188,4 @@ class Results():
for test purposes
"""
for
node
in
self
.
nodes
:
print
(
node
.
topology_node
.
uuid
+
": "
+
str
(
cmath
.
polar
(
node
.
voltage
)))
\ No newline at end of file
print
(
node
.
topology_node
.
uuid
+
" = "
+
str
(
cmath
.
polar
(
node
.
voltage
)))
\ No newline at end of file
examples/CIGREMV_tests/test_nv_powerflow_cim.py
View file @
f005ca76
import
sys
import
logging
sys
.
path
.
append
(
"../../acs/state_estimation"
)
import
network
import
nv_powerflow_cim
sys
.
path
.
append
(
"../../../cimpy"
)
from
acs.state_estimation
import
network
from
acs.state_estimation
import
nv_powerflow_cim
import
cimpy
logging
.
basicConfig
(
filename
=
'CIGRE.log'
,
level
=
logging
.
INFO
,
filemode
=
'w'
)
...
...
@@ -19,24 +15,13 @@ cim_xml_files=[cim_xml_path + r"\Rootnet_FULL_NE_06J16h_DI.xml",
#read cim files and create new network.Systen object
res
=
cimpy
.
cimread
(
cim_xml_files
)
system
=
network
.
System
()
system
.
load_cim_data
(
res
,
20
)
#print node voltages
for
node
in
system
.
nodes
:
print
(
'{}={}'
.
format
(
node
.
uuid
,
node
.
voltage
))
print
()
#print node powers
for
node
in
system
.
nodes
:
print
(
'{}={}'
.
format
(
node
.
uuid
,
node
.
power
))
base_apparent_power
=
25
#MW
system
.
load_cim_data
(
res
,
base_apparent_power
)
#Execute power flow analysis
results
,
num_iter_cim
=
nv_powerflow_cim
.
solve
(
system
)
print
()
print
(
"voltages:"
)
#print node voltages
print
(
"results.voltages (pu): "
)
for
node
in
results
.
nodes
:
print
(
'{}={}'
.
format
(
node
.
topology_node
.
uuid
,
node
.
voltage
))
#results.print_voltages_polar()
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment