Skip to content

Commit 0e89a7c

Browse files
yasirronirdzman
authored andcommitted
proper message if slack bus contains no generator
1 parent 285b4fa commit 0e89a7c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/+mp/mm_shared_pfcpf_ac.m

+6
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
[i, j] = find(CCrpv);
110110
if size(i, 2) > 1, i = i'; j = j'; end
111111
ij = sortrows([i j]); %% 1st state comes 1st for each node
112+
113+
%% check if ij is empty (no generators in slack node)
114+
if isempty(ij)
115+
error('No generator found in the slack node. Ensure at least one generator is connected to the slack bus.');
116+
end
117+
112118
[~, k1] = unique(ij(:, 1), 'first');%% index of 1st entry for each node
113119
% j1 = ij(k1, 2); %% indices of states that are 1st at their node
114120
kn = find(~ismember(1:length(i), k1)); %% indices of entries that are not first state for corresponding node

0 commit comments

Comments
 (0)