Skip to content

Commit

Permalink
fix services test
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed May 7, 2024
1 parent 3c42876 commit 16a8e84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/services_models/agc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function get_default_attributes(
::Type{PSY.AGC},
::Type{<:AbstractAGCFormulation},
)
return Dict{String, Any}()
return Dict{String, Any}("aggregated_service_model" => false)
end

"""
Expand Down Expand Up @@ -174,10 +174,10 @@ function add_constraints!(
::Type{T},
::Type{SteadyStateFrequencyDeviation},
agcs::IS.FlattenIteratorWrapper{U},
::ServiceModel{PSY.AGC, V},
model::ServiceModel{PSY.AGC, V},
sys::PSY.System,
) where {T <: SACEPIDAreaConstraint, U <: PSY.AGC, V <: PIDSmoothACE}
services = get_available_components(PSY.AGC, sys)
services = get_available_components(model, sys)
time_steps = get_time_steps(container)
agc_names = PSY.get_name.(services)
area_names = [PSY.get_name(PSY.get_area(s)) for s in services]
Expand All @@ -196,7 +196,7 @@ function add_constraints!(
kp = PSY.get_K_p(service)
ki = PSY.get_K_i(service)
kd = PSY.get_K_d(service)
Δt = convert(Dates.Second, container.resolution).value
Δt = convert(Dates.Second, get_resolution(container)).value
a = PSY.get_name(service)
for t in time_steps
if t == 1
Expand Down
6 changes: 3 additions & 3 deletions src/services_models/services_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function construct_service!(
::Set{<:DataType},
::NetworkModel{<:PM.AbstractPowerModel},
) where {S <: PSY.AGC, T <: AbstractAGCFormulation}
services = get_available_components(S, sys)
services = get_available_components(model, sys)
agc_areas = PSY.get_area.(services)
areas = PSY.get_components(PSY.Area, sys)
if !isempty(setdiff(areas, agc_areas))
Expand Down Expand Up @@ -315,7 +315,7 @@ function construct_service!(
::NetworkModel{<:PM.AbstractPowerModel},
) where {S <: PSY.AGC, T <: AbstractAGCFormulation}
areas = PSY.get_components(PSY.Area, sys)
services = get_available_components(S, sys)
services = get_available_components(model, sys)

add_constraints!(container, AbsoluteValueConstraint, LiftVariable, services, model)
add_constraints!(
Expand Down Expand Up @@ -519,7 +519,7 @@ function construct_service!(
incompatible_device_types::Set{<:DataType},
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {T <: PSY.TransmissionInterface}
interfaces = get_available_components(T, sys)
interfaces = get_available_components(model, sys)
if get_use_slacks(model)
# Adding the slacks can be done in a cleaner fashion
interface = PSY.get_component(T, sys, get_service_name(model))
Expand Down
6 changes: 4 additions & 2 deletions test/test_services_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ end
)

model = DecisionModel(template, c_sys5_uc)
@test build!(model; output_dir = mktempdir(; cleanup = true)) == PSI.BuildStatus.BUILT
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
moi_tests(model, 432, 144, 288, 288, 288, false)

template = get_thermal_dispatch_template_network(PTDFPowerModel)
Expand All @@ -431,7 +432,8 @@ end
ServiceModel(TransmissionInterface, ConstantMaxInterfaceFlow; use_slacks = true),
)
model = DecisionModel(template, c_sys5_uc)
@test build!(model; output_dir = mktempdir(; cleanup = true)) == PSI.BuildStatus.BUILT
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
moi_tests(model, 312, 0, 288, 288, 168, false)

#= TODO: Fix this test
Expand Down

0 comments on commit 16a8e84

Please sign in to comment.