forked from ahmadabdullah/ATPMAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetGroundFaultResistance.m
141 lines (127 loc) · 4.1 KB
/
setGroundFaultResistance.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
function setGroundFaultResistance(fid1,faultType,faultBus, faultResistance)
%This is a helper function to write the ground fault resitance to the ATP
%file. The ground fault resitance which is inserted by default previously
%in the code is now replaced by a resistance supplied by the user.
%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.
% type='SWITCH';
whichCard='BRANCH';
BusNA=strcat(faultBus,'NA');
BusNB=strcat(faultBus,'NB');
BusNC=strcat(faultBus,'NC');
BusG=' ';
switch faultType
case {9,11}
% set position indicator to begining of file
fseek(fid1,0,-1);
%find row number
rowNumber=getRowNumber(BusNA,BusG,whichCard,fid1);
fseek(fid1,0,-1);
%move file position indicator
for i=1:rowNumber-1
fgetl(fid1);
end
%function for switch data
setFaultResistance(fid1,2*faultResistance);
fseek(fid1,0,-1);
end
switch faultType
case {9,10}
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNB,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,2*faultResistance);
fseek(fid1,0,-1);
end
switch faultType
case {10,11}
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNC,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,2*faultResistance);
fseek(fid1,0,-1);
end
switch faultType
case {6}
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNA,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,faultResistance);
fseek(fid1,0,-1);
end
switch faultType
case {7}
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNB,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,faultResistance);
fseek(fid1,0,-1);
end
switch faultType
case {8}
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNC,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,faultResistance);
fseek(fid1,0,-1);
end
switch faultType
case {12}
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNA,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,3*faultResistance);
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNB,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,3*faultResistance);
fseek(fid1,0,-1);
rowNumber=getRowNumber(BusNC,BusG,whichCard,fid1);
fseek(fid1,0,-1);
for i=1:rowNumber-1
fgetl(fid1);
end
setFaultResistance(fid1,3*faultResistance);
fseek(fid1,0,-1);
end