Sunteți pe pagina 1din 146

Modelling the Absorbence of the Rural

Distribution Network for Connection of


Embedded Generators

Diploma Thesis
by
Robert Schmaranz

University of Edinburgh
Department of Electronics and Electrical Engineering
Edinburgh, United Kingdom
May 2000

Submitted to
Technical University Graz
Institute of Electric Power Systems
Graz, Austria
Preface 1

Preface
This project was performed at the University of Edinburgh, Department of Electronics and
Electrical Engineering, and submitted to the Technical University Graz, Institute of
Electric Power Systems.

This work is intended to be my final thesis for diploma at the Technical University Graz.

I would like to thank Dr. Robin Wallace, my project supervisor at the University of
Edinburgh, for the proposal of the topic, the discussions and his help encouragement and
professionalism during the course of the project.

Thanks also go to Dr. Gary Conner for his invaluable advice and information provided
with regard to the work I carried out, Gareth Harrison for the help he gave me when
learning the VC++ programming language and the whole Energy System Group for their
aid when writing the report.

Many thanks also go to Professor Lothar Fickert at the Technical University Graz, Institute
of Electric Power Systems, for his help during the application process and encouragement
in the beginning of the project.

A final word of thanks goes out to my dearest friends and family back home for their
never-ending encouragement and support.

The work shall be dedicated to my family and my girlfriend Hanni.

Robert Schmaranz Edinburgh, 15 May 2000

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Abstract 2

Abstract
Electricity is being demanded at an ever increasing rate by modern society. Due to the
depletion of fossil fuel energy sources to generate electricity this increasing demand must
be met by some other means. Government initiatives and the privatisation of the electricity
supply industry in recent years has encouraged the development of wind farms, mini-hydro
schemes and industrial Combined Heat and Power (CHP) generating plants which are
embedded in the electricity distribution network. The operation of these embedded
generators may improve or adversely effect the quality or stability of the electricity
supplied to costumers. Each embedded generation scheme must be assessed for its
technical feasibility as many of the plants may propose to connect in remote areas where
the grid system is already weak. Due to the shear number of proposed schemes there is a
need for a hierarchical rule-base which could identify, at an early stage in development,
any problems that would be encountered by the connection. The effects an embedded
generator has on the distribution system can be determined by different computer
simulations.
This report explains the basics of embedded generation, the problems an embedded
generator has on the rural distribution network and describes the construction of circle
diagrams for a short- and long-transmission line, to determine the absorbence of the grid.
With the developed knowledge a program in Microsoft Visual C++ Version 6.0 is written
to visualise the obtained results.
The Visual C++ simulation shows an universal power circle diagram for a short-
transmission line similar to the power circle diagram of a synchronous machine. It obtains
an active and reactive power area for the receiving end and an area for the receiving- and
sending-end voltage. The program additionally calculates the sending-end values for the
active, reactive and complex power, the power factor, the phase angle, the current and the
load angle.

Keywords: circle diagram, embedded generation, grid absorbence, power flow, voltage
violation

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Table of Contents 3

Table of Contents

1 INTRODUCTION .......................................................................................................8
1.1 General Background ..................................................................................................8
1.2 Worldwide Energy Reserves – Forecast....................................................................9
1.3 Worldwide Energy Consumption – Forecast ..........................................................10
1.4 Situation in the United Kingdom.............................................................................11
1.5 The Future of Distributed Generation in the United Kingdom ...............................13
1.6 Scope of this Project ................................................................................................14

2 EMBEDDED GENERATION..................................................................................15
2.1 Basics.......................................................................................................................15
2.2 The Electricity Supply System ................................................................................15
2.3 Types of Embedded Generation ..............................................................................17
2.3.1 Combined Heat and Power Schemes.................................................................17
2.3.2 Mini-Hydro Schemes.........................................................................................17
2.3.3 Wind Power .......................................................................................................17
2.3.4 Others ................................................................................................................18
2.4 Advantages of Embedded Generators .....................................................................19
2.5 Legislation in the United Kingdom .........................................................................20
2.6 Types of Generators ................................................................................................21
2.6.1 The Synchronous Generator ..............................................................................21
2.6.2 The Induction Generator....................................................................................22
2.6.3 Fault Contribution .............................................................................................24
2.6.4 Choice of Generator ..........................................................................................24
2.7 Solid-State Power Convertors .................................................................................25
2.8 Effects of Embedded Generators on Weak Rural Grids..........................................26
2.8.1 Load Flow and Losses .......................................................................................26
2.8.2 Power Quality ....................................................................................................29
2.8.3 Fault Levels .......................................................................................................29
2.8.4 Steady-State and Transient Stability..................................................................30
2.8.5 Voltage Variations.............................................................................................30
2.9 Protection Considerations........................................................................................32
2.9.1 Generator Protection..........................................................................................32
2.9.2 Loss of Main Protection ....................................................................................32
2.9.3 G59/1 Protection................................................................................................33

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Table of Contents 4

3 POWER FLOW AND ABSORBENCE...................................................................34


3.1 The Per-Unit System ...............................................................................................34
3.2 Reactive Power ........................................................................................................35
3.3 The Four-Terminal Network ...................................................................................37
3.4 The Short-Transmission Line ..................................................................................40
3.4.1 Power Transfer of a Short-Transmission Line ..................................................40
3.4.2 The Circle Diagram for Z = X (R = 0) ..............................................................43
3.4.3 The Receiving-End Power Circle Diagram of a Short-Transmission Line .......46
3.4.4 The Universal Power Circle Diagram of a Short-Transmission Line ...............51
3.5 The Long-Transmission Line ..................................................................................55
3.5.1 Transmission Line Constants ............................................................................55
3.5.2 The Receiving-End Power Circle Diagram of a Long-Transmission Line .......57
3.5.3 The Universal Power Circle Diagram of a Long-Transmission Line................59
3.6 The Use of Power Circle Diagrams.........................................................................61
3.7 Comparison between Long- and Short-Transmission Lines ...................................62

4 DEVELOPMENT OF SIMULATION PACKAGE ...............................................64


4.1 The Programming Language ...................................................................................64
4.2 The Microsoft Visual C++ Environment.................................................................64
4.3 Flow Chart of ‘Universal Power Circle Diagram’ (UPCD) ....................................66
4.4 Starting UPCD.........................................................................................................67
4.5 The Main Menu Screen ...........................................................................................67
4.5.1 The ‘File’ Menu.................................................................................................68
4.5.2 The ‘View’ Menu ..............................................................................................69
4.5.3 The ‘Start’ Menu ...............................................................................................69
4.5.4 The ‘Help’ Menu ...............................................................................................70
4.5.5 The ‘Zoom In’ and ‘Zoom Out’ Button ............................................................70
4.5.6 The ‘Constant Receiving Power Circle’ Button ................................................71
4.5.7 The ‘Constant Power Factor’ Button.................................................................72
4.5.8 The ‘Print Screen’ Button..................................................................................72
4.6 The View Window ..................................................................................................73
4.7 Error Estimation ......................................................................................................76

5 CASE STUDIES ........................................................................................................77


5.1 System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 250 kVA ..................................77
5.2 System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 500 kVA ..................................79
5.3 System fault level: 3.98 MVA, Vgrid: 400 V, Sgrid: 500 kVA ..................................80
5.4 System fault level: 67 MVA, Vgrid: 3.3 kV, Sgrid: 6.5 MVA....................................81

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Table of Contents 5

6 DISCUSSION AND CONCLUSION.......................................................................83


6.1 Overview .................................................................................................................83
6.2 Problems Encountered.............................................................................................83
6.3 Conclusion and Future Work...................................................................................84

7 LIST OF FIGURES...................................................................................................85

8 REFERENCES ..........................................................................................................87

9 BIBLIOGRAPHY......................................................................................................89

10 APPENDIX ................................................................................................................90
10.1 Class Calculation .....................................................................................................90
10.2 Class Circle DiagramDoc ........................................................................................94
10.3 Class Circle DiagramView ....................................................................................100
10.4 Class Draw Axis ....................................................................................................112
10.5 Class Input Dialog .................................................................................................119
10.6 Class MainFrm ......................................................................................................130
10.7 Class P1Out ...........................................................................................................133
10.8 Class PowerFactor Dialog .....................................................................................136
10.9 Class PrintScreenDlg Dialog .................................................................................139
10.10 Class Sconstant Dialog ........................................................................................141
10.11 Resource.h ...........................................................................................................144

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Glossary 6

Glossary

ac............................. alternating current


ACSR...................... Aluminium Conductor Steel Reinforcement
AVC........................ Automatic Voltage Control
AVR........................ Automatic Voltage Regulator
CEGB ..................... Central Electricity Generating Board
CHP ........................ Combined Heat and Power
dc ............................ direct current
DG1 ......................... Distributed Generation/Generator – a conceptual term based on the
fact that an integrated electricity system with centralised generation
can operate with Embedded Generation (EG) which tends to be
situated closer to demand consumers (such as industrial sites with
their own on-site generation). This term is used as a less specific (with
regard to connection voltage) version of EG.
EG1 ......................... Embedded Generation/Generator – refers to generation which is
connected to a distribution network rather than the transmission
system and which is not usually centrally-despatched.
EU........................... European Union
GTO ........................ Gate-Turn-Off Thyristor
IDMT ...................... Inverse Definite Minimum Time
IGBT....................... Insulated-Gate Bipolar Transistor
LDC ....................... Line Drop Compensation schemes
LOM ....................... Loss Of Main
LV........................... Low Voltage (230 V / 400 V in United Kingdom)
MV.......................... Medium Voltage (11 kV – 132 kV in United Kingdom)
HV .......................... High Voltage (above 132 kV in United Kingdom)
NFFO ...................... Non-Fossil Fuel Obligation (England and Wales)
NGC........................ National Grid Company

1
definition taken from [5]

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Glossary 7

PES ......................... Public Electricity Supplier


pf............................. power factor
PWM....................... Pulse Width Modulation
REC ........................ Regional Electricity Company
ROCOF................... Rate-Of-Change Of Frequency (df/dt)
SDI.......................... Single Document Interface
SRO ........................ Scottish Renewable Order
UK .......................... United Kingdom
UPCD ..................... Universal Power Circle Diagram

There are some important differences between the United Kingdom (UK) and the Austrian
system for circuit notation which are explained below:

• To represent an inductance the following symbols are used:


Austria: a black box
UK: a coil-symbol
In this thesis the coil-symbol indicates an inductance.

• The reference arrow in voltage circuits:


Austria: The arrow points from the higher level (dc: plus) to the lower level
(dc: minus, ac: ground) of voltage. Therefore, it indicates the voltage drop.
UK: The arrow points from the lower level (dc: minus, ac: ground) to the higher
level (dc: plus) of voltage. Therefore, it indicates the voltage rise.
In this thesis the arrow indicates the voltage drop.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Introduction 8

1 Introduction

1.1 General Background

Increasing environmental concern since the beginning of the decade has promoted
considerable interest in the improvement of energy efficiency, the reduction of pollution,
and the development of non-fossil-fuel and renewable energy generating schemes.
Liberalisation of the electricity supply industries in many industrialised countries has
resulted in the market-driven dispatch of privately-owned generating plants of capacity
ranging from a few hundred kW up to 600 MW. Because such plant cannot be centrally
constrained and since it can be connected to national electricity systems at distribution
voltage, it is termed Embedded Generation (EG). System expansion in recent years in the
United Kingdom has largely been met by the installation of privately-owned EG plant
(mainly fast-access gas-turbine plant) which makes a significant contribution to total
capacity.
Many European Union (EU) member states actively encourage renewable energy
development by providing enhanced tariffs for energy produced from non-fossil fuel
sources or by subsidy of investment in renewable energy plant. Among the truly renewable
energy sources, wind and hydro power offer the greatest natural potential and the
technologies are mature, proven and market-ready. Wind turbines offer economy of scale
and commercially viable expansion tends to take the form of multi-machine wind farms,
with unit capacities below 500 kW. Water turbines do not offer the same economy of scale
and in many industrialised countries much of the large-scale hydro schemes were
developed many years ago, requiring considerable government-led investment that will
never again take place on the same scale, but there is considerable private interest in small
and mini-hydro power stations [22].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Introduction 9

1.2 Worldwide Energy Reserves – Forecast

Figure 1-1 shows the worldwide consumption of crude oil, natural gas, coal and the ‘static
range’ of secure reserves in the years 1970, 1980, 1990 and 1997. ‘Static range’ defines the
temporal range for unchangeable production in the year specified and on the assumption of
no further prospecting.

mio. t oil-equivalent

production of crude oil


data in years for
production of coal unchangeable consumption
production of natural gas
Figure 1-1: Range of the worldwide crude oil-, natural gas- and coal-reserves2

It is noted that the discovery of new resources in the last two decades has increased at a
rate higher than consumption. The secured crude oil and natural gas reserves for 1970 were
only for 36 and 42 years respectively. Twenty-seven years later, in 1997, the static range
was 41 and 64 years respectively. It can be assumed that there will be the discovery and
development of considerable new resources in the future, and thereby no decrease in the
static range of fossil fuel. Another factor to be considered is that of political instability, as a

2
Data source: [1]

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Introduction 10

considerable part of the natural gas and crude oil reserves lies in potential crisis
regions [3].

1.3 Worldwide Energy Consumption – Forecast

Figure 1-2 shows the worldwide consumption of primary energy until 2050 in three
different scenarios predicted by the World Energy Council (WEC) and the International
Institutes for Applied Systems Analysis (IIASA).

24,8
Giga Tons Oil Equivalent [GTOE]
22%
A ...’high growth’
B ...’middle course’
19,8
C ...’ecologically driven’
22%
19%
15,4
13,6 14,2
16% 23%
11,4 32% 39%
17%
24%
9,0 24% 21%
20%

18% 30% 27%


27%
28%
19%
15% 21%
34% 26%
24% 19%
25%
24% 20% 12% 14%
11%
6% 6% 7% 6% 4%
A B C A B C
1990 2020 2050
renewables crude oil nuclear power
natural gas
Figure 1-2: Evolution of the world energy consumption 1990, 2020 and 20503

Case A (‘high growth’) addresses key development in energy supply. It varies principally
in the future to envisage coal on the one side, and nuclear and renewables, on the other.
Dominance of oil and gas is perpetuated to the end of the 21st century. After 2020 rapid
technological change in nuclear and renewable energy technologies will result in a
phaseout of fossil fuels for economic reasons rather than due to resource scarcity.

3
Data source: [29]

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Introduction 11

Course B (‘middle course’) incorporates more modest estimates of economic growth and
technological development, and the demise of trade barriers and expansion of new
arrangements facilitating international exchange. Compared with the Case A and C
scenario, it is more ‘pragmatic’, which is its main appeal.
Case C (‘ecologically driven’) is the most challenging. It is optimistic about technology
and geopolitics, but unlike Case A, it assumes unprecedented progressive international
cooperation focused explicitly on environmental protection and international equity. In
Case C, nuclear energy is at a crossroad. In this case there is a reduction of carbon
emissions in 2100 to 2 Gigatonnes of Carbon per year, one-third of today’s level [29].
World population is expected to double by the middle of the 21st century and economic
development will continue. According to the scenarios of the forecast, this results in a 1.5
to 3 fold increase in world economic output by 2020 and a 3 to 5 fold increase by 2050.
The average percentage increase of renewables for all three scenarios will be about 50%
between 1990 and 2020 and about 220% between 1990 and 2050.

1.4 Situation in the United Kingdom

In 1919 there were some 570 separate electricity undertakings in the UK operating 430
generating stations. There was no national transmission system and so the generators were
connected directly to distribution networks serving their local area. The 132 kV National
Grid was then built which allowed larger, more efficient generating stations to be used and
electricity to be transmitted to remote loads. After nationalisation in 1948 the power
system was developed using very large central power stations feeding a 275 kV or 400 kV
supergrid which provided the bulk supplies to the distribution networks.
The Energy Act of 1983 contained an obligation on the area electricity boards to purchase
power from independent generators, but this legislation failed to stimulate the wide scale
development of EG [10].
In 1990, UK’s Central Electricity Generating Board (CEGB) was privatised as part of the
restructuring of the electrical supply industry. This privatisation established conditions
which are likely to be more favourable, although the commercial and administrative
arrangements for EG in the new electricity market are complex and still being developed.
The economic benefits of promoting competition between the resulting companies have
been well documented, but attention must also be paid to the effects on the technical and
operational aspects of such a change.
Previously, the nationalised industry was effectively a monopolistic structure in which the
CEGB sold electricity to the 12 area distribution boards who each supplied a particular
defined geographical area. Under this structure the CEGB had control of both the

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Introduction 12

generation and the transmission system. Within the new structure, the ownership and
operation of the 400 kV and 275 kV transmission system was transferred to the newly
formed National Grid Company (NGC), with generation going to National Power,
PowerGen and Nuclear Electric, with exception of 2100 MW of hydroelectric pumped
storage capacity which remained within NGC. Since privatisation, an additional 46
generation licences have been issued to 22 independent generators. NGC was given the
remit to ‘develop and maintain an efficient, coordinated and economical transmission
system and to facilitate competition in the generation of electricity’. Local distribution
remained with the 12 area distribution boards, now known as Regional Electricity
Companies (REC), to which NGC supplies power.
The key features of this structure are that power is traded through an open commodity
market known as the Pool, and that generators have no assurance of market share, but have
to compete for business [14].
There has been a gradual increase in the amount of commissioned capacity of CHP and
renewable energy schemes throughout the country in recent years. Figure 1-3 shows that
the capacity of DG is about 3 GW, and this represents approximately 5% of the peak
demand in the UK.

Figure 1-3: The recent growth of DG (installed capacity/MW) in the UK4

4
Data source: [4]

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Introduction 13

The CHP schemes in Figure 1-3 tend to be less than 1 MW sites (83% of CHP sites were
less than 1 MW in 1998) although the 5% of sites which were above 10 MW generate 79%
of the total electricity. If we assume that the sites above 10 MW are not DG, then about
822 MW (21% of total) is DG. The remaining 3107 MW would then be transmission-
connected.
The renewable plant is generally contracted under the Non-Fossil Fuel Obligation (NFFO)
and the Scottish Renewable Order (SRO) and does not include large hydro or pumped
storage stations. The growth in renewable project development is driven by government
announcements of NFFO orders.
Large hydro plant, of which the majority is located in Scotland, are also defined as DG [5].
Large hydro is defined as plant belonging to companies with an aggregate hydro capacity
of more than 5 MW and the data used in Figure 1-3 exclude pumped storage schemes [4].

1.5 The Future of Distributed Generation in the United


Kingdom

European initiatives, UK Government Renewable Orders NFFO 1-5, SRO 1-3, and
revisions to energy trading arrangement will increase significantly the European and UK
capacity of embedded and renewable generators. The renewed interest in EG has been
stimulated by a number of technical, commercial and environmental factors. These include
the high overall thermal efficiencies possible with CHP and the Government’s
commitment to new renewable energy sources such as landfill gas and wind power.
Permission for the construction of overhead circuits is difficult to obtain in certain areas
and so the use of diesel or small gas turbine generators is being considered for
reinforcement of the local distribution network.
There will be a large expansion of EG-capacity in the UK, if the Government is to meet its
targets of:

• Renewable energy providing 10% of UK’s electricity supplies by 2010, and


• Having 10 GW of CHP capacity contributing to the demand.
This is approximately a 3 to 4 times increase in unconstrained capacity to be added in the
next 10 years and most of the new plant will be connected within the distribution network.
More significantly, the capacity of renewable energy generating plants that are likely to be
connected to the weak, remote parts of the distribution network is forecast to rise by over
12 times. Since none of this new plant will be centrally constrained or dispatched, and its
presence will cause wide variations in rural load flow, there is real concern in the RECs
about the effects on the distribution system of this amount of embedded renewable

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Introduction 14

generation. Government aspirations will only be met if access is maximised by research


into the ability of the distribution system to absorb and better integrate this rapidly
increasing capacity of EGs.
Looking further into the future, the increased use of fuel cells, micro-CHP using Stirling
engines and photovoltaic devices integrated into the fabric of buildings may all be
anticipated as possible sources of power for EGs [10].

1.6 Scope of this Project

Embedded unconstrained renewable and CHP generating plant (EGs) at remote locations
in the rural distribution system nearly always results in unacceptable voltage violations –
both when the plant is in and out of service. The extent of this violation is determined by
the net reversal of load flow, which varies with time of day and seasonally, because the
availability of the energy resource and local load each vary to different chronological
patterns.
To ensure that the distribution system will absorb the exported power within a statutory
voltage envelope RECs include in the EG connection cost the reinforcement of those areas
of the distribution system at which violation would occur. In many cases the attribution of
these costs to new projects render them unfeasible and curtails the development of many
otherwise suitable sites.
The aim of this project is to develop a body of knowledge and software that will readily
establish the absorbence of the rural distribution network at a proposed point of
connection. This will not be a single capacity but an area of active and reactive power
within which the EG can operate without the net export leading to voltage violation.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 15

2 Embedded Generation

2.1 Basics

The supply of electricity to the distribution network by most EGs is determined either by
the heat demand and internal load of a CHP scheme or by the energy available from a
renewable energy source. Thus the power output of CHP schemes may be described as
‘heat lead’ while renewable energy schemes may be considered to be ‘source led’.
Small generators are not subject to central dispatch by the NGC and so do not respond
directly to the national electricity demand. However, some generators may respond to
system loading conditions indirectly through pricing signals received via tariffs or other
charging mechanisms. Although a small number of generators have been installed
specifically to support the distribution system, most schemes are operating independently
of the loading and voltage conditions on the local network. Wind turbines and some micro-
hydro plants use induction generators with no direct control over reactive power flow
while even CHP plant with synchronous generators may either use rather simple excitation
equipment or choose to run at unity power factor in order to minimise charges for reactive
power. Even those types of plants which technically can respond to distribution network
conditions may be quite inflexible for commercial or contractual reasons.
At present most EG is viewed as a source of energy, rather than generation capacity, and
the rules governing its connection reflect this. In the future, as the quantity of EG continues
to increase it may be necessary to integrate its operation much more closely with that of the
distribution network and to recognise its contribution to the capacity of the power system.
Although technically this is quite feasible, the required commercial and institutional
arrangements are not yet in place [10].

2.2 The Electricity Supply System

There are two ways generators can feed into the electricity supply system:

• At the level of the high voltage transmission network, i.e. into the National Grid. This
is what all large generators do and it is known as centralised generation.

• At the level of the lower voltage distribution network, i.e. directly into the Regional
Electricity Companies (RECs) network. This is known as Embedded Generation.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 16

A diagrammatic representation of the UK electricity supply industry is shown below


(Figure 2-1). All wind farms and most other renewable projects are embedded generators.
EG can bring a number of advantages over centralised generation, but the extent of the
advantage depends on where the EG is located in the network.

Large Generator Large Generator

Electricity Pool NGC Transmission


Network

REC Distribution
Network

Embedded
REC/PES REC/PES REC/PES REC/PES REC/PES
Generator
= Electricity meter
Figure 2-1: UK electricity supply industry

Basically, EGs deliver electricity to consumers in a more direct way than centralised
generators. The electricity is generated in closer proximity to the user, reducing the
distance over which the electricity has to travel and therefore reducing electrical losses.
The electricity is also delivered either at or closer to the correct voltage for distribution.
The electrical output from centralised generators has to be transformed up to a high
voltage, transmitted, and then transformed back down to the lower voltage.
Many problems can occur when renewable-energy generators are installed at the remote
extremities of power systems due both to the characteristics of the generators and the
weakness of the electricity network. There can be variations and reversals in load flow
causing electrical power transmission to exceed system thermal capacities, unacceptable
voltage regulation, increased fault levels and loss of stability.
To accept safely the power produced by new renewable energy generators it is frequently
necessary to up-grade and reinforce the existing electricity distribution system. This is an
expensive process that can jeopardise the economic feasibility of many new seemingly
attractive renewable energy schemes [22].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 17

2.3 Types of Embedded Generation

2.3.1 Combined Heat and Power Schemes

Many large industrial sites utilise CHP schemes. Steam is used to run a turbine and
generate electricity for the site. The steam leaves the turbine at a temperature that makes it
useful for heating the site or delivery to any processes that require heat. Some industrial
processes produce steam as a by-product and this makes this type of scheme a very viable
alternative to buying in electricity. In the past most of these schemes operated in isolation
but now with the change of legislation they can be embedded into the rest of the electricity
network. Excess power generated can be sold to the local distribution company increasing
profitability. Most of these types of plant use synchronous generators so that they can
operate in isolation.

2.3.2 Mini-Hydro Schemes

The total installed hydro-electrical capacity in the world is currently close to 650 GW,
meeting approximately 18.5% of global electricity demand. The World Council estimates
that the world-wide growth of small-hydro capacity (general defined as less than 10 MW)
between 1990-2020 will be 12%, rising to a predicted total capacity of 65 GW, with
greatest investment in newly-industrialised or less-developed countries [22].
In the UK most potential large-scale hydro schemes have being exploited. In Scotland
hydro-generated electricity accounts for 40% of electricity capacity. The development of
small scale hydro generators has increased in the UK with the change of legislation and the
obligation to renewable energy sources. Now, previously unviable schemes can be
developed as an EG. Within the UK, the total small-scale accessible and practicable
resource by 2005 is estimated to reach 3.9 TWh/yr (including existing sites) with 80% of
the unexploited resources in Scotland [19].

2.3.3 Wind Power

Wind power is a form of EG that is being actively encouraged by most developed


countries. These countries have committed to generate electricity through renewable means
and using wind power is one viable alternative energy source. There are two schools of
thought as to the best forms of wind energy:

• Single generators which have a large diameter blade and a medium generating
capacity. Because of their large size they are not considered as EG and in some cases

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 18

they form the main source of generating especially on Island communities. Most large
wind generators were developed from research and usually exist in prototype form.
Their experimental status makes them unreliable and there is usually difficulty in
obtaining spare parts [19].

• Wind farms, which are the most common type of wind generation, contain a number
of small generators in one area. The size of each individual generator may be small
but the aggregate capacity can be large. Wind farms are becoming increasingly more
widespread and the technology is becoming standardised and reliable. The large
number at any one site means that some turbines can be switched off for repairs
without having any major effects. These farms are normally placed in remote rural
areas and are connected into the local distribution network.

