Skip to content

Commit

Permalink
Merge pull request #9 from NREL-SIIP/jm/missed-2.0-updates
Browse files Browse the repository at this point in the history
Fix some leftover 2.0 problems
  • Loading branch information
jd-lara authored Mar 30, 2023
2 parents 4b24670 + 07f509a commit e0c4147
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.6'
version: '1'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
Expand Down
12 changes: 9 additions & 3 deletions src/fuel_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ results = solve_op_model!(OpModel)
generators = make_fuel_dictionary(sys)
"""
function make_fuel_dictionary(sys::PSY.System, mapping::Dict{NamedTuple, String})
generators = PSY.get_components(PSY.get_available, PSY.StaticInjection, sys)
function make_fuel_dictionary(
sys::PSY.System,
mapping::Dict{NamedTuple, String};
filter_func = x -> true,
kwargs...,
)
filter_func2 = x -> PSY.get_available(x) && filter_func(x)
generators = PSY.get_components(filter_func2, PSY.StaticInjection, sys)
gen_categories = Dict()
for category in unique(values(mapping))
gen_categories["$category"] = []
Expand All @@ -107,5 +113,5 @@ end

function make_fuel_dictionary(sys::PSY.System; kwargs...)
mapping = get_generator_mapping(get(kwargs, :generator_mapping_file, nothing))
return make_fuel_dictionary(sys, mapping)
return make_fuel_dictionary(sys, mapping; kwargs...)
end
6 changes: 3 additions & 3 deletions src/get_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function _get_loads(system::PSY.System, load::PSY.StaticLoad)
return [load]
end
function _get_loads(system::PSY.System, sys::PSY.System)
return PSY.get_components(PSY.StaticLoad, system, PSY.get_available)
return PSY.get_components(PSY.get_available, PSY.StaticLoad, system)
end

get_base_power(system::PSY.System) = PSY.get_base_power(system)
Expand All @@ -425,7 +425,7 @@ get_base_power(results::PSI.ProblemResults) = results.base_power
function get_load_data(
system::PSY.System;
aggregation::Union{
Type{PSY.StandardLoad},
Type{PSY.StaticLoad},
Type{PSY.Bus},
Type{PSY.System},
Type{<:PSY.AggregationTopology},
Expand Down Expand Up @@ -534,7 +534,7 @@ Re-categorizes data according to an aggregation dictionary
# Example
```julia
aggregation = PG.make_fuel_dictionary(results_uc.system)
aggregation = PA.make_fuel_dictionary(results_uc.system)
categorize_data(gen_uc.data, aggregation)
```
Expand Down
20 changes: 18 additions & 2 deletions test/test_result_sorting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ problem_results = run_test_prob()
@test length(srv.time) == 5

# TODO: make tests for subsetting data
#sub_gen = get_generation_data(results_uc, filter_func = x->get_name(get_bus(x)) == "bus2")
#@test length(sub_gen.data) == 1
sub_gen =
get_generation_data(results_uc, filter_func = x -> get_name(get_bus(x)) == "bus1")
@test length(sub_gen.data) == 8
end

@testset "test curtailment calculations" begin
Expand Down Expand Up @@ -98,3 +99,18 @@ end
fuel_agg = PA.combine_categories(fuel)
@test size(fuel_agg) == (48, 8)
end

@testset "Test system data getters" begin
sys = PSI.get_system(results_uc)
load_data1 = PA.get_load_data(sys; aggregation = Bus)
@test length(load_data1.data) == 3
@test length(load_data1.time) == 24

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
end

2 comments on commit e0c4147

@jd-lara
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/80699

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.2 -m "<description of version>" e0c41479ed06137e88a1ce0d3c0bf79494700346
git push origin v0.3.2

Please sign in to comment.