-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenbm.m
More file actions
29 lines (28 loc) · 1.13 KB
/
Copy pathgenbm.m
File metadata and controls
29 lines (28 loc) · 1.13 KB
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
function mat = genbm(ID,btype,F,T,Sb,Qg,Qd,u0,phi,varargin)
[g,b,bc,tau,tshift,~,bsh] = branchparts_unpack(Sb,btype);
% Gwtype = varargin_parse(varargin,'Gw','default');
% Gw = genweights(b,Gwtype);
Gw = varargin_parse(varargin,'Gw',branchweights(Sb));
switch ID
case 0
mat = ...
exp(-u0).*(Qd-Qg) - exp(u0).*bsh...
-F'*diags(tau.^(-1))*( diags(tau.^(-1))*(exp(Gw.b*F*u0).*(b + bc/2))...
-exp(Gw.b*T*u0).*(g.*sin(tshift) + b.*cos(tshift)).*(1-phi))...
-T'*(exp(Gw.b*T*u0).*(b + bc/2) ...
-diags(tau.^(-1))*exp(Gw.b*F*u0).*(-g.*sin(tshift) + b.*cos(tshift)).*(1-phi));
case 1
mat = ...
exp(-u0).*(Qd-Qg) - exp(u0).*bsh...
-F'*diags(tau.^(-1))*( diags(tau.^(-1))*(exp(Gw.b*F*u0).*(b + bc/2))...
-exp(Gw.b*T*u0).*b.*(1-phi))...
-T'*(exp(Gw.b*T*u0).*(b + bc/2) ...
-diags(tau.^(-1))*exp(Gw.b*F*u0).*b.*(1-phi));
case 2
mat = ...
Qd - Qg - bsh...
-F'*diags(tau.^(-1))*( diags(tau.^(-1))*(b + bc/2) - b.*(1-phi))...
-T'*((b + bc/2) - diags(tau.^(-1))*b.*(1-phi));
otherwise
error('Incorrect ID')
end