Ejemplo n.º 1
0
def generate345PathList(Raw,startBusList):
	# Function to generate the list of paths

	print 'Compiling the neighbour data from the Raw file. May take some time. Please wait.'
	print '\n'
	CAPENeighbourDict = getNeighbours(Raw) # key: any bus in the raw file, value: set of all neighbours (line and tf)
	BusDataDict = getBusData(Raw) # Dict whose values are all the relevant info about any bus, key is the bus itself
	print 'Ok, done!'

	ImpPathDict = {}
	# Use CAPENeighbourDict and BFS to find path from one bus to another. Use the concept given in getNeighboursAtCertainDepthFn
	for startBus in startBusList:
		PathDict = {}
		explored = set()
		#startBus = raw_input('Enter start bus: ')
		#endBus = raw_input('Enter end bus: ')



		frontier = Queue(maxsize=0)
		frontier.put(startBus)

		while not frontier.empty():
			currentBus = frontier.get()
			frontier.task_done()
			#if currentBus == endBus:
			#	break

			BusVolt = float(BusDataDict[currentBus].NominalVolt)
			BusName = BusDataDict[currentBus].name
			BusArea = BusDataDict[currentBus].area
			if BusVolt >= 345.0 and not BusName.startswith('T3W') and not BusName.endswith('M') and BusArea == '222': # see if the bus is a legit 345 kV bus
				endBus = currentBus
				break
			NeighBourList = list(CAPENeighbourDict[currentBus])


			explored.add(currentBus)

			for neighbour in NeighBourList:
				try:
					NeighBourArea = BusDataDict[neighbour].area
				except: # probably type 4 bus
					continue
				if NeighBourArea != '222': # go to next neighbour if 
					continue
				if neighbour in explored:
					continue

				if currentBus in PathDict.keys():
					PathDict[neighbour] = PathDict[currentBus] + '->' + neighbour
				else: # if currentBus is the start bus
					PathDict[neighbour] = currentBus + '->' + neighbour
 
				frontier.put(neighbour)

		#print PathDict[endBus]
		ImpPathDict[startBus] = PathDict[endBus]
	
	return ImpPathDict
Ejemplo n.º 2
0
def getPath(Raw, startBus, endBus):
    # Function to generate the list of paths

    NeighbourDict = getNeighbours(
        Raw
    )  # key: any bus in the raw file, value: set of all neighbours (line and tf)

    # Use CAPENeighbourDict and BFS to find path from one bus to another. Use the concept given in getNeighboursAtCertainDepthFn
    PathDict = {}
    explored = set()
    #startBus = raw_input('Enter start bus: ')
    #endBus = raw_input('Enter end bus: ')

    frontier = Queue(maxsize=0)
    frontier.put(startBus)

    while not frontier.empty():
        currentBus = frontier.get()
        frontier.task_done()
        if currentBus == endBus:
            break

        NeighBourList = list(NeighbourDict[currentBus])

        explored.add(currentBus)

        for neighbour in NeighBourList:
            if neighbour in explored:
                continue

            if currentBus in PathDict.keys():
                PathDict[neighbour] = PathDict[currentBus] + '->' + neighbour
            else:  # if currentBus is the start bus
                PathDict[neighbour] = currentBus + '->' + neighbour

            frontier.put(neighbour)

    Path = PathDict[endBus]

    return Path
Ejemplo n.º 3
0
from findPathTo345Fn import generate345PathList
from getTFDataFn import getTFData
from writeFileFn import writeToFile
from generateNeighboursFn import getNeighbours
from getBranchGroupFn import makeBranchGroups

CAPERaw = 'RAW0602.raw'
changeLog = 'changeBusNoLog.txt'
Imp138PathFile = 'Imp138PathFile.txt'
directTFConnFile = 'directTFConnFile.txt'
AllToBeMappedFile = 'AllToBeMappedFile.txt'
ArtificialLoadBusFile = 'ArtificialLoadBusFile.txt'
Imp138PathSet = set()
Imp138Depth1Set = set()
CAPEBusDataDict = getBusData(CAPERaw)
CAPENeighboursDict = getNeighbours(CAPERaw)
ArtificialLoadBusSet = set()
necessaryMidpointSet = set()  # set of tf midpoints which need to be there
ParentDict = {}
AllToBeMappedSet = set()  # All the non-345 comed buses to be mapped
toGetPathSet = set(
)  # set of 138 kV belonging to the 3 SVC substations, from which we need to get paths to 345
OldToNewBusDict = {}  # key: new CAPE bus number, old: old CAPE bus number
# get the path from the three 138 kV substations where the SVCs are at, to nearest 345
impSubStationList = [
    'TSS 135 ELMHURST', 'TSS 117 PROSPECT HEIGHTS', 'STA 13 CRAWFORD'
]
AllToBeMappedLines = []
OldBusSet = set()
directTFConnLines = []
BoundaryBusSet = set()
class Features(object):
    def __init__(self, inputV):
        self.max_ratio = 0.0
        self.genRatioF = 0.0
        self.similarityCL0 = 0.0
        self.similarityCL1 = 0.0
        self.t_max = 0.0
        self.osc = 0.0  # one if sample belongs to oscillatory class, otherwise 0
        self.inputV = inputV


