A Co-Simulation Platform For Packetized Energy Management and Trading
PEMT-CoSim is a co-simulation platform for packetized energy management (PEM) and trading (PET) in smart grids. It is developed based on the open-source Transactive Energy Simulation Platform (TESP, v1.0.0).
Packetized Energy (PE) is a gird management technology which breaks the power into fixed-duration/fixed power "energy packet" with a "request-reply" scheme. Prosumers (both suppler and consumer) can request a packet for their load/generator to consume/provide. A central coordinator will accept/reject the request based on grid condition. There are two types of PE, Packetized Energy Management (PEM) and Packetized Energy Trading (PET). Packetized Energy Management (PEM) is a load dispatch program which uses a PEM controller to have houses' flexible load to request a packet with a probability, and the central coordinator will accept/reject the request by comparing the the request load with a balancing signal. PET allows prosumers to bid for a packet in a double-auction market. The cleared price and quantity determine whether bids are accepted or rejected for prosumers.
PEMT-CoSim utilizes the TESP's HELICS co-simulation framework to enable coordination between a number of dedicated simulators/programs (named "federate" under the HECLIS framework): GridLAB-D federate (distribution system simulator), PyPower federate (transmission system simulator), EnergyPlus federate(building simulator), Wether federate (weather data generator), Substation federate (Implemented the processes for PET and PEM).
PEMT-CoSim ArchitectureSubstation is main federate which implements the PEM and PET using developed API, including PEM-related modules (PEM Controllers, PEM Coordinator), PET-related modules (PET Prosumer, PEM Market). Moreover, the AI modules implemented the reinforcement learning algorithm that can be used to optimize the biding strategies for prosumers.
PEMT-CoSim runs natively on Linux. However, for better deployment of this project, it is suggested to run this project in a docker container. Therefore, PEMT-CoSim can also run in Windows and MacOS via docker. In addition, the PEMT-CoSim integrated with Fabric blockchain cannot run in a Docker container, for the detailed instructions, please refer to the document in the demo-PET-BC folder.
Before the installation, the Docker or Docker Desktop, and Git should be installed.
- Clone the PEMT-CoSim Project from Github (https://github.com/Yuanliang-Li/PEMT-CoSim)
- Open a command prompt in Linux/Windows/MacOS, and cd into the "docker" directory of the PEMT-CoSim project.
cd docker
- Build docker image
docker build . -t ubuntu-vnc
- Build ubuntu docker container
docker run -it --privileged -p 2222:22 -p 5951:5901 --mount type=bind,source= /YOURDIRECTORY/To/PEMT-CoSim,destination=/PEMT-CoSim --name ubuntu-pemt ubuntu-vnc
The "--mount" option can make a file or directory on the host machine mounted into the container. So, after the installation you can make development/edition/post-processing on your project in your host machine, and run the co-simulation in the container. - Install TESP by typing when building the container
/root/startup/tesp-1.0.0-linux-x64-installer.run
The following steps show how you start and connect to your running container
- Start the container (the container will run)
docker start ubuntu-pemt
- Connect to a running docker container
docker exec --privileged -it ubuntu-pemt /bin/bash
Denote "(c)" as configuration file, "(o)" as output file.
-
generate_case.py : a python script to generate a study case based on user configuration
-
glmhelper.py : a class including functions to generate the .glm file
-
plotFig.py : makes plots for the case
-
fed_gridlabd : folder for Gridlab-D federate
- (c) TE_Challenge.glm : define the distribution power grid for Gridlab-D
- (c) outputs_te.glm : define the output record for Gridlab-D
- (c) phase_A.player : define the phase A voltage for the unresponsive load in Gridlab-D
- (c) phase_B.player : define the phase B voltage for the unresponsive load in Gridlab-D
- (c) phase_C.player : define the phase C voltage for the unresponsive load in Gridlab-D
- (c) TE_Challenge_glm_dict.json : a dictionary of elements in Gridlab-D
- (c) TE_Challenge_HELICS_gld_msg.json : define HELICS message flows for Gridlab-D federate
- (o) billing_meter_TE_ChallengeH_metrics.json
- (o) house_TE_ChallengeH_metrics.json
- (o) inverter_TE_ChallengeH_metrics.json
- (o) line_TE_ChallengeH_metrics.json
- (o) capacitor_TE_ChallengeH_metrics.json
- (o) regulator_TE_ChallengeH_metrics.json
- (o) eplus_load.csv
- (o) evchargerdet_TE_ChallengeH_metrics.json
- (o) substation_TE_ChallengeH_metrics.json
- (o) weather.csv
- (o) gridlabd.log
-
fed_pypower : folder for PyPower federate
- launch_pypower.py : python script for launching the PyPower federate
- (c) te30_pp.json : define the transmission system in PyPower
- (c) NonGLDLoad.txt : define the nonresponsive load in transmission system
- (c) pypowerConfig.json : define HELICS message flows for PyPower federate
- (o) bus_TE_ChallengeH_metrics.json.csv
- (o) gen_TE_ChallengeH_metrics.json
- (o) pypower.log
-
fed_energyplus : folder for EnergyPlus federate and EnergyPlus agent federate
- (c) *.idf : define the building for the EnergyPlus
- (c) helics_eplus.json : define HELICS message flows for EnergyPlus federate
- (c) helics_eplus_agent.json : define HELICS message flows for EnergyPlus agent federate
- (o) eplus_TE_ChallengeH_metrics.json
- (o) output
- (o) eplus.log
- (o) eplus_agent.log
-
fed_substation : folder for substation federate
- launch_substation.py : python script for launching the substation federate. Moreover, in this example, it is also the main federate that can launch other federates at the same time.
- federate_helper.py : some functions for managing the federate, managing co-simulation, and data recording
- my_auction.py : user-defined double-auction class for the market
- PEM_Controller.py : define classes for PEM controller.
- PEM_Coordinator.py : define classes for PEM coordinator.
- PET_Prosumer.py : define classes for PET prosumers.
- env.py : define the reinforcement learning environment for prosumers.
- ddpg.py : deep determinstic policy gradient algorithm for reinforcement learnig agents.
- (c) TE_Challenge_agent_dict.json : define the market agent and HVAC controller agents
- (c) TE_Challenge_HELICS_substation.json : define HELICS message flows for substation federate
- (o) data: a folder that save all data for post-processing
-
fed_weather : folder for weather federate
- launch_weather.py : python script for launching the weather federate
- (c) weather.dat : weather data for one specific place in one specific time period
- (c) TE_Challenge_HELICS_Weather_Config.json : weather federate configuration file
- (o) weather.log
-
my_tesp_support_api: include the modified version of TESP support API
In the docker container, type:
cd /PEMT-CoSim/demo-PEM
python3 generate_case.py
cd ./fed_substation/
python3 launch_substation.py
To visualize the experimental results after the simulation
cd /PEMT-CoSim/
python3 plotFig.py
In the docker container, type:
cd /PEMT-CoSim/demo-PET
python3 generate_case.py
cd ./fed_substation/
python3 launch_substation.py
To visualize the experimental results after the simulation
cd /PEMT-CoSim/
python3 plotFig.py
In this case, we apply RL to optimize the biding price for prosumers including the biding prices for seller and buyer, respectively. The first 48 hours are used to train the RL agents. After 48 hours, prsoumers use the trained policy to generate biding prices.
In the docker container, type:
cd /PEMT-CoSim/demo-PET-RL
python3 generate_case.py
cd ./fed_substation/
python3 launch_substation.py
To visualize the experimental results after the simulation
cd /PEMT-CoSim/
python3 plotFig.py