Electric Power System State Estimation
Electric Power System State Estimation
ESTIMATION
Project Work Report
BACHELOR OF TECHNOLOGY
in
ELECTRICAL AND ELECTRONICS ENGINEERING
by
i
DECLARATION
We hereby declare that the Project Work Report entitled Electric Power System State
Estimation which is being submitted to the National Institute of Technology Karnataka,
Surathkal for the award of the Degree of Bachelor of Technology in Electrical and
Electronics Engineering is a bonafide report of the work carried out by us. The material
contained in this Project Work Report has not been submitted to any University or Institution for
the award of any degree.
Date: 28/04/2011
ii
DEPARTMENT OF ELECTRICAL AND ELECTRONICS
ENGINEERING
NATIONAL INSTITUTE OF TECHNOLOGY KARNATAKA,
SURATHKAL
CERTIFICATE
This is to certify that the B.Tech Project Work Report entitled “Electric Power
System State Estimation” submitted by:
1) 07EE04 Aditya S
2) 07EE33 Milind R
3) 07EE37 Narayanan S
as the record of the bonafide work carried out by them, is accepted as the B.Tech
Project Work Report submission in partial fulfillment of the requirements for the
award of degree of Bachelor of Technology in Electrical and Electronics
Engineering.
iii
ACKNOWLEDGEMENT
iv
ABSTRACT
State estimation is the process of determining an acceptable probable future state of a system
in the face of noisy and incomplete output measurements. State Estimation takes all the
telemetry seen so far and uses it to determine the underlying behavior of the system at any
point in time. It includes fault detection and isolation and continuous system parameter
estimation.
In the power transmission network, substation buses are equipped with measuring devices to
sense voltage at, and real power, reactive power and current through every line from that bus.
All these are relayed to load dispatch centers. As only a fraction of these measurements are
essential for analysis of the power system, the remaining measurements are harnessed to
generate confidence values that determine the acceptability of a measurement.
The very probabilistic nature of state estimation makes it ideally suited to be implemented by
neural networks. The neural network is tasked with optimizing the parameters used for
statistical processing of noisy values. The learning element of the neural network allows the
state estimator to assign weights to the memory – ensuring that better estimates are
considered.
v
TABLE OF CONTENTS
D E C L A R A T I O N............................................................................................................................... ii
CERTIFICATE .......................................................................................................................................... iii
ACKNOWLEDGEMENT ......................................................................................................................... iv
ABSTRACT ................................................................................................................................................. v
INTRODUCTION....................................................................................................................................... 2
1.1 ELECTRICITY IN INDIA’S GROWTH ........................................................................................... 2
1.2 MEASUREMENTS & MEASURING DEVICES.............................................................................. 2
1.3 SCADA AND THE SMART GRID ..................................................................................................... 3
1.4 TRANSMISSION AND DISTRIBUTION .......................................................................................... 4
1.5 STATE ESTIMATION ........................................................................................................................ 5
LITERATURE SURVEY ........................................................................................................................... 6
BASIC CONCEPTS AND DESIGN .......................................................................................................... 7
3.1 STATE ESTIMATION ........................................................................................................................ 7
3.1.1 TOPOLOGY PROCESSORS ........................................................................................................... 9
3.1.2 OBSERVABILITY ANALYSIS ..................................................................................................... 12
3.1.3 STATE ESTIMATION SOLUTION ............................................................................................. 14
3.1.4 BAD DATA PROCESSING ............................................................................................................ 15
IMPLEMENTATION AND RESULTS.................................................................................................. 16
CONCLUSION AND FUTURE SCOPE ................................................................................................ 22
REFERENCES .......................................................................................................................................... 23
APPENDIX A: CODE SNIPPET ............................................................................................................ 25
vi
1
CHAPTER - 1
INTRODUCTION
At present, SCADA systems are hardware PC based and possess a distributed architecture
through LAN. Open (non-proprietary) Databases like Oracle, Sybase etc are used. All the user
terminals are workstations. SCADA systems in the near future will involve novel concepts like
parallel processing, grid computing for large data storage, fault tolerance systems.
A smart grid, also known as an intelligent grid is an electricity network that employs
digital technology. It delivers electricity using two-way digital communications which could
save energy; reduce costs and increase reliability and transparency if the risks inherent in
executing massive information technology projects are avoided. This innovation is planned to
overlay the ordinary grid with an information and net metering system that uses smart meters.
Open loop controls and human intervention inadequate for real time control actions
Fast acting phenomena such as instability – angular/voltage requires closed loop controls
which detects and controls
Online monitoring of parameters on substation equipment and immediate communication for
corrective maintenance Warehousing and data mining to facilitate MIS on maintenance
plans, resources deployment, disturbance analysis etc.
Event based architecture to direct actions based on the event information for corrective
action.
3
1.4 TRANSMISSION AND DISTRIBUTION
The electricity is transported to load locations from a power station to a transmission subsystem.
Therefore we may think of the transmission system as providing the medium of transportation
for electric energy. The transmission system may be subdivided into the bulk transmission
system and the sub-transmission system. The functions of the bulk transmission are to
interconnect generators, to interconnect various areas of the network, and to transfer electrical
energy from the generators to the major load centers. This portion of the system is called "bulk"
because it delivers energy only to so-called bulk loads such as the distribution system of a town,
city, or large industrial plant. The function of the sub-transmission system is to interconnect the
bulk power system with the distribution system. Transmission circuits may be built either
underground or overhead. Underground cables are used predominantly in urban areas where
acquisitions of overhead rights of way are costly or not possible. They are also used for
transmission under rivers, lakes and bays. Overhead transmission is used otherwise because, for
a given voltage level, overhead conductors are much less expensive than underground cables.
The transmission system is a highly integrated system. It is referred to the substation equipment
and transmission lines. The substation equipment contains the transformers, relays, and circuit
breakers. Transformers are important static devices which transfer electrical energy from one
circuit with another in the transmission subsystem. Transformers are used to step up the voltage
on the transmission line to reduce the power loss which is dissipated on the way. A relay is
functionally a level-detector; they perform a switching action when the input voltage (or current)
meets or exceeds a specific and adjustable value. A circuit breaker is an automatically operated
electrical switch designed to protect an electrical circuit from damage caused by overload or
short circuit. A change in the status of any one component can significantly affect the operation
of the entire system. There are three possible causes for power flow limitations to a transmission
line. These causes are thermal overload, voltage instability, and rotor angle instability. Thermal
overload is caused by excessive current flow in a circuit causing overheating. Voltage instability
is said to occur when the power required to maintain voltages at or above acceptable levels
exceeds the available power. Rotor angle instability is a dynamic problem that may occur
following faults, such as short circuit, in the transmission system. It may also occur tens of
seconds after a fault due to poorly damped or undamped oscillatory response of the rotor motion.
4
1.5 STATE ESTIMATION
State estimation is the process of determining an acceptable probable future state of a system in
the face of noisy and incomplete output measurements. Proposed by Prof. Fred Schweppe et al at
the MIT EECS division, State Estimation takes all the telemetry seen so far and uses it to
determine the underlying behavior of the system at any point in time. It includes fault detection
and isolation and continuous system parameter estimation.
In the power transmission network, substation buses are equipped with measuring devices to
sense voltage at, and real power, reactive power and current through every line from that bus. All
these are relayed to load dispatch centers. As only a fraction of these measurements are essential
for analysis of the power system, the remaining measurements are harnessed to generate
confidence values that determine the acceptability of a measurement.
The very probabilistic nature of state estimation makes it ideally suited to be implemented by
neural networks. The neural network is tasked with optimizing the parameters used for statistical
processing of noisy values. The learning element of the neural network allows the state estimator
to assign weights to the memory – ensuring that better estimates are considered.
5
CHAPTER - 2
LITERATURE SURVEY
In [1], A. Monticelli introduces and describes the basic concepts of state estimation.
Being an invited paper on the subject, it is a comprehensive treatise, and functions as a base for
most of the ideas in this project, in general.
[2] provides an in-depth perspective on Topology Processing. The need for dynamic
topology processing is recognized, and they describe their method in considerable detail. By
using these ideas as a spring board, the idea of using P-buses emerged as an effective way to
reduce the amount of data to be processed on each resample.
We turned to [3] [7] [8] for the handling of forests of full rank, and to obtain maximal
observable subnetwork.
6
CHAPTER – 3
BASIC CONCEPTS AND DESIGN
Power system state estimation (PSSE) is a technique for determining the system state from a
model of the power system network and redundant system measurements. The ability of the state
estimator to achieve a high level of efficiency and numerical robustness is of paramount
importance in today’s eclectic utility industry.
Often an engineer needs to estimate system states in order to implement a state feedback
controller. For example, the electrical engineer needs to estimate the winding currents of a
motor in order to control its position. The aerospace engineer needs to estimate the attitude of
a satellite in order to control its velocity. The economist needs to estimate economic growth
in order to control unemployment. The medical doctor needs to estimate blood sugar levels in
order to control heart and respiration rates.
Often an engineer needs to estimate the system states because those states are interesting in
their own right. For example, if an engineer wants to measure the health of an engineering
system, it may be necessary to estimate the internal condition of the system using a state
estimation algorithm. An engineer might want to estimate satellite position in order to more
7
intelligently schedule future satellite activities. An economist might want to estimate
economic growth in order to make a political point. A medical doctor might want to estimate
blood sugar levels in order to evaluate the health of a patient.
Observable islands are handled with full state estimation including bad data analysis. State
estimation can be extended to the rest of the system of interest through the addition of
pseudo-measurements based on load prediction and generation scheduling. In executing state
estimation for this augmented system, however, care must be taken to avoid corrupting the
states estimated from telemetry data. Hence, the state estimator is used to build the model for
the observable part of the network and optionally to attach a model of the unobservable part
to it. With adequate redundancy level, state estimation can eliminate the effect of bad data
and allow the temporary loss of measurements without significantly affecting the quality of
the estimated values. State estimation is mainly used to filter redundant data, to eliminate
incorrect measurements, and to produce reliable state estimates, although, to a certain extent,
it allows the determination of the power flows in parts of the network that are not directly
metered. Not only do traditional applications such as contingency analysis, optimal power
flow, and dispatcher training simulator rely on the quality of the real-time network model
obtained via state estimation, but the new functions needed by the emerging energy markets
will do so even more.
8
State Estimation is not a standalone process. It requires preprocessing, which is also required for
other power system applications and simulations. Conveniently expressed as a set of sequential
steps, the constituent elements of a state estimation package are:
The power grid consists of many devices which can be broadly categorized into Generators,
Active loads, Passive loads, Transformers, Circuit breakers, Transmission lines, and Shunt
components. Most power systems employ the 1.5 CB protection scheme – which means every 2
devices are connected to the system through 3 CBs. The status of these CBs influences the
connection of these devices to the network, and hence the way they interact with and influence
the network – thus determining the network topology. The Topology processor should thus be
able to provide the electrical equivalent representation of the physical connections i.e. the
bus/branch oriented model.
The following basic results are expected from a conventional topology processor
Network Configuration – establishing the energized network islands and the busses that belong
to them.
10
substations are associated with terminals of branch devices (e.g., transmission lines,
transformers, phase shifters, and series devices), shunt devices (e.g., capacitors, reactors,
synchronous condensers, static VAr compensators, loads and generators), and metering devices
(e.g., power and current flow meters, power and current injection meters, and voltage magnitude
meters) as well. The connection of these devices in a bus/branch model requires the
determination of the network buses. Bus section processing consists of merging bus sections of a
bus section group into one or more network buses (buses of the bus/branch network model).
Once such network buses are formed, data structures (pointers and links) are built to associate
them with branch and shunt devices.
In the tracking mode, the NTP updates the parts of the power network affected by status changes.
Only bus section groups where changes have occurred are processed and the associated data
structures are updated accordingly. Switching device status changes can modify both the way bus
sections are grouped into network buses and the association of branch and shunt devices with
network buses. The location of metering devices may be affected as well. Thus, the new data
structures relating network buses to various devices (branch, shunt, and metering) are compared
with the corresponding structures saved from the previous run. Simple plausibility checks are
then performed for changed bus section groups using Kirchhoff's laws. There are cases in which
changes in a bus section group also affect network connectivity (e.g., cases when a bus splits or a
branch device switches from one bus to other). In these cases, the data structures describing
network connectivity and network islands are updated by NTP in tracking mode. The benefits of
the tracking mode are not limited to the topology processor itself: in the case of minor changes,
or when no changes occur, matrix structures (including the optimal pivoting order) used in other
applications can be reused up to a certain point, although eventually the cumulative effect of
changes will require a complete matrix refactorization.
Depending on the results of the state estimation, bad analog/status data can be removed or, if
redundancy does not permit a safe decision, the suspect area is kept in the bus-section/switching-
device model level for further evaluation during state estimation of the entire network.
11
3.1.2 OBSERVABILITY ANALYSIS
The output of the topology processor is used to determine the feasibility of the process of State
Estimation. There are mathematical criteria to determine if the measurement set has sufficient
number of variables for the SE block to function. Sometimes only certain parts of a power
system are found to be observable. These are called observable islands. Each Observable island
will contain a slack bus. The unobservable parts will have to be supplemented with additional
measurement devices. Observability analysis also makes it possible to find the best points for
introducing the additional meters. Also it is possible to introduce calculated values as meters in
unobservable areas, called pseudo measurements. Observability analysis also deals with the
extent of error introduced due to pseudo measurements.
If there are enough measurements and they are well distributed throughout the network in such a
way that state estimation is possible, the network is said to be observable. If a network is not
observable, it is still useful to know which portion has a state which can be estimated, i.e., it is
important to determine the observable islands. In the observable parts of a network, measurement
redundancy is defined as the ratio of the number of measurements to the number of states; in
most practical cases the redundancy is in the range 1.7–2.2. A critical measurement is a
nonredundant measurement, i.e., a measurement that when removed turns the network
unobservable. There are three principal types of algorithms for observability analysis:
topological; numerical; and hybrid.
The inclusion of breakers, switches, zero impedance branches, and branches with unknown
impedances in the generalized state estimation model has motivated the following extended
definitions of islands and observable islands.
An island is a contiguous part of a network with bus sections as nodes and lines, transformers,
open switches, closed switches, and switches with unknown status as branches.
An observable island is an island for which all branch flows can be calculated from the available
measurements independent of the values adopted for reference pseudomeasurements.
12
Topological Observability Analysis
The concept of topological observability was originally proposed for networks represented by
bus/branch models and is linked to the idea of maximal spanning tree, which is a tree that
contains every node in the graph representing a network. To each branch of a maximal spanning
tree is assigned a measurement. A measurement assignment satisfies:
1) different branches are always assigned to different measurements; 2) if the flow in a branch is
measured the branch is assigned to that measurement; 3) a branch with unmeasured flow is
assigned to an injection measurement at a node incident to the branch. Although it is generally
agreed that the topological approach can be extended to handle the additional states and
pseudomeasurements of the generalized state estimation, further research is still needed (The
same can be said regarding the consideration of current magnitude measurements.)
Topological observability does not necessarily guarantee solvability of the state estimation
problem.
The numerical observability algorithm below was designed to handle networks that are totally or
partially represented at the physical level. The basic modifications regarding the algorithm for
networks modeled at the bus/branch level is the addition of new state variables and new pseudo
measurements. The extended algorithm is also based on the presence of zero pivots that may
occur during triangular factorization of the gain matrix. The difference is that the gain matrix
will include additional information as well as new states, and since power flows are also state
variables, zero pivots may occur in connection with these variables as well. When this happens,
state variables corresponding to these zero pivots are added as pseudomeasurements with
arbitrary values, just as in the bus/branch model. Irrelevant measurements are again identified,
i.e., injection measurements with incident branches with estimated flows being a function of the
arbitrary values assigned to the pseudo measurements added (nonzero flows) are considered
irrelevant.
13
3.1.3 STATE ESTIMATION SOLUTION
The core of the system, it derives the state of the system from the given electrical network. In
electrical systems, the state is usually a vector of Potentials (V) and Phase angles (delta) w.r.t the
slack bus. Since the phase angle of the slack bus is defined to be zero, the order of a state vector
is 2n – 1, where n is the number of buses in an observable island. Using this state, all the system
values are determined.
State estimation program is a mathematical tool which based on the network connectivity
information, network parameters, the analog measurement which is redundant in nature,
estimates the state of the given power system i.e., computes the voltage magnitude and angle at
each and every bus.
Voltage magnitude at all buses can be easily measured. Angle measurement at all buses is
extremely difficult as the angle is relative in nature and simultaneous voltage waveform at each
bus is required at one point.
( )
( )
( )
( )
14
Z: Measurement vector
G(x). ε = HT (x).W.ε
With all the properties that are both predicted as well as measured, we are now in a position to
find errors and hence determine outliers from the expected value. Generally the cause of a gross
error would be a misconnection, such as a phase sequence error; or an instrument defect; or bad
maintenance. Bad data processing quickly detects suspicious measurements which can be
corrected for better telemetry.
An essential requirement of the Bad data processing is redundancy of a sufficiently high degree.
The greater the amount of redundant data, with greater certainty can a suspicious measurement
be identified correctly.
It may occur that the errors affecting state estimates are not compatible with their standard
deviations. Most frequently, this happens due to the presence of bad data among the measured
quantities. Alternatively, the proposed model may be unfit to explain the measured quantities. In
either case, it is important to determine a plausible explanation, or a set of plausible explanations,
for the observed data inconsistency.
15
CHAPTER - 4
IMPLEMENTATION AND RESULTS
Our topology processor:
Our literature survey revealed that this component has many different implementations, with few
commonalities. One important aspect was how it dealt with a changing electrical network. Those
that required complete refactorization of the entire jacobian, are called static state estimators.
They suffer from a serious disadvantage in real power transmission networks when several
changes are taking place during a short time, due to the already considerable amount of
computation involved with factorization. Dynamic topology processors (or tracking topology
processors) overcome this problem, using a variety of techniques to minimize the processing
required for each change.
Input:
The input to our topology processor is in the form of files. They are:
One contains a list of devices in the network. A device inventory. (show structure).
Another contains the device terminal connections listing one at a time. (show struct).
Both directions are included (if A-> B, then B-> A) will be present too. Connection Data.
Output:
The output of our topology processor is stored in memory as a set of data structures.
Admittance Matrix (Ybus)
Power injection vector
Line data – contains similar information to Ybus, but in a different form.
Our novel topology processor uses a variety of data structures to efficiently parse the network.
The important ones are described below:
16
Devices:
1) Devices
Each device has some unique properties of its own, apart from the basic ones.
class device
{
public:
dev_type type;
int num;
int mva;
std::string description;
};
};
2) Node
Each device has either 1 or 2 terminals. To identify a particular terminal of a particular
device, we use node.
Code:
class node
{
public:
int terminal;
device* tdev;
bool operator==(const node& b) const;
18
};
The reason we have used a pointer member to device is that many different terminals are
part of the same device. Hence to emphasize the uniqueness of the device among its set
of terminals, a pointer is used.
3) Device Connection
The fundamental unit of connections in our project is a device connection. It denotes the
electrical connection between two different nodes.
CB#1.1-TR#2.2
The two nodes before and after the hyphen are called F (from) and T (to) respectively. As
electrical AC connections are bidirectional, we include F-T and T-F also. The reason for
this is that the search operation requires a hash map, and retaining both variations makes
it simple to search using the hash map.
class dev_conn
{
public:
node F;
node T;
dev_conn(node Fa, node Ta) : F(Fa),T(Ta);
bool operator==(const dev_conn& b) const;
dev_conn operator~() const;
};
19
Mechanism:
Circuit breakers are the most important for topology processing. They determine a
network topology and configuration. Our observation is that buses generally have a
number of circuit breakers connected, to retain flexibility in the energisation. The 1.5 CB
scheme is one other reason for this practice.
Taking advantage of this fact, we have designated those connections between Circuit
Breakers as Physical Buses or Pbuses. These Pbuses are generated by the function
getPbus. They are identified and copied separately, to be handled separately. These
Pbuses do not contain equivalent connections (~dev_conn). These equivalent connections
are checked for existence, but not copied. By this method we can cut down on the number
of connections to be processed when a topology change is to take place.
The next step is the generation of Electrical buses (or Ebuses). An Ebus is a list of nodes
all of which are found to be at the same electrical potential. Any two nodes can be
compared using the function checkElecConn. It checks for the following conditions:
The Ebuses, processed, will contain some terminals whose device’s other terminal is also
part of the same one. These are inaccessible from outside and completely trivial. These
are removed by the function ebusCollapse.
Once the Ebuses are slimmed down, each CB terminal that has survived the collapse is
one of the terminals of an Electrical bus. The next step is changing all bus CB terminal
references into Ebus references. Ebus terminal numbers are simply the list item number
of the CB terminal that the Ebus contains. The existing data is converted to this more
20
usable form by the function dataPurifier. CB-CB connections are omitted. Connections
between non-CB devices are copied as-is.
The data is now ready for the final processing, to convert into an electrical network. This
stage results in the formation of
Ybus
Pinj
Vector<line>
If the link terminates in an Ebus, then the admittance is found, and is assigned to
Ybus[starting_ebus][ending_ebus]. It is also added Ybus[starting_ebus][starting_ebus].
The injection (if any) is added to Pinj[starting_ebus].
If the link does not terminate in an ebus, then the admittance is added to
Ybus[starting_ebus][starting_ebus] only. These are in accordance with the definition of
the Admittance Matrix.
21
CHAPTER - 5
CONCLUSION AND FUTURE SCOPE
In this project, we have implemented Observability using algorithms in [3], [6], [7], [8]. We
intend to make a wider study of the techniques available and make a more robust
implementation. While developing our new topology processor, we ran into problems of
unprecedented difficulty and requiring uncommon insight. Bad Data processing is a statistical
technique which examines the state estimator output and finds the error between the seen output
and expected output. Weights are assigned to each of these measurements based on their
deviation from the expected value as per the state estimator. These weights are constantly
updated and the measurements with higher weights are considered.
22
REFERENCES
[1] A. Monticelli, Fellow, IEEE, “Electric Power System State Estimation”, Proceedings
of the IEEE, vol. 88, no. 2, February 2000.
[2] Mauro Prais, Anjan Bose, Department of Electrical Engineering, Arizona State
University, “A Topology Processor That Tracks Network Modifications Over Time”, IEEE
Transactions on Power Systems, Vol. 3, No. 3, August 1988.
[6] Nucera, R.R.; Gilles, M.L.; ABB Power Autom. Inc., Palo Alto, CA, “Observability
analysis: a new topological algorithm”, Power Systems, IEEE Transactions on May 1991
[9] F.C. Schweppe and J. Wildes, "Power System Static State Estimation, Part I: “Exact
Model", IEEE Trans. on Power App. Syst., Vol. PAS-89, pp. 120-125, Jan. 1970.
[10] “Optimal State Estimation: Kalman, H-infinity, and Nonlinear Approaches”: Dan
Simon, Professor, Cleveland State University, Department of Electrical and Computer
Engineering.
[11] “Power System State Estimation and Contingency Constrained Optimal Power Flow -
A Numerically Robust Implementation” by Slobodan Paji´c, A Dissertation Submitted to the
Faculty of the Worcester polytechnic institute in partial fulfillment of the requirements for
the Degree of Doctor of Philosophy in Electrical and Computer Engineering.
23
[12] “High Voltage Engineering” - J R Lucas 2001
24
APPENDIX A: CODE
File: Definitions.hpp
#include <iostream>
#include <vector>
#include <list>
#include <complex>
#include "EnumString.h"
class device
{
public:
25
dev_type type;
int num;
int mva;
std::string description;
static device* find(dev_type typ, int numb)
{
extern std::vector<device*> inventory;
std::vector<device*>::iterator device_iter;
for(device_iter=inventory.begin();device_iter!=inventory.end();device_iter++)
{
if((*device_iter)->type == typ && (*device_iter)-> num == numb)
return *device_iter;
}
if(device_iter == inventory.end())
{
myexception devicenotfound;
throw devicenotfound;
}
}
int nTerm()
{
switch(type)
{
case G:
case AL:
case PL:
case SI:
return 1;
break;
case TR:
case TL:
case CB:
return 2;
break;
case T3R:
return 3;
break;
default:
return 0;
}
}
class node
{
public:
26
int terminal;
device* tdev;
bool operator==(const node& b) const
{
return tdev==b.tdev && terminal==b.terminal ? true : false;
}
node get_other_term()
{
if(tdev->nTerm() == 2)
{
node similar;
similar.tdev = tdev;
similar.terminal = (terminal == 1 ? 2 : 1);
return similar;
}
}
class dev_conn
{
public:
node F;
node T;
dev_conn(node Fa, node Ta) : F(Fa),T(Ta) {} //Needed due to
reference having to be initialized at definition
bool operator==(const dev_conn& b) const
{
return F==b.F && T==b.T ? true : false;
}
dev_conn operator~() const
{
dev_conn b(T,F);
return b;
}
};
};
class line
{
public:
int num;
elec_bus *Fbus,*Tbus;
std::complex<float> impedance;
};
class adjacency
{
public:
};
typedef std::list<std::list<node> >::iterator lististnode_itr;
typedef std::list<node>::iterator listnode_itr;
28
File: EnumString.h
#ifndef ENUMSTRING_HEADER
#define ENUMSTRING_HEADER
/* Usage example
// WeekEnd enumeration
enum WeekEnd
{
Sunday = 1,
Saturday = 7
};
#include <string>
#include <map>
#include <cassert>
// Helper macros
#define Begin_Enum_String(EnumerationName) \
template <> struct EnumString<EnumerationName> : \
public EnumStringBase< EnumString<EnumerationName>, EnumerationName > \
{ \
static void RegisterEnumerators()
// {
#define Enum_String(EnumeratorName) \
29
RegisterEnumerator( EnumeratorName, #EnumeratorName );
// }
#define End_Enum_String \
}
protected:
// Constructor / Destructor
explicit EnumStringBase();
~EnumStringBase();
private:
// Copy Constructor / Assignment Operator
EnumStringBase(const EnumStringBase &);
const EnumStringBase &operator =(const EnumStringBase &);
// Functions
private:
static AssocMap &GetMap();
protected:
// Use this helper function to register each enumerator
// and its string representation.
static void RegisterEnumerator(const EnumType e, const std::string &eStr);
public:
// Converts from an enumerator to a string.
// Returns an empty string if the enumerator was not registered.
static const std::string &From(const EnumType e);
// Function definitions
// If this is the first time we're accessing the map, then populate it.
if( bFirstAccess )
{
bFirstAccess = false;
D::RegisterEnumerators();
assert( !assocMap.empty() );
}
return assocMap;
}
// Keep searching and see if we find another one with the same value
typename AssocMap::const_iterator j( i );
for(++j; j != GetMap().end(); ++j)
if( (*j).second == e )
break;
// If we found another one with the same value, we can't do this conversion
if( j != GetMap().end() )
break;
#endif
32
File: inventory_read.cpp
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include "definitions.hpp"
#include "EnumString.h"
vector<active_device> listActDev;
vector<passive_device> listPassDev;
vector<breaker> listBreaker;
vector<elec_bus> listElecbus;
string conn;
getline(connreader,conn);
while(connreader.good())
{
getline(connreader,conn);
if(conn.empty()) break;
//cout<<conn;
stringstream cba(conn);
string aa;
//Device Type
getline(cba,aa,',');
dev_type a=UNKNOWN;
remove(aa.begin(), aa.end(),' '); //trim space
assert(EnumString<dev_type>::To(a,aa) != 0);
if(a==UNKNOWN) break;
dev_type thetype = a;
//Device number
getline(cba,aa,',');
int thenum=atoi(aa.c_str());
//MVA
getline(cba,aa,',');
int themva = atoi(aa.c_str());
//Description
getline(cba,aa,',');
string thedescr = aa;
33
//Special Characteristic 2 : Imaginary component
getline(cba,aa,',');
string spchar2 = aa;
switch(thetype)
{
case AL:
case PL:
case G:
{
active_device
curra(thetype,thenum,themva,thedescr,spchar,spchar2);
listActDev.push_back(curra);
break;
}
case TL:
case TR:
case SI:
{
passive_device
currb(thetype,thenum,themva,thedescr,spchar,spchar2);
listPassDev.push_back(currb);
break;
}
case CB:
{
breaker currc(thenum,themva,thedescr,spchar);
listBreaker.push_back(currc);
break;
}
}
}
connreader.close();
for(vector<passive_device>::iterator i= listPassDev.begin() ; i !=
listPassDev.end(); i++)
inventory.push_back(&(*i));
34
File:devconn_read
#include <sstream>
#include <string>
#include <fstream>
#include <algorithm>
#include "definitions.hpp"
getline(cba,aa,',');
b=atoi(aa.c_str());
node da;
da.tdev = curr;
da.terminal = b;
//T
getline(cba,aa,',');
remove(aa.begin(), aa.end(), ' '); //trim space
EnumString<dev_type>::To(a,aa);
if(a==UNKNOWN) break;
getline(cba,aa,',');
b=atoi(aa.c_str());
//ca.type = a;
//ca.num = b;
device* curra = device::find(a,b);
getline(cba,aa);
b=atoi(aa.c_str());
node ea;
ea.tdev = curra;
ea.terminal = b;
dev_conn fa(da,ea);
data.push_back(fa);
}
connreader.close();
}
36
File:GetYbus.cpp
#include <complex>
#include <list>
#include <map>
#include "definitions.hpp"
while(followLink(curr_conn_to,injection,Z,termInWhichEbus,lineNum))//////check
{
node next_node = curr_conn_to.get_other_term();
curr_conn_to = newerdata[next_node];
}
//How to ensure that SI is added to Y11 only, and not any other Y1n?
39
File:dataPbus.cpp
#include <fstream>
#include <algorithm>
#include "definitions.hpp"
#include "EnumString.h"
40
File: getEbus.cpp
#include <iterator>
#include <list>
#include <map>
#include <fstream>
#include "definitions.hpp"
41
}
in1 = Ebus.end();
if(!added)
{
Electricalbus.push_back(curr.F);
Electricalbus.push_back(curr.T);
Ebus.push_back(Electricalbus);
Electricalbus.clear();
}
}
}
node Ebusbelong(list<list<node> > ebus,node CBa) // Returns the Ebus the CB terminal
belongs to
{
bool found=false;
int aba = 0;
for(lististnode_itr i = ebus.begin();i != ebus.end(); i++)
{
aba++;
int abb = 0;
42
for(listnode_itr j = i->begin();j != i->end(); j++)
{
abb++;
if(*j == CBa)
{
node belongnode;
belongnode.tdev = device::find(EB,aba);//j->tdev;
belongnode.terminal = abb;
return belongnode;
}
}
}
if(!found)
{
node nonode;
nonode.terminal =0;
return nonode;
}
}
}
}
for(listnode_itr j=i->begin();j!=i->end();j++)
ebusout<<(*j)<<endl;
ebusout<<endl;
}
ebusout.close();
}
45
File: observability.cpp
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include "definitions.hpp"
46
File:main.cpp
#include <string>
#include <list>
#include <exception>
#include <map>
#include "definitions.hpp"
#include "EnumString.h"
vector<device*> inventory;
vector<dev_conn> data,Pbus; // Master list of all connections.
map<node,node> newerdata;
int main()
{
string inv_filename = "device_inventory_final.csv";
getDeviceList(inv_filename,inventory);
string conn_filename = "dev_conn_final.csv";
connections_populate(conn_filename,data);
getPbus(data,Pbus);
printPbus(Pbus,"pbuses.txt");
pbustoebus(Pbus,Ebus);
addEbuses(Ebus,inventory);
exportEbus(Ebus,"ebuses_unslimmed.txt");
ebus_collapse(Ebus);
outerify(Ebus);
exportEbus(Ebus,"ebuses_slimmed.txt");
purifier(data,Ebus,newerdata);
formElectricalNetwork(Ebus,newerdata,Ybus,Pinj,listLines);
exportLines(listLines,"linelist.csv");
}
47
std::ostream& operator<<(std::ostream& out, node a)
{
out<<EnumString<dev_type>::From(a.tdev->type)<<","<<a.tdev->num<<","<<a.terminal;
return out;
}
48
APPENDIX B: OUTPUT SCREEN
Data:
Device_inventory.csv
Device Device Real Imag
Type Number MVA Description SpChar SpChar
G 1 500 GENERATOR 1.3 0.13
CB 1 750 BREAKER 1
CB 2 750 BREAKER 1
CB 3 750 BREAKER 1
CB 4 750 BREAKER 1
CB 5 750 BREAKER 1
CB 6 750 BREAKER 1
CB 7 750 BREAKER 1
CB 8 750 BREAKER 1
CB 9 750 BREAKER 1
CB 10 750 BREAKER 1
CB 11 750 BREAKER 1
CB 12 750 BREAKER 0
CB 13 750 BREAKER 0
CB 14 750 BREAKER 1
CB 15 750 BREAKER 1
CB 16 750 BREAKER 1
CB 17 750 BREAKER 1
49
CB 18 750 BREAKER 1
TL 1 500 LINE 0.05 0.32
TL 2 500 LINE 0.05 0.32
TL 3 500 LINE 0.05 0.32
TL 4 500 LINE 0.05 0.32
G 2 500 GENERATOR 1.3 0.13
G 3 500 GENERATOR 1.3 0.13
TR 1 500 TRANSFORMER 0.01 0.1
TR 2 500 TRANSFORMER 0.01 0.1
TR 3 500 TRANSFORMER 0.01 0.1
AL 1 350 MOTOR 1 0.2
AL 2 250 MOTOR 0.8 0.3
Dev_conn_final.csv
G 1 1 CB 1 1
CB 1 1 G 1 1
CB 1 2 CB 2 1
CB 1 2 CB 9 1
CB 2 1 CB 1 2
CB 2 1 CB 9 1
CB 2 2 TR 1 1
TR 1 1 CB 2 2
TR 1 2 CB 3 1
CB 3 1 TR 1 2
CB 3 2 TL 1 1
TL 1 1 CB 3 2
TL 1 2 CB 4 1
CB 4 1 TL 1 2
CB 4 2 TR 2 1
TR 2 1 CB 4 2
TR 2 2 CB 5 1
CB 5 1 TR 2 2
CB 5 2 CB 6 1
CB 5 2 CB 7 2
CB 5 2 CB 8 1
CB 6 1 CB 5 2
CB 6 1 CB 7 2
CB 6 1 CB 8 1
CB 6 2 G 2 1
G 2 1 CB 6 2
CB 7 1 TL 2 2
50
CB 7 2 CB 5 2
CB 7 2 CB 6 1
CB 7 2 CB 8 1
CB 8 1 CB 5 2
CB 8 1 CB 6 1
CB 8 1 CB 7 2
CB 8 2 AL 1 1
AL 1 1 CB 8 2
TL 2 2 CB 7 1
TL 2 1 CB 12 2
CB 12 2 TL 2 1
CB 12 2 CB 14 1
CB 12 2 CB 13 2
CB 9 1 CB 1 2
CB 9 1 CB 2 1
CB 9 2 TL 4 1
TL 4 1 CB 9 2
TL 4 2 CB 10 2
TL 4 2 CB 11 1
CB 10 1 CB 15 2
CB 10 1 CB 13 1
CB 10 2 TL 4 2
CB 10 2 CB 11 1
CB 11 1 CB 10 2
CB 11 1 TL 4 2
CB 11 2 CB 12 1
CB 12 1 CB 11 2
CB 13 1 CB 10 1
CB 13 1 CB 15 2
CB 13 2 CB 12 2
CB 13 2 CB 14 1
CB 13 2 TL 2 1
CB 14 1 CB 13 2
CB 14 1 CB 12 2
CB 14 1 TL 2 1
CB 14 2 TL 3 1
CB 15 1 AL 2 1
AL 2 1 CB 15 1
CB 15 2 CB 10 1
CB 15 2 CB 13 1
TL 3 1 CB 14 2
TL 3 2 CB 16 1
51
CB 16 1 TL 3 2
CB 16 2 TR 3 1
TR 3 1 CB 16 2
TR 3 2 CB 17 1
CB 17 1 TR 3 2
CB 17 2 CB 18 1
CB 18 1 CB 17 2
CB 18 2 G 2 1
G 2 1 CB 18 3
Pbuses
CB 2 1 CB 1 2
CB 9 1 CB 1 2
CB 9 1 CB 2 1
CB 6 1 CB 5 2
CB 7 2 CB 5 2
CB 8 1 CB 5 2
CB 7 2 CB 6 1
CB 8 1 CB 6 1
CB 8 1 CB 7 2
CB 14 1 CB 12 2
CB 13 2 CB 12 2
CB 15 2 CB 10 1
CB 13 1 CB 10 1
CB 11 1 CB 10 2
CB 12 1 CB 11 2
CB 15 2 CB 13 1
CB 14 1 CB 13 2
CB 18 1 CB 17 2
Ebuses
Ebus1 Terminals
CB,2,2
CB,1,1
CB,9,2
Ebus2 Terminals
52
CB,6,2
CB,5,1
CB,7,1
CB,8,2
Ebus3 Terminals
CB,14,2
CB,12,2
CB,13,2
Ebus4 Terminals
CB,15,1
CB,13,1
CB,12,1
Ebus5 Terminals
CB,18,2
CB,17,1
53