1. Setting values of bus loads and voltages in code after loading from a case 
file is fine.
2. See caseformat() 
<http://www.pserc.cornell.edu//matpower/docs/ref/matpower5.1/caseformat.html> 
or Table B-1 in the User’s Manual 
<http://www.pserc.cornell.edu/matpower/docs/MATPOWER-manual-5.1.pdf>. You will 
see that the PD and QD columns in the bus matrix are in MW and MVAr, not in 
p.u. So you will have to convert them by multiplying by mpc.baseMVA.
3. Your Va is a voltage angle in radians, Vc is the complex voltage.

As a MATPOWER “best practices”, I also suggest that you use the named constants 
rather than numerical column indices when referencing columns of the data 
matrices. See define_constants() 
<http://www.pserc.cornell.edu//matpower/docs/ref/matpower5.1/define_constants.html>
 and the next to last paragraph in section 2.3.2 of the User’s Manual 
<http://www.pserc.cornell.edu/matpower/docs/MATPOWER-manual-5.1.pdf> for more 
details.

    Ray




> On Nov 26, 2015, at 5:35 AM, lydia edwin <lydiaedwin...@gmail.com> wrote:
> 
> Hello sir
> 
> I am a beginner in MATPOWER.  I wanted to solve a power flow problem using 
> the IEEE_30 bus system. I have Va, Pa, Qa in pu quantities.  I used Pa and Qa 
> as inputs and wanted to solve the AC power flow and check if I get Va.  I 
> used the following code:
> 
> mpc=loadcase(case30); 
> mpc.bus(:,3)=Pa; % Input Pa in pu
> mpc.bus(:,4)=Qa; % Input Qa in pu
> mpc.bus(1,8)=1; % slack bus voltage
> mpc.bus(1,9)=0; % slack bus angle
> results=runpf(mpc); % stored the results
> Vm1=results.bus(:,8); % output voltage magnitude
> Va1=results.bus(:,9)*pi/180; %output voltage angles
> % convert the voltage from polar to cartesian
> for j=1:length(Vm1)
> [Vr1(j),Vr2(j)]=pol2cart(Va1(j), Vm1(j));
> Vc(j)=Vr1(j)+ 1i*Vr2(j);
> end
> 
> Queries: 
> 1. Is the way I have coded right? Or should I create a separate case format?
> 2. Can I input Pa and Qa in pu values?
> 3. The output Vc that I get is not same as Va.
> 
> Please help. Thanks
> Lydia Edwin

Reply via email to