Internals

Index

Types

EnergyModelsGUI.ConnectionType
Connection <: AbstractGUIObj

Mutable type for providing a flexible data structure for connections between EnergySystemDesigns.

Fields

  • from::EnergySystemDesign is the EnergySystemDesign from which the connection originates.
  • to::EnergySystemDesign is the EnergySystemDesign to which the connection is linked to.
  • connection::AbstractElement is the EMX connection structure.
  • colors::Vector{RGBA{Float32}} is the associated colors of the connection.
  • plots::Vector{Any} is a vector with all Makie object associated with this object.
  • invest_data::ProcInvData stores processed investment data.
source
EnergyModelsGUI.EnergySystemIteratorType
EnergySystemIterator

Type for iterating over nested EnergySystemDesign structures, enabling recursion through AbstractGUIObjs.

Fields

  • stack::Vector{<:AbstractGUIObj} is the stack used to manage the iteration through the nested EnergySystemDesign components (and its connections). It starts with the initial EnergySystemDesign object and progressively includes its subcomponents as the iteration proceeds.
source
EnergyModelsGUI.PlotContainerType
PlotContainer{T}

Type for storing plot-related data available from the "Data" menu.

Fields

  • name::String: is the reference name for the data.
  • selection::Vector: is the indices used to extract the data to be plotted.
  • field_data::Any: is the data from which plots are extracted based on selection.
  • description::String: is the description to be used for the legend.
source
EnergyModelsGUI.ProcInvDataType
ProcInvData

Type for storing processed investment data.

Fields

  • inv_times::Vector{String} is a vector of formatted strings for added investments.
  • capex::Vector{Number} contains the capex of all times with added investments.
  • invested::Bool indicates if the element has been invested in.
source
EnergyModelsGUI.SystemType
System

Type for storing processed system data from EnergyModelsBase.

Fields

  • T::TimeStructure is the time structure of the model.
  • products::Vector{<:Resource} are the resources that should be incorporated into the model.
  • elements::Vector{Vector} are the vectors of AbstractElement that should be included in the analysis.
  • children::Vector{<:EMB.Node} are the children of the system.
  • connections::Vector{<:Link} are the connections between system parts.
  • parent::AbstractElement is the parent of the system (e.g., the Area node of the reference GeoAvailability node).
  • ref_element::AbstractElement is the reference element of the system (first Availability node).
source
EnergyModelsGUI.SystemGeoType
SystemGeo

Type for storing processed system data from EnergyModelsGeography.

Fields

  • T::TimeStructure is the time structure of the model.
  • products::Vector{<:Resource} are the resources that should be incorporated into the model.
  • elements::Vector{Vector} are the vectors of AbstractElement that should be included in the analysis.
  • children::Vector{<:EMB.Node} are the children of the system.
  • connections::Vector{<:Link} are the connections between system parts.
  • parent::AbstractElement is the parent of the system.
  • ref_element::AbstractElement is the reference element of the system.
source

Functions

Base.iterateFunction
iterate(itr::EnergySystemIterator)

Initialize the iteration over an EnergySystemIterator, returning the first EnergySystemDesign object in the stack and the iterator itself. If the stack is empty, return nothing.

source
EnergyModelsGUI._type_to_headerMethod
_type_to_header(::Type{<:TS.AbstractStrategicPeriod})
_type_to_header(::Type{<:TS.AbstractRepresentativePeriod})
_type_to_header(::Type{<:TS.AbstractOperationalScenario})
_type_to_header(::Type{<:TS.TimePeriod})
_type_to_header(::Type{<:TS.TimeStructure})
_type_to_header(::Type{<:Resource})
_type_to_header(::Type{<:AbstractElement})

Map types to header symbols for saving results.

source
EnergyModelsGUI.add_component!Method
add_component!(gui::GUI, component::EnergySystemDesign)

Draw a box containing the icon and add a label with the id of the EnergySystemDesign component with its type in parantheses.

source
EnergyModelsGUI.add_description!Method
add_description!(
    field::Any,
    name::String,
    ::String,
    pre_desc::String,
    element,
    available_data::Vector{PlotContainer},
    gui::GUI,
)

Loop through all struct fieldnames of field (i.e.,for the field level of type NoStartInvData) and update available_data with an added description.

