📄 setx0.m
字号:
function a = setx0(a)
global Line Bus DAE Settings
if ~a.n, return, end
% reset transmission line reactance and admittance matrix
Line.con(a.line,9) = Line.con(a.line,9)./(1-a.Cp);
fm_y;
x0 = zeros(a.n,1);
if a.ty1
x0(a.ty1) = a.Cp(a.ty1).*Line.con(a.line(a.ty1),9);
end
if a.ty2
af = -pi/2:0.025:pi/2;
for i = 1:length(a.ty2)
% find a "good" initial guess in a brutal way...
B = balpha(a,af,a.ty2(i),1);
B0 = a.B(a.ty2(i));
[val,idx] = min(abs(B-B0));
B1 = B(idx);
af0 = af(idx);
err = 1;
iter = 0;
while abs(B1-B0) > Settings.lftol
if iter > 20, break, end
B1 = balpha(a,af0,a.ty2(i),1);
dB = balpha(a,af0,a.ty2(i),2);
err = -(B1-B0)/dB;
af0 = af0 + err;
iter = iter + 1;
end
if iter > 20
tcscwarn(a,a.ty2(i),[': initialization of alpha failed.'])
end
x0(a.ty2(i)) = af0;
end
end
jdx = find(x0 > a.con(:,10));
if jdx
tcscwarn(a,jdx,': state variable is over its maximum limit.')
end
jdx = find(x0 < a.con(:,11));
if jdx
tcscwarn(a,jdx,': state variable is under its minimum limit.')
end
x0 = min(x0,a.con(:,10));
x0 = max(x0,a.con(:,11));
ty2 = a.con(:,3) == 2;
tyang = a.con(:,4) == 2;
% initial state variables and reference
a.x0 = x0;
DAE.x(a.x1) = x0;
if ty2, DAE.x(a.x2(ty2)) = x0(ty2); end
% reference power
[Ps,Qs,Pr,Qr,Is,Ir] = fex_lineflows;
a.Pref = Ps(a.line) + ty2.*tyang.*Pr(a.line);
fm_disp('Initialization of TCSC completed.')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -