Skip to content

Commit 32d7485

Browse files
committed
Updated to support PFRecord propagation and uploading matlab scripts
- Fixed propagation for sys model to properly pass the power flow data - Created additional initial guess cases for different dispatch scenarios - Added the matlab psat scripts to generate the power flow data
1 parent 315c337 commit 32d7485

31 files changed

Lines changed: 4341 additions & 12 deletions

Assets/PSAT_powerflow_scripts/d_kundur1.mdl

Lines changed: 3468 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Bus.con = [ ...
2+
1 20 1.03 0.3229 1 1;
3+
2 20 1.01 0.1536 1 1;
4+
3 20 1.03 -0.1187 2 1;
5+
4 20 1.01 -0.295 2 1;
6+
5 230 1.01 0.2112 1 1;
7+
6 230 0.9876 0.03665 1 1;
8+
7 230 1 -0.1065 1 1;
9+
8 230 1 -0.3368 3 1;
10+
9 230 0.9899 -0.555 2 1;
11+
10 230 0.9938 -0.4119 2 1;
12+
11 230 1.013 -0.2339 2 1;
13+
];
14+
15+
Line.con = [ ...
16+
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
17+
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
18+
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
19+
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
20+
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
21+
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
22+
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
23+
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
24+
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
25+
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
26+
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
27+
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
28+
];
29+
30+
Fault.con = [ ...
31+
8 100 230 60 1 1.05 0 1e-05;
32+
];
33+
34+
SW.con = [ ...
35+
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
36+
];
37+
38+
PV.con = [ ...
39+
1 100 20 7 1.03 5 -2 1.1 0.9 1 1;
40+
2 100 20 7 1.01 5 -2 1.1 0.9 1 1;
41+
4 100 20 7 1.01 5 -2 1.1 0.9 1 1;
42+
];
43+
44+
PQ.con = [ ...
45+
9 100 230 17.67 -2.5 1.05 0.95 0;
46+
7 100 230 9.67 -1 1.05 0.95 0;
47+
];
48+
49+
Pl.con = [ ...
50+
7 100 230 60 0 100 0 0 0 100 1 1;
51+
9 100 230 60 0 100 0 0 0 100 1 1;
52+
];
53+
54+
Syn.con = [ ...
55+
4 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
56+
2 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0 0 0 1 1;
57+
1 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0.002 0 0 1 1;
58+
3 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
59+
];
60+
61+
Bus.names = {...
62+
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
63+
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
64+
'Bus 11'};
65+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Bus.con = [ ...
2+
1 20 1.03 0.3229 1 1;
3+
2 20 1.01 0.1536 1 1;
4+
3 20 1.03 -0.1187 2 1;
5+
4 20 1.01 -0.295 2 1;
6+
5 230 1.01 0.2112 1 1;
7+
6 230 0.9876 0.03665 1 1;
8+
7 230 1 -0.1065 1 1;
9+
8 230 1 -0.3368 3 1;
10+
9 230 0.9899 -0.555 2 1;
11+
10 230 0.9938 -0.4119 2 1;
12+
11 230 1.013 -0.2339 2 1;
13+
];
14+
15+
Line.con = [ ...
16+
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
17+
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
18+
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
19+
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
20+
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
21+
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
22+
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
23+
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
24+
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
25+
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
26+
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
27+
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
28+
];
29+
30+
Fault.con = [ ...
31+
8 100 230 60 1 1.05 0 1e-05;
32+
];
33+
34+
SW.con = [ ...
35+
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
36+
];
37+
38+
PV.con = [ ...
39+
1 100 20 5 1.03 5 -2 1.1 0.9 1 1;
40+
2 100 20 5 1.01 5 -2 1.1 0.9 1 1;
41+
4 100 20 5 1.01 5 -2 1.1 0.9 1 1;
42+
];
43+
44+
PQ.con = [ ...
45+
9 100 230 10.00 0.0 1.05 0.95 0;
46+
7 100 230 5.00 0.0 1.05 0.95 0;
47+
];
48+
49+
Pl.con = [ ...
50+
7 100 230 60 0 100 0 0 0 100 1 1;
51+
9 100 230 60 0 100 0 0 0 100 1 1;
52+
];
53+
54+
Syn.con = [ ...
55+
4 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
56+
2 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0 0 0 1 1;
57+
1 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0.002 0 0 1 1;
58+
3 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
59+
];
60+
61+
Bus.names = {...
62+
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
63+
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
64+
'Bus 11'};
65+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Bus.con = [ ...
2+
1 20 1.03 0.3229 1 1;
3+
2 20 1.01 0.1536 1 1;
4+
3 20 1.03 -0.1187 2 1;
5+
4 20 1.01 -0.295 2 1;
6+
5 230 1.01 0.2112 1 1;
7+
6 230 0.9876 0.03665 1 1;
8+
7 230 1 -0.1065 1 1;
9+
8 230 1 -0.3368 3 1;
10+
9 230 0.9899 -0.555 2 1;
11+
10 230 0.9938 -0.4119 2 1;
12+
11 230 1.013 -0.2339 2 1;
13+
];
14+
15+
Line.con = [ ...
16+
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
17+
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
18+
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
19+
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
20+
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
21+
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
22+
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
23+
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
24+
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
25+
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
26+
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
27+
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
28+
];
29+
30+
Fault.con = [ ...
31+
8 100 230 60 1 1.05 0 1e-05;
32+
];
33+
34+
SW.con = [ ...
35+
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
36+
];
37+
38+
PV.con = [ ...
39+
1 100 20 2.5 1.03 5 -2 1.1 0.9 1 1;
40+
2 100 20 2.5 1.01 5 -2 1.1 0.9 1 1;
41+
4 100 20 2.5 1.01 5 -2 1.1 0.9 1 1;
42+
];
43+
44+
PQ.con = [ ...
45+
9 100 230 5.00 0.0 1.05 0.95 0;
46+
7 100 230 2.50 0.0 1.05 0.95 0;
47+
];
48+
49+
Pl.con = [ ...
50+
7 100 230 60 0 100 0 0 0 100 1 1;
51+
9 100 230 60 0 100 0 0 0 100 1 1;
52+
];
53+
54+
Syn.con = [ ...
55+
4 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
56+
2 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0 0 0 1 1;
57+
1 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0.002 0 0 1 1;
58+
3 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
59+
];
60+
61+
Bus.names = {...
62+
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
63+
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
64+
'Bus 11'};
65+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Bus.con = [ ...
2+
1 20 1.03 0.3229 1 1;
3+
2 20 1.01 0.1536 1 1;
4+
3 20 1.03 -0.1187 2 1;
5+
4 20 1.01 -0.295 2 1;
6+
5 230 1.01 0.2112 1 1;
7+
6 230 0.9876 0.03665 1 1;
8+
7 230 1 -0.1065 1 1;
9+
8 230 1 -0.3368 3 1;
10+
9 230 0.9899 -0.555 2 1;
11+
10 230 0.9938 -0.4119 2 1;
12+
11 230 1.013 -0.2339 2 1;
13+
];
14+
15+
Line.con = [ ...
16+
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
17+
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
18+
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
19+
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
20+
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
21+
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
22+
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
23+
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
24+
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
25+
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
26+
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
27+
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
28+
];
29+
30+
Fault.con = [ ...
31+
8 100 230 60 1 1.05 0 1e-05;
32+
];
33+
34+
SW.con = [ ...
35+
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
36+
];
37+
38+
PV.con = [ ...
39+
1 100 20 1.5 1.03 5 -2 1.1 0.9 1 1;
40+
2 100 20 1.5 1.01 5 -2 1.1 0.9 1 1;
41+
4 100 20 1.5 1.01 5 -2 1.1 0.9 1 1;
42+
];
43+
44+
PQ.con = [ ...
45+
9 100 230 3.00 0.0 1.05 0.95 0;
46+
7 100 230 3.00 0.0 1.05 0.95 0;
47+
];
48+
49+
Pl.con = [ ...
50+
7 100 230 60 0 100 0 0 0 100 1 1;
51+
9 100 230 60 0 100 0 0 0 100 1 1;
52+
];
53+
54+
Syn.con = [ ...
55+
4 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
56+
2 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0 0 0 1 1;
57+
1 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 13 0 0 0 1 1 0.002 0 0 1 1;
58+
3 900 20 60 6 0.2 0.0025 1.8 0.3 0.25 8 0.03 1.7 0.55 0.25 0.4 0.05 12.35 0 0 0 1 1 0 0 0 1 1;
59+
];
60+
61+
Bus.names = {...
62+
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
63+
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
64+
'Bus 11'};
65+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
% Script to obtain the power flow solution from PSAT models
2+
% LV, 2024/01
3+
clear all; clc;
4+
% put the path to where the psat .zip has been uncompressed
5+
cd("C:\Users\vanfretti\Documents\MATLAB\psat-2.1.11-mat\psat")
6+
initpsat % starts PSAT in command line mode
7+
% put the path to the working director where the models are stored
8+
cd("C:\Users\vanfretti\Documents\MATLAB\example2_psat_models")
9+
clpsat.readfile = 0; % do not reload the data files
10+
11+
%% Specify the model to be solved and settings
12+
runpsat('d_kundur1_mdl_case0.m','data')
13+
% Set the system parameters
14+
Settings.freq = 60;
15+
Settings.mva = 100;
16+
Settings.showlf = 1;
17+
% Power flow settings and solution
18+
Settings.lftol = 1e-12;
19+
runpsat('pf')
20+
21+
%% Post-process the data
22+
23+
% calculate the line flows
24+
[ps0,qs0,pr0,qr0] = fm_flows;
25+
26+
% extract the bus voltages and angles for further use
27+
voltages = DAE.y(1+Bus.n:2*Bus.n);
28+
angles = DAE.y(Bus.a);
29+
30+
% extract the power at each bus from the solution
31+
Sbase = 100.0e6;
32+
pgen = Snapshot.Pg*Sbase/1e6;
33+
qgen = Snapshot.Qg*Sbase/1e6;
34+
pload = Snapshot.Pl*Sbase/1e6;
35+
qload = Snapshot.Ql*Sbase/1e6;
36+
37+
% Make a table
38+
varNames = {'Bus', '|V (pu)|','/_V (rad)', ...
39+
'Pgen (MW)', 'Qgen (Mvar)', ...
40+
'Pload (MW)', 'Qload (Mvar)'};
41+
Tableout = table(Bus.names,voltages,angles,pgen,qgen,pload,qload,'VariableNames',varNames);
42+
disp(Tableout)
43+
%% Display data for reuse
44+
% disp('Voltage Magnitudes')
45+
% disp(voltages)
46+
% figure(101)
47+
% bar(voltages,'DisplayName','voltages')
48+
% xlabel('Iteration no and Bus no')
49+
% ylabel('Voltage (pu)')
50+
51+
% Make a table
52+
varNames = {'Bus', '|V (pu)|','/_V (rad)', ...
53+
'Pgen (MW)', 'Qgen (Mvar)', ...
54+
'Pload (MW)', 'Qload (Mvar)'};
55+
Tableout = table(Bus.names,voltages,angles,pgen,qgen,pload,qload,'VariableNames',varNames);
56+
disp(Tableout)
57+
%% Display data for reuse
58+
format long g
59+
disp('Voltage Magnitudes')
60+
disp(voltages)
61+
figure(101)
62+
bar(voltages,'DisplayName','voltages')
63+
xlabel('Iteration no and Bus no')
64+
ylabel('Voltage (pu)')
65+
66+
%% Display record data
67+
run dexample2_print_record_data.m
68+
69+
%closepsat % exits PSAT gracefully

0 commit comments

Comments
 (0)