ERACS’ Python folder within the ERACS installation directory contains two sub-folders. One is Interface and contains the Interface API code, the other is Examples which contains some ERACS data XML files and numerous sub-folders provided to demonstrate the various uses of the ERACS Python Interface. It’s recommended to look through the example scripts to get an idea of how the ERACS Python Interface works, and how you might design a tool of your own.
ERACS (Python Interface) Applications¶
The Python Interface related applications which come installed with ERACS, such as the Setup Wizard (to help install the Python Interface in all Python installations) and the Python Editor (to write the Python code) make it easy to access the examples. The image below shows how to access the list of examples from the ERACS Python Editor.
List of Examples¶
A list of the examples can be found in a text file named “Examples.txt” at the root of the Examples folder. Below is the text from the file as of the generation of this documentation. The format is as follows…
<name of the python script>, <description>, <path>
LFExampleBasicGUI, Loadflow study performed on our "Springfield Road" model. Results output to a simple graphical user interface., Loadflow\ LFExampleComplexGUI, Loadflow example with an advanced graphical user interface for custom studies., Loadflow\ LFExampleMultipleStudies, Performs multiple Loadflow studies on our "Springfield Road" model using instructions provided in CSV input files., Loadflow\ LFExampleNoGUI, Loadflow study performed on our "Springfield Road" model. Results output to the console., Loadflow\ LFExampleReactiveCapability, Uses the Loadflow interface to perform reactive capability analysis. Results written to MS Excel workbook., Loadflow\ FExampleNoGUI, Fault study performed on our "Springfield Road" model. Results output to CSV file., Fault\ FExampleComplexGUI, Fault example with an advanced graphical interface for custom studies., Fault\ FExampleMultipleStudies, Uses the Fault interface to perform multiple Fault studies based on configuration in code., Fault\ HZExampleNoGUI, Harmonic Impedance study performed on our "Springfield Road" model. Results output to CSV file., HarmonicImpedance\ HZExampleComplexGUI, Harmonic Impedance example with an advanced graphical user interface for custom studies., HarmonicImpedance\ HIExampleNoGUI, Harmonic Injection study performed on our "Springfield Road - Generation On" model. Results output to CSV file., HarmonicInjection\ HIExampleComplexGUI, Harmonic Injection example with an advanced graphical user interface for custom studies with waveforms and spectrum charts included., HarmonicInjection\ ExampleNetworkDiff, Example GUI tool for diffing two different ERACS network data XML files to see the changes made in a network., Diff\
Study Based Examples¶
The majority of examples provided with the ERACS Python Interface are study related. These examples will prove most useful to users that want to automate the execution of multiple studies on an ERACS network.
There’s numerous Loadflow example scripts, each serving a different purpose. Looking at these example scripts should be the starting point for learning about the ERACS Python Interface and running studies in the Loadflow Module, just like running a Loadflow study in ERACS is one of the first things a user learns.
LFExampleBasicGUI- A basic graphical interface made with the Tkinter Python library which displays a basic button for running Loadflow on the Springfield Road network provided in the data XML files in the examples folder.
LFExampleComplexGUI- A more advanced graphical interface made with the Tkinter Python library which allows the user to perform more complex operations such as loading a data XML file, opening/closing switches, and exporting results.
LFExampleMultipleStudies- A script for running multiple Loadflow studies via the Multi-Loadflow interface. The example makes use of two CSV files which come included in the same Loadflow subfolder.
LFExampleNoGUI- A non-graphical example which outputs Loadflow results to the console. This is the most basic example, but has a fair number of lines of code due to the result output.
LFExampleReactiveCapability- An example script which carries out a real use-case; this script performs a reactive power capability study. This example script requires external dependencies (openpyxl, pillow), which are grabbed automatically by the script after requesting user permission.
The Fault examples are very similar to the Loadflow examples apart from they make use of the Fault Module.
FExampleComplexGUI- An advanced graphical interface designed using the Tkinter Python library which allows users to run Fault studies easily as if they were being run from inside ERACS.
FExampleMultipleStudies- An example which enables users to run multiple fault studies via the Multi-Fault interface. The example configures multiple studies in code, but the Multi-Fault interface also suppots loading CSV definition files.
FExampleNoGUI- A non-graphical interface which outputs results to Excel. This is the most basic example script for Fault.
All examples within the HarmonicImpedance subfolder demonstrate usage of the Impedance Module in the ERACS Python Interface.
HZExampleComplexGUI- An advanced graphical interface designed with the Tkinter Python module for running Harmonic Impedance as if you were using ERACS.
HZExampleNoGUI- A non-graphical Harmonic Impedance example for running a study using the Springfield Road network and exporting results to Excel.
All examples within the HarmonicInjection subfolder demonstrate usage of the Injection Module in the ERACS Python Interface.
HIExampleComplexGUI- An advanced graphical interface designed with the Tkinter Python module for running Harmonic Injection as if you were using ERACS. Load an XML data file, select injection sources, and view harmonic waveform and spectrum charts. This advanced interface contains Matplotlib graphs, and thus requires the Matplotlib library. The library will be automatically installed by the script after being granted user permission.
HIExampleNoGUI- A non-graphical Harmonic Injection example for running a study using the Springfield Road network and outputting results to Excel.
The Examples folder contains other scripts and tools alongside those based on studies. Some of these other examples and tools are described below.
The ExampleNetworkDiff script is a diffing tool for comparing network data from XML files. The diffing tool allows toggling of context or full views, toggling of element data or all data, and the output can be viewed in the graphical user interface or in a web browser via the output HTML file in the same subfolder as the Python script. The diffing tool simply compares textural differences from the XML data files, but in future may be tightly integrated into the ERACS Python Interface such that the diffing tool can distinguish individual elements and provide unique and helpful functionality. The diffing tool displays a HTML page in the GUI with the help of the CEF Python library. This dependency is installed automatically by the tool after requesting user permission.
The heat grid examples allows users to examine a heat map once a Loadflow or Fault study has been performed. These example scripts use built-in HeatGrid scripts within the Python Interface which requires Matplotlib, Pillow, and NumPy dependencies.
The Diagram Generator example scripts allow a user to generate graphical
information for ERACS data loaded into the Python Interface via one of the
File classes and stored within the
Data class. The diagram
generator uses a simulated annealing algorithm to attempt to optimise the
network layout by minimizing line crossings and line lengths (Transmission Lines,
Cables, and Series Elements are considered lines since they provide links