📄 swing2run.m
字号:
%swing2run.m script file associated with swing2.mdl
%when <RUN> is double clicked, the parameters are entered,
%the model is run, and the results plotted.
%Transient stability of a single machine against an infinite bus
%with clearing times Tc as parameter
clc,close all,clear
echo on
%Parameters from script file <swing2run.m>:
V=1; %infinite bus voltage [pu]
E=1.03; %internal machine voltage [pu]
Pm=0.8; %mechanical input [pu]
H=2.76; %inertia constant [s]
f=60; %base frequency [Hz]
Xbefore=0.4; %transfer reactance between E and V before, during, and
Xduring=1.1; % after the fault [pu]
Xafter=0.5; % Xduring=1000 represents a short at the machine terminals
par=[0.1 0.2 .3 0.4 0.6]; %clearing times [s]
%
echo off
delta0=asin(Pm*Xbefore/(E*V)); %initial angle [rad]
xo=[delta0 1]; %IC
delta=[];wm=[];Pe=[];
for m=1:length(par)
Tc=par(m);
sim('swing2',2,simset('InitialState',xo));
delta=[delta angle];
wm=[wm speed];
Pe=[Pe power];
end
%plots
delta=delta*180/pi;
h0=figure('Position',[100 60 900 560],'Name','Transient stability');
subplot(2,2,1),plot(t,delta);title('Swing Curves');xlabel('Time [s]'),ylabel('Delta [deg]'),grid
subplot(2,2,2),plot(delta,wm);title('Speed-Angle Curves');xlabel('Delta [deg]'),ylabel('Speed [pu]'),grid
subplot(2,2,3),plot(t,wm);title('Frequency Curves');xlabel('Time [s]'),ylabel('Speed [pu]'),grid
subplot(2,2,4),plot(delta,Pe,[0 180],[0.8 0.8],'r');title('Power-Angle Curves');set(gca,'Xlim',[0 180]);
xlabel('Delta [deg]'),ylabel('Power [pu]')
text(165,0.9,'Pm'),text(90,2.2,'after'),text(65,1.1,'during'),grid
uicontrol('Parent',h0, ...
'Units','normalized', ...
'BackgroundColor',[0.5 0.5 0.5], ...
'Callback','clc,clear,close all,break', ...
'FontSize',10, ...
'FontWeight','bold', ...
'ForegroundColor',[0 0 0.5], ...
'Position',[0.88 0.01 0.08 0.071], ...
'String','CLOSE', ...
'TooltipString','Close');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -