From 189988ff3139d4e9588c51647d6ca047a9194df1 Mon Sep 17 00:00:00 2001 From: akody Date: Mon, 7 Oct 2024 19:02:50 -0400 Subject: [PATCH] fix testing --- Project.toml | 1 - src/PowerSystems.jl | 3 +++ src/descriptors/power_system_structs.json | 4 --- src/models/VPPSystem.jl | 33 +++++++++++++++++++---- src/models/generated/FlexiblePowerLoad.jl | 2 +- test/test_vpp_system.jl | 6 +++-- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Project.toml b/Project.toml index e63c6942a6..c10f4a1aaa 100644 --- a/Project.toml +++ b/Project.toml @@ -14,7 +14,6 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" PowerFlowData = "dd99e9e3-7471-40fc-b48d-a10501125371" PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e" diff --git a/src/PowerSystems.jl b/src/PowerSystems.jl index b311860c42..846e111c96 100644 --- a/src/PowerSystems.jl +++ b/src/PowerSystems.jl @@ -104,6 +104,7 @@ export FixedAdmittance export SwitchedAdmittance export ControllableLoad export InterruptiblePowerLoad +export FlexiblePowerLoad export ExponentialLoad export Storage @@ -116,6 +117,7 @@ export DynamicGenerator export DynamicInverter export DynamicBranch export HybridSystem +export VPPSystem export GenericDER export AggregateDistributedGenerationA @@ -690,6 +692,7 @@ include("models/cost_functions/ThermalGenerationCost.jl") # Include all auto-generated structs. include("models/generated/includes.jl") include("models/HybridSystem.jl") +include("models/VPPSystem.jl") #Methods for devices include("models/components.jl") diff --git a/src/descriptors/power_system_structs.json b/src/descriptors/power_system_structs.json index fba98ec7bd..16e751feda 100644 --- a/src/descriptors/power_system_structs.json +++ b/src/descriptors/power_system_structs.json @@ -1441,10 +1441,6 @@ "comment": "Time period during which load must be balanced", "null_value": "Dates.Hour(0)", "data_type": "Union{Nothing, Dates.Period}", - "valid_range": { - "min": 0, - "max": null - }, "validation_action": "warn" }, { diff --git a/src/models/VPPSystem.jl b/src/models/VPPSystem.jl index aea9e83856..718523ba9a 100644 --- a/src/models/VPPSystem.jl +++ b/src/models/VPPSystem.jl @@ -33,7 +33,7 @@ function VPPSystem(; flexible_load = nothing, services = Service[], ext = Dict{String, Any}(), - internal = InfrastructureSystemsInternal(), + internal = IS.InfrastructureSystemsInternal(), ) return VPPSystem( name, @@ -53,8 +53,34 @@ function VPPSystem(; ) end +println("HEY HEY HEY") + + +# Constructor for demo purposes; non-functional. +function VPPSystem(::Nothing) + return VPPSystem(; + name = "init", + available = false, + status = false, + bus = ACBus(nothing), + active_power = 0.0, + reactive_power = 0.0, + base_power = 100.0, + operation_cost = MarketBidCost(nothing), + storage = EnergyReservoirStorage(nothing), + renewable_unit = RenewableDispatch(nothing), + flexible_load = FlexiblePowerLoad(nothing), + services = Service[], + ext = Dict{String, Any}(), + internal = IS.InfrastructureSystemsInternal(), + ) +end + + # Getter functions for VPPSystem struct +get_name(value::VPPSystem) = value.name + function _get_components(value::VPPSystem) components = [value.storage, value.renewable_unit, value.flexible_load] @@ -62,7 +88,7 @@ function _get_components(value::VPPSystem) return components end -function set_units_setting!(value::VPPSystem, settings::SystemUnitsSettings) +function set_units_setting!(value::VPPSystem, settings::IS.SystemUnitsSettings) set_units_info!(get_internal(value), settings) for component in _get_components(value) set_units_info!(get_internal(component), settings) @@ -70,9 +96,6 @@ function set_units_setting!(value::VPPSystem, settings::SystemUnitsSettings) return end -"""Get [`VPPSystem`](@ref) `name`.""" -get_name(value::VPPSystem) = value.name - """Get [`VPPSystem`](@ref) `available`.""" get_available(value::VPPSystem) = value.available diff --git a/src/models/generated/FlexiblePowerLoad.jl b/src/models/generated/FlexiblePowerLoad.jl index 997d81ab32..c291140c17 100644 --- a/src/models/generated/FlexiblePowerLoad.jl +++ b/src/models/generated/FlexiblePowerLoad.jl @@ -34,7 +34,7 @@ A [static](@ref S) power load that can be partially or completed shifted to late - `max_active_power::Float64`: Maximum active power (MW) that this load can demand - `max_reactive_power::Float64`: Maximum reactive power (MVAR) that this load can demand - `base_power::Float64`: Base power (MVA) for [per unitization](@ref per_unit), validation range: `(0, nothing)` -- `balance_time_period::Union{Nothing, Dates.Period}`: Time period during which load must be balanced, validation range: `(0, nothing)` +- `balance_time_period::Union{Nothing, Dates.Period}`: Time period during which load must be balanced - `operation_cost::Union{LoadCost, MarketBidCost}`: [`OperationalCost`](@ref) of interrupting load - `services::Vector{Service}`: (default: `Device[]`) Services that this device contributes to - `ext::Dict{String, Any}`: (default: `Dict{String, Any}()`) An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude. diff --git a/test/test_vpp_system.jl b/test/test_vpp_system.jl index cf02959c42..17e6c19604 100644 --- a/test/test_vpp_system.jl +++ b/test/test_vpp_system.jl @@ -1,6 +1,8 @@ @testset "VPP System tests" begin test_sys = PSB.build_system(PSB.PSITestSystems, "c_sys14"; add_forecasts = false) + #include("/Users/akody/Library/CloudStorage/OneDrive-NREL/Sienna/VPP_Project/PowerSystems.jl/src/models/VPPSystem.jl") + vpp_sys = VPPSystem(; name = "Test VPP", available = true, @@ -8,11 +10,11 @@ bus = get_component(ACBus, test_sys, "Bus 1"), active_power = 1.0, reactive_power = 1.0, - base_power = 100.0, - operation_cost = MarketBidCost(nothing), storage = EnergyReservoirStorage(nothing), renewable_unit = RenewableDispatch(nothing), flexible_load = FlexiblePowerLoad(nothing), + base_power = 100.0, + operation_cost = MarketBidCost(nothing), ) add_component!(test_sys, vpp_sys)