Driving a Time-based Simulation from MATLAB for Custom Calculations and Control



Similar documents
Microsoft Windows PowerShell v2 For Administrators

SQL Server Replication Guide

Python for Series 60 Platform

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

How To Deploy Lync 2010 Client Using SCCM 2012 R2

Basics of VTune Performance Analyzer. Intel Software College. Objectives. VTune Performance Analyzer. Agenda

Elixir Schedule Designer User Manual

SIMULATIONS OF PARALLEL RESONANT CIRCUIT POWER ELECTRONICS COLORADO STATE UNIVERSITY

Desktop, Web and Mobile Testing Tutorials

CAPIX Job Scheduler User Guide

MS Active Sync: Sync with External Memory Files

Work. MATLAB Source Control Using Git

B&K Precision 1785B, 1786B, 1787B, 1788 Power supply Python Library

Java Application Developer Certificate Program Competencies

Computational Mathematics with Python

Click to begin. Maitre'D Full System Backup & Restore

Integrated Virtual Debugger for Visual Studio Developer s Guide VMware Workstation 8.0

Eventia Log Parsing Editor 1.0 Administration Guide

Installing and Running the Google App Engine On Windows

Computational Mathematics with Python

Windows Scheduled Task and PowerShell Scheduled Job Management Pack Guide for Operations Manager 2012

MS SQL Express installation and usage with PHMI projects

MATLAB Tutorial. Chapter 6. Writing and calling functions

Data Intensive Computing Handout 6 Hadoop

Make a folder named Lab3. We will be using Unix redirection commands to create several output files in that folder.

Getting Started with STATISTICA Enterprise Programming

NiCE Log File Management Pack. for. System Center Operations Manager Quick Start Guide

Python Loops and String Manipulation

Effective unit testing with JUnit

Deploying Microsoft Operations Manager with the BIG-IP system and icontrol

Hydras 3 LT Quick Start

NASA Workflow Tool. User Guide. September 29, 2010

Data Intensive Computing Handout 5 Hadoop

Implementing Microsoft SQL Server 2008 Exercise Guide. Database by Design

Image Acquisition Toolbox Adaptor Kit User's Guide

MATLAB DFS. Interface Library. User Guide

NVIDIA CUDA GETTING STARTED GUIDE FOR MAC OS X

Table Of Contents. iii

ILTA HANDS ON Securing Windows 7

Parallel Computing using MATLAB Distributed Compute Server ZORRO HPC

MATLAB Instrument Driver

WrkSetup.exe Automated Installation (version 8.0.7)

Python Programming: An Introduction to Computer Science

Developing, Deploying, and Debugging Applications on Windows Embedded Standard 7

A Visualization System and Monitoring Tool to Measure Concurrency in MPICH Programs

Web Parser for Hyper-V Bandwidth Meter

Deploying System Center 2012 R2 Configuration Manager

Copyright. Proprietary Notice

CE 504 Computational Hydrology Computational Environments and Tools Fritz R. Fiedler

IBM Tivoli Monitoring V6.2.3, how to debug issues with Windows performance objects issues - overview and tools.

Moxa Device Manager 2.3 User s Manual

MapGuide Open Source Repository Management Back up, restore, and recover your resource repository.

Utilizing SFTP within SSIS

Snow Inventory. Installing and Evaluating

Memory Management Simulation Interactive Lab

Logging and SNMP Trap Notification Of Events. Isonas Access Control System. Release 12 June 2007

Distributed Generation and the Impact on a Distribution System. Brian Lassiter Technical Sales Engineer

For Introduction to Java Programming, 5E By Y. Daniel Liang

Connector for Microsoft Office SharePoint Server. ados.com Therefore Corporation, all rights reserved.

User Manual Gigabit Ethernet Vision Quick Start Guide

Reading and Writing Files Using the File Utilities service

Monitoring Oracle Enterprise Performance Management System Release Deployments from Oracle Enterprise Manager 12c

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

X1 Professional Client

Access Control and Audit Trail Software

BUILDER 3.0 Installation Guide with Microsoft SQL Server 2005 Express Edition January 2008

Using Network Application Development (NAD) with InTouch

Integrity Checking and Monitoring of Files on the CASTOR Disk Servers

New York University Computer Science Department Courant Institute of Mathematical Sciences

Xcode User Default Reference. (Legacy)

EVENT VIEWER IN WINDOWS 7

32-Bit Workload Automation 5 for Windows on 64-Bit Windows Systems

Visual Basic. murach's TRAINING & REFERENCE

InstallAware for Windows Installer, Native Code, and DRM

Yubico YubiHSM Monitor

ODBC Group Policy Settings

InTouch Example Description

