From 4c3dfe3d81edd13a6eba830d406b5a7476c7eb7e Mon Sep 17 00:00:00 2001 From: Jerry Potts Date: Wed, 5 Jun 2024 20:03:07 -0600 Subject: [PATCH 01/10] updated generate_structs --- src/PowerSystemsInvestmentsPortfolios.jl | 1 + src/generate_structs.jl | 124 ++++++++++++++++--- src/models/generated/DemandRequirement.jl | 44 +++++++ src/models/generated/DemandsideTechnology.jl | 44 +++++++ src/models/generated/StorageTechnology.jl | 51 ++++++++ src/models/generated/SupplyTechnology.jl | 100 +++++++++++++++ src/models/generated/TransportTechnology.jl | 44 +++++++ src/models/generated/includes.jl | 30 +++++ 8 files changed, 423 insertions(+), 15 deletions(-) create mode 100644 src/models/generated/DemandRequirement.jl create mode 100644 src/models/generated/DemandsideTechnology.jl create mode 100644 src/models/generated/StorageTechnology.jl create mode 100644 src/models/generated/SupplyTechnology.jl create mode 100644 src/models/generated/TransportTechnology.jl create mode 100644 src/models/generated/includes.jl diff --git a/src/PowerSystemsInvestmentsPortfolios.jl b/src/PowerSystemsInvestmentsPortfolios.jl index fea644c..d664f0d 100644 --- a/src/PowerSystemsInvestmentsPortfolios.jl +++ b/src/PowerSystemsInvestmentsPortfolios.jl @@ -35,6 +35,7 @@ export add_technology! export add_technologies! export read_json_data export generate_invest_structs +export generate_structs const PSY = PowerSystems const IS = InfrastructureSystems diff --git a/src/generate_structs.jl b/src/generate_structs.jl index 225ba08..f5488f8 100644 --- a/src/generate_structs.jl +++ b/src/generate_structs.jl @@ -1,3 +1,81 @@ +import Mustache + +const STRUCT_TEMPLATE = """ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +\"\"\" + mutable struct {{struct_name}}{{#parametric}}{T <: {{parametric}}}{{/parametric}} <: {{supertype}} + {{#parameters}} + {{name}}::{{{data_type}}} + {{/parameters}} + end + +{{#docstring}}{{{docstring}}}{{/docstring}} + +# Arguments +{{#parameters}} +- `{{name}}::{{{data_type}}}`:{{#default}} (default: `{{{default}}}`){{/default}}{{#comment}} {{{comment}}}{{/comment}}{{#valid_range}}, validation range: `{{{valid_range}}}`{{/valid_range}} +{{/parameters}} +\"\"\" +mutable struct {{struct_name}}{{#parametric}}{T <: {{parametric}}}{{/parametric}} <: {{supertype}} + {{#parameters}} + {{#comment}}"{{{comment}}}"\n {{/comment}}{{name}}::{{{data_type}}} + {{/parameters}} + {{#inner_constructor_check}} + + function {{struct_name}}({{#parameters}}{{name}}, {{/parameters}}) + ({{#parameters}}{{name}}, {{/parameters}}) = {{inner_constructor_check}}( + {{#parameters}} + {{name}}, + {{/parameters}} + ) + new({{#parameters}}{{name}}, {{/parameters}}) + end + {{/inner_constructor_check}} +end + +{{#needs_positional_constructor}} +function {{constructor_func}}({{#parameters}}{{^internal_default}}{{name}}{{#default}}={{default}}{{/default}}, {{/internal_default}}{{/parameters}}){{{closing_constructor_text}}} + {{constructor_func}}({{#parameters}}{{^internal_default}}{{name}}, {{/internal_default}}{{/parameters}}{{#parameters}}{{#internal_default}}{{{internal_default}}}, {{/internal_default}}{{/parameters}}) +end +{{/needs_positional_constructor}} + +function {{constructor_func}}(; {{#parameters}}{{name}}{{#kwarg_value}}{{{kwarg_value}}}{{/kwarg_value}}, {{/parameters}}){{{closing_constructor_text}}} + {{constructor_func}}({{#parameters}}{{name}}, {{/parameters}}) +end + +{{#has_null_values}} +# Constructor for demo purposes; non-functional. +function {{constructor_func}}(::Nothing){{{closing_constructor_text}}} + {{constructor_func}}(; + {{#parameters}} + {{^internal_default}} + {{name}}={{#quotes}}"{{null_value}}"{{/quotes}}{{^quotes}}{{null_value}}{{/quotes}}, + {{/internal_default}} + {{/parameters}} + ) +end + +{{/has_null_values}} +{{#accessors}} +{{#create_docstring}}\"\"\"Get [`{{struct_name}}`](@ref) `{{name}}`.\"\"\"{{/create_docstring}} +{{accessor}}(value::{{struct_name}}) = {{#needs_conversion}}get_value(value, value.{{name}}){{/needs_conversion}}{{^needs_conversion}}value.{{name}}{{/needs_conversion}} +{{/accessors}} + +{{#setters}} +{{#create_docstring}}\"\"\"Set [`{{struct_name}}`](@ref) `{{name}}`.\"\"\"{{/create_docstring}} +{{setter}}(value::{{struct_name}}, val) = value.{{name}} = {{#needs_conversion}}set_value(value, val){{/needs_conversion}}{{^needs_conversion}}val{{/needs_conversion}} +{{/setters}} + +{{#custom_code}} +{{{custom_code}}} +{{/custom_code}} +""" + function read_json_data(filename::String) try return JSONSchema.Schema(JSON3.read(filename)) @@ -6,30 +84,39 @@ function read_json_data(filename::String) end end -function generate_invest_structs(directory, data::Dict{String, Any}; print_results=true) +function generate_invest_structs(directory, data::Schema; print_results=true) struct_names = Vector{String}() unique_accessor_functions = Set{String}() unique_setter_functions = Set{String}() - for (struc_name, input) in data + for (struct_name, input) in data.data["\$defs"] + properties = input["properties"] item = Dict{String, Any}() - item["has_internal"] = true + item["has_internal"] = false + item["has_null_values"] = true + accessors = Vector{Dict}() setters = Vector{Dict}() - item["has_null_values"] = true - has_non_default_values = false + + item["has_non_default_values"] = false item["constructor_func"] = struct_name + item["constructor_func"] *= "{T}" + item["struct_name"] = struct_name item["closing_constructor_text"] = "" item["parametric"] = properties["power_systems_type"] - item["constructor_func"] *= "{T}" item["closing_constructor_text"] = " where T <: $(item["parametric"])" parameters = Vector{Dict}() for (field, values) in properties param = Dict{String, Any}() - param["struct_name"] = item["struct_name"] + + #param["struct_name"] = item["struct_name"] + param["struct_name"] = item["constructor_func"] + param["name"] = field + param["data_type"] = values["type"] + if haskey(param, "valid_range") if typeof(param["valid_range"]) == Dict{String, Any} min = param["valid_range"]["min"] @@ -52,8 +139,10 @@ function generate_invest_structs(directory, data::Dict{String, Any}; print_resul accessor_module = "" create_docstring = true end + accessor_name = accessor_module * "get_" * param["name"] setter_name = accessor_module * "set_" * param["name"] * "!" + push!( accessors, Dict( @@ -63,6 +152,7 @@ function generate_invest_structs(directory, data::Dict{String, Any}; print_resul "needs_conversion" => get(param, "needs_conversion", false), ), ) + include_setter = !get(param, "exclude_setter", false) if include_setter push!( @@ -76,7 +166,8 @@ function generate_invest_structs(directory, data::Dict{String, Any}; print_resul ), ) end - if field["name"] != "internal" && accessor_module == "" + + if field != "internal" && accessor_module == "" push!(unique_accessor_functions, accessor_name) push!(unique_setter_functions, setter_name) end @@ -86,10 +177,10 @@ function generate_invest_structs(directory, data::Dict{String, Any}; print_resul param["kwarg_value"] = "=" * param["default"] elseif !isnothing(get(param, "internal_default", nothing)) param["kwarg_value"] = "=" * string(param["internal_default"]) - has_internal = true + item["has_internal"] = true continue else - has_non_default_values = true + item["has_non_default_values"] = true end # This controls whether a demo constructor will be generated. @@ -109,22 +200,24 @@ function generate_invest_structs(directory, data::Dict{String, Any}; print_resul item["parameters"] = parameters item["accessors"] = accessors item["setters"] = setters + # If all parameters have defaults then the positional constructor will # collide with the kwarg constructor. - item["needs_positional_constructor"] = has_internal && has_non_default_values + item["needs_positional_constructor"] = item["has_internal"] && item["has_non_default_values"] filename = joinpath(directory, item["struct_name"] * ".jl") + open(filename, "w") do io - write(io, strip(Mustache.render(IS.STRUCT_TEMPLATE, item))) + write(io, strip(Mustache.render(STRUCT_TEMPLATE, item))) write(io, "\n") push!(struct_names, item["struct_name"]) end - + if print_results println("Wrote $filename") end end - + accessors = sort!(collect(unique_accessor_functions)) setters = sort!(collect(unique_setter_functions)) filename = joinpath(directory, "includes.jl") @@ -144,6 +237,7 @@ function generate_invest_structs(directory, data::Dict{String, Any}; print_resul println("Wrote $filename") end end + end function generate_structs( @@ -157,6 +251,6 @@ function generate_structs( end data = read_json_data(input_file) - generate_structs(output_directory, data; print_results=print_results) + generate_invest_structs(output_directory, data; print_results=print_results) return end diff --git a/src/models/generated/DemandRequirement.jl b/src/models/generated/DemandRequirement.jl new file mode 100644 index 0000000..8d577e7 --- /dev/null +++ b/src/models/generated/DemandRequirement.jl @@ -0,0 +1,44 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct DemandRequirement{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + power_systems_type::string + available::boolean + end + + + +# Arguments +- `name::string`: +- `power_systems_type::string`: +- `available::boolean`: +""" +mutable struct DemandRequirement{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + power_systems_type::string + available::boolean +end + + +function DemandRequirement{T}(; name, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") + DemandRequirement{T}(name, power_systems_type, available, ) +end + +"""Get [`DemandRequirement`](@ref) `name`.""" +get_name(value::DemandRequirement) = value.name +"""Get [`DemandRequirement`](@ref) `power_systems_type`.""" +get_power_systems_type(value::DemandRequirement) = value.power_systems_type +"""Get [`DemandRequirement`](@ref) `available`.""" +get_available(value::DemandRequirement) = value.available + +"""Set [`DemandRequirement`](@ref) `name`.""" +set_name!(value::DemandRequirement, val) = value.name = val +"""Set [`DemandRequirement`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::DemandRequirement, val) = value.power_systems_type = val +"""Set [`DemandRequirement`](@ref) `available`.""" +set_available!(value::DemandRequirement, val) = value.available = val diff --git a/src/models/generated/DemandsideTechnology.jl b/src/models/generated/DemandsideTechnology.jl new file mode 100644 index 0000000..90c24c4 --- /dev/null +++ b/src/models/generated/DemandsideTechnology.jl @@ -0,0 +1,44 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct DemandsideTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + power_systems_type::string + available::boolean + end + + + +# Arguments +- `name::string`: +- `power_systems_type::string`: +- `available::boolean`: +""" +mutable struct DemandsideTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + power_systems_type::string + available::boolean +end + + +function DemandsideTechnology{T}(; name, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") + DemandsideTechnology{T}(name, power_systems_type, available, ) +end + +"""Get [`DemandsideTechnology`](@ref) `name`.""" +get_name(value::DemandsideTechnology) = value.name +"""Get [`DemandsideTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::DemandsideTechnology) = value.power_systems_type +"""Get [`DemandsideTechnology`](@ref) `available`.""" +get_available(value::DemandsideTechnology) = value.available + +"""Set [`DemandsideTechnology`](@ref) `name`.""" +set_name!(value::DemandsideTechnology, val) = value.name = val +"""Set [`DemandsideTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::DemandsideTechnology, val) = value.power_systems_type = val +"""Set [`DemandsideTechnology`](@ref) `available`.""" +set_available!(value::DemandsideTechnology, val) = value.available = val diff --git a/src/models/generated/StorageTechnology.jl b/src/models/generated/StorageTechnology.jl new file mode 100644 index 0000000..5f0626e --- /dev/null +++ b/src/models/generated/StorageTechnology.jl @@ -0,0 +1,51 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct StorageTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + storage_tech::string + power_systems_type::string + available::boolean + end + + + +# Arguments +- `name::string`: +- `storage_tech::string`: +- `power_systems_type::string`: +- `available::boolean`: +""" +mutable struct StorageTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + storage_tech::string + power_systems_type::string + available::boolean +end + + +function StorageTechnology{T}(; name, storage_tech, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") + StorageTechnology{T}(name, storage_tech, power_systems_type, available, ) +end + +"""Get [`StorageTechnology`](@ref) `name`.""" +get_name(value::StorageTechnology) = value.name +"""Get [`StorageTechnology`](@ref) `storage_tech`.""" +get_storage_tech(value::StorageTechnology) = value.storage_tech +"""Get [`StorageTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::StorageTechnology) = value.power_systems_type +"""Get [`StorageTechnology`](@ref) `available`.""" +get_available(value::StorageTechnology) = value.available + +"""Set [`StorageTechnology`](@ref) `name`.""" +set_name!(value::StorageTechnology, val) = value.name = val +"""Set [`StorageTechnology`](@ref) `storage_tech`.""" +set_storage_tech!(value::StorageTechnology, val) = value.storage_tech = val +"""Set [`StorageTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::StorageTechnology, val) = value.power_systems_type = val +"""Set [`StorageTechnology`](@ref) `available`.""" +set_available!(value::StorageTechnology, val) = value.available = val diff --git a/src/models/generated/SupplyTechnology.jl b/src/models/generated/SupplyTechnology.jl new file mode 100644 index 0000000..d95b41f --- /dev/null +++ b/src/models/generated/SupplyTechnology.jl @@ -0,0 +1,100 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct SupplyTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + capital_cost::float + minimum_required_capacity::float + available::boolean + name::string + initial_capacity::float + fuel::string + power_systems_type::string + variable_cost::float + operations_cost::float + maximum_capacity::float + capacity_factor::string + end + + + +# Arguments +- `capital_cost::float`: +- `minimum_required_capacity::float`: +- `available::boolean`: +- `name::string`: +- `initial_capacity::float`: +- `fuel::string`: +- `power_systems_type::string`: +- `variable_cost::float`: +- `operations_cost::float`: +- `maximum_capacity::float`: +- `capacity_factor::string`: +""" +mutable struct SupplyTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + capital_cost::float + minimum_required_capacity::float + available::boolean + name::string + initial_capacity::float + fuel::string + power_systems_type::string + variable_cost::float + operations_cost::float + maximum_capacity::float + capacity_factor::string +end + + +function SupplyTechnology{T}(; capital_cost, minimum_required_capacity, available, name, initial_capacity, fuel, power_systems_type, variable_cost, operations_cost, maximum_capacity, capacity_factor, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") + SupplyTechnology{T}(capital_cost, minimum_required_capacity, available, name, initial_capacity, fuel, power_systems_type, variable_cost, operations_cost, maximum_capacity, capacity_factor, ) +end + +"""Get [`SupplyTechnology`](@ref) `capital_cost`.""" +get_capital_cost(value::SupplyTechnology) = value.capital_cost +"""Get [`SupplyTechnology`](@ref) `minimum_required_capacity`.""" +get_minimum_required_capacity(value::SupplyTechnology) = value.minimum_required_capacity +"""Get [`SupplyTechnology`](@ref) `available`.""" +get_available(value::SupplyTechnology) = value.available +"""Get [`SupplyTechnology`](@ref) `name`.""" +get_name(value::SupplyTechnology) = value.name +"""Get [`SupplyTechnology`](@ref) `initial_capacity`.""" +get_initial_capacity(value::SupplyTechnology) = value.initial_capacity +"""Get [`SupplyTechnology`](@ref) `fuel`.""" +get_fuel(value::SupplyTechnology) = value.fuel +"""Get [`SupplyTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::SupplyTechnology) = value.power_systems_type +"""Get [`SupplyTechnology`](@ref) `variable_cost`.""" +get_variable_cost(value::SupplyTechnology) = value.variable_cost +"""Get [`SupplyTechnology`](@ref) `operations_cost`.""" +get_operations_cost(value::SupplyTechnology) = value.operations_cost +"""Get [`SupplyTechnology`](@ref) `maximum_capacity`.""" +get_maximum_capacity(value::SupplyTechnology) = value.maximum_capacity +"""Get [`SupplyTechnology`](@ref) `capacity_factor`.""" +get_capacity_factor(value::SupplyTechnology) = value.capacity_factor + +"""Set [`SupplyTechnology`](@ref) `capital_cost`.""" +set_capital_cost!(value::SupplyTechnology, val) = value.capital_cost = val +"""Set [`SupplyTechnology`](@ref) `minimum_required_capacity`.""" +set_minimum_required_capacity!(value::SupplyTechnology, val) = value.minimum_required_capacity = val +"""Set [`SupplyTechnology`](@ref) `available`.""" +set_available!(value::SupplyTechnology, val) = value.available = val +"""Set [`SupplyTechnology`](@ref) `name`.""" +set_name!(value::SupplyTechnology, val) = value.name = val +"""Set [`SupplyTechnology`](@ref) `initial_capacity`.""" +set_initial_capacity!(value::SupplyTechnology, val) = value.initial_capacity = val +"""Set [`SupplyTechnology`](@ref) `fuel`.""" +set_fuel!(value::SupplyTechnology, val) = value.fuel = val +"""Set [`SupplyTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::SupplyTechnology, val) = value.power_systems_type = val +"""Set [`SupplyTechnology`](@ref) `variable_cost`.""" +set_variable_cost!(value::SupplyTechnology, val) = value.variable_cost = val +"""Set [`SupplyTechnology`](@ref) `operations_cost`.""" +set_operations_cost!(value::SupplyTechnology, val) = value.operations_cost = val +"""Set [`SupplyTechnology`](@ref) `maximum_capacity`.""" +set_maximum_capacity!(value::SupplyTechnology, val) = value.maximum_capacity = val +"""Set [`SupplyTechnology`](@ref) `capacity_factor`.""" +set_capacity_factor!(value::SupplyTechnology, val) = value.capacity_factor = val diff --git a/src/models/generated/TransportTechnology.jl b/src/models/generated/TransportTechnology.jl new file mode 100644 index 0000000..d7b4108 --- /dev/null +++ b/src/models/generated/TransportTechnology.jl @@ -0,0 +1,44 @@ +#= +This file is auto-generated. Do not edit. +=# + +#! format: off + +""" + mutable struct TransportTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + power_systems_type::string + available::boolean + end + + + +# Arguments +- `name::string`: +- `power_systems_type::string`: +- `available::boolean`: +""" +mutable struct TransportTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: + name::string + power_systems_type::string + available::boolean +end + + +function TransportTechnology{T}(; name, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") + TransportTechnology{T}(name, power_systems_type, available, ) +end + +"""Get [`TransportTechnology`](@ref) `name`.""" +get_name(value::TransportTechnology) = value.name +"""Get [`TransportTechnology`](@ref) `power_systems_type`.""" +get_power_systems_type(value::TransportTechnology) = value.power_systems_type +"""Get [`TransportTechnology`](@ref) `available`.""" +get_available(value::TransportTechnology) = value.available + +"""Set [`TransportTechnology`](@ref) `name`.""" +set_name!(value::TransportTechnology, val) = value.name = val +"""Set [`TransportTechnology`](@ref) `power_systems_type`.""" +set_power_systems_type!(value::TransportTechnology, val) = value.power_systems_type = val +"""Set [`TransportTechnology`](@ref) `available`.""" +set_available!(value::TransportTechnology, val) = value.available = val diff --git a/src/models/generated/includes.jl b/src/models/generated/includes.jl new file mode 100644 index 0000000..72b5210 --- /dev/null +++ b/src/models/generated/includes.jl @@ -0,0 +1,30 @@ +include("TransportTechnology.jl") +include("SupplyTechnology.jl") +include("DemandsideTechnology.jl") +include("DemandRequirement.jl") +include("StorageTechnology.jl") + +export get_available +export get_capacity_factor +export get_capital_cost +export get_fuel +export get_initial_capacity +export get_maximum_capacity +export get_minimum_required_capacity +export get_name +export get_operations_cost +export get_power_systems_type +export get_storage_tech +export get_variable_cost +export set_available! +export set_capacity_factor! +export set_capital_cost! +export set_fuel! +export set_initial_capacity! +export set_maximum_capacity! +export set_minimum_required_capacity! +export set_name! +export set_operations_cost! +export set_power_systems_type! +export set_storage_tech! +export set_variable_cost! From eefbd89cf1223243c7705e3d0d7490ab288f7309 Mon Sep 17 00:00:00 2001 From: Jerry Potts Date: Mon, 10 Jun 2024 11:42:06 -0600 Subject: [PATCH 02/10] updated file writing and supertypes --- src/generate_structs.jl | 101 ++++--------------- src/models/generated/DemandRequirement.jl | 24 ++--- src/models/generated/DemandsideTechnology.jl | 24 ++--- src/models/generated/StorageTechnology.jl | 30 +++--- src/models/generated/SupplyTechnology.jl | 72 ++++++------- src/models/generated/TransportTechnology.jl | 24 ++--- 6 files changed, 105 insertions(+), 170 deletions(-) diff --git a/src/generate_structs.jl b/src/generate_structs.jl index f5488f8..0597dc2 100644 --- a/src/generate_structs.jl +++ b/src/generate_structs.jl @@ -1,80 +1,11 @@ -import Mustache +using JSON3 +using JSONSchema +using Mustache +using InfrastructureSystems +using PowerSystems -const STRUCT_TEMPLATE = """ -#= -This file is auto-generated. Do not edit. -=# - -#! format: off - -\"\"\" - mutable struct {{struct_name}}{{#parametric}}{T <: {{parametric}}}{{/parametric}} <: {{supertype}} - {{#parameters}} - {{name}}::{{{data_type}}} - {{/parameters}} - end - -{{#docstring}}{{{docstring}}}{{/docstring}} - -# Arguments -{{#parameters}} -- `{{name}}::{{{data_type}}}`:{{#default}} (default: `{{{default}}}`){{/default}}{{#comment}} {{{comment}}}{{/comment}}{{#valid_range}}, validation range: `{{{valid_range}}}`{{/valid_range}} -{{/parameters}} -\"\"\" -mutable struct {{struct_name}}{{#parametric}}{T <: {{parametric}}}{{/parametric}} <: {{supertype}} - {{#parameters}} - {{#comment}}"{{{comment}}}"\n {{/comment}}{{name}}::{{{data_type}}} - {{/parameters}} - {{#inner_constructor_check}} - - function {{struct_name}}({{#parameters}}{{name}}, {{/parameters}}) - ({{#parameters}}{{name}}, {{/parameters}}) = {{inner_constructor_check}}( - {{#parameters}} - {{name}}, - {{/parameters}} - ) - new({{#parameters}}{{name}}, {{/parameters}}) - end - {{/inner_constructor_check}} -end - -{{#needs_positional_constructor}} -function {{constructor_func}}({{#parameters}}{{^internal_default}}{{name}}{{#default}}={{default}}{{/default}}, {{/internal_default}}{{/parameters}}){{{closing_constructor_text}}} - {{constructor_func}}({{#parameters}}{{^internal_default}}{{name}}, {{/internal_default}}{{/parameters}}{{#parameters}}{{#internal_default}}{{{internal_default}}}, {{/internal_default}}{{/parameters}}) -end -{{/needs_positional_constructor}} - -function {{constructor_func}}(; {{#parameters}}{{name}}{{#kwarg_value}}{{{kwarg_value}}}{{/kwarg_value}}, {{/parameters}}){{{closing_constructor_text}}} - {{constructor_func}}({{#parameters}}{{name}}, {{/parameters}}) -end - -{{#has_null_values}} -# Constructor for demo purposes; non-functional. -function {{constructor_func}}(::Nothing){{{closing_constructor_text}}} - {{constructor_func}}(; - {{#parameters}} - {{^internal_default}} - {{name}}={{#quotes}}"{{null_value}}"{{/quotes}}{{^quotes}}{{null_value}}{{/quotes}}, - {{/internal_default}} - {{/parameters}} - ) -end - -{{/has_null_values}} -{{#accessors}} -{{#create_docstring}}\"\"\"Get [`{{struct_name}}`](@ref) `{{name}}`.\"\"\"{{/create_docstring}} -{{accessor}}(value::{{struct_name}}) = {{#needs_conversion}}get_value(value, value.{{name}}){{/needs_conversion}}{{^needs_conversion}}value.{{name}}{{/needs_conversion}} -{{/accessors}} - -{{#setters}} -{{#create_docstring}}\"\"\"Set [`{{struct_name}}`](@ref) `{{name}}`.\"\"\"{{/create_docstring}} -{{setter}}(value::{{struct_name}}, val) = value.{{name}} = {{#needs_conversion}}set_value(value, val){{/needs_conversion}}{{^needs_conversion}}val{{/needs_conversion}} -{{/setters}} - -{{#custom_code}} -{{{custom_code}}} -{{/custom_code}} -""" +const IS = InfrastructureSystems +const PSY = PowerSystems function read_json_data(filename::String) try @@ -95,25 +26,29 @@ function generate_invest_structs(directory, data::Schema; print_results=true) item = Dict{String, Any}() item["has_internal"] = false item["has_null_values"] = true - + item["supertype"] = input["supertype"] + accessors = Vector{Dict}() setters = Vector{Dict}() item["has_non_default_values"] = false item["constructor_func"] = struct_name - item["constructor_func"] *= "{T}" item["struct_name"] = struct_name item["closing_constructor_text"] = "" - item["parametric"] = properties["power_systems_type"] - item["closing_constructor_text"] = " where T <: $(item["parametric"])" + item["parametric"] = input["parametric"] + if haskey(item, "parametric") + item["constructor_func"] *= "{T}" + item["closing_constructor_text"] = " where T <: $(item["parametric"])" + end + + parameters = Vector{Dict}() for (field, values) in properties param = Dict{String, Any}() - #param["struct_name"] = item["struct_name"] - param["struct_name"] = item["constructor_func"] + param["struct_name"] = item["struct_name"] param["name"] = field param["data_type"] = values["type"] @@ -208,7 +143,7 @@ function generate_invest_structs(directory, data::Schema; print_results=true) filename = joinpath(directory, item["struct_name"] * ".jl") open(filename, "w") do io - write(io, strip(Mustache.render(STRUCT_TEMPLATE, item))) + write(io, strip(Mustache.render(IS.STRUCT_TEMPLATE, item))) write(io, "\n") push!(struct_names, item["struct_name"]) end diff --git a/src/models/generated/DemandRequirement.jl b/src/models/generated/DemandRequirement.jl index 8d577e7..9b79ad3 100644 --- a/src/models/generated/DemandRequirement.jl +++ b/src/models/generated/DemandRequirement.jl @@ -5,27 +5,27 @@ This file is auto-generated. Do not edit. #! format: off """ - mutable struct DemandRequirement{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - power_systems_type::string - available::boolean + mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + name::String + power_systems_type::String + available::Boolean end # Arguments -- `name::string`: -- `power_systems_type::string`: -- `available::boolean`: +- `name::String`: +- `power_systems_type::String`: +- `available::Boolean`: """ -mutable struct DemandRequirement{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - power_systems_type::string - available::boolean +mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + name::String + power_systems_type::String + available::Boolean end -function DemandRequirement{T}(; name, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") +function DemandRequirement{T}(; name, power_systems_type, available, ) where T <: PSY.StaticInjection DemandRequirement{T}(name, power_systems_type, available, ) end diff --git a/src/models/generated/DemandsideTechnology.jl b/src/models/generated/DemandsideTechnology.jl index 90c24c4..4c80d20 100644 --- a/src/models/generated/DemandsideTechnology.jl +++ b/src/models/generated/DemandsideTechnology.jl @@ -5,27 +5,27 @@ This file is auto-generated. Do not edit. #! format: off """ - mutable struct DemandsideTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - power_systems_type::string - available::boolean + mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + name::String + power_systems_type::String + available::Boolean end # Arguments -- `name::string`: -- `power_systems_type::string`: -- `available::boolean`: +- `name::String`: +- `power_systems_type::String`: +- `available::Boolean`: """ -mutable struct DemandsideTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - power_systems_type::string - available::boolean +mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + name::String + power_systems_type::String + available::Boolean end -function DemandsideTechnology{T}(; name, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") +function DemandsideTechnology{T}(; name, power_systems_type, available, ) where T <: PSY.StaticInjection DemandsideTechnology{T}(name, power_systems_type, available, ) end diff --git a/src/models/generated/StorageTechnology.jl b/src/models/generated/StorageTechnology.jl index 5f0626e..773dc51 100644 --- a/src/models/generated/StorageTechnology.jl +++ b/src/models/generated/StorageTechnology.jl @@ -5,30 +5,30 @@ This file is auto-generated. Do not edit. #! format: off """ - mutable struct StorageTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - storage_tech::string - power_systems_type::string - available::boolean + mutable struct StorageTechnology{T <: PSY.Storage} <: InfrastructureSystemsComponent + name::String + storage_tech::String + power_systems_type::String + available::Boolean end # Arguments -- `name::string`: -- `storage_tech::string`: -- `power_systems_type::string`: -- `available::boolean`: +- `name::String`: +- `storage_tech::String`: +- `power_systems_type::String`: +- `available::Boolean`: """ -mutable struct StorageTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - storage_tech::string - power_systems_type::string - available::boolean +mutable struct StorageTechnology{T <: PSY.Storage} <: InfrastructureSystemsComponent + name::String + storage_tech::String + power_systems_type::String + available::Boolean end -function StorageTechnology{T}(; name, storage_tech, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") +function StorageTechnology{T}(; name, storage_tech, power_systems_type, available, ) where T <: PSY.Storage StorageTechnology{T}(name, storage_tech, power_systems_type, available, ) end diff --git a/src/models/generated/SupplyTechnology.jl b/src/models/generated/SupplyTechnology.jl index d95b41f..13ae039 100644 --- a/src/models/generated/SupplyTechnology.jl +++ b/src/models/generated/SupplyTechnology.jl @@ -5,51 +5,51 @@ This file is auto-generated. Do not edit. #! format: off """ - mutable struct SupplyTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - capital_cost::float - minimum_required_capacity::float - available::boolean - name::string - initial_capacity::float - fuel::string - power_systems_type::string - variable_cost::float - operations_cost::float - maximum_capacity::float - capacity_factor::string + mutable struct SupplyTechnology{T <: PSY.Generator} <: InfrastructureSystemsComponent + capital_cost::Float + minimum_required_capacity::Float + available::Boolean + name::String + initial_capacity::Float + fuel::String + power_systems_type::String + variable_cost::Float + operations_cost::Float + maximum_capacity::Float + capacity_factor::String end # Arguments -- `capital_cost::float`: -- `minimum_required_capacity::float`: -- `available::boolean`: -- `name::string`: -- `initial_capacity::float`: -- `fuel::string`: -- `power_systems_type::string`: -- `variable_cost::float`: -- `operations_cost::float`: -- `maximum_capacity::float`: -- `capacity_factor::string`: +- `capital_cost::Float`: +- `minimum_required_capacity::Float`: +- `available::Boolean`: +- `name::String`: +- `initial_capacity::Float`: +- `fuel::String`: +- `power_systems_type::String`: +- `variable_cost::Float`: +- `operations_cost::Float`: +- `maximum_capacity::Float`: +- `capacity_factor::String`: """ -mutable struct SupplyTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - capital_cost::float - minimum_required_capacity::float - available::boolean - name::string - initial_capacity::float - fuel::string - power_systems_type::string - variable_cost::float - operations_cost::float - maximum_capacity::float - capacity_factor::string +mutable struct SupplyTechnology{T <: PSY.Generator} <: InfrastructureSystemsComponent + capital_cost::Float + minimum_required_capacity::Float + available::Boolean + name::String + initial_capacity::Float + fuel::String + power_systems_type::String + variable_cost::Float + operations_cost::Float + maximum_capacity::Float + capacity_factor::String end -function SupplyTechnology{T}(; capital_cost, minimum_required_capacity, available, name, initial_capacity, fuel, power_systems_type, variable_cost, operations_cost, maximum_capacity, capacity_factor, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") +function SupplyTechnology{T}(; capital_cost, minimum_required_capacity, available, name, initial_capacity, fuel, power_systems_type, variable_cost, operations_cost, maximum_capacity, capacity_factor, ) where T <: PSY.Generator SupplyTechnology{T}(capital_cost, minimum_required_capacity, available, name, initial_capacity, fuel, power_systems_type, variable_cost, operations_cost, maximum_capacity, capacity_factor, ) end diff --git a/src/models/generated/TransportTechnology.jl b/src/models/generated/TransportTechnology.jl index d7b4108..0a879bf 100644 --- a/src/models/generated/TransportTechnology.jl +++ b/src/models/generated/TransportTechnology.jl @@ -5,27 +5,27 @@ This file is auto-generated. Do not edit. #! format: off """ - mutable struct TransportTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - power_systems_type::string - available::boolean + mutable struct TransportTechnology{T <: PSY.Device} <: InfrastructureSystemsComponent + name::String + power_systems_type::String + available::Boolean end # Arguments -- `name::string`: -- `power_systems_type::string`: -- `available::boolean`: +- `name::String`: +- `power_systems_type::String`: +- `available::Boolean`: """ -mutable struct TransportTechnology{T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling")} <: - name::string - power_systems_type::string - available::boolean +mutable struct TransportTechnology{T <: PSY.Device} <: InfrastructureSystemsComponent + name::String + power_systems_type::String + available::Boolean end -function TransportTechnology{T}(; name, power_systems_type, available, ) where T <: Dict{String, Any}("type" => "string", "description" => "maps to a valid PowerSystems.jl for PCM modeling") +function TransportTechnology{T}(; name, power_systems_type, available, ) where T <: PSY.Device TransportTechnology{T}(name, power_systems_type, available, ) end From dd1d8f11dc8741fa97e1e391ba92d4e076e3eb96 Mon Sep 17 00:00:00 2001 From: Jerry Potts Date: Mon, 10 Jun 2024 14:54:46 -0600 Subject: [PATCH 03/10] added demand field --- src/models/generated/DemandsideTechnology.jl | 11 +++++++++-- src/models/generated/includes.jl | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/models/generated/DemandsideTechnology.jl b/src/models/generated/DemandsideTechnology.jl index 4c80d20..f894ca6 100644 --- a/src/models/generated/DemandsideTechnology.jl +++ b/src/models/generated/DemandsideTechnology.jl @@ -8,6 +8,7 @@ This file is auto-generated. Do not edit. mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent name::String power_systems_type::String + demand::Float available::Boolean end @@ -16,23 +17,27 @@ This file is auto-generated. Do not edit. # Arguments - `name::String`: - `power_systems_type::String`: +- `demand::Float`: - `available::Boolean`: """ mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent name::String power_systems_type::String + demand::Float available::Boolean end -function DemandsideTechnology{T}(; name, power_systems_type, available, ) where T <: PSY.StaticInjection - DemandsideTechnology{T}(name, power_systems_type, available, ) +function DemandsideTechnology{T}(; name, power_systems_type, demand, available, ) where T <: PSY.StaticInjection + DemandsideTechnology{T}(name, power_systems_type, demand, available, ) end """Get [`DemandsideTechnology`](@ref) `name`.""" get_name(value::DemandsideTechnology) = value.name """Get [`DemandsideTechnology`](@ref) `power_systems_type`.""" get_power_systems_type(value::DemandsideTechnology) = value.power_systems_type +"""Get [`DemandsideTechnology`](@ref) `demand`.""" +get_demand(value::DemandsideTechnology) = value.demand """Get [`DemandsideTechnology`](@ref) `available`.""" get_available(value::DemandsideTechnology) = value.available @@ -40,5 +45,7 @@ get_available(value::DemandsideTechnology) = value.available set_name!(value::DemandsideTechnology, val) = value.name = val """Set [`DemandsideTechnology`](@ref) `power_systems_type`.""" set_power_systems_type!(value::DemandsideTechnology, val) = value.power_systems_type = val +"""Set [`DemandsideTechnology`](@ref) `demand`.""" +set_demand!(value::DemandsideTechnology, val) = value.demand = val """Set [`DemandsideTechnology`](@ref) `available`.""" set_available!(value::DemandsideTechnology, val) = value.available = val diff --git a/src/models/generated/includes.jl b/src/models/generated/includes.jl index 72b5210..f9ad079 100644 --- a/src/models/generated/includes.jl +++ b/src/models/generated/includes.jl @@ -7,6 +7,7 @@ include("StorageTechnology.jl") export get_available export get_capacity_factor export get_capital_cost +export get_demand export get_fuel export get_initial_capacity export get_maximum_capacity @@ -19,6 +20,7 @@ export get_variable_cost export set_available! export set_capacity_factor! export set_capital_cost! +export set_demand! export set_fuel! export set_initial_capacity! export set_maximum_capacity! From d0a6ce3ddc855e5fa55da3e986f0568828815727 Mon Sep 17 00:00:00 2001 From: Jerry Potts Date: Mon, 10 Jun 2024 15:11:25 -0600 Subject: [PATCH 04/10] added fields for supplytechnology --- src/models/generated/DemandRequirement.jl | 25 +++++++++++++-- src/models/generated/DemandsideTechnology.jl | 11 ++----- src/models/generated/SupplyTechnology.jl | 32 ++++++++++++++++++-- src/models/generated/includes.jl | 16 ++++++++-- 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/src/models/generated/DemandRequirement.jl b/src/models/generated/DemandRequirement.jl index 9b79ad3..0f92b57 100644 --- a/src/models/generated/DemandRequirement.jl +++ b/src/models/generated/DemandRequirement.jl @@ -6,39 +6,60 @@ This file is auto-generated. Do not edit. """ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + load_growth::Float name::String power_systems_type::String + region::String available::Boolean + peak_load::Float end # Arguments +- `load_growth::Float`: - `name::String`: - `power_systems_type::String`: +- `region::String`: - `available::Boolean`: +- `peak_load::Float`: """ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + load_growth::Float name::String power_systems_type::String + region::String available::Boolean + peak_load::Float end -function DemandRequirement{T}(; name, power_systems_type, available, ) where T <: PSY.StaticInjection - DemandRequirement{T}(name, power_systems_type, available, ) +function DemandRequirement{T}(; load_growth, name, power_systems_type, region, available, peak_load, ) where T <: PSY.StaticInjection + DemandRequirement{T}(load_growth, name, power_systems_type, region, available, peak_load, ) end +"""Get [`DemandRequirement`](@ref) `load_growth`.""" +get_load_growth(value::DemandRequirement) = value.load_growth """Get [`DemandRequirement`](@ref) `name`.""" get_name(value::DemandRequirement) = value.name """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) `available`.""" get_available(value::DemandRequirement) = value.available +"""Get [`DemandRequirement`](@ref) `peak_load`.""" +get_peak_load(value::DemandRequirement) = value.peak_load +"""Set [`DemandRequirement`](@ref) `load_growth`.""" +set_load_growth!(value::DemandRequirement, val) = value.load_growth = val """Set [`DemandRequirement`](@ref) `name`.""" set_name!(value::DemandRequirement, val) = value.name = 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) `available`.""" set_available!(value::DemandRequirement, val) = value.available = val +"""Set [`DemandRequirement`](@ref) `peak_load`.""" +set_peak_load!(value::DemandRequirement, val) = value.peak_load = val diff --git a/src/models/generated/DemandsideTechnology.jl b/src/models/generated/DemandsideTechnology.jl index f894ca6..4c80d20 100644 --- a/src/models/generated/DemandsideTechnology.jl +++ b/src/models/generated/DemandsideTechnology.jl @@ -8,7 +8,6 @@ This file is auto-generated. Do not edit. mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent name::String power_systems_type::String - demand::Float available::Boolean end @@ -17,27 +16,23 @@ This file is auto-generated. Do not edit. # Arguments - `name::String`: - `power_systems_type::String`: -- `demand::Float`: - `available::Boolean`: """ mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent name::String power_systems_type::String - demand::Float available::Boolean end -function DemandsideTechnology{T}(; name, power_systems_type, demand, available, ) where T <: PSY.StaticInjection - DemandsideTechnology{T}(name, power_systems_type, demand, available, ) +function DemandsideTechnology{T}(; name, power_systems_type, available, ) where T <: PSY.StaticInjection + DemandsideTechnology{T}(name, power_systems_type, available, ) end """Get [`DemandsideTechnology`](@ref) `name`.""" get_name(value::DemandsideTechnology) = value.name """Get [`DemandsideTechnology`](@ref) `power_systems_type`.""" get_power_systems_type(value::DemandsideTechnology) = value.power_systems_type -"""Get [`DemandsideTechnology`](@ref) `demand`.""" -get_demand(value::DemandsideTechnology) = value.demand """Get [`DemandsideTechnology`](@ref) `available`.""" get_available(value::DemandsideTechnology) = value.available @@ -45,7 +40,5 @@ get_available(value::DemandsideTechnology) = value.available set_name!(value::DemandsideTechnology, val) = value.name = val """Set [`DemandsideTechnology`](@ref) `power_systems_type`.""" set_power_systems_type!(value::DemandsideTechnology, val) = value.power_systems_type = val -"""Set [`DemandsideTechnology`](@ref) `demand`.""" -set_demand!(value::DemandsideTechnology, val) = value.demand = val """Set [`DemandsideTechnology`](@ref) `available`.""" set_available!(value::DemandsideTechnology, val) = value.available = val diff --git a/src/models/generated/SupplyTechnology.jl b/src/models/generated/SupplyTechnology.jl index 13ae039..5ab43f5 100644 --- a/src/models/generated/SupplyTechnology.jl +++ b/src/models/generated/SupplyTechnology.jl @@ -6,14 +6,18 @@ This file is auto-generated. Do not edit. """ mutable struct SupplyTechnology{T <: PSY.Generator} <: InfrastructureSystemsComponent + base_power::Float capital_cost::Float minimum_required_capacity::Float + prime_mover_type::String available::Boolean + gen_ID::String name::String initial_capacity::Float fuel::String power_systems_type::String variable_cost::Float + balancing_topology::String operations_cost::Float maximum_capacity::Float capacity_factor::String @@ -22,43 +26,57 @@ This file is auto-generated. Do not edit. # Arguments +- `base_power::Float`: - `capital_cost::Float`: - `minimum_required_capacity::Float`: +- `prime_mover_type::String`: - `available::Boolean`: +- `gen_ID::String`: - `name::String`: - `initial_capacity::Float`: - `fuel::String`: - `power_systems_type::String`: - `variable_cost::Float`: +- `balancing_topology::String`: - `operations_cost::Float`: - `maximum_capacity::Float`: - `capacity_factor::String`: """ mutable struct SupplyTechnology{T <: PSY.Generator} <: InfrastructureSystemsComponent + base_power::Float capital_cost::Float minimum_required_capacity::Float + prime_mover_type::String available::Boolean + gen_ID::String name::String initial_capacity::Float fuel::String power_systems_type::String variable_cost::Float + balancing_topology::String operations_cost::Float maximum_capacity::Float capacity_factor::String end -function SupplyTechnology{T}(; capital_cost, minimum_required_capacity, available, name, initial_capacity, fuel, power_systems_type, variable_cost, operations_cost, maximum_capacity, capacity_factor, ) where T <: PSY.Generator - SupplyTechnology{T}(capital_cost, minimum_required_capacity, available, name, initial_capacity, fuel, power_systems_type, variable_cost, operations_cost, maximum_capacity, capacity_factor, ) +function SupplyTechnology{T}(; base_power, capital_cost, minimum_required_capacity, prime_mover_type, available, gen_ID, name, initial_capacity, fuel, power_systems_type, variable_cost, balancing_topology, operations_cost, maximum_capacity, capacity_factor, ) where T <: PSY.Generator + SupplyTechnology{T}(base_power, capital_cost, minimum_required_capacity, prime_mover_type, available, gen_ID, name, initial_capacity, fuel, power_systems_type, variable_cost, balancing_topology, operations_cost, maximum_capacity, capacity_factor, ) end +"""Get [`SupplyTechnology`](@ref) `base_power`.""" +get_base_power(value::SupplyTechnology) = value.base_power """Get [`SupplyTechnology`](@ref) `capital_cost`.""" get_capital_cost(value::SupplyTechnology) = value.capital_cost """Get [`SupplyTechnology`](@ref) `minimum_required_capacity`.""" get_minimum_required_capacity(value::SupplyTechnology) = value.minimum_required_capacity +"""Get [`SupplyTechnology`](@ref) `prime_mover_type`.""" +get_prime_mover_type(value::SupplyTechnology) = value.prime_mover_type """Get [`SupplyTechnology`](@ref) `available`.""" get_available(value::SupplyTechnology) = value.available +"""Get [`SupplyTechnology`](@ref) `gen_ID`.""" +get_gen_ID(value::SupplyTechnology) = value.gen_ID """Get [`SupplyTechnology`](@ref) `name`.""" get_name(value::SupplyTechnology) = value.name """Get [`SupplyTechnology`](@ref) `initial_capacity`.""" @@ -69,6 +87,8 @@ get_fuel(value::SupplyTechnology) = value.fuel get_power_systems_type(value::SupplyTechnology) = value.power_systems_type """Get [`SupplyTechnology`](@ref) `variable_cost`.""" get_variable_cost(value::SupplyTechnology) = value.variable_cost +"""Get [`SupplyTechnology`](@ref) `balancing_topology`.""" +get_balancing_topology(value::SupplyTechnology) = value.balancing_topology """Get [`SupplyTechnology`](@ref) `operations_cost`.""" get_operations_cost(value::SupplyTechnology) = value.operations_cost """Get [`SupplyTechnology`](@ref) `maximum_capacity`.""" @@ -76,12 +96,18 @@ get_maximum_capacity(value::SupplyTechnology) = value.maximum_capacity """Get [`SupplyTechnology`](@ref) `capacity_factor`.""" get_capacity_factor(value::SupplyTechnology) = value.capacity_factor +"""Set [`SupplyTechnology`](@ref) `base_power`.""" +set_base_power!(value::SupplyTechnology, val) = value.base_power = val """Set [`SupplyTechnology`](@ref) `capital_cost`.""" set_capital_cost!(value::SupplyTechnology, val) = value.capital_cost = val """Set [`SupplyTechnology`](@ref) `minimum_required_capacity`.""" set_minimum_required_capacity!(value::SupplyTechnology, val) = value.minimum_required_capacity = val +"""Set [`SupplyTechnology`](@ref) `prime_mover_type`.""" +set_prime_mover_type!(value::SupplyTechnology, val) = value.prime_mover_type = val """Set [`SupplyTechnology`](@ref) `available`.""" set_available!(value::SupplyTechnology, val) = value.available = val +"""Set [`SupplyTechnology`](@ref) `gen_ID`.""" +set_gen_ID!(value::SupplyTechnology, val) = value.gen_ID = val """Set [`SupplyTechnology`](@ref) `name`.""" set_name!(value::SupplyTechnology, val) = value.name = val """Set [`SupplyTechnology`](@ref) `initial_capacity`.""" @@ -92,6 +118,8 @@ set_fuel!(value::SupplyTechnology, val) = value.fuel = val set_power_systems_type!(value::SupplyTechnology, val) = value.power_systems_type = val """Set [`SupplyTechnology`](@ref) `variable_cost`.""" set_variable_cost!(value::SupplyTechnology, val) = value.variable_cost = val +"""Set [`SupplyTechnology`](@ref) `balancing_topology`.""" +set_balancing_topology!(value::SupplyTechnology, val) = value.balancing_topology = val """Set [`SupplyTechnology`](@ref) `operations_cost`.""" set_operations_cost!(value::SupplyTechnology, val) = value.operations_cost = val """Set [`SupplyTechnology`](@ref) `maximum_capacity`.""" diff --git a/src/models/generated/includes.jl b/src/models/generated/includes.jl index f9ad079..d36ac07 100644 --- a/src/models/generated/includes.jl +++ b/src/models/generated/includes.jl @@ -5,28 +5,40 @@ include("DemandRequirement.jl") include("StorageTechnology.jl") export get_available +export get_balancing_topology +export get_base_power export get_capacity_factor export get_capital_cost -export get_demand export get_fuel +export get_gen_ID export get_initial_capacity +export get_load_growth export get_maximum_capacity export get_minimum_required_capacity export get_name export get_operations_cost +export get_peak_load export get_power_systems_type +export get_prime_mover_type +export get_region export get_storage_tech export get_variable_cost export set_available! +export set_balancing_topology! +export set_base_power! export set_capacity_factor! export set_capital_cost! -export set_demand! export set_fuel! +export set_gen_ID! export set_initial_capacity! +export set_load_growth! export set_maximum_capacity! export set_minimum_required_capacity! export set_name! export set_operations_cost! +export set_peak_load! export set_power_systems_type! +export set_prime_mover_type! +export set_region! export set_storage_tech! export set_variable_cost! From 4f12eb21d06042d91aedf11fccbde6e59cd62f03 Mon Sep 17 00:00:00 2001 From: Jerry Potts Date: Wed, 12 Jun 2024 13:44:58 -0600 Subject: [PATCH 05/10] added argument descriptions --- src/generate_structs.jl | 1 + src/models/generated/DemandRequirement.jl | 18 +++++--- src/models/generated/DemandsideTechnology.jl | 9 ++-- src/models/generated/StorageTechnology.jl | 12 ++++-- src/models/generated/SupplyTechnology.jl | 45 +++++++++++++------- src/models/generated/TransportTechnology.jl | 9 ++-- 6 files changed, 63 insertions(+), 31 deletions(-) diff --git a/src/generate_structs.jl b/src/generate_structs.jl index 0597dc2..dd0ca84 100644 --- a/src/generate_structs.jl +++ b/src/generate_structs.jl @@ -51,6 +51,7 @@ function generate_invest_structs(directory, data::Schema; print_results=true) param["struct_name"] = item["struct_name"] param["name"] = field param["data_type"] = values["type"] + param["comment"] = values["description"] if haskey(param, "valid_range") if typeof(param["valid_range"]) == Dict{String, Any} diff --git a/src/models/generated/DemandRequirement.jl b/src/models/generated/DemandRequirement.jl index 0f92b57..ef0dc42 100644 --- a/src/models/generated/DemandRequirement.jl +++ b/src/models/generated/DemandRequirement.jl @@ -17,19 +17,25 @@ This file is auto-generated. Do not edit. # Arguments -- `load_growth::Float`: -- `name::String`: -- `power_systems_type::String`: -- `region::String`: -- `available::Boolean`: -- `peak_load::Float`: +- `load_growth::Float`: Annual load growth (%) +- `name::String`: The technology name +- `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling +- `region::String`: Corresponding region for peak demand +- `available::Boolean`: identifies whether the technology is available +- `peak_load::Float`: Demand value (MW) for single timepoint (for now) """ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + "Annual load growth (%)" load_growth::Float + "The technology name" name::String + "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String + "Corresponding region for peak demand" region::String + "identifies whether the technology is available" available::Boolean + "Demand value (MW) for single timepoint (for now)" peak_load::Float end diff --git a/src/models/generated/DemandsideTechnology.jl b/src/models/generated/DemandsideTechnology.jl index 4c80d20..cb4fa15 100644 --- a/src/models/generated/DemandsideTechnology.jl +++ b/src/models/generated/DemandsideTechnology.jl @@ -14,13 +14,16 @@ This file is auto-generated. Do not edit. # Arguments -- `name::String`: -- `power_systems_type::String`: -- `available::Boolean`: +- `name::String`: The technology name +- `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling +- `available::Boolean`: identifies whether the technology is available """ mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent + "The technology name" name::String + "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String + "identifies whether the technology is available" available::Boolean end diff --git a/src/models/generated/StorageTechnology.jl b/src/models/generated/StorageTechnology.jl index 773dc51..e1e7f3d 100644 --- a/src/models/generated/StorageTechnology.jl +++ b/src/models/generated/StorageTechnology.jl @@ -15,15 +15,19 @@ This file is auto-generated. Do not edit. # Arguments -- `name::String`: -- `storage_tech::String`: -- `power_systems_type::String`: -- `available::Boolean`: +- `name::String`: The technology name +- `storage_tech::String`: Storage Technology Type +- `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling +- `available::Boolean`: identifies whether the technology is available """ mutable struct StorageTechnology{T <: PSY.Storage} <: InfrastructureSystemsComponent + "The technology name" name::String + "Storage Technology Type" storage_tech::String + "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String + "identifies whether the technology is available" available::Boolean end diff --git a/src/models/generated/SupplyTechnology.jl b/src/models/generated/SupplyTechnology.jl index 5ab43f5..aa5d53f 100644 --- a/src/models/generated/SupplyTechnology.jl +++ b/src/models/generated/SupplyTechnology.jl @@ -26,37 +26,52 @@ This file is auto-generated. Do not edit. # Arguments -- `base_power::Float`: -- `capital_cost::Float`: -- `minimum_required_capacity::Float`: -- `prime_mover_type::String`: -- `available::Boolean`: -- `gen_ID::String`: -- `name::String`: -- `initial_capacity::Float`: -- `fuel::String`: -- `power_systems_type::String`: -- `variable_cost::Float`: -- `balancing_topology::String`: -- `operations_cost::Float`: -- `maximum_capacity::Float`: -- `capacity_factor::String`: +- `base_power::Float`: Base power +- `capital_cost::Float`: Capital costs for investing in a technology. +- `minimum_required_capacity::Float`: Minimum required capacity for a technology +- `prime_mover_type::String`: Prime mover for generator +- `available::Boolean`: identifies whether the technology is available +- `gen_ID::String`: ID for individual generator +- `name::String`: The technology name +- `initial_capacity::Float`: Pre-existing capacity for a technology +- `fuel::String`: Fuel type according to IEA +- `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling +- `variable_cost::Float`: Variable O&M costs for a technology +- `balancing_topology::String`: Set of balancing nodes +- `operations_cost::Float`: Fixed O&M costs for a technology +- `maximum_capacity::Float`: Maximum allowable installed capacity for a technology +- `capacity_factor::String`: Derating factor to account for planned or forced outages of a technology """ mutable struct SupplyTechnology{T <: PSY.Generator} <: InfrastructureSystemsComponent + "Base power" base_power::Float + "Capital costs for investing in a technology." capital_cost::Float + "Minimum required capacity for a technology" minimum_required_capacity::Float + "Prime mover for generator" prime_mover_type::String + "identifies whether the technology is available" available::Boolean + "ID for individual generator" gen_ID::String + "The technology name" name::String + "Pre-existing capacity for a technology" initial_capacity::Float + "Fuel type according to IEA" fuel::String + "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String + "Variable O&M costs for a technology" variable_cost::Float + "Set of balancing nodes" balancing_topology::String + "Fixed O&M costs for a technology" operations_cost::Float + "Maximum allowable installed capacity for a technology" maximum_capacity::Float + "Derating factor to account for planned or forced outages of a technology" capacity_factor::String end diff --git a/src/models/generated/TransportTechnology.jl b/src/models/generated/TransportTechnology.jl index 0a879bf..f19835a 100644 --- a/src/models/generated/TransportTechnology.jl +++ b/src/models/generated/TransportTechnology.jl @@ -14,13 +14,16 @@ This file is auto-generated. Do not edit. # Arguments -- `name::String`: -- `power_systems_type::String`: -- `available::Boolean`: +- `name::String`: The technology name +- `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling +- `available::Boolean`: identifies whether the technology is available """ mutable struct TransportTechnology{T <: PSY.Device} <: InfrastructureSystemsComponent + "The technology name" name::String + "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String + "identifies whether the technology is available" available::Boolean end From 46ec9ec7aa51e7b0af7d13402769376ceee18c79 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Wed, 12 Jun 2024 15:10:50 -0700 Subject: [PATCH 06/10] formatter --- src/generate_structs.jl | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/generate_structs.jl b/src/generate_structs.jl index dd0ca84..9208e7d 100644 --- a/src/generate_structs.jl +++ b/src/generate_structs.jl @@ -21,7 +21,6 @@ function generate_invest_structs(directory, data::Schema; print_results=true) unique_setter_functions = Set{String}() for (struct_name, input) in data.data["\$defs"] - properties = input["properties"] item = Dict{String, Any}() item["has_internal"] = false @@ -43,7 +42,6 @@ function generate_invest_structs(directory, data::Schema; print_results=true) item["closing_constructor_text"] = " where T <: $(item["parametric"])" end - parameters = Vector{Dict}() for (field, values) in properties param = Dict{String, Any}() @@ -78,7 +76,7 @@ function generate_invest_structs(directory, data::Schema; print_results=true) accessor_name = accessor_module * "get_" * param["name"] setter_name = accessor_module * "set_" * param["name"] * "!" - + push!( accessors, Dict( @@ -139,21 +137,22 @@ function generate_invest_structs(directory, data::Schema; print_results=true) # If all parameters have defaults then the positional constructor will # collide with the kwarg constructor. - item["needs_positional_constructor"] = item["has_internal"] && item["has_non_default_values"] + item["needs_positional_constructor"] = + item["has_internal"] && item["has_non_default_values"] filename = joinpath(directory, item["struct_name"] * ".jl") - + open(filename, "w") do io write(io, strip(Mustache.render(IS.STRUCT_TEMPLATE, item))) write(io, "\n") push!(struct_names, item["struct_name"]) end - + if print_results println("Wrote $filename") end end - + accessors = sort!(collect(unique_accessor_functions)) setters = sort!(collect(unique_setter_functions)) filename = joinpath(directory, "includes.jl") @@ -173,7 +172,6 @@ function generate_invest_structs(directory, data::Schema; print_results=true) println("Wrote $filename") end end - end function generate_structs( From 44dbc70f91d93dcd5e30d5e2e2936230bf21ca6b Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Thu, 13 Jun 2024 13:24:26 -0700 Subject: [PATCH 07/10] remove old structs --- src/models/demand_requirement.jl | 9 --------- src/models/demand_side.jl | 9 --------- src/models/includes.jl | 6 ------ src/models/storage.jl | 12 ------------ src/models/supply.jl | 13 ------------- src/models/transport.jl | 9 --------- 6 files changed, 58 deletions(-) delete mode 100644 src/models/demand_requirement.jl delete mode 100644 src/models/demand_side.jl delete mode 100644 src/models/includes.jl delete mode 100644 src/models/storage.jl delete mode 100644 src/models/supply.jl delete mode 100644 src/models/transport.jl diff --git a/src/models/demand_requirement.jl b/src/models/demand_requirement.jl deleted file mode 100644 index a111187..0000000 --- a/src/models/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/models/demand_side.jl b/src/models/demand_side.jl deleted file mode 100644 index 75fe348..0000000 --- a/src/models/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/models/includes.jl b/src/models/includes.jl deleted file mode 100644 index 01bf175..0000000 --- a/src/models/includes.jl +++ /dev/null @@ -1,6 +0,0 @@ -include("technologies.jl") -include("demand_requirement.jl") -include("supply.jl") -include("demand_side.jl") -include("transport.jl") -include("storage.jl") diff --git a/src/models/storage.jl b/src/models/storage.jl deleted file mode 100644 index 7039971..0000000 --- a/src/models/storage.jl +++ /dev/null @@ -1,12 +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 diff --git a/src/models/supply.jl b/src/models/supply.jl deleted file mode 100644 index ba1bdc5..0000000 --- a/src/models/supply.jl +++ /dev/null @@ -1,13 +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::IS.FunctionData - operational_cost::PSY.OperationalCost - supplemental_attributes_container::IS.SupplementalAttributesContainer - time_series_container::IS.TimeSeriesContainer - internal::InfrastructureSystemsInternal -end diff --git a/src/models/transport.jl b/src/models/transport.jl deleted file mode 100644 index 06ddcfb..0000000 --- a/src/models/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 269c8f78249569f616f3f9cc680b3623047b0f4f Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Thu, 13 Jun 2024 13:24:37 -0700 Subject: [PATCH 08/10] manual update float and boolean --- src/models/generated/DemandRequirement.jl | 18 ++++---- src/models/generated/DemandsideTechnology.jl | 6 +-- src/models/generated/StorageTechnology.jl | 6 +-- src/models/generated/SupplyTechnology.jl | 48 ++++++++++---------- src/models/generated/TransportTechnology.jl | 6 +-- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/models/generated/DemandRequirement.jl b/src/models/generated/DemandRequirement.jl index ef0dc42..e765305 100644 --- a/src/models/generated/DemandRequirement.jl +++ b/src/models/generated/DemandRequirement.jl @@ -6,27 +6,27 @@ This file is auto-generated. Do not edit. """ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent - load_growth::Float + load_growth::Float64 name::String power_systems_type::String region::String - available::Boolean - peak_load::Float + available::Bool + peak_load::Float64 end # Arguments -- `load_growth::Float`: Annual load growth (%) +- `load_growth::Float64`: Annual load growth (%) - `name::String`: The technology name - `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling - `region::String`: Corresponding region for peak demand -- `available::Boolean`: identifies whether the technology is available -- `peak_load::Float`: Demand value (MW) for single timepoint (for now) +- `available::Bool`: identifies whether the technology is available +- `peak_load::Float64`: Demand value (MW) for single timepoint (for now) """ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent "Annual load growth (%)" - load_growth::Float + load_growth::Float64 "The technology name" name::String "maps to a valid PowerSystems.jl for PCM modeling" @@ -34,9 +34,9 @@ mutable struct DemandRequirement{T <: PSY.StaticInjection} <: InfrastructureSyst "Corresponding region for peak demand" region::String "identifies whether the technology is available" - available::Boolean + available::Bool "Demand value (MW) for single timepoint (for now)" - peak_load::Float + peak_load::Float64 end diff --git a/src/models/generated/DemandsideTechnology.jl b/src/models/generated/DemandsideTechnology.jl index cb4fa15..7707bff 100644 --- a/src/models/generated/DemandsideTechnology.jl +++ b/src/models/generated/DemandsideTechnology.jl @@ -8,7 +8,7 @@ This file is auto-generated. Do not edit. mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent name::String power_systems_type::String - available::Boolean + available::Bool end @@ -16,7 +16,7 @@ This file is auto-generated. Do not edit. # Arguments - `name::String`: The technology name - `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling -- `available::Boolean`: identifies whether the technology is available +- `available::Bool`: identifies whether the technology is available """ mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureSystemsComponent "The technology name" @@ -24,7 +24,7 @@ mutable struct DemandsideTechnology{T <: PSY.StaticInjection} <: InfrastructureS "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String "identifies whether the technology is available" - available::Boolean + available::Bool end diff --git a/src/models/generated/StorageTechnology.jl b/src/models/generated/StorageTechnology.jl index e1e7f3d..0e7454f 100644 --- a/src/models/generated/StorageTechnology.jl +++ b/src/models/generated/StorageTechnology.jl @@ -9,7 +9,7 @@ This file is auto-generated. Do not edit. name::String storage_tech::String power_systems_type::String - available::Boolean + available::Bool end @@ -18,7 +18,7 @@ This file is auto-generated. Do not edit. - `name::String`: The technology name - `storage_tech::String`: Storage Technology Type - `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling -- `available::Boolean`: identifies whether the technology is available +- `available::Bool`: identifies whether the technology is available """ mutable struct StorageTechnology{T <: PSY.Storage} <: InfrastructureSystemsComponent "The technology name" @@ -28,7 +28,7 @@ mutable struct StorageTechnology{T <: PSY.Storage} <: InfrastructureSystemsCompo "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String "identifies whether the technology is available" - available::Boolean + available::Bool end diff --git a/src/models/generated/SupplyTechnology.jl b/src/models/generated/SupplyTechnology.jl index aa5d53f..c0523a8 100644 --- a/src/models/generated/SupplyTechnology.jl +++ b/src/models/generated/SupplyTechnology.jl @@ -6,71 +6,71 @@ This file is auto-generated. Do not edit. """ mutable struct SupplyTechnology{T <: PSY.Generator} <: InfrastructureSystemsComponent - base_power::Float - capital_cost::Float - minimum_required_capacity::Float + base_power::Float64 + capital_cost::Float64 + minimum_required_capacity::Float64 prime_mover_type::String - available::Boolean + available::Bool gen_ID::String name::String - initial_capacity::Float + initial_capacity::Float64 fuel::String power_systems_type::String - variable_cost::Float + variable_cost::Float64 balancing_topology::String - operations_cost::Float - maximum_capacity::Float + operations_cost::Float64 + maximum_capacity::Float64 capacity_factor::String end # Arguments -- `base_power::Float`: Base power -- `capital_cost::Float`: Capital costs for investing in a technology. -- `minimum_required_capacity::Float`: Minimum required capacity for a technology +- `base_power::Float64`: Base power +- `capital_cost::Float64`: Capital costs for investing in a technology. +- `minimum_required_capacity::Float64`: Minimum required capacity for a technology - `prime_mover_type::String`: Prime mover for generator -- `available::Boolean`: identifies whether the technology is available +- `available::Bool`: identifies whether the technology is available - `gen_ID::String`: ID for individual generator - `name::String`: The technology name -- `initial_capacity::Float`: Pre-existing capacity for a technology +- `initial_capacity::Float64`: Pre-existing capacity for a technology - `fuel::String`: Fuel type according to IEA - `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling -- `variable_cost::Float`: Variable O&M costs for a technology +- `variable_cost::Float64`: Variable O&M costs for a technology - `balancing_topology::String`: Set of balancing nodes -- `operations_cost::Float`: Fixed O&M costs for a technology -- `maximum_capacity::Float`: Maximum allowable installed capacity for a technology +- `operations_cost::Float64`: Fixed O&M costs for a technology +- `maximum_capacity::Float64`: Maximum allowable installed capacity for a technology - `capacity_factor::String`: Derating factor to account for planned or forced outages of a technology """ mutable struct SupplyTechnology{T <: PSY.Generator} <: InfrastructureSystemsComponent "Base power" - base_power::Float + base_power::Float64 "Capital costs for investing in a technology." - capital_cost::Float + capital_cost::Float64 "Minimum required capacity for a technology" - minimum_required_capacity::Float + minimum_required_capacity::Float64 "Prime mover for generator" prime_mover_type::String "identifies whether the technology is available" - available::Boolean + available::Bool "ID for individual generator" gen_ID::String "The technology name" name::String "Pre-existing capacity for a technology" - initial_capacity::Float + initial_capacity::Float64 "Fuel type according to IEA" fuel::String "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String "Variable O&M costs for a technology" - variable_cost::Float + variable_cost::Float64 "Set of balancing nodes" balancing_topology::String "Fixed O&M costs for a technology" - operations_cost::Float + operations_cost::Float64 "Maximum allowable installed capacity for a technology" - maximum_capacity::Float + maximum_capacity::Float64 "Derating factor to account for planned or forced outages of a technology" capacity_factor::String end diff --git a/src/models/generated/TransportTechnology.jl b/src/models/generated/TransportTechnology.jl index f19835a..fdc2cbd 100644 --- a/src/models/generated/TransportTechnology.jl +++ b/src/models/generated/TransportTechnology.jl @@ -8,7 +8,7 @@ This file is auto-generated. Do not edit. mutable struct TransportTechnology{T <: PSY.Device} <: InfrastructureSystemsComponent name::String power_systems_type::String - available::Boolean + available::Bool end @@ -16,7 +16,7 @@ This file is auto-generated. Do not edit. # Arguments - `name::String`: The technology name - `power_systems_type::String`: maps to a valid PowerSystems.jl for PCM modeling -- `available::Boolean`: identifies whether the technology is available +- `available::Bool`: identifies whether the technology is available """ mutable struct TransportTechnology{T <: PSY.Device} <: InfrastructureSystemsComponent "The technology name" @@ -24,7 +24,7 @@ mutable struct TransportTechnology{T <: PSY.Device} <: InfrastructureSystemsComp "maps to a valid PowerSystems.jl for PCM modeling" power_systems_type::String "identifies whether the technology is available" - available::Boolean + available::Bool end From 7ed901d2d923e6c075fcc00f95ac0d5b6a0cf31a Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Thu, 13 Jun 2024 13:25:23 -0700 Subject: [PATCH 09/10] add mustache --- src/PowerSystemsInvestmentsPortfolios.jl | 7 +++++-- src/generate_structs.jl | 17 +++++++---------- src/serialization.jl | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/PowerSystemsInvestmentsPortfolios.jl b/src/PowerSystemsInvestmentsPortfolios.jl index d664f0d..99b197d 100644 --- a/src/PowerSystemsInvestmentsPortfolios.jl +++ b/src/PowerSystemsInvestmentsPortfolios.jl @@ -19,7 +19,8 @@ import InfrastructureSystems: CompressionTypes, MultiLogger, LogEventTracker, - StructField + StructField, + InfrastructureSystemsComponent import PowerSystems import JSONSchema @@ -39,8 +40,10 @@ export generate_structs const PSY = PowerSystems const IS = InfrastructureSystems +const MU = IS.Mustache -include("models/includes.jl") +include("models/technologies.jl") +include("models/generated/includes.jl") include("portfolio.jl") include("generate_structs.jl") diff --git a/src/generate_structs.jl b/src/generate_structs.jl index 9208e7d..52ddb58 100644 --- a/src/generate_structs.jl +++ b/src/generate_structs.jl @@ -1,11 +1,8 @@ -using JSON3 -using JSONSchema -using Mustache -using InfrastructureSystems -using PowerSystems - -const IS = InfrastructureSystems -const PSY = PowerSystems +#using JSON3 +#using JSONSchema +#using InfrastructureSystems +#using InfrastructureSystems.Mustache +#using PowerSystems function read_json_data(filename::String) try @@ -15,7 +12,7 @@ function read_json_data(filename::String) end end -function generate_invest_structs(directory, data::Schema; print_results=true) +function generate_invest_structs(directory, data::JSONSchema.Schema; print_results=true) struct_names = Vector{String}() unique_accessor_functions = Set{String}() unique_setter_functions = Set{String}() @@ -143,7 +140,7 @@ function generate_invest_structs(directory, data::Schema; print_results=true) filename = joinpath(directory, item["struct_name"] * ".jl") open(filename, "w") do io - write(io, strip(Mustache.render(IS.STRUCT_TEMPLATE, item))) + write(io, strip(MU.render(IS.STRUCT_TEMPLATE, item))) write(io, "\n") push!(struct_names, item["struct_name"]) end diff --git a/src/serialization.jl b/src/serialization.jl index 3966530..e9844ea 100644 --- a/src/serialization.jl +++ b/src/serialization.jl @@ -299,7 +299,7 @@ function _post_deserialize_handling( assign_new_uuid!(portfolio, component) end for component in - IS.get_masked_components(InfrastructureSystemsComponent, portfolio.data) + IS.get_masked_components(IS.InfrastructureSystemsComponent, portfolio.data) assign_new_uuid!(portfolio, component) end # Note: this does not change UUIDs for time series data because they are From e4c666c0afcde7105c469fe430296e8691650fd8 Mon Sep 17 00:00:00 2001 From: rodrigomha Date: Thu, 13 Jun 2024 13:25:32 -0700 Subject: [PATCH 10/10] remove stale code --- src/generate_structs.jl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/generate_structs.jl b/src/generate_structs.jl index 52ddb58..752bdfb 100644 --- a/src/generate_structs.jl +++ b/src/generate_structs.jl @@ -1,9 +1,3 @@ -#using JSON3 -#using JSONSchema -#using InfrastructureSystems -#using InfrastructureSystems.Mustache -#using PowerSystems - function read_json_data(filename::String) try return JSONSchema.Schema(JSON3.read(filename))