mirror of
https://github.com/ANL-CEEESA/powersas.m.git
synced 2025-12-06 09:58:51 -06:00
enable emt in runPowerSAS.m function
This commit is contained in:
@@ -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;
|
||||||
|
sol_final = res.sol_final;
|
||||||
|
|
||||||
% t_final = [t_pre; t_on(2:end); t_post(2:end)];
|
% %% relative rotor angles
|
||||||
% sol_final = [x_pre; x_on(2:end,:); x_post(2:end,:)];
|
% figure(1)
|
||||||
% % t_final = [t_pre; t_on(2:end)];
|
% % EMT result
|
||||||
% % sol_final = [x_pre; x_on(2:end,:)];
|
% plot(t_final, (sol_final(:,1)-sol_final(:,1) )*180/pi,'r--','LineWidth',3)
|
||||||
% % t_final = [t_pre];
|
% hold on
|
||||||
% % sol_final = [x_pre];
|
% plot(t_final, (sol_final(:,2)-sol_final(:,1) )*180/pi,'g--','LineWidth',3)
|
||||||
|
% hold on
|
||||||
|
% plot(t_final, (sol_final(:,3)-sol_final(:,1) )*180/pi,'b--','LineWidth',3)
|
||||||
|
% hold on
|
||||||
|
% plot(t_final, (sol_final(:,4)-sol_final(:,1) )*180/pi,'b--','LineWidth',3)
|
||||||
|
% hold on
|
||||||
|
% % ylim([-60,10])
|
||||||
|
% xlabel('Time (s)')
|
||||||
|
% ylabel('Relative rotor angles (degree)')
|
||||||
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
|
% title('Relative rotor angles')
|
||||||
|
% legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
||||||
|
|
||||||
%% relative rotor angles
|
% %% frequency deviation
|
||||||
figure(1)
|
% figure(2)
|
||||||
% EMT result
|
% % EMT result
|
||||||
plot(t_final, (sol_final(:,1)-sol_final(:,1) )*180/pi,'r--','LineWidth',3)
|
% plot(t_final, sol_final(:,9),'r--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, (sol_final(:,2)-sol_final(:,1) )*180/pi,'g--','LineWidth',3)
|
% plot(t_final, sol_final(:,10),'g--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, (sol_final(:,3)-sol_final(:,1) )*180/pi,'b--','LineWidth',3)
|
% plot(t_final, sol_final(:,11),'b--','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(:,12),'m--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
% ylim([-60,10])
|
% % ylim([-60,10])
|
||||||
xlabel('Time (s)')
|
% % xlim([0,0.25])
|
||||||
ylabel('Relative rotor angles (degree)')
|
% xlabel('Time (s)')
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
% ylabel('Frequency deviation (p.u.)')
|
||||||
title('Relative rotor angles')
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
% title('Frequency deviation')
|
||||||
|
% legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
||||||
|
|
||||||
%% frequency deviation
|
% %% Exciter field voltage
|
||||||
figure(2)
|
% figure(3)
|
||||||
% EMT result
|
% % EMT result
|
||||||
plot(t_final, sol_final(:,9),'r--','LineWidth',3)
|
% plot(t_final, sol_final(:,33),'r--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,10),'g--','LineWidth',3)
|
% plot(t_final, sol_final(:,34),'g--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,11),'b--','LineWidth',3)
|
% plot(t_final, sol_final(:,35),'b--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,12),'m--','LineWidth',3)
|
% plot(t_final, sol_final(:,36),'m--','LineWidth',3)
|
||||||
hold on
|
% xlabel('Time (s)')
|
||||||
% ylim([-60,10])
|
% xlim([0,0.4])
|
||||||
% xlim([0,0.25])
|
% ylabel('Exciter field voltage (p.u.)')
|
||||||
xlabel('Time (s)')
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
ylabel('Frequency deviation (p.u.)')
|
% title('Exciter field voltage')
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
% legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
||||||
title('Frequency deviation')
|
|
||||||
legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
|
||||||
|
|
||||||
%% Exciter field voltage
|
% %% P1
|
||||||
figure(3)
|
% figure(4)
|
||||||
% EMT result
|
% % EMT result
|
||||||
plot(t_final, sol_final(:,33),'r--','LineWidth',3)
|
% plot(t_final, sol_final(:,37),'r--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,34),'g--','LineWidth',3)
|
% plot(t_final, sol_final(:,38),'g--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,35),'b--','LineWidth',3)
|
% plot(t_final, sol_final(:,39),'b--','LineWidth',3)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,36),'m--','LineWidth',3)
|
% plot(t_final, sol_final(:,40),'m--','LineWidth',3)
|
||||||
xlabel('Time (s)')
|
%
|
||||||
xlim([0,0.4])
|
% xlabel('Time (s)')
|
||||||
ylabel('Exciter field voltage (p.u.)')
|
% ylabel('P1(p.u.)')
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
title('Exciter field voltage')
|
% title('P1')
|
||||||
legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
% legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
||||||
|
|
||||||
%% P1
|
% %% Voltage at bus 7
|
||||||
figure(4)
|
% figure(5)
|
||||||
% EMT result
|
% % EMT result
|
||||||
plot(t_final, sol_final(:,37),'r--','LineWidth',3)
|
% plot(t_final, sol_final(:,51),'r','LineWidth',1)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,38),'g--','LineWidth',3)
|
% plot(t_final, sol_final(:,52),'g','LineWidth',1)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,39),'b--','LineWidth',3)
|
% plot(t_final, sol_final(:,53),'b','LineWidth',1)
|
||||||
hold on
|
%
|
||||||
plot(t_final, sol_final(:,40),'m--','LineWidth',3)
|
% xlabel('Time (s)')
|
||||||
|
% ylabel('Voltage at bus 7(p.u.)')
|
||||||
xlabel('Time (s)')
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
ylabel('P1(p.u.)')
|
% title('Voltage at bus 7')
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
% legend('EMT phase A','EMT phase B','EMT phase C')
|
||||||
title('P1')
|
|
||||||
legend('EMT G1','EMT G2','EMT G3','EMT G4')
|
|
||||||
|
|
||||||
%% Voltage at bus 7
|
|
||||||
figure(5)
|
|
||||||
% EMT result
|
|
||||||
plot(t_final, sol_final(:,51),'r','LineWidth',1)
|
|
||||||
hold on
|
|
||||||
plot(t_final, sol_final(:,52),'g','LineWidth',1)
|
|
||||||
hold on
|
|
||||||
plot(t_final, sol_final(:,53),'b','LineWidth',1)
|
|
||||||
|
|
||||||
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)')
|
||||||
|
% ylabel('Voltage at bus 10(p.u.)')
|
||||||
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
|
% title('Voltage at bus 10')
|
||||||
|
% legend('EMT phase A','EMT phase B','EMT phase C')
|
||||||
|
|
||||||
xlabel('Time (s)')
|
% %% Voltage at bus 6
|
||||||
ylabel('Voltage at bus 10(p.u.)')
|
% figure(8)
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
% % EMT result
|
||||||
title('Voltage at bus 10')
|
% plot(t_final, sol_final(:,48),'r','LineWidth',1)
|
||||||
legend('EMT phase A','EMT phase B','EMT phase C')
|
% hold on
|
||||||
|
% plot(t_final, sol_final(:,49),'g','LineWidth',1)
|
||||||
|
% hold on
|
||||||
|
% plot(t_final, sol_final(:,50),'b','LineWidth',1)
|
||||||
|
%
|
||||||
|
% xlabel('Time (s)')
|
||||||
|
% ylabel('Voltage at bus 6(p.u.)')
|
||||||
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
|
% title('Voltage at bus 6')
|
||||||
|
% legend('EMT phase A','EMT phase B','EMT phase C')
|
||||||
|
|
||||||
%% Voltage at bus 6
|
% %% current on branch 5-6
|
||||||
figure(8)
|
% figure(9)
|
||||||
% EMT result
|
% % EMT result
|
||||||
plot(t_final, sol_final(:,48),'r','LineWidth',1)
|
% plot(t_final, sol_final(:,78),'r','LineWidth',1)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,49),'g','LineWidth',1)
|
% plot(t_final, sol_final(:,79),'g','LineWidth',1)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,50),'b','LineWidth',1)
|
% plot(t_final, sol_final(:,80),'b','LineWidth',1)
|
||||||
|
%
|
||||||
xlabel('Time (s)')
|
% xlabel('Time (s)')
|
||||||
ylabel('Voltage at bus 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('Voltage at bus 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 5-6
|
|
||||||
figure(9)
|
|
||||||
% EMT result
|
|
||||||
plot(t_final, sol_final(:,78),'r','LineWidth',1)
|
|
||||||
hold on
|
|
||||||
plot(t_final, sol_final(:,79),'g','LineWidth',1)
|
|
||||||
hold on
|
|
||||||
plot(t_final, sol_final(:,80),'b','LineWidth',1)
|
|
||||||
|
|
||||||
xlabel('Time (s)')
|
|
||||||
ylabel('Current on branch 5-6(p.u.)')
|
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
|
||||||
title('Current on branch 5-6')
|
|
||||||
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)')
|
||||||
|
% ylabel('Current on branch 7-8(p.u.)')
|
||||||
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
|
% title('Current on branch 7-8')
|
||||||
|
% legend('EMT phase A','EMT phase B','EMT phase C')
|
||||||
|
|
||||||
xlabel('Time (s)')
|
% %% current on branch 9-10
|
||||||
ylabel('Current on branch 7-8(p.u.)')
|
% figure(12)
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
% % EMT result
|
||||||
title('Current on branch 7-8')
|
% plot(t_final, sol_final(:,96),'r','LineWidth',1)
|
||||||
legend('EMT phase A','EMT phase B','EMT phase C')
|
% hold on
|
||||||
|
% plot(t_final, sol_final(:,97),'g','LineWidth',1)
|
||||||
|
% hold on
|
||||||
|
% plot(t_final, sol_final(:,98),'b','LineWidth',1)
|
||||||
|
%
|
||||||
|
% xlabel('Time (s)')
|
||||||
|
% ylabel('Current on branch 9-10(p.u.)')
|
||||||
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
|
% title('Current on branch 9-10')
|
||||||
|
% legend('EMT phase A','EMT phase B','EMT phase C')
|
||||||
|
|
||||||
%% current on branch 9-10
|
% %% Voltage at bus 6
|
||||||
figure(12)
|
% figure(13)
|
||||||
% EMT result
|
% % EMT result
|
||||||
plot(t_final, sol_final(:,96),'r','LineWidth',1)
|
% plot(t_final, sol_final(:,108),'r','LineWidth',1)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,97),'g','LineWidth',1)
|
% plot(t_final, sol_final(:,109),'g','LineWidth',1)
|
||||||
hold on
|
% hold on
|
||||||
plot(t_final, sol_final(:,98),'b','LineWidth',1)
|
% plot(t_final, sol_final(:,110),'b','LineWidth',1)
|
||||||
|
% hold on
|
||||||
xlabel('Time (s)')
|
% plot(t_final, sol_final(:,111),'b','LineWidth',1)
|
||||||
ylabel('Current on branch 9-10(p.u.)')
|
%
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
% xlabel('Time (s)')
|
||||||
title('Current on branch 9-10')
|
% ylabel('Voltage at bus 6(p.u.)')
|
||||||
legend('EMT phase A','EMT phase B','EMT phase C')
|
% set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
||||||
|
% title('Voltage at bus 6')
|
||||||
%% Voltage at bus 6
|
% legend('Gen1','Gen2','Gen3','Gen4')
|
||||||
figure(13)
|
|
||||||
% EMT result
|
|
||||||
plot(t_final, sol_final(:,108),'r','LineWidth',1)
|
|
||||||
hold on
|
|
||||||
plot(t_final, sol_final(:,109),'g','LineWidth',1)
|
|
||||||
hold on
|
|
||||||
plot(t_final, sol_final(:,110),'b','LineWidth',1)
|
|
||||||
hold on
|
|
||||||
plot(t_final, sol_final(:,111),'b','LineWidth',1)
|
|
||||||
|
|
||||||
xlabel('Time (s)')
|
|
||||||
ylabel('Voltage at bus 6(p.u.)')
|
|
||||||
set(gca, 'Fontname', 'Times New Roman', 'Fontsize', 12);
|
|
||||||
title('Voltage at bus 6')
|
|
||||||
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();
|
|
||||||
|
|
||||||
|
|||||||
6
example/output/~default_log.txt
Normal file
6
example/output/~default_log.txt
Normal file
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user