source
EnergyModelsGUI.add_description!Method
add_description!(
    field::Dict,
    name::String,
    key_str::String,
    pre_desc::String,
    selection::Vector,
    available_data::Vector{PlotContainer},
    gui::GUI,
)

Loop through all dictnames for a field of type Dict (e.g. for the field penalty having the keys :deficit and surplus) and update available_data with an added description.

source
EnergyModelsGUI.add_description!Method
add_description!(
    field::TS.TimeProfile,
    name::String,
    key_str::String,
    pre_desc::String,
    selection::Vector,
    available_data::Vector{PlotContainer},
    gui::GUI,
)

Create a container with a description, and add container to available_data.

source
EnergyModelsGUI.add_description!Method
add_description!(
    field::Vector,
    name::String,
    key_str::String,
    pre_desc::String,
    selection::Vector,
    available_data::Vector{PlotContainer},
    gui::GUI,
)

Loop through all elements of field of type Vector (i.e.,for the field data) and update available_data with an added description.

source
EnergyModelsGUI.alignMethod
align(gui::GUI, align::Symbol)

Align components in get_selected_systems(gui) based on the value of Symbol align.

The following values are allowed

  • :horizontal for horizontal alignment.
  • :vertical for vertical alignment.
source
EnergyModelsGUI.angleMethod
angle(node_1::EnergySystemDesign, node_2::EnergySystemDesign)

Based on the location of node_1 and node_2, return the angle between the x-axis and node_2 with node_1 being the origin.

source
EnergyModelsGUI.boxMethod
function box(x::Float32, y::Float32, Δ::Float32)

Get the coordinates of a box with half side lengths Δ and centered at (x,y) starting at the upper right corner.

source
EnergyModelsGUI.clear_selectionMethod
clear_selection(gui::GUI, ax_type::Symbol)

Clear the color selection of the topology axis if ax_type = :topo, and of the results axis if ax_type = :results.

source
EnergyModelsGUI.connect!Method
connect!(gui::GUI, connection::Connection, two_way::Bool)

When a boolean argument two_way is specified, draw the lines in both directions.

source
EnergyModelsGUI.connect!Method
connect!(gui::GUI, design::EnergySystemDesign)

Draws lines between connected nodes/areas in GUI gui using EnergySystemDesign design.

source
EnergyModelsGUI.create_labelMethod
create_label(selection::PlotContainer)

Return a label for a given selection to be used in the getmenus(gui)[:availabledata] menu.

source
EnergyModelsGUI.create_makie_objectsMethod
create_makie_objects(vars::Dict, design::EnergySystemDesign)

Create Makie figure and all its objects (buttons, menus, toggles and axes) for EnergySystemDesign design and the options vars.

source
EnergyModelsGUI.draw_box!Method
draw_box!(gui::GUI, design::EnergySystemDesign)

Draw a box for EnergySystemDesign design and it's appearance, including style, color, size.

source
EnergyModelsGUI.export_to_fileMethod
export_to_file(gui::GUI)

Export results based on the state of gui to a file located within the folder specified through the path_to_results keyword of GUI.

source
EnergyModelsGUI.export_xlsxMethod
export_xlsx(plots::Vector, filename::String, xlabel::Symbol)

Export the plots to a .xlsx file with path given by filename and top header xlabel.

source
EnergyModelsGUI.extract_data_selectionMethod
extract_data_selection(var::SparseVars, selection::Vector, i_T::Int64, periods::Vector)
extract_data_selection(var::Jump.Containers.DenseAxisArray, selection::Vector, i_T::Int64, ::Vector)
extract_data_selection(var::DataFrame, selection::Vector, ::Int64, ::Vector)

Extract data from var having its time dimension at index i_T for all time periods in periods.

Reading model results from CSV-files

This function does not support more than three indices for var::DataFrame (i.e., when model results are read from CSV-files). This implies it is incompatible with potential extensions that introduce more than three indices for variables.

source
EnergyModelsGUI.find_iconMethod
find_icon(system::AbstractSystem, id_to_icon_map::Dict)

Find the icon associated with a given system's node id utilizing the mapping provided through id_to_icon_map.

source
EnergyModelsGUI.find_min_max_coordinatesMethod
find_min_max_coordinates(
    design::EnergySystemDesign,
    min_x::Number,
    max_x::Number,
    min_y::Number,
    max_y::Number
)

