Skip to content

Commit

Permalink
Updated to support PFRecord propagation and uploading matlab scripts
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
lvanfretti committed Mar 14, 2024
1 parent 315c337 commit 32d7485
Show file tree
Hide file tree
Showing 31 changed files with 4,341 additions and 12 deletions.
3,468 changes: 3,468 additions & 0 deletions Assets/PSAT_powerflow_scripts/d_kundur1.mdl

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions Assets/PSAT_powerflow_scripts/d_kundur1_mdl_case0.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Bus.con = [ ...
1 20 1.03 0.3229 1 1;
2 20 1.01 0.1536 1 1;
3 20 1.03 -0.1187 2 1;
4 20 1.01 -0.295 2 1;
5 230 1.01 0.2112 1 1;
6 230 0.9876 0.03665 1 1;
7 230 1 -0.1065 1 1;
8 230 1 -0.3368 3 1;
9 230 0.9899 -0.555 2 1;
10 230 0.9938 -0.4119 2 1;
11 230 1.013 -0.2339 2 1;
];

Line.con = [ ...
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
];

Fault.con = [ ...
8 100 230 60 1 1.05 0 1e-05;
];

SW.con = [ ...
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
];

PV.con = [ ...
1 100 20 7 1.03 5 -2 1.1 0.9 1 1;
2 100 20 7 1.01 5 -2 1.1 0.9 1 1;
4 100 20 7 1.01 5 -2 1.1 0.9 1 1;
];

PQ.con = [ ...
9 100 230 17.67 -2.5 1.05 0.95 0;
7 100 230 9.67 -1 1.05 0.95 0;
];

Pl.con = [ ...
7 100 230 60 0 100 0 0 0 100 1 1;
9 100 230 60 0 100 0 0 0 100 1 1;
];

Syn.con = [ ...
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;
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;
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;
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;
];

Bus.names = {...
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
'Bus 11'};

65 changes: 65 additions & 0 deletions Assets/PSAT_powerflow_scripts/d_kundur1_mdl_case1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Bus.con = [ ...
1 20 1.03 0.3229 1 1;
2 20 1.01 0.1536 1 1;
3 20 1.03 -0.1187 2 1;
4 20 1.01 -0.295 2 1;
5 230 1.01 0.2112 1 1;
6 230 0.9876 0.03665 1 1;
7 230 1 -0.1065 1 1;
8 230 1 -0.3368 3 1;
9 230 0.9899 -0.555 2 1;
10 230 0.9938 -0.4119 2 1;
11 230 1.013 -0.2339 2 1;
];

Line.con = [ ...
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
];

Fault.con = [ ...
8 100 230 60 1 1.05 0 1e-05;
];

SW.con = [ ...
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
];

PV.con = [ ...
1 100 20 5 1.03 5 -2 1.1 0.9 1 1;
2 100 20 5 1.01 5 -2 1.1 0.9 1 1;
4 100 20 5 1.01 5 -2 1.1 0.9 1 1;
];

PQ.con = [ ...
9 100 230 10.00 0.0 1.05 0.95 0;
7 100 230 5.00 0.0 1.05 0.95 0;
];

Pl.con = [ ...
7 100 230 60 0 100 0 0 0 100 1 1;
9 100 230 60 0 100 0 0 0 100 1 1;
];

Syn.con = [ ...
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;
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;
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;
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;
];

Bus.names = {...
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
'Bus 11'};

65 changes: 65 additions & 0 deletions Assets/PSAT_powerflow_scripts/d_kundur1_mdl_case2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Bus.con = [ ...
1 20 1.03 0.3229 1 1;
2 20 1.01 0.1536 1 1;
3 20 1.03 -0.1187 2 1;
4 20 1.01 -0.295 2 1;
5 230 1.01 0.2112 1 1;
6 230 0.9876 0.03665 1 1;
7 230 1 -0.1065 1 1;
8 230 1 -0.3368 3 1;
9 230 0.9899 -0.555 2 1;
10 230 0.9938 -0.4119 2 1;
11 230 1.013 -0.2339 2 1;
];

Line.con = [ ...
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
];

Fault.con = [ ...
8 100 230 60 1 1.05 0 1e-05;
];

SW.con = [ ...
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
];

PV.con = [ ...
1 100 20 2.5 1.03 5 -2 1.1 0.9 1 1;
2 100 20 2.5 1.01 5 -2 1.1 0.9 1 1;
4 100 20 2.5 1.01 5 -2 1.1 0.9 1 1;
];

PQ.con = [ ...
9 100 230 5.00 0.0 1.05 0.95 0;
7 100 230 2.50 0.0 1.05 0.95 0;
];

Pl.con = [ ...
7 100 230 60 0 100 0 0 0 100 1 1;
9 100 230 60 0 100 0 0 0 100 1 1;
];

Syn.con = [ ...
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;
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;
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;
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;
];

Bus.names = {...
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
'Bus 11'};

