Application Programming Interface

SAInt-API is a powerful tool to automate the manual processes in the GUI. It gives access to multiple network and scenario data processing and execution functions. The API can be used with Python, C++, and other programming languages.

1. Requirement

1.1. Python

Python version: SAInt-API has been tested with multiple releases of Python. Python 3.9 and 3.10 are perfectly compatible. Python 3.11 and 3.12 may generate compatibility problems in conjunction with other packages or caused by unsolved bugs. We encourage our users to avoid the very latest release of Python.

Ctypes package: The ctypes package provides C-compatible data types and allows function calls from a dynamic link library (DLL). It can imported using from ctypes import * command.

Access API Functions: It is necessary to create a DLL object using mydll = cdll.LoadLibrary(path) command, where path is the directory of the SAInt API and DLL file. The SAInt-API functions can then be accessed as attributes of the DLL object.

If you are not able to load SAInt-API, try the following:

  1. Go to "Edit the system environment variables" by searching in the Windows start menu.

  2. On the System Properties window, click on the button Environment variables.

  3. Under user variables, select Path and click on Edit.

  4. On the Edit environment variable window, check if the SAInt directory is listed there; if not, click on New and select the path where SAInt is installed: "C:\Program Files\encoord\SAInt-v3", and click OK on both.

  5. Close the interface and re-open.

If the problem persists, please contact encoord support.

2. SAInt-API functions

This section describes the functions of SAInt-API with examples of their usage with Python. The functions are divided into seven categories:

2.1. Project

openPRJ(string PrjFile)

Open a project and load it into memory.

Parameter Type Description

PrjFile

String

Full path to project file (*.prj)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openPRJ("C:\\Project1.prj")
python
openSES(string SesFile)

Open a session of a related project and load it into memory.

Parameter Type Description

SesFile

String

Full path to session file (*.ses)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openSES("C:\\Project1_Session1.ses")
python

2.2. Network

openENET(string ENETFile)

Open an electric network model and load it into memory.

Parameter Type Description

ENETFile

String

Full path to electric network file (*.enet)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")
python
importENET(string ImportFile)

Import an electric network model from a network import file and load it into memory.

Parameter Type Description

ImportFile

String

Full path to network import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.importENET("C:\\Template_ENET.xlsx")
python
exportENET(string ImportFile)

Export an electric network to network import file.

Parameter Type Description

ImportFile

String

Full path to network import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.exportENET("C:\\Export_to_ENET_Import.xlsx")
python
paraimportENET(string ImportFile)

Import a parameter import file and apply it to a loaded electric network model.

Parameter Type Description

ImportFile

String

Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.paraimportENET("C:\\ENET_ParaImport.xlsx")
python
paraexportENET(string ExportFile)

Export an input parameter for an electric network model.

Parameter Type Description

ExportFile

String

Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.paraexportENET("C:\\ENET_ParaExport.xlsx")
python
importWTPC(string ImportFile)

Import a wind turbine power curve to a loaded electric network.

Parameter Type Description

ImportFile

String

Full path to import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.importWTPC("C:\\ENET_WTPCExport.xlsx")
python
includeWTPC(string WTPCFile)

Include a wind turbine power curve to a loaded electric network.

Parameter Type Description

WTPCFile

String

Full path to wind turbine power curve file (*.wtpc)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.includeWTPC("C:\\ENET_WTPCInclude.wtpc")
python
exportWTPC(string ExportFile)

Export a wind turbine power curve from a loaded electric network to an import or include file.

Parameter Type Description

ExportFile

String

