Skip to content

Commit

Permalink
Merge pull request #14 from NREL-Sienna/gks/issue-8
Browse files Browse the repository at this point in the history
Fix #8, add tests using PowerSystemCaseBuilder
  • Loading branch information
jd-lara authored Oct 26, 2023
2 parents 5dd42b3 + 82e1c28 commit fe8a49f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
PowerSimulations = "e690365d-45e2-57bb-ac84-44ba829e73c4"
PowerSystemCaseBuilder = "f00506e0-b84f-492a-93c2-c0a9afc4364e"
PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd"
TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
Expand Down
4 changes: 2 additions & 2 deletions src/get_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,11 @@ get_base_power(results::PSI.ProblemResults) = results.base_power
function get_load_data(
system::PSY.System;
aggregation::Union{
Type{PSY.StaticLoad},
Type{<:PSY.StaticLoad},
Type{PSY.ACBus},
Type{PSY.System},
Type{<:PSY.AggregationTopology},
} = PSY.StandardLoad,
} = PSY.StaticLoad,
kwargs...,
)
aggregation_components =
Expand Down
26 changes: 21 additions & 5 deletions test/test_result_sorting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,32 @@ end
end

@testset "Test system data getters" begin
sys = PSI.get_system(results_uc)
# We can test get_load_data without running a simulation
sys = PSB.build_system(PSB.PSITestSystems, "c_sys5_all_components")

load_data1 = PA.get_load_data(sys; aggregation = ACBus)
@test length(load_data1.data) == 3
@test length(load_data1.time) == 24

load_data2 = PA.get_load_data(sys, aggregation = StaticLoad)
load_data2 = PA.get_load_data(sys; aggregation = StaticLoad)
@test length(load_data2.data) == 3
@test length(load_data2.time) == 24

load_data3 = PA.get_load_data(sys, aggregation = System)
@test length(load_data2.data) == 3
@test length(load_data2.time) == 24
# With System aggregation, everything gets lumped together
load_data3 = PA.get_load_data(sys; aggregation = System)
@test length(load_data3.data) == 1
@test length(load_data3.time) == 24

# No aggregation specified: default is StaticLoad
load_data4 = PA.get_load_data(sys)
@test length(load_data4.data) == 3
@test length(load_data4.time) == 24

load_data5 = PA.get_load_data(sys; aggregation = PowerLoad)
@test length(load_data5.data) == 2
@test length(load_data5.time) == 24

load_data6 = PA.get_load_data(sys; aggregation = StandardLoad)
@test length(load_data6.data) == 1
@test length(load_data6.time) == 24
end

0 comments on commit fe8a49f

Please sign in to comment.