예제 #1
0
    event4Flag = '-event04'
    event4Param = '0.31,OUT,LINE,' + L2Bus1 + ',' + L2Bus2 + ',,' + L2cktID + ',7,,,,,'

    exitFlag = '-event05'
    exitParam = '30,EXIT,,,,,,,,,,,'
    EventList = [state_varFlag, state_varFile ,rawFlag, rawPath, dyrFlag, dyrPath,event1Flag, event1Param, event2Flag, event2Param,event3Flag, event3Param, event4Flag, event4Param, exitFlag, exitParam,
                protection_fbus_flag,protection_fbus_param,protection_tbus_flag,protection_tbus_param,protection_cid_flag, protection_cid_param]

    eventLogfile = 'TS3phEvent{}.log'.format(k)

    #Results = runSim(rawFile, EventList, 'TS3phEvent{}.log'.format(k), TS3phOutFile)


    # get a suspect event if ts3ph exits due to some reason
    try:
        Results = runSim(rawFile, EventList, eventLogfile, TS3phOutFile)
    except: # some error happened, log the event which caused error and continue
        print('Suspect event: {}'.format(event))
        suspectEvents.append(event)
        continue

    # get any cases which do not converge
    with open(eventLogfile,'r') as f:
        eventLog = f.read()

    matchString = 'Exiting TS3ph at t = 30.0000'
    if matchString not in eventLog:
        suspectEvents.append(event)
        continue
    ##
event3Flag = '-event03'
event3Param = '0.3,FAULTOFF,ABCG,901,,,,,,,,,'

event4Flag = '-event04'
event4Param = '0.31,OUT,LINE,901,1000,,1,7,,,,,'

exitFlag = '-event05'
exitParam = '10,EXIT,,,,,,,,,,,'
#EventList = [event1Flag, event1Param, event2Flag, event2Param,event3Flag, event3Param, event4Flag, event4Param, exitFlag, exitParam]
EventList = [
    state_varFlag, state_varFile, rawFlag, rawPath, dyrFlag, dyrPath,
    event1Flag, event1Param, event2Flag, event2Param, event3Flag, event3Param,
    event4Flag, event4Param, exitFlag, exitParam
]
Results = runSim(rawPath, EventList, 'TS3phN_2F.log')
###

# get plots for all the buses in the HV set
# angles
for Bus in rawBusDataDict:

    time = Results['time']
    Angle = Results[int(Bus)].ang
    plt.plot(time, Angle)
    titleStr = 'Bus ' + Bus
    plt.title(titleStr)
    plt.ylabel('Angle (degrees)')
    plt.ticklabel_format(useOffset=False)
    plt.xlabel('Time (sec)')
    plt.ylim(-180, 180)
예제 #3
0
# script to get a simulation from the real world (predetermined in our case) and try to capture the event timings and reconstruct the whole event in another copy of TS3ph
# since we cannot do dynamic initialization at the moment, everytime a new event is detected, it is added to the event list and the whole simulation is rerun.
# This process is repeated till we get a good match with the real world simulation
import matplotlib.pyplot as plt
import numpy as np
from input_data import RealWorldEventList, TS3phEventList, rawPath, EventDescriptionDict
from runSimFn import runSim  # function to run simulation and plot the results
Results_Actual = runSim(rawPath, RealWorldEventList,
                        'TS3phFault.log')  # case representing real world data
#Results_Sim = runSim(rawPath,TS3phEventList,'TS3phNoDist.log')

time = Results_Actual['time']
totSimTime = int(round(float(time[-1])))  # get the total time to simulate

EventDict = {}  # dynamic dictionary of events for the simulation

mostRecentEventIndex = 0  # keeps track of how many events have been recorded
exitParamString = str(totSimTime) + ',EXIT,,,,,,,,,,,'

# loop to redo the whole simulation when new events are detected
while True:
    EventList = []  # reset event list
    # get the most updated event list from the event dictionary
    for i in range(len(EventDict)):
        currentEventList = EventDict[i]
        for ele in currentEventList:
            EventList.append(ele)

    # add the exit event
    exitFlag = '-event' + str(len(EventDict) + 1).zfill(2)
    EventList.append(exitFlag)
