Hello everyone,
I'm working on a project where I'm modeling two isolated towns as a two-bus
system. Each town (represented as a bus) will have a storage system, load, and
a PV generator. My objective is to determine the feasibility of connecting
these towns with a lossy link (initially using a single DC branch, and later an
AC branch) versus keeping them isolated and simply expanding their battery
capacities.
In my case file, "casefarm.m", I've defined a dispatchable load at each bus
within `mpc.gen`. My goal is to apply a load profile to each bus and simulate
the power flow over a series of time periods. Additionally, I'll be using
profiles to simulate PV generation for each solar generator.
However, I'm having difficulty understanding the `profile` struct, especially
after going through the MOST tutorials. While I've read the documentation on
the `profile` struct, I'm still unclear about its implementation. I'm hoping
someone could help clarify the struct definition in the "ex_load_profile.m"
example provided below:
```matlab
function loadprofile = ex_load_profile
% ... [omitted for brevity]
loadprofile = struct( ...
'type', 'mpcData', ...
'table', CT_TLOAD, ...
'rows', 0, ...
'col', CT_LOAD_ALL_PQ, ...
'chgtype', CT_REP, ...
'values', [] );
loadprofile.values(:, 1, 1) = [
440;
... [omitted for brevity]
]-1e-3;
```
I'm particularly interested in understanding the 'col', 'rows', and 'values'
definitions. Could someone explain their roles in this specific tutorial
example?
Furthermore, for my two-bus system, I'd like to assign independent load
profiles to each dispatchable load. I'm not looking to simulate contingencies;
I just want a straightforward single load demand for a given load at each time
step as shown in the example above. How can I associate a specific profile with
a particular generator? Moreover, I noticed that the plots generated by the
provided "plot_storage" and "plot_gen" functions, don't have a legend. Has
anyone updated this code?
Any insights or guidance would be immensely appreciated. Thank you in advance!
Below is my casefile and main simulation file:
function mpc = casefarm
%% MATPOWER Case Format : Version 2
mpc.version = '2';
%%----- Power Flow Data -----%%
%% system MVA base
mpc.baseMVA = 1;
baseKV = 22;
baseMVA = mpc.baseMVA;
%% bus data
% bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
mpc.bus = [
1 3 0 0 0 0 1 1 0 baseKV 1 1.1 0.9;
2 2 0 0 0 0 1 1 0 baseKV 1 1.1 0.9;
];
%% generator data
% bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min
Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf
mpc.gen = [
% 1 10 0 0 0 1 1 1 0 10 0 0 0 0 0 0 0 50 50 0 0; % testing convergence
2 -45 0 0 0 1 1 1 0 -45 0 0 0 0 0 0 0 50 50 0 0; % load at PV bus
% 1 -3 0 0 0 1 1 1 0 -3 0 0 0 0 0 0 0 50 50 0 0; % load at Slack bus
];
%% branch data
% fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax
mpc.branch = [
1 2 2.35537190082645e-06 4.63223140495868e-07 0 25.56048 25.56048 25.56048 0 0
1 -360 360;
];
%%----- OPF Data -----%%
%% generator cost data
% 1 startup shutdown n x1 y1 ... xn yn
% 2 startup shutdown n c(n-1) ... c0
mpc.gencost = [
2 0 0 2 100 0; % PV Load
% 2 0 0 2 100 0; % Slack Load
];
% Mainfarm_two.m Use this to test random ideas so i dont mess my mainfarm
% code.
clear all
close all
% Output controls:
Print_results = 0;
Plotresults = 0;
%% set up options
define_constants;
verbose = 1;
mpopt = mpoption('verbose', verbose);
mpopt = mpoption(mpopt, 'out.all', 0); % Print all results
mpopt = mpoption(mpopt, 'model', 'DC');
mpopt = mpoption(mpopt, 'opf.dc.solver', 'MIPS');
mpopt = mpoption(mpopt, 'most.solver', 'DEFAULT');
mpopt = mpoption(mpopt, 'out.all', 1);
%% Load case study
casefile = 'casefarm';
mpc = loadcase(casefile);
%% ----- + Solar/loads -----
xgd = loadxgendata('xgd_uc_farm', mpc);
[iwind, mpc, xgd] = addwind('wind_uc_farm', mpc, xgd);
disp(mpc.gen)
%%
profiles = getprofiles('wind_profile_farm', iwind);
profiles = getprofiles('load_profile_farm', profiles);
nt = size(profiles(1).values, 1); % number of periods
%% ----- + storage -----
mpopt = mpoption(mpopt, 'most.storage.cyclic', 0);
[iess, mpc, xgd, sd] = addstorage('storage_farm', mpc, xgd);
%% ----- run optimization -----
mdi = loadmd(mpc, nt, xgd, sd, [], profiles);
mdo = most(mdi, mpopt); % Run most simulation
%% results
ms = most_summary(mdo); % Print all MOST results in cmd window
if Plotresults
figure;
plot_storage(mdo); % plot SOC vs time
figure;
plot_gen(mdo); % plot gen vs time
end