Click Studios. Passwordstate. High Availability Installation Instructions

Technical Support Set-up Procedure

Deploying Cisco Unified Contact Center Express Volume 1

Automatic Configuration of Slave Nameservers (BIND only)

Integrating VoltDB with Hadoop

SUMMARY Moderate-High: Requires Visual Basic For Applications (VBA) skills, network file services skills and interoperability skills.

How to Push CDR Files from Asterisk to SDReporter. September 27, 2013

Glossary of Object Oriented Terms

2667A - Introduction to Programming

... connecting the Automotive Aftermarket. TEC-MessageCall. Version 1.0

Snapshot Reports for 800xA User Guide

VHDL Test Bench Tutorial

Using CertAgent to Obtain Domain Controller and Smart Card Logon Certificates for Active Directory Authentication

Exercise 1: Python Language Basics

WINDOWS PROCESSES AND SERVICES

Stretching A Wolfpack Cluster Of Servers For Disaster Tolerance. Dick Wilkins Program Manager Hewlett-Packard Co. Redmond, WA dick_wilkins@hp.

Hypercosm. Studio.

DeviceLock Management via Group Policy

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

Introduction to Synoptic

Transcription:

Driving a Time-based Simulation from MATLAB for Custom Calculations and Control Wes Sunderman Roger Dugan June 2010 The OpenDSS allows other programs to drive the simulations and perform custom calculations and control via the program s COM interface. This documentation is provided to give the reader with a basic understanding for how to drive the OpenDSS using the familiar Matlab program. Note that the OpenDSS program is provided in two forms: 1. OpenDSS.EXE: A stand-alone executable that does not have a COM interface. This is for running the program through text scripts, and for developing and testing scripts. 2. OpenDSSEngine.DLL: An in-process COM server designed to provide easy access to program features via the COM interface. This module must be registered with the Windows operating system. These two forms are functionally equivalent for distribution system analysis. The DLL version lacks some of the features available through the menus of the EXE version. More documentation on the COM interface is available in the doc folder that is provided on the Sourceforge.Net website. A direct link to the folder is: http://electricdss.svn.sourceforge.net/viewvc/electricdss/doc/ Another document at this site relevant to writing custom control algorithms and interfacing with the OpenDSS through the CtrlQueue interface is OpenDSS CtrlQueue Interface.doc. This document will outline the steps for running a time-based simulation that performs custom calculations for running a control algorithm. The examples here are for MATLAB. They can be implemented in other programming languages that support connecting to COM interfaces on the Windows platform. Similar algorithms have been developed using VBA in Microsoft Excel and Access and such languages as Python, C#, and Delphi.

Step 1: Get a connection to the OpenDSS COM interface and start the OpenDSS First, define some variables and call the DSSStartup function with a directory path name. The DSSStartup function will make this directory the home directory and then start up the OpenDSS. %Start up the DSS global DSSStartOK; global DSSObj; global DSSText; [DSSStartOK, DSSObj, DSSText] = DSSStartup(myDir); The Matlab function DSSStartUp (below) starts the OpenDSS and provides a handle to the DSS via the Obj variable, which subsequently assigned to the DSSObj variable when the function returns. The function definition for the DSSStartup is shown here: function [Start,Obj,Text] = DSSStartup(mydir) % Function for starting up the DSS % make sure we are in the proper directory cd(mydir); % %instantiate the DSS Object Obj = actxserver('opendssengine.dss'); % %Start the DSS. Without this statement, DSS will not run (gives %max_circuit=0 error). Only needs to be executed the first time w/in a %Matlab session % Define the text interface Start = Obj.Start(0); Text = Obj.Text; Note that we re instantiating the OpenDSSengine.DSS COM server via the Matlab actxvserver function, and then starting the OpenDSS by passing in the value 0 to the Start method. Then we assign the local variable Text, which is returned in the function argument list to the DSSText variable, to the Text Interface of the OpenDSS for passing in text commands. Step 2: Setting up the Time-based Simulation Now that the OpenDSS COM server is running and ready for some circuit definitions or other initial steps, we need to do some setup work before getting into the simulation loop itself. We have an OpenDSS script that includes all of the objects/classes that we need to define for the circuit on which we re interested in performing simulations. This is usually a file named master.dss that contains such things as a source definition, transformer