예제 #4
0
"""
# just N-2 line outages
# one line out then a fault
event1Flag = '-event01'
event1Param = '0.1,OUT,LINE,201,204,,1,7,,,,,'


event2Flag = '-event02'
event2Param = '0.11,OUT,LINE,151,152,,1,7,,,,,'

exitFlag = '-event03'
exitParam = '3,EXIT,,,,,,,,,,,'
EventList = [event1Flag,event1Param,event2Flag,event2Param,exitFlag,exitParam]
"""

Results = runSim(rawPath,EventList,'TS3phLoadOut.log')

# print the final steady state voltage of some bus
print Results[205].mag[-1]
# get plots for all the buses in the HV set
# plot to see if everything is ok
for Bus in list(HVBusSet):

	time = Results['time']
	vMag = Results[int(Bus)].mag
	plt.plot(time, vMag)
	titleStr = 'Bus ' + Bus
	plt.title(titleStr)
	plt.ylabel('Voltage magnitude (pu)')
	plt.ticklabel_format(useOffset=False)
	plt.xlabel('Time (sec)')
예제 #5
0
"""
# just N-2 line outages
# one line out then a fault
event1Flag = '-event01'
event1Param = '0.1,OUT,LINE,201,204,,1,7,,,,,'


event2Flag = '-event02'
event2Param = '0.11,OUT,LINE,151,152,,1,7,,,,,'

exitFlag = '-event03'
exitParam = '3,EXIT,,,,,,,,,,,'
EventList = [event1Flag,event1Param,event2Flag,event2Param,exitFlag,exitParam]
"""

Results = runSim(rawPath,EventList,'log.log')

# print the final steady state voltage of some bus
#print Results[205].mag[-1]
# get plots for all the buses in the HV set
# plot to see if everything is ok
for Bus in rawBusDataDict:

	time = Results['time']
	vMag = Results[int(Bus)].mag
	plt.plot(time, vMag)
	titleStr = 'Bus ' + Bus
	plt.title(titleStr)
	plt.ylabel('Voltage magnitude (pu)')
	plt.ticklabel_format(useOffset=False)
	plt.xlabel('Time (sec)')
예제 #6
0
import matplotlib.pyplot as plt
import numpy as np
from input_data import RealWorldEventList, TS3phEventList, rawPath
from runSimFn import runSim  # function to run simulation and plot the results
Results_Fault = runSim(rawPath, RealWorldEventList, 'TS3phFault.log')
Results_NoDist = runSim(rawPath, TS3phEventList, 'TS3phNoDist.log')
"""
# plot to see if everything is ok
time = Results_Fault['time']
vMag = Results_Fault[153].mag
plt.plot(time, vMag)
plt.title('Bus 153')
plt.ylabel('Voltage magnitude (pu)')
plt.ticklabel_format(useOffset=False)
plt.xlabel('Time (sec)')
plt.ylim(-0.1,1.5)
plt.savefig('Bus153VMag.png')
"""

time = Results_Fault['time']
DiffInstant = {}
# get the exact time when the results are different
for key in Results_NoDist:
    if key == 'time':
        continue
    Vmag1 = Results_NoDist[key].mag
    Vmag2 = Results_Fault[key].mag
    #	print type(Vmag1)
    #	print Vmag1.size
    #	print Vmag2.size
    i = 0
            event2Flag = '-event02'
            event2Param = '0.2,FAULTON,ABCG,' + FaultBus + ',,,,1.0e-6,1.0e-6,1.0e-6,0.0,0.0,0.0'

            event3Flag = '-event03'
            event3Param = '0.3,FAULTOFF,ABCG,' + FaultBus + ',,,,,,,,,'

            event4Flag = '-event04'
            event4Param = '0.31,OUT,LINE,' + L2Bus1 + ',' + L2Bus2 + ',,' + L2cktID + ',7,,,,,'

            exitFlag = '-event05'
            exitParam = '3,EXIT,,,,,,,,,,,'
            EventList = [
                event1Flag, event1Param, event2Flag, event2Param, event3Flag,
                event3Param, event4Flag, event4Param, exitFlag, exitParam
            ]
            Results = runSim(raw, EventList, 'TS3phEvent.log')
            currentEvent = currentSet + ';' + 'F' + FaultBus
            # print 'Current event: ' + currentEvent

            time = list(Results['time'])
            # get the time index when its greater than 1 sec (after the 2nd line out)
            ind_1sec = [ind for ind, t in enumerate(time) if t >= 1.31][0]
            # print time[ind_1sec]

            # extract LV results if any
            for key in Results:
                if key == 'time':
                    continue

                vMag = Results[key].mag
                # get the dv_dt values