65 changes: 65 additions & 0 deletions Assets/PSAT_powerflow_scripts/d_kundur1_mdl_case3.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Bus.con = [ ...
1 20 1.03 0.3229 1 1;
2 20 1.01 0.1536 1 1;
3 20 1.03 -0.1187 2 1;
4 20 1.01 -0.295 2 1;
5 230 1.01 0.2112 1 1;
6 230 0.9876 0.03665 1 1;
7 230 1 -0.1065 1 1;
8 230 1 -0.3368 3 1;
9 230 0.9899 -0.555 2 1;
10 230 0.9938 -0.4119 2 1;
11 230 1.013 -0.2339 2 1;
];

Line.con = [ ...
5 6 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
6 7 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
8 9 100 230 60 0 0 0.011 0.11 0.1925 0 0 1 0 0 1;
11 10 100 230 60 0 0 0.0025 0.025 0.04375 0 0 1 0 0 1;
9 10 100 230 60 0 0 0.001 0.01 0.0175 0 0 1 0 0 1;
7 8 100 230 60 0 0 0.011 0.11 0.09625 0 0 1 0 0 1;
1 5 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
2 6 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
4 10 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
3 11 900 20 60 0 0.08695652 0 0.15 0 0 0 1 0 0 1;
];

Fault.con = [ ...
8 100 230 60 1 1.05 0 1e-05;
];

SW.con = [ ...
3 100 20 1.03 -0.1186824 99 -99 1.1 0.9 7 1 1 1;
];

PV.con = [ ...
1 100 20 1.5 1.03 5 -2 1.1 0.9 1 1;
2 100 20 1.5 1.01 5 -2 1.1 0.9 1 1;
4 100 20 1.5 1.01 5 -2 1.1 0.9 1 1;
];

PQ.con = [ ...
9 100 230 3.00 0.0 1.05 0.95 0;
7 100 230 3.00 0.0 1.05 0.95 0;
];

Pl.con = [ ...
7 100 230 60 0 100 0 0 0 100 1 1;
9 100 230 60 0 100 0 0 0 100 1 1;
];

Syn.con = [ ...
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;
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;
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;
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;
];

Bus.names = {...
'Bus 01'; 'Bus 02'; 'Bus 03'; 'Bus 04'; 'Bus 05';
'Bus 06'; 'Bus 07'; 'Bus 08'; 'Bus 09'; 'Bus 10';
'Bus 11'};

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
% Script to obtain the power flow solution from PSAT models
% LV, 2024/01
clear all; clc;
% put the path to where the psat .zip has been uncompressed
cd("C:\Users\vanfretti\Documents\MATLAB\psat-2.1.11-mat\psat")
initpsat % starts PSAT in command line mode
% put the path to the working director where the models are stored
cd("C:\Users\vanfretti\Documents\MATLAB\example2_psat_models")
clpsat.readfile = 0; % do not reload the data files

%% Specify the model to be solved and settings
runpsat('d_kundur1_mdl_case0.m','data')
% Set the system parameters
Settings.freq = 60;
Settings.mva = 100;
Settings.showlf = 1;
% Power flow settings and solution
Settings.lftol = 1e-12;
runpsat('pf')

%% Post-process the data

% calculate the line flows
[ps0,qs0,pr0,qr0] = fm_flows;

% extract the bus voltages and angles for further use
voltages = DAE.y(1+Bus.n:2*Bus.n);
angles = DAE.y(Bus.a);

% extract the power at each bus from the solution
Sbase = 100.0e6;
pgen = Snapshot.Pg*Sbase/1e6;
qgen = Snapshot.Qg*Sbase/1e6;
pload = Snapshot.Pl*Sbase/1e6;
qload = Snapshot.Ql*Sbase/1e6;

% Make a table
varNames = {'Bus', '|V (pu)|','/_V (rad)', ...
'Pgen (MW)', 'Qgen (Mvar)', ...
'Pload (MW)', 'Qload (Mvar)'};
Tableout = table(Bus.names,voltages,angles,pgen,qgen,pload,qload,'VariableNames',varNames);
disp(Tableout)
%% Display data for reuse
% disp('Voltage Magnitudes')
% disp(voltages)
% figure(101)
% bar(voltages,'DisplayName','voltages')
% xlabel('Iteration no and Bus no')
% ylabel('Voltage (pu)')

% Make a table
varNames = {'Bus', '|V (pu)|','/_V (rad)', ...
'Pgen (MW)', 'Qgen (Mvar)', ...
'Pload (MW)', 'Qload (Mvar)'};
Tableout = table(Bus.names,voltages,angles,pgen,qgen,pload,qload,'VariableNames',varNames);
disp(Tableout)
%% Display data for reuse
format long g
disp('Voltage Magnitudes')
disp(voltages)
figure(101)
bar(voltages,'DisplayName','voltages')
xlabel('Iteration no and Bus no')
ylabel('Voltage (pu)')

%% Display record data
run dexample2_print_record_data.m

%closepsat % exits PSAT gracefully
Loading

0 comments on commit 32d7485

Please sign in to comment.