-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetFaultBlockSwitches.m
114 lines (104 loc) · 3.74 KB
/
setFaultBlockSwitches.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function []= setFaultBlockSwitches(fid1,faultType,startTime,faultBus, endTime)
%A helper function to set the switches of the fault block inserted
%previously
%This file is part of ATPMAT
%For more information, please go to https://bitbucket.org/ahmadmabdullah/atpmat
% ATPMAT is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation, either version 3 of the License,
% or (at your option) any later version.
%
% ATPMAT is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
%
% Additional permission under GNU GPL version 3 section 7
%
% If you modify ATPMAT, or any covered work, to interface with
% other modules (such as MATLAB code and MEX-files) available in a
% MATLAB(R) or comparable environment containing parts covered
% under other licensing terms, the licensors of MATPOWER grant
% you additional permission to convey the resulting work.
whichCard='SWITCH';
%The following give a one to one mapping to the fault block inserted.
BusA=strcat(faultBus,'A');
BusB=strcat(faultBus,'B');
BusC=strcat(faultBus,'C');
BusS=strcat(faultBus,'S');
BusSA=strcat(faultBus,'SA');
BusSB=strcat(faultBus,'SB');
BusSC=strcat(faultBus,'SC');
BusNA=strcat(faultBus,'NA');
BusNB=strcat(faultBus,'NB');
BusNC=strcat(faultBus,'NC');
switch faultType
case {2,4,5,6,9,11,12} % fault on phase A
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusA,BusS,whichCard,fid1);
fseek(fid1,0,-1);
% skip all lines till you get to the switch
for i=1:rowNumber-1
fgetl(fid1);
end
setSwitchOpenCloseTimes(fid1,startTime,endTime);
fseek(fid1,0,-1);
end
switch faultType
case {2,3,5,7,9,10,12} % B phase faulted
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusB,BusS,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setSwitchOpenCloseTimes(fid1,startTime,endTime);
fseek(fid1,0,-1);
end
switch faultType
case {3,4,5,8,10,11,12} % C phase faulted
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusC,BusS,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setSwitchOpenCloseTimes(fid1,startTime,endTime);
fseek(fid1,0,-1);
end
switch faultType
case {6,9,11,12} %ground fault phase A
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusSA,BusNA,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setSwitchOpenCloseTimes(fid1,startTime,endTime);
fseek(fid1,0,-1);
end
switch faultType
case {7,9,10,12} %ground fault phase B
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusSB,BusNB,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setSwitchOpenCloseTimes(fid1,startTime,endTime);
fseek(fid1,0,-1);
end
switch faultType
case {8,10,11,12} %ground fault phase C
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusSC,BusNC,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setSwitchOpenCloseTimes(fid1,startTime,endTime);
fseek(fid1,0,-1);
end