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.

Copy the network and scenario file used in this tutorial from the sub-folder .\Scripting\API Beginner\export of the folder Tutorials in the directory (C:\Users\...\Documents\encoord\SAInt-v3\Projects).

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 Export operations 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
saint_dll.openENET(
        "ENET09_13.enet"
        )

# Load the electric scenario
saint_dll.openESCE(
        "PCM_DCUCOPF_5.esce"
        )

# Load the electric scenario solution file
saint_dll.openESOL(
        "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].(%)')"
        )
Example 1. Logs from the eval function

Total active power generation

→ [30762.664976254]

Total production cost

→ [643650.563849067]

Total CO2 emissions

→ [0]

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.(%)')"
        )
Example 2. Logs from the emax function

Peak electricity demand

→ [293.775]

Maximum PV generation

→ [35.1927196817945]

Maximum WIND generation

→ [32.3213012331884]

Maximum shadow price at NODE7

→ [63.2068674485426]

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.(%)')"
        )
Example 3. Logs from the emean function

Average electricity demand

→ [253.870661157025]

Average shadow price at NODE7

→ [42.3237097503048]