Professional Documents
Culture Documents
Semester Work
Vanco Janev
Supervisors:
Dipl.-Ing. Stephan Koch
Prof. Dr. Gran Andersson
By signing this statement, I affirm that I have read the information notice on plagiarism,
independently produced this paper, and adhered to the general practice of source
citation in this subject-area.
Information notice on plagiarism:
http://www.ethz.ch/students/semester/plagiarism_s_en.pdf
_______________________
___________________________________
signature
4/4
Abstract
In this semester project, an existing algorithm for the calculation of power flow
in a distribution network with dispersed generation is presented and implemented in
MATLAB code. With the developed code a given network is analyzed. Special
consideration was given to the voltage profile of the network, active and reactive power
losses, and active and reactive power flows. Two cases were taken into account:
network with dispersed generation and network without dispersed generation. Different
types of representative distribution generation profiles and load profiles were adopted.
Code was developed for the calculation of both PQ and PV buses. Comparisons were
made in case with and without DG units.
Preface
This semester thesis was completed under the supervision of Prof. Dr. Gran
Andersson and Dipl.-Ing. Stephan Koch from Power Systems Laboratory, Department
of Information Technology and Electrical Engineering, ETH Zurich.
I would like to thank my supervisor Prof. Dr. Gran Andersson for his support and help
for this work. I am very much indebted to Dipl.-Ing Stephan Koch for his helpful advices
and comments during my work. He has always been ready for discussions and his
wonderful suggestions helped me to improve my MATLAB programming skills and
extend my knowledge of distribution networks.
Vanco Janev
Zurich, March 2009
Contents
1. List of Figures ........................................................................................................... 5
2. Introduction ............................................................................................................... 7
3. Theoretical Background ............................................................................................ 8
3.1 Basic equations ................................................................................................... 8
3.2 Dynamic data structure algorithm ........................................................................ 9
3.3 Power flow calculation algorithm ........................................................................ 11
4. Case Study ............................................................................................................. 15
4.1. Network topology .............................................................................................. 16
4.2. Load and Generation Profiles ........................................................................... 17
4.3. Results of the load flow calculation ................................................................... 21
5. Conclusion .............................................................................................................. 29
6. Bibliography ............................................................................................................ 30
7. Appendix A ............................................................................................................. 32
8. Appendix B ............................................................................................................. 43
1. List of Figures
Figure 1: Model of a transmission line
Figure 2: Schematic diagram of a dynamic data structure
Figure 3: Radial system used as an example in this work with all the brunches
displayed
Figure 4: Representation of the data structure storing details of branch II
Figure 5: Distribution load flow with distributed generation algorithm
Figure 6: Worked example of distribution network
Figure 7: Active power load per bus
Figure 8: Reactive power load per bus
Figure 9: Active power generation per bus
Figure 10: Reactive power generation per bus
Figure 11: cos
graphic
2. Introduction
Electrical energy is essential for the existence of the civilized world today. The
present power system results from a long-term development that has started 120 years
ago and is still going on.
The necessity for reduction of 2 emissions in the atmosphere, current primary
energy shortage, acceptance problems with nuclear power after the nuclear accident in
Chernobyl and the new deregulated market trigger more attention to be paid to
renewable energy sources and dispersed energy generation. According to different
studies such as [1], the share of dispersed generation technology in overall power
generation has been increased substantially compared with the share before some
years ago. Having dispersed generation close to the loads can reduce transmission
and distribution costs, including delayed equipment upgrades and loss reduction and
reduced voltage sags.
Distribution systems were designed to operate under radial (unique path from
any given bus to the source) and unidirectional power flow conditions, but with
dispersed generation in the network the power flow is no longer unidirectional. Wide
use of dispersed energy generation units changes the planning as well as the way of
operation of the power system. Hierarchical structure of the power system which was
the case until now is threatened by the penetration of DG in the system. An existence
of DG units in the system results with new tasks for the distribution network. The role of
conventional power plants in the power system is to generate energy, but they also
participate in the voltage and frequency control. The ancillary services that
conventional power plants are providing for the power system are very important for
stable operation of the system. A possible threat for stable operation of the power
system is the installed capacity of dispersed generation units in the system, which
usually does not provide the ancillary services mentioned above and whenever a fault
occurs they are disconnected from the network. Disconnection can increase the impact
of the disturbance and lead to a power system outage.
However, concluding that the penetration of distributed generation is real and
cannot be neglected, deep and detailed studies are needed on dynamic and static
analysis of the distribution network. For these studies to be possible an appropriate
power flow algorithm is a basic need. Distribution network characteristics are radial or
near radial structure, high R/X ratios, unbalanced operation, and nowadays dispersed
generation. In this semester work for the sake of simplicity was assumed three-phase
balanced operation. According to the distribution network characteristics, suitable
methods for load flow calculation in distribution networks are methods that use ladder
network theory, which includes the use of basic circuit theories (Kirchhoff's Current Law
and Kirchhoff's Voltage Law) and natural feature of the radial networks that there is a
unique path from any given bus to the source. The general algorithm used in the ladder
network methods consists of two steps: backward and forward sweep. The forward
sweep is usually a voltage drop calculation from the main substation bus to the furthest
bus and backward sweep is usually current summation based on the voltage updates
from the furthest bus to the main substation bus. These two steps are repeated until
convergence is met. In this semester work was implemented a distribution load flow
method [2, 4] which is in the group of ladder network theory methods, but is slightly
7
different, namely in this method both sweeps are backward and instead of branch
current a power flow in the branches is used. The reason why I chose this method is
because of the noticeable low number of iterations needed to solve the equations and
its convenience with network reconfiguration [2, 3].
3. Theoretical Background
The following part explains the theoretical background of load flow algorithm
used in this semester thesis.
The receiving end bus voltage considering sending end powers of the line is given
below:
2 = 2 2 + +
2 + 2 (2 + 2 )
2
The receiving end bus voltage considering receiving end powers of the line is given
below:
2 = ( +
2 2
2
) + ( + )2 2 + 2 (2 + 2 )
2
2
8
Using the value of receiving end bus voltage, the receiving end bus angle can be
calculated through the equation given below:
+
1
The line losses between the receiving and sending end buses and can
be calculated using equations (4) and (5):
=
=
2 + 2
2
2 + 2
2
4
5
An array to store IDs of all the buses in the order of their location from the head
of the branch;
Parent bus id
Pointers to structure of
emanating branches
10
I
1
3
III
8
4
II
7
IV
5
10
11
Figure 3: Radial system used as an example in this work with all the branches
displayed
A representation of the data structure storing details of branch I is shown in
Figure 4.
Parent-bus-id 3
Number-of-buses-inbranch 3
Number-of-branches-emanating 2
1
4
II
III
11
The basic voltage equations between buses 1 and 2 and buses 2 and 3 are:
12
1 = 2 + 12 12
()
2 = 3 + 23 23
()
2 = 2 12
2 23
()
From the equations (), () and the following equation for 2 is derived:
1 2
12
2 = 2
2 3
23
()
The final equation for calculation of the net apparent power injected, in which
the self impedance is contained, is given below. This form of the equation is
implemented in the code.
1 2
2 =
12
2 1 +12
2 3
23
2 3 +23
12
12
23
23
So far, a method for the calculation of a distribution load flow without PV buses
in a network has been presented. A modification of this method is possible in order to
calculate the load flow in a distribution system with distributed generation with
controllable bus voltage [2]. Any bus containing a generator with voltage control
possibility is represented as a PV bus. All other buses in the distribution system are
represented as PQ buses. The known variables and those to be calculated during a
load flow for PV and PQ buses are as follows:
PV buses:
PQ buses:
Equation 2 is used to calculate the voltage of a PQ bus, since the real and
reactive powers are known. A different method is used for calculating the reactive
power injected into a PV bus . With rearrangement of the previously given
equation 2 , can be a variable to solve and to be a known variable. Another
method for calculating is to use the reactive power injection equation, as given
below:
13
(8)
Due to real and reactive power limits of the generator, it is not sufficient to use
the above equation to calculate the of a PV bus. Once calculated, this value of
can be used to determine the amount of reactive power produced by the generator at
that PV bus. The actions that need to be taken for maximum and minimum reactive
power generator limits , violations are outlined below:
1. Then
2. <
3. >
=
=
Then
=
Then
The distribution load flow algorithm for networks with distributed generation is
shown as a flow chart in Figure 5. The subscript refers to the index of the current
"receiving end bus" (refer to Figure 1). The "start bus" should be the last bus at the end
of a radial branch, as was mentioned previously in the text, since the load flow iterates
from the end of a radial branch up to the top-most bus (which typically represents the
substation bus). The values of and are calculated with previously given
equations 2 and 3 . The reactive power injected into bus is calculated for PV
buses by using the above equations. Then can be used for calculation of the
reactive power generated at that bus . The procedures for generator reactive
power limit violations are given above. The convergence criteria remain the same as
previously explained.
14
START
Go to Start Bus
PV
PQ
PV or PQ
Bus?
Pj=Pacc+Ploss+Pgen
Pj=Pacc+Ploss+Pgen
Qj=Qacc+Qloss+Qgen
Find Vj (Eq. 2)
Qgen
violation?
No
Find (Eq. 3)
Yes
No
Use Qj-new to calculate Vj (Eq. 2)
End bus?
Yes
No
Convergence
criteria met? (Eq.
6 and 7 )
Yes
4. Case Study
In this chapter the above presented algorithm implemented in MATLAB code
was employed for a case study. A typical distribution network with DG units shown on
Figure 6 taken from reference [3] was used and the following studies were made:
(Germany) [10] available on-line on their internet web page. More detailed figures of
load profiles used are given in Appendix B.
Installed
power in
[p.u]
Installed power
in [kW]
PV bus 1
0.05 p.u
50 kW
Wind bus 1
0.05 p.u
50 kW
0.15 p.u
150 kW
PV bus 4
0.05 p.u
50 kW
Biomass bus 4
0.05 p.u
50 kW
PV bus 5
0.1 p.u
100 kW
PV bus 6
0.1 p.u
100 kW
Wind bus 7
0.1 p.u
100 kW
Biomass bus 8
0.1 p.u
100 kW
Biomass bus 9
0.05 p.u
50 kW
Wind bus 9
0.05 p.u
50 kW
Wind bus 10
0.1 p.u
100 kW
Wind bus 11
0.1 p.u
100 kW
Wind
Power
1
Households+
Industry
3
Small
Hydro
Households+
Industry
4
PV
Biomass
8
Biomass
Households
Households
7
5
PV
9
Biomass
Wind
Power
Households
6
PV
Wind
Power
Industry
Industry
10
Wind
Power
Households
Households+
Industry
11
Wind
Power
Households
17
cos
0.90
1
0.1
0.9
0.90
graphic
P/Pn
21
In Figures 18, 19, 20 and 21 power losses in the lines are shown in case
without and with DG. From the figures can be noticed that power losses in the lines are
much larger if the network is without DG. Active and reactive energy losses in the lines
during 24h are given in the Table 2. From there could be seen that when the network is
without DG energy losses in the lines are larger than when DG units are present in the
network. Energy supplied in the system is given in Table 2 and energy lost percentage
from overall active energy consumption is given on Table 3.
Energy lost in lines
during 24h
1-2
line
2-3
line
3-4
line
4-5
line
5-6
line
8-7
line
3-8
line
8-9
line
9-10
line
1011
line
Total
Active
Energy
Losses
[kWh]
Without
DG
25.55
25.55
3.16
1.40
0.35
0.27
7.56
2.71
1.28
0.35
68.18
With
DG
4.31
4.31
1.90
0.88
0.22
0.18
2.31
0.88
0.46
0.11
15.56
Reactive
Energy
Losses
[kVArh]
Without
DG
12.77
12.77
1.58
0.70
0.17
0.13
3.78
1.35
0.64
0.17
34.06
With
DG
2.15
2.15
0.95
0.44
0.11
0.09
1.15
0.44
0.23
0.05
7.76
15.6 103
5.13 103
11.58 103
0.94 103
15.53
3.94
103
5.10 103
103
4.15
103
Without DG units
0.43%
0.30%
With DG units
0.22%
0.15%
24
25
26
27
5. Conclusion
In this semester work the distribution load flow algorithm presented in [2] and [4]
was implemented in MATLAB. The implemented code in MATLAB was used to perform
analyses of the impact of DG units on network voltage profile, on active and reactive
power flows in the lines and the impact of DG units on line losses in the network. A
representative example of distribution network in this work was analyzed. Different
types of representative distribution generation profiles and load profiles were used in all
the studies and comparisons are made between the cases without and with presence
of DG units in the network. The results from comparisons were shown graphically and
structured by bus from where part of the overall impact of the presence of DG units in
the network can be seen.
29
6. Bibliography
[1] N.I. Voropai:
Distributed Generation in Electric Power Systems
The DIGESEC CRIS Workshop, Magdeburg, Germany, Dec. 6-8, 2006
[2] A. Rost, B. Venkatesh and C. P. Diduch:
Distribution System with Distributed Generation Load Flow
Department of Electrical and Computer Engineering New Brunswick, NB,
Canada
[3] B. Venkatesh and R. Ranjan:
Data Structure for Radial Distribution System Load Flow Analysis
IEE Proc.-Gener. Transm. Distrib. Vol 150 No.1 January 2003
[4] K. Rudion, A. Orths, Z. A. Styczynski, K. Strunz:
Design of Benchmark of Medium Voltage Distribution Network for Investigation
of DG Integration
[5] G. Renato Cespedes:
New Method for the Analysis of Distribution Network
IEEE Transactions on Power Delivery, Vol. 5, No. 1, January 1990
[6] S. Ghosh and D. Das:
Method for Load-Flow Solution of Radial Distribution Networks
IEE Proc.- Gener. Transm. Distrib., Vol. 146, No. 6, November 1999
[7] G. B. Jasmon and L. H. C. C. Lee:
Stability of Load-flow Techniques for Distribution System Voltage Stability
Analysis
IEE Proceedings-C, Vol. 138, No. 6, November 1991
[8] BDEW:
Technische Richtlinie Erzeugungsanlagen am Mittelspannungsnetz
BDEW, June 2008
[9] EnBW Energie Baden-Wrttemberg Regional AG:
http://www.enbw.com
[10] E.on Netz (Germany):
http://www.eon-energie.com
7. Appendix A
Following is the MATLAB code that implements the presented load flow calculation
algorithm.
File: start.m
Network = build_network;
Profiles = build_profiles;
Voltages(Profiles.time_intervals, Network.num_buses)=0;
Angles(Profiles.time_intervals, Network.num_buses)=0;
Ploads(Profiles.time_intervals, Network.num_buses)=0;
Qloads(Profiles.time_intervals, Network.num_buses)=0;
Pgen(Profiles.time_intervals, Network.num_buses)=0;
Qgen(Profiles.time_intervals, Network.num_buses)=0;
Plosses(Profiles.time_intervals, Network.num_buses)=0;
Qlosses(Profiles.time_intervals, Network.num_buses)=0;
Pbus(Profiles.time_intervals, Network.num_buses)=0;
Qbus(Profiles.time_intervals, Network.num_buses)=0;
for i=1:Profiles.time_intervals
Results = compute_DLF(Network, Profiles, i);
for k=1:Network.num_buses
Voltages(i,k)=Results.buses(k).V;
Angles(i,k)=Results.buses(k).delta;
Ploads(i,k)=Results.buses(k).P_load;
Qloads(i,k)=Results.buses(k).Q_load;
Pgen(i,k)=Results.buses(k).P_gen;
Qgen(i,k)=Results.buses(k).Q_gen;
Plosses(i,k)=Results.P_loss(k);
Qlosses(i,k)=Results.Q_loss(k);
Pbus(i,k)=Results.P_per_bus(k);
Qbus(i,k)=Results.Q_per_bus(k);
end
end
plot_results(Voltages, Angles, Ploads,
Qloads,Pgen,Qgen,Plosses,Qlosses,Pbus,Qbus);
File: build_network.m
function [Network] = build_network
file1 = 'incidence_matrix_11.dat';
file3 = 'resistance_11.dat';
file4 = 'reactance_11.dat';
A=load(file1);
C=load(file3);
D=load(file4);
clear file1 file3 file4
Network.S_B = 1000; % kVA
Network.V_B = 20;
% kV
branches=struct('ID',0,'parent_bus_ID',0,'num_buses_in_branch',0
,'array_bus_IDs',0','num_branches_em',0,'array_head_busIDs_em_br
anches',[],'neigh_branches',[]);
branches = create_structure(branches, 1, 1, A, 0);
Network.branches = branches;
s=size(branches,2);
for i=1:s
branches(i)
end
clear branches;
Network.num_branches=size(Network.branches,2);
Network.num_buses=size(A,2);
resistance=C;
resistance=resistance+resistance'; %make it symmetric
resistance=resistance./400; % divide by impedance base
reactance=D;
reactance=1*(reactance+reactance'); %make it symmetric
reactance=reactance./400; % divide by impedance base
Network.resistance = resistance;
Network.reactance = reactance;
Network.z=zeros(Network.num_buses);
Network.teta=zeros(Network.num_buses);
for i=1:Network.num_buses
for j=1:Network.num_buses
Network.z(i,j)=sqrt(Network.resistance(i,j)^2+Network.reactance(
i,j)^2);
if Network.resistance(i,j)~=0
Network.teta(i,j)=atan(Network.reactance(i,j)/Network.resistance
(i,j));
end
end
end
clear resistance reactance A B C D
File: build_profiles.m
function [Profiles] = build_profiles
Pload=load('P_load_work.dat');
Profiles.P_load = Pload;
Profiles.Q_load = Profiles.P_load*tan(acos(0.95));
PVPQinfo=load('PV_PQ_info11.dat');
Profiles.PVPQinfo=PVPQinfo;
Voltages_init=load('Voltages_init11.dat');
Profiles.Voltages_init=Voltages_init;
Pgen=load('Pgen.dat');
Pn=0.7;
Profiles.P_gen = Pgen;
for i=1:size(Pgen,1)
for j=1:size(Pgen,2)
if((Profiles.P_gen(i,j)/Pn)==0)
Profiles.Q_gen(i,j)=0;
elseif ((Profiles.P_gen(i,j)/Pn)<=0.1)
Profiles.Q_gen(i,j)=Profiles.P_gen(i,j)*tan(acos(0.9));
elseif ((Profiles.P_gen(i,j)/Pn)>=0.9)
Profiles.Q_gen(i,j)=Profiles.P_gen(i,j)*tan(acos(0.9));
elseif ((Profiles.P_gen(i,j)/Pn)>0.1) &&
((Profiles.P_gen(i,j)/Pn)<=0.5)
Profiles.Q_gen(i,j)=Profiles.P_gen(i,j)*tan(acos(0.9+0.25*((Prof
iles.P_gen(i,j)/Pn)-0.1)));
else
Profiles.Q_gen(i,j)=-Profiles.P_gen(i,j)*tan(acos(10.25*((Profiles.P_gen(i,j)/Pn)-0.5)));
end
end
end
Profiles.time_intervals=size(Pload,1);
File: compute_DLF.m
function [Results] = compute_DLF(Network, Profiles, t)
fprintf('*******************************\n\t\tTime Interval:
%d\n*******************************\n', t)
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%specify number of iterations
num_itr=100;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%
% Inititalize the result structure
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%
Results.buses=struct('ID',0,'P_load',0,'Q_load',0,'P_gen',0,'Q_g
en',0,'V',1,'delta',0,'isPV',0);
for i=1:Network.num_buses
if ~isempty(Results.buses) && isstruct(Results.buses)
Results.buses(i)=struct('ID',i,'P_load',Profiles.P_load(t,i),'Q_
load',Profiles.Q_load(t,i),'P_gen',Profiles.P_gen(t,i),'Q_gen',P
rofiles.Q_gen(t,i),'V',Profiles.Voltages_init(i),'delta',0,'isPV
',Profiles.PVPQinfo(i));
end
end
clear i
Results.dP(1:Network.num_buses)=0;
Results.dQ(1:Network.num_buses)=0;
P(m)=Results.buses(m).V*Results.buses(k).V*cos(Results.buses(m).
deltaResults.buses(k).delta+Network.teta(m,k))/Network.z(m,k)+Results
.buses(m).V*Results.buses(l).V*cos(Results.buses(m).deltaResults.buses(l).delta+Network.teta(m,l))/Network.z(m,l)Results.buses(m).V^2*(cos(Network.teta(m,k))/Network.z(m,k)+cos(
Network.teta(m,l))/Network.z(m,l));
Q(m)=Results.buses(m).V*Results.buses(k).V*sin(Results.buses(m).
deltaResults.buses(k).delta+Network.teta(m,k))/Network.z(m,k)+Results
.buses(m).V*Results.buses(l).V*sin(Results.buses(m).deltaResults.buses(l).delta+Network.teta(m,l))/Network.z(m,l)Results.buses(m).V^2*(sin(Network.teta(m,k))/Network.z(m,k)+sin(
Network.teta(m,l))/Network.z(m,l));
else
k=Network.branches(br).array_bus_IDs(n-1);
P(m)=Results.buses(m).V*Results.buses(k).V*cos(Results.buses(m).
deltaResults.buses(k).delta+Network.teta(m,k))/Network.z(m,k)+Results
.buses(m).V*Results.buses(l).V*cos(Results.buses(m).deltaResults.buses(l).delta+Network.teta(m,l))/Network.z(m,l)Results.buses(m).V^2*(cos(Network.teta(m,k))/Network.z(m,k)+cos(
Network.teta(m,l))/Network.z(m,l));
Q(m)=Results.buses(m).V*Results.buses(k).V*sin(Results.buses(m).
deltaResults.buses(k).delta+Network.teta(m,k))/Network.z(m,k)+Results
.buses(m).V*Results.buses(l).V*sin(Results.buses(m).deltaResults.buses(l).delta+Network.teta(m,l))/Network.z(m,l)Results.buses(m).V^2*(sin(Network.teta(m,k))/Network.z(m,k)+sin(
Network.teta(m,l))/Network.z(m,l));
end
else %calculation for last bus in a branch
for nl=1:Network.branches(br).num_branches_em;
%for all the neighbor busses from the emanating neighbor
branches
l=Network.branches(br).array_head_busIDs_em_branches(nl);
P(m)=P(m)+Results.buses(m).V*Results.buses(l).V*cos(Results.buse
s(m).deltaResults.buses(l).delta+Network.teta(m,l))/Network.z(m,l)Results.buses(m).V^2*cos(Network.teta(m,l))/Network.z(m,l);
Q(m)=Q(m)+Results.buses(m).V*Results.buses(l).V*sin(Results.buse
s(m).deltaResults.buses(l).delta+Network.teta(m,l))/Network.z(m,l)Results.buses(m).V^2*sin(Network.teta(m,l))/Network.z(m,l);
end
if(n==1)
k=Network.branches(br).parent_bus_ID;
else
k=Network.branches(br).array_bus_IDs(n-1);
end
P(m)=P(m)+Results.buses(m).V*Results.buses(k).V*cos(Results.buse
s(m).deltaResults.buses(k).delta+Network.teta(m,k))/Network.z(m,k)Results.buses(m).V^2*cos(Network.teta(m,k))/Network.z(m,k);
Q(m)=Q(m)+Results.buses(m).V*Results.buses(k).V*sin(Results.buse
s(m).deltaResults.buses(k).delta+Network.teta(m,k))/Network.z(m,k)Results.buses(m).V^2*sin(Network.teta(m,k))/Network.z(m,k);
end
end
end
%For all the buses calculate the differences.
for i=2:Network.num_buses
dP(i)=P(i) - Results.buses(i).P_load +
Results.buses(i).P_gen;
dQ(i)=Q(i) - Results.buses(i).Q_load +
Results.buses(i).Q_gen;
Results.P_gen(i)=Results.buses(i).P_gen;
Results.Q_gen(i)=Results.buses(i).Q_gen;
Results.P_load(i)=Results.buses(i).P_load;
Results.Q_load(i)=Results.buses(i).Q_load;
Results.V(i)=Results.buses(i).V;
Results.delta(i)=Results.buses(i).delta;
end
end
fprintf('Error for Active Power: \n')
dP
P
fprintf('Error for Reactive Power: \n')
dQ
Q
File: calculate_load.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%This function is called recursivly: if the parent branch has
children
%%branches that are no calculated, then calculate for them fist.
%%P_branch,Q_branch contain the calculated P and Q powers
starting from the
%%last bus and going up to the top of the branch.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [buses, P_branch, Q_branch, P_loss, Q_loss, P_bus,
Q_bus] = calculate_load(branch, buses, Network, P_bus, Q_bus,
P_loss, Q_loss, P_branch, Q_branch )
k=branch.ID; % id of the branch that is being calculated
P_branch(k)=0;
Q_branch(k)=0;
%if the branch has children
if (branch.num_branches_em~=0)
for i=1:branch.num_branches_em % for each child
child_branch=branch.neigh_branches(i);
[buses, P_branch, Q_branch, P_loss, Q_loss, P_bus,
Q_bus] = calculate_load(child_branch, buses, Network, P_bus,
Q_bus, P_loss, Q_loss, P_branch, Q_branch); %recusivly calculate
about the child
P_branch(k)=P_branch(k)+P_branch(child_branch.ID); %
add the total absorbed P of the child branch
Q_branch(k)=Q_branch(k)+Q_branch(child_branch.ID); %
add the total absorbed Q of the child branch
end
end
%
fprintf('********** Calculating for branch: %d **********
\n', k)
% if (branch.num_buses_in_branch>1) % if the branch has more
than 1 buses
for n=branch.num_buses_in_branch:-1:1 % start from the
last bus until the second one
j=branch.array_bus_IDs(n);
%%The following part is needed in order to calculate
the powers between
%%the fist bus of each branch and the parent bus of
it. Exception is
%%only the first branch of the network, where the
current power is summed up.
if n == 1,
if
(branch.array_bus_IDs(branch.num_buses_in_branch)~=Network.branc
hes(k).parent_bus_ID)
% now calculate for the fist bus of the branch
and the parent bus
i=Network.branches(k).parent_bus_ID;
else
i = 0;
end
else
i=branch.array_bus_IDs(n-1);
end
if (i~=0)
if (buses(j).isPV) %if the bus is PV bus
Qmin=-buses(j).P_gen*tan(acos(0.9));
Qmax=buses(j).P_gen*tan(acos(0.9));
P_branch(k)= P_branch(k) + buses(j).P_load buses(j).P_gen; % add the load of the bus to the total absorbed
P of the branch
Qs=Q_branch(k);
%
Q_branch(k)=calculate_Q(j,n,k,Network,buses);
%
Q_branch(k)=(P_branch(k)*Network.reactance(i,j)buses(j).V*buses(i).V*sin(buses(i).deltabuses(j).delta))/Network.resistance(i,j);
w=buses(j).V^2*Network.reactance(i,j)/(Network.reactance(i,j)^2+
Network.resistance(i,j)^2);
q=(buses(j).V^4buses(j).V^2*buses(i).V^2+2*buses(j).V^2*P_branch(k)*Network.res
istance(i,j)+P_branch(k)^2*Network.resistance(i,j)^2+P_branch(k)
^2*Network.reactance(i,j)^2)/(Network.reactance(i,j)^2+Network.r
esistance(i,j)^2);
Q_branch(k)=-w+sqrt(w^2-q);
buses(j).Q_gen=QsQ_branch(k)+buses(j).Q_load;
%
fprintf('Calculation for bus : %d \n',j)
%
fprintf('Calculation for Qs: %6.5f
\n',Qs)
%
fprintf('Calculation for Qj: %6.5f
\n',Q_branch(k))
%
fprintf('Calculation for Qload: %6.5f
\n',buses(j).Q_load)
%
fprintf('Calculation for Q gen=QsQj+Q_load: %6.5f \n',buses(j).Q_gen)
violation=0;
if (buses(j).Q_gen>Qmax)
buses(j).Q_gen=Qmax;
Q_branch(k)=Qs+buses(j).Q_loadbuses(j).Q_gen;
violation=1;
elseif (buses(j).Q_gen<Qmin)
buses(j).Q_gen=Qmin;
Q_branch(k)=Qs+buses(j).Q_loadbuses(j).Q_gen;
violation=1;
end
if (violation)
% recalculate the voltage of the bus in
case of Qgen violation
a=(Network.resistance(i,j)*P_branch(k)+Network.reactance(i,j)*Q_
branch(k)-buses(i).V^2/2)^2;
b=(Network.resistance(i,j)^2+Network.reactance(i,j)^2)*(P_branch
(k)^2+Q_branch(k)^2);
c=(Network.resistance(i,j)*P_branch(k)+Network.reactance(i,j)*Q_
branch(k)-buses(i).V^2/2);
buses(j).V=sqrt(sqrt(a-b)-c);
end
else % if the bus is PQ bus
P_branch(k)= P_branch(k) + buses(j).P_load buses(j).P_gen; % add the load of the bus to the total absorbed
P of the branch
Q_branch(k)= Q_branch(k) + buses(j).Q_load buses(j).Q_gen; % add the load of the bus to the total absorbed
Q of the branch
% calculate the voltage of the bus
a=(Network.resistance(i,j)*P_branch(k)+Network.reactance(i,j)*Q_
branch(k)-buses(i).V^2/2)^2;
b=(Network.resistance(i,j)^2+Network.reactance(i,j)^2)*(P_branch
(k)^2+Q_branch(k)^2);
c=(Network.resistance(i,j)*P_branch(k)+Network.reactance(i,j)*Q_
branch(k)-buses(i).V^2/2);
buses(j).V=sqrt(sqrt(a-b)-c);
end
P_bus(j)=P_branch(k);
Q_bus(j)=Q_branch(k);
buses(j).delta=buses(i).deltaasin((P_branch(k)*Network.reactance(i,j)Q_branch(k)*Network.resistance(i,j))/(buses(i).V*buses(j).V));
P_loss(j)=
Network.resistance(i,j)*(P_branch(k)^2+Q_branch(k)^2)/buses(j).V
^2;
Q_loss(j)=
Network.reactance(i,j)*(P_branch(k)^2+Q_branch(k)^2)/buses(j).V^
2;
P_branch(k)=P_branch(k)+P_loss(j);
Q_branch(k)=Q_branch(k)+Q_loss(j);
else
P_bus(j)=P_branch(k)+buses(j).P_loadbuses(j).P_gen;
Q_bus(j)=Q_branch(k)+buses(j).Q_loadbuses(j).Q_gen;
end
end
File: plot_results.m
function plot_results(Voltages, Angles, Ploads,
Qloads,Pgen,Qgen,Plosses,Qlosses,Pbus,Qbus)
figure(1)
for i=1:size(Voltages,2)
subplot(3,4,i);
plot(Voltages(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('Voltage')
axis([0 100 0.9 1])
ttl=['Bus ' int2str(i)];
title(ttl);
end
figure(2)
for i=1:size(Angles,2)
subplot(3,4,i);
plot(Angles(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('Angles')
axis([0 100 -0.014 0.014])
ttl=['Bus ' int2str(i)];
title(ttl);
end
figure(3)
for i=1:size(Ploads,2)
subplot(3,4,i);
plot(Ploads(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('P loads')
ttl=['Bus ' int2str(i)];
title(ttl);
end
figure(4)
for i=1:size(Qloads,2)
subplot(3,4,i);
plot(Qloads(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('Q loads')
axis([0 100 0 0.4])
ttl=['Bus ' int2str(i)];
title(ttl);
end
figure(5)
for i=1:size(Pgen,2)
subplot(3,4,i);
plot(Pgen(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('P generation')
ttl=['Bus ' int2str(i)];
title(ttl);
end
figure(6)
for i=1:size(Qgen,2)
subplot(3,4,i);
plot(Qgen(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('Q generation')
ttl=['Bus ' int2str(i)];
title(ttl);
end
figure(7)
for i=2:size(Plosses,2)
subplot(3,4,i-1);
plot(Plosses(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('P losses')
axis([0 100 0 0.25])
ttl=['Line between buses ' int2str(i)];
title(ttl);
end
figure(8)
for i=2:size(Qlosses,2)
subplot(3,4,i-1);
plot(Qlosses(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('Q losses')
axis([0 100 0 0.25])
ttl=['Line between buses ' int2str(i)];
title(ttl);
end
figure(9)
for i=1:size(Pbus,2)
subplot(3,4,i);
plot(Pbus(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('P per line')
axis([0 100 0 10])
ttl=['Bus ' int2str(i)];
title(ttl);
end
figure(10)
for i=1:size(Qbus,2)
subplot(3,4,i);
plot(Qbus(:,i),'--bs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','b',...
'MarkerSize',3);
xlabel('Intervals')
ylabel('Q per line')
axis([0 100 0 10])
ttl=['Bus ' int2str(i)];
title(ttl);
end
8. Appendix B
In the following more detailed Figures from load profiles and generation profiles
will be given.
1.2
1
0.8
0.6
0.4
0.2
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
1.2
1
0.8
0.6
0.4
0.2
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
1
0.8
0.6
0.4
0.2
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
1.2
1
0.8
0.6
0.4
0.2
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
1.2
Workday 2/5Household+3/5Industry
Load Profile
1
0.8
0.6
0.4
0.2
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
1.2
Weekend 2/5Household+3/5Industry
Load Profile
1
0.8
0.6
0.4
0.2
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
0.9
PV Generation
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
Wind Generation
0.1
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91
81
91
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
0.9
0.8
0.7
0.6
0.5
Biomass Generation
0.4
0.3
0.2
0.1
0
1
11
21
31
41
51
61
71
15 minutes time intervals during one day
81
91