From 79d89281fcebb04ccdf2e55d7017cc74118aa785 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Mon, 25 Mar 2024 10:20:07 -0600 Subject: [PATCH 01/12] bug fix in struct defination --- src/portfolio.jl | 18 +++++++++--------- src/storage.jl | 3 +-- src/supply.jl | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/portfolio.jl b/src/portfolio.jl index 52839a6..9ff6a4c 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -1,18 +1,18 @@ -mutable struct PortfolioMetadata <: IS.InfrastructurePortfoliosType +mutable struct PortfolioMetadata <: IS.InfrastructureSystemsType name::Union{Nothing, String} description::Union{Nothing, String} data_source::Union{Nothing, String} end -struct Portfolio <: IS.InfrastructurePortfoliosType +struct Portfolio <: IS.InfrastructureSystemsType aggregation::Type{<:Union{PSY.ACBus, PSY.AggregationTopology}} discount_rate::Float64 - portfolio_data::IS.PortfolioData # Inputs to the model + portfolio_data::IS.SystemData # Inputs to the model investment_schedule::Dict # Investment decisions container i.e., model outputs. Container TBD metadata::PortfolioMetadata time_series_directory::Union{Nothing, String} - time_series_container::InfrastructurePortfolios.TimeSeriesContainer - internal::IS.InfrastructurePortfoliosInternal + time_series_container::IS.TimeSeriesContainer + internal::IS.InfrastructureSystemsInternal end """ @@ -176,7 +176,7 @@ Throws ArgumentError if the component is not stored in the system. function add_time_series!( portfolio::Portfolio, component::Technology, - time_series::TimeSeriesData, + time_series::IS.TimeSeriesData, ) return IS.add_time_series!(portfolio.data, component, time_series) end @@ -189,7 +189,7 @@ individually with the same data because in this case, only one time series array Throws ArgumentError if a component is not stored in the system. """ -function add_time_series!(portfolio::Portfolio, technologies, time_series::TimeSeriesData) +function add_time_series!(portfolio::Portfolio, technologies, time_series::IS.TimeSeriesData) return IS.add_time_series!(portfolio.data, technologies, time_series) end @@ -218,14 +218,14 @@ function remove_time_series!( ::Type{T}, component::Component, name::String, -) where {T <: TimeSeriesData} +) where {T <: IS.TimeSeriesData} return IS.remove_time_series!(portfolio.data, T, component, name) end """ Remove all the time series data for a time series type. """ -function remove_time_series!(portfolio::Portfolio, ::Type{T}) where {T <: TimeSeriesData} +function remove_time_series!(portfolio::Portfolio, ::Type{T}) where {T <: IS.TimeSeriesData} return IS.remove_time_series!(portfolio.data, T) end diff --git a/src/storage.jl b/src/storage.jl index b187736..7039971 100644 --- a/src/storage.jl +++ b/src/storage.jl @@ -4,8 +4,7 @@ struct StorageTechnology{T <: PSY.Storage} <: Technology power_systems_type::Type{T} capital_cost::IS.FunctionData battery_chemistry::String # Implement Chemistry Type Enums in PowerSystems - prime_mover::PSY.Primer_mover - capital_cost::IS.FunctionData + prime_mover::PSY.PrimeMovers operational_cost::PSY.OperationalCost supplemental_attributes_container::IS.SupplementalAttributesContainer time_series_container::IS.TimeSeriesContainer diff --git a/src/supply.jl b/src/supply.jl index fe680c4..ba1bdc5 100644 --- a/src/supply.jl +++ b/src/supply.jl @@ -3,7 +3,7 @@ struct SupplyTechnology{T <: PSY.Generator} <: Technology available::Bool power_systems_type::Type{T} fuel::PSY.ThermalFuels - prime_mover::PSY.Primer_mover + prime_mover::PSY.PrimeMovers capacity_factor::Float64 capital_cost::IS.FunctionData operational_cost::PSY.OperationalCost From a6c98807f00b9f564328c9933acb44c2e16682c6 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Tue, 26 Mar 2024 08:06:57 -0600 Subject: [PATCH 02/12] adding some examples --- Project.toml | 2 +- src/PowerSystemsInvestmentsPortfolios.jl | 75 +++++++++++++++++++++--- src/portfolio.jl | 2 +- src/storage.jl | 2 + src/supply.jl | 27 ++++++++- 5 files changed, 97 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 1d3e918..679685a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "PowerSystemsInvestmentsPortfolios" uuid = "bed98974-b02a-5e2f-9fe0-a103f5c450dd" -authors = ["Jose Daniel Lara"] +authors = ["Jose Daniel Lara", "Sourabh Dalvi"] version = "0.1.0" [deps] diff --git a/src/PowerSystemsInvestmentsPortfolios.jl b/src/PowerSystemsInvestmentsPortfolios.jl index 9f93535..2684684 100644 --- a/src/PowerSystemsInvestmentsPortfolios.jl +++ b/src/PowerSystemsInvestmentsPortfolios.jl @@ -1,25 +1,84 @@ module PowerSystemsInvestmentsPortfolios -import InfrastructureSystems +import PowerSystems # TODO: Some of these re-exports may cause name collisions with PowerSystems +import PowerSystems: + add_time_series!, + get_time_series, + has_time_series, + get_time_series_array, + get_time_series_timestamps, + get_time_series_values, + get_time_series_names + +import InfrastructureSystems import InfrastructureSystems: - add_time_series, - to_json, - from_json, - serialize, - deserialize, + Components, + TimeSeriesData, + StaticTimeSeries, + Forecast, + AbstractDeterministic, + Deterministic, + Probabilistic, + SingleTimeSeries, + DeterministicSingleTimeSeries, + Scenarios, + ForecastCache, + StaticTimeSeriesCache, + InfrastructureSystemsComponent, + InfrastructureSystemsType, + InfrastructureSystemsInternal, + DeviceParameter, + FlattenIteratorWrapper, + LazyDictFromIterator, + DataFormatError, + InvalidRange, + InvalidValue, + copy_time_series!, + get_count, + get_data, + get_horizon, + get_resolution, + get_window, + get_name, + set_name!, + get_internal, + set_internal!, + get_time_series_container, + iterate_windows, get_time_series, has_time_series, get_time_series_array, get_time_series_timestamps, get_time_series_values, get_time_series_names, - InfrastructureSystemsInternal, + get_scenario_count, # Scenario Forecast Exports + get_percentiles, # Probabilistic Forecast Exports + get_next_time_series_array!, + get_next_time, + get_units_info, + set_units_info!, + to_json, + from_json, + serialize, + deserialize, + get_time_series_multiple, + compare_values, CompressionSettings, CompressionTypes, + NormalizationFactor, + NormalizationTypes, + UnitSystem, + SystemUnitsSettings, + open_file_logger, + make_logging_config_file, + validate_struct, MultiLogger, LogEventTracker, - StructField + StructField, + StructDefinition + +const IS = InfrastructureSystems import PowerSystems diff --git a/src/portfolio.jl b/src/portfolio.jl index 9ff6a4c..38f8c5e 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -216,7 +216,7 @@ Remove the time series data for a component and time series type. function remove_time_series!( portfolio::Portfolio, ::Type{T}, - component::Component, + component::PSY.Component, name::String, ) where {T <: IS.TimeSeriesData} return IS.remove_time_series!(portfolio.data, T, component, name) diff --git a/src/storage.jl b/src/storage.jl index 7039971..b9844a8 100644 --- a/src/storage.jl +++ b/src/storage.jl @@ -10,3 +10,5 @@ struct StorageTechnology{T <: PSY.Storage} <: Technology time_series_container::IS.TimeSeriesContainer internal::InfrastructureSystemsInternal end + +get_name(technology::StorageTechnology) = technology.name diff --git a/src/supply.jl b/src/supply.jl index ba1bdc5..3ab8a36 100644 --- a/src/supply.jl +++ b/src/supply.jl @@ -9,5 +9,30 @@ struct SupplyTechnology{T <: PSY.Generator} <: Technology operational_cost::PSY.OperationalCost supplemental_attributes_container::IS.SupplementalAttributesContainer time_series_container::IS.TimeSeriesContainer - internal::InfrastructureSystemsInternal + internal::IS.InfrastructureSystemsInternal end + + +function SupplyTechnology(name, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container=IS.TimeSeriesContainer(), ) + SupplyTechnology(nunamember, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container, IS.InfrastructureSystemsInternal(), ) +end + +function SupplyTechnology(; name, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container=IS.TimeSeriesContainer(), internal=IS.InfrastructureSystemsInternal(), ) + SupplyTechnology(name, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container, internal) +end + +# Constructor for demo purposes; non-functional. +function SupplyTechnology(::Nothing) + SupplyTechnology(; + name="init", + available=false, + power_systems_type = PSY.ThermalStandard, + fuel = PSY.ThermalFuels.NG, + prime_mover = PSY.PrimeMovers.CT, + capacity_factor = 0.9, + capital_cost = IS.FunctionData(nothing), + operational_cost = PSY.ThreePartCost(nothing), + supplemental_attributes_container = IS.SupplementalAttributesContainer(nothing), + time_series_container=IS.TimeSeriesContainer(), + ) +end \ No newline at end of file From b21e8551d4f0ac98c2ff950c955542f162777909 Mon Sep 17 00:00:00 2001 From: Pradyumna Rao Date: Tue, 26 Mar 2024 14:04:33 -0600 Subject: [PATCH 03/12] fixed UUID --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 679685a..85ea561 100644 --- a/Project.toml +++ b/Project.toml @@ -1,5 +1,5 @@ name = "PowerSystemsInvestmentsPortfolios" -uuid = "bed98974-b02a-5e2f-9fe0-a103f5c450dd" +uuid = "9212B679-331E-471F-8FA8-FF293E16DBC8" authors = ["Jose Daniel Lara", "Sourabh Dalvi"] version = "0.1.0" From fc74eb2399ff4b3135f95f7192b78f7ac86079e5 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Wed, 27 Mar 2024 13:19:08 -0600 Subject: [PATCH 04/12] removing function redefination --- src/portfolio.jl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/portfolio.jl b/src/portfolio.jl index 38f8c5e..bab28a0 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -46,11 +46,6 @@ 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. From b7deead6bcc0a8ff6be6b9ac9a965da59364a0b5 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Tue, 9 Apr 2024 18:50:41 -0600 Subject: [PATCH 05/12] adding auto generated structs --- src/PowerSystemsInvestmentsPortfolios.jl | 14 +- src/descriptors/portfolio_structs.json | 292 +++++++++++++++++++++++ src/models/DemandRequirement.jl | 80 +++++++ src/models/DemandSideTechnology.jl | 80 +++++++ src/models/StorageTechnology.jl | 104 ++++++++ src/models/SupplyTechnology.jl | 112 +++++++++ src/models/TransportTechnology.jl | 80 +++++++ 7 files changed, 757 insertions(+), 5 deletions(-) create mode 100644 src/descriptors/portfolio_structs.json create mode 100644 src/models/DemandRequirement.jl create mode 100644 src/models/DemandSideTechnology.jl create mode 100644 src/models/StorageTechnology.jl create mode 100644 src/models/SupplyTechnology.jl create mode 100644 src/models/TransportTechnology.jl diff --git a/src/PowerSystemsInvestmentsPortfolios.jl b/src/PowerSystemsInvestmentsPortfolios.jl index 68b13fb..3ded9fe 100644 --- a/src/PowerSystemsInvestmentsPortfolios.jl +++ b/src/PowerSystemsInvestmentsPortfolios.jl @@ -82,6 +82,7 @@ const IS = InfrastructureSystems import PowerSystems import PrettyTables +import JSON3 export Portfolio export SupplyTechnology @@ -96,16 +97,19 @@ const PSY = PowerSystems const IS = InfrastructureSystems include("technologies.jl") -include("demand_requirement.jl") -include("supply.jl") -include("demand_side.jl") -include("transport.jl") -include("storage.jl") +include("models/includes.jl") +include("models/serialization.jl") +# include("demand_requirement.jl") +# include("supply.jl") +# include("demand_side.jl") +# include("transport.jl") +# include("storage.jl") include("portfolio.jl") include("utils/print.jl") using DocStringExtensions +const DATA_FORMAT_VERSION = "0.1.0" @template (FUNCTIONS, METHODS) = """ $(TYPEDSIGNATURES) $(DOCSTRING) diff --git a/src/descriptors/portfolio_structs.json b/src/descriptors/portfolio_structs.json new file mode 100644 index 0000000..ad1987b --- /dev/null +++ b/src/descriptors/portfolio_structs.json @@ -0,0 +1,292 @@ +{ + "auto_generated_structs": [ + { + "struct_name": "DemandRequirement", + "parametric": "PSY.StaticInjection", + "docstring": "This struct represents the demand requirement for a power system.", + "fields": [ + { + "name": "name", + "comment": "The name of the load demand requirement.", + "data_type": "String" + }, + { + "name": "available", + "comment": "Indicates whether the load demand is available or not in the simulation.", + "null_value": "true", + "data_type": "Bool" + }, + { + "name": "power_systems_type", + "comment": "The type of PowerSystems Component this build option translates to.", + "data_type": "Type{T}" + }, + { + "name": "region", + "comment": "The region of the demand requirement.", + "data_type": "Union{PSY.ACBus, PSY.AggregationTopology}" + }, + { + "name": "supplemental_attributes_container", + "comment": "Container for supplemental attributes.", + "null_value": "InfrastructureSystems.SupplementalAttributesContainer()", + "data_type": "InfrastructureSystems.SupplementalAttributesContainer", + "default": "InfrastructureSystems.SupplementalAttributesContainer()" + }, + { + "name": "time_series_container", + "comment": "internal time_series storage", + "null_value": "InfrastructureSystems.TimeSeriesContainer()", + "data_type": "InfrastructureSystems.TimeSeriesContainer", + "default": "InfrastructureSystems.TimeSeriesContainer()" + }, + { + "name": "internal", + "comment": "power system internal reference, do not modify", + "data_type": "InfrastructureSystemsInternal", + "internal_default": "InfrastructureSystemsInternal()", + "exclude_setter": true + } + ], + "supertype": "PSY.StaticInjection" + }, + { + "struct_name": "DemandSideTechnology", + "parametric": "PSY.StaticInjection", + "docstring": "This struct represents a demand side technology in a power system.", + "fields": [ + { + "name": "name", + "comment": "The name of the demand side technology.", + "data_type": "String" + }, + { + "name": "available", + "comment": "Indicates whether the technology is available or not in the simulation.", + "null_value": "true", + "data_type": "Bool" + }, + { + "name": "power_systems_type", + "comment": "The type of PowerSystems Component this build option translates to.", + "data_type": "Type{T}" + }, + { + "name": "capital_cost", + "comment": "The capital cost of the technology.", + "data_type": "IS.FunctionData" + }, + { + "name": "supplemental_attributes_container", + "comment": "Container for supplemental attributes.", + "null_value": "InfrastructureSystems.SupplementalAttributesContainer()", + "data_type": "InfrastructureSystems.SupplementalAttributesContainer", + "default": "InfrastructureSystems.SupplementalAttributesContainer()" + }, + { + "name": "time_series_container", + "comment": "internal time_series storage", + "null_value": "InfrastructureSystems.TimeSeriesContainer()", + "data_type": "InfrastructureSystems.TimeSeriesContainer", + "default": "InfrastructureSystems.TimeSeriesContainer()" + }, + { + "name": "internal", + "comment": "power system internal reference, do not modify", + "data_type": "InfrastructureSystemsInternal", + "internal_default": "InfrastructureSystemsInternal()", + "exclude_setter": true + } + ], + "supertype": "Technology" + }, + { + "struct_name": "StorageTechnology", + "parametric": "PSY.Storage", + "docstring": "This struct represents a storage technology in a power system.", + "fields": [ + { + "name": "name", + "comment": "The name of the storage technology.", + "data_type": "String" + }, + { + "name": "available", + "comment": "Indicates whether the technology is available or not in the simulation.", + "null_value": "true", + "data_type": "Bool" + }, + { + "name": "power_systems_type", + "comment": "The type of PowerSystems Component this build option translates to.", + "data_type": "Type{T}" + }, + { + "name": "capital_cost", + "comment": "The capital cost of the technology.", + "data_type": "IS.FunctionData" + }, + { + "name": "battery_chemistry", + "comment": "The type of battery chemistry. Implement Chemistry Type Enums in PowerSystems.", + "data_type": "String" + }, + { + "name": "prime_mover", + "comment": "The prime mover of the storage technology.", + "data_type": "PSY.PrimeMovers" + }, + { + "name": "operational_cost", + "comment": "The operational cost of the storage technology.", + "data_type": "PSY.OperationalCost" + }, + { + "name": "supplemental_attributes_container", + "comment": "Container for supplemental attributes.", + "null_value": "InfrastructureSystems.SupplementalAttributesContainer()", + "data_type": "InfrastructureSystems.SupplementalAttributesContainer", + "default": "InfrastructureSystems.SupplementalAttributesContainer()" + }, + { + "name": "time_series_container", + "comment": "internal time_series storage", + "null_value": "InfrastructureSystems.TimeSeriesContainer()", + "data_type": "InfrastructureSystems.TimeSeriesContainer", + "default": "InfrastructureSystems.TimeSeriesContainer()" + }, + { + "name": "internal", + "comment": "power system internal reference, do not modify", + "data_type": "InfrastructureSystemsInternal", + "internal_default": "InfrastructureSystemsInternal()", + "exclude_setter": true + } + ], + "supertype": "Technology" + }, + { + "struct_name": "SupplyTechnology", + "parametric": "PSY.Generator", + "docstring": "This struct represents a supply technology in a power system.", + "fields": [ + { + "name": "name", + "comment": "The name of the supply technology.", + "data_type": "String" + }, + { + "name": "available", + "comment": "Indicates whether the technology is available or not in the simulation.", + "null_value": "true", + "data_type": "Bool" + }, + { + "name": "power_systems_type", + "comment": "The type of PowerSystems Component this build option translates to.", + "data_type": "Type{T}" + }, + { + "name": "fuel", + "comment": "The type of fuel used by the supply technology.", + "data_type": "PSY.ThermalFuels" + }, + { + "name": "prime_mover", + "comment": "The prime mover of the supply technology.", + "data_type": "PSY.PrimeMovers" + }, + { + "name": "capacity_factor", + "comment": "The capacity factor of the supply technology.", + "data_type": "Float64" + }, + { + "name": "capital_cost", + "comment": "The capital cost of the technology.", + "null_value": "null", + "data_type": "Union{Nothing, IS.FunctionData}" + }, + { + "name": "operational_cost", + "comment": "The operational cost of the supply technology.", + "null_value": "null", + "data_type": "Union{Nothing, PSY.OperationalCost}" + }, + { + "name": "supplemental_attributes_container", + "comment": "Container for supplemental attributes.", + "null_value": "InfrastructureSystems.SupplementalAttributesContainer()", + "data_type": "InfrastructureSystems.SupplementalAttributesContainer", + "default": "InfrastructureSystems.SupplementalAttributesContainer()" + }, + { + "name": "time_series_container", + "comment": "internal time_series storage", + "null_value": "InfrastructureSystems.TimeSeriesContainer()", + "data_type": "InfrastructureSystems.TimeSeriesContainer", + "default": "InfrastructureSystems.TimeSeriesContainer()" + }, + { + "name": "internal", + "comment": "power system internal reference, do not modify", + "data_type": "InfrastructureSystemsInternal", + "internal_default": "InfrastructureSystemsInternal()", + "exclude_setter": true + } + ], + "supertype": "Technology" + }, + { + "struct_name": "TransportTechnology", + "parametric": "PSY.Device", + "docstring": "This struct represents a transport technology in a power system.", + "fields": [ + { + "name": "name", + "comment": "The name of the transport technology.", + "data_type": "String" + }, + { + "name": "available", + "comment": "Indicates whether the technology is available or not in the simulation.", + "null_value": "true", + "data_type": "Bool" + }, + { + "name": "power_systems_type", + "comment": "The type of PowerSystems Component this build option translates to.", + "data_type": "Type{T}" + }, + { + "name": "capital_cost", + "comment": "The capital cost of the technology.", + "data_type": "IS.FunctionData" + }, + { + "name": "supplemental_attributes_container", + "comment": "Container for supplemental attributes.", + "null_value": "InfrastructureSystems.SupplementalAttributesContainer()", + "data_type": "InfrastructureSystems.SupplementalAttributesContainer", + "default": "InfrastructureSystems.SupplementalAttributesContainer()" + }, + { + "name": "time_series_container", + "comment": "internal time_series storage", + "null_value": "InfrastructureSystems.TimeSeriesContainer()", + "data_type": "InfrastructureSystems.TimeSeriesContainer", + "default": "InfrastructureSystems.TimeSeriesContainer()" + }, + { + "name": "internal", + "comment": "power system internal reference, do not modify", + "data_type": "InfrastructureSystemsInternal", + "internal_default": "InfrastructureSystemsInternal()", + "exclude_setter": true + } + ], + "supertype": "Technology" + } + ], + "struct_validation_descriptors": [] +} diff --git a/src/models/DemandRequirement.jl b/src/models/DemandRequirement.jl new file mode 100644 index 0000000..5961da1 --- /dev/null +++ b/src/models/DemandRequirement.jl @@ -0,0 +1,80 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct DemandRequirement{T <: PSY.StaticInjection} <: PSY.StaticInjection + name::String + available::Bool + power_systems_type::Type{T} + region::Union{PSY.ACBus, PSY.AggregationTopology} + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + time_series_container::InfrastructureSystems.TimeSeriesContainer + internal::InfrastructureSystemsInternal + end + +This struct represents the demand requirement for a power system. + +# Arguments +- `name::String`: The name of the load demand requirement. +- `available::Bool`: Indicates whether the load demand is available or not in the simulation. +- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. +- `region::Union{PSY.ACBus, PSY.AggregationTopology}`: The region of the demand requirement. +- `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. +- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage +- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify +""" +mutable struct DemandRequirement{T <: PSY.StaticInjection} <: PSY.StaticInjection + "The name of the load demand requirement." + name::String + "Indicates whether the load demand is available or not in the simulation." + available::Bool + "The type of PowerSystems Component this build option translates to." + power_systems_type::Type{T} + "The region of the demand requirement." + region::Union{PSY.ACBus, PSY.AggregationTopology} + "Container for supplemental attributes." + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + "internal time_series storage" + time_series_container::InfrastructureSystems.TimeSeriesContainer + "power system internal reference, do not modify" + internal::InfrastructureSystemsInternal +end + +function DemandRequirement{T}(name, available, power_systems_type, region, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.StaticInjection + DemandRequirement{T}(name, available, power_systems_type, region, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +end + +function DemandRequirement{T}(; name, available, power_systems_type, region, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.StaticInjection + DemandRequirement{T}(name, available, power_systems_type, region, supplemental_attributes_container, time_series_container, internal, ) +end + +"""Get [`DemandRequirement`](@ref) `name`.""" +get_name(value::DemandRequirement) = value.name +"""Get [`DemandRequirement`](@ref) `available`.""" +get_available(value::DemandRequirement) = value.available +"""Get [`DemandRequirement`](@ref) `power_systems_type`.""" +get_power_systems_type(value::DemandRequirement) = value.power_systems_type +"""Get [`DemandRequirement`](@ref) `region`.""" +get_region(value::DemandRequirement) = value.region +"""Get [`DemandRequirement`](@ref) `supplemental_attributes_container`.""" +get_supplemental_attributes_container(value::DemandRequirement) = value.supplemental_attributes_container +"""Get [`DemandRequirement`](@ref) `time_series_container`.""" +get_time_series_container(value::DemandRequirement) = value.time_series_container +"""Get [`DemandRequirement`](@ref) `internal`.""" +get_internal(value::DemandRequirement) = value.internal + +"""Set [`DemandRequirement`](@ref) `name`.""" +set_name!(value::DemandRequirement, val) = value.name = val +"""Set [`DemandRequirement`](@ref) `available`.""" +set_available!(value::DemandRequirement, val) = value.available = val +"""Set [`DemandRequirement`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::DemandRequirement, val) = value.power_systems_type = val +"""Set [`DemandRequirement`](@ref) `region`.""" +set_region!(value::DemandRequirement, val) = value.region = val +"""Set [`DemandRequirement`](@ref) `supplemental_attributes_container`.""" +set_supplemental_attributes_container!(value::DemandRequirement, val) = value.supplemental_attributes_container = val +"""Set [`DemandRequirement`](@ref) `time_series_container`.""" +set_time_series_container!(value::DemandRequirement, val) = value.time_series_container = val diff --git a/src/models/DemandSideTechnology.jl b/src/models/DemandSideTechnology.jl new file mode 100644 index 0000000..dd550f7 --- /dev/null +++ b/src/models/DemandSideTechnology.jl @@ -0,0 +1,80 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct DemandSideTechnology{T <: PSY.StaticInjection} <: Technology + name::String + available::Bool + power_systems_type::Type{T} + capital_cost::IS.FunctionData + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + time_series_container::InfrastructureSystems.TimeSeriesContainer + internal::InfrastructureSystemsInternal + end + +This struct represents a demand side technology in a power system. + +# Arguments +- `name::String`: The name of the demand side technology. +- `available::Bool`: Indicates whether the technology is available or not in the simulation. +- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. +- `capital_cost::IS.FunctionData`: The capital cost of the technology. +- `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. +- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage +- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify +""" +mutable struct DemandSideTechnology{T <: PSY.StaticInjection} <: Technology + "The name of the demand side technology." + name::String + "Indicates whether the technology is available or not in the simulation." + available::Bool + "The type of PowerSystems Component this build option translates to." + power_systems_type::Type{T} + "The capital cost of the technology." + capital_cost::IS.FunctionData + "Container for supplemental attributes." + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + "internal time_series storage" + time_series_container::InfrastructureSystems.TimeSeriesContainer + "power system internal reference, do not modify" + internal::InfrastructureSystemsInternal +end + +function DemandSideTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.StaticInjection + DemandSideTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +end + +function DemandSideTechnology{T}(; name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.StaticInjection + DemandSideTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, internal, ) +end + +"""Get [`DemandSideTechnology`](@ref) `name`.""" +get_name(value::DemandSideTechnology) = value.name +"""Get [`DemandSideTechnology`](@ref) `available`.""" +get_available(value::DemandSideTechnology) = value.available +"""Get [`DemandSideTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::DemandSideTechnology) = value.power_systems_type +"""Get [`DemandSideTechnology`](@ref) `capital_cost`.""" +get_capital_cost(value::DemandSideTechnology) = value.capital_cost +"""Get [`DemandSideTechnology`](@ref) `supplemental_attributes_container`.""" +get_supplemental_attributes_container(value::DemandSideTechnology) = value.supplemental_attributes_container +"""Get [`DemandSideTechnology`](@ref) `time_series_container`.""" +get_time_series_container(value::DemandSideTechnology) = value.time_series_container +"""Get [`DemandSideTechnology`](@ref) `internal`.""" +get_internal(value::DemandSideTechnology) = value.internal + +"""Set [`DemandSideTechnology`](@ref) `name`.""" +set_name!(value::DemandSideTechnology, val) = value.name = val +"""Set [`DemandSideTechnology`](@ref) `available`.""" +set_available!(value::DemandSideTechnology, val) = value.available = val +"""Set [`DemandSideTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::DemandSideTechnology, val) = value.power_systems_type = val +"""Set [`DemandSideTechnology`](@ref) `capital_cost`.""" +set_capital_cost!(value::DemandSideTechnology, val) = value.capital_cost = val +"""Set [`DemandSideTechnology`](@ref) `supplemental_attributes_container`.""" +set_supplemental_attributes_container!(value::DemandSideTechnology, val) = value.supplemental_attributes_container = val +"""Set [`DemandSideTechnology`](@ref) `time_series_container`.""" +set_time_series_container!(value::DemandSideTechnology, val) = value.time_series_container = val diff --git a/src/models/StorageTechnology.jl b/src/models/StorageTechnology.jl new file mode 100644 index 0000000..14cf953 --- /dev/null +++ b/src/models/StorageTechnology.jl @@ -0,0 +1,104 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct StorageTechnology{T <: PSY.Storage} <: Technology + name::String + available::Bool + power_systems_type::Type{T} + capital_cost::IS.FunctionData + battery_chemistry::String + prime_mover::PSY.PrimeMovers + operational_cost::PSY.OperationalCost + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + time_series_container::InfrastructureSystems.TimeSeriesContainer + internal::InfrastructureSystemsInternal + end + +This struct represents a storage technology in a power system. + +# Arguments +- `name::String`: The name of the storage technology. +- `available::Bool`: Indicates whether the technology is available or not in the simulation. +- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. +- `capital_cost::IS.FunctionData`: The capital cost of the technology. +- `battery_chemistry::String`: The type of battery chemistry. Implement Chemistry Type Enums in PowerSystems. +- `prime_mover::PSY.PrimeMovers`: The prime mover of the storage technology. +- `operational_cost::PSY.OperationalCost`: The operational cost of the storage technology. +- `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. +- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage +- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify +""" +mutable struct StorageTechnology{T <: PSY.Storage} <: Technology + "The name of the storage technology." + name::String + "Indicates whether the technology is available or not in the simulation." + available::Bool + "The type of PowerSystems Component this build option translates to." + power_systems_type::Type{T} + "The capital cost of the technology." + capital_cost::IS.FunctionData + "The type of battery chemistry. Implement Chemistry Type Enums in PowerSystems." + battery_chemistry::String + "The prime mover of the storage technology." + prime_mover::PSY.PrimeMovers + "The operational cost of the storage technology." + operational_cost::PSY.OperationalCost + "Container for supplemental attributes." + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + "internal time_series storage" + time_series_container::InfrastructureSystems.TimeSeriesContainer + "power system internal reference, do not modify" + internal::InfrastructureSystemsInternal +end + +function StorageTechnology{T}(name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Storage + StorageTechnology{T}(name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +end + +function StorageTechnology{T}(; name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Storage + StorageTechnology{T}(name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container, time_series_container, internal, ) +end + +"""Get [`StorageTechnology`](@ref) `name`.""" +get_name(value::StorageTechnology) = value.name +"""Get [`StorageTechnology`](@ref) `available`.""" +get_available(value::StorageTechnology) = value.available +"""Get [`StorageTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::StorageTechnology) = value.power_systems_type +"""Get [`StorageTechnology`](@ref) `capital_cost`.""" +get_capital_cost(value::StorageTechnology) = value.capital_cost +"""Get [`StorageTechnology`](@ref) `battery_chemistry`.""" +get_battery_chemistry(value::StorageTechnology) = value.battery_chemistry +"""Get [`StorageTechnology`](@ref) `prime_mover`.""" +get_prime_mover(value::StorageTechnology) = value.prime_mover +"""Get [`StorageTechnology`](@ref) `operational_cost`.""" +get_operational_cost(value::StorageTechnology) = value.operational_cost +"""Get [`StorageTechnology`](@ref) `supplemental_attributes_container`.""" +get_supplemental_attributes_container(value::StorageTechnology) = value.supplemental_attributes_container +"""Get [`StorageTechnology`](@ref) `time_series_container`.""" +get_time_series_container(value::StorageTechnology) = value.time_series_container +"""Get [`StorageTechnology`](@ref) `internal`.""" +get_internal(value::StorageTechnology) = value.internal + +"""Set [`StorageTechnology`](@ref) `name`.""" +set_name!(value::StorageTechnology, val) = value.name = val +"""Set [`StorageTechnology`](@ref) `available`.""" +set_available!(value::StorageTechnology, val) = value.available = val +"""Set [`StorageTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::StorageTechnology, val) = value.power_systems_type = val +"""Set [`StorageTechnology`](@ref) `capital_cost`.""" +set_capital_cost!(value::StorageTechnology, val) = value.capital_cost = val +"""Set [`StorageTechnology`](@ref) `battery_chemistry`.""" +set_battery_chemistry!(value::StorageTechnology, val) = value.battery_chemistry = val +"""Set [`StorageTechnology`](@ref) `prime_mover`.""" +set_prime_mover!(value::StorageTechnology, val) = value.prime_mover = val +"""Set [`StorageTechnology`](@ref) `operational_cost`.""" +set_operational_cost!(value::StorageTechnology, val) = value.operational_cost = val +"""Set [`StorageTechnology`](@ref) `supplemental_attributes_container`.""" +set_supplemental_attributes_container!(value::StorageTechnology, val) = value.supplemental_attributes_container = val +"""Set [`StorageTechnology`](@ref) `time_series_container`.""" +set_time_series_container!(value::StorageTechnology, val) = value.time_series_container = val diff --git a/src/models/SupplyTechnology.jl b/src/models/SupplyTechnology.jl new file mode 100644 index 0000000..ba3f374 --- /dev/null +++ b/src/models/SupplyTechnology.jl @@ -0,0 +1,112 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct SupplyTechnology{T <: PSY.Generator} <: Technology + name::String + available::Bool + power_systems_type::Type{T} + fuel::PSY.ThermalFuels + prime_mover::PSY.PrimeMovers + capacity_factor::Float64 + capital_cost::Union{Nothing, IS.FunctionData} + operational_cost::Union{Nothing, PSY.OperationalCost} + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + time_series_container::InfrastructureSystems.TimeSeriesContainer + internal::InfrastructureSystemsInternal + end + +This struct represents a supply technology in a power system. + +# Arguments +- `name::String`: The name of the supply technology. +- `available::Bool`: Indicates whether the technology is available or not in the simulation. +- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. +- `fuel::PSY.ThermalFuels`: The type of fuel used by the supply technology. +- `prime_mover::PSY.PrimeMovers`: The prime mover of the supply technology. +- `capacity_factor::Float64`: The capacity factor of the supply technology. +- `capital_cost::Union{Nothing, IS.FunctionData}`: The capital cost of the technology. +- `operational_cost::Union{Nothing, PSY.OperationalCost}`: The operational cost of the supply technology. +- `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. +- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage +- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify +""" +mutable struct SupplyTechnology{T <: PSY.Generator} <: Technology + "The name of the supply technology." + name::String + "Indicates whether the technology is available or not in the simulation." + available::Bool + "The type of PowerSystems Component this build option translates to." + power_systems_type::Type{T} + "The type of fuel used by the supply technology." + fuel::PSY.ThermalFuels + "The prime mover of the supply technology." + prime_mover::PSY.PrimeMovers + "The capacity factor of the supply technology." + capacity_factor::Float64 + "The capital cost of the technology." + capital_cost::Union{Nothing, IS.FunctionData} + "The operational cost of the supply technology." + operational_cost::Union{Nothing, PSY.OperationalCost} + "Container for supplemental attributes." + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + "internal time_series storage" + time_series_container::InfrastructureSystems.TimeSeriesContainer + "power system internal reference, do not modify" + internal::InfrastructureSystemsInternal +end + +function SupplyTechnology{T}(name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Generator + SupplyTechnology{T}(name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +end + +function SupplyTechnology{T}(; name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Generator + SupplyTechnology{T}(name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container, time_series_container, internal, ) +end + +"""Get [`SupplyTechnology`](@ref) `name`.""" +get_name(value::SupplyTechnology) = value.name +"""Get [`SupplyTechnology`](@ref) `available`.""" +get_available(value::SupplyTechnology) = value.available +"""Get [`SupplyTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::SupplyTechnology) = value.power_systems_type +"""Get [`SupplyTechnology`](@ref) `fuel`.""" +get_fuel(value::SupplyTechnology) = value.fuel +"""Get [`SupplyTechnology`](@ref) `prime_mover`.""" +get_prime_mover(value::SupplyTechnology) = value.prime_mover +"""Get [`SupplyTechnology`](@ref) `capacity_factor`.""" +get_capacity_factor(value::SupplyTechnology) = value.capacity_factor +"""Get [`SupplyTechnology`](@ref) `capital_cost`.""" +get_capital_cost(value::SupplyTechnology) = value.capital_cost +"""Get [`SupplyTechnology`](@ref) `operational_cost`.""" +get_operational_cost(value::SupplyTechnology) = value.operational_cost +"""Get [`SupplyTechnology`](@ref) `supplemental_attributes_container`.""" +get_supplemental_attributes_container(value::SupplyTechnology) = value.supplemental_attributes_container +"""Get [`SupplyTechnology`](@ref) `time_series_container`.""" +get_time_series_container(value::SupplyTechnology) = value.time_series_container +"""Get [`SupplyTechnology`](@ref) `internal`.""" +get_internal(value::SupplyTechnology) = value.internal + +"""Set [`SupplyTechnology`](@ref) `name`.""" +set_name!(value::SupplyTechnology, val) = value.name = val +"""Set [`SupplyTechnology`](@ref) `available`.""" +set_available!(value::SupplyTechnology, val) = value.available = val +"""Set [`SupplyTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::SupplyTechnology, val) = value.power_systems_type = val +"""Set [`SupplyTechnology`](@ref) `fuel`.""" +set_fuel!(value::SupplyTechnology, val) = value.fuel = val +"""Set [`SupplyTechnology`](@ref) `prime_mover`.""" +set_prime_mover!(value::SupplyTechnology, val) = value.prime_mover = val +"""Set [`SupplyTechnology`](@ref) `capacity_factor`.""" +set_capacity_factor!(value::SupplyTechnology, val) = value.capacity_factor = val +"""Set [`SupplyTechnology`](@ref) `capital_cost`.""" +set_capital_cost!(value::SupplyTechnology, val) = value.capital_cost = val +"""Set [`SupplyTechnology`](@ref) `operational_cost`.""" +set_operational_cost!(value::SupplyTechnology, val) = value.operational_cost = val +"""Set [`SupplyTechnology`](@ref) `supplemental_attributes_container`.""" +set_supplemental_attributes_container!(value::SupplyTechnology, val) = value.supplemental_attributes_container = val +"""Set [`SupplyTechnology`](@ref) `time_series_container`.""" +set_time_series_container!(value::SupplyTechnology, val) = value.time_series_container = val diff --git a/src/models/TransportTechnology.jl b/src/models/TransportTechnology.jl new file mode 100644 index 0000000..007c064 --- /dev/null +++ b/src/models/TransportTechnology.jl @@ -0,0 +1,80 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct TransportTechnology{T <: PSY.Device} <: Technology + name::String + available::Bool + power_systems_type::Type{T} + capital_cost::IS.FunctionData + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + time_series_container::InfrastructureSystems.TimeSeriesContainer + internal::InfrastructureSystemsInternal + end + +This struct represents a transport technology in a power system. + +# Arguments +- `name::String`: The name of the transport technology. +- `available::Bool`: Indicates whether the technology is available or not in the simulation. +- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. +- `capital_cost::IS.FunctionData`: The capital cost of the technology. +- `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. +- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage +- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify +""" +mutable struct TransportTechnology{T <: PSY.Device} <: Technology + "The name of the transport technology." + name::String + "Indicates whether the technology is available or not in the simulation." + available::Bool + "The type of PowerSystems Component this build option translates to." + power_systems_type::Type{T} + "The capital cost of the technology." + capital_cost::IS.FunctionData + "Container for supplemental attributes." + supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer + "internal time_series storage" + time_series_container::InfrastructureSystems.TimeSeriesContainer + "power system internal reference, do not modify" + internal::InfrastructureSystemsInternal +end + +function TransportTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Device + TransportTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +end + +function TransportTechnology{T}(; name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Device + TransportTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, internal, ) +end + +"""Get [`TransportTechnology`](@ref) `name`.""" +get_name(value::TransportTechnology) = value.name +"""Get [`TransportTechnology`](@ref) `available`.""" +get_available(value::TransportTechnology) = value.available +"""Get [`TransportTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::TransportTechnology) = value.power_systems_type +"""Get [`TransportTechnology`](@ref) `capital_cost`.""" +get_capital_cost(value::TransportTechnology) = value.capital_cost +"""Get [`TransportTechnology`](@ref) `supplemental_attributes_container`.""" +get_supplemental_attributes_container(value::TransportTechnology) = value.supplemental_attributes_container +"""Get [`TransportTechnology`](@ref) `time_series_container`.""" +get_time_series_container(value::TransportTechnology) = value.time_series_container +"""Get [`TransportTechnology`](@ref) `internal`.""" +get_internal(value::TransportTechnology) = value.internal + +"""Set [`TransportTechnology`](@ref) `name`.""" +set_name!(value::TransportTechnology, val) = value.name = val +"""Set [`TransportTechnology`](@ref) `available`.""" +set_available!(value::TransportTechnology, val) = value.available = val +"""Set [`TransportTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::TransportTechnology, val) = value.power_systems_type = val +"""Set [`TransportTechnology`](@ref) `capital_cost`.""" +set_capital_cost!(value::TransportTechnology, val) = value.capital_cost = val +"""Set [`TransportTechnology`](@ref) `supplemental_attributes_container`.""" +set_supplemental_attributes_container!(value::TransportTechnology, val) = value.supplemental_attributes_container = val +"""Set [`TransportTechnology`](@ref) `time_series_container`.""" +set_time_series_container!(value::TransportTechnology, val) = value.time_series_container = val From 25822845d958e4de66d49b03f048b808ed413819 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Tue, 9 Apr 2024 18:51:11 -0600 Subject: [PATCH 06/12] adding serialization --- Project.toml | 1 + src/models/includes.jl | 30 +++++++++++++++ src/models/serialization.jl | 74 +++++++++++++++++++++++++++++++++++++ src/portfolio.jl | 39 ++++++++++++++++--- 4 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 src/models/includes.jl create mode 100644 src/models/serialization.jl diff --git a/Project.toml b/Project.toml index 71c7f87..f565485 100644 --- a/Project.toml +++ b/Project.toml @@ -6,6 +6,7 @@ version = "0.1.0" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1" +JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd" PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" diff --git a/src/models/includes.jl b/src/models/includes.jl new file mode 100644 index 0000000..d66f3ca --- /dev/null +++ b/src/models/includes.jl @@ -0,0 +1,30 @@ +include("DemandRequirement.jl") +include("DemandSideTechnology.jl") +include("StorageTechnology.jl") +include("SupplyTechnology.jl") +include("TransportTechnology.jl") + +export get_available +export get_battery_chemistry +export get_capacity_factor +export get_capital_cost +export get_fuel +export get_name +export get_operational_cost +export get_power_systems_type +export get_prime_mover +export get_region +export get_supplemental_attributes_container +export get_time_series_container +export set_available! +export set_battery_chemistry! +export set_capacity_factor! +export set_capital_cost! +export set_fuel! +export set_name! +export set_operational_cost! +export set_power_systems_type! +export set_prime_mover! +export set_region! +export set_supplemental_attributes_container! +export set_time_series_container! diff --git a/src/models/serialization.jl b/src/models/serialization.jl new file mode 100644 index 0000000..9db8053 --- /dev/null +++ b/src/models/serialization.jl @@ -0,0 +1,74 @@ +const _ENCODE_AS_UUID_A = ( + Union{Nothing, PSY.Arc}, + Union{Nothing, PSY.Area}, + Union{Nothing, PSY.Bus}, + Union{Nothing, PSY.LoadZone}, + Union{Nothing, PSY.DynamicInjection}, + Union{Nothing, PSY.StaticInjection}, + Vector{PSY.Service}, + PSY.ThermalGen, + PSY.Storage, + PSY.StaticLoad, + PSY.RenewableGen +) + +const _ENCODE_AS_UUID_B = ( + PSY.Arc, + PSY.Area, + PSY.Bus, + PSY.LoadZone, + PSY.DynamicInjection, + PSY.StaticInjection, + Vector{PSY.Service}, + PSY.ThermalGen, + PSY.Storage, + PSY.StaticLoad, + PSY.RenewableGen +) + +@assert length(_ENCODE_AS_UUID_A) == length(_ENCODE_AS_UUID_B) + +should_encode_as_uuid(val) = any(x -> val isa x, _ENCODE_AS_UUID_B) +# TODO: how does this work? +should_encode_as_uuid(::Type{T}) where {T} = !any(x -> T <: x, _ENCODE_AS_UUID_A) + + +function IS.serialize(technology::T) where {T <: Technology} + @debug "serialize" _group = IS.LOG_GROUP_SERIALIZATION technology T + data = Dict{String, Any}() + for name in fieldnames(T) + val = serialize_uuid_handling(getfield(technology, name)) + if name == :ext + if !IS.is_ext_valid_for_serialization(val) + error( + "technology type=$T name=$(get_name(technology)) has a value in its " * + "ext field that cannot be serialized.", + ) + end + end + data[string(name)] = val + end + + IS.add_serialization_metadata!(data, T) + + # This is a temporary workaround until these types are not parameterized. + data[IS.METADATA_KEY][IS.CONSTRUCT_WITH_PARAMETERS_KEY] = true + + return data +end + +function serialize_uuid_handling(val) + if should_encode_as_uuid(val) + if val isa Array + value = IS.get_uuid.(val) + elseif val === nothing + value = nothing + else + value = IS.get_uuid(val) + end + else + value = val + end + + return serialize(value) +end diff --git a/src/portfolio.jl b/src/portfolio.jl index 56cc31f..e18f9c2 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -19,7 +19,7 @@ struct Portfolio <: IS.InfrastructureSystemsType #units_settings::IS.SystemUnitsSettings time_series_directory::Union{Nothing, String} time_series_container::IS.TimeSeriesContainer - metadata::PortfolioMetadata +metadata::PortfolioMetadata internal::IS.InfrastructureSystemsInternal function Portfolio( @@ -552,19 +552,46 @@ function has_technology( return IS.has_component(T, portfolio.data.components, name) end -function IS.serialize(portfolio::Portfolio) - return + +function IS.serialize(portfolio::T) where {T <: Portfolio} + data = Dict{String, Any}() + data["data_format_version"] = DATA_FORMAT_VERSION + for field in fieldnames(T) + # Exclude bus_numbers because they will get rebuilt during deserialization. + # Exclude time_series_directory because the portfolio may get deserialized on a + # different portfolio. + if field != :bus_numbers && field != :time_series_directory + data[string(field)] = serialize(getfield(portfolio, field)) + end + end + + return data end function IS.deserialize( ::Type{Portfolio}, - filename::AbstractString; + filename::AbstractString, time_series_read_only=false, time_series_directory=nothing, kwargs..., ) - portfolio = nothing - return portfolio + raw = open(filename) do io + JSON3.read(io, Dict) + end + + if raw["data_format_version"] != DATA_FORMAT_VERSION + pre_read_conversion!(raw) + end + + # These file paths are relative to the system file. + directory = dirname(filename) + for file_key in ("time_series_storage_file",) + if haskey(raw["data"], file_key) && !isabspath(raw["data"][file_key]) + raw["data"][file_key] = joinpath(directory, raw["data"][file_key]) + end + end + + return from_dict(Portfolio, raw; kwargs...) end function deserialize_components!(portfolio::Portfolio, raw) end From 60193d225594b315ed05a247cd50ed04553309b4 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Tue, 9 Apr 2024 18:51:22 -0600 Subject: [PATCH 07/12] updating test script --- scripts/portfolio_test.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/portfolio_test.jl b/scripts/portfolio_test.jl index 4381acb..568e1a3 100644 --- a/scripts/portfolio_test.jl +++ b/scripts/portfolio_test.jl @@ -20,10 +20,9 @@ t = SupplyTechnology{ThermalStandard}( 0.98, # cap factor nothing, nothing, - IS.SupplementalAttributesContainer(), - IS.TimeSeriesContainer(), - IS.InfrastructureSystemsInternal(), ) PSIP.add_technology!(p, t) +IS.serialize(t) +IS.serialize(p) PSIP.remove_technology!(SupplyTechnology{ThermalStandard}, p, "thermal_tech") From e43614e53a0f1faa2c0e95bb9be89f7fc2576a36 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Tue, 9 Apr 2024 19:08:44 -0600 Subject: [PATCH 08/12] adding to_json function --- Project.toml | 1 + src/PowerSystemsInvestmentsPortfolios.jl | 1 + src/portfolio.jl | 115 +++++++++++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/Project.toml b/Project.toml index f565485..2b4dfc6 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ authors = ["Jose Daniel Lara", "Sourabh Dalvi"] version = "0.1.0" [deps] +DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" diff --git a/src/PowerSystemsInvestmentsPortfolios.jl b/src/PowerSystemsInvestmentsPortfolios.jl index 3ded9fe..7f5cf92 100644 --- a/src/PowerSystemsInvestmentsPortfolios.jl +++ b/src/PowerSystemsInvestmentsPortfolios.jl @@ -83,6 +83,7 @@ const IS = InfrastructureSystems import PowerSystems import PrettyTables import JSON3 +import DataStructures: OrderedDict export Portfolio export SupplyTechnology diff --git a/src/portfolio.jl b/src/portfolio.jl index e18f9c2..4dde2e5 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -600,3 +600,118 @@ function _is_deserialization_in_progress(portfolio::Portfolio) ext = get_ext(portfolio) return get(ext, "deserialization_in_progress", false) end + + +""" +Serializes a portfolio to a JSON file and saves time series to an HDF5 file. + +# Arguments +- `portfolio::Portfolio`: portfolio +- `filename::AbstractString`: filename to write + +# Keyword arguments +- `user_data::Union{Nothing, Dict} = nothing`: optional metadata to record +- `pretty::Bool = false`: whether to pretty-print the JSON +- `force::Bool = false`: whether to overwrite existing files +- `check::Bool = false`: whether to run portfolio validation checks + +Refer to [`check_component`](@ref) for exceptions thrown if `check = true`. +""" +function IS.to_json( + portfolio::Portfolio, + filename::AbstractString; + user_data = nothing, + pretty = false, + force = false, + runchecks = false, +) + # TODO: add checks for portfolio and technology + # if runchecks + # check(portfolio) + # check_technologies(portfolio) + # end + + IS.prepare_for_serialization_to_file!(portfolio.data, filename; force = force) + data = to_json(portfolio; pretty = pretty) + open(filename, "w") do io + write(io, data) + end + + mfile = joinpath(dirname(filename), splitext(basename(filename))[1] * "_metadata.json") + _serialize_portfolio_metadata_to_file(portfolio, mfile, user_data) + @info "Serialized Portfolio to $filename" + + return +end + +function _serialize_portfolio_metadata_to_file(portfolio::Portfolio, filename, user_data) + name = get_name(portfolio) + description = get_description(portfolio) + resolution = get_time_series_resolution(portfolio).value + metadata = OrderedDict( + "name" => isnothing(name) ? "" : name, + "description" => isnothing(description) ? "" : description, + "time_series_resolution_milliseconds" => resolution, + "component_counts" => IS.get_component_counts_by_type(portfolio.data), + "time_series_counts" => IS.get_time_series_counts_by_type(portfolio.data), + ) + if !isnothing(user_data) + metadata["user_data"] = user_data + end + + open(filename, "w") do io + JSON3.pretty(io, metadata) + end + + @info "Serialized Portfolio metadata to $filename" +end + + +""" +If assign_new_uuids = true, generate new UUIDs for the portfolio and all components. + +Warning: time series data is not restored by this method. If that is needed, use the normal +process to construct the portfolio from a serialized JSON file instead, such as with +`Portfolio("portfolio.json")`. +""" +function IS.from_json( + io::Union{IO, String}, + ::Type{Portfolio}; + runchecks = true, + assign_new_uuids = false, + kwargs..., +) + data = JSON3.read(io, Dict) + # These objects could be removed in to_json(portfolio). Doing it here will allow us to + # keep that JSON string fully consistent with time series and potentially use it in the + # future. + for component in data["data"]["components"] + if haskey(component, "time_series_container") + empty!(component["time_series_container"]) + end + end + + portfolio = from_dict(Portfolio, data; kwargs...) + _post_deserialize_handling( + portfolio; + runchecks = runchecks, + assign_new_uuids = assign_new_uuids, + ) + return portfolio +end + +function _post_deserialize_handling(portfolio::Portfolio; runchecks = true, assign_new_uuids = false) + runchecks && check(portfolio) + if assign_new_uuids + IS.assign_new_uuid!(portfolio) + for component in get_components(Technology, portfolio) + assign_new_uuid!(portfolio, component) + end + for component in + IS.get_masked_components(InfrastructureSystemsComponent, portfolio.data) + assign_new_uuid!(portfolio, component) + end + # Note: this does not change UUIDs for time series data because they are + # shared with components. + end +end From 5e5efc731a316b61b35f082609e35b7dabdcde80 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Thu, 11 Apr 2024 10:22:10 -0600 Subject: [PATCH 09/12] removing old files --- src/demand_requirement.jl | 9 --------- src/demand_side.jl | 9 --------- src/storage.jl | 14 -------------- src/supply.jl | 38 -------------------------------------- src/transport.jl | 9 --------- 5 files changed, 79 deletions(-) delete mode 100644 src/demand_requirement.jl delete mode 100644 src/demand_side.jl delete mode 100644 src/storage.jl delete mode 100644 src/supply.jl delete mode 100644 src/transport.jl diff --git a/src/demand_requirement.jl b/src/demand_requirement.jl deleted file mode 100644 index a111187..0000000 --- a/src/demand_requirement.jl +++ /dev/null @@ -1,9 +0,0 @@ -struct DemandRequirement{T <: PSY.StaticInjection} - name::String - available::Bool - power_systems_type::Type{T} - region::Union{PSY.ACBus, PSY.AggregationTopology} - supplemental_attributes_container::IS.SupplementalAttributesContainer - time_series_container::IS.TimeSeriesContainer - internal::InfrastructureSystemsInternal -end diff --git a/src/demand_side.jl b/src/demand_side.jl deleted file mode 100644 index 75fe348..0000000 --- a/src/demand_side.jl +++ /dev/null @@ -1,9 +0,0 @@ -struct DemandSideTechnology{T <: PSY.StaticInjection} <: Technology - name::String - available::Bool - power_systems_type::Type{T} - capital_cost::IS.FunctionData - supplemental_attributes_container::IS.SupplementalAttributesContainer - time_series_container::IS.TimeSeriesContainer - internal::InfrastructureSystemsInternal -end diff --git a/src/storage.jl b/src/storage.jl deleted file mode 100644 index b9844a8..0000000 --- a/src/storage.jl +++ /dev/null @@ -1,14 +0,0 @@ -struct StorageTechnology{T <: PSY.Storage} <: Technology - name::String - available::Bool - power_systems_type::Type{T} - capital_cost::IS.FunctionData - battery_chemistry::String # Implement Chemistry Type Enums in PowerSystems - prime_mover::PSY.PrimeMovers - operational_cost::PSY.OperationalCost - supplemental_attributes_container::IS.SupplementalAttributesContainer - time_series_container::IS.TimeSeriesContainer - internal::InfrastructureSystemsInternal -end - -get_name(technology::StorageTechnology) = technology.name diff --git a/src/supply.jl b/src/supply.jl deleted file mode 100644 index 6becb00..0000000 --- a/src/supply.jl +++ /dev/null @@ -1,38 +0,0 @@ -struct SupplyTechnology{T <: PSY.Generator} <: Technology - name::String - available::Bool - power_systems_type::Type{T} - fuel::PSY.ThermalFuels - prime_mover::PSY.PrimeMovers - capacity_factor::Float64 - capital_cost::Union{Nothing, IS.FunctionData} - operational_cost::Union{Nothing, PSY.OperationalCost} - supplemental_attributes_container::IS.SupplementalAttributesContainer - time_series_container::IS.TimeSeriesContainer - internal::IS.InfrastructureSystemsInternal -end - - -function SupplyTechnology(name, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container=IS.TimeSeriesContainer(), ) - SupplyTechnology(nunamember, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container, IS.InfrastructureSystemsInternal(), ) -end - -function SupplyTechnology(; name, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container=IS.TimeSeriesContainer(), internal=IS.InfrastructureSystemsInternal(), ) - SupplyTechnology(name, available, power_systems_type, fuel, prime_mover, capacity_factor, operational_cost, supplemental_attributes_container, time_series_container, internal) -end - -# Constructor for demo purposes; non-functional. -function SupplyTechnology(::Nothing) - SupplyTechnology(; - name="init", - available=false, - power_systems_type = PSY.ThermalStandard, - fuel = PSY.ThermalFuels.NG, - prime_mover = PSY.PrimeMovers.CT, - capacity_factor = 0.9, - capital_cost = IS.FunctionData(nothing), - operational_cost = PSY.ThreePartCost(nothing), - supplemental_attributes_container = IS.SupplementalAttributesContainer(nothing), - time_series_container=IS.TimeSeriesContainer(), - ) -end \ No newline at end of file diff --git a/src/transport.jl b/src/transport.jl deleted file mode 100644 index 06ddcfb..0000000 --- a/src/transport.jl +++ /dev/null @@ -1,9 +0,0 @@ -struct TransportTechnology{T <: PSY.Device} <: Technology - name::String - available::Bool - power_systems_type::Type{T} - capital_cost::IS.FunctionData - supplemental_attributes_container::IS.SupplementalAttributesContainer - time_series_container::IS.TimeSeriesContainer - internal::InfrastructureSystemsInternal -end From eefce028288f88da09db12c8677d29b2b341411c Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Fri, 12 Apr 2024 18:12:54 -0500 Subject: [PATCH 10/12] updating structs --- src/PowerSystemsInvestmentsPortfolios.jl | 18 ++- src/descriptors/portfolio_structs.json | 55 ++++--- src/models/DemandRequirement.jl | 23 ++- src/models/DemandSideTechnology.jl | 23 ++- src/models/StorageTechnology.jl | 23 ++- src/models/SupplyTechnology.jl | 23 ++- src/models/TransportTechnology.jl | 23 ++- src/models/includes.jl | 4 +- src/models/serialization.jl | 72 ++++++++- src/portfolio.jl | 196 ++++++++++++++++++++++- 10 files changed, 365 insertions(+), 95 deletions(-) diff --git a/src/PowerSystemsInvestmentsPortfolios.jl b/src/PowerSystemsInvestmentsPortfolios.jl index 7f5cf92..4497797 100644 --- a/src/PowerSystemsInvestmentsPortfolios.jl +++ b/src/PowerSystemsInvestmentsPortfolios.jl @@ -9,7 +9,21 @@ import PowerSystems: get_time_series_array, get_time_series_timestamps, get_time_series_values, - get_time_series_names + get_time_series_names, + ThermalGen, + HydroGen, + RenewableGen, + Storage, + ThermalStandard, + ThermalMultiStart, + ThermalFuels, + PrimeMovers, + RenewableFix, + RenewableDispatch, + GenericBattery, + BatteryEMS, + HydroEnergyReservoir, + HydroDispatch import InfrastructureSystems import InfrastructureSystems: @@ -35,6 +49,8 @@ import InfrastructureSystems: InvalidRange, InvalidValue, copy_time_series!, + clear_ext!, + get_type_from_serialization_data, get_count, get_data, get_horizon, diff --git a/src/descriptors/portfolio_structs.json b/src/descriptors/portfolio_structs.json index ad1987b..ab0adee 100644 --- a/src/descriptors/portfolio_structs.json +++ b/src/descriptors/portfolio_structs.json @@ -16,16 +16,17 @@ "null_value": "true", "data_type": "Bool" }, - { - "name": "power_systems_type", - "comment": "The type of PowerSystems Component this build option translates to.", - "data_type": "Type{T}" - }, { "name": "region", "comment": "The region of the demand requirement.", "data_type": "Union{PSY.ACBus, PSY.AggregationTopology}" }, + { + "name": "ext", + "data_type": "Dict{String, Any}", + "null_value": "Dict{String, Any}()", + "default": "Dict{String, Any}()" + }, { "name": "supplemental_attributes_container", "comment": "Container for supplemental attributes.", @@ -66,16 +67,17 @@ "null_value": "true", "data_type": "Bool" }, - { - "name": "power_systems_type", - "comment": "The type of PowerSystems Component this build option translates to.", - "data_type": "Type{T}" - }, { "name": "capital_cost", "comment": "The capital cost of the technology.", "data_type": "IS.FunctionData" }, + { + "name": "ext", + "data_type": "Dict{String, Any}", + "null_value": "Dict{String, Any}()", + "default": "Dict{String, Any}()" + }, { "name": "supplemental_attributes_container", "comment": "Container for supplemental attributes.", @@ -116,11 +118,6 @@ "null_value": "true", "data_type": "Bool" }, - { - "name": "power_systems_type", - "comment": "The type of PowerSystems Component this build option translates to.", - "data_type": "Type{T}" - }, { "name": "capital_cost", "comment": "The capital cost of the technology.", @@ -141,6 +138,12 @@ "comment": "The operational cost of the storage technology.", "data_type": "PSY.OperationalCost" }, + { + "name": "ext", + "data_type": "Dict{String, Any}", + "null_value": "Dict{String, Any}()", + "default": "Dict{String, Any}()" + }, { "name": "supplemental_attributes_container", "comment": "Container for supplemental attributes.", @@ -181,11 +184,6 @@ "null_value": "true", "data_type": "Bool" }, - { - "name": "power_systems_type", - "comment": "The type of PowerSystems Component this build option translates to.", - "data_type": "Type{T}" - }, { "name": "fuel", "comment": "The type of fuel used by the supply technology.", @@ -213,6 +211,12 @@ "null_value": "null", "data_type": "Union{Nothing, PSY.OperationalCost}" }, + { + "name": "ext", + "data_type": "Dict{String, Any}", + "null_value": "Dict{String, Any}()", + "default": "Dict{String, Any}()" + }, { "name": "supplemental_attributes_container", "comment": "Container for supplemental attributes.", @@ -253,16 +257,17 @@ "null_value": "true", "data_type": "Bool" }, - { - "name": "power_systems_type", - "comment": "The type of PowerSystems Component this build option translates to.", - "data_type": "Type{T}" - }, { "name": "capital_cost", "comment": "The capital cost of the technology.", "data_type": "IS.FunctionData" }, + { + "name": "ext", + "data_type": "Dict{String, Any}", + "null_value": "Dict{String, Any}()", + "default": "Dict{String, Any}()" + }, { "name": "supplemental_attributes_container", "comment": "Container for supplemental attributes.", diff --git a/src/models/DemandRequirement.jl b/src/models/DemandRequirement.jl index 5961da1..4855444 100644 --- a/src/models/DemandRequirement.jl +++ b/src/models/DemandRequirement.jl @@ -8,8 +8,8 @@ This file is auto-generated. Do not edit. mutable struct DemandRequirement{T <: PSY.StaticInjection} <: PSY.StaticInjection name::String available::Bool - power_systems_type::Type{T} region::Union{PSY.ACBus, PSY.AggregationTopology} + ext::Dict{String, Any} supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer time_series_container::InfrastructureSystems.TimeSeriesContainer internal::InfrastructureSystemsInternal @@ -20,8 +20,8 @@ This struct represents the demand requirement for a power system. # Arguments - `name::String`: The name of the load demand requirement. - `available::Bool`: Indicates whether the load demand is available or not in the simulation. -- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. - `region::Union{PSY.ACBus, PSY.AggregationTopology}`: The region of the demand requirement. +- `ext::Dict{String, Any}` - `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. - `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage - `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify @@ -31,10 +31,9 @@ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: PSY.StaticInjectio name::String "Indicates whether the load demand is available or not in the simulation." available::Bool - "The type of PowerSystems Component this build option translates to." - power_systems_type::Type{T} "The region of the demand requirement." region::Union{PSY.ACBus, PSY.AggregationTopology} + ext::Dict{String, Any} "Container for supplemental attributes." supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer "internal time_series storage" @@ -43,22 +42,22 @@ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: PSY.StaticInjectio internal::InfrastructureSystemsInternal end -function DemandRequirement{T}(name, available, power_systems_type, region, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.StaticInjection - DemandRequirement{T}(name, available, power_systems_type, region, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +function DemandRequirement{T}(name, available, region, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.StaticInjection + DemandRequirement{T}(name, available, region, ext, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) end -function DemandRequirement{T}(; name, available, power_systems_type, region, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.StaticInjection - DemandRequirement{T}(name, available, power_systems_type, region, supplemental_attributes_container, time_series_container, internal, ) +function DemandRequirement{T}(; name, available, region, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.StaticInjection + DemandRequirement{T}(name, available, region, ext, supplemental_attributes_container, time_series_container, internal, ) end """Get [`DemandRequirement`](@ref) `name`.""" get_name(value::DemandRequirement) = value.name """Get [`DemandRequirement`](@ref) `available`.""" get_available(value::DemandRequirement) = value.available -"""Get [`DemandRequirement`](@ref) `power_systems_type`.""" -get_power_systems_type(value::DemandRequirement) = value.power_systems_type """Get [`DemandRequirement`](@ref) `region`.""" get_region(value::DemandRequirement) = value.region +"""Get [`DemandRequirement`](@ref) `ext`.""" +get_ext(value::DemandRequirement) = value.ext """Get [`DemandRequirement`](@ref) `supplemental_attributes_container`.""" get_supplemental_attributes_container(value::DemandRequirement) = value.supplemental_attributes_container """Get [`DemandRequirement`](@ref) `time_series_container`.""" @@ -70,10 +69,10 @@ get_internal(value::DemandRequirement) = value.internal set_name!(value::DemandRequirement, val) = value.name = val """Set [`DemandRequirement`](@ref) `available`.""" set_available!(value::DemandRequirement, val) = value.available = val -"""Set [`DemandRequirement`](@ref) `power_systems_type`.""" -set_power_systems_type!(value::DemandRequirement, val) = value.power_systems_type = val """Set [`DemandRequirement`](@ref) `region`.""" set_region!(value::DemandRequirement, val) = value.region = val +"""Set [`DemandRequirement`](@ref) `ext`.""" +set_ext!(value::DemandRequirement, val) = value.ext = val """Set [`DemandRequirement`](@ref) `supplemental_attributes_container`.""" set_supplemental_attributes_container!(value::DemandRequirement, val) = value.supplemental_attributes_container = val """Set [`DemandRequirement`](@ref) `time_series_container`.""" diff --git a/src/models/DemandSideTechnology.jl b/src/models/DemandSideTechnology.jl index dd550f7..7839b6b 100644 --- a/src/models/DemandSideTechnology.jl +++ b/src/models/DemandSideTechnology.jl @@ -8,8 +8,8 @@ This file is auto-generated. Do not edit. mutable struct DemandSideTechnology{T <: PSY.StaticInjection} <: Technology name::String available::Bool - power_systems_type::Type{T} capital_cost::IS.FunctionData + ext::Dict{String, Any} supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer time_series_container::InfrastructureSystems.TimeSeriesContainer internal::InfrastructureSystemsInternal @@ -20,8 +20,8 @@ This struct represents a demand side technology in a power system. # Arguments - `name::String`: The name of the demand side technology. - `available::Bool`: Indicates whether the technology is available or not in the simulation. -- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. - `capital_cost::IS.FunctionData`: The capital cost of the technology. +- `ext::Dict{String, Any}` - `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. - `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage - `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify @@ -31,10 +31,9 @@ mutable struct DemandSideTechnology{T <: PSY.StaticInjection} <: Technology name::String "Indicates whether the technology is available or not in the simulation." available::Bool - "The type of PowerSystems Component this build option translates to." - power_systems_type::Type{T} "The capital cost of the technology." capital_cost::IS.FunctionData + ext::Dict{String, Any} "Container for supplemental attributes." supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer "internal time_series storage" @@ -43,22 +42,22 @@ mutable struct DemandSideTechnology{T <: PSY.StaticInjection} <: Technology internal::InfrastructureSystemsInternal end -function DemandSideTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.StaticInjection - DemandSideTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +function DemandSideTechnology{T}(name, available, capital_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.StaticInjection + DemandSideTechnology{T}(name, available, capital_cost, ext, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) end -function DemandSideTechnology{T}(; name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.StaticInjection - DemandSideTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, internal, ) +function DemandSideTechnology{T}(; name, available, capital_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.StaticInjection + DemandSideTechnology{T}(name, available, capital_cost, ext, supplemental_attributes_container, time_series_container, internal, ) end """Get [`DemandSideTechnology`](@ref) `name`.""" get_name(value::DemandSideTechnology) = value.name """Get [`DemandSideTechnology`](@ref) `available`.""" get_available(value::DemandSideTechnology) = value.available -"""Get [`DemandSideTechnology`](@ref) `power_systems_type`.""" -get_power_systems_type(value::DemandSideTechnology) = value.power_systems_type """Get [`DemandSideTechnology`](@ref) `capital_cost`.""" get_capital_cost(value::DemandSideTechnology) = value.capital_cost +"""Get [`DemandSideTechnology`](@ref) `ext`.""" +get_ext(value::DemandSideTechnology) = value.ext """Get [`DemandSideTechnology`](@ref) `supplemental_attributes_container`.""" get_supplemental_attributes_container(value::DemandSideTechnology) = value.supplemental_attributes_container """Get [`DemandSideTechnology`](@ref) `time_series_container`.""" @@ -70,10 +69,10 @@ get_internal(value::DemandSideTechnology) = value.internal set_name!(value::DemandSideTechnology, val) = value.name = val """Set [`DemandSideTechnology`](@ref) `available`.""" set_available!(value::DemandSideTechnology, val) = value.available = val -"""Set [`DemandSideTechnology`](@ref) `power_systems_type`.""" -set_power_systems_type!(value::DemandSideTechnology, val) = value.power_systems_type = val """Set [`DemandSideTechnology`](@ref) `capital_cost`.""" set_capital_cost!(value::DemandSideTechnology, val) = value.capital_cost = val +"""Set [`DemandSideTechnology`](@ref) `ext`.""" +set_ext!(value::DemandSideTechnology, val) = value.ext = val """Set [`DemandSideTechnology`](@ref) `supplemental_attributes_container`.""" set_supplemental_attributes_container!(value::DemandSideTechnology, val) = value.supplemental_attributes_container = val """Set [`DemandSideTechnology`](@ref) `time_series_container`.""" diff --git a/src/models/StorageTechnology.jl b/src/models/StorageTechnology.jl index 14cf953..d046d7e 100644 --- a/src/models/StorageTechnology.jl +++ b/src/models/StorageTechnology.jl @@ -8,11 +8,11 @@ This file is auto-generated. Do not edit. mutable struct StorageTechnology{T <: PSY.Storage} <: Technology name::String available::Bool - power_systems_type::Type{T} capital_cost::IS.FunctionData battery_chemistry::String prime_mover::PSY.PrimeMovers operational_cost::PSY.OperationalCost + ext::Dict{String, Any} supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer time_series_container::InfrastructureSystems.TimeSeriesContainer internal::InfrastructureSystemsInternal @@ -23,11 +23,11 @@ This struct represents a storage technology in a power system. # Arguments - `name::String`: The name of the storage technology. - `available::Bool`: Indicates whether the technology is available or not in the simulation. -- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. - `capital_cost::IS.FunctionData`: The capital cost of the technology. - `battery_chemistry::String`: The type of battery chemistry. Implement Chemistry Type Enums in PowerSystems. - `prime_mover::PSY.PrimeMovers`: The prime mover of the storage technology. - `operational_cost::PSY.OperationalCost`: The operational cost of the storage technology. +- `ext::Dict{String, Any}` - `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. - `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage - `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify @@ -37,8 +37,6 @@ mutable struct StorageTechnology{T <: PSY.Storage} <: Technology name::String "Indicates whether the technology is available or not in the simulation." available::Bool - "The type of PowerSystems Component this build option translates to." - power_systems_type::Type{T} "The capital cost of the technology." capital_cost::IS.FunctionData "The type of battery chemistry. Implement Chemistry Type Enums in PowerSystems." @@ -47,6 +45,7 @@ mutable struct StorageTechnology{T <: PSY.Storage} <: Technology prime_mover::PSY.PrimeMovers "The operational cost of the storage technology." operational_cost::PSY.OperationalCost + ext::Dict{String, Any} "Container for supplemental attributes." supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer "internal time_series storage" @@ -55,20 +54,18 @@ mutable struct StorageTechnology{T <: PSY.Storage} <: Technology internal::InfrastructureSystemsInternal end -function StorageTechnology{T}(name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Storage - StorageTechnology{T}(name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +function StorageTechnology{T}(name, available, capital_cost, battery_chemistry, prime_mover, operational_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Storage + StorageTechnology{T}(name, available, capital_cost, battery_chemistry, prime_mover, operational_cost, ext, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) end -function StorageTechnology{T}(; name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Storage - StorageTechnology{T}(name, available, power_systems_type, capital_cost, battery_chemistry, prime_mover, operational_cost, supplemental_attributes_container, time_series_container, internal, ) +function StorageTechnology{T}(; name, available, capital_cost, battery_chemistry, prime_mover, operational_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Storage + StorageTechnology{T}(name, available, capital_cost, battery_chemistry, prime_mover, operational_cost, ext, supplemental_attributes_container, time_series_container, internal, ) end """Get [`StorageTechnology`](@ref) `name`.""" get_name(value::StorageTechnology) = value.name """Get [`StorageTechnology`](@ref) `available`.""" get_available(value::StorageTechnology) = value.available -"""Get [`StorageTechnology`](@ref) `power_systems_type`.""" -get_power_systems_type(value::StorageTechnology) = value.power_systems_type """Get [`StorageTechnology`](@ref) `capital_cost`.""" get_capital_cost(value::StorageTechnology) = value.capital_cost """Get [`StorageTechnology`](@ref) `battery_chemistry`.""" @@ -77,6 +74,8 @@ get_battery_chemistry(value::StorageTechnology) = value.battery_chemistry get_prime_mover(value::StorageTechnology) = value.prime_mover """Get [`StorageTechnology`](@ref) `operational_cost`.""" get_operational_cost(value::StorageTechnology) = value.operational_cost +"""Get [`StorageTechnology`](@ref) `ext`.""" +get_ext(value::StorageTechnology) = value.ext """Get [`StorageTechnology`](@ref) `supplemental_attributes_container`.""" get_supplemental_attributes_container(value::StorageTechnology) = value.supplemental_attributes_container """Get [`StorageTechnology`](@ref) `time_series_container`.""" @@ -88,8 +87,6 @@ get_internal(value::StorageTechnology) = value.internal set_name!(value::StorageTechnology, val) = value.name = val """Set [`StorageTechnology`](@ref) `available`.""" set_available!(value::StorageTechnology, val) = value.available = val -"""Set [`StorageTechnology`](@ref) `power_systems_type`.""" -set_power_systems_type!(value::StorageTechnology, val) = value.power_systems_type = val """Set [`StorageTechnology`](@ref) `capital_cost`.""" set_capital_cost!(value::StorageTechnology, val) = value.capital_cost = val """Set [`StorageTechnology`](@ref) `battery_chemistry`.""" @@ -98,6 +95,8 @@ set_battery_chemistry!(value::StorageTechnology, val) = value.battery_chemistry set_prime_mover!(value::StorageTechnology, val) = value.prime_mover = val """Set [`StorageTechnology`](@ref) `operational_cost`.""" set_operational_cost!(value::StorageTechnology, val) = value.operational_cost = val +"""Set [`StorageTechnology`](@ref) `ext`.""" +set_ext!(value::StorageTechnology, val) = value.ext = val """Set [`StorageTechnology`](@ref) `supplemental_attributes_container`.""" set_supplemental_attributes_container!(value::StorageTechnology, val) = value.supplemental_attributes_container = val """Set [`StorageTechnology`](@ref) `time_series_container`.""" diff --git a/src/models/SupplyTechnology.jl b/src/models/SupplyTechnology.jl index ba3f374..f2c8d18 100644 --- a/src/models/SupplyTechnology.jl +++ b/src/models/SupplyTechnology.jl @@ -8,12 +8,12 @@ This file is auto-generated. Do not edit. mutable struct SupplyTechnology{T <: PSY.Generator} <: Technology name::String available::Bool - power_systems_type::Type{T} fuel::PSY.ThermalFuels prime_mover::PSY.PrimeMovers capacity_factor::Float64 capital_cost::Union{Nothing, IS.FunctionData} operational_cost::Union{Nothing, PSY.OperationalCost} + ext::Dict{String, Any} supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer time_series_container::InfrastructureSystems.TimeSeriesContainer internal::InfrastructureSystemsInternal @@ -24,12 +24,12 @@ This struct represents a supply technology in a power system. # Arguments - `name::String`: The name of the supply technology. - `available::Bool`: Indicates whether the technology is available or not in the simulation. -- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. - `fuel::PSY.ThermalFuels`: The type of fuel used by the supply technology. - `prime_mover::PSY.PrimeMovers`: The prime mover of the supply technology. - `capacity_factor::Float64`: The capacity factor of the supply technology. - `capital_cost::Union{Nothing, IS.FunctionData}`: The capital cost of the technology. - `operational_cost::Union{Nothing, PSY.OperationalCost}`: The operational cost of the supply technology. +- `ext::Dict{String, Any}` - `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. - `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage - `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify @@ -39,8 +39,6 @@ mutable struct SupplyTechnology{T <: PSY.Generator} <: Technology name::String "Indicates whether the technology is available or not in the simulation." available::Bool - "The type of PowerSystems Component this build option translates to." - power_systems_type::Type{T} "The type of fuel used by the supply technology." fuel::PSY.ThermalFuels "The prime mover of the supply technology." @@ -51,6 +49,7 @@ mutable struct SupplyTechnology{T <: PSY.Generator} <: Technology capital_cost::Union{Nothing, IS.FunctionData} "The operational cost of the supply technology." operational_cost::Union{Nothing, PSY.OperationalCost} + ext::Dict{String, Any} "Container for supplemental attributes." supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer "internal time_series storage" @@ -59,20 +58,18 @@ mutable struct SupplyTechnology{T <: PSY.Generator} <: Technology internal::InfrastructureSystemsInternal end -function SupplyTechnology{T}(name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Generator - SupplyTechnology{T}(name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +function SupplyTechnology{T}(name, available, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Generator + SupplyTechnology{T}(name, available, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, ext, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) end -function SupplyTechnology{T}(; name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Generator - SupplyTechnology{T}(name, available, power_systems_type, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, supplemental_attributes_container, time_series_container, internal, ) +function SupplyTechnology{T}(; name, available, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Generator + SupplyTechnology{T}(name, available, fuel, prime_mover, capacity_factor, capital_cost, operational_cost, ext, supplemental_attributes_container, time_series_container, internal, ) end """Get [`SupplyTechnology`](@ref) `name`.""" get_name(value::SupplyTechnology) = value.name """Get [`SupplyTechnology`](@ref) `available`.""" get_available(value::SupplyTechnology) = value.available -"""Get [`SupplyTechnology`](@ref) `power_systems_type`.""" -get_power_systems_type(value::SupplyTechnology) = value.power_systems_type """Get [`SupplyTechnology`](@ref) `fuel`.""" get_fuel(value::SupplyTechnology) = value.fuel """Get [`SupplyTechnology`](@ref) `prime_mover`.""" @@ -83,6 +80,8 @@ get_capacity_factor(value::SupplyTechnology) = value.capacity_factor get_capital_cost(value::SupplyTechnology) = value.capital_cost """Get [`SupplyTechnology`](@ref) `operational_cost`.""" get_operational_cost(value::SupplyTechnology) = value.operational_cost +"""Get [`SupplyTechnology`](@ref) `ext`.""" +get_ext(value::SupplyTechnology) = value.ext """Get [`SupplyTechnology`](@ref) `supplemental_attributes_container`.""" get_supplemental_attributes_container(value::SupplyTechnology) = value.supplemental_attributes_container """Get [`SupplyTechnology`](@ref) `time_series_container`.""" @@ -94,8 +93,6 @@ get_internal(value::SupplyTechnology) = value.internal set_name!(value::SupplyTechnology, val) = value.name = val """Set [`SupplyTechnology`](@ref) `available`.""" set_available!(value::SupplyTechnology, val) = value.available = val -"""Set [`SupplyTechnology`](@ref) `power_systems_type`.""" -set_power_systems_type!(value::SupplyTechnology, val) = value.power_systems_type = val """Set [`SupplyTechnology`](@ref) `fuel`.""" set_fuel!(value::SupplyTechnology, val) = value.fuel = val """Set [`SupplyTechnology`](@ref) `prime_mover`.""" @@ -106,6 +103,8 @@ set_capacity_factor!(value::SupplyTechnology, val) = value.capacity_factor = val set_capital_cost!(value::SupplyTechnology, val) = value.capital_cost = val """Set [`SupplyTechnology`](@ref) `operational_cost`.""" set_operational_cost!(value::SupplyTechnology, val) = value.operational_cost = val +"""Set [`SupplyTechnology`](@ref) `ext`.""" +set_ext!(value::SupplyTechnology, val) = value.ext = val """Set [`SupplyTechnology`](@ref) `supplemental_attributes_container`.""" set_supplemental_attributes_container!(value::SupplyTechnology, val) = value.supplemental_attributes_container = val """Set [`SupplyTechnology`](@ref) `time_series_container`.""" diff --git a/src/models/TransportTechnology.jl b/src/models/TransportTechnology.jl index 007c064..54f86aa 100644 --- a/src/models/TransportTechnology.jl +++ b/src/models/TransportTechnology.jl @@ -8,8 +8,8 @@ This file is auto-generated. Do not edit. mutable struct TransportTechnology{T <: PSY.Device} <: Technology name::String available::Bool - power_systems_type::Type{T} capital_cost::IS.FunctionData + ext::Dict{String, Any} supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer time_series_container::InfrastructureSystems.TimeSeriesContainer internal::InfrastructureSystemsInternal @@ -20,8 +20,8 @@ This struct represents a transport technology in a power system. # Arguments - `name::String`: The name of the transport technology. - `available::Bool`: Indicates whether the technology is available or not in the simulation. -- `power_systems_type::Type{T}`: The type of PowerSystems Component this build option translates to. - `capital_cost::IS.FunctionData`: The capital cost of the technology. +- `ext::Dict{String, Any}` - `supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer`: Container for supplemental attributes. - `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage - `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify @@ -31,10 +31,9 @@ mutable struct TransportTechnology{T <: PSY.Device} <: Technology name::String "Indicates whether the technology is available or not in the simulation." available::Bool - "The type of PowerSystems Component this build option translates to." - power_systems_type::Type{T} "The capital cost of the technology." capital_cost::IS.FunctionData + ext::Dict{String, Any} "Container for supplemental attributes." supplemental_attributes_container::InfrastructureSystems.SupplementalAttributesContainer "internal time_series storage" @@ -43,22 +42,22 @@ mutable struct TransportTechnology{T <: PSY.Device} <: Technology internal::InfrastructureSystemsInternal end -function TransportTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Device - TransportTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) +function TransportTechnology{T}(name, available, capital_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), ) where T <: PSY.Device + TransportTechnology{T}(name, available, capital_cost, ext, supplemental_attributes_container, time_series_container, InfrastructureSystemsInternal(), ) end -function TransportTechnology{T}(; name, available, power_systems_type, capital_cost, supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Device - TransportTechnology{T}(name, available, power_systems_type, capital_cost, supplemental_attributes_container, time_series_container, internal, ) +function TransportTechnology{T}(; name, available, capital_cost, ext=Dict{String, Any}(), supplemental_attributes_container=InfrastructureSystems.SupplementalAttributesContainer(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), ) where T <: PSY.Device + TransportTechnology{T}(name, available, capital_cost, ext, supplemental_attributes_container, time_series_container, internal, ) end """Get [`TransportTechnology`](@ref) `name`.""" get_name(value::TransportTechnology) = value.name """Get [`TransportTechnology`](@ref) `available`.""" get_available(value::TransportTechnology) = value.available -"""Get [`TransportTechnology`](@ref) `power_systems_type`.""" -get_power_systems_type(value::TransportTechnology) = value.power_systems_type """Get [`TransportTechnology`](@ref) `capital_cost`.""" get_capital_cost(value::TransportTechnology) = value.capital_cost +"""Get [`TransportTechnology`](@ref) `ext`.""" +get_ext(value::TransportTechnology) = value.ext """Get [`TransportTechnology`](@ref) `supplemental_attributes_container`.""" get_supplemental_attributes_container(value::TransportTechnology) = value.supplemental_attributes_container """Get [`TransportTechnology`](@ref) `time_series_container`.""" @@ -70,10 +69,10 @@ get_internal(value::TransportTechnology) = value.internal set_name!(value::TransportTechnology, val) = value.name = val """Set [`TransportTechnology`](@ref) `available`.""" set_available!(value::TransportTechnology, val) = value.available = val -"""Set [`TransportTechnology`](@ref) `power_systems_type`.""" -set_power_systems_type!(value::TransportTechnology, val) = value.power_systems_type = val """Set [`TransportTechnology`](@ref) `capital_cost`.""" set_capital_cost!(value::TransportTechnology, val) = value.capital_cost = val +"""Set [`TransportTechnology`](@ref) `ext`.""" +set_ext!(value::TransportTechnology, val) = value.ext = val """Set [`TransportTechnology`](@ref) `supplemental_attributes_container`.""" set_supplemental_attributes_container!(value::TransportTechnology, val) = value.supplemental_attributes_container = val """Set [`TransportTechnology`](@ref) `time_series_container`.""" diff --git a/src/models/includes.jl b/src/models/includes.jl index d66f3ca..615220b 100644 --- a/src/models/includes.jl +++ b/src/models/includes.jl @@ -8,10 +8,10 @@ export get_available export get_battery_chemistry export get_capacity_factor export get_capital_cost +export get_ext export get_fuel export get_name export get_operational_cost -export get_power_systems_type export get_prime_mover export get_region export get_supplemental_attributes_container @@ -20,10 +20,10 @@ export set_available! export set_battery_chemistry! export set_capacity_factor! export set_capital_cost! +export set_ext! export set_fuel! export set_name! export set_operational_cost! -export set_power_systems_type! export set_prime_mover! export set_region! export set_supplemental_attributes_container! diff --git a/src/models/serialization.jl b/src/models/serialization.jl index 9db8053..fd011e7 100644 --- a/src/models/serialization.jl +++ b/src/models/serialization.jl @@ -30,7 +30,7 @@ const _ENCODE_AS_UUID_B = ( should_encode_as_uuid(val) = any(x -> val isa x, _ENCODE_AS_UUID_B) # TODO: how does this work? -should_encode_as_uuid(::Type{T}) where {T} = !any(x -> T <: x, _ENCODE_AS_UUID_A) +should_encode_as_uuid(::Type{T}) where {T} = any(x -> T <: x, _ENCODE_AS_UUID_A) function IS.serialize(technology::T) where {T <: Technology} @@ -72,3 +72,73 @@ function serialize_uuid_handling(val) return serialize(value) end + + +function IS.deserialize(::Type{T}, data::Dict, tech_cache::Dict) where {T <: Technology} + @debug "deserialize Technology" _group = IS.LOG_GROUP_SERIALIZATION T data + vals = Dict{Symbol, Any}() + @show data, tech_cache + for (name, type) in zip(fieldnames(T), fieldtypes(T)) + field_name = string(name) + if haskey(data, field_name) + val = data[field_name] + else + continue + end + if val isa Dict && haskey(val, IS.METADATA_KEY) + vals[name] = deserialize_uuid_handling( + IS.get_type_from_serialization_metadata(IS.get_serialization_metadata(val)), + val, + tech_cache, + ) + else + @show val, field_name + vals[name] = deserialize_uuid_handling(type, val, tech_cache) + end + end + type = IS.get_type_from_serialization_metadata(data[IS.METADATA_KEY]) + return type(; vals...) +end + +function IS.deserialize(::Type{Technology}, data::Dict) + error("This form of IS.deserialize is not supported for Devices") + return +end + +""" +Deserialize the value, converting UUIDs to technologies where necessary. +""" +function deserialize_uuid_handling(field_type, val, tech_cache) + @debug "deserialize_uuid_handling" _group = IS.LOG_GROUP_SERIALIZATION field_type val + if val === nothing + value = val + elseif should_encode_as_uuid(field_type) + if field_type <: Vector + _vals = field_type() + for _val in val + uuid = deserialize(Base.UUID, _val) + tech = tech_cache[uuid] + push!(_vals, tech) + end + value = _vals + else + uuid = deserialize(Base.UUID, val) + tech = tech_cache[uuid] + value = tech + end + elseif field_type <: Technology + value = IS.deserialize(field_type, val, tech_cache) + elseif field_type <: Union{Nothing, Technology} + value = IS.deserialize(field_type.b, val, tech_cache) + elseif field_type <: InfrastructureSystemsType + value = deserialize(field_type, val) + elseif field_type isa Union && field_type.a <: Nothing && !(field_type.b <: Union) + # Nothing has already been handled. Apply the second type as long as there isn't a + # third. Julia appears to always put the Nothing in field a. + value = deserialize(field_type.b, val) + else + value = deserialize(field_type, val) + end + + return value +end diff --git a/src/portfolio.jl b/src/portfolio.jl index 4dde2e5..78c1799 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -4,6 +4,9 @@ const PORTFOLIO_KWARGS = const DEFAULT_DISCOUNT_RATE = 0.07 const DEFAULT_AGGREGATION = PSY.ACBus +const PORTFOLIO_STRUCT_DESCRIPTOR_FILE = + joinpath(dirname(pathof(PowerSystemsInvestmentsPortfolios)), "descriptors", "portfolio_structs.json") + mutable struct PortfolioMetadata <: IS.InfrastructureSystemsType name::Union{Nothing, String} description::Union{Nothing, String} @@ -19,7 +22,7 @@ struct Portfolio <: IS.InfrastructureSystemsType #units_settings::IS.SystemUnitsSettings time_series_directory::Union{Nothing, String} time_series_container::IS.TimeSeriesContainer -metadata::PortfolioMetadata + metadata::PortfolioMetadata internal::IS.InfrastructureSystemsInternal function Portfolio( @@ -571,8 +574,6 @@ end function IS.deserialize( ::Type{Portfolio}, filename::AbstractString, - time_series_read_only=false, - time_series_directory=nothing, kwargs..., ) raw = open(filename) do io @@ -590,11 +591,162 @@ function IS.deserialize( raw["data"][file_key] = joinpath(directory, raw["data"][file_key]) end end - + # return raw return from_dict(Portfolio, raw; kwargs...) end -function deserialize_components!(portfolio::Portfolio, raw) end +""" +Clear any value stored in ext. +""" +clear_ext!(sys::Portfolio) = IS.clear_ext!(sys.internal) + + +function from_dict( + ::Type{Portfolio}, + raw::Dict{String, Any}; + time_series_read_only = false, + time_series_directory = nothing, + config_path = PORTFOLIO_STRUCT_DESCRIPTOR_FILE, + kwargs..., +) + # Read any field that is defined in Portfolio but optional for the constructors and not + # already handled here. + + handled = ( + "aggregation", + "discount_rate", + "data", + "investment_schedule", + "time_series_directory", + "time_series_container", + "metadata", + "internal", + ) + parsed_kwargs = Dict{Symbol, Any}() + for field in setdiff(keys(raw), handled) + parsed_kwargs[Symbol(field)] = raw[field] + end + + # The user can override the serialized runchecks value by passing a kwarg here. + if haskey(kwargs, :runchecks) + parsed_kwargs[:runchecks] = kwargs[:runchecks] + end + + # units = IS.deserialize(SystemUnitsSettings, raw["units_settings"]) + data = IS.deserialize( + IS.SystemData, + raw["data"]; + time_series_read_only = time_series_read_only, + time_series_directory = time_series_directory, + validation_descriptor_file = config_path, + ) + metadata = get(raw, "metadata", Dict()) + name = get(metadata, "name", nothing) + description = get(metadata, "description", nothing) + internal = IS.deserialize(InfrastructureSystemsInternal, raw["internal"]) + aggregation = PSY.ACBus + discount_rate = raw["discount_rate"] + investment_schedule = raw["investment_schedule"] + portfolio = Portfolio( + aggregation, + discount_rate, + data, + investment_schedule, + internal, + # name = name, + # description = description, + # parsed_kwargs..., + ) + + if raw["data_format_version"] != DATA_FORMAT_VERSION + pre_deserialize_conversion!(raw, portfolio) + end + + ext = get_ext(portfolio) + ext["deserialization_in_progress"] = true + try + deserialize_components!(portfolio, raw["data"]) + finally + pop!(ext, "deserialization_in_progress") + isempty(ext) && clear_ext!(portfolio) + end + + # if !get_runchecks(portfolio) + # @warn "The System was deserialized with checks disabled, and so was not validated." + # end + + if raw["data_format_version"] != DATA_FORMAT_VERSION + post_deserialize_conversion!(portfolio, raw) + end + + return portfolio +end + +function deserialize_components!(sys::Portfolio, raw) + # Convert the array of components into type-specific arrays to allow addition by type. + data = Dict{Any, Vector{Dict}}() + + for component in raw["components"] + type = IS.get_type_from_serialization_data(component) + components = get(data, type, nothing) + if components === nothing + components = Vector{Dict}() + data[type] = components + end + push!(components, component) + end + + # Maintain a lookup of UUID to component because some component types encode + # composed types as UUIDs instead of actual types. + component_cache = Dict{Base.UUID, Technology}() + + # Add each type to this as we parse. + parsed_types = Set() + + function is_matching_type(type, types) + return any(x -> type <: x, types) + end + + function deserialize_and_add!(; + skip_types = nothing, + include_types = nothing, + post_add_func = nothing, + ) + for (type, components) in data + type in parsed_types && continue + if !isnothing(skip_types) && is_matching_type(type, skip_types) + continue + end + if !isnothing(include_types) && !is_matching_type(type, include_types) + continue + end + for component in components + handle_deserialization_special_cases!(component, type) + comp = deserialize(type, component, component_cache) + add_technology!(sys, comp) + component_cache[IS.get_uuid(comp)] = comp + if !isnothing(post_add_func) + post_add_func(comp) + end + end + push!(parsed_types, type) + end + end + + + deserialize_and_add!() + +end + +""" +Allow types to implement handling of special cases during deserialization. + +# Arguments +- `component::Dict`: The component serialized as a dictionary. +- `::Type`: The type of the technology. +""" +handle_deserialization_special_cases!(component::Dict, ::Type{<:Technology}) = nothing + function _is_deserialization_in_progress(portfolio::Portfolio) ext = get_ext(portfolio) @@ -701,7 +853,7 @@ function IS.from_json( end function _post_deserialize_handling(portfolio::Portfolio; runchecks = true, assign_new_uuids = false) - runchecks && check(portfolio) + # runchecks && check(portfolio) if assign_new_uuids IS.assign_new_uuid!(portfolio) for component in get_components(Technology, portfolio) @@ -715,3 +867,35 @@ function _post_deserialize_handling(portfolio::Portfolio; runchecks = true, assi # shared with components. end end + +function Portfolio(file_path::AbstractString; assign_new_uuids = false, kwargs...) + ext = splitext(file_path)[2] + if lowercase(ext) in [".m", ".raw"] + pm_kwargs = Dict(k => v for (k, v) in kwargs if !in(k, PORTFOLIO_KWARGS)) + sys_kwargs = Dict(k => v for (k, v) in kwargs if in(k, PORTFOLIO_KWARGS)) + return System(PowerModelsData(file_path; pm_kwargs...); sys_kwargs...) + elseif lowercase(ext) == ".json" + unsupported = setdiff(keys(kwargs), PORTFOLIO_KWARGS) + !isempty(unsupported) && error("Unsupported kwargs = $unsupported") + runchecks = get(kwargs, :runchecks, true) + time_series_read_only = get(kwargs, :time_series_read_only, false) + time_series_directory = get(kwargs, :time_series_directory, nothing) + config_path = get(kwargs, :config_path, PORTFOLIO_STRUCT_DESCRIPTOR_FILE) + portfolio = deserialize( + Portfolio, + file_path; + # time_series_read_only = time_series_read_only, + # runchecks = runchecks, + # time_series_directory = time_series_directory, + # config_path = config_path, + ) + _post_deserialize_handling( + portfolio; + runchecks = runchecks, + assign_new_uuids = assign_new_uuids, + ) + return portfolio + else + throw(DataFormatError("$file_path is not a supported file type")) + end +end \ No newline at end of file From 3bfde43fad540b9b11ed5813780a7201d93da5c5 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Fri, 12 Apr 2024 18:15:33 -0500 Subject: [PATCH 11/12] merging test script --- scripts/portfolio_test.jl | 2 +- test/Project.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/portfolio_test.jl b/scripts/portfolio_test.jl index bc707bc..51e9c3f 100644 --- a/scripts/portfolio_test.jl +++ b/scripts/portfolio_test.jl @@ -21,7 +21,6 @@ p = Portfolio(0.07) t = SupplyTechnology{ThermalStandard}( "thermal_tech", true, - ThermalStandard, PSY.ThermalFuels.COAL, PSY.PrimeMovers.ST, 0.98, # cap factor @@ -39,3 +38,4 @@ get_technologies(SupplyTechnology{ThermalStandard}, p) PSIP.remove_technology!(SupplyTechnology{ThermalStandard}, p, "thermal_tech") get_available(t) +IS.deserialize(p) diff --git a/test/Project.toml b/test/Project.toml index 4d450b6..5de27b8 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -3,6 +3,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1" PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd" PowerSystemsInvestmentsPortfolios = "bed98974-b02a-5e2f-9fe0-a103f8c450dd" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] julia = "^1.6" From ae2d6526118286bbce2b3abd427b7416ec69b857 Mon Sep 17 00:00:00 2001 From: sourabhdalvi Date: Fri, 12 Apr 2024 18:17:46 -0500 Subject: [PATCH 12/12] adding formatter changes --- src/models/serialization.jl | 6 +-- src/portfolio.jl | 93 ++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 51 deletions(-) diff --git a/src/models/serialization.jl b/src/models/serialization.jl index fd011e7..4321045 100644 --- a/src/models/serialization.jl +++ b/src/models/serialization.jl @@ -9,7 +9,7 @@ const _ENCODE_AS_UUID_A = ( PSY.ThermalGen, PSY.Storage, PSY.StaticLoad, - PSY.RenewableGen + PSY.RenewableGen, ) const _ENCODE_AS_UUID_B = ( @@ -23,7 +23,7 @@ const _ENCODE_AS_UUID_B = ( PSY.ThermalGen, PSY.Storage, PSY.StaticLoad, - PSY.RenewableGen + PSY.RenewableGen, ) @assert length(_ENCODE_AS_UUID_A) == length(_ENCODE_AS_UUID_B) @@ -32,7 +32,6 @@ should_encode_as_uuid(val) = any(x -> val isa x, _ENCODE_AS_UUID_B) # TODO: how does this work? should_encode_as_uuid(::Type{T}) where {T} = any(x -> T <: x, _ENCODE_AS_UUID_A) - function IS.serialize(technology::T) where {T <: Technology} @debug "serialize" _group = IS.LOG_GROUP_SERIALIZATION technology T data = Dict{String, Any}() @@ -73,7 +72,6 @@ function serialize_uuid_handling(val) return serialize(value) end - function IS.deserialize(::Type{T}, data::Dict, tech_cache::Dict) where {T <: Technology} @debug "deserialize Technology" _group = IS.LOG_GROUP_SERIALIZATION T data vals = Dict{Symbol, Any}() diff --git a/src/portfolio.jl b/src/portfolio.jl index e3ecb24..5d7dfb3 100644 --- a/src/portfolio.jl +++ b/src/portfolio.jl @@ -4,8 +4,11 @@ const PORTFOLIO_KWARGS = const DEFAULT_DISCOUNT_RATE = 0.07 const DEFAULT_AGGREGATION = PSY.ACBus -const PORTFOLIO_STRUCT_DESCRIPTOR_FILE = - joinpath(dirname(pathof(PowerSystemsInvestmentsPortfolios)), "descriptors", "portfolio_structs.json") +const PORTFOLIO_STRUCT_DESCRIPTOR_FILE = joinpath( + dirname(pathof(PowerSystemsInvestmentsPortfolios)), + "descriptors", + "portfolio_structs.json", +) mutable struct PortfolioMetadata <: IS.InfrastructureSystemsType name::Union{Nothing, String} @@ -545,7 +548,6 @@ function has_technology( return IS.has_component(T, portfolio.data.components, name) end - function IS.serialize(portfolio::T) where {T <: Portfolio} data = Dict{String, Any}() data["data_format_version"] = DATA_FORMAT_VERSION @@ -561,11 +563,7 @@ function IS.serialize(portfolio::T) where {T <: Portfolio} return data end -function IS.deserialize( - ::Type{Portfolio}, - filename::AbstractString, - kwargs..., -) +function IS.deserialize(::Type{Portfolio}, filename::AbstractString, kwargs...) raw = open(filename) do io JSON3.read(io, Dict) end @@ -590,13 +588,12 @@ Clear any value stored in ext. """ clear_ext!(sys::Portfolio) = IS.clear_ext!(sys.internal) - function from_dict( ::Type{Portfolio}, raw::Dict{String, Any}; - time_series_read_only = false, - time_series_directory = nothing, - config_path = PORTFOLIO_STRUCT_DESCRIPTOR_FILE, + time_series_read_only=false, + time_series_directory=nothing, + config_path=PORTFOLIO_STRUCT_DESCRIPTOR_FILE, kwargs..., ) # Read any field that is defined in Portfolio but optional for the constructors and not @@ -626,9 +623,9 @@ function from_dict( data = IS.deserialize( IS.SystemData, raw["data"]; - time_series_read_only = time_series_read_only, - time_series_directory = time_series_directory, - validation_descriptor_file = config_path, + time_series_read_only=time_series_read_only, + time_series_directory=time_series_directory, + validation_descriptor_file=config_path, ) metadata = get(raw, "metadata", Dict()) name = get(metadata, "name", nothing) @@ -698,9 +695,9 @@ function deserialize_components!(sys::Portfolio, raw) end function deserialize_and_add!(; - skip_types = nothing, - include_types = nothing, - post_add_func = nothing, + skip_types=nothing, + include_types=nothing, + post_add_func=nothing, ) for (type, components) in data type in parsed_types && continue @@ -723,58 +720,57 @@ function deserialize_components!(sys::Portfolio, raw) end end - deserialize_and_add!() - end """ Allow types to implement handling of special cases during deserialization. # Arguments -- `component::Dict`: The component serialized as a dictionary. -- `::Type`: The type of the technology. + + - `component::Dict`: The component serialized as a dictionary. + - `::Type`: The type of the technology. """ handle_deserialization_special_cases!(component::Dict, ::Type{<:Technology}) = nothing - function _is_deserialization_in_progress(portfolio::Portfolio) ext = get_ext(portfolio) return get(ext, "deserialization_in_progress", false) end - """ Serializes a portfolio to a JSON file and saves time series to an HDF5 file. # Arguments -- `portfolio::Portfolio`: portfolio -- `filename::AbstractString`: filename to write + + - `portfolio::Portfolio`: portfolio + - `filename::AbstractString`: filename to write # Keyword arguments -- `user_data::Union{Nothing, Dict} = nothing`: optional metadata to record -- `pretty::Bool = false`: whether to pretty-print the JSON -- `force::Bool = false`: whether to overwrite existing files -- `check::Bool = false`: whether to run portfolio validation checks + + - `user_data::Union{Nothing, Dict} = nothing`: optional metadata to record + - `pretty::Bool = false`: whether to pretty-print the JSON + - `force::Bool = false`: whether to overwrite existing files + - `check::Bool = false`: whether to run portfolio validation checks Refer to [`check_component`](@ref) for exceptions thrown if `check = true`. """ function IS.to_json( portfolio::Portfolio, filename::AbstractString; - user_data = nothing, - pretty = false, - force = false, - runchecks = false, -) + user_data=nothing, + pretty=false, + force=false, + runchecks=false, +) # TODO: add checks for portfolio and technology # if runchecks # check(portfolio) # check_technologies(portfolio) # end - IS.prepare_for_serialization_to_file!(portfolio.data, filename; force = force) - data = to_json(portfolio; pretty = pretty) + IS.prepare_for_serialization_to_file!(portfolio.data, filename; force=force) + data = to_json(portfolio; pretty=pretty) open(filename, "w") do io write(io, data) end @@ -808,7 +804,6 @@ function _serialize_portfolio_metadata_to_file(portfolio::Portfolio, filename, u @info "Serialized Portfolio metadata to $filename" end - """ If assign_new_uuids = true, generate new UUIDs for the portfolio and all components. @@ -819,8 +814,8 @@ process to construct the portfolio from a serialized JSON file instead, such as function IS.from_json( io::Union{IO, String}, ::Type{Portfolio}; - runchecks = true, - assign_new_uuids = false, + runchecks=true, + assign_new_uuids=false, kwargs..., ) data = JSON3.read(io, Dict) @@ -836,13 +831,17 @@ function IS.from_json( portfolio = from_dict(Portfolio, data; kwargs...) _post_deserialize_handling( portfolio; - runchecks = runchecks, - assign_new_uuids = assign_new_uuids, + runchecks=runchecks, + assign_new_uuids=assign_new_uuids, ) return portfolio end -function _post_deserialize_handling(portfolio::Portfolio; runchecks = true, assign_new_uuids = false) +function _post_deserialize_handling( + portfolio::Portfolio; + runchecks=true, + assign_new_uuids=false, +) # runchecks && check(portfolio) if assign_new_uuids IS.assign_new_uuid!(portfolio) @@ -858,7 +857,7 @@ function _post_deserialize_handling(portfolio::Portfolio; runchecks = true, assi end end -function Portfolio(file_path::AbstractString; assign_new_uuids = false, kwargs...) +function Portfolio(file_path::AbstractString; assign_new_uuids=false, kwargs...) ext = splitext(file_path)[2] if lowercase(ext) in [".m", ".raw"] pm_kwargs = Dict(k => v for (k, v) in kwargs if !in(k, PORTFOLIO_KWARGS)) @@ -881,11 +880,11 @@ function Portfolio(file_path::AbstractString; assign_new_uuids = false, kwargs.. ) _post_deserialize_handling( portfolio; - runchecks = runchecks, - assign_new_uuids = assign_new_uuids, + runchecks=runchecks, + assign_new_uuids=assign_new_uuids, ) return portfolio else throw(DataFormatError("$file_path is not a supported file type")) end -end \ No newline at end of file +end