(Sorry, resending this … it seems something wacky is going on with my mail 
program or outgoing mail service or something … hopefully this one won’t get 
garbled.)

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:11:04 ): 
"invalid command name "Bbus,""
OutmailID: 121773331, 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:11:04 ): "extra 
characters after close-quote"
OutmailID: 121773331, 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=_949CB95B-96A9-49C3-96DD-B48DD332F8BC 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=""><i class="">(Sorry, resending this … 
it seems something wacky is going on with my mail program or outgoing mail 
service or something&nbsp;… hopefully this one won’t get 
garbled.)</i></div><div class=""><br class=""></div><div class="">There are a 
couple of things missing.<br class=""><br class="">1. The <font face="Courier" 
class="">Pbusinj</font>, 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.<br class="">2. Voltage angles must be in radians (and 
injections in p.u.)<br class=""><br class="">Try this …<br class=""><br 
class=""><font face="Courier" class="">define_constants;<br class="">mpc = 
loadcase('case14');<br class="">r = rundcpf(mpc);<br class="">Va = r.bus(:, VA) 
* pi/180; &nbsp; &nbsp;"
 bus voltage angles in radians<br class="">[Bbus, Bf, Pbusinj, Pfinj] = 
makeBdc(r);<br class="">Pd = r.bus(:, PD) / r.baseMVA; &nbsp;%% load in p.u.<br 
class="">Pg = zeros(size(Pd)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %% generation 
in p.u.<br class="">Pg(r.gen(:, GEN_BUS)) = r.gen(:, PG) / r.baseMVA;<br 
class="">mis = Bbus*Va+Pbusinj + Pd - Pg<br class=""><br class=""></font>Hope 
this helps,<br class=""><br class="">&nbsp; &nbsp; Ray<br class=""><br 
class=""></div><div class=""><br class=""></div><br class=""><div><blockquote 
type="cite" class=""><div class="">On Aug 29, 2017, at 2:04 AM, Alexander Loh 
&lt;<a href="mailto:[email protected]"; class="">[email protected]</a>&gt; 
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&nbsp;</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=""></body></html>

Reply via email to