Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsing of FACTS Devices #41

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ InterAreaTransfers
```@docs
Owners
```

## FACTS Devices
```@docs
FACTSDevices
```
2 changes: 1 addition & 1 deletion src/PowerFlowData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export parse_network
export Network
export CaseID, Buses, Loads, Generators, Branches, Transformers, AreaInterchanges
export TwoTerminalDCLines, VSCDCLines, SwitchedShunts, ImpedanceCorrections
export Zones, InterAreaTransfers, Owners
export Zones, InterAreaTransfers, Owners, FACTSDevices

include("debug.jl")
include("types.jl")
Expand Down
4 changes: 4 additions & 0 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ function parse_network(source)
owners, pos = parse_records!(Owners(), bytes, pos, len, OPTIONS)
@debug 1 "Parsed Owners: nrows = $(length(owners)), pos = $pos"

facts, pos = parse_records!(FACTSDevices(), bytes, pos, len, OPTIONS)
@debug 1 "Parsed FACTSDevices: nrows = $(length(facts)), pos = $pos"

return Network(
caseid,
buses,
Expand All @@ -91,6 +94,7 @@ function parse_network(source)
zones,
area_transfers,
owners,
facts,
)
end

Expand Down
123 changes: 122 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,124 @@ struct Owners <: Records
owname::Vector{InlineString15}
end

"""
$TYPEDEF

Flexible AC Transmission System devices.

There is a multiplicity of Flexible AC Transmission System devices currently available
comprising shunt devices, such as the Static Compensator (STATCOM), series devices such as
the Static Synchronous Series Compensator (SSSC), combined devices such as the
Unified Power Flow Controller (UPFC) and the Interline Power Flow Controllers (IPFC),
of which the latter are parallel series devices.

# Fields
$TYPEDFIELDS
"""
struct FACTSDevices <: Records
"FACTS device number."
n::Vector{Int16}
"""
Sending end bus number, or extended bus name enclosed in single quotes.
No default.
"""
i::Vector{BusNum}
"""
Terminal end bus number, or extended bus name enclosed in single quotes.
0 for a STATCON.
`j` = 0 by default.
"""
j::Vector{BusNum}
"""
Control mode:
* 0 - out-of-service (i.e., series and shunt links open).
* 1 - series and shunt links operating.
* 2 - series link bypassed (i.e., like a zero impedance line) and shunt link operating as a STATCON.
* 3 - seriesandshuntlinksoperatingwithserieslinkatconstantseriesimpedance.
* 4 - series and shunt links operating with series link at constant series voltage.
* 5 - master device of an IPFC with P and Q setpoints specified;
FACTS device N+1 must be the slave device (i.e., its `mode` is 6 or 8) of this IPFC.
* 6 - slave device of an IPFC with P and Q setpoints specified;
FACTS device N-1 must be the master device (i.e., its `mode` is 5 or 7) of this IPFC.
The Q setpoint is ignored as the master device dictates the active power exchanged between the two devices.
* 7 - master device of an IPFC with constant series voltage setpoints specified;
FACTS device N+1 must be the slave device (i.e., its `mode` is 6 or 8) of this IPFC.
* 8 - slave device of an IPFC with constant series voltage setpoints specified;
FACTS device N-1 must be the master device (i.e., its `mode` is 5 or 7) of this IPFC.
The complex ``V_d + j V_q`` setpoint is modified during power flow solutions to reflect
the active power exchange determined by the master device.
If `j` is specified as 0, `mode` must be either 0 or 1.
`mode` = 1 by default.
"""
mode::Vector{Int8}
"""
Desired active power flow arriving at the terminal end bus; entered in MW.
`pdes` = 0.0 by default.
"""
pdes::Vector{Float64}
"""
Desired reactive power flow arriving at the terminal end bus; entered in MVAR.
`qdes` = 0.0 by default.
"""
qdes::Vector{Float64}
"Voltage setpoint at the sending end bus; entered in pu. `vset` = 1.0 by default."
vset::Vector{Float64}
"""
Maximum shunt current at the sending end bus; entered in MVA at unity voltage.
`shmx` = 9999.0 by default.
"""
shmx::Vector{Float64}
"Maximum bridge active power transfer; entered in MW. `trmx` = 9999.0 by default."
trmx::Vector{Float64}
"Minimum voltage at the terminal end bus; entered in pu. `vtmn` = 0.9 by default."
vtmn::Vector{Float64}
"Maximum voltage at the terminal end bus; entered in pu. `vtmx` = 1.1 by default."
vtmx::Vector{Float64}
"Maximum series voltage; entered in pu. `vsmx` = 1.0 by default."
vsmx::Vector{Float64}
"""
Maximum series current, or zero for no series current limit; entered in MVA at unity voltage.
`imx` = 0.0 by default.
"""
imx::Vector{Float64}
"""
Reactance of the dummy series element used during model solution; entered in pu.
`linx` = 0.05 by default.
"""
linx::Vector{Float64}
"""
Percent of the total Mvar required to hold the voltage at bus `i` that are to be contributed
by the shunt element of this FACTS device; `rmpct` must be positive.
`rmpct` is needed only if there is more than one local or remote voltage controlling device
(plant, switched shunt, FACTS device shunt element, or VSC dc line converter) controlling
the voltage at bus `i` to a setpoint. `rmpct` = 100.0 by default.
"""
rmpct::Vector{Float64}
"""
Owner number (1 through the maximum number of owners at the current size level).
`owner` = 1 by default.
"""
owner::Vector{OwnerNum}
"""
If `mode` is 3, resistance and reactance respectively of the constant impedance, entered in pu;
if `mode` is 4, the magnitude (in pu) and angle (in degrees) of the constant series voltage
with respect to the quantity indicated by `vsref`;
if `mode` is 7 or 8, the real (vd) and imaginary (vq) components (in pu) of the constant
series voltage with respect to the quantity indicated by `vsref`;
for other values of `mode`, `set1` and set2 are read, but not saved or used during power flow solutions.
`set1` = 0.0 by default.
"""
set1::Vector{Float64}
"See `set1`. `set2` = 0.0 by default."
set2::Vector{Float64}
"""
Series voltage reference code to indicate the series voltage reference of `set1` and `set2`
when `mode` is 4, 7 or 8: 0 for sending end voltage, 1 for series current.
`vsref` = 0 by default.
"""
vsref::Vector{Int8} # 0 or 1... i think
end