Find the minimum and maximum coordinates of the components of EnergySystemDesign design given the minimum and maximum coordinates min_x, min_y, max_x, and max_y.

source
EnergyModelsGUI.get_EMGUI_objMethod
get_EMGUI_obj(plt)

Get the EnergySystemDesign/Connection assosiated with plt. Note that due to the nested structure of Makie, we must iteratively look through up to three nested layers to find where this object is stored.

source
EnergyModelsGUI.get_JuMP_dictMethod
get_JuMP_dict(model::Model)
get_JuMP_dict(model::Dict)

Get the dictionary of the model results. If the model is a JuMP.Model, it returns the object dictionary.

source
EnergyModelsGUI.get_all_periods!Method
get_all_periods!(vec::Vector, ts::TwoLevel)
get_all_periods!(vec::Vector, ts::RepresentativePeriods)
get_all_periods!(vec::Vector, ts::OperationalScenarios)
get_all_periods!(vec::Vector, ts::Any)

Get all TimeStructures in ts and append them to vec.

source
EnergyModelsGUI.get_capexMethod
get_capex(data::ProcInvData)
get_capex(design::AbstractGUIObj)

Returns the capex of the investments of a ProcInvData/AbstractGUIObj object data.

source
EnergyModelsGUI.get_changeMethod
get_change(::GUI, ::Val)

Handle different keyboard inputs (events) and return changes in x, y coordinates in the design object gui.

source
EnergyModelsGUI.get_combinationsMethod
get_combinations(var::SparseVars, i_T::Int)
get_combinations(var::JuMP.Containers.DenseAxisArray, i_T::Int)
get_combinations(var::DataFrame, ::Int)

Get an iterator of combinations of unique indices excluding the time index located at index i_T.

source
EnergyModelsGUI.get_componentMethod
get_component(designs::Vector{EnergySystemDesign}, id)
get_component(designs::EnergySystemDesign, id)

Extract the component from a vector of EnergySystemDesign(s) that has a parent with the given id.

source
EnergyModelsGUI.get_dataMethod
get_data(
    model::Union{JuMP.Model, Dict},
    selection::PlotContainer,
    T::TS.TimeStructure,
    sp::Int64,
    rp::Int64,
    sc::Int64,
)

Get the values from the JuMP model, or the input data, at selection for all periods in T restricted to strategic period sp, representative period rp, and scenario sc.

source
EnergyModelsGUI.get_elementMethod
get_element(design::EnergySystemDesign)

Returns the system node (i.e., availability node for areas) of a EnergySystemDesign design.

source
EnergyModelsGUI.get_element_labelMethod
get_element_label(element)

Get the label of the element based on its id field. If the id is a number it returns the built in Base.display() functionality of node, otherwise, the id field is converted to a string.

source
EnergyModelsGUI.get_inv_timesMethod
get_inv_times(data::ProcInvData)
get_inv_times(design::AbstractGUIObj)

Returns the inv_times field of a ProcInvData/AbstractGUIObj object data.

source
EnergyModelsGUI.get_investment_timesMethod
get_investment_times(gui::GUI, max_inst::Float64)

Calculate when investments has taken place and store the information. An investement is assumed to have taken place if any investment_indicators are larger than getvar(gui,:tol) relative to `maxinst`.

source
EnergyModelsGUI.get_jump_axis_typesMethod
get_jump_axis_types(data::JuMP.Containers.DenseAxisArray)
get_jump_axis_types(data::SparseVars)
get_jump_axis_types(data::DataFrame)

Get the types for each axis in the data.

source
EnergyModelsGUI.get_periodsMethod
get_periods(T::TS.TimeStructure, type::Type, sp::Int64, rp::Int64, sc::Int64)

Get the periods for a given TimePeriod/TimeProfile type (e.g., TS.StrategicPeriod, TS.RepresentativePeriod, TS.OperationalPeriod) restricted to the strategic period sp, representative period rp and the scenario sc.

source
EnergyModelsGUI.get_resource_colorsMethod
get_resource_colors(l::Vector{Link}, id_to_color_map::Dict{Any,Any})

Get the colors linked to the resources in the link l based on the mapping id_to_color_map.

source
EnergyModelsGUI.get_resource_colorsMethod
get_resource_colors(resources::Vector{Resource}, id_to_color_map::Dict{Any,Any})

Get the colors linked the the resources in resources based on the mapping id_to_color_map.

source
EnergyModelsGUI.get_scenario_indicesMethod
get_scenario_indices(T::TS.TimeStructure, sp::Int64, rp::Int64)

Return indices of the scenarios in the time structure T for strategic period number sp and representative period rp.

source
EnergyModelsGUI.get_sector_pointsMethod
get_sector_points(;
    center::Point2f = Point2f(0.0f0, 0.0f0),
    Δ::Float32 = 1.0f0,
    θ₁::Float32 = 0.0f0,
    θ₂::Float32 = Float32(π / 4),
    steps::Int=200,
    geometry::Symbol = :circle)

Get points for the boundary of a sector defined by the center c, radius/halfsidelength Δ, and angles θ₁ and θ₂ for a square (geometry = :rect), a circle (geometry = :circle), or a triangle (geometry = :triangle).

source
EnergyModelsGUI.get_supertypesMethod
get_supertypes(input) -> Dict{Symbol, Vector{Type}}

Retrieves the supertypes of all defined types from modules or packages.

Method Overloads

  • get_supertypes(modul::Module): Returns a dictionary mapping type names to their supertypes from the given module.

  • get_supertypes(moduls::Vector{Module}): Merges and returns supertypes from multiple modules.

  • get_supertypes(pkg::Union{String, Symbol}): Converts the package name to a module (via Main) and returns its type supertypes.

  • get_supertypes(pkgs::Union{Vector{<:Union{String, Symbol}}, Set{<:Union{String, Symbol}}}): Merges and returns supertypes from multiple packages via their names.

Arguments

  • input: Can be a single module, a vector of modules, a single package name (as String or Symbol), or a collection of package names.

Returns

  • Dict{Symbol, Vector{Type}}: A dictionary where each key is a type name and the value is a vector of its supertypes.

Description

This set of functions helps extract the inheritance hierarchy of types defined in Julia modules or packages. It filters out non-type bindings and collects supertypes using supertypes.

source
EnergyModelsGUI.get_time_axisMethod
get_time_axis(
    data::Union{
        JuMP.Containers.DenseAxisArray,
        JuMP.Containers.SparseAxisArray,
        SparseVariables.IndexedVarArray,
    },
)

Get the index of the axis/column of data (i.e.,from a JuMP variable) corresponding to TS.TimePeriod and return this index (i_T) alongside its TimeStruct type.

source
EnergyModelsGUI.get_total_sum_timeMethod
get_total_sum_time(data::JuMP.Containers.DenseAxisArray, ::Vector{<:TS.TimeStructure})
get_total_sum_time(data::DataFrame, periods::Vector{<:TS.TimeStructure})

Get the total sum of the data for each time period in data.

source
EnergyModelsGUI.get_typesMethod
get_types(input) -> Vector{Symbol}

Retrieves the names of all defined types from modules or packages.

Method Overloads

  • get_types(modul::Module): Returns a vector of type names defined in the given module.

  • get_types(moduls::Vector{Module}): Returns a combined vector of type names from multiple modules.

  • get_types(pkg::Union{String, Symbol}): Converts the package name to a module (via Main) and returns its defined types.

  • get_types(pkgs::Union{Vector{<:Union{String, Symbol}}, Set{<:Union{String, Symbol}}}): Returns a combined vector of type names from multiple packages.

Arguments

  • input: Can be a single module, a vector of modules, a single package name (as String or Symbol), or a collection of package names.

Returns

  • Vector{Symbol}: A list of names corresponding to types defined in the given module(s) or package(s).

Description

This set of functions helps extract type definitions from Julia modules or packages. It filters out non-type bindings and collects only those that are instances of DataType.

Example

get_types(Base)  # returns type names defined in Base

get_types(["Base", "Core"])  # returns type names from both packages
source
EnergyModelsGUI.get_types_structureMethod
get_types_structure(emx_supertypes_dict::Dict{Any, Vector{Type}}) -> Dict{Type, Union{Dict, Nothing}}

Constructs a nested dictionary representing type dependencies from a dictionary of supertypes.

Arguments

  • emx_supertypes_dict::Dict{Any, Vector{Type}}: A dictionary where each key corresponds to a type identifier, and the value is a vector of supertypes ordered from the most general to the most specific.