Full path to file to export to (*.wtpc | *.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.exportWTPC("C:\\ENET_WTPCExport.xlsx")
python
importFCC(string ImportFile)

Import a fuel consumption curve to a loaded electric network.

Parameter Type Description

ImportFile

String

Full path to import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.importWTPC("C:\\ENET_FCCExport.xlsx")
python
includeFCC(string FCCFile)

Include a fuel consumption curve to a loaded electric network.

Parameter Type Description

FCCFile

String

Full path to fuel consumption curve file (*.fcc)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.includeWTPC("C:\\ENET_FCCInclude.fcc")
python
exportFCC(string ExportFile)

Export a fuel consumption curve from a loaded electric network to an import or include file.

Parameter Type Description

ExportFile

String

Full path to file to export to (*.fcc | *.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.exportWTPC("C:\\ENET_FCCExport.xlsx")
python
includeENET(string MainENETFile, string ENETFileToAdd, string targetENETFile, bool PreserveContainers, bool LoadAfter)

Include an electric network model from a network file to another electric network model from network file and save the joined network to the target file. Each network must be in a different directory.

Parameter Type Description

MainENETFile

String

Full path to main electric network file (*.enet)

ENETFileToAdd

String

Full path to electric network file to add (*.enet)

targetENETFile

String

Full path to electric network file to save (*.enet)

PreserveContainers

Boolean

Set true to preserve the existing subsystems (Zones,Subs,Groups) in the main network

LoadAfter

Boolean

Set true to load the target network after the join process

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.includeENET("C:\\A\\ENET30.enet","C:\\B\\ENET5.enet","C:\\C\\newENET.enet",False,True)
python
includeInLoadedENET(string ENETFileToAdd, string targetNetFile, bool PreserveContainers, bool LoadAfter)

Include an electric network model from a network file to loaded electric network model and save the joined network to the target file. Each network must be in a different directory.

Parameter Type Description

ENETFileToAdd

String

Full path to electric network file to add (*.enet)

targetNetFile

String

Full path to electric network file to save (*.enet)

PreserveContainers

Boolean

Set true to preserve the existed the subsystems ( Zones,Subs,Groups) in the main network

LoadAfter

Boolean

Set true to load the target network after the include process

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.includeInLoadedENET("C:\\A\\ENET5.enet","C:\\B\\newENET.enet",False,True)
python
convertCRSENET(string targetFileName, string sourceEPSG_ID, string targetEPSG_ID, bool transferWholeNet)
Parameter Type Description

targetFileName

String

sourceEPSG_ID

String

targetEPSG_ID

String

transferWholeNet

Boolean

exportENETByEPSGID(string ImportFile, string EPSG_ID)

Export an electric network to network import file with a new CRS indicated by an EPSG code.

Parameter Type Description

ImportFile

String

Full path to network import file (*.xlsx | *.xls | *.txt | *.csv)

EPSG_ID

String

EPSG Coordinate System ID

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openGNET("C:\\ENET30.enet")

mydll.exportGNETByEPSGID("C:\\Export_to_ENET_Import.xlsx","32632")
python

2.3. Scenario management

newESCE(string ScenarioNameStr, string ScenarioTypeStr, string StartTimeStr, string EndTimeStr, int TimeStep, int TimeHorizon, int TimeLookAhead, int TimeStepLookAhead)

Create a new electric scenario for a loaded electric network model.

Parameter Type Description

ScenarioNameStr

String

Scenario name

ScenarioTypeStr

String

Scenario type, either "SteadyACPF", "SteadyACOPF", "QuasiDynamicACPF", "QuasiDynamicACOPF", "SteadyDCPF", "SteadyDCOPF", "QuasiDynamicDCPF", "QuasiDynamicDCOPF", or "DCUCOPF"

StartTimeStr

String

Start time in format "dd/MM/yyyy HH:mm"

EndTimeStr

String

End time in format "dd/MM/yyyy HH:mm"

TimeStep

Int32

Time step (of time horizon) in seconds

TimeHorizon

Int32

Time horizon (required input) in seconds, only used in "DCUCOPF"

TimeLookAhead

Int32

Time look ahead (required input) in seconds, only used in "DCUCOPF"

TimeStepLookAhead

Int32

Time step look ahead (required input) in seconds, only used in "DCUCOPF"

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.newESCE("ENET30_STE", "SteadyACPF", "01/01/2022 00:00", "01/01/2022 01:00", 3600, 3600, 0, 0)
python
from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 900, 900, 0, 0)
python
from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.newESCE("ENET30_PCM", "DCUCOPF", "01/01/2022 00:00", "08/01/2022 00:00", 1800, 86400, 86400, 7200)
python
openESCE(string ESCEFile)

Open an electric scenario for a loaded electric network model.

Parameter Type Description

ESCEFile

String

Path to electric scenario file (*.esce)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_STE.esce")
python
importESCE(string FileName)

Import a scenario events from an import file to a loaded electric scenario.

Parameter Type Description

FileName

String

Path to scenario event import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.importESCE("C:\\Template_ESCE.xlsx")
python
from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.newGSCE("ENET30_DYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 900)

mydll.importESCE("C:\\Template_ESCE.xlsx")
python
exportESCE(string FileName)

Export an electric scenario events to a scenario event import file.

Parameter Type Description

FileName

String

Path to scenario event export file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.exportESCE("C:\\ExportEvents.xlsx")
python
includeESCE(string FileName, string StartTimeStr, string EndTimeStr)

Include an electric scenario to a loaded network model and scenario.

Parameter Type Description

FileName

String

Path to electric scenario file to include (*.esce)

StartTimeStr

String

Start time from which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file)

EndTimeStr

String

End time to which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 900)

mydll.includeESCE("C:\\ENET30_QDYN2.esce", "+2", "+5")
python
from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 900)

mydll.includeESCE("C:\\ENET30_QDYN2.esce", "2:00", "5:00")
python
from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 900)

mydll.includeESCE("C:\\ENET30_QDYN2.esce", "1/2:00", "2/5:00")
python

2.4. Scenario execution

These functions apply to all scenario types.

showSIMLOG(bool input)

Show the simulation log in a console window.

Parameter Type Description

input

Boolean

True if simulation log should be displayed in the console

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.runGSIM.restype = c_int

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGCON("C:\\GNET30_STE.gcon")

mydll.showSIMLOG(True)

b = mydll.runGSIM()

print(b)
python
setSIMLOGFile(string input)

Specify a file to write the simulation log to.

Parameter Type Description

input

String

Full path to log file (*.log)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.runGSIM.restype = c_int

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGCON("C:\\GNET30_STE.gcon")

mydll.setSIMLOGFile("C:\\SimOut.log)

b = mydll.runGSIM()

print(b)
python
writeSIMLOG(bool input)

Write the simulation log to a file.

Parameter Type Description

input

Boolean

True if simulation log should be written to a file specified by the "setSIMLOGFile" function

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.runGSIM.restype = c_int

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGCON("C:\\GNET30_STE.gcon")

mydll.writeSIMLOG(True)

b = mydll.runGSIM()

print(b)
python
int runESIM()

Run an electric scenario for the loaded electric network, scenario and condition file.

Returns:

  • none = 0

  • Infeasible = 1

  • Feasible = 2

  • Solving = 4

  • Aborted = 8

  • Paused = 16

  • Solved = 32

  • Failed = 64

  • ConstraintViolation = 128

  • AmbientPressureViolation = 256

  • ConstraintHandling = 512

  • MissingPressure = 1028

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.runESIM.restype = c_int

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.openECON("C:\\ENET30_STE.econ")

b = mydll.runESIM()

print(b)
python
int runESIMCustomDLL(string AssemblyPath, string NamespaceName, string ClassName)

Run an electric scenario for the loaded electric network, scenario and condition file using a custom dll file.

Parameter Type Description

AssemblyPath

String

Path to custom dll file (*.dll)

NamespaceName

String

Namespace where the class is defined

ClassName

String

Name of class where the "ISolverHandler" interface is implemented

Returns:

  • none = 0

  • Infeasible = 1

  • Feasible = 2

  • Solving = 4

  • Aborted = 8

  • Paused = 16

  • Solved = 32

  • Failed = 64

  • ConstraintViolation = 128

  • AmbientPressureViolation = 256

  • ConstraintHandling = 512

  • MissingPressure = 1028

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.runESIMCustomDLL.restype = c_int

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_DYN.esce")

mydll.openECON("C:\\ENET30_STE.econ")

b = mydll.rungESIMCustomDLL("C:\\MyAssembly.dll", "MyAssembly", "TestClass")

print(b)
python

2.5. Scenario solution

openESOL(string SOLFile)

Open an electric solution file to the loaded electric network model.

Parameter Type Description

SOLFile

String

Full path to electric solution file (*.esol)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.openESOL("C:\\ENET30_QDYN.esol")
python
writeESOL(string SOLInputFile, string SOLOutputFile)

Write an electric scenario results to a file using a result description file.

Parameter Type Description

SOLInputFile

String

Path to result description file (*.xlsx | *.xls | *.txt | *.csv)

SOLOutputFile

String

Path to result output file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_DYN.esce")

mydll.openECON("C:\\ENET30_STE.econ")

mydll.runESIM()

mydll.writeESOL("C:\\SolIn.xlsx", "C:\\SolOutput.xlsx")
python
openECON(string CONFile)

Open a state/condition file for the loaded electric network model.

Parameter Type Description

CONFile

String

Path to electric state file (*.econ)

from ctypes import *

mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.openECON("C:\\ENET30_STE.econ")
python
setECONWriteStatus(bool writefile)

Switch between writing and not writing the electric network state file after simulation.

Parameter Type Description

writefile

Boolean

If True state file will be generated after simulation

from ctypes import *

mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.openECON("C:\\ENET30_QDYN.econ")

mydll.setECONWriteStatus(False)

mydll.runESIM()
python
exportECON(string Filename, string TimeStr)

Export an electric network state at the specified simulation time to a state file.

Parameter Type Description

Filename

String

Path to electric state file (*.econ)

TimeStr

String

Time for which state file should be generated (similar to time definition for scenario event in EUI and import file)

from ctypes import *

mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.openESOL("C:\\ENET30_QDYN.esol")

mydll.exportECON("C:\\ExportState.econ", "1/2:00")
python
from ctypes import *

mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.openESOL("C:\\ENET30_QDYN.esol")

mydll.exportECON("C:\\ExportState.econ", "+2")
python

2.6. Profiles

importEPRF(string FileName)

Import a profile import file to a loaded electric scenario.

Parameter Type Description

FileName

String

Path to profile import file (*.xlsx | *.xls | *.txt | *.csv)

from ctypes import *

mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.importEPRF("C:\\Template_Profile_Import.xlsx")

mydll.importESCE("C:\\Template_ESCE.xlsx")
python
exportEPRF(string FileName)

Export profiles from the current electric scenario to an export file.

Parameter Type Description

FileName

String

Full path to profile export file (*.prfl)

from ctypes import *

mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.exportEPRF("C:\\ExportProfile.prfl")
python
includeEPRF(string FileName)

Include profiles from a profile file to the current electric scenario.

Parameter Type Description

FileName

String

Full path to profile file (*.prfl)

from ctypes import *

mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openENET("C:\\ENET30.enet")

mydll.openESCE("C:\\ENET30_QDYN.esce")

mydll.includeEPRF("C:\\Profile.prfl")

mydll.importESCE("C:\\Template_ESCE.xlsx")
python

2.7. Evaluation

How to write expression is discussed in the section "Expression" of the reference guide. These functions apply to all scenario types.

eval(string Expression)

Evaluate an expression for the current loaded model and display the result in a console/log.

Parameter Type Description

Expression

String

Expression similar to GUI command window expression

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_STE.gsol")

mydll.eval("GNET.LP.(%)")
python
bool evalBool(string Expression)

Evaluate a logical expression for the current loaded model and return an integer.

Parameter Type Description

Expression

String

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalBool.restype = c_bool

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_DYN.gsol")

b = mydll.evalBool("GNET.NUMNO>2")

print(b)
python
float evalFloat(string Expression)

Evaluate an expression for the current loaded model and return a float.

Parameter Type Description

Expression

String

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalFloat.restype = c_float

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_DYN.gsol")

b = mydll.evalFloat("GNET.LP.[Msm3].(2)")

print(b)
python
int evalInt(string Expression)

Evaluate the expression for the current loaded model and return an integer.

Parameter Type Description

Expression

String

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalInt.restype = c_int

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_DYN.gsol")

b = mydll.evalInt("GNET.NUMNO")

print(b)
python
string evalStr(string Expression)

Evaluate the expression for the current loaded model and return a string.

Parameter Type Description

Expression

String

Expression similar to GUI command window expression

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalStr.restype = c_wchar_p

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_STE.gsol")

b = mydll.evalStr("GNO.Name.(%)")

print(b)
python
evalCmd(string Expression)

Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and display the result in console/log.

Parameter Type Description

Expression

String

Expression similar to GUI command window expression

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_STE.gsol")

mydll.evalCmd("eminat('GNO.%.P')")
python
bool evalCmdBool(string Expression)

Evaluate a logical expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return a boolean.

Parameter Type Description

Expression

String

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalCmdBool.restype=c_bool

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_DYN.gsol")

b = mydll.evalCmdBool("emin('GNO.%.P.[barg]')>10")

print(b)
python
float evalCmdFloat(string Expression)

Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return a float.

Parameter Type Description

Expression

String

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalCmdFloat.restype=c_float

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_DYN.gsol")

b = mydll.evalCmdFloat("emax('GNO.%.P.[barg]')")

print(b)
python
int evalCmdInt(string Expression)

Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return an integer.

Parameter Type Description

Expression

String

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalCmdInt.restype=c_int

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_DYN.gsol")

b = mydll.evalCmdInt("ecount('GNO.%')")

print(b)
python
string evalCmdStr(string Expression)

Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return a string.

Parameter Type Description

Expression

String

Expression similar to GUI command window expression

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.evalCmdStr.restype = c_wchar_p

mydll.openGNET("C:\\GNET30.gnet")

mydll.openGSCE("C:\\GNET30_DYN.gsce")

mydll.openGSOL("C:\\GNET30_STE.gsol")

b = mydll.evalCmdStr("eminat('GNO.%.P')")

print(b)
python

2.8. Miscellaneous Functions

LoadUnits(string filePath)

Change the default units by loading a units file.

Parameter Type Description

filePath

String

Full path to units file (*.units)

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.LoadUnits("C:\\SampleUnits.units)
python
string getVersion()

Get the current SAInt version.

Returns: None

from ctypes import *

mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")

mydll.getVersion.restype = c_wchar_p

b = mydll.getVersion()

print(b)
python

3. Change DCUCOPF scenario settings

RelMipGap

The relative mip gap in the current loaded scenario.

mydll = cdll.LoadLibrary('C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll')

mydll.evalCmdStr('ENET.SCE.RelMipGap=0.05')
python
TimeLimit

The solver time limit in the current loaded scenario.

mydll = cdll.LoadLibrary('C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll')

mydll.evalCmdStr('ENET.SCE.TimeLimit=600')
python

4. Exception logging mechanism

SAInt API provides the user with a logging option for debugging possible errors and addressing exceptions caused by the execution of Python code. The exception logging mechanism saves the exception log either in the default directory .\encoord\SAInt-v3\Logs or in a user-specified directory if a new system environment variable named SAIntExceptionLogPath is defined.