###
### Network
###
Expand Down Expand Up @@ -1848,6 +1966,7 @@ Currently supported are:
1. [`Zones`](@ref)
1. [`InterAreaTransfers`](@ref)
1. [`Owners`](@ref)
1. [`FACTSDevices`](@ref)

`CaseID` data is a single row (in the Tables.jl-sense).
You can access it like `network.caseid` and interact with it like a `NamedTuple`,
Expand Down Expand Up @@ -1889,10 +2008,12 @@ struct Network
impedance_corrections::ImpedanceCorrections
"Zone records."
zones::Zones
"Inter-area tranfer records."
"Inter-area transfer records."
area_transfers::InterAreaTransfers
"Owner records."
owners::Owners
"FACTS device records."
facts::FACTSDevices
end

###
Expand Down
15 changes: 12 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ using Test
@test size(df) == (3, 2)

for T in (
Buses, Loads, Generators, Branches, Transformers, AreaInterchanges, VSCDCLines,
SwitchedShunts
Buses, Loads, Generators, Branches, Transformers, AreaInterchanges,
TwoTerminalDCLines, VSCDCLines, SwitchedShunts, ImpedanceCorrections, Zones,
InterAreaTransfers, Owners, FACTSDevices
)
@test T <: PowerFlowData.Records
@test Tables.istable(T)
Expand All @@ -63,7 +64,7 @@ using Test
@test repr(mime, net; context) == "Network"
@test repr(mime, net) == strip(
"""
Network with 14 data categories:
Network with 15 data categories:
$(sprint(show, mime, net.caseid))
$(sprint(show, mime, net.buses; context))
$(sprint(show, mime, net.loads; context))
Expand All @@ -78,6 +79,7 @@ using Test
$(sprint(show, mime, net.zones; context))
$(sprint(show, mime, net.area_transfers; context))
$(sprint(show, mime, net.owners; context))
$(sprint(show, mime, net.facts; context))
"""
)
@test repr(mime, net.caseid) == "CaseID: (ic = 0, sbase = 100.0)"
Expand Down Expand Up @@ -183,6 +185,10 @@ using Test
owners = net1.owners
@test owners.i == [1, 2]
@test owners.owname == [" ABC ", " CDE "]

facts = net1.facts
@test facts.n == [1]
@test facts.vsref == [0]
end

@testset "v29 file" begin
Expand Down Expand Up @@ -271,6 +277,9 @@ using Test
owners = net2.owners
@test owners.i == [1, 2]
@test owners.owname == [" EAI ", " OUYK "]

facts = net2.facts
@test isempty(facts)
end

@testset "issues" begin
Expand Down
1 change: 1 addition & 0 deletions test/testfiles/synthetic_data_v30.raw
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ SOME OTHER COMMENTS
1,' ABC '
2,' CDE '
0 / end of owner cards
1, 113, 0,1, 0.000, 0.000,1.11111, 50.000, 100.000,0.97777,1.13333,1.00000, 0.000, 0.05555, 100.00, 1, 0.00000, 0.00000,0
0 / end of FACTS device cards