There are a couple of things missing.
1. The Pbusinj, is simply an injection offset to handle phase shifters (all
zeros in case14), so it does not include the load and generation terms from
(3.32) in B_dc.
2. Voltage angles must be in radians (and injections in p.u.)
Try this …
define_constants;
mpc = loadcase('case14');
r = rundcpf(mpc);
Va = r.bus(:, VA) * pi/180; TCL MERGE ERROR ( 08/30/2017 10:05:06 ):
"invalid command name "Bbus,""
OutmailID: 121773286, List: 'matpower-l', MemberID: 75174736
SCRIPT: "bus voltage angles in radians [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(r);
Pd = r.bus(:, PD) / r.baseMVA;"
load in p.u.
Pg = zeros(size(Pd)); TCL MERGE ERROR ( 08/30/2017 10:05:06 ): "extra
characters after close-quote"
OutmailID: 121773286, List: 'matpower-l', MemberID: 75174736
SCRIPT: "generation in p.u. Pg(r.gen(:, GEN_BUS)) = r.gen(:, PG) / r.baseMVA;
mis = Bbus*Va+Pbusinj + Pd - Pg Hope this helps, Ray > On Aug 29,
2017, at 2:04 AM, Alexander Loh <[email protected]> wrote: > > I am trying
to solve a power flow problem with MATPOWER using the DC model and trying to
verify that the solution fits the DC power flow equations (eqn. 4.7 in the
MATPOWER user manual). I have a minimal working example that goes as follows: >
> close all > clear all > clc > > option = mpoption('model','DC'); > mpc =
loadcase('case14'); > > result = runpf(mpc, option); > > [Bbus, Bf, Pbusinj,
Pfinj] = makeBdc(result); > theta = result.bus(:,9); > diff =
Bbus*theta-Pbusinj; > > disp(diff) > > If my understanding of subsection
9.5.2 (pg. 102) and eqn 4.7 (pg. 30) are correct, diff should be a vector of
all zero values, or close to it. However, that doesn't appear to be the case;
diff(1) is about 125, for example. Is there a mistake in my understanding of
the way the code is meant to operate? > > Thanks for your time, > Alex
--Apple-Mail=_74241A9F-9A93-4C3E-850B-D2A3DB483A92 Content-Transfer-Encoding:
quoted-printable Content-Type: text/html; charset="utf-8" <html><head><meta
http-equiv="Content-Type" content="text/html charset=utf-8"></head><body
style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break:
after-white-space;" class=""><div class="">There are a couple of things
missing.</div><div class=""><br class=""></div><div class="">1. The Pbusinj, is
simply an injection offset to handle phase shifters (all zeros in case14), so
it does not include the load and generation terms from (3.32) in
B_dc.</div><div class="">2. Voltage angles must be in radians (and injections
in p.u.)</div><div class=""><br class=""></div><div class="">Try this
…</div><div class=""><br class=""></div><div class=""><div class=""><font
face="Courier" class="">define_constants;</font></div><div class=""><font
face="Courier" class="">mpc = loadcase('case14');</font></div><div
class=""><font face="Courier" class="">r = rundcpf(mpc);</font></div><div
class=""><font face="Courier" class="">Va = r.bus(:, VA) * pi/180;
"
bus voltage angles in radians</font></div><div class=""><font face="Courier"
class="">[Bbus, Bf, Pbusinj, Pfinj] = makeBdc(r);</font></div><div
class=""><font face="Courier" class="">Pd = r.bus(:, PD) / r.baseMVA; %%
load in p.u.</font></div><div class=""><font face="Courier" class="">Pg =
zeros(size(Pd)); %% generation in
p.u.</font></div><div class=""><font face="Courier" class="">Pg(r.gen(:,
GEN_BUS)) = r.gen(:, PG) / r.baseMVA;</font></div><div class=""><font
face="Courier" class="">mis = Bbus*Va+Pbusinj + Pd - Pg</font></div></div><div
class=""><br class=""></div><div class="">Hope this helps,</div><div
class=""><br class=""></div><div class=""> Ray</div><div
class=""><br class=""><div class=""><br class=""></div><div class=""><br
class=""></div><div class=""><div><blockquote type="cite" class=""><div
class="">On Aug 29, 2017, at 2:04 AM, Alexander Loh <<a
href="mailto:[email protected]" class="">[email protected]</a>>
wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr"
class=""><div dir="ltr" class=""><div class="">I am trying to solve a power
flow problem with
MATPOWER using the DC model and trying to verify that the solution fits
the DC power flow equations (eqn. 4.7 in the MATPOWER user manual). I
have a minimal working example that goes as follows:</div><div class=""><br
class=""></div><div class="">close all </div><div class="">clear
all</div><div class="">clc</div><div class=""><br class=""></div><div
class="">option = mpoption('model','DC');</div><div class="">mpc =
loadcase('case14');</div><div class=""><br class=""></div><div class="">result
= runpf(mpc, option);</div><div class=""><br class=""></div><div
class="">[Bbus, Bf, Pbusinj, Pfinj] = makeBdc(result);</div><div class="">theta
= result.bus(:,9);</div><div class="">diff = Bbus*theta-Pbusinj;</div><div
class=""><br class=""></div><div class="">disp(diff)</div><div class=""><br
class=""></div><div class="">If
my understanding of subsection 9.5.2 (pg. 102) and eqn 4.7 (pg. 30) are
correct, diff should be a vector of all zero values, or close to it.
However, that doesn't appear to be the case; diff(1) is about 125, for
example. Is there a mistake in my understanding of the way the code is
meant to operate?</div><div class=""><br class=""></div><div class="">Thanks
for your time,</div><div class="">Alex</div></div></div>
</div></blockquote></div><br class=""></div></div></body></html>