Evaluate results using SAInt API
SAInt offers the ability to directly evaluate scenario results using various evaluation functions. These functions are used to analyze and aggregate object input properties and output results to understand the behavior of an object within a given time step or scenario time window. The objective of this tutorial is to learn how to use some of the basic evaluation functions with SAInt API. All the evaluation functions are listed here with their syntax, description, and output examples.
|
The network, scenario and import files used in this tutorial can be found in the folder |
1. esum
Let’s get started by opening your preferred Python IDE and creating a new Python script. For this tutorial, we will use the network and scenario files from the "Basic functions of SAInt API" tutorial to evaluate some useful results. After creating the script, copy only the SAInt network and scenario files from the tutorial’s directory to your Python script directory.
We can use various evaluation functions to evaluate and obtain results at both the network and object levels. In this case, we will be using the esum function in conjunction with the eval function to calculate the total active power generation, total production cost, and total CO2 emissions at the network level. Add the code below into your Python script and execute.
|
It is important to load the electric network, scenario, and solution files before evaluating the results. |
from ctypes import *
# Path to the SAInt-API.dll file (located in the SAInt installation folder)
path = "C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll"
# Create a SAInt API DLL object
saint_dll = cdll.LoadLibrary(path)
# Load the electric network
# CHANGE the path to the network file to match your folder
saint_dll.openENET(
"C:\\Work\\API Beginner\\Basic\\ENET09_13.enet"
)
# Load the electric scenario
# CHANGE the path to the scenario file to match your folder
saint_dll.openESCE(
"C:\\Work\\API Beginner\\Basic\\PCM_DCUCOPF_5.esce"
)
# Load the electric scenario solution file
# CHANGE the path to the solution file to match your folder
saint_dll.openESOL(
"C:\\Work\\API Beginner\\Basic\\PCM_DCUCOPF_5.esol"
)
# Total active power generation
print("Total active power generation")
saint_dll.eval(
"esum('ENET.PG.[MW].(%)')"
)
# Total production cost
print("Total production cost")
saint_dll.eval(
"esum('ENET.TOTCOSTRATE.[$/h].(%)')"
)
# Total CO2 emissions
print("Total CO2 emissions")
saint_dll.eval(
"esum('ENET.CO2RATE.[t/h].(%)')"
)
2025-07-10 12:56:10 [INFO] Loading Electric Network model from file: C:\Work\API Beginner\Basic\ENET09_13.enet
2025-07-10 12:56:20 [INFO] Electric Network loaded successfully
2025-07-10 12:56:20 [INFO] Loading Electric Scenario from file: C:\Work\API Beginner\Basic\PCM_DCUCOPF_5.esce.
2025-07-10 12:56:21 [INFO] Electric Scenario loaded successfully
2025-07-10 12:56:21 [INFO] Attempting to load Electric Scenario results.
2025-07-10 12:56:21 [INFO] Loading results for Electric Scenario from file: C:\Work\API Beginner\Basic\PCM_DCUCOPF_5.esol
2025-07-10 12:56:22 [INFO] Solution file was loaded successfully.
Total active power generation
2025-07-10 12:56:22 [INFO] SAInt>>:30065.3467332748
Total production cost
2025-07-10 12:56:22 [INFO] SAInt>>:652034.582482191
Total CO2 emissions
2025-07-10 12:56:22 [INFO] SAInt>>:0
1
2. emax
To find the maximum value from a time series of energy network results, we can use the emax function. This function will determine the highest value in a set of values, providing valuable insights into the performance of the energy network. For example, using the emax function on a time series of electricity demand data will reveal the peak demand, while using it on a time series of renewable energy generation data will show the maximum generation from renewable sources.
In this case, we will extract the peak electricity demand, maximum generation from renewable sources, and the maximum shadow price at one of the electric nodes. Add the code below into your Python script and execute.
# Peak electricity demand
print("Peak electricity demand")
saint_dll.eval(
"emax('ENET.PDSET.[MW].(%)')"
)
# Maximum PV generation
print("Maximum PV generation")
saint_dll.eval(
"emax('PV.SOLARPARK.P.(%)')"
)
# Maximum WIND generation
print("Maximum WIND generation")
saint_dll.eval(
"emax('WIND.WINDFARM.P.(%)')"
)
# Maximum shadow price at NODE7
print("Maximum shadow price at NODE7")
saint_dll.eval(
"emax('ENO.NODE7.PSHDW.(%)')"
)
emax function.Peak electricity demand
2025-07-10 12:57:56 [INFO] SAInt>>:293.775
Maximum PV generation
2025-07-10 12:57:56 [INFO] SAInt>>:35.1927196817945
Maximum WIND generation
2025-07-10 12:57:56 [INFO] SAInt>>:32.3213012331884
Maximum shadow price at NODE7
2025-07-10 12:57:56 [INFO] SAInt>>:44.1712729769872
1
3. emean
The emean function can be an extremely valuable in analyzing energy network results. By using the emean function on a time series of data, important information can be gathered about the performance of the energy network. For example, you can calculate the average electricity demand in a scenario or evaluate the average energy price at an electric node to determine the marginal cost of meeting the energy demand.
In this case, we will extract the average electricity demand and the average shadow price at one of the electric nodes. Add the code below into your Python script and execute.
# Average electricity demand
print("Average electricity demand")
saint_dll.eval(
"emean('ENET.PDSET.[MW].(%)')"
)
# Average shadow price at NODE7
print("Average shadow price at NODE7")
saint_dll.eval(
"emean('ENO.NODE7.PSHDW.(%)')"
)
emean function.Average electricity demand
2025-07-10 12:59:04 [INFO] SAInt>>:253.870661157025
Average shadow price at NODE7
2025-07-10 12:59:04 [INFO] SAInt>>:40.5826496584541