Skip to content

EnergyExemplar/Python-PLEXOS-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python PLEXOS API

https://github.com/EnergyExemplar/Python-PLEXOS-API

A repository of simple Python examples for use with the PLEXOS API.

Please note that this repository is not a supported product of Energy Exemplar, but rather a help to the user which is a free time activity for dedicated fans of the product.

Migrating from prior versions to PLEXOS 9 API and newer

Python's .NET interop components only work with .NET 4.8.

That means you need to install an additional software component to use the PLEXOS API with Python. It is available on the Energy Exemplar customer portal (you have to scroll nearly to the bottom).

The primary components to import have changed a bit.

Before

sys.path.append('C:/Program Files (x86)/Energy Exemplar/PLEXOS 8.1/')
clr.AddReference('PLEXOS7_NET.Core')

After

sys.path.append('C:/Program Files/Energy Exemplar/PLEXOS 9.0 API')
clr.AddReference('PLEXOS_NET.Core')

Note the new location to add to the PATH references the install location of the new software components mentioned above, and the missing 7 in the name of the reference. Also if you are migrating from an older PLEXOS version, (x86) is no longer in the default installation folder.

Likewise, a key import statement has changed.

Before

from PLEXOS7_NET.Core import DatabaseCore

After

from PLEXOS_NET.Core import DatabaseCore

Again a missing 7.

There is a new reference that contains some of the enumerations that used to be in EEUTILITY.

Before

clr.AddReference('EEUTILITY')

After

clr.AddReference('EEUTILITY')
clr.AddReference('EnergyExemplar.PLEXOS.Utility')

There is a corresponding modification to import the enumerations that are in this new component.

Before

from EEUTILITY.Enums import *

After

from EEUTILITY.Enums import *
from EnergyExemplar.PLEXOS.Utility.Enums import *

Using Enumerations in Python scripts

Prior to PLEXOS API 10.0 R04 the API functions were coded to accept values from enums defined in the .Net libraries. This approach had always meant that the API could only reliably operate on databases created by the same version as the API. This would lead to issues when users would upgrade PLEXOS but still needed to process databases or solutions which were generated by the previous version of PLEXOS. To address this issue, the API no longer relies on many of those enumerations. Instead, there are a new set of functions which fetch a dictionary of values where the key is similar to what the former enumeration name would have been. These are:

FetchAllClassIds()
FetchAllCollectionIds()
FetchAllAttributeEnums()
FetchAllPropertyEnums()

Fetch these dictionaries once in your script and use them in place of the former enumerations.

Before

results = sol.QueryToList(
    SimulationPhaseEnum.STSchedule,
    CollectionEnum.SystemGenerators, 
    '',
    '',
    PeriodEnum.FiscalYear,
    SeriesTypeEnum.Values, 
    str(int(SystemOutGeneratorsEnum.Generation))
    )

After

collectionEnums = sol.FetchAllCollectionIds()
propertyEnums = sol.FetchAllPropertyEnums()

results = sol.QueryToList(
    SimulationPhaseEnum.STSchedule,
    collectionEnums["SystemGenerators"], 
    '',
    '',
    PeriodEnum.FiscalYear,
    SeriesTypeEnum.Values, 
    str(propertyEnums["SystemGenerators.Generation"])
    )

Note there is no more need for "Out" to appear in collection names.

Fetch functions return a .Net dictionary, not a Python dictionary. To convert, if needed, simply call (eg):

collectionEnums = dict(sol.FetchAllCollectionIds())

PLEXOS® for Power Systems

PLEXOS® Integrated Energy Model (PLEXOS) is tried-and-true simulation software that uses state-of-the-art mathematical optimisation combined with the latest data handling and visualisation and distributed computing methods, to provide a high-performance, robust simulation system for electric power, water and gas that is leading edge yet open and transparent. PLEXOS meets the demands of energy market participants, system planners, investors, regulators, consultants and analysts alike with a comprehensive range of features seamlessly integrating electric, water, gas and heat production, transportation and demand over simulated timeframes from minutes to 10’s of years, all delivered through a common simulation engine with easy-to-use interface and integrated data platform.

PLEXOS is the fastest and most sophisticated software available today, and also the most cost-effective.

PLEXOS Licensing

PLEXOS® licensing is not included with the license for these examples. These scripts are therefore only useful to those with current PLEXOS licensing. Furthermore, these scripts are NOT a supported part of the PLEXOS software. They are only illustrative of uses that could be made of the PLEXOS API by PLEXOS licensees.

For assistance with PLEXOS licensing, please visit

https://www.energyexemplar.com/contact-us

Development Environment

The authors are primarily using Python version 3.x along with the PythonNet repository.

Python for .NET --> https://pythonnet.github.io/

Visual Studio Code --> https://code.visualstudio.com/

Energy Exemplar and PLEXOS --> https://portal.energyexemplar.com/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages