Skip to content

Commit

Permalink
add more details to structs and portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Feb 29, 2024
1 parent 0ccfafc commit c62c606
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/PowerSystemsInvestmentsPortfolios.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/demand.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
110 changes: 107 additions & 3 deletions src/portfolio.jl
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/storage.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions src/supply.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/technologies.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""
Required fields for a technology Type
- name
- available
- power_systems_type
- time_series_container
- internal
"""
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))
Expand Down
1 change: 1 addition & 0 deletions src/transport.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit c62c606

Please sign in to comment.