VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

16
VOLTTRON™ Integration with MATLAB, FNCS, Energy+ & GridLAB-D POORVA SHARMA August 11, 2016 1 Pacific Northwest National Laboratory VOLTTRON™ 2016 PNNL-SA-120037

Transcript of VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

Page 1: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

VOLTTRON™ Integration with MATLAB, FNCS, Energy+ & GridLAB-DPOORVA SHARMA

August 11, 2016 1

Pacific Northwest National LaboratoryVOLTTRON™ 2016

PNNL-SA-120037

Page 2: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

Goal: Incrementally Increasing Realism

► Proof of Concept

August 11, 2016 2

► Simulation Testing

► Real Deployment

Page 3: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

From Theory to Deployment: The Tools

► FNCS■ A framework for integrating simulators across

multiple domains■ Enables multi-scale modeling & simulation■ Allows for re-use of existing software AND models

► Energy+■ A whole building energy simulation program■ Supports big and complicated building models

design.

► GridLAB-D■ Distribution system simulation and analysis tool ■ Incorporates advanced modeling techniques

August 11, 2016 3

Page 4: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

Intentional Experimental Design

August 11, 2016 44

MATLAB(Controllers)

(Physical Testbed)

Simulation(Building/

Distribution Models)

VOLTTRON™Driven Agent

(MATLAB API)

VOLLTRON™Message

Bus

FNCSBridge & Actuator

FNCSMessage

Bus

VOLTTRON™Device Driver

Agent

Page 5: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

MATLAB-VOLTTRON™ Connection

Data Flow

■ Devices publish their data after specified time on VOLTTRON™ message bus.■ Driven Agent subscribes to devices mentioned in config file and forwards their data

to MATLAB application.

sends set point commands to Driven Agent.MATLAB application receives device data messages, do the computation and■

■ Driven Agent publishes set point commands to VOLTTRON™ message bus.■ These commands are received by device drivers to set point on device.

August 11, 2016 5

MATLAB(Controllers)

VOLTTRON™Driven Agent(MATLAB API)

VOLLTRON™Message

Bus

Control commands

Device status

Control commands

Device status

ZMQ socket connection

Data Flow

Page 6: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

VOLTTRON™-FNCS Connection

August 11, 2016 6

MATLAB(Controllers)

Simulation(Building/

Distribution Models)

VOLLTRON™Message

Bus

FNCSBridge & Actuator

FNCSMessage

Bus

Control commands

Device status

Control commands

Device status

VOLTTRON™Driven Agent

(MATLAB API)

► VOLTTRON™ FNCS Bridge is a FNCS client and a VOLTTRON™agent

► Bridge is accelerated – one second tick equates to 5 minute modeltime■ Want to test control code as fast as possible■ Later deploy in real-time

Page 7: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 7

Demo Run

► Left side - MATLAB■ Control application

► Output■ Receiving device data■ Sending control commands

► Right side – Run Script:■ VOLTTRON™■ FNCS ■ Energy+■ VOLTTRONTM Driven Agent

(MATLAB API)■ VOLTTRONTM FNCS Agent

► Output■ Sending device data ■ Receiving control commands

Device data

Control commands

Page 8: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 8

VOLTTRONTM – MATLAB InterfaceFile Structure

► example.m ► DrivenMatlabAgent■ drivenmatlabagent■ drivenagent.py■ matlab.py■ config_file■ setup.py

MATLAB DrivenMatlab Agent

Note: MATLAB controller and VOLTTRONTM running on different machines.

Page 9: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 9

VOLTTRONTM – MATLAB InterfaceSetup/Configuration

► Setup Python in MATLAB■ Install Python ■ Install pyzmq■ Setup Python path in MATLAB

pyversion [path/to]/python.exe

► Get example.m

MATLAB DrivenMatlab Agent► Create configuration file{ "agentid": "matlab",

"application": "drivenmatlab.matlab.Application","device": {

"campus": “CampusName","building": “BuildingName","unit": { "HEATER1": { "subdevices": [] },

"HEATER2": { "subdevices": [] }},"analysis_name": "WaterHeater_Controller"

},"mode": "ACTIVE","arguments": {

"status_stpt": "statussetpoint","temperature": "temperature","config_url": "tcp://[ip address]:5556","data_url": "tcp://[ip address]:5557","recv_timeout": 50000

},"conversion_map": {

"statussetpoint*": "bool","temperature*": "float"

},"unittype_map": {

"statussetpoint*": "On/Off","temperature*": "Farenheit"

}}

