From c62c606d4e80547dc53288ff4451f05b5bf1e60c Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Thu, 29 Feb 2024 15:45:04 -0700 Subject: [PATCH] add more details to structs and portfolio --- src/PowerSystemsInvestmentsPortfolios.jl | 4 + src/demand.jl | 1 + src/portfolio.jl | 110 ++++++++++++++++++++++- src/storage.jl | 1 + src/supply.jl | 1 + src/technologies.jl | 2 + src/transport.jl | 1 + 7 files changed, 117 insertions(+), 3 deletions(-) diff --git a/src/PowerSystemsInvestmentsPortfolios.jl b/src/PowerSystemsInvestmentsPortfolios.jl index eec261f..e9b9a08 100644 --- a/src/PowerSystemsInvestmentsPortfolios.jl +++ b/src/PowerSystemsInvestmentsPortfolios.jl @@ -7,6 +7,10 @@ export Portfolio export SupplyTechnology export TransportTechnology export DemandTechnology +export StorageTechnology + +export add_technology! +export add_technologies! const PSY = PowerSystems const IS = InfrastructureSystems diff --git a/src/demand.jl b/src/demand.jl index 1a4f7a2..b4fa9fa 100644 --- a/src/demand.jl +++ b/src/demand.jl @@ -1,5 +1,6 @@ struct DemandTechnology{T <: PSY.StaticInjection} <: Technology name::String + available::Bool power_systems_type::Type{T} capital_cost::Float64 time_series_container::InfrastructureSystems.TimeSeriesContainer diff --git a/src/portfolio.jl b/src/portfolio.jl index e6c1dac..8bb206a 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -1,6 +1,110 @@ -struct Portfolio <: IS.InfrastructureSystemsType +mutable struct PortfolioMetadata <: IS.InfrastructurePortfoliosType + name::Union{Nothing, String} + description::Union{Nothing, String} + data_source::Union{Nothing, String} +end + +struct Portfolio <: IS.InfrastructurePortfoliosType aggregation::Type{<:Union{PSY.ACBus, PSY.AggregationTopology}} discount_rate::Float64 - data::IS.SystemData - time_series_container::InfrastructureSystems.TimeSeriesContainer + data::IS.PortfolioData + metadata::PortfolioMetadata + time_series_directory::Union{Nothing, String} + time_series_container::InfrastructurePortfolios.TimeSeriesContainer + internal::IS.InfrastructurePortfoliosInternal +end + +""" +Return the internal of the portfolio +""" +IS.get_internal(val::Portfolio) = val.internal + +""" +Return a user-modifiable dictionary to store extra information. +""" +get_ext(val::Portfolio) = IS.get_ext(val.internal) + +""" +Set the name of the portfolio. +""" +set_name!(val::Portfolio, name::AbstractString) = val.metadata.name = name + +""" +Get the name of the portfolio. +""" +get_name(val::Portfolio) = val.metadata.name + +""" +Set the description of the portfolio. +""" +set_description!(val::Portfolio, description::AbstractString) = + val.metadata.description = description + +""" +Get the description of the portfolio. +""" +get_description(val::Portfolio) = val.metadata.description + +""" +Get the description of the portfolio. +""" +get_description(val::Portfolio) = val.metadata.description + +""" +Add a technology to the portfoliotem. + +Throws ArgumentError if the technology's name is already stored for its concrete type. +Throws ArgumentError if any Component-specific rule is violated. +Throws InvalidValue if any of the technology's field values are outside of defined valid +range. + +# Examples +```julia +portfolio = Portfolio(...) + +# Add a single technology. +add_technology!(portfolio, bus) + +# Add many at once. +foreach(x -> add_technology!(portfolio, x), Iterators.flatten((buses, generators))) +``` +""" +function add_technology!( + portfolio::Portfolio, + technology::T; + skip_validation = false, + kwargs..., +) where {T <: Technology} + + IS.add_technology!( + portfolio.data, + technology; + allow_existing_time_series = deserialization_in_progress, + skip_validation = skip_validation, + _kwargs..., + ) + + return +end + +""" +Add many components to the system at once. + +Throws ArgumentError if the technology's name is already stored for its concrete type. +Throws ArgumentError if any Component-specific rule is violated. +Throws InvalidValue if any of the technology's field values are outside of defined valid +range. + +# Examples +```julia +portfolio = Portfolio(100.0) + +buses = [bus1, bus2, bus3] +generators = [gen1, gen2, gen3] +foreach(x -> add_technologies!(portfolio, x), Iterators.flatten((buses, generators))) +``` +""" +function add_technologies!(::Portfolio, technologies) + foreach(x -> add_technology!(portfolio, x), technologies) + return end diff --git a/src/storage.jl b/src/storage.jl index f461614..10498a9 100644 --- a/src/storage.jl +++ b/src/storage.jl @@ -1,5 +1,6 @@ struct StorageTechnology{T <: PSY.Storage} <: Technology name::String + available::Bool power_systems_type::Type{T} capital_cost::Float64 battery_chemistry::String # Implement Chemistry Type Enums in PowerSystems diff --git a/src/supply.jl b/src/supply.jl index 249fe21..5dc2fd9 100644 --- a/src/supply.jl +++ b/src/supply.jl @@ -1,5 +1,6 @@ struct SupplyTechnology{T <: PSY.Generator} <: Technology name::String + available::Bool power_systems_type::Type{T} fuel::PSY.ThermalFuels prime_mover::PSY.Primer_mover diff --git a/src/technologies.jl b/src/technologies.jl index 0812114..ba917d9 100644 --- a/src/technologies.jl +++ b/src/technologies.jl @@ -1,6 +1,7 @@ """ Required fields for a technology Type - name + - available - power_systems_type - time_series_container - internal @@ -8,6 +9,7 @@ Required fields for a technology Type abstract type Technology <: IS.Component end get_name(val::Technology) = val.name +get_available(val::Technology) = val.available get_power_systems_type(val::Technology) = val.power_systems_type get_internal(val::Technology) = val.internal get_ext(val::Technology) = get_ext(get_internal(val)) diff --git a/src/transport.jl b/src/transport.jl index adccfe6..bbcb749 100644 --- a/src/transport.jl +++ b/src/transport.jl @@ -1,5 +1,6 @@ struct TransportTechnology{T <: PSY.Device} <: Technology name::String + available::Bool power_systems_type::Type{T} capital_cost::Float64 time_series_container::InfrastructureSystems.TimeSeriesContainer