Update HEMS.py code

This commit is contained in:
Sadam93 2024-05-31 10:58:57 -04:00
parent 504cd67cba
commit abd1f96a2d

121
HEMS.py
View File

@ -16,16 +16,16 @@ from pyomo.core import value, RangeSet
# data = pd.ExcelFile('input_new_cluster.xlsx') #it will read the excel one time you do not need to read again and gain # data = pd.ExcelFile('input_new_cluster.xlsx') #it will read the excel one time you do not need to read again and gain
# Parse the different tab # Parse the different tab
sheet_data = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='data') sheet_data = pd.read_excel("input_new_cluster.xlsx", sheet_name='data')
sheet_EV = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='EV') sheet_EV = pd.read_excel("input_new_cluster.xlsx", sheet_name='EV')
sheet_EWH = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='EWH') sheet_EWH = pd.read_excel("input_new_cluster.xlsx", sheet_name='EWH')
sheet_wateruse = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='Water_Use') sheet_wateruse = pd.read_excel("input_new_cluster.xlsx", sheet_name='Water_Use')
sheet_watertemp = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='Water_Temp') sheet_watertemp = pd.read_excel("input_new_cluster.xlsx", sheet_name='Water_Temp')
sheet_home = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='Home') sheet_home = pd.read_excel("input_new_cluster.xlsx", sheet_name='Home')
sheet_ESS = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='ESS') sheet_ESS = pd.read_excel("input_new_cluster.xlsx", sheet_name='ESS')
sheet_PV = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='PV') sheet_PV = pd.read_excel("input_new_cluster.xlsx", sheet_name='PV')
sheet_ambient = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='Ambient_Temp') sheet_ambient = pd.read_excel("input_new_cluster.xlsx", sheet_name='Ambient_Temp')
sheet_load = pd.read_excel("input_new_cluster_trying.xlsx", sheet_name='Base_Load') sheet_load = pd.read_excel("input_new_cluster.xlsx", sheet_name='Base_Load')
# </editor-fold> # </editor-fold>
# </editor-fold> # </editor-fold>
@ -860,59 +860,60 @@ for i in model.Sell_price:
# plt.show() # plt.show()
# code for if you want to plot all the home togathoer # code for if you want to plot all the home togathoer
fig, ax = plt.subplots(8, len(model.h), figsize=(10,10)) # fig, ax = plt.subplots(6, len(model.h), figsize=(10,10))
for k in range(len(model.h)): # for k in range(len(model.h)):
ax[0, k].plot(time, pbuy[k], label='Buying power') # ax[0, k].plot(time, pbuy[k], label='Buying power')
ax[0, k].plot(time, psell[k], label='Selling power') # ax[0, k].plot(time, psell[k], label='Selling power')
ax[0, k].plot(time, baseload[k], label='Base load') # # ax[0, k].plot(time, baseload[k], label='Base load')
ax[0, k].legend(loc='best') # ax[0, 0].legend(loc='best')
ax[1, k].plot(time, Buyprice, label='Buyprice') # ax[1, k].plot(time, Buyprice, label='Buyprice')
ax[1, k].legend(loc='best') # ax[1, 0].legend(loc='best')
ax[1, k].plot(time, Sellprice, label='Sellprice') # ax[1, k].plot(time, Sellprice, label='Sellprice')
ax[1, k].legend(loc='best') # ax[1, 0].legend(loc='best')
ax[2, k].plot(time, PEWH[k], label='EWH Power') # ax[2, k].plot(time, PEWH[k], label='EWH Power')
ax[2, k].plot(time, tettaEWHwat[k], label='EWH Temp') # ax[2, k].plot(time, tettaEWHwat[k], label='EWH Temp')
ax[2, k].legend(loc='best') # ax[2, 0].legend(loc='best')
ax[3, k].plot(time, PESSCharge[k],label='ESS Charging power') # ax[3, k].plot(time, PESSCharge[k],label='ESS Charging power')
ax[3, k].plot(time, PESSDischHome[k], label='ESS Disch to home') # ax[3, k].plot(time, PESSDischHome[k], label='ESS Disch to home')
ax[3, k].plot(time, PESSDischGrid[k], label='ESS Disch to grid') # ax[3, k].plot(time, PESSDischGrid[k], label='ESS Disch to grid')
ax[3, k].legend(loc='best') # ax[3, 0].legend(loc='best')
ax[4, k].plot(time, PVHome[k], label='PV to Home') # ax[4, k].plot(time, PVHome[k], label='PV to Home')
ax[4, k].plot(time, PVGrid[k], label='PV to Grid') # ax[4, k].plot(time, PVGrid[k], label='PV to Grid')
ax[4, k].plot(time, PPV[k], label='All PV Production') # ax[4, k].plot(time, PPV[k], label='All PV Production')
ax[4, k].legend(loc='best') # ax[4, 0].legend(loc='best')
ax[5, k].plot(time, PEVCharge[k], label='EV Charging power') # ax[5, k].plot(time, PEVCharge[k], label='EV Charging power')
ax[5, k].plot(time, PEVDischHome[k], label='EV Disch to home') # ax[5, k].plot(time, PEVDischHome[k], label='EV Disch to home')
ax[5, k].plot(time, PEVDischGrid[k], label='EV Disch to grid') # ax[5, k].plot(time, PEVDischGrid[k], label='EV Disch to grid')
ax[5, k].legend(loc='best') # ax[5, 0].legend(loc='best')
ax[6, k].plot(time, EnergyESS[k], label='Energy of ESS') # # ax[6, k].plot(time, EnergyESS[k], label='Energy of ESS')
ax[6, k].legend(loc='best') # # ax[6, k].legend(loc='best')
ax[7, k].plot(time, EnergyEV[k], label='Energy of EV') # # ax[7, k].plot(time, EnergyEV[k], label='Energy of EV')
ax[7, k].legend(loc='best') # # ax[7, 0].legend(loc='best')
ax[4, k].set_xlabel('Time (step)') # ax[4, 5].set_xlabel('Time (step)')
ax[1, k].set_ylabel('Electricity price ($/W/h)') # ax[1, 0].set_ylabel('Electricity price ($/W/h)')
ax[0, k].set_ylabel('Power (kW)') # ax[0, 0].set_ylabel('Power (kW)')
ax[2, k].set_ylabel('Power (kW)') # ax[2,0].set_ylabel('Power (kW)')
ax[0, k].set_title(f"Home {k+1}") # ax[0, k].set_title(f"Home {k+1}")
#
pl.tight_layout() # # pl.tight_layout()
#
plt.show() # plt.show()
# if you want to plot each home alone in the figure # if you want to plot each home alone in the figure
# for k in range(len(model.h)): bar_width =0.4
# fig, ax = plt.subplots(2) time1 = np.array(time)
# ax[0].plot(time, pbuy[k], 'b-', label='Base') for k in range(len(model.h)):
# ax[0].plot(time, psell[k], 'g--', label='Controllable Load') fig, ax = plt.subplots(2,constrained_layout=True, )
# ax[1].plot(time, Buyprice, label='buying price') ax[0].bar(time1 - bar_width/2 , pbuy[k], width=bar_width, label='Base')
# ax[1].plot(time, Sellprice, 'y-+', label='selling price') ax[0].bar(time1 + bar_width/2 , psell[k], width=bar_width, label='Controllable Load')
# ax[1].legend(loc='upper left') ax[1].plot(time, Buyprice, label='buying price')
# ax[1].set_xlabel('Time (hour)') ax[1].plot(time, Sellprice, 'y-+', label='selling price')
# ax[1].set_ylabel('Electricity price ($/W/h)') ax[1].legend(loc='upper left')
# plt.suptitle(f"Home {k+1}") ax[1].set_xlabel('Time (hour)')
# pl.tight_layout() ax[1].set_ylabel('Electricity price ($/W/h)')
# plt.show() plt.suptitle(f"Home {k+1}")
plt.show()
# print('this is the end of code') # print('this is the end of code')