event3Flag = '-event03'
event3Param = '0.3,FAULTOFF,ABCG,{},,,,,,,,,'.format(FaultBus)

event4Flag = '-event04'
event4Param = '0.31,OUT,LINE,{},{},,{},7,,,,,'.format(L2Bus1, L2Bus2, L2cktID)

exitFlag = '-event05'
exitParam = '30,EXIT,,,,,,,,,,,'
#EventList = [event1Flag, event1Param, event2Flag, event2Param,event3Flag, event3Param, event4Flag, event4Param, exitFlag, exitParam]
EventList = [
    state_varFlag, state_varFile, rawFlag, rawPath, dyrFlag, dyrPath,
    event1Flag, event1Param, event2Flag, event2Param, event3Flag, event3Param,
    event4Flag, event4Param, exitFlag, exitParam
]
Results = runSim(rawFile, EventList, 'TS3phN_2F.log', TS3phOutFile)
###

# get plots for all the buses in the HV set
# angles
for Bus in rawBusDataDict:

    time = Results['time']
    Angle = Results[int(Bus)].ang
    plt.plot(time, Angle)
    titleStr = 'Bus ' + Bus
    plt.title(titleStr)
    plt.ylabel('Angle (degrees)')
    plt.ticklabel_format(useOffset=False)
    plt.xlabel('Time (sec)')
    plt.ylim(-180, 180)
예제 #9
0
import matplotlib.pyplot as plt
import numpy as np
from input_data import RealWorldEventList, TS3phEventList, rawPath, EventDescriptionDict
from runSimFn import runSim  # function to run simulation and plot the results
Results_Actual = runSim(rawPath, RealWorldEventList, 'TS3phFault.log')
#Results_Sim = runSim(rawPath,TS3phEventList,'TS3phNoDist.log')
"""
# plot to see if everything is ok
time = Results_Actual['time']
vMag = Results_Actual[153].mag
plt.plot(time, vMag)
plt.title('Bus 153')
plt.ylabel('Voltage magnitude (pu)')
plt.ticklabel_format(useOffset=False)
plt.xlabel('Time (sec)')
plt.ylim(-0.1,1.5)
plt.savefig('Bus153VMag.png')
"""

time = Results_Actual['time']
totSimTime = int(round(float(time[-1])))  # get the total time to simulate
# dynamic dictionary of events for the simulation
EventDict = {}

#EvenDict['EXIT'] = ['-event01', exitParamString] # initialize the dictionary, the flag will need to be updated everytime an event is detected

mostRecentEventIndex = 0  # keeps track of how many events have been recorded
#exitFlag = '-event' + str(mostRecentEventIndex+1).zfill(2)
exitParamString = str(totSimTime) + ',EXIT,,,,,,,,,,,'

while True:
예제 #10
0
exitParam = '3,EXIT,,,,,,,,,,,'
EventList = [event1Flag,event1Param,event2Flag,event2Param,exitFlag,exitParam]
"""

# Fault at b151

event1Flag = '-event01'
event1Param = '0.1,FAULTON,ABCG,151,,,,1.0e-6,1.0e-6,1.0e-6,0.0,0.0,0.0'

event2Flag = '-event02'
event2Param = '0.2,FAULTOFF,ABCG,151,,,,,,,,,'

exitFlag = '-event03'
exitParam = '5,EXIT,,,,,,,,,,,'
EventList = [event1Flag,event1Param,event2Flag,event2Param,exitFlag,exitParam]
Results151F = runSim(rawPath,EventList,'TS3phF.log')


# get the voltage mag
v151 = {}
for bus in Results151F:
	if bus == 'time':
		v151[bus] = Results151F[bus]
		continue
	v = Results151F[bus].mag
	v151[bus] = v