Returns

  • Dict{Type, Union{Dict, Nothing}}: A nested dictionary structure where each type is a key pointing to its subtype hierarchy. Leaf nodes point to nothing.

Description

This function builds a tree-like structure of type dependencies by iterating through each type's supertypes and nesting them accordingly. It uses the helper function update_tree! to insert types into the correct level of the hierarchy. ```

source
EnergyModelsGUI.get_valuesMethod
get_values(vals::SparseVars)
get_values(vals::JuMP.Containers.DenseAxisArray)
get_values(vals::DataFrame)
get_values(vals::JuMP.Containers.SparseAxisArray, ts::Vector)
get_values(vals::SparseVariables.IndexedVarArray, ts::Vector)
get_values(vals::JuMP.Containers.DenseAxisArray, ts::Vector)
get_values(vals::DataFrame, ts::Vector)

Get the values of the variables in vals. If a vector of time periods ts is provided, it returns the values for the times in ts.

source
EnergyModelsGUI.getfirstMethod
getfirst(f::Function, a::Vector)

Return the first element of Vector a satisfying the requirement of Function f.

source
EnergyModelsGUI.has_fieldsMethod
has_fields(type::Type) -> Bool

Checks whether a given type is a concrete struct with at least one field.

Arguments

  • type::Type: The type to be inspected.

Returns

  • Bool: Returns true if the type is a concrete struct and has one or more fields; otherwise, returns false.

Description

This function combines three checks:

  • isstructtype(type): Ensures the type is a struct.
  • nfields(type) > 0: Ensures the struct has at least one field.

Example

struct MyStruct
    x::Int
end

has_fields(MyStruct)  # returns true

abstract type AbstractType end
has_fields(AbstractType)  # returns false
source
EnergyModelsGUI.inherit_descriptive_names_from_supertypes!Method
inherit_descriptive_names_from_supertypes!(descriptive_names, emx_supertypes_dict)

Copies descriptive field names from supertypes to subtypes in the descriptive_names dictionary.

Arguments

  • descriptive_names::Dict: A dictionary containing descriptive names for structure fields,

organized by type.

  • emx_supertypes_dict::Dict: A dictionary mapping type identifiers to arrays of types,

where the first element is the type itself and the remaining elements are its supertypes.

Description

For each type in emx_supertypes_dict, this function checks if the type has fields. For each field, it looks for descriptive names in the supertypes. If a descriptive name exists for a field in a supertype but not in the subtype, it copies the descriptive name from the supertype to the subtype.

Modifies

  • Updates descriptive_names in-place by inheriting missing descriptive names from supertypes.
source
EnergyModelsGUI.initialize_plot!Method
initialize_plot!(gui::GUI, design::EnergySystemDesign)

Initialize the plot of the topology of design object gui given an EnergySystemDesign design.

source
EnergyModelsGUI.new_global_delta_hMethod
new_global_delta_h(gui::GUI)

Recalculate the sizes of the boxes in get_axes(gui)[:topo] such that their size is independent of zooming an resizing the window.

source
EnergyModelsGUI.pick_component!Method
pick_component!(gui::GUI, ax_type::Symbol)
pick_component!(gui::GUI, plt::AbstractPlot, ax_type::Symbol)
pick_component!(gui::GUI, element::AbstractGUIObj, ::Symbol)
pick_component!(gui::GUI, element::Dict, ::Symbol)
pick_component!(gui::GUI, ::Nothing, ax_type::Symbol)

Check if a system is found under the mouse pointer and if it is an AbstractGUIObj (for objects in the topology axis) or a Dict (for objects in the results axis). If found, state variables are updated. Results in the topology axis are only cleared if ax_type = :topo and in the results axis if ax_type = :results.

source
EnergyModelsGUI.place_nodes_in_circleMethod
place_nodes_in_circle(total_nodes::Int64, current_node::Int64, r::Float32, xₒ::Float32, yₒ::Float32)

Return coordinate for point number i of a total of n points evenly distributed around a circle of radius r centered at (xₒ, yₒ) from -π/4 to 5π/4.

source
EnergyModelsGUI.plot_design!Method
plot_design!(
    gui::GUI, design::EnergySystemDesign; visible::Bool=true, expand_all::Bool=true
)