definitions, line definitions, capacitor definitions, loadshape definitions and load definitions. An approach that we took in setting up the master.dss file was to not include any solve statements as we wanted to let the MATLAB code control any solutions as needed. This is not absolutely necessary, but it did allow us more flexibility. The master.dss file does contain a calcvoltagebases statement to set the base voltages. This causes a solution without any Load object or other shunt elements. To the code: % compile the base circuit which does NOT have a solve in it DSSCircuit = DSSObj.ActiveCircuit; result = dss_command('compile master.dss'); First we set the DSSCircuit variable to the ActiveCircuit interface of the DSSObj. At this point, ActiveCircuit is empty because there is no circuit defined. The DSSCircuit variable gives us a handle into the Circuit interface of the OpenDSS COM server for convenience. Next, the text statement to compile the master.dss file is passed into the DSSText.Command interface using the dss_command function written in the Matlab code. Notice that the result code from the command is retrieved. Generally speaking, if the result code from dss_command is anything except 1, we want to exit the MATLAB script. We use the following general code to provide the text of the result to the user and then exit the script: % if an error returned from the DSS - return text from the DSS % %and exit this function with a failure return value if(result~= 1) disp(['error:' result]) k = 0; return Some commands s a sizeable string back from the DSSText.Result interface, even when the text command is successfully parsed and executed. For example, you can retrieve voltages and currents, etc. through this interface if they are the result of the command. Check the Error interface to distinguish whether an actual error occurred. We perform a snapshot solve and then assign a variable that will allow us easy access to all of the EnergyMeter objects in the circuit: %solve the circuit in snap shot mode result = dss_command('solve mode=snap'); DSSEnergyMeters = DSSCircuit.Meters;

For a yearly simulation, we set the mode to yearly via the text interface, and then, in this example we set the number of solutions per invocation of the Solve command and the interval (or step-size) between solutions using directly using numerical values in the Solution interface. We are telling the OpenDSS that we want only 1 solution for each time that it performs a Solve so that we can interact with the solution before advancing to the next time step. Note that the stepsize is specified in seconds when using the Solution interface directly.: result = dss_command('set mode = yearly'); DSSCircuit.Solution.Number = 1; DSSCircuit.Solution.Stepsize = 3600; If we were using the Text interface to specify the stepsize, we could have defined it in minutes or hours as well using text strings. The following are equivalent; result = dss_command('set stepsize=3600'); result = dss_command('set stepsize=3600s'); result = dss_command('set stepsize=60m'); result = dss_command('set stepsize=1.0h'); For our purposes, we want to get a variety of reports for each time step from the energymeters in the circuit. The following code sets this up: %set the case name result = dss_command('set casename=pv_var_testing9'); %set trace control to true result = dss_command('set tracecontrol = yes'); %we want an overload report result = dss_command('set overloadreport=true'); %we want a voltage exception report result = dss_command('set voltexceptionreport=true'); %we want verbose demand interval data result = dss_command('set DIVerbose=true'); %demand is true result = dss_command('set demand=true'); The last step before getting into the external solution and control loop, is to set the hour for the first simulation to zero. We can do that by setting the dblhour property in the Solutions interface through the following statement: DSSCircuit.Solution.dblHour = 0.0; The dblhour property is expecting a double-precision floating-point number.

Step 3: Time-based Simulation Loop For the time-based simulation that we re performing we first want to get a solution of the circuit. Since the simulation is in Yearly mode, the loads will follow the yearly Loadshape objects that were defined when the master.dss file was loaded along with definitions of the Load objects and all other circuit elements. In our particular loop, we want to run for a certain number of steps. At each step we want to solve the circuit, perform some calculations that are specific to our problem, update some loads or other objects in the circuit definition based on a control algorithm, and repeat the process. The Matlab code for this is shown below: while(present_step <= num_pts) DSSCircuit.Solution.Solve; t = sample_dss_values(present_step); t = do_custom_control_loop(); if (t == 0) disp('error running the pv control loop') k = 0; return %increment the present step present_step = present_step + 1; result = dss_command('closedi'); In more detail, at the top of the loop we first perform a Solve. Recall that we set the mode to Yearly, so the loads will follow their loadshapes. Had we been in Snapshot mode the loads would not follow their respective loadshapes they would have been at the defined kw output level at each solve. Next, we call a function to sample some values from the OpenDSS solution that are pertinent to our control loop. Based on those values we go into our custom control loop that, in this example, updates reactive power output of some of the loads. The custom control loop function does some solutions of its own to iterate on the reactive power output, to set it to a correct value based on the conditions of the circuit. The solutions that the custom control loop performs are NoControl solutions. These perform solutions of the circuit, but do not allow any the other OpenDSS control objects to change the state of their controlled object We increment the internal (i.e., MATLAB) step counter variable, present_step. Since we are in Yearly mode, the OpenDSS solution time variable is automatically incremented and the energy meters and monitors sampled each time Solve is executed. Since demand interval metering was turned on, the demand interval files have to be closed by the CloseDI command.