Analyze parallel simulation results
Now that we have successfully finished running our parallel simulations, it’s time to look at the results. The writeESOL function used in our code has exported a Results.xlsx file to each network folder. The file contains detailed information on the simulation results at the network level. You can use this file to analyze further and make decisions based on the results.
1. Create summary of the results
Additionally, to get a summary of the parallel simulation results in a tabular form, you can run the code given in Python code to obtain a ResultsSummary.xlsx file in the main Parallel folder.
To begin, open your preferred Python IDE and create a new Python script called results.py. Place the Python script into the main Parallel folder. Close and re-open your Python script from the new location to avoid directory problems. Next, copy the code below to your Python script and execute.
Python code
# Import packages
from ctypes import *
import os
import glob
import pandas as pd
# Path to the SAInt-API.dll file
path = "C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll"
# Create a SAInt API DLL object
saint_dll = cdll.LoadLibrary(path)
saint_dll.evalStr.restype=c_wchar_p
# Source directory
def get_source_directory():
return os.path.dirname(os.path.abspath(__file__))
source_dir = get_source_directory()
# Main folder
main_dir = source_dir + "\\Networks\\"
# Number of networks
networks = os.listdir(main_dir)
# Results dictionary
results = {'Solar Capacity [MW]': [], 'Wind Capacity [MW]': [],
'Unserved Demand [MW]': [], 'Fossil Generation [%]': [],
'Hydro Generation [%]': [], 'Co Generation [%]': [],
'Renewable Generation [%]': [], 'Renewable Curtailment [MW]': [],
'CO2 Emissions [tonnes]': [], 'Fuel Cost [$]': [],
'Production cost [$]': [],
}
def NetworkResults(results):
# Wind Capacity
wind_cap= float(saint_dll.evalStr("WIND.WINDFARM.PMAX.[MW]"))
# Solar Capacity
solar_cap = float(saint_dll.evalStr("PV.SOLARPARK.PMAX.[MW]"))
# PV Generation
pv_gen = float(saint_dll.evalStr("esum('ENET.PPV.(%).[MW]')"))
# WIND Generation
wind_gen = float(saint_dll.evalStr("esum('ENET.PWIND.(%).[MW]')"))
# Fossil Generation
fossil_gen = float(saint_dll.evalStr("esum('ENET.PFGEN.(%).[MW]')"))
# Co Generation
co_gen = float(saint_dll.evalStr("esum('ENET.PXGEN.(%).[MW]')"))
# Hydro Generation
hydro_gen = float(saint_dll.evalStr("esum('ENET.PHGEN.(%).[MW]')"))
# Total Generation
total_gen = float(saint_dll.evalStr("esum('ENET.PG.(%).[MW]')"))
# Unserved Demand
pns = float(saint_dll.evalStr("esum('ENET.PNSDEM.(%).[MW]')"))
# Total Fuel Cost
fuel_cost = float(saint_dll.evalStr("esum('ENET.FuelCostRate.(%).[$/h]')"))
# Total Production Cost
total_cost = float(saint_dll.evalStr("esum('ENET.TOTCOSTRATE.(%).[$/h]')"))
# Total Emissions
emissions = float(saint_dll.evalStr("esum('ENET.CO2RATE.(%).[t/h]')"))
# PV curtailment
pv_pns = float(saint_dll.evalStr("esum('ENET.PNSPV.(%).[MW]')"))
# Wind curtailment
wind_pns = float(saint_dll.evalStr("esum('ENET.PNSWIND.(%).[MW]')"))
# Append results
results['Wind Capacity [MW]'].append(wind_cap)
results['Solar Capacity [MW]'].append(solar_cap)
results['Renewable Generation [%]'].append(round(((pv_gen+wind_gen)/total_gen)*100,3))
results['Fossil Generation [%]'].append(round((fossil_gen/total_gen)*100,3))
results['Hydro Generation [%]'].append(round((hydro_gen/total_gen)*100,3))
results['Co Generation [%]'].append(round((co_gen/total_gen)*100,3))
results['Unserved Demand [MW]'].append(pns)
results['Fuel Cost [$]'].append(round(fuel_cost,2))
results['Production cost [$]'].append(round(total_cost,2))
results['CO2 Emissions [tonnes]'].append(round(emissions,2) )
results['Renewable Curtailment [MW]'].append(round(pv_pns + wind_pns,2))
for n in range(len(networks)):
net_dir = main_dir + networks[n] + "\\"
saint_dll.openENET(net_dir + "ENET09_12.enet")
scenario = glob.glob1(net_dir, "*.esce")[0]
saint_dll.openESCE(net_dir + scenario)
sol_file = glob.glob1(net_dir, "*.esol")[0]
saint_dll.openESOL(net_dir + sol_file)
NetworkResults(results)
# Make dataframe of results
df = pd.DataFrame.from_dict(results).T
df = df.rename_axis("Results")
x = 0
for col in df.columns:
df = df.rename(columns={col:networks[x]})
x += 1
df.to_excel(source_dir + "\\ResultsSummary.xlsx")