(Sorry, for all of the e-mails … one more try … seems the comments in the
Matlab code are triggering a bug in the mailing list software.)
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;
[Bbus, Bf, Pbusinj, Pfinj] = makeBdc(r);
Pd = r.bus(:, PD) / r.baseMVA;
Pg = zeros(size(Pd));
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]
> <mailto:[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