Plots
The graphs that build the conceptual basis for the modelling approach pursued by AnyMOD can be plotted. All plots are created with plotly which is accessed from Julia using PyCall.
Node trees
The plotTree
function is used to plot the hierarchical trees of sets as introduced in Sets and Mappings.
plotTree(tree_sym::Symbol, model_object::anyModel)
The input tree_sym
indicates which set should be plotted (:region
,:timestep
,:carrier
, or :technology
). As an example, the tree for :carrier
from the demo problem is plotted below.
Optional arguments include:
argument | explanation | default |
plotSize |
|
(8.0,4.5) |
fontSize |
|
12 |
useColor |
|
true |
wide |
|
fill(1.0,30) |
Energy flow
The plotEnergyFlow
function provides two ways to visualize the flow of energy within a model: Either as a qualitative node graph or as a quantitative Sankey diagram.
Node graph
To plot a qualitative node graph use the plotEnergyFlow
command with the :graph
argument.
plotEnergyFlow(:graph, model_object::anyModel)
Nodes either correspond to technologies (grey dots) or energy carriers (colored squares). Edges between technology and energy carrier nodes indicate the carrier is either an input (entering edge) or an output (leaving edge) of the respective technology. Edges between carriers result from inheritance relationships between carriers. These are included, because, according to AnyMOD's graph-based approach, descendants can satisfy the demand for an ancestral carrier (see Göke (2020) for details).
The layout of the graph is created using a force-directed drawing algorithm originally implemented in GraphLayout.jl.
In many cases the resulting layout will be sufficient to get an overview of energy flows for debugging, but inadequate for publication. For this reason, the moveNode!
function can be used to adjust the layout.
moveNode!(model_object::anyModel, newPos_arr::Array{Tuple{String,Array{Float64,1}},1})
moveNode!
requires an initial layout within that specific nodes are moved. In the example below, an initial layout is created by calling plotEnergyFlow
. Afterwards, the node for 'ocgt' is moved 0.2 units to the right and 0.1 units up. The node for 'coal' is moved accordingly. Afterwards, the graph is plotted again with the new layout.
plotEnergyFlow(:graph, model_object)
moveNode!(model_object, [("ocgt",[0.2,0.1]),("coal",[0.15,0.0])])
plotEnergyFlow(:graph, model_object, replot = false)
When plotting again, it is important to set the optional replot
argument to false
. Otherwise, the original layout algorithm will be run again and overwrite any changes made manually.
Optional arguments for plotting the qualitative node graph are listed below:
argument | explanation | default |
plotSize |
|
(16.0,9.0) |
fontSize |
|
12 |
useTeColor |
|
false |
replot |
|
true |
scaDist |
|
0.5 |
maxIter |
5000 |
|
initTemp |
2.0 |
Sankey diagram
To plot the qualitative energy flows for a solved model use plotEnergyFlow
command with the :sankey
argument:
plotEnergyFlow(:sankey, model_object::anyModel)
The command will create an entire html application including a dropdown menu and drag-and-drop capabilities. Below is a screenshot of one graph from the solved demo problem.
Optional arguments for plotting a Sankey diagram are:
argument | explanation | default |
plotSize |
|
(16.0,9.0) |
minVal |
|
0.1 |
filterFunc |
|
x -> true |
dropDown |
|
(:region,:timestep) |
rmvNode |
|
tuple() |
useTeColor |
|
true |
Styling
The colors and labels of nodes within plots can be adjusted using the graInfo
field of the model object.
The sub-field graInfo.names
provides a dictionary that maps node names as specified in the input files to node labels used for plotting. By default, some names occurring in the demo problem are already assigned labels within the dictionary.
Analogously, graInfo.colors
assigns colors used for plotting to nodes. Both the actual node name or an assigned label can serve as a key. The assigned value is a tuple of three numbers between 0 and 1 corresponding to a RGB color code.