Skip to content

Commit

Permalink
fix testing
Browse files Browse the repository at this point in the history
  • Loading branch information
akody committed Oct 7, 2024
1 parent 096273e commit 189988f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions src/PowerSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export FixedAdmittance
export SwitchedAdmittance
export ControllableLoad
export InterruptiblePowerLoad
export FlexiblePowerLoad
export ExponentialLoad

export Storage
Expand All @@ -116,6 +117,7 @@ export DynamicGenerator
export DynamicInverter
export DynamicBranch
export HybridSystem
export VPPSystem

export GenericDER
export AggregateDistributedGenerationA
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 0 additions & 4 deletions src/descriptors/power_system_structs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
Expand Down
33 changes: 28 additions & 5 deletions src/models/VPPSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function VPPSystem(;
flexible_load = nothing,
services = Service[],
ext = Dict{String, Any}(),
internal = InfrastructureSystemsInternal(),
internal = IS.InfrastructureSystemsInternal(),
)
return VPPSystem(
name,
Expand All @@ -53,26 +53,49 @@ 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]
filter!(x -> !isnothing(x), components)
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)
end
return
end

"""Get [`VPPSystem`](@ref) `name`."""
get_name(value::VPPSystem) = value.name

"""Get [`VPPSystem`](@ref) `available`."""
get_available(value::VPPSystem) = value.available

Expand Down
2 changes: 1 addition & 1 deletion src/models/generated/FlexiblePowerLoad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions test/test_vpp_system.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
@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,
status = true,
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)

Expand Down

0 comments on commit 189988f

Please sign in to comment.