Energy Balance AnalysisΒΆ
This notebook outlines the steps needed to visualize the energy balance for all the streams in the model. We can use this to analyse the energy flow to/from all the streams over the time span of the optimization. These plots tell us how the LOADs are met, how much energy is being imported/exported, etc.
[ ]:
from pyehub.energy_hub.ehub_model import EHubModel
from pyehub.outputter import plot_energy_balance
First we load and run a model.
[ ]:
excel_file = (
"test_file.xlsx" # name of the excel file. [This must be in the current directory]
)
my_model = EHubModel(
excel=excel_file
) # instantiate our model. Nothing is solved at this point.
results = my_model.solve() # solve the model and get back our results
- The function
plot_energy_balance(...)plots, for every stream, its energy interactions with respective converters, storages, etc. - Every positive (negative) energy transfer line plot is overlayed over the previous positive (negative) line plot.
- Therefore, the actual amount of energy involved in
ith plot is the difference between theith andi-1th plot. - Due to overlay, the topmost and bottommost plots for all the streams are mirror images of each other about x-axis. This verifies that energy is balanced for each stream.
- The order in which the line plots are plotted is the order in which they appear in the legend of the figure.
- Pass
my_modelandresultsto this plot function to yield the energy balance plots.
[ ]:
plot_energy_balance(my_model, results)
plot_energy_balance(...) function gives you various options to control properties of the plot (see the docstring [TODO: Add a link to docstring after updating readthedocs.]) + You can specify the size of the plot by passing size tuple [default value is (9,5)]. + To change linewidth of the plots, use the lw parameter [default value is 2]. + To change the length of dashes constituting the line plot, use dl parameter [default value is 3].
[ ]:
plot_energy_balance(my_model, results, size=(12, 6), lw=3, dl=5)
[ ]: