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

PSSE Exporter Part 1: Add Tests and Formalize Exporter Implementation #42

Merged
merged 31 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3f2deeb
Add `DISABLED_TEST_FILES` option like in PowerSimulations
GabrielKS Jul 16, 2024
59b1448
Add compat for new dependencies
GabrielKS Jul 19, 2024
6f791b3
Begin work on a formal exporter interface
GabrielKS Jul 19, 2024
addfb21
Add rough draft tests for exporter interface
GabrielKS Jul 19, 2024
a37c899
Add `update_exporter!(..., System)`, extensively refactor tests
GabrielKS Jul 19, 2024
702b101
PSSE exporter: test AC powerflow on reimport, minor test refactor
GabrielKS Jul 19, 2024
3c29656
Begin implementing routine to update a `System` from a `PowerFlowData`
GabrielKS Jul 22, 2024
d4efe5c
Finish first draft of `update_system!`
GabrielKS Jul 22, 2024
e29f18f
Exporter: add round trip generator name remapping
GabrielKS Jul 23, 2024
1f369e9
Exporter: add round trip *bus* name remapping
GabrielKS Jul 23, 2024
caba8bd
Add round trip branch name remapping, RTS_GMLC tests, more test tweaks
GabrielKS Jul 24, 2024
e15e29d
Add load zone name mapping, test verbosity; make RTS_GMLC tests pass
GabrielKS Jul 25, 2024
7080857
Implement `update_exporter!` for `PowerFlowData`, build out RTS tests
GabrielKS Jul 25, 2024
82267a8
Reimplement Case Identification Data and Bus Data export (untested)
GabrielKS Jul 26, 2024
314022c
Reimplement Load Data and Fixed Bus Shunt Data export (untested)
GabrielKS Jul 29, 2024
5c6d323
Reimplement Generator Data and Non-Transformer Branch Data export
GabrielKS Jul 29, 2024
4568505
Reimplement Transformer Data export (first draft, untested)
GabrielKS Jul 31, 2024
60e76bd
Implement Zone Data export, keep track of unimplemented sections
GabrielKS Jul 31, 2024
95e97ea
Add option for customary comments at end of group, etc.
GabrielKS Jul 31, 2024
006a3e5
Support `PowerLoad`s
GabrielKS Aug 7, 2024
d02092c
Use new `IS.compare_values` interface
GabrielKS Aug 7, 2024
8ed4b42
Revamp reimport remappers, etc. so tests fully pass with both systems
GabrielKS Aug 9, 2024
9dbb19a
Remove old exporter implementation
GabrielKS Aug 9, 2024
a10604c
Address minor PR comments, migrate from JSON.jl to JSON3.jl
GabrielKS Aug 9, 2024
61f33ad
Minor `end_group` refactor
GabrielKS Aug 11, 2024
1719c5a
Multiply dispatch on export groups: part 1
GabrielKS Aug 11, 2024
0420b12
Multiply dispatch on export groups: part 2
GabrielKS Aug 11, 2024
26a1edc
Add `write_comments` test
GabrielKS Aug 11, 2024
93fd777
Remove more old code
GabrielKS Aug 11, 2024
1a94a18
Fix power limits units, fix redistribution calls, power flow is broken
GabrielKS Aug 13, 2024
d718b7f
Remove old dependency and TODOs, fix some power flow testing
GabrielKS Aug 19, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
test_simulation_results/*
# TODO reevaluate next few entries
test/Raw_Export
test/test_psse_exports
#Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov
Expand Down
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ version = "0.7.0"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
PowerNetworkMatrices = "bed98974-b02a-5e2f-9fe0-a103f5c450dd"
PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
DataFrames = "1"
DataStructures = "0.18"
Dates = "1"
InfrastructureSystems = "2"
JSON3 = "1"
LinearAlgebra = "1"
Logging = "1"
NLsolve = "4"
PowerNetworkMatrices = "^0.11"
PowerSystems = "^4"
Expand Down
15 changes: 10 additions & 5 deletions src/PowerFlows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ export ACPowerFlow
export PTDFDCPowerFlow
export vPTDFDCPowerFlow
export write_results
export PSSEExporter
export update_exporter!
export write_export
export get_psse_export_paths

import Logging
import DataFrames
import PowerSystems
import PowerSystems: System
import LinearAlgebra
import NLsolve
import SparseArrays
import InfrastructureSystems
import PowerNetworkMatrices
import SparseArrays: SparseMatrixCSC
import JSON3

const IS = InfrastructureSystems
const PSY = PowerSystems
Expand All @@ -31,15 +38,13 @@ include("ac_power_flow.jl")
include("ac_power_flow_jacobian.jl")
include("nlsolve_ac_powerflow.jl")
include("post_processing.jl")
include("psse_export.jl")

# PSSE Exporter
import PowerSystems: System
# Old PSSE Exporter
import DataFrames: DataFrame
import Dates
import DataStructures
import DataStructures: OrderedDict
import DelimitedFiles
import JSON
include("psse_exporter/support_tools.jl")
include("psse_exporter/psse_exporter.jl")

end
29 changes: 29 additions & 0 deletions src/post_processing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,32 @@ function write_results(

return Dict("bus_results" => bus_df, "flow_results" => branch_df)
end

"""
Modify the values in the given `System` to correspond to the given `PowerFlowData` such that
if a new `PowerFlowData` is constructed from the resulting system it is the same as `data`.
See also `write_powerflow_solution!`.
"""
function update_system!(sys::PSY.System, data::PowerFlowData)
for bus in PSY.get_components(PSY.Bus, sys)
if bus.bustype == PSY.ACBusTypes.REF
# For REF bus, voltage and angle are fixed; update active and reactive
P_gen = data.bus_activepower_injection[data.bus_lookup[PSY.get_number(bus)]]
Q_gen = data.bus_reactivepower_injection[data.bus_lookup[PSY.get_number(bus)]]
_power_redistribution_ref(sys, P_gen, Q_gen, bus,
DEFAULT_MAX_REDISTRIBUTION_ITERATIONS)
elseif bus.bustype == PSY.ACBusTypes.PV
# For PV bus, active and voltage are fixed; update reactive and angle
Q_gen = data.bus_reactivepower_injection[data.bus_lookup[PSY.get_number(bus)]]
_reactive_power_redistribution_pv(sys, Q_gen, bus,
DEFAULT_MAX_REDISTRIBUTION_ITERATIONS)
PSY.set_angle!(bus, data.bus_angles[data.bus_lookup[PSY.get_number(bus)]])
elseif bus.bustype == PSY.ACBusTypes.PQ
# For PQ bus, active and reactive are fixed; update voltage and angle
Vm = data.bus_magnitude[data.bus_lookup[PSY.get_number(bus)]]
PSY.set_magnitude!(bus, Vm)
PSY.set_angle!(bus, data.bus_angles[data.bus_lookup[PSY.get_number(bus)]])
end
end
# TODO
end
Loading
Loading