raw = 'savnw.raw'
BusDataDict = getBusData(raw)
GenDataDict = getGenData(raw)
NeighbourDict = getNeighbours(raw)
FeatureDict = {}


############## Functions
def load_obj(name):
    # load pickle object
    with open('obj/' + name + '.pkl', 'rb') as f:
        return pickle.load(f)


def GenRatioDepth1(Bus, totalGen):
    # function which returns the total generation in a depth of one of the bus
    # as a ratio of the total gen in the system
    depthOneBuses = list(NeighbourDict[Bus])
    depthOneBuses.append(Bus)
Ejemplo n.º 5
0
from Queue import Queue
#from generateBranchNeighboursOutEvenFn import getBranchNeighbours
from getBusDataFn import getBusData
from generateNeighboursFn import getNeighbours
CAPERaw = 'MASTER_CAPE_Fixed.raw'
#CAPERaw = 'CAPE_RAW1116v33.raw'
boundaryFile = 'BoundaryplanningMapCleaned.txt' # Cleaned boundary maps to initialize searching points
boundarynoncomed = 'BoundaryNonComedv3.txt' # List of buses on the non-comed side of the boundary
outsideComedBuses = 'outsideComedBusesv4.txt' # generate a set of buses on the outside of comed area
hiddenboundaryList = 'hiddenboundarylistv4.txt'
ManuallyAddedList = ['50123','50124','50122','3039','757'] # list of buses to be manually added to outside comed buses
BoundaryList = [] # fill this up
nonComedBoundarySet = set()
explored = []
hiddenboundary = set()
BranchNeighbourDict = getNeighbours(CAPERaw)
BusDict = getBusData(CAPERaw)

# file contains CAPE boundary info
with open(boundaryFile,'r') as f:
	filecontent = f.read()
	fileLines = filecontent.split('\n')
	for line in fileLines:
		words = line.split('->')
		if len(words) < 2:
			continue
		CAPEWords = words[1].split(',')
		CAPEBoundary = CAPEWords[0].strip()
		BoundaryList.append(CAPEBoundary)

Ejemplo n.º 6
0

def dist2FaultBus(currentBus, FaultBus):
    # return the depth (distance between) fault bus and current bus
    #Path = getPath(Raw,currentBus,FaultBus)
    #depth = len(Path.split('->')) - 1 # since the starting bus is the bus itself
    nInd = depthDict[currentBus].restOfBuses.index(FaultBus)
    depth = depthDict[currentBus].depth[nInd]
    return depth


#################################
savnw_raw = 'savnw_dy_sol_0905.raw'
# get the total load (MVA) in the raw file
LoadDataDict = getLoadData(savnw_raw)
NeighbourDict = getNeighbours(savnw_raw)

totalConstZMVA = 0.0  # total constant impedance load in the raw file
for Bus in LoadDataDict:
    constZP = LoadDataDict[Bus].constZP
    constZQ = LoadDataDict[Bus].constZQ
    constZS = math.sqrt(constZP**2 + constZQ**2)
    totalConstZMVA += constZS

# organize the distance between any two buses in the system
BusDataDict = getBusData(savnw_raw)
depthDict = {
}  # stores the distance of all the other buses to the bus provided as key
for Bus in BusDataDict:
    depthDict[Bus] = PathStruct()
    for n in BusDataDict:
Ejemplo n.º 7
0
#from generateNeighboursPlanning import NeighbourDict
from generateNeighboursFn import getNeighbours
#from changetfDatav4 import BusVoltageDict
from getBusDataFn import getBusData

PSSErawFile = 'hls18v1dyn_1219.raw'
AllMapFile = 'AllMappedLog.txt'
manualMapFile = 'mapped_buses_cleaned_for_load_shunt.csv'
newShuntData = 'newShuntData.txt'  # output of this file
ssBusNoChangeLog = 'ssBusNoChangeLog.txt'  # log of changes made in this file
changeLog = 'changeBusNoLog.txt'
BusData = 'PSSE_bus_data.txt'
outsideComedFile = 'outsideComedBusesv4.txt'
isolatedCAPEBusList = 'isolatedCAPEBusList_All.txt'  # list of buses which are isolated in cape
GenBusChangeLog = 'GenBusChange.log'  # log file of CAPE buses which have been renumbered to PSSE gen bus numbers
NeighbourDict = getNeighbours(PSSErawFile)  # dict of neighbours in planning
#PSSEGenFile = 'PSSEGenFile.txt'
BusDataDict = getBusData(PSSErawFile)
genLines = []
ComedBusSet = set()
MapDict = {}
ManualMapDict = {}
ssBusNoChangeDict = {}
changeBusNoLogList = []
OldBusSet = set()
changeNameDict = {}
#BusVoltageDict = {}
noNeedtoMapSet = set()
TrueGenBusSet = set()  # set of all gen buses, numbered according to planning
"""
with open(BusData,'r') as f: