For future reference, it looks like I saw and answered it
here<https://www.mathworks.com/matlabcentral/fileexchange/72085-matpower?tab=discussions#discussions_2528667>
first.
Ray
On Sep 22, 2023, at 8:29 AM, keir steegstra <[email protected]> wrote:
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
"
OutmailID: 127791072, List: 'matpower-l', MemberID: 82861091
SCRIPT: "MATPOWER Case Format : Version 2 mpc.version = '2';"
TCL MERGE ERROR ( 09/27/2023 15:27:14 ): "invalid command name "MATPOWER"-----
Power Flow Data ----- system MVA base
mpc.baseMVA = 1;
baseKV = 22;
baseMVA = mpc.baseMVA;
"
OutmailID: 127791072, List: 'matpower-l', MemberID: 82861091
SCRIPT: "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; ];"
TCL MERGE ERROR ( 09/27/2023 15:27:14 ): "invalid command name "1" 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
];
"
OutmailID: 127791072, List: 'matpower-l', MemberID: 82861091
SCRIPT: "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; ];"
TCL MERGE ERROR ( 09/27/2023 15:27:14 ): "invalid command name "1"----- 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;
"
OutmailID: 127791072, List: 'matpower-l', MemberID: 82861091
SCRIPT: "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);"
TCL MERGE ERROR ( 09/27/2023 15:27:14 ): "wrong # args: should be "set varName
?newValue?" Load case study
casefile = 'casefarm';
mpc = loadcase(casefile);
"
OutmailID: 127791072, List: 'matpower-l', MemberID: 82861091
SCRIPT: "----- + Solar/loads ----- xgd = loadxgendata('xgd_uc_farm', mpc);
[iwind, mpc, xgd] = addwind('wind_uc_farm', mpc, xgd); disp(mpc.gen)"
TCL MERGE ERROR ( 09/27/2023 15:27:14 ): "invalid command name "-----"
profiles = getprofiles('wind_profile_farm', iwind);
profiles = getprofiles('load_profile_farm', profiles);
nt = size(profiles(1).values, 1); % number of periods
"
OutmailID: 127791072, List: 'matpower-l', MemberID: 82861091
SCRIPT: "----- + storage ----- mpopt = mpoption(mpopt, 'most.storage.cyclic',
0); [iess, mpc, xgd, sd] = addstorage('storage_farm', mpc, xgd);"
TCL MERGE ERROR ( 09/27/2023 15:27:14 ): "invalid command name "-----" -----
run optimization -----
mdi = loadmd(mpc, nt, xgd, sd, [], profiles);
mdo = most(mdi, mpopt); % Run most simulation
"
OutmailID: 127791072, List: 'matpower-l', MemberID: 82861091
SCRIPT: "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
--_000_BC2525F5670643629E90726551D39038cornelledu_ Content-Type: text/html;
charset="us-ascii" Content-ID:
<[email protected]>
Content-Transfer-Encoding: quoted-printable <html> <head> <meta
http-equiv="Content-Type" content="text/html; charset=us-ascii"> </head> <body
style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break:
after-white-space;"> For future reference, it looks like I saw and answered
it <a
href="https://www.mathworks.com/matlabcentral/fileexchange/72085-matpower?tab=discussions#discussions_2528667">here</a> first.
<div><br> </div> <div> Ray</div> <div><br> <div><br> <blockquote
type="cite"> <div>On Sep 22, 2023, at 8:29 AM, keir steegstra
<[email protected]> wrote:</div> <br
class="Apple-interchange-newline"> <div> <div class="elementToProof"
style="font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size:
12pt;"> </div> <div class="elementToProof" style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: 400; letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> <span>Hello
everyone,</span><br> </div> <div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> <br> </div> <div
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> 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.</div> <div style="caret-color:
rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: 400; letter-spacing: normal;
text-align: start; text-indent: 0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br> </div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight:
400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> 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.</div> <div
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> <br> </div> <div style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: 400; letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> 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:</div> <div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> <br> </div> <div
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> ```matlab</div> <div style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: 400; letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> function loadprofile =
ex_load_profile</div> <div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> % ... [omitted for
brevity]</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight:
400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> loadprofile = struct(
...</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight:
400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> 'type',
'mpcData', ...</div> <div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> 'table',
CT_TLOAD, ...</div> <div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> 'rows',
0, ...</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight:
400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> 'col',
CT_LOAD_ALL_PQ, ...</div> <div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;">
'chgtype', CT_REP, ...</div> <div style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: 400; letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;">
'values', [] );</div> <div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> loadprofile.values(:,
1, 1) = [</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight:
400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> 440;</div> <div
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> ... [omitted for brevity]</div> <div
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> ]-1e-3;</div> <div style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: 400; letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> ```</div> <div
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> <br> </div> <div style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: 400; letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> I'm particularly
interested in understanding the 'col', 'rows', and 'values' definitions. Could
someone explain their roles in this specific tutorial example?</div> <div
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> <br> </div> <div class="elementToProof"
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> 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?</div> <div style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight:
400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> <br> </div> <div
class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"> Any insights or
guidance would be immensely appreciated. Thank you in advance!</div> <div
class="elementToProof" style="font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;"> <br> </div> <div
class="elementToProof" style="font-style: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;"> Below is my casefile and main
simulation file:<br> <br> <br> </div> <div class="elementToProof"
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal; font-weight: 400;
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;"> <div class="rtcContent" style="padding: 30px;"><span
class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas,
"Courier New", monospace; font-weight: normal;"><span><span
class="ContentPasted2" style="color: rgb(14, 0, 255);">function<span
class="Apple-converted-space"> </span></span><span
class="ContentPasted2">mpc = casefarm</span></span></span> <div
class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas,
"Courier New", monospace; font-weight: normal;"> <span><span
class="ContentPasted2" style="color: rgb(0, 128, 19);">"
TCL MERGE ERROR ( 09/27/2023 15:27:14 ): "extra characters after close-quote
MATPOWER Case Format : Version 2</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">mpc.version =<span
class="Apple-converted-space"> </span></span><span class="ContentPasted2"
style="color: rgb(167, 9, 245);">'2'</span><span
class="ContentPasted2">;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">%%-----
Power Flow Data -----%%</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">%% system
MVA base</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">mpc.baseMVA = 1;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">baseKV = 22;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">baseMVA = mpc.baseMVA;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">%% bus
data</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% bus_i type
Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">mpc.bus = [</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">1 3 0 0 0 0 1 1 0 baseKV 1 1.1
0.9;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">2 2 0 0 0 0 1 1 0 baseKV 1 1.1
0.9;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">];</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">%% generator
data</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% 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</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">mpc.gen = [</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% 1 10 0 0 0
1 1 1 0 10 0 0 0 0 0 0 0 50 50 0 0; % testing convergence</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">2 -45 0 0 0 1 1 1 0 -45 0 0 0 0 0 0 0 50 50
0 0;<span class="Apple-converted-space"> </span></span><span
class="ContentPasted2" style="color: rgb(0, 128, 19);">% load at PV
bus</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% 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</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">];</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">%% branch
data</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% fbus tbus
r x b rateA rateB rateC ratio angle status angmin angmax</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">mpc.branch = [</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">1 2 2.35537190082645e-06
4.63223140495868e-07 0 25.56048 25.56048 25.56048 0 0 1 -360
360;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">];</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">%%-----
OPF Data -----%%</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">%% generator
cost data</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% 1 startup
shutdown n x1 y1 ... xn yn</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% 2 startup
shutdown n c(n-1) ... c0</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">mpc.gencost = [</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2">2 0 0 2 100 0;<span
class="Apple-converted-space"> </span></span><span class="ContentPasted2"
style="color: rgb(0, 128, 19);">% PV Load</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted2" style="color: rgb(0, 128, 19);">% 2 0 0 2
100 0; % Slack Load</span></span></div>
<span class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;"><span><span
class="ContentPasted2">];</span></span></span>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
</div>
<div class="rtcContent" style="padding: 30px;"><span class="lineNode"
style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier
New", monospace; font-weight: normal;"><span><span class="ContentPasted3"
style="color: rgb(0, 128, 19);">% Mainfarm_two.m
Use this to test random ideas so i dont mess my mainfarm</span></span></span>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%
code.</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">clear<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">all</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">close<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">all</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">% Output
controls:</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">Print_results = 0;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">Plotresults = 0;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<br>
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%% set up
options</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">define_constants;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">verbose = 1;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpopt = mpoption(</span><span
class="ContentPasted3" style="color: rgb(167, 9, 245);">'verbose'</span><span
class="ContentPasted3">, verbose);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpopt = mpoption(mpopt,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'out.all'</span><span class="ContentPasted3">,
0);<span class="Apple-converted-space"> </span></span><span
class="ContentPasted3" style="color: rgb(0, 128, 19);">%
Print all results</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpopt = mpoption(mpopt,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'model'</span><span
class="ContentPasted3">,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'DC'</span><span
class="ContentPasted3">);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpopt = mpoption(mpopt,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'opf.dc.solver'</span><span
class="ContentPasted3">,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'MIPS'</span><span
class="ContentPasted3">);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpopt = mpoption(mpopt,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'most.solver'</span><span
class="ContentPasted3">,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'DEFAULT'</span><span
class="ContentPasted3">);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpopt = mpoption(mpopt,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'out.all'</span><span class="ContentPasted3">,
1);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<br>
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%% Load case
study</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">casefile =<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'casefarm'</span><span
class="ContentPasted3">;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpc = loadcase(casefile);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3"><br>
</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%% -----
+ Solar/loads -----</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">xgd = loadxgendata(</span><span
class="ContentPasted3" style="color: rgb(167, 9,
245);">'xgd_uc_farm'</span><span class="ContentPasted3">,
mpc);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">[iwind, mpc, xgd] = addwind(</span><span
class="ContentPasted3" style="color: rgb(167, 9,
245);">'wind_uc_farm'</span><span class="ContentPasted3">, mpc,
xgd);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">disp(mpc.gen)</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128,
19);">%%</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">profiles = getprofiles(</span><span
class="ContentPasted3" style="color: rgb(167, 9,
245);">'wind_profile_farm'</span><span class="ContentPasted3">,
iwind);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">profiles = getprofiles(</span><span
class="ContentPasted3" style="color: rgb(167, 9,
245);">'load_profile_farm'</span><span class="ContentPasted3">,
profiles);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">nt = size(profiles(1).values, 1);
</span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%
number of periods</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<br>
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%% -----
+ storage -----</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mpopt = mpoption(mpopt,<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(167, 9, 245);">'most.storage.cyclic'</span><span
class="ContentPasted3">, 0);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">[iess, mpc, xgd, sd] =
addstorage(</span><span class="ContentPasted3" style="color: rgb(167, 9,
245);">'storage_farm'</span><span class="ContentPasted3">, mpc,
xgd);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3"><br>
</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%% -----
run optimization -----</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mdi = loadmd(mpc, nt, xgd, sd, [],
profiles);</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">mdo = most(mdi, mpopt);<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(0, 128, 19);">% Run most simulation</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<br>
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(0, 128, 19);">%%
results</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3">ms = most_summary(mdo);<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(0, 128, 19);">% Print all MOST results in cmd
window</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
</div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(14, 0, 255);">if<span
class="Apple-converted-space"> </span></span><span
class="ContentPasted3">Plotresults</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3"> figure;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3"> plot_storage(mdo);<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(0, 128, 19);">% plot SOC vs time</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3"> figure;</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3"> plot_gen(mdo);<span
class="Apple-converted-space"> </span></span><span class="ContentPasted3"
style="color: rgb(0, 128, 19);">% plot gen vs time</span></span></div>
<div class="lineNode" style="font-size: 10pt; font-family: Menlo, Monaco,
Consolas, "Courier New", monospace; font-weight: normal;">
<span><span class="ContentPasted3" style="color: rgb(14, 0,
255);">end</span></span></div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>