compareDPresults_with_PLECS.m 4.43 KB
Newer Older
1
2
3
4
clc
clear
%% read PLECS results

5
Results_PLECS = csvread('../../../vsa/Results/SynGenDqEmt_ABCFault_PLECS/Voltages_and_currents.csv'); 
6
7
8
%Te_PLECS = csvread('../../vsa/Results/SynGenVBREmt_ABCFault_PLECS/electrical_torque.csv'); 
%omega_PLECS = csvread('../../vsa/Results/SynGenVBREmt_ABCFault_PLECS/omega.csv'); 
%theta_PLECS = csvread('../../vsa/Results/SynGenVBREmt_ABCFault_PLECS/theta.csv'); 
9
10
11
12

%% Read data from DP simulation and calculate absolute value and phase

% Read values from CSV files
13
14
voltageDP = csvread('../../../vsa/Results/Testing/data_vt.csv');
currentDP = csvread('../../../vsa/Results/Testing/data_j.csv');
15
%Log_SynGen = csvread('../../vsa/Results//SynGenDqDynPh_ABCFault_DPsim/Euler/SynGen_gen.csv');
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
compOffsetDP = (size(voltageDP,2) - 1) / 2;

% Calculate Voltage DP absolute value
voltageAbsDP = voltageDP(:,1);
for col = 2:( compOffsetDP + 1 )
    for row = 1:size(voltageDP,1)
        voltageAbsDP(row,col) = sqrt(voltageDP(row,col)^2 + ...
            voltageDP(row,col+compOffsetDP)^2);
    end
end

% Voltage Shift DP values
voltageShiftDP = voltageDP(:,1);
for col = 2:(compOffsetDP + 1)
    for row = 1:size(voltageDP,1)
        voltageShiftDP(row,col) = voltageDP(row,col)*cos(2*pi*60*voltageDP(row,1)) - ...
            voltageDP(row,col+compOffsetDP)*sin(2*pi*60*voltageDP(row,1));
    end
end

% Calculate Current DP absolute value
currentAbsDP = currentDP(:,1);
for col = 2:( compOffsetDP + 1 )
    for row = 1:size(currentDP,1)
        currentAbsDP(row,col) = sqrt(currentDP(row,col)^2 + ...
            currentDP(row,col+compOffsetDP)^2);
    end
end

% Current Shift DP values
currentShiftDP = currentDP(:,1);
for col = 2:(compOffsetDP + 1)
    for row = 1:size(currentDP,1)
        currentShiftDP(row,col) = currentDP(row,col)*cos(2*pi*60*currentDP(row,1)) - ...
            currentDP(row,col+compOffsetDP)*sin(2*pi*60*currentDP(row,1));
    end
end


%% Plot Voltage

% Phase A
figure(1)
hold off
PLECSplot = plot(Results_PLECS(:,1), Results_PLECS(:,2), '--');
hold on
DPplot = plot(voltageShiftDP(:,1),voltageShiftDP(:,2));
DPabsPlot = plot(voltageAbsDP(:,1),voltageAbsDP(:,2));
title('Voltage A');
65
legend('Voltage Phase a Simulink', 'DP shift a', 'DP abs a')
66
67
68
69
70
71
72
73
74
75
76
xlabel('time [s]')
ylabel('voltage [V]')

% Phase B
figure(2)
hold off
PLECSplot2 = plot(Results_PLECS(:,1), Results_PLECS(:,3), '--');
hold on
DPplot2 = plot(voltageShiftDP(:,1),voltageShiftDP(:,3));
DPabsPlot2 = plot(voltageAbsDP(:,1),voltageAbsDP(:,3));
title('Voltage B');
77
legend('Voltage Phase b Simulink', 'DP shift b', 'DP abs b')
78
79
80
81
82
83
84
85
86
87
88
xlabel('time [s]')
ylabel('voltage [V]')

% Phase C
figure(3)
hold off
PLECSplot3 = plot(Results_PLECS(:,1), Results_PLECS(:,4), '--');
hold on
DPplot3 = plot(voltageShiftDP(:,1),voltageShiftDP(:,4));
DPabsPlot3 = plot(voltageAbsDP(:,1),voltageAbsDP(:,4));
title('Voltage C');
89
legend('Voltage Phase c Simulink', 'DP shift c', 'DP abs c')
90
91
92
93
94
95
96
97
98
99
xlabel('time [s]')
ylabel('voltage [V]')

%% Plot Current

% Phase A
figure(4)
hold off
PLECSplotc = plot(Results_PLECS(:,1), Results_PLECS(:,5), '--');
hold on
100
DPplotc = plot(currentShiftDP(:,1),-currentShiftDP(:,2));
101
102
DPabsPlotc = plot(currentAbsDP(:,1),currentAbsDP(:,2));
title('Current phase A');
103
legend('Current Phase a Simulink', 'DP shift a', 'DP abs a')
104
105
106
107
108
109
110
111
xlabel('time [s]')
ylabel('current [A]')

% Phase B
figure(5)
hold off
PLECSplot2c = plot(Results_PLECS(:,1), Results_PLECS(:,6), '--');
hold on
112
DPplot2c = plot(currentShiftDP(:,1),-currentShiftDP(:,3));
113
114
DPabsPlot2c = plot(currentAbsDP(:,1),currentAbsDP(:,3));
title('Current phase B');
115
legend('Current Phase b Simulink', 'DP shift b', 'DP abs b')
116
117
118
119
120
121
122
123
xlabel('time [s]')
ylabel('current [A]')

% Phase C
figure(6)
hold off
PLECSplot3c = plot(Results_PLECS(:,1), Results_PLECS(:,7), '--');
hold on
124
DPplot3c = plot(currentShiftDP(:,1),-currentShiftDP(:,4));
125
126
DPabsPlot3c = plot(currentAbsDP(:,1),currentAbsDP(:,4));
title('Currents phase C');
127
legend('Current Phase c Simulink', 'DP shift c', 'DP abs c')
128
129
130
xlabel('time [s]')
ylabel('current [A]')

131
132
% figure(7)
% hold off
133
% plot(Log_SynGen(:,1),Log_SynGen(:,21));
134
135
136
137
138
139
140
141
% hold on
% plot(Results_PLECS(:,1),omega_PLECS);
% 
% title('Rotor speed');
% legend('\omega DPSim','\omega PLECS');
% 
% figure(8)
% hold off
142
% plot(Log_SynGen(:,1),Log_SynGen(:,20));
143
144
145
146
147
148
149
150
% hold on
% plot(Results_PLECS(:,1),Te_PLECS);
% 
% title('Electrical Torque');
% legend('Te DPSim','Te PLECS');
% 
% figure(9)
% hold off
151
% plot(Log_SynGen(:,1),Log_SynGen(:,22));
152
153
154
155
156
% hold on
% plot(Results_PLECS(:,1),theta_PLECS);
% 
% title('Rotor position');
% legend('\theta DPSim','\theta PLECS');
Viviane Sapucaia's avatar
Viviane Sapucaia committed
157