Loading pyehub/outputter.py +2 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import collections from collections import OrderedDict from typing import Union import yaml import copy import pandas as pd import matplotlib.pyplot as plt from openpyxl import load_workbook Loading Loading @@ -203,7 +202,7 @@ def pretty_print(results: dict) -> None: print(f"\ttime: {solver['time']}") print("Solution") print_section('Stuff', results['solution']) print_section('Stuff', results['solution'].copy()) def print_section(section_name: str, solution_section: dict) -> None: Loading Loading @@ -380,7 +379,7 @@ def plot_storages(results: dict, to_plot: dict = None, size: tuple = (10, 5)) -> 'pl_decay': boolean value; whether to plot 'decay loss' or not size: tuple defining (width, height) of the plot. """ solution_section = copy.deepcopy(results['solution']) solution_section = results['solution'].copy() attributes = to_dataframes(solution_section) if to_plot is None: to_plot = {'pl_state': True, 'pl_gross_ch': True, 'pl_gross_dch': True, Loading pyehub/plots.py +8 −5 Original line number Diff line number Diff line from pyehub.outputter import plot_storages import pickle import copy import pandas as pd import matplotlib.pyplot as plt from pyehub.energy_hub.ehub_model import EHubModel from pyehub.outputter import pretty_print # import seaborn as sns # sns.set() def plot_energy_balance(model, results: dict, size: tuple = (8, 5), lw: float = 3, dl: float = 3 ) -> None: attributes = copy.deepcopy(results['solution']) attributes = results['solution'].copy() streams_wo_sources = [x for x in model.streams if x not in model.sources] for stream in streams_wo_sources: Loading Loading @@ -105,7 +105,7 @@ def plot_energy_balance(model, results: dict, size: tuple = (8, 5), lw: float = ds = (dl, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) # plt.plot(data, label=label, axes=ax, linewidth=lw, marker=mk, dashes=ds) plt.plot(data, label=label, axes=ax, linewidth=lw, dashes=ds) plt.legend(loc='best') plt.legend(loc='best',ncol=2) ax.set(title=stream, xticks=model.time, xlabel='Timesteps (-)', ylabel=stream+' (kWh)') plt.show() Loading @@ -128,9 +128,12 @@ def main(): model = EHubModel(excel=input_file) model1 =EHubModel(excel=input_file) results = model.solve() plot_storages(results) results1=model1.solve() # print(results['solution'] == results1['solution']) # plot_storages(results) plot_energy_balance(model1, results) # pretty_print(results) # print(results['solution'] == results1['solution']) if __name__ == '__main__': main() Loading Loading
pyehub/outputter.py +2 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import collections from collections import OrderedDict from typing import Union import yaml import copy import pandas as pd import matplotlib.pyplot as plt from openpyxl import load_workbook Loading Loading @@ -203,7 +202,7 @@ def pretty_print(results: dict) -> None: print(f"\ttime: {solver['time']}") print("Solution") print_section('Stuff', results['solution']) print_section('Stuff', results['solution'].copy()) def print_section(section_name: str, solution_section: dict) -> None: Loading Loading @@ -380,7 +379,7 @@ def plot_storages(results: dict, to_plot: dict = None, size: tuple = (10, 5)) -> 'pl_decay': boolean value; whether to plot 'decay loss' or not size: tuple defining (width, height) of the plot. """ solution_section = copy.deepcopy(results['solution']) solution_section = results['solution'].copy() attributes = to_dataframes(solution_section) if to_plot is None: to_plot = {'pl_state': True, 'pl_gross_ch': True, 'pl_gross_dch': True, Loading
pyehub/plots.py +8 −5 Original line number Diff line number Diff line from pyehub.outputter import plot_storages import pickle import copy import pandas as pd import matplotlib.pyplot as plt from pyehub.energy_hub.ehub_model import EHubModel from pyehub.outputter import pretty_print # import seaborn as sns # sns.set() def plot_energy_balance(model, results: dict, size: tuple = (8, 5), lw: float = 3, dl: float = 3 ) -> None: attributes = copy.deepcopy(results['solution']) attributes = results['solution'].copy() streams_wo_sources = [x for x in model.streams if x not in model.sources] for stream in streams_wo_sources: Loading Loading @@ -105,7 +105,7 @@ def plot_energy_balance(model, results: dict, size: tuple = (8, 5), lw: float = ds = (dl, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) # plt.plot(data, label=label, axes=ax, linewidth=lw, marker=mk, dashes=ds) plt.plot(data, label=label, axes=ax, linewidth=lw, dashes=ds) plt.legend(loc='best') plt.legend(loc='best',ncol=2) ax.set(title=stream, xticks=model.time, xlabel='Timesteps (-)', ylabel=stream+' (kWh)') plt.show() Loading @@ -128,9 +128,12 @@ def main(): model = EHubModel(excel=input_file) model1 =EHubModel(excel=input_file) results = model.solve() plot_storages(results) results1=model1.solve() # print(results['solution'] == results1['solution']) # plot_storages(results) plot_energy_balance(model1, results) # pretty_print(results) # print(results['solution'] == results1['solution']) if __name__ == '__main__': main() Loading