Introduction

The Python API enables a broad range of applications for GridLAB-D™, from simply running a model to integrating GridLAB-D™ into a larger code base where it serves as a modeling engine alongside a wide range of Python-enabled functionality. The API fundamentally changes GridLAB-D™ from a command-line simulation tool to a simulation engine that can be used in a much broader range of applications. The goal of this section is to provide an overview of the essential portions of the API and provides some examples of how it can be used as part of a larger code-base to achieve broader analysis needs.

Simulation Time Control

The clock in GridLAB-D™ is used control the start and stop time of the simulation and can be read and written (e.g. get_starttime(), set_starttime()). Control of the advancement of time is managed through a simple set of APIs: step() to move through simulation time in a progressive manner and run() to simply run straight through the model from the defined start and stop time. Further details are provided in the documentation pages on setting start and stop times and controlling simulation time.

Getters and Setters

The most common GridLAB-D™ API calls you're likely to use are for getting values from the GridLAB-D™ model ("getters") and setting values in the GridLAB-D™ model ("setters"). This is a common paradigm for APIs in many applications and given GridLAB-D™'s object-oriented nature, it fits well; virtually everything a GridLAB-D™ user would want to interrogate or manipulate is representated as an object with parameters that can be accessed with generic methods. Almost all objects in GridLAB-D™ can be read through methods like get_model(), get_objects_by_class(), and get_property() (among others) and written to using methods like set_property_by_class() and set_property(). (A complete listing of the API can be found on the API Reference page.) Further details are provided in documentation pages on reading data from a GridLAB-D™ model, and writing data to a GridLAB-D™ model.

Everything Else

The remainder of this section of the the documentation provides detailed instruction on the above APIs as well as other useful functionality such as working with console messages and working with checkpoints (among other). Not all of the GridLAB-D™ APIs will be disucssed in this documentation but those that provide access to the core functionality of GridLAB-D™ will be covered and will be sufficient to enable the use of GridLAB-D™ in a wide variety of applications.