Plot the topology of get_design(gui) (only if not already available), and toggle visibility based on the optional argument visible.

source
EnergyModelsGUI.print_nested_structure!Method
print_nested_structure!(
    element,
    output::Observable;
    indent::Int64=0,
    vector_limit::Int64=typemax(Int64),
)

Appends the nested structure of element in a nice format to the output[] string. The parameter vector_limit is used to truncate large vectors.

source
EnergyModelsGUI.save_designMethod
save_design(design::EnergySystemDesign, file::String)

Save the x,y-coordinates of design_dict to a .yml file at location and filename given by file.

source
EnergyModelsGUI.save_designMethod
save_design(design::EnergySystemDesign)

Save the x,y-coordinates of EnergySystemDesign design to a .yml file specifield in the field file of design.

source
EnergyModelsGUI.square_intersectionMethod
square_intersection(c::Point2f, θ::Float32, Δ::Float32)

Calculate the intersection point between a line starting at c and direction described by θ and a square with half side lengths Δ centered at center c.

source
EnergyModelsGUI.square_intersectionMethod
square_intersection(c::Point2f, x::Point2f, θ::Float32, Δ::Float32)

Calculate the intersection point between a line starting at x and direction described by θ, and a square with half side lengths Δ centered at center c. If the line does not intersect the square, the extension of the two facing sides to x will be used instead.

source
EnergyModelsGUI.sub_systemMethod
sub_system(system::SystemGeo, element::AbstractElement)

Create a sub-system of system with the element as the reference node.

source
EnergyModelsGUI.toggle_selection_color!Method
toggle_selection_color!(gui::GUI, selection::EnergySystemDesign, selected::Bool)
toggle_selection_color!(gui::GUI, selection::Connection, selected::Bool)
toggle_selection_color!(gui::GUI, selection::Dict{Symbol,Any}, selected::Bool)

Set the color of selection to get_selection_color(gui) if selected, and its original color otherwise using the argument selected.

source
EnergyModelsGUI.transfer_modelMethod
transfer_model(model::Model, system::AbstractSystem)
transfer_model(model::String, system::AbstractSystem)

Convert the model to a DataFrame if it is provided as a path to a directory.

source
EnergyModelsGUI.update!Method
update!(gui::GUI, element; updateplot::Bool=true)

Based on element, update the text in get_axes(gui)[:info] and update plot in get_axes(gui)[:results] if updateplot = true.

source
EnergyModelsGUI.update!Method
update!(gui::GUI, connection::Connection; updateplot::Bool=true)

Based on Connection, update the text in get_axes(gui)[:info] and update plot in get_axes(gui)[:results] if updateplot = true.

source
EnergyModelsGUI.update!Method
update!(gui::GUI, design::EnergySystemDesign; updateplot::Bool=true)

Based on design, update the text in get_axes(gui)[:info] and update plot in get_axes(gui)[:results] if updateplot = true.

source
EnergyModelsGUI.update_descriptive_names!Method
update_descriptive_names!(gui::GUI)

Update the dictionary of descriptive_names where the Dict is appended/overwritten in the following order:

  • The default descriptive names found in src/descriptive_names.yml.
  • Any descriptive_names.yml file found in the ext/EMGUIExt folder of any other EMX package.
  • Descriptive names from a user defined file (from the GUI input argument path_to_descriptive_names).
  • Descriptive names from a user defined Dict (from the GUI input argument descriptive_names_dict).
source
EnergyModelsGUI.update_distances!Method
update_distances!(gui::GUI)

Find the minimum distance between the elements in the design object gui and update Δh such that neighbouring icons do not overlap.

source
EnergyModelsGUI.update_tree!Method
update_tree!(current_lvl::Dict{Type, Union{Dict, Nothing}}, tmp_type::Type) -> Nothing

Ensures that a given type exists as a key in the current level of a nested type dependency dictionary.

Arguments

  • current_lvl::Dict{Type, Union{Dict, Nothing}}: The current level of the nested dictionary structure representing type dependencies.
  • tmp_type::Type: The type to be added as a key in the current level if it does not already exist.

Behavior

If tmp_type is not already a key in current_lvl, it adds it with an empty dictionary as its value, preparing for further nesting.

Returns

  • Nothing: This function modifies current_lvl in-place and does not return a value.
source