Get SAInt Simulation Results

In this section, we’ll explore into using SAInt API methods to extract specific results from the : "triangle" network and the "REFERENCE" scenario, as outlined in the previous section Execute Scenarios with the SAInt API. Additionally, we will showcase how to easily and flexibly extract results using pySAInt.

If you are following along, ensure the presence of the following SAInt files in your current working directory before proceeding:

  • triangle.ENET

  • REFERENCE.esce

  • REFERENCE.esol

  • REFERENCE.econ

1. Use SAInt API to Write Scenario Results

There are two primary methods to extract results from SAInt:

  • Evaluation Functions: For evaluating specific object properties.

  • Write Function: For directly writing out scenario results.

1.1. Evaluation Functions

SAInt API’s evaluation functions assess object properties at specific time steps or across all time steps in a scenario. We can access these functions in pySAInt with the ps.saint_dll.evalCmdStr method, which requires a SAInt object expression ObjectType.ObjectName.PropertyExtension.[Unit] as an input, similar to the expressions used in SAInt GUI Command Window.

For further information on input expressions, refer to the SAInt documentation.

First, we load the "triangle" network and REFERENCE scenario:

import pysaint as ps

# Set the SAInt API DLL for standard installations
ps.utils.set_dll()

# Load the network, scenario, and solution
ps.saint_dll.openENET("triangle.ENET")
ps.saint_dll.openESCE("REFERENCE.esce")
ps.saint_dll.openESOL("REFERENCE.esol")
python

For example, to extract shadow prices at NODE3 and the total active power from GAS_CC:

# Extracting shadow prices at "NODE3" for all time steps
prices = ps.saint_dll.evalCmdStr("eval('ENO.NODE3.PSHDW.(%)')")

# Total active power generation for "GAS_CC"
p_gascc = ps.saint_dll.evalCmdStr("esum('FGEN.GAS_CC.P.[MW].(%)')")
python

1.2. Write Function

The writeESOL method of SAInt API extracts specific results from an electric scenario. It requires:

  • The path to the results description file.

  • The path where the results should be saved.

It uses a result description file, which can be in text, csv, or Excel format. This file specifies the result properties with the format ObjectType.ObjectName.PropertyExtension.[Unit]. Including units in the description file is optional; if omitted, default units will be used.

We can also use writeGSOL for gas network and scenarios.

Let’s extract shadow prices at NODE3 and the power output from GAS_CC across all timesteps of the scenario. To prepare your results description file, simply:

  • Open a text editor.

  • Input your desired result properties on separate lines, for example:

    • ENO.NODE3.PSHDW

    • FGEN.GAS_CC.P.[MW]

After saving this file as results_description.txt in your current working directory, you can then use the writeESOL method to extract the specified results:

# Extract results
ps.saint_dll.writeESOL("results_description.txt", "results.xlsx")
python

Check the file "results.xlsx" file created in your current working directory.

2. Use pySAInt to Write Scenario Results

pySAInt offers a simplified way of extracting results from an electric or gas scenario. The write_data_from_saint method retrieves results for every object within a specified object type. It supports flexible, descriptor-based result extraction without needing separate files or manual scenario loading. For instance, obtaining shadow prices for every node or the power output from all the fuel generators.

The method accepts the following arguments:

Parameter Type Description

project_dir

str

Directory for the network and scenario files

netname

str

Name of the network

scenname

str

Name of the scenario

descriptors

dict

A dictionary where keys are object types (e.g., ENO, FGEN) and values are lists of properties (e.g., [PSHDW], [P]).

single_timestep

bool, optional

Discern between Steady or Dynamic scenarios, defaults to Dynamic

net_type

str, optional

Type of network (electric or gas), defaults to electric

Let’s now extract the shadow prices at all the nodes and the power ouput from all the fuel generators:

import os
import pysaint as ps

# Extract results
ps.utils.write_data_from_saint(
  project_dir=os.getcwd(),
  netname='triangle',
  scenname='REFERENCE',
  descriptors={'ENO': ['PSHDW'], 'FGEN': ['P']},
  single_timestep=False,
  net_type='electric'
)
python

2.1. Why Use write_data_from_saint?

Using the write_data_from_saint method offers several advantages for flexibility and ease of use:

  • Simplicity: Automatically loads network and scenario files.

  • No Descriptors File Needed: Directly use descriptors for result extraction.

  • Comprehensive Extraction: Retrieves results for all objects of a specified object type in a single file.

2.2. What happens after?

Running write_data_from_saint organizes output as follows:

triangle_Info: This folder is created in the project_dir to hold all the output data related to the triangle network. The naming convention follows the pattern [network name]_Info, where the network name (triangle in this case) is prefixed to _Info to indicate that the folder contains information extracted from the network.

REFERENCE: Within the triangle_Info folder, there’s a subfolder named REFERENCE (in this case), which corresponds to the scenario name. This structure allows you to keep results from different scenarios separate and organized, especially when analyzing multiple scenarios within the same network.

Network_Parameters.csv: This file, located directly within the triangle_Info folder, summarizes the network parameters for the triangle (in this case) network. It provides a comprehensive view of the network’s objects and properties.

ENO.PSHDW.csv and FGEN_P.csv: Inside the REFERENCE subfolder, you’ll find CSV files for each descriptor you specified in the descriptors parameter. Each file contains the extracted results for that descriptor across all relevant objects and time steps.

  • ENO.PSHDW.csv: This file contains the extracted results for shadow prices at each node (ENO) for the property PSHDW.

  • FGEN_P.csv: Similarly, this file holds the power generation data (P) for all fuel generators (FGEN) in the network.