2.3.4 Others

There has been much research into ways of harnessing renewable energy from different
natural sources. Much of the research was carried out in 1970s, during the oil crises but
now with the commitments to enhance development of renewable energy sources funds for
research have been increased. These include:

• Geothermal energy
Geothermal energy, in the broadest sense, is the natural heat of the earth.
Temperatures in the earth rise with increasing depth. Geothermal energy may be
relevant in those parts of the world where the heat of the earth’s core penetrates the
cold crust and comes near to the surface [13].

• Ocean energy
There are two different types of ocean energy: wave power and tidal power. Wave
power uses small machines that can tap the power of the waves by bobbing up and
down. Tidal power is similar in all essential respects to hydroelectric power. The
difference is that tidal-electric power is obtained from the oscillatory flow of water in
the filling and emptying of partially enclosed coastal basins during the semidiurnal
rise and fall of the ocean tides [16].

• Photovoltaic energy
This means converting the sun’s energy directly into electricity, using photovoltaic
cells.

• Solar thermal energy


To use solar power in an industrial way it is necessary to concentrate sunlight falling
over a wide area with a large number of reflectors. This heat is used to produce steam
and to drive a turbine which generates electricity.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 19

2.4 Advantages of Embedded Generators

The commercial advantages of small generating plant arise from the benefits of being
‘embedded’ in distribution networks and the costs which it can avoid [5]:

• DG plant is not centrally-despatched by the NGC, can generate at will (self-


dispatched) and is not liable for generation transmission charges;

• DG plant contracted to a supplier can reduce the suppliers liability for electrical
losses in the transmission- and distribution-system as well as some charges for the use
of the distribution network;

• DG can provide benefits to the network such as avoiding or deferring network


reinforcement.
The DG’s are rarely, if ever, rewarded for most or all of these benefits. As more of these
benefits are acknowledged and rewarded in the marketplace, DG will become more
attractive to investors. DG has other advantages which all contribute to the growth in their
development. For example [5]:

• the operating regime of CHP plant is governed by the heat and/or steam demand on-
site and so it can run as and when it is required;

• construction timescales tend to be shorter than for transmission-connected generators;

• both CHP and renewables are promoted as part of the Government’s energy and
environmental programmes.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 20

2.5 Legislation in the United Kingdom

The statutory requirements for the operation of a private generating plant connected to the
electricity supply network are set out in the Electricity Supply Regulation from 1988. The
Energy Act (1983) permits any private person or company to use the electricity utility’s
transmission and distribution networks to transmit energy [19].
In the Electricity Supply Industry there are extensive statutory requirements covering the
transmission and distribution of electricity. These requirements include statutory
obligations with respect to frequency, voltage, fault level, fault detection and protection.
Before permission to connect an EG is given by the REC there is an established procedure
that a design and application has to go through [2]:

• Notification: The REC has to be informed of a proposed project before advanced


planning can proceed. An outline proposal has to be submitted to establish the
feasibility of the project and to prepare costs.

• Technical Submission: Once preliminary notification has been approved a more


detailed submission has to be made. Technical details of the scheme will be included
and the REC will carry out a design study.

• Connection Quotation: When the details are agreed between REC and developer the
REC makes a formal connection quotation. Planning permission and wayleaves must
be obtained both for the connection to the grid and also the necessary buildings and
structures.

• Connection, Supply and Meter Operator Agreements: These are drawn up


between the PES and the EG-operator and include all the detailed aspects of the
interface including protection, earthing and metering requirements. They also include
details of charges for imported real and reactive energy.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 21

2.6 Types of Generators

Once the output power and speed of the prime mover are determined, a fundamental choice
that developers must make is whether to install synchronous or induction generators. The
major differences between these two include method of excitation, operating efficiency and
power factor, fault contribution and harmonic generation [6].

2.6.1 The Synchronous Generator

Synchronous generators are the traditional form of EGs. They are widely used and make
up the bulk of EGs. They are called synchronous generators because they generate
electricity only at synchronous speed. In the case of a generator acting in isolation this
speed is set by the governor. When a synchronous generator is brought on-line it is first
brought up to speed and then carefully synchronised. This is done by comparing frequency,
voltage and phase. After the connection the frequency of the grid controls the speed of the
generator.
In the steady-state a synchronous generator with a constant terminal voltage may be
represented by the simplified diagram and the phasor diagram shown in Figure 2-2, where
M is the mechanical prime mover, E is the voltage induced in the stator due to the rotating
flux from the rotor, XS is the armature reaction, V is the voltage of the network, δ is the
load angle, φ is the phase angle and cosφ the power factor.

XS E
IXS
M E V
δ
φ V
I

Figure 2-2: Small synchronous generator connected to the network and phasor diagram

It is common to find descriptions of how the governors of large generators may be set to
maintain system frequency and the excitation system to control voltage. These
considerations do not apply to a small generator connected to a utility distribution system.
The generator has little control over its terminal voltage and none over the system
frequency, which is fixed by the network. Therefore the governor is used to control the real
power output of the unit and the excitation system determine the reactive power flow [10].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 22

For the simple circuit of Figure 2-2 it may be shown that the generator output, per phase,
of real and reactive power is given by:

E⋅V
P= ⋅ sin δ Equ. 2-1
XS

E⋅V V2
Q= ⋅ cos δ − Equ. 2-2
XS XS

Recalling that both V and XS are constant and that δ is likely to be less than 30°, these
simple equations illustrate how:

• The real power output (P) is controlled by the governor or the mechanical prime
mover which determines the applied torque and hence the power angle (δ).

• The reactive power (Q) is controlled by the excitation system which varies the
magnitude of the induced stator voltage (E).
A synchronous generator is excited by a dc-current applied by the field winding. In
statically excited machines this dc is derived from the generator output by rectifying the ac
and applying it to the rotor via slip rings. Modern brushless excitation systems use a
permanent magnet exciter to supply this power. The armature of the exciter and the
rectifier bridge are located on the rotor so power is transferred without the need of slip
rings. This assists voltage build up at start but means that the generator will continue to
provide fault current even with a short-circuit close to its terminals.
Synchronous generators are attractive as they can operate in a number of modes and allow
independent control of real and reactive power flow. However, they need to be carefully
synchronised to the grid and brushless excitation leads to complex rotor constructions
which makes them expensive, although the large number of synchronous machines which
are used in packaged standby diesel generating sets leads to economies of scale in their
production [10].

2.6.2 The Induction Generator

Induction generators are simpler than synchronous generators, only the stator is excited.
They are, in principle, motors with torque applied to the rotor shaft. Induction generators
are becoming popular because of their simple construction, the fact that they do not need to
be synchronised to the grid and their ability to introduce damping into the drive train of the
generating set. They are commonly used in wind generators as they are able to absorb the
fluctuating torque produced by the blades passing the tower. Small synchronous generators
are not capable of providing adequate damping to control this torque. Small, high slip
induction generators possess very good damping characteristics but it may be noted that, as

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 23

they increases in size, the transient response of induction generators to applied torque starts
resemble that of synchronous machines [10].
The operation of an induction generator may be understood using the familiar induction
motor equivalent circuit of Figure 2-3, where s is the slip, R1 is the stator resistance (stator
copper loss), X1 is the stator reactance, Xm is the magnetising reactance, RC is the
magnetising resistance (iron loss), X2’ is the rotor reactance referred to the stator and R2’ is
the rotor resistance referred to the stator (rotor copper loss).

R1 R2’

V1 RC R2’(1-s)/s

Figure 2-3: Equivalent circuit of an induction machine

The usual simple analysis of this circuit leads to the torque/speed characteristic shown in
Figure 2-4, where s is the slip, τ is the shaft torque, sM is the slip at τmax, -sM is the slip at
τmin, ω is the shaft speed and ωs is the synchronous shaft speed.

motoring generating

τ
τmax

1 sM 0 -sM -1 s
0 no ωS 2ωS ω
load

normal
generation

τmin

Figure 2-4: Torque/speed curve of an induction machine

Operating as a generator the slip is negative and the peak torque is larger than when the
same machine is motoring. Variations in prime mover torque are absorbed by an increase

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 24

in rotor slip. Induction machines require magnetising current to create a magnetic field,
thus an induction generator can not operate without a connected electricity supply unless it
is separately excited. The field in the stator rotates at the same frequency as the grid and
does not vary with torque applied or time. To produce active power the rotor rotates at
above synchronous speed. The percentage difference between the speed of the rotor and
the synchronous speed of the magnetic field of the stator is called the slip. The slip varies
with the torque supplied by the prime mover. Unlike the synchronous machine the reactive
power requirement of an induction machine remains constant and the power factor will
vary from 0 to 0.9 leading and cannot be set like synchronous generators. The generator’s
power factor will progressively decrease as the output power is reduced and falls off
rapidly at light load.
Switching in of induction generators is simpler than of synchronous generators. The
generator may be brought up to speed as a motor with the reactive and real power being
supplied by the grid. Then the active supply to the prime mover can be switched, the prime
mover accelerates above synchronous speed and the generator then supplies real power to
the grid.

2.6.3 Fault Contribution

The initial fault contribution from an induction generator is likely to be lower than that
from a synchronous generator of equivalent capacity. An induction generator cannot make
a sustained contribution to a ‘close-up’ short-circuit in the system. Provided that the short-
circuit causes the voltage on the stator to collapse, the rotating magnetic field will
disappear and the machine will stop generating. Therefore the fault current of an induction
machine is generally not relied on for the operation of any protective relays. The sub-
transient fault current of a synchronous generator will contribute to the fault current of the
network and may lead to overstressing of switchgear. In both cases the initial fault
contribution may be estimated from the sub-transient reactance of the machines, with
induction generators having a higher reactance than synchronous.

2.6.4 Choice of Generator

The choice of the type of machines to use for an EG is always left to the developer.
Induction machines are usually cheaper than synchronous machines, they are simpler and
more robust in construction, there is no apparent need for a governor or voltage regulator
and synchronising and protection equipment is simpler and less expensive [24]. For these
reasons induction machines are usually chosen initially provided that they can be
magnetised from the grid. Developers may forget the possibility that they may have to

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 25

purchase the reactive power to magnetise their machine from the REC and this will be
expensive.
In some cases the choice will be determined by the nature of the prime mover. The
generators of wind turbines experience strong periodic torque pulsations as the blades pass
the tower as well as those brought about by changes in wind speed. Synchronous machines
have only limited damping and careful design is necessary to control even the cyclic torque
variation in a reciprocating engine. For this reason induction machines are normally used
for wind power generation and synchronous machines are used where the delivery of
mechanical power from the prime mover has a much lower torque variance. Examples of
these are:

• water turbines (mini-hydro schemes)


• steam turbines (waste or landfill gas burning)
• gas turbines (CHP schemes)
• high speed diesel engines (CHP schemes)
It should be noted that induction generators could also be used with any of these prime
movers. Ultimately the choice of machine for the EG will depend on the effect it has on the
distribution network when it is connected and exporting real power [6].

2.7 Solid-State Power Convertors

High-power electronic devices are being used increasingly in various convertor


configurations to interface EGs with the distribution network. The main advantage of these
arrangements is that the speed of the generator is no longer directly linked to the network
frequency.
The conventional circuit is that of Figure 2-5 which shows a current source, naturally
commutated network side convertor. The generator side convertor may be a controlled or
diode rectifier, but its operation has little effect on the distribution network.

prime
rectifier X transformer
mover
M
generator current source grid
naturally commutated
convertor
Figure 2-5: Variable speed convertor (using thyristors)

This arrangement is well proven and uses thyristors as switching devices. However, the
power factor of the network side convertor is proportional to the dc link voltage which, on

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 26

weak networks, must be kept low. Also, significant harmonics currents are injected into the
network and so filtering is likely to be required [10].
A more recent development is the voltage source, forced commutated convertor, shown in
Figure 2-6. This uses either Insulated-Gate Bipolar Transistors (IGBTs) or Gate-Turn-Off
thyristors (GTOs) as the switches.

prime rectifier
mover transformer

M C
generator voltage source grid
forced commutated
convertor
Figure 2-6: Variable speed convertor (using IGBTs)

This convertor can run at any desired power factor and, using fast switching in a Pulse
Width Modulation (PWM) pattern, does not produce low-order harmonics. Although much
more benign to the network, these convertors are at present rather expensive and rapid
switching of the devices can lead to significant power losses [10].

2.8 Effects of Embedded Generators on Weak Rural Grids

Energy schemes with exploit renewable energy resources in particular have to be located
where the source of primary energy is available. This may be in a geographically or
electrically remote area, therefore the EG is often installed in areas where the grid system
is weak. The presence of the EG can lead to real and reactive power flows in rather
direction depending on the powers produced and absorbed locally, and this must be
predicted carefully for all local loads [5]. The design, selection and application of EG plant
requires to be assessed carefully to ensure satisfactory operation under all conditions,
including the ability of the distribution grid to successfully integrate the generators
presence.

2.8.1 Load Flow and Losses

Passive distribution networks were originally designed to deliver electricity from the main
transmission system to remote consumers, with real and reactive power generally flowing
towards the edge of the system in the direction of the voltage gradient. Particularly with
single source radial distribution feeders, transformers along the feeders are tapped up to
compensate for the voltage drop along the line under maximum loading to ensure that
consumers at the remote end receive supplies within the statutory voltage limits. Due to the

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 27

remote location of renewable energy resources, many EGs are now connected to the
remote ends of distribution networks at, or below 33kV, operating in parallel with the
existing grid system. Integrating EGs to operate in parallel with the existing grid system
produces an active distribution network with bi-directional power flows (depending on
loading conditions), resulting in a change in losses and variations in voltage. This is
illustrated in Figure 2-7 by considering the effects of increasing generator output power in
a feeder with a fixed local load.

33 kV

AVC
11 kV

Power transmitted
PLine, QLine

400 V

Local Load
Embedded PL, QL
Generator
PG, QG

Figure 2-7: Typical EG connection

There are five cases to be considered [22]:


1. If the output of the EG is zero, the local load is supplied by the grid (PLine = PL and
QLine = QL).
2. If the active (or real) power PG [kW] and reactive (or imaginary) power QG [kVAr]
produced by the EG is less than that required by the local load PL and QL, this reduces
the real and reactive power PLine and QLine transmitted from the grid towards the
generator (PLine = PL - PG and QLine = QL - QG) and reduces losses on the distribution
system and voltage drop along the line.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 28

3. If the generator output increases until the kW and kVAr generated just meets that
demanded by the local load or load distributed along the line, losses in the line are zero
and the voltage profile is virtually flat.
4. Where the active and reactive power produced exceed that consumed locally, but is less
than twice the local load demand, the excesses are exported along the line towards the
bulk supply point, causing an increase in losses and local voltage rise, but these will be
comparable in magnitude with those of the voltage drops where the grid supplies the
local load.
5. If the active and reactive power produced is more than twice the local load demand, the
increase in load flow and losses may exceed the thermal limits of the line and the local
voltage may exceed the statutory maximum.
The 11 kV or 33 kV circuit breakers within the supply authority boundary may have
current- or impedance-operated protection relays set to protect the system for
unidirectional power flow. Their operation may become ineffective or spurious as a result
in the re-direction and changes to current flow in the system.
The transmission of additional real or reactive power – in either direction increases feeder
losses. A large synchronous generator operated overexcited exports reactive power that
exaggerates voltage rise and increases system losses. The presence of a large induction
generator which requires to be magnetised from the grid will add to the system losses as
reactive power is supplied to magnetise it, but a fortunate consequence is that absorbing
reactive power at the remote end reduces voltage rise. If a large quantity of reactive power
is carried, then the maximum real power that can be transmitted within the thermal limit of
the line is reduced.
Larger sites such as multi-machine wind farms or large-hydro power stations are usually
thermally limited by the capacity of the rural system, and the costs of upgrading
substations and/or re-conductoring sections of line are most frequently attributed to the
scheme proposed. Even if there are no problems brought about by thermal limits the next
most prevalent limit occurs due to increased voltage variations [22].
It is conventional practice for the network voltage to be controlled by Automatic Voltage
Control (AVC), such as auto-tap changing transformers, (negative reactance) Line Drop
Compensation schemes (LDC) and AVC relays. The AVC voltage reference is usually on
the second winding of the supply transformer, as shown in Figure 2-7. When the EG is
exporting, reverse power flow through the transformer causes erroneous operation of the
voltage sensing relay and tap-changing mechanism. Protection settings for the supply
authority under- and over-voltage relays that are appropriate for the condition where the
generator is out of service may cause the relays to operate and trip the authority circuit
breakers when the generator is in service and loaded (or vice-versa). Time variant energy

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 29

sources (wind farms, wave-devices) without storage produce power and voltage variations.
This is a serious problem because it causes the AVC equipment operating continually
rather than occasionally, leading to increased wear and maintenance [11].

2.8.2 Power Quality

Embedded generation will influence the power quality of distribution networks. The usual
causes of concern are transient network voltage disturbance, referred to as ‘flicker’ because
of its effects on lighting, and harmonic distortion of the voltage waveform. Voltage flicker
may be caused either by the connection and disconnection of generators or by transient
torque pulsations from the prime mover being translated into network voltage variations.
Harmonic distortion of the network voltage is generally caused by the power electronic
interfaces which are being used increasingly for the connection of EGs, although directly
connected generators may also have an effect.
Standards are in place to control the connection of loads likely to degrade the power
quality of the distribution network, and these are also applied to EGs. Voltage flicker and
harmonic voltage distortion tend to be most significant in rural distribution systems which
have a low fault level and hence high source impedance. Surprisingly, the connection of
rotating EGs may act to improve the power quality of the network by increasing the fault
level and so reducing transient voltage variations [11].

2.8.3 Fault Levels

Where the electricity supply system is heavily reinforced the prospective three phase
symmetrical short-circuit fault level of the grid is likely to exceed that contributed by the
EG towards an intervening fault. In such circumstances it is the developers responsibility
to ensure that their new switchgear is adequately fault rated for the total prospective (and
future) grid fault current and the contribution from the generator.
A geographical effect of installing the EG at a remote point is that the system fault level
decreases with increasing series impedance and the REC switchgear at the remote end may
have a fault capacity below that resulting once the EG was connected. Where the supply
grid is older or weaker the increases fault level due to the EG plant may cause the total
fault level at points out in the system to exceed the supply authority switchgear short-
circuit rating. If the short-circuit fault level at any point in the system exceeds the fault
rating of the switchgear this will require the installation of new switchgear whose costs
may be included in the costs of connecting the new EG.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 30

It should be noted that while the REC may quote a fault level at the point of connection,
they reserve the right to reinforce fully the network up to this point, and this future fault
level may exceed existing values and must be taken into account.
Synchronous generators with permanent magnets or otherwise secure excitation supplies
and low reactances contribute the highest short-circuit currents. Smaller EGs will have less
impact on any limit imposed by system fault level or capacity, and will integrate more
easily in remote areas. Installing the EG at a location closer to the primary substation will
mean that the existing equipment is likely to have a higher fault capacity with a margin that
would allow the connection of a larger EG. The likelihood of the EG exceeding the fault
capacity is proportional to both EG capacity and distance from the primary substation [22].

2.8.4 Steady-State and Transient Stability

Steady-state and transient stability analysis is necessary to determine the ability of the
embedded synchronous generator to remain synchronised following small disturbances in
the grid system (e.g. gradual changes in load, excitation or prime mover input) and large
disturbances (e.g. severe load changes, switching operations and electrical faults). During
such disturbances there is a dynamic mismatch between mechanical power input to the
generator and that absorbed to produce the electrical power accepted by the grid
connection. This results in acceleration, dynamic change in shaft speed and rotor angle and
possible loss of synchronism. The generator behaviour and overall stability depends on

• the fault type;


• the electrical distance from disturbance;
• the stored kinetic energy in the shaft system (directly rated to combined shaft inertia
of the shaft system) and eventually on
• the response of the governor or AVR.
Distribution codes, Engineering Recommendations and Guidelines define the design,
operational and protection requirements applied to EG schemes [22].

2.8.5 Voltage Variations

Many generators may be owned by organisations without any direct interest in power
quality and its main control will therefore be through the connection agreement. One of the
main concerns about the effect EG has on power quality in general is the steady-state
voltage variation, which will be considered in Chapter 3 and 4. The EG capacity is
normally limited by the maximum over-voltage created at any point in the REC
distribution network, which is usually at the most remote point closest to the EG.
Following rationalisation in 1995, the statutory voltage variation for LV-distribution

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 31

networks in the UK became +10/-6% of nominal 400/230 V. The variation at MV is only


around ± 6% but the problems with voltage violation are most frequent and obvious at LV.
These limits are in place to protect consumers and network equipment.
A remote EG that produces real (P) and reactive (Q) power (over-excited synchronous
generator) causes a greater local voltage rise than it would at unity power factor (Q = 0).
An EG that absorbs reactive power (under-excited synchronous generator or induction
generator) will reduce local voltage rise.
The REC may accommodate the over-voltage at LV by tapping down the local transformer
but this is unusual since when the EG trips or is shut down the voltage at the remote end of
the line may fall back below the statutory minimum. Where there is AVC equipment
within distribution substations, such as auto-tap changing transformers, the reverse load
flow and voltage violations can cause over-frequent operation. This is particularly serious
where renewable energy power production can vary widely and frequently.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 32

2.9 Protection Considerations

The addition of rotating EG plant will raise the network fault level and change the X/R-
ratio of the system as seen from the point of fault. In areas where the distribution system
fault level is already high, careful calculations will be required to ensure that the fault
ratings of existing switchgear and other equipment are not exceeded. If equipment ratings
are exceeded then additional impedance, in the form of transformers or reactors, may be
inserted in the connection to the generator, although this will increase voltage drops and
may influence adversely transient stability [11].

2.9.1 Generator Protection

Current-operated relays are required to protect comprehensively the EG (depending on the


capacity of the plant) including: Inverse Definite Minimum Time (IDMT) over-current,
instantaneous high-set over-current, voltage-restrained over-current, instantaneous- or
time-graded earth fault, differential protection and reverse power. Other generator
protection such as over-speed and vibration detectors must be installed to protect the plant
against mechanical failure together with devices that will detect winding, bearing, or
coolant over-temperatures [22].

2.9.2 Loss of Main Protection

Distribution networks are normally designed to supply passive loads. To enhance supply
reliability, it is common practice in the UK to provide auto-reclose circuit breakers. Should
a fault occur, the protection will open the breaker for a limited period, then close it again.
If the fault does not persist, supply will be restored. Otherwise the breaker will open again.
There may be several reclosure operations before the protection deems the fault to be
persistent.
The presence of EG in the utility network poses a problem for the auto-reclosure operation.
There is the probability of an out-of-phase reclosure, onto what may now be an active
network. To avoid this, the UK regulations for EG require the machine to be fitted with
Loss Of Main (LOM) protection. The aim is to ensure that, should the generator and its
load become isolated from the network as a result of fault clearance on the supply line, the
ensuing auto-reclosure operation will not result in an out-of-phase reclosure. The generator
should be disconnected to clear the way for safe auto-reclosure. It may then reconnected in
the usual way.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Embedded Generation 33

In practice an EG is seldom – if ever – likely to develop exactly the active power


demanded by the local load, and there will always be a net import (or export) of active
power from (or to) the grid. On remote disconnection of the grid and loss of the
synchronous reference supply, there is then a shortfall (or excess) of active power that
causes shaft speed and frequency to decrease (or increase) before the governor acts, if
possible, to maintain speed [27]. The standard technique for detection of LOM is to
measure the Rate-Of-Change Of Frequency (df/dt) called ROCOF, that results from the
load change of the loss of the grid connection. The basis of the method is that the island
supplied by the EG is unlikely to have a generation/demand balance. The rate setting is
typically 0.125 Hz/sec to minimise the risk of nuisance tripping caused by minor system
frequency variations [12].

2.9.3 G59/1 Protection

The nature and extent of protection specified by Engineering Recommendation G59/1 is


intended to protect the PES system and its connected consumers from the effect of the EG,
including: preventing connection of the EG to an unhealthy or faulted rural grid;
preventing EG from displacing voltage or frequency out with statutory limits and
preventing the EG from continuing to back-feed part of the grid in the event that a remote
fault had tripped the main grid supply. The minimum requirements of G59/1 include over-
and under-voltage relays set to operate within the absolute limits on voltage of ± 10% of
nominal 230 V (253-207 V), and over- and under-frequency relays to operate within
+1/-6% of nominal 50 Hz (50.5-47 Hz). While the recommended total tripping time is 0.5
seconds, increasing times may be agreed with the REC. Neutral voltage displacement
protection can be used to provide back-up to phase voltage failure and assist over-current
protection that might not be sensitive to an over-current or earth fault remote in the
distribution system. The above protection relays and LOM protection are voltage and
frequency operated [22].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 34

3 Power Flow and Absorbence

3.1 The Per-Unit System

In the analysis of power networks instead of using actual values or quantities it is usual to
express them as fractions of reference quantities, such as rated or full-load values. These
fractions are called per-unit (denoted by p.u.) and the p.u. value of any quantity is defined
as shown below.

the actual value [in any unit ]


the actual value [p.u.] =
the base or reference [in the same unit ]

Some authorities express the p.u. value as percentage. Although the use of p.u. values may
at first sight seem a rather indirect method of expression, there are in fact great advantages;
they are as follows [28]:

• The apparatus considered may vary widely in size; losses and volt drops will also
vary considerably. For apparatus of the same general type the p.u. volt drops and
losses are in the same order regardless of size.
• By the choice of appropriate voltage bases the solution of networks containing
several transformers is facilitated. Since 1.0 per-unit is the same at any level –
transformers may be represented by a single leakage reactance and no voltage ratio.
• Per-unit values lend themselves more readily to automatic computation.
• The use of 3 ’s in the three phase calculation is reduced.

For instance to a base of one minute, one second is 1/60 per-unit. To a base of one kilowatt
a 60 W light bulb is rated 0.06 p.u., and a 100 W bulb 0.1 p.u..
All of per-unit analysis rests on the correct and consistent choice of a common base, and
accurate conversion of circuit parameters into and out of that base. A minimum of four
base quantities is required to completely define a per-unit system, these are: voltage,
current, power and impedance. If two of them are set arbitrarily, then the other two are
automatically fixed. For circuit analysis a base apparent power [VA] is chosen, and 1.0 p.u.
voltage is prescribed throughout the circuit, so the base currents and base impedances are
fully defined and a per-unit computation may be carried out [23].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 35

Base apparent power [VA] S b = Base current [A] × Base voltage [V] = I b .Vb Equ. 3-1

Base voltage [V] Vb


Base impedance [Ω] Z base = = Equ. 3-2
Base current [A] I b

Actual impedance [Ω]


Per-unit impedance [p.u.] Z p.u . = Equ. 3-3
Base impedance [Ω]

Actual current [A]


Per-unit current [p.u.] I p.u . = Equ. 3-4
Base current [A]

Actual voltage [ V]
Per-unit voltage [p.u.] Vp.u. = Equ. 3-5
Base voltage [ V]

3.2 Reactive Power

The source of the simple circuit shown in Figure 3-1 is supplying active energy to the load
in one direction only. At the same time an interchange of reactive energy is taking place
between the source and the load of average value zero, but of peak value V.Isinφ. This
latter quantity is known as the reactive power Q and the unit is Volt-Ampere reactive
[VAr]. The interchange of energy between the source and the inductive and capacitive
elements of the load (i.e. the magnetic and electric fields) takes place at twice the supply
frequency. It is possible to think, therefore, of a power component P [Watt] of magnitude
V.Icosφ and a reactive-power component Q [VAr] equal to V.Isinφ, where φ is the phase
angle, i.e. the angle between I and V. It should be stressed, however, that the two quantities
P and Q are physically quite different.

I V

V Z=R+jωL φ I

φv φi
Figure 3-1: Voltage source and load; phasor diagram

The quantity S [VA], known as the complex power, may be found by multiplying V by the
complex conjugate of I or vice versa. The case when I lags V should be considered, and
S=V*.I assumed.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 36

Referring to Figure 3-1,

S = V * ⋅I = V ⋅ e − jφV × I ⋅ e jφi = V ⋅ I ⋅ e − j(φV −φi ) = V ⋅ I ⋅ e − jφ

S = P − jQ Equ. 3-6

Next assume
(φ V −φi )
S = V ⋅ I* = V ⋅ e jφV × I ⋅ e − jφi = V ⋅ I ⋅ e j = V ⋅ I ⋅ e jφ
S = P + jQ Equ. 3-7

Obviously both methods above give the correct magnitudes for P and Q but the sign of Q is
different. The method used is arbitrarily decided and the convention to be adopted in this
thesis is as follows:
The volt-ampere reactive absorbed by an inductive load shall be considered positive, and
by a capacitive load negative; hence S=V.I*. This convention is also recommended by the
International Electrotechnical Commission.
In a network the net energy is the sum of the various inductive and capacitive stored
energies present. The net value of reactive power is the sum of the VArs absorbed by the
various components present, taking due account of the sign. Lagging VArs can be
considered as either being produced or absorbed in a circuit; a capacitive load can be
though of as generating lagging VArs. Assuming that an inductive load is represented by
R+jX and that the V.I* convention is used then an inductive load absorbs positive or
lagging VArs and a capacitive load produces lagging VArs [28].
The magnitude of S, S = P 2 + Q 2 , is the apparent power. The apparent power gives a
direct indication of heating and is used as a rating unit of power equipment.

φ I S
Q
φi φ
φv
P
Figure 3-2: Phasor diagram and power triangle for an inductive load (lagging pf)

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 37

I V
P
φ
φ
Q
S
φv
φi

Figure 3-3: Phasor diagram and power triangle for a capacitive load (leading pf)

The reactive power Q is positive when the phase angle φ (φ = φv - φi) between voltage and
current is positive (i.e., when the load impedance is inductive, and I lags V) as shown in
Figure 3-2. Q is negative when φ is negative (i.e., when load impedance is capacitive and I
leads V) as shown in Figure 3-3 [17].

3.3 The Four-Terminal Network

A three-phase transmission line can be represented by a circuit consisting of two terminals


where power enters the circuit and two terminals where power leaves the circuit. The
circuit is said to be passive, linear and bilateral. It is passive because it contains no sources
of electric energy, linear because the impedances of its elements are independent of the
amount of current passing through them, and bilateral because the impedances are
independent of the direction of the current. The most general network consisting of a pair
of input terminals and a pair of output terminals has an impedance connected between each
combination of two of its four terminals and is called a four-terminal network. Any linear,
passive, and bilateral four-terminal network can be represented by either a T- or Π-circuit
which is equivalent to it in so far as measurements at the input or output terminals are
concerned. Such a T- or Π-circuit actually is a three-terminal network since one terminal is
common to both the sending- and receiving-ends.
To find the relationships between sending- and receiving- end quantities of a four-terminal
network, the voltage and current at the sending end of the unsymmetrical T-circuit of
Figure 3-4 in terms of the voltage and current at the receiving end must be determined,
since an unsymmetrical T is equivalent to the general four-terminal network for
measurements made at the ends of the network with the assumption that the network is
passive, linear and bilateral.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 38

IS IR
Z1 Z2

VS Y VR

Figure 3-4: Unsymmetrical T-circuit equivalent to a four terminal network

The current at the sending end is

I S = I R + Y ⋅ (VR + I R ⋅ Z 2 ) = Y ⋅ VR + (1 + Y ⋅ Z 2 ) ⋅ I R Equ. 3-8

The voltage at the sending end is

VS = VR + I R ⋅ Z 2 + I S ⋅ Z1 = VR + I R ⋅ Z 2 + Z1 ⋅ Y ⋅ VR + I R ⋅ Z1 + I R ⋅ Y ⋅ Z1 ⋅ Z 2

VS = (1 + Y ⋅ Z1 ) ⋅ VR + (Z1 + Z 2 + Y ⋅ Z1 ⋅ Z 2 ) ⋅ I R Equ. 3-9

The above equations are simplified in form by letting

A = 1 + Y ⋅ Z1 B = Z1 + Z 2 + Y ⋅ Z1 ⋅ Z 2

C=Y D = 1 + Y ⋅ Z2 Equ. 3-10

Then Equation 3-9 becomes

VS = A ⋅ VR + B ⋅ I R Equ. 3-11

and Equation 3-8 becomes

I S = C ⋅ VR + D ⋅ I R Equ. 3-12

The matrix-form of these equations is

⎡VS ⎤ ⎡A B ⎤ ⎡VR ⎤
⎢ I ⎥ = ⎢ C D⎥ ⎢ I ⎥ Equ. 3-13
⎣ S⎦ ⎣ ⎦⎣ R⎦

Since the unsymmetrical T-circuit is valid for measuring the end conditions of any passive,
linear, and bilateral four-terminal network Equation 3-13 is valid for any such network.
The constants A, B, C and D are called the generalized circuit constants or the ABCD-
constants of the network, and they can be evaluated for any such four-terminal network.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 39

Solving the Equation 3-13 for VR and IR and using the known relationship AD - BC = 1
[18], we obtain

⎡VR ⎤ ⎡ D − B⎤ ⎡VS ⎤
⎢ I ⎥ = ⎢− C A ⎥ ⎢ I ⎥ Equ. 3-14
⎣ R⎦ ⎣ ⎦⎣ S⎦

Usually the ABCD-constants are complex. An interpretation of each constant is found by


examination of Equations 3-11 and 3-12.
By letting IR equal zero in Equation 3-11, it is seen that the constant A is the ratio of
sending-end voltage to receiving-end voltage when the receiving end is open-circuited. The
constant A is dimensionless since it is a ratio of two voltages. Unless the voltages are in
phase, A is complex and its angle is the phase between the voltages.
If VR is equal zero in Equation 3-11, it is found that B is the ratio of voltage at the sending
end to current at the receiving end with the receiving end short-circuited. Since it is a ratio
of voltage to current, the constant B has the dimension of impedance and is specified in
ohms.
Similarly, by letting IR equal zero in Equation 3-12, it is seen that the constant C is the ratio
of current at the sending end to voltage at the receiving end with the receiving end open-
circuited. Since it is a ratio of current to voltage, the constant C has the dimension of
admittance and is specified in siemens.
If VR is equal zero in Equation 3-12, it is found that D is the ratio of sending-end current to
receiving-end current with the receiving end short-circuited. The constant D is
dimensionless since it is a ratio of two currents.

IS IR

VS A B C D VR

Figure 3-5: Symbolic diagram representing a four-terminal network

A general four-terminal network is often indicated by a diagram similar to Figure 3-5,


where a rectangle encloses the two pairs of terminals and letters symbolizing the
generalized circuit constants are placed inside the rectangle [18].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 40

3.4 The Short-Transmission Line

The classification of power transmission lines according to length depends upon what
approximations are justified in treating the parameters of the line. Resistance, inductance,
and capacitance are uniformly distributed along the line, and exact calculations of long
lines must recognize this fact. For short lines, the total capacitive susceptance is negligible
and may be omitted.
The parameters ABCD of a four-terminal network for a short-transmission line, as seen in
Figure 3-6, become

⎡A B ⎤ ⎡ 1 0⎤
⎢ C D⎥ = ⎢ Z = Z ∠θ 1 ⎥⎦
Equ. 3-15
⎣ ⎦ ⎣

3.4.1 Power Transfer of a Short-Transmission Line

The circuit shown in Figure 3-6 is very important as it represents the simplest electrical
model for a synchronous generator (VS) feeding into a power system represented by a
voltage source (VR). For this network the sign of power entering a boundary is assumed
positive and leaving a boundary negative.

I ∠-φ
Z ∠θ

SS VS ∠δS VR ∠δR SR

Figure 3-6: Power transfer of a short-transmission line

The determination of the voltages and currents in a network can obviously be achieved by
means of complex notation, but in power systems usually active power (P) and reactive
power (Q) are specified.
For the assumed direction of current

⎛ V − VR ⎞ ⎛ VS e jδS − VR e jδ R ⎞ VS j( δS −θ ) VR j(δ R −θ )
I = ⎜⎜ S ⎟⎟ = ⎜⎜ ⎟=
⎟ Z e − e Equ. 3-16
⎝ Z ⎠ ⎝ Ze jθ ⎠ Z

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 41

The complex power SS at the sending end is given by



∗ ⎛ V − VS ⎞ ⎛ V e − jδ R − VS e − jδS ⎞
SS = −V S ⋅ I = V S ⋅ ⎜⎜ R ⎟⎟ = VS e jδS ⋅ ⎜⎜ R ⎟

⎝ Z ⎠ ⎝ Ze − jθ ⎠

V ⋅V
2
V
S S = S R e j ( δ S − δ R + θ ) − S e jθ Equ. 3-17
Z Z

Thus, the real and reactive power at the sending end are

VS ⋅ VR
2
V
PS = Re (SS ) = ⋅ cos (δ S − δ R + θ) − S ⋅ cos (θ) Equ. 3-18
Z Z

V ⋅V
2
V
Q S = Im (SS ) = S R ⋅ sin (δ S − δ R + θ) − S ⋅ sin (θ) Equ. 3-19
Z Z

On the receiving end the complex power SR is given by



∗ ⎛ V − VR ⎞ ⎛ VS e − jδS − VR e − jδ R ⎞
S R = V R ⋅ I = V R ⋅ ⎜⎜ S ⎟⎟ = VR e jδ R ⋅ ⎜⎜ ⎟

⎝ Z ⎠ ⎝ Ze − jθ ⎠

V ⋅V
2
V
S R = R S e j ( δ R − δ S + θ ) − R e jθ Equ. 3-20
Z Z

The real and reactive power at the receiving end are

VR ⋅ VS
2
V
PR = Re (S R ) = ⋅ cos (δ R − δ S + θ) − R ⋅ cos (θ) Equ. 3-21
Z Z

V ⋅V
2
V
Q R = Im (S R ) = R S ⋅ sin (δ R − δ S + θ) − R ⋅ sin (θ) Equ. 3-22
Z Z

Power transmission lines have small resistance compared to the reactance. Assuming
R = 0, θ = 90 (i.e. Z = X∠90°) and δ = δ S − δ R , the above equations become

VS ⋅ VR
PS = − ⋅ sin (δ ) Equ. 3-23
X

V ⋅V
2
V
Q S = S R ⋅ cos (δ ) − S Equ. 3-24
X X

VR ⋅ VS
PR = ⋅ sin (δ ) Equ. 3-25
X

VR ⋅ VS
2
V
QR = ⋅ cos (δ ) − R Equ. 3-26
X X

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 42

Since R = 0, there are no transmission line losses and the real power sent equals the real
power received.
From the above results, for a typical power system with small R/X ratio, the following
important observations are made:

1. Equations 3-23 and 3-25 show that small changes in δS and δR will have a significant
effect in the real power flow, while small changes in voltage magnitudes will not have
appreciable effect on the real power flow. Therefore, the flow of real power on a
transmission line is governed mainly by the angle difference of the terminal voltages
(i.e., P12 ∝ sin δ), where δ = δS - δR. If VS leads VR , δ is positive and the real power
flows from the sending to the receiving end. If VS lags VR , δ is negative and the real
power flows from the receiving to the sending end.
2. Assuming R = 0, the theoretical maximum power (static transmission capacity) occurs
when δ = 90° and the maximum power transfer is given by

VS ⋅ VR
Pmax = Equ. 3-27
X

3. To maintain transient stability, the power system is usually operated with a small load
angle δ. Also, from Equations 3-24 and 3-26 it is seen that the reactive power flow is
determined by the magnitude difference of the two terminal voltages, (i.e.,
Q∝ VS − VR ).

4. For R = 0 and the assumed direction of current, voltage and power the sign of the
receiving-end real power PR and the receiving-end reactive power QR is as follows:

• PR is positive (PR enters the grid) for 0° < δ < 90°


• PR is negative (PR leaves the grid) for 0° > δ > -90°
• PR is zero for δ = 0°
• QR is negative (QR leaves the grid) for VS ≤ VR
• QR is negative (QR leaves the grid) for VS > VR and cos -1 (VR / VS ) < δ < 90°
• QR is positive (QR enters the grid) for VS > VR and
cos -1 (VR / VS ) > δ > − cos -1 (VR / VS )
• QR is zero for VS = VR and δ = 0°

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 43

3.4.2 The Circle Diagram for Z = X (R = 0)

The operating conditions of a transmission circuit can be expressed in terms of many


different quantities. There are, for example, the terminal voltages VS and VR, the currents
IS and IR, the active powers PS and PR, the reactive powers QS and QR; there are also the
power losses PL, and the load angle δ between the terminal voltages. If any three of these
quantities are known, all the remainder may be determined [21].
A graphical analysis of the variation of the voltage, current, or power of a circuit, when
some parameters or the circuit are changing, not only saves a great deal of time when the
number of points to be calculated is great, but also serves to explain some of the results
obtained. The locus of the end points of a phasor of voltage or current some place in a
circuit is very often a circle when some parameters of the circuit are varied. Thus circles
can often be plotted on a set of rectangular coordinates to show the variation of some
quantity in a circuit in response to the variation of some other quantity. Such circle
diagrams are very helpful in the design and operation of power systems.
As an introduction to the study of circle diagrams of a power circuit, the equivalent circuit
of a short-transmission line, as shown in Figure 3-6, should be considered. It will be shown
that for R = 0 (Z = X) and VR = constant the circle diagram is exactly the same as for the
synchronous machine. The phasor diagram shown in Figure 3-7 is for the assumptions of
Z = X, δ positive, φ positive and VS > VR.

Icosφ.jX
φ

Isinφ.jX
I.jX

VR
VS

Isinφ
I
δ
φ

Icosφ

Figure 3-7: Phasor diagram of a synchronous machine and a short-transmission line with R = 0
respectively

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 44

The current I may be separated into real and reactive power (in- and out-of phase)
components I cos φ and I sin φ . These components may be considered to induce separate
stator voltage drops I cos φ ⋅ jX and I sin φ ⋅ jX , as shown in Figure 3-7. This resolution is
also consistent with resolving the short sides of the triangle in which I ⋅ jX is hypotenuse.
From the triangle containing VS as hypotenuse the following voltage relationships emerge

VS sin (δ ) = I cos(φ) ⋅ X

VS sin (δ )
I cos(φ ) = Equ. 3-28
X

VS cos(δ ) = VR + I sin (φ) ⋅ X

VS cos(δ ) − VR
I sin (φ ) = Equ. 3-29
X

Multiplying each of the above active and reactive components of current by voltage gives
the real and reactive electrical powers in terms of equivalent circuit parameters:

VR ⋅ VS
PR = VR ⋅ I cos(φ ) = ⋅ sin (δ ) Equ. 3-30
X

VR ⋅ VS
2
V
Q R = VR ⋅ I sin (φ) = ⋅ cos (δ ) − R Equ. 3-31
X X

The x-direction of the phasor diagram VS.sin(δ) represents real power, and the y-direction
of the phasor diagram VS.cos(δ)-VR represents reactive power. The voltage phasor diagram
may be superimposed on the P-Q coordinate system to create the operating chart, provided
that a common means of scaling the respective axes can be established. The origin of the
P-Q plane must be located on the tip of VR such that δ = 0° and φ = 90° corresponds to
zero power. To align the two graphical representations a common scale must be found
which equates distance on a voltage plane with distance on a P-Q plane.
Since

VR ⋅ VS
PR = ⋅ sin (δ ) Equ. 3-32
X

when the system is operating at maximum power P = 1.0 p.u., VR = 1.0 p.u., and since
sin δ = 1. From these conditions

VS (p.u.) = X (p.u.) Equ. 3-33

This equation defines the relationship between the scales in the voltage phasor diagram and
the P-Q plane.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 45

Q [p.u.]
1.0

0.8

0.6
st.
f =con
p
0.4
S=
con
st V
S3 =c
0.2 on
st. (
V
VS S3 >V
P [p.u.] φ )
R

1.0 0.8 0.6 0.4 0.2 VR -0.2 -0.4 -0.6 -0.8 -1.0
V
S2 =c
0.8 on
st.

(V
S2
=V
0.6

R
)
VS

0.4
1
=c
o
ns
t.(
V S1

δpositive 0.2 δnegative


<V R
)

1.25 1.0 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1.0

Figure 3-8: Circle diagram for VR = constant and X = 1.25 p.u. (R = 0 p.u.)

Figure 3-8 shows the operating chart for a short-transmission line with the receiving-end
voltage VR = constant, the sending-end voltage VS = variable, the resistance R = 0 p.u. and
the inductive reactance X = 1.25 p.u.. This circle diagram is exactly the same as for the
synchronous machine. Rotating VS round ± 90° from VR (which defines 1.0 p.u. voltage)
to the horizontal sets the voltage scales. In this position setting VS = 1.25 p.u. defines
maximum (1 p.u.) power. Projecting lines up from VS = 1.25 p.u. till they cross the P axis
(drawn on the tip of VR) defines ± 1 p.u. power and the scale for the P and Q axes. The
framework of the diagram is complete. At any operating point P,Q in the plane the per-unit
values of P and Q now define VS and δ. Per-unit changes in VS and δ also define new P
and Q and power factors. The diagram also shows constant sending-end voltage circles
(VS1 < VR, VS2 = VR, VS3 > VR), a constant power circle (S = const.) and a constant power
factor line (pf = const.) [23].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 46

3.4.3 The Receiving-End Power Circle Diagram of a Short-


Transmission Line

At the next stage the equivalent circuit of a short-transmission line represented by a series
impedance Z = R + jX between the sending and receiving ends of the circuit is considered,
as shown in Figure 3-6. Figure 3-9 is the phasor diagram of the circuit and shows the
sending-end voltage VR, which is the reference, and the voltage drops in the resistance and
inductive reactance of the line, I.R and I.jX, respectively.

VS
I.Ζ
I.jX
δ VR
φ I.cosφ
I.R
I.sinφ

Figure 3-9: Phasor diagram of a short-transmission line

For these assumptions it is also possible to draw a diagram with its coordinates real power
on the horizontal axis and reactive power on the vertical axis. Each load at the receiving
end is represented on the chart by a point determined by the real and reactive power of the
load. This circle diagram is developed from the phasor diagram shown in Figure 3-10.

VS
I.Ζ

n δ VR θ−φ
φ O

θ
I
Figure 3-10: Phasor diagram of a two-sources network

All the phasors except the current I on the diagram of Figure 3-10 are voltages. Since a
diagram of real and reactive power is desired, all the quantities must be multiplied by
current, and since power at the receiving end of the network should be obtained, it is

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 47

obvious to choose VR/Z as the multiplier. VR/Z has the dimensions of current, and the
product of the voltage I.Z and the current VR/Z is VR.I, the volt-amperes at the receiving-
end of the network.
VR is the reference phasor in Figure 3-10 and its phase angle is chosen at zero degree. The
phasor VR/Z is displaced from the reference phasor by the angle -θ, since

VR ∠0° VR VR
= ∠−θ = ⋅ e − jθ Equ. 3-34
Z ∠θ Z Z

Therefore, multiplication of the phasor of voltage on the diagram of Figure 3-10 by VR/Z
shifts all the phasors, and the whole diagram, through the angle -θ. The result is the power
diagram of Figure 3-11.

reactive
power

θ−δ

2
VR VSVR
Z Z

θ real power
O φ

VRI
k

Figure 3-11: Receiving-end power diagram

For convenience, the origin of the coordinate system is placed at point O in the new
diagram. Now VR.I lies at an angle -φ, or at an angle φ below the horizontal. Since VR.I
intersects the horizontal axis at the origin at the angle by which the current lags the
voltage, the horizontal component of VR.I is real power, and the vertical component is
reactive power. The coordinate axes may be marked in watts and VArs.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 48

In constructing Figure 3-11, current was taken as lagging the voltage at the load. Thus, the
load is inductive, and on the diagram the VArs drawn by an inductive load, or flowing into
an inductive load, are negative. In order to conform to the convention adopted in
Chapter 3.2 (a positive sign indicates the lagging VArs taken by an inductive load), the
diagram will rotate. The required alteration is the interchanging of points below and above
the horizontal axis by rotating the whole diagram about the horizontal axis. To use the
same direction of the P-axis as for the circle diagram of a synchronous machine
(Figure 3-8), it is also necessary to change +P and –P by rotating the diagram on the
vertical axis. Figure 3-12 is the result. Now the left side of the nO-line in the picture
indicates positive load angle (+δ) and the right side negative load angle (-δ).

+Q

k
|VR|.|I|

+P φ O -P
θ d

|VS|.|VR|
|Z | |VR |
2

|Z |

δ
δpositive δnegative

θ−δ
n
c
-Q
Figure 3-12: Receiving-end power diagram after rotation

Distances on Figure 3-12 are marked only as magnitudes since they do not have the same
angular relation with the horizontal reference axis as the corresponding distances of
Figure 3-11.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 49

Now some points on the power diagram of Figure 3-12 for various loads should be
determined, with fixed values of VS and VR . First it is noticed that the point n is not

dependent on the current and will not change as long as VR and Z ∠θ is constant. If VR

and Z is constant and the angle θ = arctan (X R ) is changing, then the point n will move
around a circle with the centre O between the points c and d. The point c indicates θ = 90°,
which means R = 0 and the receiving-end power diagram is the same as the circle diagram
for a synchronous machine developed in Chapter 3.4.1 (Figure 3-8). The point d indicates
θ = 0°, which means X = 0. It is noted further that the distance from point n to point k is
constant for fixed values of VS , VR and Z . Therefore, as the distance from O to k
changes with changing load, the point k, since it must remain at a constant distance from
the fixed point n, is constrained to move in a circle whose centre is at n. Thus all the points
representing loads on a network with fixed values of VS , VR and Z lie on the circle
determined by the values of the fixed voltages and the fixed impedance. If a different
voltage of VS is held constant with the same value for VR , the location of point n is
unchanged, but a new circle of radius nk is found.
Z from the origin at an angle of θ with
2
The point n may be located by measuring VR
the horizontal. Greater accuracy is obtained if the point n is located by computing its
horizontal and vertical coordinates. Examination of Figure 3-12 shows, for the receiving-
end diagram,

VS ⋅ VR
Radius of a receiving − end circle [VA ] = Equ. 3-35
Z

Coordinates of the centre of a receiving-end circle (point n):


2
VR
Horizontal [ watts] = − ⋅ cos(θ) Equ. 3-36
Z

2
VR
Vertical [VArs] = − ⋅ sin(θ) Equ. 3-37
Z

If the voltages used in the equations above are line-to-line voltages then the coordinates of
the power diagram are three-phase quantities. If line-to-neutral voltages are used, the
coordinates of the power diagram are per-phase quantities.

The angle δ between the sending- and the receiving-end voltages is called the load angle.
As the load changes, the load angle changes. On the power diagram the load angle δ is
Z and VS ⋅ VR Z .
2
measured between the line VR

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 50

If the receiving-end voltage is held constant and receiving-end circles are drawn for
different values of sending-end voltages, the resulting circles are concentric because the
location of the centre of the receiving-end power circles is independent of the sending-end
voltage. A family of receiving-end circles is shown in Figure 3-13. The radial lines cutting
the circles are spaced at 10° intervals so that the load angle can be read for any load. The
load line marked in Figure 3-13 is convenient if the load changes in magnitude while its
power factor remains constant. The angle between the load line through the origin and the
horizontal axis is the phase angle (between IR and UR) whose cosine is the power factor of
the load.

+Q
-20° -30°

angl
e -10° |VS1|
d
loa

|VS2|
l oa d 0 °
l i ne +1 |VS3|

|VS4|

φ
+2

O
+P -P

θ
+3
°
+40

|VR|=constant

n
-Q

Figure 3-13: Receiving-end power circle diagram for ⎟VR⎟ = constant and ⎟VS⎟ = variable

If the sending-end voltage is fixed, the receiving-end power circles for different receiving-
end voltages are not concentric. The equations 3-35 to 3-37 show that the centres of the
circles are at different points for each value of VR , but the centres all lie on the same line

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 51

through the origin. The radii of the circles change also as VR changes [18]. In the same
way as developing the receiving-end power circle diagram it is also possible to construct
the sending-end power circle diagram which is not shown in this thesis.

3.4.4 The Universal Power Circle Diagram of a Short-Transmission


Line

The power circle diagram described has several limitations, the most serious of which is
that, although a series of concentric receiving-end circles can be drawn for a number of
sending-end voltages, the resulting chart is valid for only the one receiving-end voltage for
which it is constructed. If several receiving-end voltages are to be investigated a new
receiving-end chart must be constructed for each new receiving-end voltage. If the latter
course is followed, the resulting circles are not concentric for the receiving-end chart, and
the load-angle lines are drawn from different centres for each circle. This limitation of the
power circle diagram can be overcome by a modification of the coordinate system [7].
To take full advantage of the method, each distance on the modified circle diagram must be
expressed as a ratio of the distance on the original diagram in volt-amperes to a selected
2
reference or base value of volt-ampere equal to V Z , where Z is the impedance of the
circuit and V is called the reference or base voltage and is chosen arbitrarily. Usually V
is the nominal line-to-neutral or line-to-line voltage of the system depending on whether
the coordinates of the power diagram being modified are per-phase or three-phase
quantities. Dimensionless units result from the division of the quantities on the original
2
diagram by V Z . The resulting quantities VR V and VS V are ratios of actual
voltage to the chosen base and are called per-unit receiving- and per-unit sending-end
voltages. If it is considered that VS and VR specify voltages in per-unit rather than in
volts, the Equations 3-35 to 3-37 become

Radius of a receiving − end circle [p.u.] = VS ⋅ VR Equ. 3-38

Coordinates of the centre of a receiving-end circle:

Horizontal [p.u.] = − VR ⋅ cos(θ)


2
Equ. 3-39

Vertical [p.u.] = − VR ⋅ sin(θ)


2
Equ. 3-40

Figure 3-14 shows the scaling of a universal power circle diagram with the reference
voltage V = VR = 1 p.u. , the base volt-ampere VR Z = 1 p.u. and the sending-end
2

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 52

voltage VS rotating round ± 90° from VR. It is noticed that the P/Q- and the V-axis use the
same scale in per-unit but a different origin of the axes. The point n, which is the origin of
the V-axis, rotates for a changing angle θ on a circle with the centre OR, as explained in the
previous chapter. The reason for the same scaling of both axes is the new volt-ampere base
Z = 1 p.u. . The diagram also shows three constant sending-end voltage circles
2
VR
(VS1 = 1.0 p.u., VS2 = 1.3 p.u., VS3 = 1.6 p.u.), a constant power circle (S = const.) and a
constant power factor line (pf = const.). Now it is possible to use this circle diagram in the
same way as the circle diagram of a synchronous machine.

Q [p.u.]
1.0
VS3 =
1.6 p
.u.=c
0.8 onst.

pf= 0.6 VS =
co 2 1
.3
nst p.u.
. = co n
st .
0.4
V [p.u.]
S= 1.0 V
con S1 =1
.0 p
0.2 st .u.=
co n
st
P [p.u.] 0.8
OR
1.0 0.8 0.6 0.4 0.2 θ
0.6 δ=-90°

|VR |
2
ve
ati
δ neg 0.4
e
tiv
osi
δp

0.2

V [p.u.]
1.0 0.8 0.6 0.4 0.2 n

δ=+90°

Figure 3-14: Scaling of the universal power circle diagram of a short-transmission line

If a receiving-end circle diagram according to the equations above for various per-unit
values of VS and a specified value of VR is constructed, the concentric circles shown in

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 53

Figure 3-15 with their centres at n and the origin of the coordinate system at OR are
obtained.
If a larger value of VR is chosen and circles for the same values of VS ⋅ VR are drawn, a
new family of concentric circles having the same radii as those shown in Figure 3-15 and
the same origin OR are obtained. The new circles must be drawn from a different centre
such as n’, as determined by the Equations 3-38 to 3-40 for the new value of VR . The
centre n’ lies on the same line through OR as the point n. Thus far this diagram is identical
to the original diagram discussed except for the use of per-unit quantities.

+Q [p.u.]

O’R
OR
+P [p.u.] θ -P [p.u.]

n
-Q [p.u.] n’

Figure 3-15: Universal power circle diagram of a short-transmission line

If the new set of circles with centres at n’ are drawn and the new diagram along the line
nOR is moved so that n and n’ coincide without the diagram being rotated, both families of
circles coincide.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 54

The origin from which power measurements are made for the new value of VR is shifted
to O’R on the extension of the line nOR. The distance from the centre n to the origin is the
square root of the sum of the squares of the horizontal and vertical coordinates given in
Equations 3-39 and 3-40, which is
2
Distance n to OR [p.u.] = VR Equ. 3-41

The method can now be extended to any number of values of receiving-end voltages.
Measurement of power are made from a different origin for each value of VR . Positive
real power is read to the left of OR, positive reactive power is read upward from OR. Per-
2
unit values measured on the diagram and multiplied by V Z give the three phase real

and reactive power respectively if V is the line-to-line base voltage from which the per-
unit voltages are determined [18].

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 55

3.5 The Long-Transmission Line

3.5.1 Transmission Line Constants

The exact solution of any transmission line and the one required for a high degree of
accuracy must consider the fact that the parameters of the line are not lumped but are
distributed uniformly throughout the length of the line. For this assumptions and for an
equivalent Π-circuit the ABCD constants of long-transmission lines involve hyperbolic
functions. These are [18]:

⎡ ⎤
⎢ cosh (γ ⋅ l ) Z C ⋅ sinh (γ ⋅ l ) ∠θ C ⎥
⎡A B ⎤ ⎢ ⎥
⎢ C D⎥ = ⎢ ⎥ Equ. 3-42
⎣ ⎦ ⎢ sinh (γ ⋅ l ) ⎥
⎢ ∠ − θC cosh (γ ⋅ l ) ⎥
⎣⎢ Z C ⎦⎥

The term Z C = Z C ∠θ C = z y and is called the characteristic impedance of the line,

γ = y ⋅ z and is called the propagation constant. The term z = Z l and y = Y l , where

Z is the total series impedance per phase of the line, Y is the total shunt impedance per
phase to neutral and l is the length of the line [18].
Povejsil and Johnson [26] have published a method of obtaining simpler equations. This
method is based on the fact that the product of L and C is practically constant for overhead
lines of stranded copper or Aluminium Conductor Steel Reinforcement (ACSR). Only the
length of the line and the ratio of series resistance to inductive reactance need to be known
to calculate the values for the ABCD constants.

If the product LC is identical for all lines, γl at a given frequency is a function only of R/X
and the length of the line l, where R is the resistance of the line in ohms per mile and X is
the inductive reactance of the line in ohms per mile, since

γ ⋅l = y⋅z ⋅l Equ. 3-43

and in terms of L and C

γ ⋅l = (R + jωL ) ⋅ jωC ⋅ l = ω 2 LC ⋅ − 1 + j
R
⋅l
ωL
R
γ ⋅ l = ω 2 LC ⋅ − 1 + j ⋅l Equ. 3-44
X

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 56

which is a function only of R/X and l, if LC is constant for all lines.


Povejsil and Johnson pointed out that an examination of a considerable number of lines
showed that the factor ω 2 ⋅ L ⋅ C was always between 2.05×10-3 and 2.07×10-3 for 60-
cycle overhead lines of stranded copper and ACSR.
If the Equations 3-42 are solved for the assumptions above and if the ABCD constants are
expressed in per-unit of Z C , they become [18]:

⎛ R⎞
A [p.u.] = cosh⎜⎜ 2.06 ⋅ 10 −3 ⋅ l ⋅ − 1 + j ⎟⎟
⎝ X⎠

⎡ ⎛ R ⎞⎤
B [p.u.] = ⎢sinh ⎜⎜ 2.06 ⋅ 10 −3 ⋅ l ⋅ − 1 + j ⎟⎟⎥ ∠θ C Equ. 3-45
⎢⎣ ⎝ X ⎠⎥⎦

⎡ ⎛ R ⎞⎤
C [p.u.] = ⎢sinh⎜⎜ 2.06 ⋅ 10 −3 ⋅ l ⋅ − 1 + j ⎟⎟⎥ ∠ − θ C
⎣⎢ ⎝ X ⎠⎥⎦
D [p.u.] = A

The angle θ C associated with the characteristic impedance is also a function of R/X, since

z R + jωL
ZC = = Equ. 3-46
y jω C

tan −1 (ωL R ) − 90
ZC = ZC ∠ Equ. 3-47
2

and

1 ⎛R⎞
θ C = − ⋅ tan −1 ⎜ ⎟ Equ. 3-48
2 ⎝X⎠

With θ C expressed in terms of R/X, the ABCD constants in per-unit given in


Equations 3-45 are functions only of the ratio R/X and the length of the line l.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 57

3.5.2 The Receiving-End Power Circle Diagram of a Long-


Transmission Line

The basics of circle diagrams were already explained in Chapter 3.4.2. The next stage is to
develop the power circle diagram for a long-transmission line and to determine the
differences between the short- and the long-transmission line diagram.
In order to draw the phasor diagram, the two constants A and B should be:

A = A ∠α

B = B ∠θ C Equ. 3-49

The constant C is not required in the development of circle diagrams, and D is only for
diagrams drawn in terms of sending-end power. Figure 3-16 is the phasor diagram of a
four-terminal network with the receiving-end voltage VR as reference. The phasor AVR
leads VR by the angle α. If the current IR is lagging VR by an angle φR the phasor BIR leads
VR by the angle (θC - φR). The sending-end voltage VS is the sum of AVR and BIR.

VS
BIR

AVR θC−φR
δ
n α O
φR VR

θC

IR
Figure 3-16: Phasor diagram of a four-terminal network

Since a diagram of real and reactive power is desired, it is necessary to multiply all the
quantities by current. The multiplier will be VR/B, which has the dimension of current.
This results, similar to the diagram of a short-transmission line, in a displacement from the
reference phasor VR by the angle -θC, since

VR ∠0° VR VR
= ∠ − θC = ⋅ e − jθ C Equ. 3-50
B ∠θ C B B

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 58

In order to conform to the convention adopted in Chapter 3.2 the diagram will rotate on the
horizontal and the vertical axis. The result is shown in Figure 3-17.

+Q

k
|VR2|
|VR|.|IR|
|Β|
+P φR O -P
θC d

θC-α
|VS|.|VR|
|Β| |Α|.|VR2|
|Β|

θC−δ
n
c

-Q
Figure 3-17: Receiving-end power diagram of a long-transmission line

The point n may be located by measuring A ⋅ VR


2
B from the origin at an angle of
(θC - α) with the horizontal. Greater accuracy is obtained if the point n is located by
computing its horizontal and vertical coordinates. Examination of Figure 3-17 shows, for
the receiving-end diagram,

VS ⋅ VR
Radius of a receiving − end circle [VA] = Equ. 3-51
B

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 59

Coordinates of the centre of a receiving-end circle:

A
Horizontal [ watts] = − ⋅ VR ⋅ cos(θ C − α)
2
Equ. 3-52
B

A
Vertical [VArs] = − ⋅ VR ⋅ sin(θ C − α)
2
Equ. 3-53
B

To determine P and Q the following equations, as seen in Figure 3-17, can be used:

A ⋅ VR
2
VS ⋅ VR
PR = cos(θ C − δ ) − cos(θ C − α ) Equ. 3-54
B B

A ⋅ VR
2
VS ⋅ VR
QR = sin (θ C − δ ) − sin (θ C − α ) Equ. 3-55
B B

The differences between the circle diagram of a long-transmission line and a short-
transmission line are as followed:

• The four-terminal network constant B and its angle θC is used instead of the
impedance Z and its angle θ.

• A long-transmission line has a new phasor labelled AVR. This phasor leads the
reference voltage VR by the angle α. The complex addition of this phasor and the
phasor BIR results in the sending-end voltage VS.

3.5.3 The Universal Power Circle Diagram of a Long-Transmission


Line

In this case dimensionless units result from the division of the quantities on the original
2 2
diagram by the reference base V B instead of V Z , where B is the generalized

circuit constant and V is the reference voltage and is chosen arbitrarily. If it is considered

that VS and VR already specify voltages in per unit, the following formulas are obtained:

Radius of a receiving − end circle [p.u.] = VS ⋅ VR Equ. 3-56

Coordinates of the centre of a receiving-end circle:

Horizontal [p.u.] = − A ⋅ VR ⋅ cos(θ C − α)


2
Equ. 3-57

Vertical [p.u.] = − A ⋅ VR ⋅ sin(θ C − α)


2
Equ. 3-58

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 60

Figure 3-18 shows the scaling of a universal power circle diagram for a long-transmission

line with the reference voltage V = VR = 1 p.u. , the base volt-ampere VR B = 1 p.u.
2

and the sending-end voltage VS rotating round ± 90° from VR.

Q [p.u.]
1.0

0.8
VS =
1.3
p .u.=
0.6 con
st.

V [p.u.]
VS =
0.4 1.0 VR =
1.0
p .u.=
c ons
VS = t.
0.85
|VR |
2 p.u.
0.2 0.8 = con
s t.
δ=-90°
P [p.u.] OR
0.6
1.0 0.8 0.6 0.4 0.2 θC
θC-α
0.4

|Α|.|VR |
2
0.2

V [p.u.]
1.0 0.8 0.6 0.4 0.2 n

δ=+90°

Figure 3-18: Scaling of the universal power circle diagram of a long-transmission line

The distance from the centre n to the origin is the square root of the sum of the squares of
the horizontal and vertical coordinates given in Equations 3-57 and 3-58, which is

Distance n to OR [p.u.] = A ⋅ VR
2
Equ. 3-59

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 61

3.6 The Use of Power Circle Diagrams

Once the circle diagrams have been drawn for a transmission line or any four-terminal
network, a great deal of information can be obtained very quickly. Some useful
information is the voltage that must be maintained at the sending end for a specified load
and voltage at the receiving end. It is assumed that Figure 3-19 is the receiving-end power
diagram for the value of VR which must be maintained at the load or at the primary
terminals of a transformer supplying the load. If the load varies in amount while its power
factor remains the same, a load line is drawn through the origin at an angle with the
horizontal axis equal to the phase angle of the load. The horizontal coordinate of the point
where the load line intersects a circle of constant sending-end voltage is the power at the
load for the sending-end voltage of the circle intersected. In this manner information for
plotting sending-end voltage versus power at the load for a given load voltage and power
factor is obtained rapidly.

+Q
-20°
ang
le -1 0 °
d
loa

|VS1|
l oa d °
l i ne 10
|VS2|
°

φ
20

b O
+P -P
θ

|VR|=const.

-Q n

Figure 3-19: The use of the power circle diagrams

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 62

Another problem readily solved with the circle diagram is the determination of the amount
of reactive power that must be supplied by synchronous condensers at a load in order to
increase the power factor, to reduce the amount of voltage regulation, or to maintain
constant voltage at the receiving end for a given sending-end voltage. For instance, the
circle diagram of Figure 3-19 may represent the conditions on a transmission line whose
receiving-end voltage is to remain constant at the value for which the diagram is drawn,
and it may be desirable to operate the line at unity power factor. If the coordinates of the
point a on the load line are the kW and kVArs of the load, the inductive kVArs of the load
represented by the vertical line ab must be supplied by a synchronous condenser or static
capacitors. The line supplies only the real power represented by Ob, and the voltage at the
sending end must be slightly greater than VS2 .

Both the sending-end and receiving-end circle diagrams may be needed for the solution of
a problem. For instance, both diagrams are needed to find the sending-end power for a
given receiving-end load. If the load and load voltage are known and the receiving-end
power diagram is available for this load voltage, the voltage at the sending end and the
torque angle may be read. Then, on a sending-end diagram drawn for the sending-end
voltage found from the receiving-end diagram, the sending-end power may be read at the
same torque angle and receiving-end voltage. This is an example of an torque angle
measured from the reference line of a diagram being required to find corresponding points
on the two diagrams [18].

3.7 Comparison between Long- and Short-Transmission


Lines

In the previous chapters the construction of power circle diagrams of long- and short-
transmission lines were explained. This chapter examines the differences in results
between these models.
Figure 3-20 shows the absolute percentage difference for the receiving-end power
calculation of a short-transmission line model compared with the accurate values of a long-
transmission line model in four cases. In these cases the values of the sending-end voltage,
the load angle and the R/X-ratio of the line are varied. The calculations use the formulas
and four-terminal network constants A, B, C and D developed in Chapter 3.4 and 3.5.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Power Flow and Absorbence 63

Figure 3-20: Absolute percentage difference of a short-transmission line model compared with a long-
transmission line model

All four cases show that the percentage error of a short-transmission line model for the
receiving-end power calculation for a line shorter than 100 miles is below one percent and
a line shorter than 200 miles below three percent. For longer distances the error increases
rapidly.
As the distance for the connection of EGs to the grid will always be under 100 miles, the
percentage error will always be smaller than one percent. Therefore, the simulation
package for universal power circle diagrams of EGs in the next chapter is developed for
the short-transmission line model. This circle diagram has the advantages of being easier to
calculate and to draw than the long-transmission one.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 64

4 Development of Simulation Package

4.1 The Programming Language

The basic code for this simulation is written in the C++ programming language, which is
an offspring of the C high level language. With Windows now being the standard PC
operating system, C++ is a standard Windows application development language.
The key concept in C++ is the class. Classes provide data hiding, guaranteed initialisation
of data, implicit type conversion of user-defined types, user-controlled memory
management, dynamic typing, and mechanisms for overloading parameters [20].
The software developed in this thesis does not take advantage of all the resources that C++
can offer, as the basic task of this program is to automate the drawing of circle diagrams on
a computer screen. Therefore the program uses C++ graphic utilities rather than complex
C++ structures.

4.2 The Microsoft Visual C++ Environment

Successful software, in addition to performing its basic function, should be user friendly.
This is one of the reasons why the software utilised in the environment of the Microsoft
Visual C++ Version 6.0 programming language instead of a command prompt based
environment such as DOS.
A fundamental feature of the windows environment is multi-tasking which is the ability for
several applications to run simultaneously. When an application is running, an application
window is visible which acts as the user interface, all the other functionality is hidden from
the view.
Another important feature is that windows programs are device independent. This means
that, instead of setting up the device parameter for each program individually, the windows
interface supplies an uniform set of instructions for interfacing with the necessary devices.
This makes it easier to change device parameters and use applications on different
computers as there is no need for device information to be programmed individually.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 65

There are several different parts of a windows application that must be integrated. This is
carried out by using a so called ‘Workspace’. This ‘Workspace’ brings together all the
necessary parts of the written programme:

• Header files
The header files include declarations for the functions, variables and library header
files. These files have the extension ‘.h’.

• Source files
The source files include the different functions which are required in the program.
These functions can be split into several different files to make them easier to handle.
All source files have the extension ‘.cpp’.

• Resource files
The resource files contain the code used to create the graphics windows that form the
user interface. These files are developed through the resource editor and are given the
extension ‘.rc’.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 66

4.3 Flow Chart of ‘Universal Power Circle Diagram’ (UPCD)

Once all of the information required by UPCD has been entered by the user, or is loaded
from an existing file, the program calculates the base power and base voltage. After the
diagram has been drawn, the user has the choice between different features of the program.
This is shown in the flow chart of Figure 4-1.

Start
Data input

Open existing file New file

Select file Keyboard input

Calculation of
base-power and
base-voltage

Calculation of the
values for the
current mouse-
position
New
output
values Draw graphics
and
output text-values
Draw power-
factor or
 power-circle

 Recalculate
Redraw
 Save data

Zoom

End program

End

Figure 4-1: Flow chart of UPCD

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 67

4.4 Starting UPCD

One of the advantages of Microsoft Visual C++ is that it automatically creates an


‘executable’ of the program. This file includes all the resources necessary to run as an
independent Windows application. The executable of this program, the Microsoft Visual
C++ source code and the Word file of this thesis is located on the compact disk included
with the thesis.

Figure 4-2: The UPCD icon

UPCD will start automatically after the compact disc is put into the compact disc drive or
by positioning the mouse pointer over the UPCD-icon and double-clicking the left mouse
button. The icon of the ‘executable’ file is shown in Figure 4-2. The software has been
written so that at any point during operation it is possible to exit from UPCD.

4.5 The Main Menu Screen

With a windows application the usual format is a main window displaying results and
containing a menu-bar from which various commands can be activated. In this program a
Single Document Interface (SDI) is used, which allows only one open ‘document frame
window’ at any time. This main window and one drop-down menu is shown in Figure 4-3.

Figure 4-3: The main window and one drop down menu

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 68

The user-interface mechanism is common to most Windows applications. That is, each
application window contains an icon on the corner to minimize, maximise or close the
window. Other icons include ‘New Document’, ‘Open File’, ‘Save File’, ‘About‘ dialog
box and an icon called ‘Start’ to run UPCD. All of these commands are also available in
the pop-up menus which are explained in the chapters following.
The main frame has five additional buttons: ‘Zoom In’, ‘Zoom Out’, ‘Constant Receiving
Power Circle’, ‘Constant Power Factor’ and ‘Print Screen’. Each of these buttons opens a
dialog box which are also described in the next chapters.
Further, the main window contains a vertical and a horizontal scroll bar and the mouse
being used in a similar manner as in any other windows application.

4.5.1 The ‘File’ Menu

Below are listed the options on the drop-down menu ‘File’:

• New
This option deletes all the data present. The screen will be cleared and the emblem of
the University of Edinburgh will be shown.

• Open
This option opens a dialog box and allows the user to choose and open an already
existing file with the extension ‘.cir’.

• Save
If the current document already has a name, this option will save all values without
opening a dialog box. For an untitled document the procedure will be the same as for
the ‘Save As’ option in this menu.

• Save As
If the data is to be used again, it must be saved. Upon saving data, the user will
encounter a dialog box. It allows the user to select a directory and enter a name for
the file which has the predefined extension ‘.cir’.

• Exit
This option is used to quit the program. If not previously saved, the current data will
be lost.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 69

4.5.2 The ‘View’ Menu

The options listed in the drop-down menu ‘View’ are:

• Toolbar
The user can hide or show the toolbar by clicking on this icon.

• Status Bar
The user can hide or show the status bar by clicking on this icon.

4.5.3 The ‘Start’ Menu

The only option in this menu is ‘Run UPCD’. This option starts the program by opening
the System Parameters dialog box as shown in Figure 4-4.

Figure 4-4: The System Parameters dialog box

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 70

There are five areas within this dialog box:


1. Grid and base voltage: The user must enter the voltage of the grid in kilovolts.
Depending on whether the nominal line-to-neutral or line-to-line voltage is entered
the coordinates of the power diagram are per-phase or three-phase quantities. This
voltage entered is automatically the base voltage for the per-unit calculations.
Only one of the next four areas can be selected at any time, depending on the data
available. This is achieved by clicking on the radio button on the left hand side of each
section:
2. Resistance and inductive reactance in ohms.
3. Impedance and its angle in ohms and degrees respectively.
4. Prospective short circuit current in amperes and the X/R ratio.
5. System fault level in mega volt-amperes and the X/R ratio.
When a number is entered in one of these edit boxes, all the other values are automatically
calculated and updated. The number entered is additionally checked for errors.
Pressing the OK-button confirms the data, calculates the values necessary and draws the
universal power circle diagram. To close the System Parameter dialog box without any
further calculations or circle diagram drawing the user must press the Cancel-button.

4.5.4 The ‘Help’ Menu

The ‘About UPCD’ command is used to display the name of the program, the version
number of this copy, the copyright notice, and the email address for software support.

4.5.5 The ‘Zoom In’ and ‘Zoom Out’ Button

These two buttons allow the user to zoom in or out of a specific area on the screen. The
range of the zoom is from 100% to 600% in six equal steps.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 71

4.5.6 The ‘Constant Receiving Power Circle’ Button

This button opens the Power Circle dialog box as shown in Figure 4-5. It is possible to
enter up to three receiving-end complex power circles in mega volt-amperes.

Figure 4-5: The Power Circle dialog box

On clicking the OK-button, an error-checking of the values entered will be carried out
automatically and the circles will be drawn. By clicking the Cancel-button the screen will
not be updated with the new values entered. To delete a circle the user must enter the value
zero in the corresponding edit box.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 72

4.5.7 The ‘Constant Power Factor’ Button

The Power Factor dialog box opens after clicking the Constant Power Factor button. Here
the user can enter the power factor between 0 and 1. Confirmation of the input is via the
OK-button, cancellation or deleting already drawn lines is via the Cancel-button.

Figure 4-6: The Power Factor dialog box

4.5.8 The ‘Print Screen’ Button

This button opens a dialog box which explains in three steps a method by which the current
diagram and the output-values displayed may be printed.

Figure 4-7: The Print Screen dialog box

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 73

4.6 The View Window

After the values in the System Parameters dialog box are confirmed the program begins to
calculate and draw the universal power circle diagram for a short-transmission line as
developed in Chapter 3.4. It is important to remember that all the drawings on the screen
are receiving-end values, except of the sending-end voltage VS. Figure 4-8 shows the circle
diagram for the input values of the System Parameters dialog box from Figure 4-4.

Figure 4-8: The universal power circle diagram – screen output

The diagram shows the receiving-end power area with its two axes P and Q in per-unit
form and the voltage area V in per-unit form. The four half-circles drawn are constant
sending-end voltages with the values 0.8 p.u., 0.94 p.u., 1.1 p.u. and 1.2 p.u.. The two red
half-circles, 1.1 p.u. and 0.94 p.u. respectively, indicate the maximum voltage variation of
+10% and –6%. The half-circles start at the left-hand-side with a load angle of +90° and
end at the right-hand-side with a load angle of –90°.
The text-values printed on the right border of the window describe the current position of
the mouse in the diagram. For the receiving end, these values are: the voltage VR, the
active power PR, the reactive power QR, the complex power SR, the power factor cos(φR)
and the phase angle φR. There are no sending-end values (except VS) drawn in the diagram

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 74

but for each receiving-end point on the screen it is possible to calculate the sending-end
values which are printed as text below the receiving-end output values. These are: the
voltage VS, the active power PS, the reactive power QS, the complex power SS, the power
factor cos(φS) and the phase angle φS. The text output also includes the load angle δ and the
current IR. The receiving-end current and the sending-end current have a phase difference
of 180 degrees, according to the conventions set out in Chapter 3.4.1. The sum of the two
phase angles shown on the screen is not exactly 180 degrees. The difference is the load
angle, which is the angle between the sending-end and the receiving-end voltage. As the
mouse moves all of these output-values are calculated for the actual position of the mouse
and automatically updated on the screen.
Figure 4-9 shows the same diagram as Figure 4-8 with an additional constant receiving-end
power circle of 45.0 MVA and a zoom-factor of 300%.

Figure 4-9: Circle diagram with marked point P1 and constant power circle SR

The user can mark a point in the diagram labelled with ‘P1’ by pressing the left mouse-
button. The corresponding values for this point are shown in the upper right area of the
screen. The line from zero power to P1 indicates I.Z in per-unit and also a constant
receiving-end power factor line. The line from zero voltage to P1 indicates the sending-end
voltage in per-unit and a constant load angle line. The distance between the origins of the

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 75

power axis and the voltage axis is always the receiving-end voltage, which is the base
voltage for every calculation and therefore one per-unit. Pressing the right mouse button at
any time deletes the point marked and all output-values shown.

Figure 4-10: Circle diagram with power factor lines and the Power Factor dialog box

Figure 4-10 shows the last drawing-feature of the program, the receiving-end power factor
lines. In this example a power factor of 0.9 is chosen and entered in the Power Factor
dialog box. The program draws the lines for all four quadrants and labels them.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Development of Simulation Package 76

4.7 Error Estimation

In this section the different sources of error are discussed and a total percentage error for a
calculation estimated. The program contains two error-sources which have to be
considered:
1. Use of the short- instead of the long-transmission line model:
This error was already explained and calculated in Chapter 3.7. It was shown that
the error for a short-transmission line model with a line-length below 100 miles is
smaller than one percent. The distance for the connection of EGs to the grid will
always be smaller than 100 miles. Therefore, this estimation assumes a maximum
error of one percent.
2. Screen resolution:
When drawing the power- and the voltage-axes on the screen, pixels are used.
Thus, all the values have to be rounded to conform to the screen pixelation and a
rounding error occurs. When calculating the output-values for the current mouse
position, the position of the according pixel is used. As the screen resolution is not
infinite, these values will jump from pixel to pixel, depending on the zoom-factor.
A comparison between the output-values of the program and Excel-based
calculations with the formulas developed in Chapter 3.4.1 shows, that the
maximum error will be up to two percent.
To calculate the total maximum error, the values of the two errors explained must be
summed. Therefore, the absolute total maximum error is estimated to be three percent. To
keep the error as small as possible it is important to zoom into the specific area, thus
minimizing pixelation rounding errors.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Case Studies 77

5 Case Studies

5.1 System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 250 kVA

In this case a 400 V generator connected to the grid via a short-transmission line with a
fault level of 1.99 MVA is studied. The grid is as always on the receiving end and the
generator on the sending end of the transmission line. Figure 5-1 shows the universal
power circle diagram for this scenario with a receiving-end power circle of 250 kVA,
which is assumed to be full output from the generator at the receiving end . The X/R-ratio
of the transmission line is 10.

Figure 5-1: System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 250 kVA - screen output

The area within which the EG can operate without the net export leading to voltage
violation or exceeding the 250 kVA receiving-end power circle (full generator output at the
receiving end) has four boundaries which are coloured green:
1. The top boundary is the red 1.1 p.u. sending-end voltage circle.
2. The right-hand side boundary for a generator is the Q-axis (P equals zero).
3. The bottom boundary is the red 0.94 p.u. sending-end voltage circle.
4. The left-hand side boundary is the 250 kVA receiving-end power circle.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Case Studies 78

The green painted boundary is for the benefit of the report only and is not drawn by UPCD.
One corner of this boundary is marked and labelled with ‘P1’. The corresponding values
are shown on the upper right corner of the screen. It can be seen that the sending-end
voltage has been calculated as 440 V, the maximum allowed over-voltage. What this
shows is that a generator overexcited producing 250 kVA at the receiving end with a
receiving-end power factor of 0.65 lagging will cause a voltage violation. However, the
same generation operated at rated receiving-end power factor of 0.8 lagging will produce a
sending-end voltage within the 1.1 p.u. envelope.
The values shown on the lower right corner of Figure 5-1 are related to the current mouse
position, which is indicated in the picture with an arrow. In this case it is the point with the
maximum active power which could be produced by the generator. The reactive power
received is zero, consequently the receiving-end power factor is unity and the current is in
phase with the receiving-end voltage.
The difference between the sending-end real power and the receiving-end real power are
the real power losses of the line, which are equal to I 2 × R . The difference between the
sending- and receiving-end reactive power are the reactive power line ‘losses’, which are
equal to I 2 × X . The sum of the absolute values of the receiving-end phase angle, the
sending-end phase angle and the load angle is exactly 180 degrees. This convention was
adopted in Chapter 3.4.1, where power or current leaving a boundary was signed negative
and entering a boundary positive.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Case Studies 79

5.2 System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 500 kVA

This case studies an induction generator with the receiving-end values of 500 kVA
complex power and 0.9 power factor leading and compares it with a synchronous machine
with the receiving-end values of 500 kVA and 0.8 power factor lagging. The generators are
connected to a 400 V grid with a 1.99 MVA system fault level. The X/R-ratio is assumed
to be 10. Figure 5-2 shows the according screen output of UPCD.

Figure 5-2: System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 500 kVA – screen output

The point labelled with ‘P1’ is the induction generator with the receiving-end power factor
of 0.9 leading. The corresponding values are shown on the upper right corner of the screen.
The values on the lower right corner indicate the current mouse position on the screen,
which is the operating point of the overexcited synchronous machine. An arrow points to
the according position in Figure 5-2.
As seen, the induction machine operates at this point with a sending-end voltage drop of
–5.5 percent, which is within the voltage limitation. The synchronous machine, exporting
500 kVA receiving-end power at a 0.8 lagging receiving-end power factor, has a sending-
end voltage rise of +18.3 percent, which exceeds the voltage limitation by +8.3 percent and

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Case Studies 80

is therefore not acceptable. To operate within the voltage limitation, the synchronous
generator has to decrease the receiving-end complex power or to increase the receiving-end
power factor. The green coloured boundaries indicates once more the area within which the
generators are allowed to operate and is not drawn by UPCD.

5.3 System fault level: 3.98 MVA, Vgrid: 400 V, Sgrid: 500 kVA

This case uses the same assumptions as the case in Chapter 5.2. The only difference is the
simulation of the reinforcement of the grid by halving the line impedance, which results in
a doubled system fault level.

Figure 5-3: System fault level: 3.98 MVA, Vgrid: 400 V, Sgrid: 500 kVA – screen output

As before, the upper values indicate the induction machine, labelled in the picture with
‘P1’, and the lower values the synchronous machine, indicated with an arrow. For these
assumptions both machines are with its operation points within the voltage limits, which is
shown in Figure 5-3.
The voltage drop of the induction generator is, compared with the latter case, reduced by
36 percent and the voltage rise of the synchronous generator by 48 percent.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Case Studies 81

5.4 System fault level: 67 MVA, Vgrid: 3.3 kV, Sgrid: 6.5 MVA

This case studies a 3.3 kV generator connected to the grid with a fault level of 67 MVA.
The generator should be operate to produce an sending-end apparent power of 6.5 MVA at
a sending-end power factor of 0.8 leading.
As explained, it is not possible to draw sending-end power values in the receiving-end
area, but it is possible to calculate all sending-end values for every single point on the
receiving-end diagram. Therefore, to find the sending-end point a 6.5 MVA receiving-end
power circle and a 0.8 lagging receiving-end power factor line is drawn. The receiving-end
point for these assumptions is found where the power circle crosses the lagging power
factor line. Now it is possible to search for the sending-end point by moving the mouse
around the area of the receiving-end point. Figure 5-4 shows the circle diagram for this
generator with the 6.5 MVA receiving-end power circle and the 0.8 receiving-end power
factor lines.

Figure 5-4: System fault level: 67 MVA, Vgrid: 3.3 kV, Sgrid: 6.5 MVA – screen output

The upper right output-values in the picture indicate the P/Q-values for the point P1 and
therefore the values for 6.5 MVA sending-end power and a sending-end power factor of
0.8 leading. The lower values indicate the point for the same assumptions at the receiving-

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Case Studies 82

end. This point is slightly above P1 where the power circle intersects the power factor line,
as seen in Figure 5-4, and is indicated in the picture with an arrow.
The figure also shows that for a constant receiving-end power circle of 6.5 MVA the over-
voltage limit will never be exceeded. In this case there are only three boundaries (drawn
green), within which the EG can operate without the net export leading to voltage violation
or exceeding the 6.5 MVA (assumed full generator output at the receiving end) receiving-
end power circle:
1. The left-hand side boundary is the 6.5 MVA receiving-end power circle.
2. The right-hand side boundary for the generator is the Q-axis (P equals zero).
3. The bottom boundary is the red 0.94 p.u. sending-end voltage circle.
The green boundary is, as explained before, for the benefit of the report only and not drawn
by UPCD.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Discussion and Conclusion 83

6 Discussion and Conclusion

6.1 Overview

This chapter finishes the diploma thesis with a discussion on the problems encountered,
possible improvements to the software, a conclusion and a recommendation for future
work.

6.2 Problems Encountered

During the development of this project, many problems were experienced and solved. As
some problems were more difficult to solve than others within the time constrained, they
have yet to be corrected.
While running the program, the circle diagrams drawn could disappear and UPCD will not
start drawing them again. The user must close the program and restart it. However, the
error could not be consistently recreated. This error was observed to occur after copious
use of the scroll bars and the left mouse button respectively. In both cases the program has
to redraw the whole area. The problem is suspected to be a computer memory limitation.
Improper memory allocation may occur, thus causing a reduction in available memory.
The program code needs to be thoroughly examined to determine if this is the reason, and
solved to make the program more robust.
Another problem occurs when entering decimal numbers in the ‘Input’ dialog box. When
any numeric value is entered in one of the edit-boxes, all the other values in this dialog box
are calculated and updated automatically. Entry of a decimal point following a number is
not registered as it is not a numeric value. A decimal point must therefore be entered once
the numeric value is in place. For example, if the user wants to enter the number 29.5, he
must first enter the value 295 and add the decimal point afterwards.
The last problem is the resolution of the screen. This program works best with a resolution
of 1024 by 768 pixels. It is also possible to use UPCD with a resolution higher than that. In
this case all the drawings are further left than before and the output-values are not at the
right border of the screen. The program can not be used for a resolution smaller than 1024
by 768 as the output-values will no longer be on the screen. To avoid this problem, it
would be necessary to rewrite all drawing-commands in the source code by using a
different graphics mapping-code.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Discussion and Conclusion 84

6.3 Conclusion and Future Work

This thesis explains the basics of embedded generation and the problems an EG has within
a rural distribution network. Further, the background, mathematical theories, development
of a methodology, software implementation and testing of power circle diagrams for short-
and long-transmission lines were explained. It was shown that it is possible to visualize the
absorbence of the rural distribution grid at a proposed point of connection by using
universal power circle diagrams. The result was not a single point (a best or worst case) but
an area of active and reactive power within which the EG can operate without the net
export leading to voltage violation.
The Visual C++ simulation shows an universal power circle diagram for a short-
transmission line. It contains an area for active and reactive power at the receiving end and
an area for the receiving- and sending-end voltage. Additionally, the program calculates
and outputs all receiving- and sending-end values.
Through the use of this software a great deal of knowledge regarding absorbence of the
grid can be attained more efficiently than through manual ‘pen and paper’ calculations.
The main advantages of this program are the ability to visualise this area, to simply and
rapidly change systems parameters and to automatically calculate and output the receiving-
and sending-end values for every single point in the diagram. As far as known, there is no
equivalent package on the market that tests and visualize the absorbence of the grid.
UPCD can be used to test induction as well as synchronous generators at the same
proposed point of connection. It is also possible to test the effects of system reinforcement
by changing the system fault level.
UPCD shows, that the voltage rise is proportional to the apparent power of the generator
and to the inductive reactance of the grid, inversely proportional to the system fault level
and also affected by the power factor. For a small load angle the magnitude difference of
the two terminal voltages is proportional to the reactive power flow which is proportional
to the sending-end voltage and therefore to the machine excitation and the power factor
control.
The maximum total on-screen error has been estimated as not exceeding three percent. As
UPCD is intended to be a fast initial feasibility tool for an EG-connection, this error is
acceptable.
A recommendation for further work is to connect UPCD to an EG- and local load-
simulation to examine the time-variation of the active and reactive power of the generator
and the load and therefore the time-variation of the voltage. This can be used to assess the
duration of the voltage-violation.

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
List of Figures 85

7 List of Figures

Figure 1-1: Range of the worldwide crude oil-, natural gas- and coal-reserves....................9
Figure 1-2: Evolution of the world energy consumption 1990, 2020 and 2050..................10
Figure 1-3: The recent growth of DG (installed capacity/MW) in the UK .........................12
Figure 2-1: UK electricity supply industry..........................................................................16
Figure 2-2: Small synchronous generator connected to the network and phasor diagram..21
Figure 2-3: Equivalent circuit of an induction machine ......................................................23
Figure 2-4: Torque/speed curve of an induction machine...................................................23
Figure 2-5: Variable speed convertor (using thyristors)......................................................25
Figure 2-6: Variable speed convertor (using IGBTs)..........................................................26
Figure 2-7: Typical EG connection .....................................................................................27
Figure 3-1: Voltage source and load; phasor diagram.........................................................35
Figure 3-2: Phasor diagram and power triangle for an inductive load (lagging pf) ............36
Figure 3-3: Phasor diagram and power triangle for a capacitive load (leading pf) .............37
Figure 3-4: Unsymmetrical T-circuit equivalent to a four terminal network ......................38
Figure 3-5: Symbolic diagram representing a four-terminal network.................................39
Figure 3-6: Power transfer of a short-transmission line .....................................................40
Figure 3-7: Phasor diagram of a synchronous machine and a short-transmission line with R
= 0 respectively....................................................................................................................43
Figure 3-8: Circle diagram for VR = constant and X = 1.25 p.u. (R = 0 p.u.) .....................45
Figure 3-9: Phasor diagram of a short-transmission line.....................................................46
Figure 3-10: Phasor diagram of a two-sources network......................................................46
Figure 3-11: Receiving-end power diagram........................................................................47
Figure 3-12: Receiving-end power diagram after rotation ..................................................48
Figure 3-13: Receiving-end power circle diagram for ⎟VR⎟ = constant and ⎟VS⎟ = variable
.............................................................................................................................................50
Figure 3-14: Scaling of the universal power circle diagram of a short-transmission line...52
Figure 3-15: Universal power circle diagram of a short-transmission line .........................53
Figure 3-16: Phasor diagram of a four-terminal network....................................................57
Figure 3-17: Receiving-end power diagram of a long-transmission line ............................58
Figure 3-18: Scaling of the universal power circle diagram of a long-transmission line....60

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
List of Figures 86

Figure 3-19: The use of the power circle diagrams .............................................................61


Figure 3-20: Absolute percentage difference of a short-transmission line model compared
with a long-transmission line model....................................................................................63
Figure 4-1: Flow chart of UPCD .........................................................................................66
Figure 4-2: The UPCD icon ................................................................................................67
Figure 4-3: The main window and one drop down menu....................................................67
Figure 4-4: The System Parameters dialog box...................................................................69
Figure 4-5: The Power Circle dialog box ............................................................................71
Figure 4-6: The Power Factor dialog box............................................................................72
Figure 4-7: The Print Screen dialog box .............................................................................72
Figure 4-8: The universal power circle diagram – screen output ........................................73
Figure 4-9: Circle diagram with marked point P1 and constant power circle SR ................74
Figure 4-10: Circle diagram with power factor lines and the Power Factor dialog box .....75
Figure 5-1: System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 250 kVA - screen output...77
Figure 5-2: System fault level: 1.99 MVA, Vgrid: 400 V, Sgrid: 500 kVA – screen output ..79
Figure 5-3: System fault level: 3.98 MVA, Vgrid: 400 V, Sgrid: 500 kVA – screen output ..80
Figure 5-4: System fault level: 67 MVA, Vgrid: 3.3 kV, Sgrid: 6.5 MVA – screen output ...81

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
References 87

8 References

[1] British Petroleum (http://www.bp.com/bpstats/)


[2] British Wind Energy Association Factsheet 14: ‘Generating Electricity into the UK
Electricity System’; web site: http//www.bea.com/fs14elec.htm
[3] Cerveny, M.: ‘Overheadfolien Energie 1999’; Energieverwertungsagentur (E.V.A.),
Austria, 1999 (in German)
[4] Department of Trade and Industry: ‘Digest of United Kingdom Energy Statistics
1999’, United Kingdom, 2000
[5] Energy Technology Support Unit (ETSU): ‘Increasing Levels of Distributed
Generation and its Effects an Electricity Networks’; 1998
[6] Gillespie, A.W.: ‘Simulation of Remote Embedded Generation’; BEng Hons
Project Report HSP 1281, Department of Electrical Engineering, University of
Edinburgh, May 1997
[7] Goodrich, R.D. Jr.: ‘A Universal Power Circle Diagram’; Trans. AIEE, Vol. 70, pp.
2042 - 2049, 1951
[8] Harrison, G.P.: ‘Ancillary Services in the UK Electricity Supply Industry’; BEng
Hons Dissertation Report HD 1196, Department of Electrical Engineering,
University of Edinburgh, May 1997
[9] Hughes, E.: ‘Electrical Technology’; Longman Group, 1970, 4th ed., pp. 288-329
[10] Jenkins, N.: ‘Embedded Generation, Tutorial – Part I’; Power Engineering Journal,
pp. 145-150, June 1995, 9, (3)
[11] Jenkins, N.: ‘Embedded Generation, Tutorial - Part II’; Power Engineering Journal,
pp. 233-239, October 1996
[12] Kane, P.J.O.; Fox, B. and Morrow, D.J.: ‘Impact of embedded generation on
emergency reserve’; IEE Proceedings Generation Transmission Distribution, Vol.
146, No. 2, pp. 159-163, March 1999
[13] Kenward, M.: ’Potential Energy – An Analysis of World Energy Technology’;
Cambridge University Press, Cambridge, 1976
[14] Luckett, Martin: ‘Have vars, can travel’; IEE REVIEW, pp.207-210, 1999
[15] Povejsil, D.J. and Johnson, A. A.: ’A Per-unit Interpretation of Transmission Line
Constants’; Trans. AIEE, Vol. 70, pp. 194 - 200, 1951

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
References 88

[16] Ruedisili, L.C. and Firebaugh M. W.: ‘Perspectives on Energy - Issues, Ideas, and
Environmental Dilemmas’; Oxford University Press Inc., London, 1975
[17] Saadat, H.: ‘Power System Analysis’; Milwaukee School of Engineering, 1999
[18] Stevenson, W.D. Jr.: ‘Elements of Power System Analysis’; McGraw-Hill
Publishing Company Ltd., London, 1955
[19] Stinson, J.F.: ‘Simulation of Loss of Main, Detection and Protection’; BEng
Honours Project Report HSP 1284, Department of Electrical Engineering,
University of Edinburgh, May 1997
[20] Stroustrup, B.: ‘The C++ Programming Language’; Addison-Wesley Publishing
Company, 1991
[21] Waddicor, H.: ‘The Principles of Electric Power Transmission’; Chapman and Hall
Ltd., London, 1964
[22] Wallace, A.R.: ‘Integration of embedded generation plant into electricity supply
networks’; Energy System Group, Departments of Electronics and Electrical
Engineering, University of Edinburgh, UK
[23] Wallace, A.R.: ‘Power Systems – 3th Year Notes’; Departments of Electronics and
Electrical Engineering, University of Edinburgh, UK, 1999
[24] Wallace, A.R. and Stapleton, S.A.: ‘Operation and protection of Embedded
Generation Schemes’; Departments of Electronics and Electrical Engineering,
University of Edinburgh, UK, 1997
[25] Wallace, A.R. and Whittington, H.W.: ‘Power Systems and Machines – 4th Year
Notes’; Departments of Electronics and Electrical Engineering, University of
Edinburgh, UK, 1996
[26] Ward, C.: ’Technical Requirements for a Reactive Service’; IEE Colloquium on
Economic provision of reactive power for system voltage control, pp. 2/1-4, 1996
[27] Warnock, G.J.: ‘Simulation of Loss of Grid Connection to an Embedded
Generator’; BEng Hons Project Report HSP 1373, Department of Electrical
Engineering, University of Edinburgh, May 1998
[28] Weedy, B.M.: ‘Electric Power Systems’; Department of Electrical Engineering,
The University of Southampton, Third Edition, 1989
[29] World Energy Council (WEC), International Institutes for Applied Systems
Analysis (IIASA): ‘Globally in Energy Perspectives 1998’; Austria, 1999
(http://www.iiasa.ac.at/cgi-bin/book_dyn/bookcnt.py)

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Bibliography 89

9 Bibliography

[1] Fickert, L.: ‘Elektrische Energieübertragung’; Institute for Electronic Power


System, University of Graz, Austria, 1998 (in German)
[2] Fickert, L.: ‘Elektrische Energieerzeugung’; Institute for Electronic Power System,
University of Graz, Austria, 1998 (in German)
[3] Gurewich, O. and Gurewich N.: ‘Teach Yourself Visual C++ 4 in 21 Days’; First
Edition, Sams Publishing, USA, 1996
[4] Kruglinski, D.J.: ‘Inside Visual C++’; Microsoft Press, Washington, 1997
[5] Sams Publishing: ‘Sams teach Yourself C++ in 21 Days’; Third Edition, USA,
February 1999
[6] Schildt, H.: ‘Teach Yourself C++, Third Edition’; Osborne/The McGraw-Hill
Companies, USA, 1998

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 90

10 Appendix

The following chapters include the source code of the different Microsoft Visual C++
classes of UPCD. Each class is split up into its header- and source-file.

10.1 Class Calculation

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Calculations.h: interface for the CCalculations class.
// This class calculates the output-values for the circle diagram
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CCircleDiagramDoc;

class CCalculations
{
public:

float P_DRAWFACTOR;
float V_DRAWFACTOR;
float BasePower;
float BaseVoltage;
float FaultLevel;
float Reactance;
float PCSS;
float Resistance;
float Voltage;
float XRratio;
float Angle;
float Impedance;
float ImpedanceCalc;
float AngleCalc;
int zoom;
int IndicationCheckBox; // indicates which checkbox is pressed, 1 for checkBoxRX,
// 2 for checkBoxZ, 3 for checkBoxPSCC and 4 for checkBoxFault

void SetDocPointer (CCircleDiagramDoc*);


void DoCalculation();

CCalculations();
virtual ~CCalculations();

protected:

CCircleDiagramDoc *pDoc;

};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 91

// Calculations.cpp: implementation of the CCalculations class.


// This class calculates the output-values for the circle diagram
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "Calculations.h"
#include "Input.h"
#include "Circle DiagramDoc.h"
#include <complex>
#include <math.h>
#include <stdio.h>
#define __STD_COMPLEX
using namespace std;

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

CCalculations::CCalculations()
{

CCalculations::~CCalculations()
{

// Copies pointer to Circle DiagramDoc


void CCalculations::SetDocPointer(CCircleDiagramDoc *DocPtr)
{
pDoc = DocPtr;
}

// This function calculates all values for the output in the Input-Dialog-Box
// and the variables P_DRAWFACTOR and V_DRAWFACTOR
void CCalculations::DoCalculation()
{
double pi = 3.1415926535;

// Get data from document


BaseVoltage = pDoc->BaseVoltage;
FaultLevel = pDoc->FaultLevel;
Reactance = pDoc->Reactance;
PCSS = pDoc->PCSS;
Resistance = pDoc->Resistance;
Voltage = pDoc->Voltage;
XRratio = pDoc->XRratio;
Angle = pDoc->Angle;
Impedance = pDoc->Impedance;
IndicationCheckBox = pDoc->IndicationCheckBox;
zoom = pDoc->zoom;

// Calculates the impedance and its angle for four different input-cases
switch (IndicationCheckBox)
{

// R and X are available


case 1:
{

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 92

ImpedanceCalc = sqrt(Resistance*Resistance+Reactance*Reactance);
AngleCalc = atan(Reactance/Resistance);

pDoc->Impedance = ImpedanceCalc;
pDoc->Angle = AngleCalc*180/pi;
pDoc->PCSS = ((Voltage/sqrt(3))/ImpedanceCalc)*1000; //PSCC in Ampere
pDoc->XRratio = (Reactance/Resistance);
pDoc->FaultLevel = (Voltage*Voltage/ImpedanceCalc);

break;
}

// Z and the angle of Z are available


case 2:
{
ImpedanceCalc = Impedance;
AngleCalc = Angle*pi/180;

pDoc->Resistance = (ImpedanceCalc*cos(AngleCalc));
pDoc->Reactance = (ImpedanceCalc*sin(AngleCalc));
pDoc->Impedance = ImpedanceCalc;
pDoc->Angle = AngleCalc*180/pi;
pDoc->PCSS = ((Voltage/sqrt(3))/ImpedanceCalc)*1000;
pDoc->XRratio = (tan(AngleCalc));
pDoc->FaultLevel = (Voltage*Voltage/ImpedanceCalc);

break;
}

// PSCC and the X/R-ratio are available


case 3:
{
ImpedanceCalc = ((Voltage/sqrt(3))/(PCSS/1000)); // kV/kA = V/A = ohm
AngleCalc = atan(XRratio);

pDoc->Resistance = (ImpedanceCalc*cos(AngleCalc));
pDoc->Reactance = (ImpedanceCalc*sin(AngleCalc));
pDoc->Impedance = ImpedanceCalc;
pDoc->Angle = AngleCalc*180/pi;
pDoc->FaultLevel = (Voltage*Voltage/ImpedanceCalc);

break;
}

// The system fault level and the X/R-ratio are available


case 4:
{
ImpedanceCalc = (Voltage*Voltage/FaultLevel); // kV*kV/MVA = V/A = ohm
AngleCalc = atan(XRratio);

pDoc->Resistance = (ImpedanceCalc*cos(AngleCalc));
pDoc->Reactance = (ImpedanceCalc*sin(AngleCalc));
pDoc->Impedance = ImpedanceCalc;
pDoc->Angle = AngleCalc*180/pi;
pDoc->PCSS = ((Voltage/sqrt(3))/ImpedanceCalc)*1000;

break;
}

default:
break;
}

// Calculating of the base power and saving in document


BasePower = BaseVoltage*BaseVoltage/ImpedanceCalc; // kV*kV/ohm = MVAbase
pDoc->BasePower = BasePower;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 93

// Saving of the calculated angle in document


pDoc->AngleCalc=AngleCalc;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Calculating of the P_DRAWFACTOR and V_DRAWFACTOR. These factors are used
// for the scaling on the screen. It is the BasePower or BaseVoltage dividet
// through 200, where 200 is the length of one half of the axis and is
// equivalent to 1p.u.Therefore P_DRAWFACTOR indicates the power per pixel and
// V_DRAWFACTOR the voltage per pixel.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

P_DRAWFACTOR = BasePower/(200);
pDoc->P_DRAWFACTOR = P_DRAWFACTOR;

V_DRAWFACTOR = BaseVoltage/(201);
pDoc->V_DRAWFACTOR = V_DRAWFACTOR;
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 94

10.2 Class Circle DiagramDoc

// Circle DiagramDoc.h : interface of the CCircleDiagramDoc class


// This class sets the default-values and stores all Input-datas
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <complex>
using namespace std;

class CCircleDiagramDoc : public CDocument


{
protected: // create from serialization only
CCircleDiagramDoc();
DECLARE_DYNCREATE(CCircleDiagramDoc)

// Attributes
public:

// Operations
public:

void DeleteContents();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCircleDiagramDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL

// Implementation
public:

BOOLEAN SwitchSave;
BOOLEAN StartSwitch;
BOOLEAN MarkDelete;
BOOLEAN MarkSwitch;
BOOLEAN PFSwitch;

CString SaveP1Iout;
CPoint DevicePosition;

int Mark_y;
int Mark_x;
int zoom;
int YVoltage;
int XVoltage;
int IndicationCheckBox;

double Sradius;
double Sradius2;
double Sradius3;

complex <double> IComplex;


float SendingVoltage;
float MarkZoom;
float PowerFactor;
float AngleCalc;
float P_DRAWFACTOR;
float V_DRAWFACTOR;
float BasePower;
float BaseVoltage;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 95

float FaultLevel;
float Reactance;
float PCSS;
float Resistance;
float Voltage;
float XRratio;
float Angle;
float Impedance;

CString P1Iout;
CString P1AngleSendOut;
CString P1PFSendout;
CString P1Ssout;
CString P1Qsout;
CString P1Psout;
CString P1LAngleout;
CString P1Vout;
CString P1AngleOut;
CString P1PFout;
CString P1Pout;
CString P1Qout;
CString P1Sout;
CString P1VrOut;

CString SaveP1AngleSendOut;
CString SaveP1PFSendout;
CString SaveP1Ssout;
CString SaveP1Qsout;
CString SaveP1Psout;
CString SaveP1LAngleout;
CString SaveP1Vout;
CString SaveP1AngleOut;
CString SaveP1PFout;
CString SaveP1Pout;
CString SaveP1Qout;
CString SaveP1Sout;
CString SaveP1VrOut;

virtual ~CCircleDiagramDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions


protected:
//{{AFX_MSG(CCircleDiagramDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 96

// Circle DiagramDoc.cpp : implementation of the CCircleDiagramDoc class


// This class sets the default-values and stores all Input-datas
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "Input.h"
#include "Circle DiagramDoc.h"
#include "Calculations.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramDoc
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE(CCircleDiagramDoc, CDocument)

BEGIN_MESSAGE_MAP(CCircleDiagramDoc, CDocument)
//{{AFX_MSG_MAP(CCircleDiagramDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramDoc construction/destruction
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

CCircleDiagramDoc::CCircleDiagramDoc()
{
// TODO: add one-time construction code here
}

CCircleDiagramDoc::~CCircleDiagramDoc()
{
}

BOOL CCircleDiagramDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
{
return FALSE;
}
// TODO: add reinitialization code here
// (SDI documents will reuse this document)

return TRUE;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramDoc serialization
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// This function stores and restores all datas from the document
void CCircleDiagramDoc::Serialize(CArchive& ar)
{
double RealCurrent,ImagCurrent;

if (ar.IsStoring())
{
RealCurrent = real(IComplex);
ImagCurrent = imag(IComplex);

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 97

// TODO: add storing code here


ar << Angle;
ar << AngleCalc;
ar << BasePower;
ar << BaseVoltage;
ar << DevicePosition;
ar << FaultLevel;
ar << RealCurrent;
ar << ImagCurrent;
ar << Impedance;

ar << IndicationCheckBox;
ar << Mark_x;
ar << Mark_y;
ar << MarkDelete;
ar << MarkSwitch;
ar << MarkZoom;

ar << P1Iout;
ar << P1AngleSendOut;
ar << P1PFSendout;
ar << P1Ssout;
ar << P1Qsout;
ar << P1Psout;
ar << P1LAngleout;
ar << P1Vout;
ar << P1AngleOut;
ar << P1PFout;
ar << P1Pout;
ar << P1Qout;
ar << P1Sout;
ar << P1VrOut;

ar << P_DRAWFACTOR;
ar << PCSS;
ar << PFSwitch;
ar << PowerFactor;
ar << Reactance;
ar << Resistance;

ar << SaveP1AngleSendOut;
ar << SaveP1PFSendout;
ar << SaveP1Ssout;
ar << SaveP1Qsout;
ar << SaveP1Psout;
ar << SaveP1LAngleout;
ar << SaveP1Vout;
ar << SaveP1AngleOut;
ar << SaveP1PFout;
ar << SaveP1Pout;
ar << SaveP1Qout;
ar << SaveP1Sout;
ar << SaveP1VrOut;
ar << SaveP1Iout;

ar << SendingVoltage;
ar << Sradius;
ar << Sradius2;
ar << Sradius3;
ar << StartSwitch;
ar << V_DRAWFACTOR;
ar << Voltage;
ar << XRratio;
ar << XVoltage;
ar << YVoltage;
ar << zoom;
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 98

else
{
// TODO: add loading code here
ar >> Angle;
ar >> AngleCalc;
ar >> BasePower;
ar >> BaseVoltage;
ar >> DevicePosition;
ar >> FaultLevel;
ar >> RealCurrent;
ar >> ImagCurrent;
ar >> Impedance;

ar >> IndicationCheckBox;
ar >> Mark_x;
ar >> Mark_y;
ar >> MarkDelete;
ar >> MarkSwitch;
ar >> MarkZoom;

ar >> P1Iout;
ar >> P1AngleSendOut;
ar >> P1PFSendout;
ar >> P1Ssout;
ar >> P1Qsout;
ar >> P1Psout;
ar >> P1LAngleout;
ar >> P1Vout;
ar >> P1AngleOut;
ar >> P1PFout;
ar >> P1Pout;
ar >> P1Qout;
ar >> P1Sout;
ar >> P1VrOut;

ar >> P_DRAWFACTOR;
ar >> PCSS;
ar >> PFSwitch;
ar >> PowerFactor;
ar >> Reactance;
ar >> Resistance;

ar >> SaveP1AngleSendOut;
ar >> SaveP1PFSendout;
ar >> SaveP1Ssout;
ar >> SaveP1Qsout;
ar >> SaveP1Psout;
ar >> SaveP1LAngleout;
ar >> SaveP1Vout;
ar >> SaveP1AngleOut;
ar >> SaveP1PFout;
ar >> SaveP1Pout;
ar >> SaveP1Qout;
ar >> SaveP1Sout;
ar >> SaveP1VrOut;
ar >> SaveP1Iout;

ar >> SendingVoltage;
ar >> Sradius;
ar >> Sradius2;
ar >> Sradius3;
ar >> StartSwitch;
ar >> V_DRAWFACTOR;
ar >> Voltage;
ar >> XRratio;
ar >> XVoltage;
ar >> YVoltage;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 99

ar >> zoom;

IComplex = complex<double>(RealCurrent,ImagCurrent);
SwitchSave = FALSE;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramDoc diagnostics
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef _DEBUG
void CCircleDiagramDoc::AssertValid() const
{
CDocument::AssertValid();
}

void CCircleDiagramDoc::Dump(CDumpContext& dc) const


{
CDocument::Dump(dc);
}
#endif //_DEBUG

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramDoc commands
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// This function is called to set the default values for the input-variables
void CCircleDiagramDoc::DeleteContents()
{
BaseVoltage = (float) 0.4;
Voltage = (float) 0.4;
Resistance = (float) 0.0080003;
Reactance = (float) 0.080003;
XRratio = 10;
Impedance = (float) 0.080402;
Angle = (float) 84.2894;
FaultLevel = (float) 1.99;
PCSS = (float) 2872.32;

zoom=1;
PowerFactor=0;
Sradius = 0;
Sradius2 = 0;
Sradius3 = 0;
P_DRAWFACTOR=0;
V_DRAWFACTOR=0;

PFSwitch = FALSE;
MarkSwitch = FALSE;
MarkDelete = FALSE;
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 100

10.3 Class Circle DiagramView

// Circle DiagramView.h : interface of the CCircleDiagramView class


// This class is the main-drawing-class for all drawings on the screen
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CCircleDiagramView : public CScrollView


{
protected: // create from serialization only
CCircleDiagramView();
DECLARE_DYNCREATE(CCircleDiagramView)

// Attributes
public:
CCircleDiagramDoc* GetDocument();

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCircleDiagramView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
//}}AFX_VIRTUAL

// Implementation
public:

CDC* pDC;
void CallInitialUpdate();

void CallDrawUpdate();
virtual ~CCircleDiagramView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions


protected:
//{{AFX_MSG(CCircleDiagramView)
afx_msg void OnZoomin();
afx_msg void OnZoomout();
afx_msg void OnStart();
afx_msg void OnSconstant();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnPowerFactor();
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnPrintScreen();
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 101

// Circle DiagramView.cpp : implementation of the CCircleDiagramView class


// This class is the main-drawing-class for all drawings on the screen
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "DrawAxis.h"
#include "Input.h"
#include "Calculations.h"
#include "afxwin.h"
#include "Sconstant.h"
#include "PowerFactor.h"
#include "P1Out.h"
#include "Circle DiagramDoc.h"
#include "Circle DiagramView.h"
#include "PrintScreenDlg.h"
#include <complex>
#include <stdlib.h>
#include <math.h>
using namespace std;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramView
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE(CCircleDiagramView, CScrollView)

BEGIN_MESSAGE_MAP(CCircleDiagramView, CScrollView)
//{{AFX_MSG_MAP(CCircleDiagramView)
ON_BN_CLICKED(IDC_ZOOMIN, OnZoomin)
ON_BN_CLICKED(IDC_ZOOMOUT, OnZoomout)
ON_COMMAND(ID_START, OnStart)
ON_BN_CLICKED(IDC_SCONSTANT, OnSconstant)
ON_WM_MOUSEMOVE()
ON_BN_CLICKED(IDC_PowerFactor, OnPowerFactor)
ON_WM_LBUTTONUP()
ON_WM_RBUTTONDOWN()
ON_BN_CLICKED(IDC_PrintScreen, OnPrintScreen)
ON_WM_VSCROLL()
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramView construction/destruction
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

CCircleDiagramView::CCircleDiagramView()
{
// TODO: add construction code here

CCircleDiagramView::~CCircleDiagramView()
{
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 102

BOOL CCircleDiagramView::PreCreateWindow(CREATESTRUCT& cs)


{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CScrollView::PreCreateWindow(cs);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramView drawing
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// This funktion calles the different drawing-functions from the class DrawAxis.
// It is called every time when the screen needs to be updated.
void CCircleDiagramView::OnDraw(CDC* pDC)
{
CCircleDiagramDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here

if (pDoc->StartSwitch)
{
DrawAxis AxisV;
AxisV.SetDocPointer(GetDocument());
AxisV.pDCPointer(pDC);
AxisV.DrawPQaxis(pDoc->zoom);

double radius = 201*1.1; // 200 pixel equals 1 per-unit


CString circleName = "1.1 p.u.";
int Red = 255;
AxisV.DrawCircles(pDoc->zoom, radius, circleName, Red);

radius = 201*0.94;
circleName = "0.94 p.u.";
Red = 255;
AxisV.DrawCircles(pDoc->zoom, radius, circleName, Red);

radius = 201*0.8;
circleName = "0.8 p.u.";
int Black = 0;
AxisV.DrawCircles(pDoc->zoom, radius, circleName, Black);

radius = 201*1.2;
circleName = "1.2 p.u.";
Black = 0;
AxisV.DrawCircles(pDoc->zoom, radius, circleName, Black);

AxisV.DrawSCircle(pDoc->zoom, pDoc->Sradius/pDoc->P_DRAWFACTOR);
AxisV.DrawSCircle(pDoc->zoom, pDoc->Sradius2/pDoc->P_DRAWFACTOR);
AxisV.DrawSCircle(pDoc->zoom, pDoc->Sradius3/pDoc->P_DRAWFACTOR);

AxisV.DrawPowerFactorLine(pDoc->zoom);

AxisV.DrawMark(pDoc->zoom);
pDoc->MarkSwitch = FALSE;

CDC* pdc;
pdc = GetDC();
P1Out NameP1Out;
NameP1Out.SetDocPointer(pDoc);
NameP1Out.ScreenOutP1(pdc);
}
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 103

// This function is called in the beginning of the program (initialisation)


// and if a new document is opened
void CCircleDiagramView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();

// Calculates the total size of the view


CSize sizeTotal (3000,2000);
CSize sizePage (sizeTotal.cx / 10, sizeTotal.cy / 10);
CSize sizeLine (sizeTotal.cx / 50, sizeTotal.cy / 50);
SetScrollSizes (MM_TEXT, sizeTotal, sizePage, sizeLine);

// Initialisation of the screen position in the beginning


int P1=1100, P2=750;
CPoint POINT1 (P1, P2);
ScrollToPosition (POINT1);

CCircleDiagramDoc* pDoc = GetDocument();

if(pDoc->SwitchSave)
{
pDoc->StartSwitch = FALSE;

// Draw Bitmap on the screen


CPaintDC dc(this);
HBITMAP hbitmap=
::LoadBitmap(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP1));
HDC hMemDC = ::CreateCompatibleDC(NULL);
SelectObject(hMemDC,hbitmap);
::StretchBlt(dc.m_hDC,300,130,400,400,hMemDC,0,0,375,379,SRCCOPY);
DeleteDC(hMemDC);
DeleteObject(hbitmap);
}

else pDoc->SwitchSave = TRUE;


}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramView diagnostics
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef _DEBUG
void CCircleDiagramView::AssertValid() const
{
CScrollView::AssertValid();
}

void CCircleDiagramView::Dump(CDumpContext& dc) const


{
CScrollView::Dump(dc);
}

CCircleDiagramDoc* CCircleDiagramView::GetDocument() // non-debug version is inline


{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCircleDiagramDoc)));
return (CCircleDiagramDoc*)m_pDocument;
}
#endif //_DEBUG

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCircleDiagramView message handlers
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// This function is called when the button 'ZOOM IN' is pressed


void CCircleDiagramView::OnZoomin()
{

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 104

// TODO: Add your control notification handler code here


CCircleDiagramDoc* pDoc = GetDocument();

if (pDoc->StartSwitch && pDoc->zoom<33)


{
pDoc->zoom=pDoc->zoom*2;
CCircleDiagramDoc* pDoc = GetDocument();
pDoc->MarkZoom = pDoc->MarkZoom*2;
pDoc->MarkSwitch = FALSE;

CScrollView::OnInitialUpdate();
}
}

// This function is called when the button 'ZOOM OUT' is pressed


void CCircleDiagramView::OnZoomout()
{
// TODO: Add your control notification handler code here
CCircleDiagramDoc* pDoc = GetDocument();

if (pDoc->zoom>1)
{
pDoc->zoom=pDoc->zoom/2;
pDoc->MarkZoom = pDoc->MarkZoom/2;
pDoc->MarkSwitch = FALSE;

CScrollView::OnInitialUpdate();
}
}

// This function is called when the button 'S' (Start) is pressed


void CCircleDiagramView::OnStart()
{
// TODO: Add your command handler code here
CScrollView::OnInitialUpdate();

// DeleteContents is called before Input-Box to initialise all variables


CCircleDiagramDoc* pDoc = GetDocument();
pDoc->DeleteContents();
pDoc->StartSwitch=FALSE;

// Initialisation of Sradius
pDoc->Sradius=0;

// Initialisation of Point1
pDoc->MarkDelete = FALSE;

// Call Input-DialogBox
Input InputDlg;
InputDlg.SetDocPointer(GetDocument());
InputDlg.SetViewPointer(this);
InputDlg.DoModal();

// Call DoCalculation
CCalculations CalcDlg;
CalcDlg.SetDocPointer(GetDocument());
CalcDlg.DoCalculation();
}

// This function is called from the OnCancel-function (class Input) after


// the Button 'Cancel' on the Input-Dlg-Box is pressed. It calles OnIntitialUpdate
// to show the Bitmap Emblem
void CCircleDiagramView::CallInitialUpdate()
{
CCircleDiagramDoc* pDoc = GetDocument();
pDoc->StartSwitch=FALSE;
OnInitialUpdate();

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 105

// This function is called from the OnOK-function (class Input) after the Button 'OK'
// on the Input-Dlg-Box is pressed. It calles OnIntitialUpdate to draw the diagram
void CCircleDiagramView::CallDrawUpdate()
{
CCircleDiagramDoc* pDoc = GetDocument();
pDoc->StartSwitch=TRUE;
pDoc->zoom=1;

CScrollView::OnInitialUpdate();
}

// This function is called when the button 'constant receiving power circle' is pressed
void CCircleDiagramView::OnSconstant()
{
// TODO: Add your control notification handler code here

//Call Sconstant-DialogBox
CCircleDiagramDoc* pDoc = GetDocument();
if (pDoc->StartSwitch)
{
Sconstant SConstDlg;
SConstDlg.SetDocPointer(GetDocument());
SConstDlg.DoModal();
CScrollView::OnInitialUpdate();
}
}

// This function is called when the mouse is moved. It calculates the values
// of P, Q, V, I, the power factor, the load and the phase angles according
// to the x anc y position of the mouse
void CCircleDiagramView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default

//general initialisations
double pi = 3.1415926535;

CPoint POINT1;
POINT1 = GetDeviceScrollPosition( );

CDC* pdc;
pdc = GetDC();

CCircleDiagramDoc* pDoc = GetDocument();

//start calculation and output


if (pDoc->StartSwitch)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Output of the RECEIVING-END values
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int xOutput = 345;


pdc->TextOut(800,xOutput," ");
pdc->TextOut(800,xOutput,"Receiving-end values:");

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Vr: convert and output
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

CString VrOut;

VrOut.Format ("Vr: %.3f kV",pDoc->Voltage);


pdc->TextOut(800,xOutput + 20," ");
pdc->TextOut(800,xOutput + 20,VrOut);

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 106

pDoc->P1VrOut = VrOut;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Pr, Qr and Sr: Calculate, convert and output
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// PQ initialisations
int x_PQaxis_zero, y_PQaxis_zero;
float MousePcalc, MouseQcalc, Scalc;
float P_DRAWFACTOR = pDoc->P_DRAWFACTOR/pDoc->zoom;
CString Pout, Qout, Sout;

// Calculation of the x and y coordinates for P and Q


// The point (0,0) is in the crossing of the two axis P and Q
x_PQaxis_zero = (point.x-(1500-POINT1.x))*(-1);
y_PQaxis_zero = (point.y-(1000-POINT1.y))*(-1);

// Calclation of the actual P and Q values


MousePcalc = (P_DRAWFACTOR) * x_PQaxis_zero;
MouseQcalc = (P_DRAWFACTOR) * y_PQaxis_zero;
Scalc = (float) (sqrt(MousePcalc*MousePcalc + MouseQcalc*MouseQcalc));

// Conversion and output of the P and Q values on the screen


Pout.Format ("Pr: %.3f MW",MousePcalc);
pdc->TextOut(800,xOutput + 35," ");
pdc->TextOut(800,xOutput + 35,Pout);
pDoc->P1Pout = Pout;

Qout.Format ("Qr: %.3f Mvar",MouseQcalc);


pdc->TextOut(800,xOutput + 50," ");
pdc->TextOut(800,xOutput + 50,Qout);
pDoc->P1Qout = Qout;

Sout.Format ("Sr: %.3f MVA",Scalc);


pdc->TextOut(800,xOutput + 65," ");
pdc->TextOut(800,xOutput + 65,Sout);
pDoc->P1Sout = Sout;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Output of the SENDING-END values
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

pdc->TextOut(800,xOutput+130," ");
pdc->TextOut(800,xOutput+130,"Sending-end values:");

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Voltage (sending end): Calculate, convert and output
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// V initialisations
int x_Vaxis_zero, y_Vaxis_zero;
float MouseVcalc, Vaxis_zero;
float V_DRAWFACTOR = pDoc->V_DRAWFACTOR/pDoc->zoom;
CString Vout;

// Calculation of the x and y coordinates for V


// The point (0,0) is in the crossing of the V axis
x_Vaxis_zero = (point.x-(pDoc->XVoltage-POINT1.x));
y_Vaxis_zero = (point.y-(pDoc->YVoltage-POINT1.y));
Vaxis_zero = (float) sqrt(x_Vaxis_zero*x_Vaxis_zero+y_Vaxis_zero*y_Vaxis_zero);

// Calclation of the actual V value


MouseVcalc = (V_DRAWFACTOR) * Vaxis_zero;
pDoc->SendingVoltage = MouseVcalc;

// Conversion and output of the V value on the screen


Vout.Format ("Vs: %.3f kV",MouseVcalc);

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 107

pdc->TextOut(800,xOutput+150," ");
pdc->TextOut(800,xOutput+150,Vout);
pDoc->P1Vout = Vout;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Load angle: Calculate, convert and output
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Load angle initialisations


double Angle, Angle1;
CString LAngleout;
float LoadAngle;

// Calclation of the load angle


float AngleCalc = (float) (pDoc->AngleCalc*180/pi);

Angle = (double) (atan2(-y_Vaxis_zero,-x_Vaxis_zero));


Angle1 = (double)(Angle*(180/pi));
LoadAngle = (float) (AngleCalc - Angle1);
if (180<LoadAngle) LoadAngle=LoadAngle-360;

// Conversion and output of the load angle value on the screen


LAngleout.Format ("Load angle: %.2f degree",LoadAngle);
pdc->TextOut(800,xOutput+260," ");
pdc->TextOut(800,xOutput+260,LAngleout);
pDoc->P1LAngleout = LAngleout;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Current (flowing from the send. to the rec. end): Calculate, convert and output
//// Ir = -Is because of short transmission line
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Current initialisations
complex <double> VrComplex, VsComplex, ZComplex;
CString Iout;

VrComplex = complex<double>(pDoc->Voltage*1000,0);

double RealSendingVoltage = pDoc->SendingVoltage * cos(LoadAngle*pi/180)*1000;


double ImagSendingVoltage = pDoc->SendingVoltage * sin(LoadAngle*pi/180)*1000;
VsComplex = complex<double>(RealSendingVoltage,ImagSendingVoltage);

ZComplex = complex<double>(pDoc->Resistance,pDoc->Reactance);

pDoc->IComplex = (VsComplex - VrComplex)/ZComplex; ///I in Ampere

// Conversion and output of the current on the screen


Iout.Format ("Current: %.1f A",(double) (abs(pDoc->IComplex)/sqrt(3)));
pdc->TextOut(800,xOutput+275," ");
pdc->TextOut(800,xOutput+275,Iout);
pDoc->P1Iout = Iout;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Ps, Qs and Ss (sending end): Calculate, convert and output
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Ps and Qs initialisations
float SP1, SP2, SPangle, SendingRealPower;
float SQ1, SQ2, SQangle, SendingReactivePower;
float SendingComplexPower;
CString Psout, Qsout, Ssout;

// Calculation of Ps, Qs and Ss


SP1 = (float) (MouseVcalc * pDoc->BaseVoltage)/pDoc->Impedance;
SPangle = (float) (cos(LoadAngle*pi/180+pDoc->AngleCalc));
SP2 = (float) ((MouseVcalc*MouseVcalc/pDoc->Impedance)*cos(pDoc->AngleCalc));
SendingRealPower = SP1*SPangle - SP2;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 108

SQ1 = SP1;
SQangle = (float) (sin(LoadAngle*pi/180+pDoc->AngleCalc));
SQ2 = (float) ((MouseVcalc*MouseVcalc/pDoc->Impedance)*sin(pDoc->AngleCalc));
SendingReactivePower = SQ1*SQangle - SQ2;

SendingComplexPower = (float)(sqrt(SendingRealPower*SendingRealPower +
SendingReactivePower*SendingReactivePower));

// Conversion and output of the Ps,Qs and Ss values on the screen


Psout.Format ("Ps: %.3f MW",SendingRealPower);
Qsout.Format ("Qs: %.3f MVar",SendingReactivePower);
Ssout.Format ("Ss: %.3f MVA",SendingComplexPower);

pdc->TextOut(800,xOutput+165," ");
pdc->TextOut(800,xOutput+165,Psout);
pDoc->P1Psout = Psout;
pdc->TextOut(800,xOutput+180," ");
pdc->TextOut(800,xOutput+180,Qsout);
pDoc->P1Qsout = Qsout;
pdc->TextOut(800,xOutput+195," ");
pdc->TextOut(800,xOutput+195,Ssout);
pDoc->P1Ssout = Ssout;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Phase angle and power factor (receiving end): Calculate, convert and output
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// PF initialisations
double AnglePF, PF;
CString PFout, AngleOut;

// Calculation of the power factor


PF = MousePcalc/Scalc;
AnglePF = (double) ((acos (PF))*180/pi); // in degree

// Conversion and output on the screen


if (MouseQcalc>=0)
{
if (PF < 0) PF = PF * (-1);

PFout.Format ("Power factor: %.2f lagging",PF);


pdc->TextOut(800,xOutput + 80," ");
pdc->TextOut(800,xOutput + 80,PFout);
pDoc->P1PFout = PFout;

AngleOut.Format ("Phase angle: %.2f degree",AnglePF);


pdc->TextOut(800,xOutput + 95," ");
pdc->TextOut(800,xOutput + 95,AngleOut);
pDoc->P1AngleOut = AngleOut;
}

else if (MouseQcalc<0)
{
if (PF < 0) PF = PF * (-1);
AnglePF = -AnglePF;

PFout.Format ("Power factor: %.2f leading",PF);


pdc->TextOut(800,xOutput + 80," ");
pdc->TextOut(800,xOutput + 80,PFout);
pDoc->P1PFout = PFout;

AngleOut.Format ("Phase angle: %.2f degree",AnglePF);


pdc->TextOut(800,xOutput + 95," ");
pdc->TextOut(800,xOutput + 95,AngleOut);
pDoc->P1AngleOut = AngleOut;
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 109

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Phase angle and power factor (sending end): Calculate, convert and output
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// PF initialisations
double AnglePFsend, PFsend;
CString PFSendout, AngleSendOut;

// Calculation of the power factor angle


PFsend = SendingRealPower/SendingComplexPower;
AnglePFsend = (double) ((acos (PFsend))*180/pi); // in degree

// Conversion and output on the screen


if (SendingReactivePower >= 0)
{
if (PFsend < 0) PFsend = PFsend * (-1);

PFSendout.Format ("Power factor: %.2f lagging",PFsend);


pdc->TextOut(800,xOutput+210," ");
pdc->TextOut(800,xOutput+210,PFSendout);
pDoc->P1PFSendout = PFSendout;

AngleSendOut.Format ("Phase angle: %.2f degree",AnglePFsend);


pdc->TextOut(800,xOutput+225," ");
pdc->TextOut(800,xOutput+225,AngleSendOut);
pDoc->P1AngleSendOut = AngleSendOut;
}

else if (SendingReactivePower < 0)


{
if (PFsend < 0) PFsend = PFsend * (-1);
AnglePFsend = -AnglePFsend;

PFSendout.Format ("Power factor: %.2f leading",PFsend);


pdc->TextOut(800,xOutput+210," ");
pdc->TextOut(800,xOutput+210,PFSendout);
pDoc->P1PFSendout = PFSendout;

AngleSendOut.Format ("Phase angle: %.2f degree",AnglePFsend);


pdc->TextOut(800,xOutput+225," ");
pdc->TextOut(800,xOutput+225,AngleSendOut);
pDoc->P1AngleSendOut = AngleSendOut;
}
}

CScrollView::OnMouseMove(nFlags, point);
}

// This function is called when the button 'constant power factor' is pressed
void CCircleDiagramView::OnPowerFactor()
{
// TODO: Add your control notification handler code here

// Call Sconstant-DialogBox
CCircleDiagramDoc* pDoc = GetDocument();

if (pDoc->StartSwitch)
{
PowerFactor NFactor;
NFactor.SetDocPointer(GetDocument());
NFactor.DoModal();
CScrollView::OnInitialUpdate();
}
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 110

// This function is called when the left mouse button is pressed


void CCircleDiagramView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CCircleDiagramDoc* pDoc = GetDocument();

if (pDoc->StartSwitch)
{
pDoc->MarkSwitch = TRUE; // for zooming if a Mark (P1) is on screen; indicates if
// a new mark is selected or zoom with old mark.
pDoc->MarkDelete = TRUE; // indicates that the rigth mouse button was pressed ->
// CLEAR SCREEN

pDoc->DevicePosition = GetDeviceScrollPosition( );
pDoc->Mark_x = point.x;
pDoc->Mark_y = point.y;

P1Out NameP1Out;
NameP1Out.SetDocPointer(pDoc);
NameP1Out.SaveValues();

CScrollView::OnInitialUpdate();
}

CScrollView::OnLButtonUp(nFlags, point);
}

// This function is called when the right mouse button is pressed -> CLEAR P1
void CCircleDiagramView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CCircleDiagramDoc* pDoc = GetDocument();

if (pDoc->StartSwitch)
{
CCircleDiagramDoc* pDoc = GetDocument();
pDoc->MarkDelete = FALSE;

CScrollView::OnInitialUpdate();
}

CScrollView::OnRButtonDown(nFlags, point);
}

// This function is called when the 'PrintScreen' button is pressed


void CCircleDiagramView::OnPrintScreen()
{
// TODO: Add your control notification handler code here

//Call PrintDlg-DialogBox
PrintScreenDlg NPrintScreen;
NPrintScreen.DoModal();

CCircleDiagramDoc* pDoc = GetDocument();


if (pDoc->StartSwitch) CScrollView::OnInitialUpdate();
}

// This function updates the screen if vertical scroll-bar is used


void CCircleDiagramView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default

CScrollView::OnInitialUpdate();

CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);


}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 111

// This function updates the screen if horizontal scroll-bar is used


void CCircleDiagramView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default

CScrollView::OnInitialUpdate();

CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);


}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 112

10.4 Class Draw Axis

// DrawAxis.h: interface for the DrawAxis class.


// This class is called from the class CCircleDiagramView. It
// calculates and draws the axis, the circles and the poer factor line
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CCircleDiagramDoc;

class DrawAxis
{
public:

int y;
int x;
int yV;
int xV;

float BasePower;

void SetDocPointer(CCircleDiagramDoc*);
void pDCPointer(CDC*);
void DrawPowerFactorLine(int zoom);
void DrawMark(int zoom);
void DrawPQaxis(int zoom);
void DrawCircles(int zoom, double radius, CString circleName,int Colour);
void DrawSCircle(int zoom, double radius);

DrawAxis();
virtual ~DrawAxis();

protected:

CCircleDiagramDoc *pDoc;
CDC *pDC;
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 113

// DrawAxis.cpp: implementation of the DrawAxis class.


// This class is called from the class CCircleDiagramView. It
// calculates and draws the axis, the circles and the poer factor line
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DrawAxis.h"
#include "MainFrm.h"
#include "Circle DiagramDoc.h"
#include <afxwin.h>
#include <math.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

DrawAxis::DrawAxis()
{

DrawAxis::~DrawAxis()
{

// Copies pointer to CircleDiagramDoc


void DrawAxis::SetDocPointer(CCircleDiagramDoc *DocPtr)
{
pDoc = DocPtr;
}

// Copies pointer to pDC


void DrawAxis::pDCPointer(CDC* pDCPointer)
{
pDC = pDCPointer;
}

// Draws the PQ-axis and the V-axis and scales them


void DrawAxis::DrawPQaxis(int zoom)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// PQ axis /////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Initialisation of the origin


x=1500;
y=1000;

CPen newPen(PS_DASHDOTDOT,2,(COLORREF) 0);


pDC->SelectObject(&newPen);

pDC->MoveTo(x-215*zoom,y); pDC->LineTo(x+215*zoom,y); // Draw x-coordinate


pDC->MoveTo(x-215*zoom,y); pDC->LineTo(x-207*zoom,y-4*zoom); // Draw left arrow
pDC->MoveTo(x-215*zoom,y); pDC->LineTo(x-207*zoom,y+4*zoom);
pDC->MoveTo(x+215*zoom,y); pDC->LineTo(x+207*zoom,y-4*zoom); // Draw right arrow
pDC->MoveTo(x+215*zoom,y); pDC->LineTo(x+207*zoom,y+4*zoom);

pDC->MoveTo(x,y-215*zoom); pDC->LineTo(x,y+215*zoom); // Draw y-coordinate


pDC->MoveTo(x,y-215*zoom); pDC->LineTo(x-4*zoom,y-207*zoom); // Draw top arrow

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 114

pDC->MoveTo(x,y-215*zoom); pDC->LineTo(x+4*zoom,y-207*zoom);
pDC->MoveTo(x,y+215*zoom); pDC->LineTo(x-4*zoom,y+207*zoom); // Draw bottom arrow
pDC->MoveTo(x,y+215*zoom); pDC->LineTo(x+4*zoom,y+207*zoom);

pDC->SelectStockObject(BLACK_PEN);

// Scale P/Q axis


CString axis_value;

CFont Text_Achse;
Text_Achse.CreatePointFont(70*zoom, "Arial", pDC);
CFont* pOldFont = pDC->SelectObject(&Text_Achse);
pDC->SetBkMode(TRANSPARENT);

pDC->TextOut(x-250*zoom,y-6*zoom,"P [p.u.]");
pDC->TextOut(x-16*zoom,y-228*zoom,"Q [p.u.]");

pDC->TextOut(x-7*zoom,y,"0");

for (int i = 40; i<240; i=i+40)


{
if (i==40) axis_value = "0.2";
if (i==80) axis_value = "0.4";
if (i==120) axis_value = "0.6";
if (i==160) axis_value = "0.8";
if (i==200) axis_value = "1.0";

pDC->MoveTo(x-3*zoom,y-i*zoom); pDC->LineTo(x+3*zoom,y-i*zoom);
pDC->TextOut(x-17*zoom,y-(i+5)*zoom,axis_value);

pDC->MoveTo(x-i*zoom,y-3*zoom); pDC->LineTo(x-i*zoom,y+3*zoom);
pDC->TextOut(x-(i+6)*zoom,y+2*zoom,axis_value);
}

for ( i = 40; i<240; i=i+40)


{
if (i==40) axis_value = "-0.2";
if (i==80) axis_value = "-0.4";
if (i==120) axis_value = "-0.6";
if (i==160) axis_value = "-0.8";
if (i==200) axis_value = "-1.0";

pDC->MoveTo(x-3*zoom,y+i*zoom); pDC->LineTo(x+3*zoom,y+i*zoom);
pDC->TextOut(x-20*zoom,y+(i-5)*zoom,axis_value);

pDC->MoveTo(x+i*zoom,y-3*zoom); pDC->LineTo(x+i*zoom,y+3*zoom);
pDC->TextOut(x+(i-9)*zoom,y+2*zoom,axis_value);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// V axis /////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

double pi = 3.1415926535;

// Calculate the new coordinates of the V-origin


double xAbstandVAchse = 201*cos(pDoc->AngleCalc);
double yAbstandVAchse = 201*sin(pDoc->AngleCalc);
xV = x+(int)xAbstandVAchse*zoom;
pDoc->XVoltage = xV;
yV = y+(int)yAbstandVAchse*zoom;
pDoc->YVoltage = yV;

pDC->SelectObject(&newPen);

pDC->MoveTo(xV-215*zoom,yV); pDC->LineTo(xV+215*zoom,yV); // Draw x-coordinate


pDC->MoveTo(xV-215*zoom,yV); pDC->LineTo(xV-207*zoom,yV-4*zoom); // Draw left arrow

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 115

pDC->MoveTo(xV-215*zoom,yV); pDC->LineTo(xV-207*zoom,yV+4*zoom);
pDC->MoveTo(xV+215*zoom,yV); pDC->LineTo(xV+207*zoom,yV-4*zoom); // Draw right arrow
pDC->MoveTo(xV+215*zoom,yV); pDC->LineTo(xV+207*zoom,yV+4*zoom);

pDC->MoveTo(xV,yV-215*zoom); pDC->LineTo(xV,yV+215*zoom); // Draw y-coordinate


pDC->MoveTo(xV,yV-215*zoom); pDC->LineTo(xV-4*zoom,yV-207*zoom); // Draw top arrow
pDC->MoveTo(xV,yV-215*zoom); pDC->LineTo(xV+4*zoom,yV-207*zoom);
pDC->MoveTo(xV,yV+215*zoom); pDC->LineTo(xV-4*zoom,yV+207*zoom); // Draw bottom arrow
pDC->MoveTo(xV,yV+215*zoom); pDC->LineTo(xV+4*zoom,yV+207*zoom);

pDC->SelectStockObject(BLACK_PEN);

pDC->TextOut(xV-250*zoom,yV-6*zoom,"V [p.u.]");
pDC->TextOut(xV-16*zoom,yV-228*zoom,"V [p.u.]");

// Scale V Axis
pDC->TextOut(xV-7*zoom,yV,"0");

for ( i = 40; i<240; i=i+40)


{
if (i==40) axis_value = "0.2";
if (i==80) axis_value = "0.4";
if (i==120) axis_value = "0.6";
if (i==160) axis_value = "0.8";
if (i==200) axis_value = "1.0";

pDC->MoveTo(xV-3*zoom,yV+i*zoom); pDC->LineTo(xV+3*zoom,yV+i*zoom);
pDC->TextOut(xV-17*zoom,yV+(i-5)*zoom,axis_value);

pDC->MoveTo(xV-3*zoom,yV-i*zoom); pDC->LineTo(xV+3*zoom,yV-i*zoom);
pDC->TextOut(xV-17*zoom,yV-(i+5)*zoom,axis_value);

pDC->MoveTo(xV+i*zoom,yV-3*zoom); pDC->LineTo(xV+i*zoom,yV+3*zoom);
pDC->TextOut(xV+(i-6)*zoom,yV+2*zoom,axis_value);

pDC->MoveTo(xV-i*zoom,yV-3*zoom); pDC->LineTo(xV-i*zoom,yV+3*zoom);
pDC->TextOut(xV-(i+6)*zoom,yV+2*zoom,axis_value);
}
}

// Draws the constant Vr-circles


void DrawAxis::DrawCircles(int zoom, double radius, CString circleName, int Colour)
{
CPen newPen(PS_SOLID,1,RGB(Colour,0,0));
pDC->SelectObject(&newPen);

int i;
int xcircle1, ycircle1,xcircle2, ycircle2;
double pi = 3.1415926535;
double circle[2][181];
double angle;
// The angle StoreAngle is (90-theta); theta=artan(X/R)
double StoreAngle = (double) (90-(pDoc->AngleCalc)*180/pi);

// Calculates and stores datas of the circle in array 'circle'


for (i = 0; i<181; i++)
{
angle = (i-StoreAngle)*pi/180; // The angle is counting from i-90+theta
// to i+90-theta
circle[0][i] = radius*cos(angle)*zoom;
circle[1][i] = radius*sin(angle)*zoom;
}

// Draw circle
int DrawVar = 1;
if (Colour == 0) DrawVar = 2; // For black circles draw intercepted lines
if (Colour == 255) DrawVar = 1; // For red circles draw normal lines

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 116

for (i = 1; i<181; i=i+DrawVar)


{
xcircle1 = (int) circle[0][i-1];
ycircle1 = (int) circle[1][i-1];

xcircle2 = (int) circle[0][i];


ycircle2 = (int) circle[1][i];

pDC->MoveTo(xV-xcircle1,yV-ycircle1);
pDC->LineTo(xV-xcircle2,yV-ycircle2);
}

// Text circle
int intradius = (int) radius;
pDC->SetTextColor (RGB(Colour,0,0));
pDC->TextOut(xV+50*zoom,yV-(intradius+2)*zoom,circleName);
pDC->SetTextColor (RGB(0,0,0));
}

// Draws the constant receiving S-circle


void DrawAxis::DrawSCircle(int zoom, double radius)
{
int i;
int xcircle1, ycircle1,xcircle2, ycircle2;
double pi = 3.1415926535;
double circle[2][361];
double angle;
CString TextCircle;
CPen newPen(PS_SOLID,1,RGB(0,0,0));
pDC->SelectObject(&newPen);

// Calculates and stores datas of circle in array circle


for (i = 0; i<361; i++)
{
angle = i*pi/180;
circle[0][i] = radius*cos(angle)*zoom;
circle[1][i] = radius*sin(angle)*zoom;
}

// Draw circle
for (i = 1; i<361; i=i+2)
{
xcircle1 = (int) circle[0][i-1];
ycircle1 = (int) circle[1][i-1];

xcircle2 = (int) circle[0][i];


ycircle2 = (int) circle[1][i];

pDC->MoveTo(x-xcircle1,y-ycircle1);
pDC->LineTo(x-xcircle2,y-ycircle2);
}

// TextOut
if (radius>0)
{
TextCircle.Format ("Sr = %.2f MVA",radius*pDoc->P_DRAWFACTOR);
pDC->TextOut((int) (x-circle[0][135]+5*zoom),(int)(y-circle[1][135]),TextCircle);
}
}

// Draws the constant power factor lines


void DrawAxis::DrawPowerFactorLine(int zoom)
{
if (pDoc->PFSwitch)
{
// Initialisation
int PFx, PFy;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 117

float PFangle;
double pi = 3.1415926535;
CPen newPen(PS_SOLID,1,RGB(0,0,0));
pDC->SelectObject(&newPen);

// Calculation for power factor lagging (P and Q positive)


PFangle = (float) (acos (pDoc->PowerFactor)); //in radiant

PFx = (int) (200* cos(PFangle) * zoom);


PFy = (int) (200* sin(PFangle) * zoom);

// Draw power factor line


pDC->MoveTo(x,y);
pDC->LineTo(x-PFx,y-PFy);

// Text pf; conversion and output of the pf value


pDC->SetTextColor (RGB(0,0,0));
int intPowerFactor = (int)pDoc->PowerFactor;
CString PFname;

PFname.Format ("pf lagging: %.2f",pDoc->PowerFactor);


pDC->TextOut(x-PFx-35*zoom,y-PFy-15*zoom,PFname);

// Calculation for power factor lagging (P negative, Q positive)


PFx = (int) (-200* cos(PFangle) * zoom);
PFy = (int) (200* sin(PFangle) * zoom);

// Draw power factor line


pDC->MoveTo(x,y);
pDC->LineTo(x-PFx,y-PFy);

// Text pf; conversion and output of the pf value


PFname.Format ("pf lagging: %.2f",pDoc->PowerFactor);
pDC->TextOut(x-PFx-35*zoom,y-PFy-15*zoom,PFname);

// Calculation for power factor leading (P positive and Q negative)


PFangle = (float) (acos (pDoc->PowerFactor)); //in radiant

PFx = (int) (200* cos(PFangle) * zoom);


PFy = (int) (-200* sin(PFangle) * zoom);

// Draw power factor line


pDC->MoveTo(x,y);
pDC->LineTo(x-PFx,y-PFy);

// Text pf; conversion and output of the pf value


pDC->SetTextColor (RGB(0,0,0));
intPowerFactor = (int)pDoc->PowerFactor;

PFname.Format ("pf leading: %.2f",pDoc->PowerFactor);


pDC->TextOut(x-PFx-35*zoom,y-PFy+zoom,PFname);

// Calculation for power factor leading (P and Q negative)


PFx = (int) (-200* cos(PFangle) * zoom);
PFy = (int) (-200* sin(PFangle) * zoom);

// Draw power factor line


pDC->MoveTo(x,y);
pDC->LineTo(x-PFx,y-PFy);

// Text pf; conversion and output of the pf value


PFname.Format ("pf leading: %.2f",pDoc->PowerFactor);
pDC->TextOut(x-PFx-35*zoom,y-PFy+zoom,PFname);
}
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 118

// Draws the Vs and Vr arrows if left mouse button was pressed


void DrawAxis::DrawMark(int zoom)
{
if(pDoc->MarkDelete)
{
int Mark_x,Mark_y;

if (pDoc->MarkSwitch)
{
Mark_x = (x-(pDoc->DevicePosition.x + pDoc->Mark_x));
Mark_y = (y-(pDoc->DevicePosition.y + pDoc->Mark_y));
pDoc->MarkZoom = 1;
}

else
{
Mark_x = (int) ((x-(pDoc->DevicePosition.x + pDoc->Mark_x))*pDoc->MarkZoom);
Mark_y = (int) ((y-(pDoc->DevicePosition.y + pDoc->Mark_y))*pDoc->MarkZoom);
}

pDC->TextOut(x-Mark_x-6*zoom,y-Mark_y-10*zoom,"P1");

pDC->MoveTo(x,y);
pDC->LineTo(x-Mark_x,y-Mark_y);

pDC->MoveTo(xV,yV);
pDC->LineTo(x-Mark_x,y-Mark_y);
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 119

10.5 Class Input Dialog

class CCircleDiagramDoc;
class CCircleDiagramView;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Input dialog
// Class for the Input-Dlg-Box
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class Input : public CDialog


{
// Construction
public:
int IndicationCheckBox; // tells which checkbox is pressed, is 1 for checkBoxRX,
// 2 for checkBoxZ, 3 for checkBoxPSCC and 4 for checkBoxFault

void SetDocPointer(CCircleDiagramDoc*);
void SetViewPointer(CCircleDiagramView*);

Input(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(Input)
enum { IDD = IDD_INPUT };
float m_BaseVoltage;
float m_FaultLevel;
float m_Reactance;
float m_PCSS;
float m_Resistance;
float m_Voltage;
float m_XRratio1;
float m_Angle;
float m_Impedance;
float m_XRratio2;
BOOL m_CheckRX;
BOOL m_CheckZ;
BOOL m_CheckPSCC;
BOOL m_CheckFault;
//}}AFX_DATA

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Input)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

CCircleDiagramDoc *pDoc;
CCircleDiagramView *pView;

// Generated message map functions


//{{AFX_MSG(Input)
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnChangeVoltage();
afx_msg void OnCheckRx();
afx_msg void OnCheckZ();
afx_msg void OnCheckPscc();
afx_msg void OnCHECKFault();

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 120

afx_msg void OnChangeResistance();


afx_msg void OnChangeReactance();
afx_msg void OnChangeImpedance();
afx_msg void OnChangeAngle();
afx_msg void OnChangePscc();
afx_msg void OnChangeXRratio1();
afx_msg void OnChangeXRratio2();
afx_msg void OnChangeFaultlevel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 121

// Input.cpp : implementation file


// Class for the Input-Dlg-Box
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "Input.h"
#include "Circle DiagramDoc.h"
#include "Circle DiagramView.h"
#include "Calculations.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Input dialog
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Input::Input(CWnd* pParent /*=NULL*/)


: CDialog(Input::IDD, pParent)
{
//{{AFX_DATA_INIT(Input)
m_BaseVoltage = 0.0f;
m_FaultLevel = 0.0f;
m_Reactance = 0.0f;
m_PCSS = 0.0f;
m_Resistance = 0.0f;
m_Voltage = 0.0f;
m_XRratio1 = 0.0f;
m_Angle = 0.0f;
m_Impedance = 0.0f;
m_XRratio2 = 0.0f;
m_CheckFault = FALSE;
m_CheckPSCC = FALSE;
m_CheckRX = FALSE;
m_CheckZ = FALSE;
//}}AFX_DATA_INIT
}

void Input::DoDataExchange(CDataExchange* pDX)


{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Input)
DDX_Text(pDX, IDC_BASEVOLTAGE, m_BaseVoltage);
DDX_Text(pDX, IDC_FAULTLEVEL, m_FaultLevel);
DDX_Text(pDX, IDC_Reactance, m_Reactance);
DDX_Text(pDX, IDC_PSCC, m_PCSS);
DDV_MinMaxFloat(pDX, m_PCSS, 0.f, 1.e+006f);
DDX_Text(pDX, IDC_RESISTANCE, m_Resistance);
DDX_Text(pDX, IDC_VOLTAGE, m_Voltage);
DDV_MinMaxFloat(pDX, m_Voltage, 0.f, 1000.f);
DDX_Text(pDX, IDC_XRratio1, m_XRratio1);
DDX_Text(pDX, IDC_Angle, m_Angle);
DDV_MinMaxFloat(pDX, m_Angle, 0.f, 90.f);
DDX_Text(pDX, IDC_Impedance, m_Impedance);
DDX_Text(pDX, IDC_XRratio2, m_XRratio2);
DDX_Check(pDX, IDC_CHECK_RX, m_CheckRX);
DDX_Check(pDX, IDC_CHECK_Z, m_CheckZ);
DDX_Check(pDX, IDC_CHECK_PSCC, m_CheckPSCC);
DDX_Check(pDX, IDC_CHECK_Fault, m_CheckFault);
//}}AFX_DATA_MAP
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 122

BEGIN_MESSAGE_MAP(Input, CDialog)
//{{AFX_MSG_MAP(Input)
ON_EN_CHANGE(IDC_VOLTAGE, OnChangeVoltage)
ON_BN_CLICKED(IDC_CHECK_RX, OnCheckRx)
ON_BN_CLICKED(IDC_CHECK_Z, OnCheckZ)
ON_BN_CLICKED(IDC_CHECK_PSCC, OnCheckPscc)
ON_BN_CLICKED(IDC_CHECK_Fault, OnCHECKFault)
ON_EN_CHANGE(IDC_RESISTANCE, OnChangeResistance)
ON_EN_CHANGE(IDC_Reactance, OnChangeReactance)
ON_EN_CHANGE(IDC_Impedance, OnChangeImpedance)
ON_EN_CHANGE(IDC_Angle, OnChangeAngle)
ON_EN_CHANGE(IDC_PSCC, OnChangePscc)
ON_EN_CHANGE(IDC_XRratio1, OnChangeXRratio1)
ON_EN_CHANGE(IDC_XRratio2, OnChangeXRratio2)
ON_EN_CHANGE(IDC_FAULTLEVEL, OnChangeFaultlevel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Input message handlers
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Copies pointer to CircleDiagramDoc


void Input::SetDocPointer(CCircleDiagramDoc *DocPtr)
{
pDoc = DocPtr;
}

// Copies pointer to CircleDiagramView


void Input::SetViewPointer(CCircleDiagramView *ViewPtr)
{
pView = ViewPtr;
}

// Initialisation of the Input-Dialog-Box-values


BOOL Input::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here

// Get data from document or set data default


m_BaseVoltage = pDoc->BaseVoltage;
m_FaultLevel = pDoc->FaultLevel;
m_Reactance = pDoc->Reactance;
m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_Voltage = pDoc->Voltage;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;
m_Impedance = pDoc->Impedance;
m_XRratio2 = pDoc->XRratio;

// Initialise all edit-windows


GetDlgItem(IDC_BASEVOLTAGE)->EnableWindow(FALSE);
GetDlgItem(IDC_RESISTANCE)->EnableWindow(TRUE);
GetDlgItem(IDC_Reactance)->EnableWindow(TRUE);
GetDlgItem(IDC_Impedance)->EnableWindow(FALSE);
GetDlgItem(IDC_Angle)->EnableWindow(FALSE);
GetDlgItem(IDC_PSCC)->EnableWindow(FALSE);
GetDlgItem(IDC_XRratio1)->EnableWindow(FALSE);
GetDlgItem(IDC_FAULTLEVEL)->EnableWindow(FALSE);
GetDlgItem(IDC_XRratio2)->EnableWindow(FALSE);

// Initialise check boxes

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 123

m_CheckRX = TRUE;
m_CheckZ = FALSE;
m_CheckPSCC = FALSE;
m_CheckFault = FALSE;

// Initialise IndicationCheckBox
IndicationCheckBox = 1;

UpdateData(FALSE);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

// This function is executed if the 'OK'-button on the Input-Dialog-Box is


// pressed. Saves datas and calles CallDrawUpdate.
void Input::OnOK()
{
// TODO: Add extra validation here

UpdateData(TRUE);

pDoc->BaseVoltage = m_BaseVoltage;
pDoc->FaultLevel = m_FaultLevel;
pDoc->Reactance = m_Reactance;
pDoc->PCSS = m_PCSS;
pDoc->Resistance = m_Resistance;
pDoc->Voltage = m_Voltage;
if (m_CheckPSCC == TRUE) pDoc->XRratio = m_XRratio1;
pDoc->Angle = m_Angle;
pDoc->Impedance = m_Impedance;
if (m_CheckFault == TRUE) pDoc->XRratio = m_XRratio2;
pDoc->IndicationCheckBox = IndicationCheckBox;

CDialog::OnOK();

pView->CallDrawUpdate();
}

// This function is executed if the 'Cancel'-button on the Input-Dialog-Box is


// pressed. It calles CallInitialUpdate.
void Input::OnCancel()
{
// TODO: Add extra cleanup here

CDialog::OnCancel();

pView->CallInitialUpdate();
}

// This function is called if the value in the voltage edit-box is changed


void Input::OnChangeVoltage()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
m_BaseVoltage = m_Voltage;
pDoc->Voltage = m_Voltage;

if (IndicationCheckBox == 1)
{
pDoc->IndicationCheckBox = IndicationCheckBox;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 124

pDoc->Resistance = m_Resistance;
pDoc->Reactance = m_Reactance;
}

if (IndicationCheckBox == 2)
{
pDoc->IndicationCheckBox = IndicationCheckBox;
pDoc->Impedance = m_Impedance;
pDoc->Angle = m_Angle;
}

if (IndicationCheckBox == 3)
{
pDoc->IndicationCheckBox = IndicationCheckBox;
pDoc->PCSS = m_PCSS;
pDoc->XRratio = m_XRratio1;
}

if (IndicationCheckBox == 4)
{
pDoc->IndicationCheckBox = IndicationCheckBox;
pDoc->FaultLevel = m_FaultLevel;
pDoc->XRratio = m_XRratio2;
}

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_Reactance = pDoc->Reactance;
m_FaultLevel = pDoc->FaultLevel;
m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;
m_Impedance = pDoc->Impedance;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

// This function is executed if check-box 'RX' is marked.


void Input::OnCheckRx()
{
// TODO: Add your control notification handler code here

UpdateData (TRUE); // Fetches datas from the dialog box

if (m_CheckRX==TRUE)
{
m_Resistance = pDoc->Resistance; GetDlgItem(IDC_RESISTANCE)->EnableWindow(TRUE);
m_Reactance = pDoc->Reactance; GetDlgItem(IDC_Reactance)->EnableWindow(TRUE);
m_Impedance = pDoc->Impedance; GetDlgItem(IDC_Impedance)->EnableWindow(FALSE);
m_Angle = pDoc->Angle; GetDlgItem(IDC_Angle)->EnableWindow(FALSE);
m_PCSS = pDoc->PCSS; GetDlgItem(IDC_PSCC)->EnableWindow(FALSE);
m_XRratio1 = pDoc->XRratio; GetDlgItem(IDC_XRratio1)->EnableWindow(FALSE);
m_FaultLevel = pDoc->FaultLevel; GetDlgItem(IDC_FAULTLEVEL)->EnableWindow(FALSE);
m_XRratio2 = pDoc->XRratio; GetDlgItem(IDC_XRratio2)->EnableWindow(FALSE);

m_CheckZ = FALSE;
m_CheckPSCC = FALSE;
m_CheckFault = FALSE;

IndicationCheckBox = 1;
}
else
{

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 125

GetDlgItem(IDC_RESISTANCE)->EnableWindow(FALSE);
GetDlgItem(IDC_Reactance)->EnableWindow(FALSE);
}

UpdateData (FALSE);
}

// This function is executed if check-box 'Z' is marked.


void Input::OnCheckZ()
{
// TODO: Add your control notification handler code here

UpdateData (TRUE); // Fetches datas from the dialog box

if (m_CheckZ==TRUE)
{
m_Resistance = pDoc->Resistance; GetDlgItem(IDC_RESISTANCE)->EnableWindow(FALSE);
m_Reactance = pDoc->Reactance; GetDlgItem(IDC_Reactance)->EnableWindow(FALSE);
m_Impedance = pDoc->Impedance; GetDlgItem(IDC_Impedance)->EnableWindow(TRUE);
m_Angle = pDoc->Angle; GetDlgItem(IDC_Angle)->EnableWindow(TRUE);
m_PCSS = pDoc->PCSS; GetDlgItem(IDC_PSCC)->EnableWindow(FALSE);
m_XRratio1 = pDoc->XRratio; GetDlgItem(IDC_XRratio1)->EnableWindow(FALSE);
m_FaultLevel = pDoc->FaultLevel; GetDlgItem(IDC_FAULTLEVEL)->EnableWindow(FALSE);
m_XRratio2 = pDoc->XRratio; GetDlgItem(IDC_XRratio2)->EnableWindow(FALSE);

m_CheckRX = FALSE;
m_CheckPSCC = FALSE;
m_CheckFault = FALSE;

IndicationCheckBox = 2;
}
else
{
GetDlgItem(IDC_Impedance)->EnableWindow(FALSE);
GetDlgItem(IDC_Angle)->EnableWindow(FALSE);
}
UpdateData (FALSE);
}

// This function is executed if check-box 'PSCC' is marked.


void Input::OnCheckPscc()
{
// TODO: Add your control notification handler code here

UpdateData (TRUE); // Fetches datas from the dialog box

if (m_CheckPSCC == TRUE)
{
m_Resistance = pDoc->Resistance; GetDlgItem(IDC_RESISTANCE)->EnableWindow(FALSE);
m_Reactance = pDoc->Reactance; GetDlgItem(IDC_Reactance)->EnableWindow(FALSE);
m_Impedance = pDoc->Impedance; GetDlgItem(IDC_Impedance)->EnableWindow(FALSE);
m_Angle = pDoc->Angle; GetDlgItem(IDC_Angle)->EnableWindow(FALSE);
m_PCSS = pDoc->PCSS; GetDlgItem(IDC_PSCC)->EnableWindow(TRUE);
m_XRratio1 = pDoc->XRratio; GetDlgItem(IDC_XRratio1)->EnableWindow(TRUE);
m_FaultLevel = pDoc->FaultLevel; GetDlgItem(IDC_FAULTLEVEL)->EnableWindow(FALSE);
m_XRratio2 = pDoc->XRratio; GetDlgItem(IDC_XRratio2)->EnableWindow(FALSE);

m_CheckRX = FALSE;
m_CheckZ = FALSE;
m_CheckFault = FALSE;

IndicationCheckBox = 3;
}
else
{
GetDlgItem(IDC_PSCC)->EnableWindow(FALSE);
GetDlgItem(IDC_XRratio1)->EnableWindow(FALSE);

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 126

}
UpdateData (FALSE);
}

// This function is executed if check box 'Fault' is marked.


void Input::OnCHECKFault()
{
// TODO: Add your control notification handler code here

UpdateData (TRUE); // Fetches datas from the dialog box

if (m_CheckFault == TRUE)
{
m_Resistance = pDoc->Resistance; GetDlgItem(IDC_RESISTANCE)->EnableWindow(FALSE);
m_Reactance = pDoc->Reactance; GetDlgItem(IDC_Reactance)->EnableWindow(FALSE);
m_Impedance = pDoc->Impedance; GetDlgItem(IDC_Impedance)->EnableWindow(FALSE);
m_Angle = pDoc->Angle; GetDlgItem(IDC_Angle)->EnableWindow(FALSE);
m_PCSS = pDoc->PCSS; GetDlgItem(IDC_PSCC)->EnableWindow(FALSE);
m_XRratio1 = pDoc->XRratio; GetDlgItem(IDC_XRratio1)->EnableWindow(FALSE);
m_FaultLevel = pDoc->FaultLevel; GetDlgItem(IDC_FAULTLEVEL)->EnableWindow(TRUE);
m_XRratio2 = pDoc->XRratio; GetDlgItem(IDC_XRratio2)->EnableWindow(TRUE);

m_CheckRX = FALSE;
m_CheckZ = FALSE;
m_CheckPSCC = FALSE;

IndicationCheckBox = 4;
}
else
{
GetDlgItem(IDC_FAULTLEVEL)->EnableWindow(FALSE);
GetDlgItem(IDC_XRratio2)->EnableWindow(FALSE);
}
UpdateData (FALSE);
}

// This function is called if the value in the 'Resistance' edit-box is changed


void Input::OnChangeResistance()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
pDoc->Resistance = m_Resistance;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_FaultLevel = pDoc->FaultLevel;
m_Reactance = pDoc->Reactance;
m_PCSS = pDoc->PCSS;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;
m_Impedance = pDoc->Impedance;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

// This function is called if the value in the 'Reactance' edit-box is changed


void Input::OnChangeReactance()

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 127

{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
pDoc->Reactance = m_Reactance;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_FaultLevel = pDoc->FaultLevel;
m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;
m_Impedance = pDoc->Impedance;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

// This function is called if the value in the 'Impedance' edit-box is changed


void Input::OnChangeImpedance()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
pDoc->Impedance = m_Impedance;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_FaultLevel = pDoc->FaultLevel;
m_Reactance = pDoc->Reactance;
m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

// This function is called if the value in the 'Z angle' edit-box is changed
void Input::OnChangeAngle()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 128

pDoc->Angle = m_Angle;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_FaultLevel = pDoc->FaultLevel;
m_Reactance = pDoc->Reactance;
m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_Impedance = pDoc->Impedance;
m_XRratio1 = pDoc->XRratio;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

// This function is called if the value in the 'PSCC' edit-box is changed


void Input::OnChangePscc()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
pDoc->PCSS = m_PCSS;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_FaultLevel = pDoc->FaultLevel;
m_Reactance = pDoc->Reactance;
m_Resistance = pDoc->Resistance;
m_Impedance = pDoc->Impedance;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

// This function is called if the value in the 'XRratio1' edit-box is changed


void Input::OnChangeXRratio1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
pDoc->XRratio = m_XRratio1;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_FaultLevel = pDoc->FaultLevel;
m_Reactance = pDoc->Reactance;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 129

m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_Impedance = pDoc->Impedance;
m_Angle = pDoc->Angle;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

// This function is called if the value in the 'XRratio2' edit-box is changed


void Input::OnChangeXRratio2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
pDoc->XRratio = m_XRratio2;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_FaultLevel = pDoc->FaultLevel;
m_Reactance = pDoc->Reactance;
m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_Impedance = pDoc->Impedance;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;

UpdateData(FALSE);
}

// This function is called if the value in the 'Fault level' edit-box is changed
void Input::OnChangeFaultlevel()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here

UpdateData(TRUE);
pDoc->FaultLevel = m_FaultLevel;
pDoc->IndicationCheckBox = IndicationCheckBox;

CCalculations CalcDlg;
CalcDlg.SetDocPointer(pDoc);
CalcDlg.DoCalculation();

m_Reactance = pDoc->Reactance;
m_PCSS = pDoc->PCSS;
m_Resistance = pDoc->Resistance;
m_Impedance = pDoc->Impedance;
m_XRratio1 = pDoc->XRratio;
m_Angle = pDoc->Angle;
m_XRratio2 = pDoc->XRratio;

UpdateData(FALSE);
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 130

10.6 Class MainFrm

// MainFrm.h : interface of the CMainFrame class


// This file contains the frame class CMainFrame, which is derived from
// CFrameWnd and controls all SDI frame features.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CMainFrame : public CFrameWnd


{

protected: // create from serialization only


CMainFrame();
DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL

// Implementation
public:

virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected: // control bar embedded members


CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CReBar m_wndReBar;
CDialogBar m_wndDlgBar;

// Generated message map functions


protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 131

// MainFrm.cpp : implementation of the CMainFrame class


// This file contains the frame class CMainFrame, which is derived from
// CFrameWnd and controls all SDI frame features.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "Input.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CMainFrame
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =


{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

CMainFrame::CMainFrame()
{
// TODO: add member initialization code here

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)


{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

if (!m_wndToolBar.CreateEx(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndDlgBar.Create(this, IDR_MAINFRAME,
CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
{
TRACE0("Failed to create dialogbar\n");

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 132

return -1; // fail to create


}

if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar(&m_wndToolBar) ||
!m_wndReBar.AddBar(&m_wndDlgBar))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}

if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}

// TODO: Remove this if you don't want tool tips


m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY);

return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)


{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

// Size the window to the screen size and center it


cs.cy = ::GetSystemMetrics(SM_CYSCREEN);
cs.cx = ::GetSystemMetrics(SM_CXSCREEN);
cs.y = ((cs.cy ) - cs.cy) / 2;
cs.x = ((cs.cx ) - cs.cx) / 2;

return TRUE;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const


{
CFrameWnd::Dump(dc);
}

#endif //_DEBUG

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 133

10.7 Class P1Out

// P1Out.h: interface for the P1Out class.


// This class is responsible for the output of the calculated datas
// on the screen after the left mouse button was pressed
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CCircleDiagramDoc;

class P1Out
{
public:

void SaveValues();

void SetDocPointer(CCircleDiagramDoc*);
void ScreenOutP1(CDC* pDC);

P1Out();
virtual ~P1Out();

protected:
CCircleDiagramDoc *pDoc;
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 134

// P1Out.cpp: implementation of the P1Out class.


// This class is responsible for the output of the calculated datas
// on the screen after the left mouse button was pressed
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "P1Out.h"
#include "Circle DiagramDoc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

P1Out::P1Out()
{

P1Out::~P1Out()
{

// Copies pointer to CircleDiagramDoc


void P1Out::SetDocPointer(CCircleDiagramDoc *DocPtr)
{
pDoc = DocPtr;
}

// Saves the values if mouse button is pressed


void P1Out::SaveValues()
{
pDoc->SaveP1AngleSendOut = pDoc->P1AngleSendOut;
pDoc->SaveP1PFSendout = pDoc->P1PFSendout;
pDoc->SaveP1Ssout = pDoc->P1Ssout ;
pDoc->SaveP1Qsout = pDoc->P1Qsout;
pDoc->SaveP1Psout = pDoc->P1Psout;
pDoc->SaveP1LAngleout = pDoc->P1LAngleout;
pDoc->SaveP1Vout = pDoc->P1Vout ;
pDoc->SaveP1AngleOut = pDoc->P1AngleOut;
pDoc->SaveP1PFout = pDoc->P1PFout;
pDoc->SaveP1Pout = pDoc->P1Pout ;
pDoc->SaveP1Qout = pDoc->P1Qout;
pDoc->SaveP1Sout = pDoc->P1Sout ;
pDoc->SaveP1VrOut = pDoc->P1VrOut;
pDoc->SaveP1Iout = pDoc->P1Iout;
}

// Output of the Mark (P1) values on the screen


void P1Out::ScreenOutP1(CDC* pDC)
{
if(pDoc->MarkDelete)
{
int xOutput = 15;
pDC->TextOut(1500 + 800,xOutput," ");
pDC->TextOut(800,xOutput,"P1 - receiving-end values:");

pDC->TextOut(800,xOutput + 20," ");


pDC->TextOut(800,xOutput + 20,pDoc->SaveP1VrOut);

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 135

pDC->TextOut(800,xOutput + 35," ");


pDC->TextOut(800,xOutput + 35,pDoc->SaveP1Pout);

pDC->TextOut(800,xOutput + 50," ");


pDC->TextOut(800,xOutput + 50,pDoc->SaveP1Qout);

pDC->TextOut(800,xOutput + 65," ");


pDC->TextOut(800,xOutput + 65,pDoc->SaveP1Sout);

pDC->TextOut(800,xOutput + 80," ");


pDC->TextOut(800,xOutput + 80,pDoc->SaveP1PFout);

pDC->TextOut(800,xOutput + 95," ");


pDC->TextOut(800,xOutput + 95,pDoc->SaveP1AngleOut);

pDC->TextOut(800,xOutput+130," ");
pDC->TextOut(800,xOutput+130,"P1 - sending-end values:");

pDC->TextOut(800,xOutput+150," ");
pDC->TextOut(800,xOutput+150,pDoc->SaveP1Vout);

pDC->TextOut(800,xOutput+260," ");
pDC->TextOut(800,xOutput+260,pDoc->SaveP1LAngleout);

pDC->TextOut(800,xOutput+165," ");
pDC->TextOut(800,xOutput+165,pDoc->SaveP1Psout);

pDC->TextOut(800,xOutput+180," ");
pDC->TextOut(800,xOutput+180,pDoc->SaveP1Qsout);

pDC->TextOut(800,xOutput+195," ");
pDC->TextOut(800,xOutput+195,pDoc->SaveP1Ssout);

pDC->TextOut(800,xOutput+210," ");
pDC->TextOut(800,xOutput+210,pDoc->SaveP1PFSendout);

pDC->TextOut(800,xOutput+225," ");
pDC->TextOut(800,xOutput+225,pDoc->SaveP1AngleSendOut);

pDC->TextOut(800,xOutput+210," ");
pDC->TextOut(800,xOutput+210,pDoc->SaveP1PFSendout);

pDC->TextOut(800,xOutput+225," ");
pDC->TextOut(800,xOutput+225,pDoc->SaveP1AngleSendOut);

pDC->TextOut(800,xOutput+275," ");
pDC->TextOut(800,xOutput+275,pDoc->SaveP1Iout);
}
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 136

10.8 Class PowerFactor Dialog

class CCircleDiagramDoc;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PowerFactor dialog
// Class for the PowerFactor-Dlg-Box
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class PowerFactor : public CDialog


{
// Construction
public:
PowerFactor(CWnd* pParent = NULL); // standard constructor

void SetDocPointer(CCircleDiagramDoc*);

// Dialog Data
//{{AFX_DATA(PowerFactor)
enum { IDD = IDD_POWERFACTOR };
float m_PowerFactor;
//}}AFX_DATA

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(PowerFactor)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

CCircleDiagramDoc *pDoc;

// Generated message map functions


//{{AFX_MSG(PowerFactor)
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual void OnCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 137

// PowerFactor.cpp : implementation file


// Class for the PowerFactor-Dlg-Box
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "PowerFactor.h"
#include "Circle DiagramDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PowerFactor dialog
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PowerFactor::PowerFactor(CWnd* pParent /*=NULL*/)


: CDialog(PowerFactor::IDD, pParent)
{
//{{AFX_DATA_INIT(PowerFactor)
m_PowerFactor = 0.0f;
//}}AFX_DATA_INIT
}

void PowerFactor::DoDataExchange(CDataExchange* pDX)


{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PowerFactor)
DDX_Text(pDX, IDC_PowerFactor, m_PowerFactor);
DDV_MinMaxFloat(pDX, m_PowerFactor, 0.f, 1.f);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(PowerFactor, CDialog)
//{{AFX_MSG_MAP(PowerFactor)

//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PowerFactor message handlers
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Initialisation of the DialogBox


BOOL PowerFactor::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here

pDoc->PFSwitch = TRUE;

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

// Copies pointer to Circle DiagramDoc


void PowerFactor::SetDocPointer(CCircleDiagramDoc *DocPtr)
{
pDoc = DocPtr;
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 138

// This function is called if the 'OK'-button of this dialog-box is pressed


void PowerFactor::OnOK()
{
// TODO: Add extra validation here

UpdateData(TRUE);
pDoc->PowerFactor = m_PowerFactor;

CDialog::OnOK();
}

// This function is called if the 'Cancel'-button of this dialog-box is pressed


void PowerFactor::OnCancel()
{
// TODO: Add extra cleanup here

pDoc->PFSwitch = FALSE;

CDialog::OnCancel();
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 139

10.9 Class PrintScreenDlg Dialog

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PrintScreenDlg dialog
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class PrintScreenDlg : public CDialog


{
// Construction
public:
PrintScreenDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(PrintScreenDlg)
enum { IDD = IDD_PrintDlg };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(PrintScreenDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

// Generated message map functions


//{{AFX_MSG(PrintScreenDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 140

// PrintScreenDlg.cpp : implementation file


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "PrintScreenDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PrintScreenDlg dialog
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

PrintScreenDlg::PrintScreenDlg(CWnd* pParent /*=NULL*/)


: CDialog(PrintScreenDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(PrintScreenDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}

void PrintScreenDlg::DoDataExchange(CDataExchange* pDX)


{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PrintScreenDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(PrintScreenDlg, CDialog)
//{{AFX_MSG_MAP(PrintScreenDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PrintScreenDlg message handlers
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 141

10.10 Class Sconstant Dialog

class CCircleDiagramDoc;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sconstant dialog
// Class for the Sconstant-Dlg-Box
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class Sconstant : public CDialog


{
// Construction
public:
Sconstant(CWnd* pParent = NULL); // standard constructor

void SetDocPointer(CCircleDiagramDoc*);

// Dialog Data
//{{AFX_DATA(Sconstant)
enum { IDD = IDD_SCONSTANT };
double m_RadiusSCircle;
double m_RadiusSCircle2;
double m_RadiusSCircle3;
//}}AFX_DATA

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Sconstant)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

CCircleDiagramDoc *pDoc;

// Generated message map functions


//{{AFX_MSG(Sconstant)
virtual void OnOK();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 142

// Sconstant.cpp : implementation file


// Class for the Sconstant-Dlg-Box
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Circle Diagram.h"
#include "Sconstant.h"
#include "Circle DiagramDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sconstant dialog
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Sconstant::Sconstant(CWnd* pParent /*=NULL*/)


: CDialog(Sconstant::IDD, pParent)
{
//{{AFX_DATA_INIT(Sconstant)
m_RadiusSCircle = 0.0;
m_RadiusSCircle2 = 0.0;
m_RadiusSCircle3 = 0.0;
//}}AFX_DATA_INIT
}

void Sconstant::DoDataExchange(CDataExchange* pDX)


{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Sconstant)
DDX_Text(pDX, IDC_RadiusSCircle, m_RadiusSCircle);
DDV_MinMaxDouble(pDX, m_RadiusSCircle, 0., 1000.);
DDX_Text(pDX, IDC_RadiusSCircle2, m_RadiusSCircle2);
DDV_MinMaxDouble(pDX, m_RadiusSCircle2, 0., 1000.);
DDX_Text(pDX, IDC_RadiusSCircle3, m_RadiusSCircle3);
DDV_MinMaxDouble(pDX, m_RadiusSCircle3, 0., 1000.);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(Sconstant, CDialog)
//{{AFX_MSG_MAP(Sconstant)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sconstant message handlers
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Copies pointer to Circle DiagramDoc


void Sconstant::SetDocPointer(CCircleDiagramDoc *DocPtr)
{
pDoc = DocPtr;
}

// This function is called if the 'OK'-button of this dialog-box is pressed


void Sconstant::OnOK()
{
// TODO: Add extra validation here

UpdateData(TRUE);

pDoc->Sradius = m_RadiusSCircle;

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 143

pDoc->Sradius2 = m_RadiusSCircle2;
pDoc->Sradius3 = m_RadiusSCircle3;

CDialog::OnOK();
}

BOOL Sconstant::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here

m_RadiusSCircle = pDoc->Sradius;
m_RadiusSCircle2 = pDoc->Sradius2;
m_RadiusSCircle3 = pDoc->Sradius3;

UpdateData(FALSE);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 144

10.11 Resource.h

// Microsoft Developer Studio generated include file.


// Used by Circle Diagram.rc
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#define IDD_ABOUTBOX 100


#define IDR_MAINFRAME 128
#define IDR_CIRCLETYPE 129
#define IDD_DIALOG1 130
#define IDD_INPUT 130
#define IDB_BITMAP1 132
#define IDD_SCONSTANT 135
#define IDD_PrintDlg 138
#define IDB_EA 146
#define IDB_ESG 149
#define IDB_ESG_klein 151
#define IDB_EA_klein 155
#define IDC_EDIT1 1000
#define IDC_PSCC 1000
#define IDC_PowerFactor 1000
#define IDC_EDIT2 1001
#define IDC_VOLTAGE 1001
#define IDC_RadiusSCircle 1001
#define IDC_PrintScreen 1001
#define IDC_EDIT3 1002
#define IDC_FAULTLEVEL 1002
#define IDC_RadiusSCircle2 1002
#define IDC_EDIT4 003
#define IDC_INDUCTANCE 1003
#define IDC_Reactance 1003
#define IDC_RadiusSCircle3 1003
#define IDC_EDIT5 1004
#define IDC_RESISTANCE 1004
#define IDC_EDIT6 1005
#define IDC_BASEVOLTAGE 1005
#define IDC_EDIT7 1006
#define IDC_XRratio 1006
#define IDC_ZOOMIN 1006
#define IDC_XRratio1 1006
#define IDC_ZOOMOUT 1007
#define IDC_XRratio2 1007
#define IDC_START 1008
#define IDC_Angle 1008
#define IDC_Impedance 1009
#define IDC_SCONSTANT 1009
#define IDC_SENDINGSCONST 1010
#define IDC_CHECK_RX 1015
#define IDC_CHECK_Z 1016
#define IDC_CHECK_Fault 1017
#define IDC_CHECK_PSCC 1018
#define IDC_PFlagging 1019
#define IDC_PFleading 1020
#define ID_BUTTON32773 32773
#define ID_BUTTON32779 32779
#define ID_START 32781

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Next default values for new objects
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz
Appendix 145

#define _APS_NEXT_RESOURCE_VALUE 156


#define _APS_NEXT_COMMAND_VALUE 32782
#define _APS_NEXT_CONTROL_VALUE 1025
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

“Modelling the Absorbence of the Rural Distribution Network for Connection of EGs” Robert Schmaranz

S-ar putea să vă placă și