Page 10: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

VOLTTRONTM – MATLAB InterfaceSteps to run

► Start VOLTTRONTM platform./env/bin/activatevolttron –vv

► Start Actuator agentexport SOURCE=services/core/ActuatorAgentexport CONFIG=services/core/ActuatorAgent/actuator-deploy.serviceexport TAG=actuator ./scripts/core/make-agent.sh

► Start MasterDriver Agentexport SOURCE=services/core/MasterDriverAgentexport CONFIG=services/core/MasterDriverAgent/fake-master-driver.agentexport TAG=masterdriver./scripts/core/make-agent.sh

► Start DrivenMatlabAgentexport SOURCE=applications/pnnl/DrivenMatlabAgentexport CONFIG=applications/pnnl/DrivenMatlabAgent/config_waterheaterexport TAG=matlab./scripts/core/make-agent.sh

► Run MATLAB example controllerexample.m

August 11, 2016 10

Page 11: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 11

VOLTTRONTM – MATLAB InterfaceData Flow

► Setup sockets

► Send configuration request

► Receive configuration

► Setup socket (matlab.py)

► Receive configuration request

► Send configuration

DrivenMatlabAgentMATLAB

Page 12: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 12

VOLTTRONTM – MATLAB InterfaceData Flow (cont.)

► Wait for device data

► Receive device data

► Send control command

► Subscribe to device data

► Send device data

► Receive control commands and call Actuator’s set point

DrivenMatlabAgentMATLAB

Page 13: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 13

VOLTTRONTM – FNCS Interface

► FncsActuatorProxy.py► It is an Actuator agent specific to

FNCS co simulator tool.

► FNCS_Volttron_Bridge.py► Communication bridge between

simulation and Actuator agent

FNCS – Simulation BridgeFNCS Actuator Agent

Simulation(Building/

Distribution Models)

VOLLTRONMessage

Bus

FNCSActuator

FNCSMessage

BusFNCSBridge

Page 14: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 14

VOLTTRONTM – FNCS Interface Configuration

► FNCS_Volttron_Bridge.py

{“simulation_run_time" : "1d","heartbeat_period" : 10,"heartbeat_multiplier" : 15,"fncs_zpl" : {

"name" : "FNCS_Volttron_Bridge","time_delta" : "150s","broker" : "tcp://localhost:5570","values" : {“point_name" : {"topic" : “device_name/point_name","default" : "0","type" : "double","list" : "false"},…}},

"remote_platform_params" : {"vip_address": "tcp://[ipaddress]","port": 55055,"agent_public": “[key]","agent_secret": “[key]","server_key": “[key]" }}

FNCS – Simulation BridgeFNCS Actuator Agent

Page 15: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

VOLTTRONTM – FNCS InterfaceSteps to Run

► Start VOLTTRONTM platform./env/bin/activatevolttron –vv

► Start FNCS_Volttron_Bridge & FncsActuatorProxypython FNCS_Volttron_Bridge.pypython FncsActuatorProxy.py

► Run Simulation Energy+ or Gridlab-D

► Start FNCS brokerfncs_broker 2

► Start DrivenMatlabAgentexport SOURCE=applications/pnnl/DrivenMatlabAgentexport CONFIG=applications/pnnl/DrivenMatlabAgent/config_waterheaterexport TAG=matlab./scripts/core/make-agent.sh

► Run MATLAB example controllerexample.m

August 11, 2016 15

Page 16: VOLTTRON Integration with MATLAB, FNCS, Energy+ and GridLAB-D

August 11, 2016 16

VOLTTRONTM – FNCS InterfaceData Flow

► Receive device data, publish on VOLTTRON bus

► Receive control commands, publish on FNCS bus

► Publish device data

► Receive control command forward to simulation

FNCS – Simulation BridgeFNCS Actuator Agent