enable emt in runPowerSAS.m function

pull/5/head
Yang Liu 2 years ago
parent e3a4af8e2c
commit 68c835ca1e

@ -1,5 +1,5 @@
function [t_final, sol_final] = calEMT(testSystem) function [res] = calEMT(testSystem)
%% %%
[orderOfDT, timeStepOfDT] = setSASParameters(); [orderOfDT, timeStepOfDT] = setSASParameters();
@ -49,6 +49,6 @@ x_ini_post = x_on(end,:)';
t_post = t_dt; t_post = t_dt;
x_post = x_dt'; x_post = x_dt';
t_final = [t_pre; t_on(2:end); t_post(2:end)]; res.t_final = [t_pre; t_on(2:end); t_post(2:end)];
sol_final = [x_pre; x_on(2:end,:); x_post(2:end,:)]; res.sol_final = [x_pre; x_on(2:end,:); x_post(2:end,:)];
return return

@ -1,97 +1,93 @@
function plotEMTResults(res)
close all close all
t_final = res.t_final;
% t_final = [t_pre; t_on(2:end); t_post(2:end)]; sol_final = res.sol_final;
% sol_final = [x_pre; x_on(2:end,:); x_post(2:end,:)];
% % t_final = [t_pre; t_on(2:end)]; % %% relative rotor angles
% % sol_final = [x_pre; x_on(2:end,:)]; % figure(1)
% % t_final = [t_pre]; % % EMT result
% % sol_final = [x_pre]; % plot(t_final, (sol_final(:,1)-sol_final(:,1) )*180/pi,'r--','LineWidth',3)
% hold on
%% relative rotor angles % plot(t_final, (sol_final(:,2)-sol_final(:,1) )*180/pi,'g--','LineWidth',3)
figure(1) % hold on
% EMT result % plot(t_final, (sol_final(:,3)-sol_final(:,1) )*180/pi,'b--','LineWidth',3)
plot(t_final, (sol_final(:,1)-sol_final(:,1) )*180/pi,'r--','LineWidth',3) % hold on
hold on % plot(t_final, (sol_final(:,4)-sol_final(:,1) )*180/pi,'b--','LineWidth',3)
plot(t_final, (sol_final(:,2)-sol_final(:,1) )*180/pi,'g--','LineWidth',3) % hold on
hold on % % ylim([-60,10])
plot(t_final, (sol_final(:,3)-sol_final(:,1) )*180/pi,'b--','LineWidth',3) % xlabel('Time (s)')
hold on % ylabel('Relative rotor angles (degree)')
plot(t_final, (sol_final(:,4)-sol_final(:,1) )*180/pi,'b--','LineWidth',3) % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
hold on % title('Relative rotor angles')
% ylim([-60,10]) % legend('EMT G1','EMT G2','EMT G3','EMT G4')
xlabel('Time (s)')
ylabel('Relative rotor angles (degree)') % %% frequency deviation
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % figure(2)
title('Relative rotor angles') % % EMT result
legend('EMT G1','EMT G2','EMT G3','EMT G4') % plot(t_final, sol_final(:,9),'r--','LineWidth',3)
% hold on
%% frequency deviation % plot(t_final, sol_final(:,10),'g--','LineWidth',3)
figure(2) % hold on
% EMT result % plot(t_final, sol_final(:,11),'b--','LineWidth',3)
plot(t_final, sol_final(:,9),'r--','LineWidth',3) % hold on
hold on % plot(t_final, sol_final(:,12),'m--','LineWidth',3)
plot(t_final, sol_final(:,10),'g--','LineWidth',3) % hold on
hold on % % ylim([-60,10])
plot(t_final, sol_final(:,11),'b--','LineWidth',3) % % xlim([0,0.25])
hold on % xlabel('Time (s)')
plot(t_final, sol_final(:,12),'m--','LineWidth',3) % ylabel('Frequency deviation (p.u.)')
hold on % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
% ylim([-60,10]) % title('Frequency deviation')
% xlim([0,0.25]) % legend('EMT G1','EMT G2','EMT G3','EMT G4')
xlabel('Time (s)')
ylabel('Frequency deviation (p.u.)') % %% Exciter field voltage
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % figure(3)
title('Frequency deviation') % % EMT result
legend('EMT G1','EMT G2','EMT G3','EMT G4') % plot(t_final, sol_final(:,33),'r--','LineWidth',3)
% hold on
%% Exciter field voltage % plot(t_final, sol_final(:,34),'g--','LineWidth',3)
figure(3) % hold on
% EMT result % plot(t_final, sol_final(:,35),'b--','LineWidth',3)
plot(t_final, sol_final(:,33),'r--','LineWidth',3) % hold on
hold on % plot(t_final, sol_final(:,36),'m--','LineWidth',3)
plot(t_final, sol_final(:,34),'g--','LineWidth',3) % xlabel('Time (s)')
hold on % xlim([0,0.4])
plot(t_final, sol_final(:,35),'b--','LineWidth',3) % ylabel('Exciter field voltage (p.u.)')
hold on % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
plot(t_final, sol_final(:,36),'m--','LineWidth',3) % title('Exciter field voltage')
xlabel('Time (s)') % legend('EMT G1','EMT G2','EMT G3','EMT G4')
xlim([0,0.4])
ylabel('Exciter field voltage (p.u.)') % %% P1
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % figure(4)
title('Exciter field voltage') % % EMT result
legend('EMT G1','EMT G2','EMT G3','EMT G4') % plot(t_final, sol_final(:,37),'r--','LineWidth',3)
% hold on
%% P1 % plot(t_final, sol_final(:,38),'g--','LineWidth',3)
figure(4) % hold on
% EMT result % plot(t_final, sol_final(:,39),'b--','LineWidth',3)
plot(t_final, sol_final(:,37),'r--','LineWidth',3) % hold on
hold on % plot(t_final, sol_final(:,40),'m--','LineWidth',3)
plot(t_final, sol_final(:,38),'g--','LineWidth',3) %
hold on % xlabel('Time (s)')
plot(t_final, sol_final(:,39),'b--','LineWidth',3) % ylabel('P1(p.u.)')
hold on % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
plot(t_final, sol_final(:,40),'m--','LineWidth',3) % title('P1')
% legend('EMT G1','EMT G2','EMT G3','EMT G4')
xlabel('Time (s)')
ylabel('P1(p.u.)') % %% Voltage at bus 7
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % figure(5)
title('P1') % % EMT result
legend('EMT G1','EMT G2','EMT G3','EMT G4') % plot(t_final, sol_final(:,51),'r','LineWidth',1)
% hold on
%% Voltage at bus 7 % plot(t_final, sol_final(:,52),'g','LineWidth',1)
figure(5) % hold on
% EMT result % plot(t_final, sol_final(:,53),'b','LineWidth',1)
plot(t_final, sol_final(:,51),'r','LineWidth',1) %
hold on % xlabel('Time (s)')
plot(t_final, sol_final(:,52),'g','LineWidth',1) % ylabel('Voltage at bus 7(p.u.)')
hold on % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
plot(t_final, sol_final(:,53),'b','LineWidth',1) % title('Voltage at bus 7')
% legend('EMT phase A','EMT phase B','EMT phase C')
xlabel('Time (s)')
ylabel('Voltage at bus 7(p.u.)')
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Voltage at bus 7')
legend('EMT phase A','EMT phase B','EMT phase C')
%% Voltage at bus 8 %% Voltage at bus 8
figure(6) figure(6)
@ -108,50 +104,50 @@ set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Voltage at bus 8') title('Voltage at bus 8')
legend('EMT phase A','EMT phase B','EMT phase C') legend('EMT phase A','EMT phase B','EMT phase C')
%% Voltage at bus 10 % %% Voltage at bus 10
figure(7) % figure(7)
% EMT result % % EMT result
plot(t_final, sol_final(:,60),'r','LineWidth',1) % plot(t_final, sol_final(:,60),'r','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,61),'g','LineWidth',1) % plot(t_final, sol_final(:,61),'g','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,62),'b','LineWidth',1) % plot(t_final, sol_final(:,62),'b','LineWidth',1)
%
xlabel('Time (s)') % xlabel('Time (s)')
ylabel('Voltage at bus 10(p.u.)') % ylabel('Voltage at bus 10(p.u.)')
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Voltage at bus 10') % title('Voltage at bus 10')
legend('EMT phase A','EMT phase B','EMT phase C') % legend('EMT phase A','EMT phase B','EMT phase C')
%% Voltage at bus 6 % %% Voltage at bus 6
figure(8) % figure(8)
% EMT result % % EMT result
plot(t_final, sol_final(:,48),'r','LineWidth',1) % plot(t_final, sol_final(:,48),'r','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,49),'g','LineWidth',1) % plot(t_final, sol_final(:,49),'g','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,50),'b','LineWidth',1) % plot(t_final, sol_final(:,50),'b','LineWidth',1)
%
xlabel('Time (s)') % xlabel('Time (s)')
ylabel('Voltage at bus 6(p.u.)') % ylabel('Voltage at bus 6(p.u.)')
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Voltage at bus 6') % title('Voltage at bus 6')
legend('EMT phase A','EMT phase B','EMT phase C') % legend('EMT phase A','EMT phase B','EMT phase C')
%% current on branch 5-6 % %% current on branch 5-6
figure(9) % figure(9)
% EMT result % % EMT result
plot(t_final, sol_final(:,78),'r','LineWidth',1) % plot(t_final, sol_final(:,78),'r','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,79),'g','LineWidth',1) % plot(t_final, sol_final(:,79),'g','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,80),'b','LineWidth',1) % plot(t_final, sol_final(:,80),'b','LineWidth',1)
%
xlabel('Time (s)') % xlabel('Time (s)')
ylabel('Current on branch 5-6(p.u.)') % ylabel('Current on branch 5-6(p.u.)')
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Current on branch 5-6') % title('Current on branch 5-6')
legend('EMT phase A','EMT phase B','EMT phase C') % legend('EMT phase A','EMT phase B','EMT phase C')
%% current on branch 6-7 %% current on branch 6-7
figure(10) figure(10)
@ -168,49 +164,49 @@ set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Current on branch 6-7') title('Current on branch 6-7')
legend('EMT phase A','EMT phase B','EMT phase C') legend('EMT phase A','EMT phase B','EMT phase C')
%% current on branch 7-8 % %% current on branch 7-8
figure(11) % figure(11)
% EMT result % % EMT result
plot(t_final, sol_final(:,84),'r','LineWidth',1) % plot(t_final, sol_final(:,84),'r','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,85),'g','LineWidth',1) % plot(t_final, sol_final(:,85),'g','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,86),'b','LineWidth',1) % plot(t_final, sol_final(:,86),'b','LineWidth',1)
%
xlabel('Time (s)') % xlabel('Time (s)')
ylabel('Current on branch 7-8(p.u.)') % ylabel('Current on branch 7-8(p.u.)')
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Current on branch 7-8') % title('Current on branch 7-8')
legend('EMT phase A','EMT phase B','EMT phase C') % legend('EMT phase A','EMT phase B','EMT phase C')
%% current on branch 9-10 % %% current on branch 9-10
figure(12) % figure(12)
% EMT result % % EMT result
plot(t_final, sol_final(:,96),'r','LineWidth',1) % plot(t_final, sol_final(:,96),'r','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,97),'g','LineWidth',1) % plot(t_final, sol_final(:,97),'g','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,98),'b','LineWidth',1) % plot(t_final, sol_final(:,98),'b','LineWidth',1)
%
xlabel('Time (s)') % xlabel('Time (s)')
ylabel('Current on branch 9-10(p.u.)') % ylabel('Current on branch 9-10(p.u.)')
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Current on branch 9-10') % title('Current on branch 9-10')
legend('EMT phase A','EMT phase B','EMT phase C') % legend('EMT phase A','EMT phase B','EMT phase C')
%% Voltage at bus 6 % %% Voltage at bus 6
figure(13) % figure(13)
% EMT result % % EMT result
plot(t_final, sol_final(:,108),'r','LineWidth',1) % plot(t_final, sol_final(:,108),'r','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,109),'g','LineWidth',1) % plot(t_final, sol_final(:,109),'g','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,110),'b','LineWidth',1) % plot(t_final, sol_final(:,110),'b','LineWidth',1)
hold on % hold on
plot(t_final, sol_final(:,111),'b','LineWidth',1) % plot(t_final, sol_final(:,111),'b','LineWidth',1)
%
xlabel('Time (s)') % xlabel('Time (s)')
ylabel('Voltage at bus 6(p.u.)') % ylabel('Voltage at bus 6(p.u.)')
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12); % set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
title('Voltage at bus 6') % title('Voltage at bus 6')
legend('Gen1','Gen2','Gen3','Gen4') % legend('Gen1','Gen2','Gen3','Gen4')

@ -1,10 +1,7 @@
clc; clear; close; clc; clear; close;
addpath('EMT') addpath('EMT')
testSystem = 'twoarea'; res = runPowerSAS('emt','twoarea');
[t_final, sol_final] = calEMT(testSystem); plotEMTResults(res);
plotEMTResults();

@ -0,0 +1,6 @@
03:20:33[INFO]The session ID is 20230425T032033017.
03:20:33[INFO]CASE twoarea. Timestamp=20230425T032033017.
03:20:33[INFO]Finished loading data file.
03:20:41[INFO]

@ -99,6 +99,8 @@ end
%% main body %% main body
if strcmp(simType,'pf') if strcmp(simType,'pf')
res=calPF(SysData,options,caseName); res=calPF(SysData,options,caseName);
elseif strcmp(simType,'emt')
res=calEMT(data);
elseif strcmp(simType,'cpf') elseif strcmp(simType,'cpf')
res=calCPF(SysData,options,caseName,varargin{:}); res=calCPF(SysData,options,caseName,varargin{:});
elseif strcmp(simType,'tsa') elseif strcmp(simType,'tsa')

Loading…
Cancel
Save