Академический Документы
Профессиональный Документы
Культура Документы
=
( 2.2)
Where:
R is droop constant.
K is regulation constant [MW/Hz]
P
rated
is the rated active power [MW]
f
system
is the set point frequency [Hz]
For the island model used in the project the regulation constant K of the island can
becalculate as an example.
For G1, data from Table 2-3 is used:
Hz MW K
G
/ 192
00 , 50 02 . 0
00 , 192
2
=
=
For G2, data from Table 2-3 is used:
Hz MW K
G
/ 33 , 85
00 , 50 03 . 0
00 , 128
2
=
=
Resulting in:
Hz MW K K K
G G island
/ 33 , 277
3 2
= + =
For 1 Hz drop in the frequency a collective increase in power output from the two units
prime mover of 277,33 MW should expected.
When the defined island transitions from grid connection mode to island mode, it can be
expected that there is a power mismatch between generation and consumption. The
level of mismatch highly depends on pre-transition conditions. Steady state output
change for the generating units after transition can be calculated by equations 2.3 and
Theory
42
2.4, if the transition is simply treated as load change, either an increase or decrease of
consumption in the island.
P P P
pre Post
+ =
( 2.3)
island post pre
K f f P = ) (
( 2.4)
Where:
P
post
is the steady state power output after islanding transition, assuming droop control.
f
post
is the frequency after islanding.
P
pre
is the dispatched power of the generators before islanding transition.
f
pre
is the frequency before islanding transition.
P
is the power mismatch immediatly after islanding transition, after steady state is
reachedIt is contributed by the droop controllers.
Therefore, the steady state post islanding frequency deviation is calculated as follows
based on the power mismatch post islanding transition.
island
pre post
K
P
f f
=
( 2.5)
From equation 2.5, the required pre-islanding conditions can be evaluated based on the
steady state frequency limits (ISR region based only on steady state frequency). These
depend on the limits given in the grid codes of where the ISR would be implemented. In
Figure 2-13 gives an example of such ISR limits based on allowed max and min
frequency which are 50,2 Hz and 49,8 Hz respectively, these are also the limits used in
[1].However according to the nordic grid codes, the frequency should remain within
49.9 Hz 50,1 Hz for normal operation [10]. Other island values used in this example
are those given in Table 2-8. See appendix D for detailed calculations.
Theory
43
Figure 2-13: Example of theoretical ISR region for an example system, based only on steady state
frequency limits f
min
= 49,8Hz and f
max
=50,2Hz.
Not considered in the above plot is that, depending on the power dispatch of each
machine pre-islanding, it is possible that one of the generators have reached their power
limits, and would therefore influence the shape of the ISR.
The following two scenarios can be used to further illustrate the theoretical steady state
frequency after islanding. First example should illustrate a scenario where the defined
island is importing power before islanding where as the second example illustrates a
scenario where the island is exporting power before islanding.
1. First scenario, Here the power is being importet to the island before islanding
transition, shown in Figure 2-14:
Figure 2-14: Scenario 1: Simplified island with power import before islanding
Defined island:
K
island
=277,33 MW/Hz
G2 G3
Power imported from
external grid, 10MW
Load
106MW
57,6MW 38,4MW
Theory
44
Generators G2 and G3 within the defined island, are producing 57,6 MW and
38,4 MW, respectively, and the total load in the island (including any losses) is
106 MW. This means that the difference of 10 MW is being supplied from the
power system before islanding. Assuming 50 Hz grid frequency pre-transition,
the post islanding steady state frequency within the island can then be calculated
by equation 2.5 to be:
Hz f
post
96 , 49
33 , 277
00 , 10
00 , 50 = =
2. Second scenario, Here the power is being exportet from the island before
islanding transition, shown in Figure 2-15:
Figure 2-15: Scenario 2: Simplified island with power export before islanding
Generators G2 and G3 within the island, are producing 57,6 MW and 38,4 MW,
respectively, and the total load in the defined island (including any losses) is 80
MW. This means that the difference of 16MW is being supplied from the power
system before islanding. Still assuming 50 Hz grid frequency pre-transition, the
post islanding steady state frequency within the island can then be calculated
with equation 2.5 to be:
Hz f
post
06 , 50
33 , 277
00 , 16
00 , 50 =
=
Based on the above it is clear that when the island is exporting power, an increased
steady state frequency should be expected post-islanding. Reversely the steady state
frequency will be lower post-islanding if the island is importing power pre-islanding.
2.7.2 Frequency derivative
Generally a sudden increase or decrease in load or generation will influence the
frequency. The larger and faster the change is, the steeper frequency change should be
expected (higher derivative). Frequency derivatives are not covered in the Nordic grid
Defined island:
K
island
=277,33 MW/Hz
G2 G3
Power exported to
external grid, 16MW
Load
80MW
57,6MW 38,4MW
Theory
45
codes, but as suggested by this projects superviser a derivative limit of 2,5 Hz/s should
be set as a criterion for successful islanding. The derivative can be defined as follows.
From equation (2.6) the effects of imbalance electromagnetic and mechanical torque is
described. An expression for frequency derivative as a function of system inertia and
change in power can be derived.
e m a
m
T T T
dt
d
J = =
[11] ( 2.6)
c
system
system
E
f P
dt
df
=
2
( 2.7)
Where:
J is combined moment of inertia for generator and turbine [kgm
2
]
m
is the angular velocity of the rotor [rad/s]
T
a
is the accelerating torque [Nm]
T
m
is the mechanical torque [Nm]
T
e
is the electrical torque [Nm]
E
system
is the rotational energy stored in the system (kinetic energy) [MWs]
The rotational energy of the system should include all rotating machines connected
directly to the system. The rotating energy in the system can be summed up for each
machine as follows:
=
=
N
i
i i system
S H E
1
( 2.8)
From equations 2.7 and 2.8 it is clear that the frequency derivative is inversely
proportional to the rotational energy in the system and proportional to the change in
power. Therefore it can be assumed that higher inertia within the island should
contribute to lower frequency derivative.
2.7.3 Simplified Model of the Islanding System and Frequency
Response
To try to realize the influence of the different parameters on the islanding transition
response a transfer function of simplified model of the system can be created. In this
chapter a much simplified transfer function of an island will be introduced, so that the
frequency response of islanding transition can be analysed and compared to the
simulation results in later chapter.
Theory
46
The proposed simplified model can be seen in Figure 2-16.
Figure 2-16: Simplified block model of the system to analyse frequency behavior at islanding transition
The block model, in figure 2-16, can be rotated to show the frequency as function of the
power mismatch at the time of islanding. From the model, the transferfunction can also
be directly derived, see Figure 2-17.
Figure 2-17: Block model from Figure 2-16 rotated to directly analyse frecuency as a function of power
mistmatch at islanding.
The transferfunction for the simplified system is therefor as follows:
s H
K
s T s H
K
s T s H
P
island
a
ref island
a
out out
+
+
+
=
2
1
1
1
2
1
1
1
2
1
K_island
s T
a
+ 1
1
Hs 2
1
Droop control Prime Mover
System inertia
out
ref
+
+
+
Power mismatch at
islanding
P
-
K_island
s T
a
+ 1
1
Hs 2
1
Droop control Prime Mover System inertia
out
ref
-
+
+
+
Feedback of measured freq ()
Power mismatch at
islanding
P
Theory
47
As the main interested is in the frequency response, due to power mismatch, the
reference frequency can be set to zero and the function is thereby simplified. The
system frequency can then be superimposed on the response after calculation. The
resulting transferfunction can be seen in equation 2.9.
s H
K
s T
s H
P
island
a
out
+
+
=
2
1
1
1
1
2
1
( 2.9)
Now the frequency response of the simplified system can be analysed with respect to
the parameters of main interest. That is the time constant of the prime mover, the
regulation constant (derived directly from the droop control) and the system inertia.
As basics for the analysis there will be used the same data, as for the previous
calculations, which is the same model which will be used for the simulations in chapter
4. Due to the simplifications in this model, developed in this chapter, the analysis does
not include many of the parameters that otherwise would influence the system response
when islanding.
As an example the frequency behavior for an islanding transition can be looked at,
where the defined island is in power import mode, and immediatly after islanding there
will be a power mismatch of P = -10 MW as indicated in Figure 2-14.
Firstly the influence of the droop control can be visualized as shown in Figure 2-18. The
calculations are shown in appendix D.
Three different droop settings are tested:
1. Droop settings as set in the reference model R
G2
= 0,02 and R
G3
= 0,03.
2. Increased droop, to 200% , that is R
G2
= 0,04 and R
G3
= 0,06.
3. Increased droop, to 50% , that is R
G2
= 0,01 and R
G3
= 0,015.
Theory
48
Figure 2-18: Frequency response at islanding, with with 3 different of droop settings(R).
Figure 2-18 shows that the droop, which is inversely proportional to regulation constant,
will greatly influence the steady state frequency. This is also expected as the regulation
constant functions as proportional controller. Higher gains will giver faster response and
less steady state deviation.
Secondly the influence of different inertia can be analysed with this model.
Three different inertia values are tested:
1. Inertia as set in the reference model H
G2
= 4,125 s and H
G3
= 2,765 s.
2. Increased droop, to 200%, that is H
G2
= 8,250 s and H
G3
= 5,530 s.
3. Decreased droop, to 50%, that is H
G2
= 2,063 s and H
G3
= 1,383 s.
Theory
49
Figure 2-19: Frequency response at islanding, with with 3 different of inertia of generators(H).
From Figure 2-19 it is clear that increased inertia within the island will decrease the
frequency derivative and allow the frequency to settle faster to a steady state. The
steady state frequency will be the same for all cases as the regulating constant (K
island
) is
the same for all cases. In Table 2-2 critera for frequency derivitative is given and should
be lower than 2,5. From the above it is therefore clear that, if the inertia of the
generators (and all rotational energy) in the defined island is higher it would potentially
increase the ISR for the island.
Thirdly the influence of different prime mover time constant can be analysed with this
model.
Three different time constant values of the prime movers are tested:
1. Time constant as set in the reference model T
G2
= T
G3
= 0.2 s
2. Increased time constant, to 200% , that is T
G2
= T
G3
= 0.4 s
3. Decreased time constant, to 50% , that is T
G2
= T
G3
= 0.1 s
Theory
50
Figure 2-20: Frequency response at islanding, with with 3 different prime mover time constants(T
a
).
Figure 2-20 shows that time constants of prime movers will influence the output
response of the generator. Shorter time constant will allow the prime mover to react
faster to the power mismatch at the islanding transistion so that steady state frequency is
reached sooner. The frequency oscillation will also be reduced as the prime mover can
react faster to the oscillation. Longer time constant will result in longer oscillation off
higher amplitude. The steady state frequency in all cases is the same as the droop
controller setting is the same. Also the frequency derivative will be approximately the
same as the rotational energy in the system is the same for the three different time
constant tests.
From the simplified model developed in this chapter, the ISR can be further limited to
the frequency derivative, as this is one of the criteria that must be fulfilled when
islanding. Using the same example as before, the ISR limits can be plotted for the
frequency derivative critera, Figure 2-21.
Theory
51
Figure 2-21: Example of theoretical ISR region for the reference system, based only on only frequency
derivative criterion (max df/dt = 2,5)
For the example shown here, it is clear that the island would be outside the frequency
derivative critera before it would be outside the steady state frequency critera (shown in
Figure 2-13). In the plot shown in figure 2-21, it is not considered how the dispatch
sharing is pre-islanding or if either of the generators reaches its maximum rating, as this
would also influence the shape of the ISR.
2.8 Different Combination of Conventional Generators
When the ISR curve is being developed by powerfactory simulation, the loads and
generation are incremented for each loop. They are incremented proportionally from
zero to100% of the rated power, as smaller generators get incremented by fewer MW
than the bigger generators. It is however of interest to see the influence of different
combination of dispatched power on the ISR as the machines have slightly different
characteristic. But primarily this would be expected to change the ISR when the
machines are getting closer to being fully loaded. This is because depending on the
offset, the machine can no longer participate to the frequency control.
Theory
52
For this simulation, the following scenarios will be considered.
1. P
G2
offset to P
G3
are by + 10 MW
2. P
G2
offset to P
G3
are by + 20 MW
3. P
G2
offset to P
G3
are by + 30 MW
Figure 2-23 shows the power offset discussed in this section.
Figure 2-22: Illustration of how the dispatched power of the two machines in the reference model can be
offset.
By offsetting the dispatch power, total power will remain the same. Simulations of these
cases are found in chapter 4.7.
2.9 Demand as Frequency Reserve
A Demand as Frequency Reserve (DFR) could potentially improve the conditions of
islanding transition. It is therefore of interest to includ simulations of the influence the
DFR could have on ISR and the islanding transition.
The DFR concept is discussed in [12] and consideres remotely controlled demand side
appliances (loads) which can function as system reserves when the system is heavily
loaded and the system frequency is considered too low. The types of appliences are
chosen based on minimum disturbance for the consumer. For example a set of
refrigerator elements can be shut off for a short period when system frequency is below
nominal. The refrigerator temperature would rise as a result, but within levels that
would be considered acceptable.
Generator increments for ISR
evaluation.
Rated P
G2
Rated P
G3
P
G3
P
G3
Generator increments for ISR
evaluation.
Rated P
G2
Rated P
G3
P
G3
P
G3
o
f
f
s
e
t
Theory
53
To give an idea of what kind of appliances are suitable, en example of suggested
appliances are shown Table 2-9 along with characteristics.
Table 2-9: Potentials for household electricity DFR [13]
In [12] a Power Factory model is developed based on a electric heater, and there are two
primary types
These types are as follows:
DFR I, where the elements will shut-off at a certain frequency, suggested shut-
off frequency is between 50 - 49,9 Hz (each element with a minor offset to avoid
overshoot).
DFR II, suggests that instead of shut-off frequency, the thermostat setpoint is
varied dynamically depending on the frequency.
This is also illustrated in Table 2-10 with advantages and disadvantages.
Theory
54
Table 2-10: Comparison of DFR I and DFR II.[14]
Figure 2-23 shows the system response due to sudden load change with different types
of the DFR models (DFR I and DFR II at three different settings), simulated in Power
Factory.
To illustrate the influence a DFR could have on the ISR, the following example is
given.
Load change P = 30MW at 1000 s
Theory
55
Figure 2-23: Sudden load change and influence on grid dependent on different types of DFR.[15]
From the simulation in Figure 2-23 it can be seen that the frequency deviation after the
load change is reduced. Dependent on the type of DFR, the frequency deviation will
increase after some time. This happens as more of the heater units are reaching the
lower limit and will start to require active power to stay within the acceptable
boundaries.
The DFR II model is included in simulations in chapter 4 to analyse the influence on the
ISR region. The model simulates 100 heater units and the following are the relevant
paramters.
PMean (kW) Mean power of each of the 100 heaters heater.
offPCT Indicates how large portion of the heaters start in
OFF mode when simulation is started
Theory
56
ampfac Amplification factor for the total power
consumption.
For the simulation purposes, the DFR load is added to the reference grid as shown in
Figure 2-24.
Figure 2-24: Reference island with DFR load.
The DFR load is added to a new bus, DFR station bus. The DFR station bus is
connected to bus 6 via an ideal line (no losses etc.).
The simulations are carried out with the following scenarios and compared to the
reference model.
1. Max 14 MW heater load added and load B reduced by 35MW
Simulation results for the above are presented in chapter 4.6.
2.10 Load Shedding
In cases where lines or systems are being overloaded, generally a load shedding scheme
can be considered. This could also be considered to the advantage of the ISR. If a
defined island is being overloaded and cannot maintain the power quality needed,
certain loads within the loads can be disconnected to improve the power quality.
Theory
57
The load shedding can therefore potentially improve the ISR. General care must be
taken when implementing load shedding controls, so that high priority loads will not be
disconnected before lower priority loads. Load priority must be evaluated and included
in the load shedding strategy.
Load shedding can also occur on subtransmission level, where larger groups of
customers are shed with little or no discrimination between customers [16].
For load shedding to be possible, frequency relays must be implemented. And in some
cases it might be beneficial that they can be activated by the proposed islanding
controller. There are two types of load shedding relays.
Under frequency relay Is activated when frequency goes
below a set threshold.
Frequency derivative relay Is activated when absolute frequency
derivative goes above the set
threshold.
Typically they are setup in multilevels, so the amount of shed load depends on how
much the frequency deviates from the setpoint frequency, or in case of frequency
derivative relay how high the frequency derivative is.
For the purpose to see the influences of load shedding control scheme on the ISR, the
following simple load shedding strategy is implemented into the reference model.
Load shedding relays type under frequency relay are implemented and simulated in
chapter 4.8, so that, when frequency goes below 49,9 Hz the first level loads are
disconnected and if the frequency goes below 49,8 Hz (which is the criterion for
successful islanding transition in the ISR in [1]), the second level of loads are
disconnected. The amount of load shedding is dependant on the defined island but for
illustrational purposes the two following scenarios are simulated.
1. First level shedding 3% (at 49,9Hz) : Second level shedding 3% (at 49,8 Hz ).
2. First level shedding 6% (at 49,9Hz) : Second level shedding 6% (at 49,8 Hz ).
The results of these load shedding strategies can be seen in chapter 4.8.
Furthermore if load shedding is to be implemented with the proposed islanding
controller, it could be suggested that for occurances when the islanding mode duration is
longer, load shedding interchanges should be implemented. This could be done in a way
Theory
58
so that the customers can be reconnected after a defined duration on the expence of
other customers.
2.11 Part Conclusion
In this chapter most of the relevant theory is covered. The concept of ISR and a control
mechanism is introduced. A reference model is defined, based on what previous work
by others has been carried out on.
A method for investigating the influence of different generation types on ISR is
suggested to investigate the influence, the characteristic parameters of the generator,
turbine and power controller are investigated. Some calculation examples are given,
where the theory on frequency deviation and deriviative are applied on the reference
model.
Other technologies such as Demand as Frequency Reserve (DFR) and load shedding are
introduced. These, together with the other analysis, will be simulated in chapter 4.
59
3
PROGRAMMING FOR ISR ANALYSIS
3.1 Introduction
To analyse an islanding transition problem, with respect to the ISR, the island can be
modeled in DIgSILENT Power Factory (PF) and islanding transition can be simulated.
In this chapter there will be given a brief introduction to PF simulation program, some
details of problems occurring with programming and simulations and details of changes
made in the ISR script as a result. Also a number of Matlab functions are developed to
replace some of the PF ISR script and to simplify the analysis of the of the ISR region.
Source code program scripts and functions can be viewed in appendixes and on the
attached CD.
Matlab Script and relevant functions can be seen in appendix A.
DIgSILENT Power Factory script can be seen in appendix B.
The simulations presented in next chapter will have somewhat low resolution, in respect
to number of simulations per ISR development. This is due to long simulation runtimes,
the plots can be developed with much higher resolution but at greater runtime.
3.2 DIgSILENT Power Factory
Power Factory DIgSILENT is a calculation program that is designed for engineering
analysis. It is focused on electrical power systems and control analysis. It allows for
system design in one line diagrams and includes a large library of power system
components.
Some of the key features of Power Factory DIgSILENT are:
Definition, modification of cases.
Power system element database (based on IEEE definitions).
Integrated calculation functions.
Manual script/function programming in DPL language.
Loadflow and short circuit calculations.
Transient and stability simulations.
Programming for ISR Analysis
60
PF is a good candidate for ISR analysis and has been used for that purpose in [1]. In this
project it will also be used in combination with Matlab. During the simulations required
when developing the ISR curve, there is a large amount of data involved. Handling this
large amount of data has turned out to be problematic in the process of this project.
However Matlab has good properties for handling and manipulating larger amount of
data as well as it has simple mathematical programming language, therefore is Matlab
being introduced and used for some of the calculations.
3.2.1 DIgSILENT Programming Language
The DIgSILENT Programming Language (DPL) is similar to C++ programming
language. It has a small syntax which is ment to do simple calculations and other basic
operations as loops. The DPL allows running simulations and changing simulation
parameters as well as element parameters from within the script. This makes it possible
to run series of simulations for different grid conditions as suggested in the ISR flow
chart, shown in Figure 2-8.
The DPL user interface allows for variables to be decleared in an option window, where
basic parameters for the scripts can be easily adjusted, as shown in Figure 3-1.
Figure 3-1: Example of how basic ISR parameter values can be changed.
Programming for ISR Analysis
61
3.3 ISR Evaluation Script Problems
The ISR script is designed to work with almost any grid model, however it is limited in
the way that it as designed in [1], as it only consideres synchronous generators as
generation sources and only non-rotational constant loads. During the process of this
project there have been series of problematic occurrances when working with and
modifying the ISR script developed in [1]. Primarily the problems were a programming
error causing the script to fail and return with an error message and no simulation
results. The error would occoure when some parameters where change and /or when
changes are applied done in the script.
Debugging and problem solving in the DPL programming language has proven time
consuming and difficult, this is partly because of lack of prior experience with PF and
the fact that the PF documentation is limited [17]. Mainly the available documentation
is from the PF help files.
It is not possible to view instances where system is stable or unstable individually. This
would help to further analyse and study the ISR region.
Based on above it has been decided for this project to interface the simulation results
from PF to Matlab, which is a large amount of data. Then in Matlab simulation results
can be handled, the ISR region can be defined and plottet. Also individual instances
(grid condition) can be plottet for further analysis, as well as simple parameters such as
frequency critera etc. can be changed and visualized without the whole simulation being
performed again, only the matlab script will be re-executed.
3.3.1 Changes Made to the ISR Evaluation Script
Due to the fact that this project analyses the influences of different generation types on
the ISR, some changes are made to the ISR script proposed in [1]. The different
generation types are analysed by defining the ISR for a reference island model
(introduced in chapter 2.5.2) and then parameters are changed referring to the different
generator types. Also to solve the problem of simulation errors discussed previously, the
output of the individual simulations is interfaced with Matlab, where post-simulation,
the ISR curve is evaluated and visulized. The flow chart introduced in chapter 2.4.1
shows the original ISR program. The new design of the program structure based on the
above is shown in Figure 3-2.
Programming for ISR Analysis
62
Figure 3-2: PF ISR script for analyzing the influence of different generator types.
The flow chart in Figure 3-2 is similar to the original flow chart in Figure 2-8, where as
a third loop has been added, where a third variable can be sweeped (called Z in flow
chart). The variable can be set to be any element parameter in the islanding system with
minor modification in the ISR script code. This is useful to see the influence of different
inertia, prime mover time constant and droop control on the ISR. Also, in the modified
script the registered results are not only generated power and load, but also the
frequency and voltage at the monitored bus for each simulation. Other change in the
program structure is that the decision block, where frequency limits where evaluated,
has been removed as the main ISR evaluation will be performed in Matlab. When the
program script is run it will sweep the three parameters and when all parameters have
been sweeped, it will output the registered simulation data to a file which in turn can be
loaded in matlab for further analysis.
Define
variables/
inputs
Output registered
results for further
analysis in Matlab
First loop for Z,
Z1ZZ2
Simulation with
islanding transition
Second loop for gen.,
P_gen1P_genPgen2
Increase Z by z%
Z_k=Z_(k-1)(1+z%)
(k=1,2,3,)
Reset P_gen
Second loop for loads,
P_lod1P_lodP_lod2
Increase loads by y%
Pload_n=Pload_(n-1)(1+y%)
(n=1,2,3,)
Register results,
P_gen, P_lod,
Freq and Volt
Yes
No
No
No
Yes
Yes
Increase gen by x%
Pgen_m=Pgen_(m-1)(1+x%)
(m=1,2,3,)
Reset P_lod
Programming for ISR Analysis
63
Output Data
The output data is dumped into three separate files. The first file holds the frequency
and time results for each simulation. The second file holds the frequency data and third
file holds grid condition data, where the power generation and load as are pre-islanding.
The data structure is a matrix format as illustrated in Table 3-1. The example shown in
the table shows a slice of frequency and time for for three simulation loop generated in
the ISR script.
Table 3-1: Example of the output format from Power Factory ISR scrip. Each column and array extends
in both directions.
After a PF simulation, the Matlab scrip can be used to visualize the ISR region. The
script loads the simulation data and plots the ISR curve based on the set criteria. The
Matlap script program structure is illustrated in the following flow chart in Figure 3-3.
50,000 19,975 50,000 19,975 50,000 19,975
50,000 19,985 50,000 19,985 50,000 19,985
50,000 19,995 50,000 19,995 50,000 19,995
49,975 20,005 49,967 20,005 49,957 20,005
49,958 20,015 49,944 20,015 49,928 20,015
49,944 20,025 49,926 20,025 49,905 20,025
49,933 20,035 49,911 20,035 49,886 20,035
49,923 20,045 49,898 20,045 49,870 20,045
49,914 20,055 49,886 20,055 49,864 20,055
Freq [Hz] Time [s] Freq [Hz] Time [s] Freq [Hz] Time [s]
Simulation nr. n Simulation nr. n+1 Simulation nr. n+2
S
l
i
c
e
f
r
o
m
P
F
s
c
r
i
p
t
o
u
t
p
u
t
f
i
l
e
Programming for ISR Analysis
64
Figure 3-3: Flow chart for Matlab program, development of ISR curve.
Define
variables/
criteria
Output results
Plot of ISR
Loop for Simulation
numbers:
Sim nSim n total
Increment simulation num-
ber:
Frequency Deriva-
tive
df/dt n df/dt max
Evaluate: Frequency deviation,
Frequency derivative,
Bus voltage
Bus Voltage
df/dt_n df/dt_max
Develop ISR curve from
registered successful ISR
simulation indexes.
Register index of
simulation, ISR
successful
No
No
No
Yes
Yes
Load data from
last PF simula-
tion
Load new simula-
tions data (or use
previous)?
Use previously
loaded data
No
Yes
Frequency Deviation
f_minf_nf_max
No
Register index of
simulation, ISR
unsuccessful
Yes
Yes
Part 4: Output
Part 1: Definition of ISR criteria
Part 2: Load simulation data
Part 3: Evaluate ISR
Programming for ISR Analysis
65
Part 1: Definition of ISR Criteria
In the matlab script, the parameters for the ISR evaluation are set manually. The main
parameters are the criteria to be fulfilled so that islanding can be considered successful,
these parameters are as follows.
Frequency deviation Maximum and minimum criterion for
frequency deviation.
Frequency derivative Max value for frequency derivative criterion
.
Voltage Maximum and minimum voltage criterion
.
Other criteria for successful ISR could easily be added, and would then also be added as
a decision block in part 3, shown in the flow chart (Figure 3-3), where each simulation
is evaluated.
Part 2: Load Simulation Data
In part two of the flow chart, there is a user option of loading new simulation data or re-
run previously loaded data. This is useful, as the influences of different ISR criteria can
be quickly evaluated without running a whole simulation in PF.
For loading the data, a specific Matlab function has been developed to load the
simulation data from the three data files mentioned in earlier in this chapter. Table 3-2
shows the function and short description. .
Matlab Function Function description
b=read_txt(filename) The function opens a text file filename,
reads the matrix text for each matrix
location, and converts it to double format
and returns a double format matrix b.
Table 3-2: Matlab functions for Load Simulation Data.
Part 3: Evaluate ISR
At this stage the ISR is evaluated. It is based on a loop that evaluates each individual PF
simulation instance. Each criterion for ISR is checked and if the simulation results show
that values are outside any of the set critera, it is registered as unsuccessful islanding
transition and next simulation instance is evaluated. If all criteria are fulfilled, the
simulation instance is registered as successful and the next simulation instance is
evaluated until all simulation instances have been processed.
Programming for ISR Analysis
66
For the purpose of this evaluation, a number of Matlab functions have been developed,
they are listed in Table 3-3 with a short description,.
Matlab Function Function description
voltt=volttime(volt,time,t1) The function returns the voltage from a
supplied voltage array (volt) based on the
supplied time array (time) at the specified
time (t1) for one instance of simulation.
freqt=freqtime(freq,time,t1) The function returns the frequency from a
supplied frequency array (freq) based on
the supplied time array (time) at the
specified time (t1) for one instance of
simulation.
max=maxdfdt(freq,time) The function evaluates the max frequency
derivative based on the supplied
frequency (freq) array and time array
(time) for one instance of simulation.
Table 3-3: Matlab functions for Evaluate ISR.
Part 4: Output.
The output part is where the ISR curve is developed based on successful and
unsuccessful simulation instances. The curve is plottet on Y/X axis where the Y axis
indicate the total dispatched active power pre islanding transition, and X axis indicate
the active power load in the island pre islanding transition. Also when a third parameter
is considered, the ouput will add the Z-axis for plotting ISR curve based on that specific
parameter, such as the inertia of the generators in the defined island.
For the purpose of developing the output curves, two Matlab functions have been
created, they are listed in table 3-4 with a short description,
Matlab Function Function description
x=returnIndexed(data,index)
The function collects data from the matrix
(data), based on the index given in the
array (index), then retuns the collected
data matrix (x).
outMatrix=outlineMatrix(cases)
The function developes outline
coordinates for the ISR curve based on the
matrix of stable cases (cases), returns a
matrix holding the x,y coordinates for the
Programming for ISR Analysis
67
curve.
plotOutlines(outLineMatrix)
The function plots the outlines based on
the supplied x,y coordinate matrix
(outLineMatrix).
plot3DISR(cases)
The function plots the outlines based on
the supplied x,y,z coordinate matrix
(cases) (holds index successful islanding
transitions, Generation, load and third
parameter, for example inertia).
Table 3-4: Matlab functions for Output.
3.3.2 Running the ISR Evaluation script
For running the developed ISR scripts, a PF project file, including the island model and
ISR script must be imported to PF. For the various simulations, small adjustments are
made to the script, adapting it to the various analyses, for each analysis, a separate
project file is created and is available on the attached CD. The Location on the CD is as
follows.
[CD-drive] :\Simulations\PF_projects\
To run an ISR evaluation within PF, the case must be activated within the imported
project file. The case to be activated is in each of the projects is.
Basic 10-bus for islanding
Before executing the script, care should be taken that the output path of the simulation
data is correctly defined in the ISR script. The path can be adjusted in the basic
parameters of the script. This path should then be added to the Matlab path if it isnt
already included.
The Matlab script and functions can be added to the default Matlab folder or any folder,
but care should be taken that the path is included in the Matlabs observed paths
(Matlab settings). The Matlab files are available the attached CD. The Location on the
CD is as follows.
[CD-drive] :\Simulations\Matlab_files\
Programming for ISR Analysis
68
When the PF project file is loaded and the Matlab files copied, simulation can be
started. Starting by running the ISR script in PF and when simulation finishes, the
Matlab script (evaluateISR.m) is executed.
3.4 Part conclusion
Due to the fact that during this project there where problems developing the ISR with
the script designed in [1], some extensive adjustments were made to the program and
program architecture. The developed combination of PF and Matlab program does
define the ISR for the reference model and allows for the possibility of varying the third
parameter, which could be for example system inertia or governor time constant. Also,
with the method used here, where Matlab is used for the data analysis, all the data is
available for further analysis after simulation and specific simulation instances can be
plotted this can be convenient for further understanding the system behavior. Also ISR
criteria can be added, removed or adjusted and the influence on the ISR region can be
plottet without running a time consuming Power Factory simulation again.
69
4
SIMULATION RESULTS
4.1 Introduction
In this chapter, the simulations results are plottet and evaluated. For most of the
analysis, the same simulation parameters will apply, the general simulation parameters
are shown in Table 4-1.
Parameter Value Unit
Simulation time 40 sec
Islanding time 20 sec
Voltage, Freq and df/dt observed at time 35 sec
Min generation 0,05 pu
Max generation 1,00 pu
Generation increments 0.03 pu
Min load 0,05 pu
Max load 1,00 pu
Load increments 0.03 pu
Table 4-1: General simulation parameters.
The above parameters will be used for all simulations unless other parameters are
specified.
It should also be noted that the axis on the plots are in p.u. and there are different base
values for the generation and load, they are 272 MW and 317 MW respectively. The
load indicated in the simulations does not include losses, it is purely the general loads,
Load A, Load B and Load C from Figure 2-11.
4.2 ISR: For the Reference Island Model
Here the first simulation on the reference island model is performed. Figure 4-1 shows
the ISR region but also indicates all simulation instances and whether they were
successful or not.
Simulation Results
70
Figure 4-1: ISR for the reference island model (plot also includes each simulation instance, whether it is
successful or unsuccessful transition).
The frequency and voltage for specific cases within or outside the ISR can be plotted,
and an example of that is shown here in Figure 4-2.
See Figure 4-2. For
frequency plot of two
simulation instances
Simulation Results
71
Figure 4-2: Frequency for two simulation instances on the reference model
The frequency is plottet for two simulation instances, in one case within the ISR but the
other is outside the ISR. The chosen instances are critical as they are close to the
boundaries between successful and unsuccessful islanding. For the case outside the ISR
itbecomes clear that the frequency deviation and derivative violate the critera set in
Table 2-2.
4.3 ISR: For Different Generator Inertia
By varying the inertia (H) of each DR, the lower and higher rotational energy for each
for the combined prime mover and generator system is emulated. The per unit values of
the inertia shown here are based on the total inertia of the reference model. The results
show the ISR for 50%, 100% (reference inertia), 150% and 200% of the reference
inertia, see Figure 4-3.
Simulation Results
72
Figure 4-3: ISR for the reference model with variousinertia.
It is clear from the figure that with higher inertia the ISR is larger and islanding
transition would be made easier. The ISR for an island model where the inertia is 150%
and 200% of that in the reference model, the ISR is considerably larger. On the other
hand, with less inertia in the system, the ISR decreases.
The following illustrates the same results from an on-top view, Figure 4-4.
Figure 4-4: ISR for the reference model with variousinertia (on top view).
Simulation Results
73
From the above figures, Figure 4-3 and Figure 4-4, the ISR curves for the separate
inertia values, are partially overlapping each other. This is due to the fact that the
simulation resolution is rather large, or 3% increase in load and generation for each
loop, as specified in Table 4-1. Running the simulation with higher resolution would
yield a better visualisation of the ISR curves but is impractical due to simulation time.
Instead it is possible to reduce the area of interest and focus on smaller area. Changing
the simulation parameters according to Table 4-2 the ISR can be visulized as shown in
Figure 4-5.
Parameter Value Unit
Min generation 0,20 pu
Max generation 0,37 pu
Generation increments 0,003 pu
Min load 0,30 pu
Max load 0,35 pu
Load increments 0.003 pu
Table 4-2: Parameters to evaluate ISR.with focus on smaller ISR area.
Figure 4-5: ISR for the reference model with variousinertia with focus on smaller ISR area.
Figure 4-5 shows the lower boundaries of the ISR. The simulation range is reduced
considerably compared to the previous plots. Here it is clearer that the with higher DR
inertia the ISR is increased. It can be concluded from the above plots that with increased
Simulation Results
74
DR inertia, the overall ISR performance is improved, at least in the range simulated
here. This is also what should be expected (found in chapter 2.7) as the frequency
derivative is decreased as the inertia is increased.
4.4 ISR: Different Prime Mover Time Constant
By varying the time constant of each DR, we can see the impact on the ISR. By varying
the time constant we can get an idea of the impact of slower or faster responding prime
movers. However the time constant of the prime mover is not the only parameter
influencing its characteristic, but is the only one included in this simulation.
The per unit values of the time constant (T
a
) shown in Figure 4-6, is based on the time
constant for the prime movers in the reference model. The values for the reference
model can be seen in Table 2-3. The result shows the ISR for 50%, 100%, 150% and
200% of the reference time constant see Figure 4-6.
Figure 4-6: ISR for the reference model with prime mover time constants.
It could be expetcted that a faster responding prime mover would improve the ISR,
however, in this simulation, it is clear that in the time constant range simulated, it does
not have a big influence. This could be explained by the fact that in this particular
islanding model, the frequency deviation criteria is dominant for the ISR. And reducing
or increasing the time constant will not directly influence the frequency deviation as
discovered in chapter 2.7.
Simulation Results
75
The range for the time constant simulated is from 0,1s to 0,4s. However when the time
constant is set to 200% of that in the reference, it is clear that the ISR has degraded,
compared to that of smaller time constants as shown in Figure 4-7.
Figure 4-7: ISR for the reference model with various prime mover time constants.
By looking at the frequency for a specific condition, we can also see the response
difference for the time constants. Figure 4-8 shows a plot of the frequency after
islanding transition simulation in PF. The conditions are the same for each curve, that is,
generation is 0,50 pu and load is 0,40 pu.
Simulation Results
76
Figure 4-8: Frequency plot at islanding for various prime mover time constants.
Each of the simulation instances in the above plot fulfills the critera for ISR but there
are obvious differences. With higher time constant, the oscilation is more severe and
damping is slower.
4.5 ISR: For Different Droop Settings
By varying the time droop setting for each DR controller, we can see the impact on the
ISR. The per unit values of the droop setting (R) shown in Figure 4-9, is based on the
droop setting for the controllers of the reference model. The result shows the ISR for
50%, 100%, 150% and 200% of the reference droop setting, see Figure 4-9.
Simulation Results
77
Figure 4-9: ISR for the reference model with various droop control settings.
As seen in chapter 2.7.1, the droop is inversly proportional to the gain of the controller.
This means that lower droop will give less frequency deviation, which is confirmed in
the simulation results as it increases the ISR. Figure 4-10shows the ISR from on-top
view.
Simulation Results
78
Figure 4-10: ISR for the reference model with various droop control settings.
It is clear in Figure 4-10 that lower droop will in some cases improve the ISR, however
for the lowest droop setting the increased gain increasis the frequency derivative, so that
in some parts of the curve, the ISR is reduced. Based on the above it is clear that an
optimal droop setting for ISR operation could be found and potentially adjusted when
the system is prepering for islanding or is in alert state as shown in Figure 2-9 for the
controller flow chart.
Simulation Results
79
4.6 Influence of DFR
An electric heater was implemented with DFR controller technology. The DFR is
shown to improve the ISR, as Figure 4-11 illustrates.
Figure 4-11: ISR for the reference model with DFR implemented.
It is clearer from Figure 4-12, that with DFR technology in the defined island, the ISR
can be improved. However from this figure it seems to only improve the ISR for
conditions where the island is in power transport mode before islanding.
Simulation Results
80
Figure 4-12: ISR for the reference model with DFR implemented.
4.7 Different Combination of Conventional Generators
In this chapter the influence of different generator combination is tried. The results in
Figure 4-13, shows that it does not have much impact on the general area of the ISR.
Table 4-3 show the parameters used for this simulation.
Parameter Value Unit
Min generation 0,10 pu
Max generation 0,90 pu
Generation increments 0,03 pu
Min load 0,10 pu
Max load 0,90 pu
Load increments 0.03 pu
Table 4-3: Simulation parameters for different combination of conventional generators.
The range simulated is reduced so that the generators are not in negative production,
and that they are not overloaded before islanding transition.
Simulation Results
81
Figure 4-13: Different combinations of Conventional Generators.
The same results better illustrated, as shown from top in Figure 4-14.
Figure 4-14: Different combinations of Conventional Generators.
Simulation Results
82
The ISR is nearly unaffected of the different combinations. Only where the grid is
highly loaded, is there a little difference in ISR. This can be partly explained by the fact
that the machines in the reference island model are fairly similar.
4.8 Load Shedding
By implementing frequency relays, the ISR can be improved as shown in Figure 4-15
and Figure 4-16. The ISR is improved as some of the loads are dropped when the island
is being overloaded and the frequency becomes too low. The degree of improvement of
the ISR depends on the amount of load shedding available.
Simulation Results
83
Figure 4-15: ISR for the reference model with two different load shedding implimentations.
Figure 4-16: ISR for the reference model with two different load shedding implimentations.
Simulation Results
84
From Figure 4-16, it is clear that the load shedding mostly improves the ISR for
conditions when the defined island is in import mode before the islanding transition.
This is because it will introduce under-frequency within the island after islanding
transition. However in cases of overfrequencies, the load shedding offers little or no
improvement.
4.9 Part Conclusion
The different parameters for the generator, controller and prime mover were
successfully simulater. The simulation results show tha ISR curve, where it can be
compared to the reference model results as well as other results. The simulations results
confirm the theoretical analysis on the influences of these different parameters.
It is also found by simulations that both DFR and load shedding can improve the ISR
region. And a combination of both technologies would potentially improve ISR further.
85
5
CONCLUSION
This project has investigated the influence of different generation types on the ISR. Also
the impact of load shedding and the emerging energy technology DFR are investigated.
The Islanding Security Region (ISR) used together with a control mechanism can
potentially improve the reliability of the electric supply to customers.
Simulation results and evaluation show that increased generator inertia can improve the
ISR. This was clearly illustrated as the results for a reference island are compared to that
of a reference island with increased generator inertia on the one hand and decreased
inertia on the other. The turbine time constant, which should indicate how fast a turbine
and its fuel system will react to controller input, showed that faster or slower time
constant do not have a very big influence on the ISR unless the changes in the time
constant are much greater compared to that of the reference model. The droop controller
does influence the ISR and can improve the ISR area greatly, less droop gives better
ISR. The generators in the reference model have a very low droop setting and lowering
it further will not necessarily improve the ISR, as other factors will start to be decisive.
Load shedding by frequency relays does show improvements to the ISR, and depending
on the level of acceptable load shedding, the ISR can be improved considerably.
However it should be noted that it only improves the lower region of the ISR curve,
when the island is importing electric power at the time of islanding. Also the DFR can
improve the ISR as shown with simulations.
The investigation of different generation types on the ISR must be considered a very
broad problem, as there are many aspects to consider. In this project most of the tasks
on the tasklist are discussed and evaluated in the report. It is clear that most of the
subjects handled in this project could be investigated in much more detail, for example
it would be interesting to focus on different types power control in more detail.
Some simplifications are justified with respect to influence of different generation types,
so that the influence is primarily investigated by the means of varying the characteristic
parameters of a generator, prime mover and controller unit.
Conclusion
86
Most of the work is done on adjusting and improvements to the program script for
evaluating the ISR of a grid model. The improvements to the script allow for visual
comparison of the influence for various generation types, as well as easier means of
analyzing the simulation data. Even though there is an primarily focus on one type of an
island model (Reference Island), the script could easily be adapted to any other grid
model for quickly evaluating the ISR and influence of different generation types on that
model.
The plots shown in this report have a rather low resolution, and in some cases that
makes comparing the different generation types difficult. The reason for not having
higher resolution is to limit the simulation time, as simulations presented in this report
take anything from 3 hours to 30 hours to execute.
The program code and functions created for this project could be applied on other island
models and other possibly more specific analysis.
87
REFERENCES
[1] Zhao Xu, Jacob stergaard Yu Chen, "Control Mechanism and Security Region for
intentional Islanding Transition," Article.
[2] Yu Chen, NextGen - Control Architecture for Inetntional Islanding Operation in
Future Distribution Network with High Penetration of Distributed Generation,
2007-04-01 to 2010-03-31, Ongoing.
[3] Prabha Kundur, "Power System Stability and Control," in Power System Stability
and Control, 1st ed.: McGraw-Hill, Inc., 1994, p. page 7.
[4] International Energy Agency. (2007, January) renewable_factsheet. [Online].
http://www.iea.org/papers/2006/renewable_factsheet.pdf
[5] Prabha Kundur, "Power System Stability and Control," in Power System Stability
and Control.: McGraw-Hill, Inc., 1994, pp. 3 - 14.
[6] IEEE, "IEEE P1547.4/Draft 6.0 Draft Guide for Design, Operation and Integration
of Distributed Resource Island Systems with Electric Power Systems," in Power
System Stability and Control., 2009, pp. 13 - 17.
[7] IEEE, "IEEE P1547.4/Draft 6.0 Draft Guide for Design, Operation and Integration
of Distributed Resource Island Systems with Electric Power Systems," IEEE,
Guide, (draft) 2009.
[8] Prabha Kundur,.: Power System Stability and ControlMcGraw-Hill, Inc., 1994, pp.
17 - 45.
[9] Prabha Kundur,.: McGraw-Hill, Inc., 1994, p. 590.
[10
]
Norway, Sweden & Finland TSOs of Denmark, "Nordic Grid Code 2007," in
Nordic Grid Code 2007., 2007, p. 74.
[11
]
Prabha Kundur, "Power System Stability and Control," in Power System Stability
and Control.: McGraw-Hill, Inc., 1994, p. 128.
[12
]
Mikael and Jacob Zhao, Demand as Frequency Controlled Reserve., 2008.
[13
]
Mikael and Jacob Zhao, "Demand as Frequency Controlled Reserve," in Demand
as Frequency Controlled Reserve., 2008, p. 18.
[14
]
Mikael and Jacob Zhao, "Demand as Frequency Controlled Reserve," in Demand
as Frequency Controlled Reserve., 2008, pp. page 33 - table 4.
Conclusion
88
[15
]
Mikael and Jacob Zhao, "Demand as Frequency Controlled Reserve," in Demand
as Frequency Controlled Reserve., 2008, p. 44.
[16
]
Powercor Citipower. http://www.powercor.com.au. [Online].
http://www.powercor.com.au/docs/pdf/Customer%20Information/Fact%20Sheet%
20-%20Load%20Shedding.pdf
[17
]
DIgSILENT Power Factory, User Manual, 1322007th ed.
89
A
MATLAB ISR SOURCE CODE AND FUNCTIONS
The following is a list of scripts and function created in matlab during the progress of
this project. Despcrition of the scripts and functions is given within the files.
evaluateISR.m
freqdev.m
freqtime.m
maxdfdt.m
outlineMatirx.m
outlineMatrix3D.m
paraChangeCounter.m
peakfreq.m
plot3DISR.m
plotISR.m
plotISR2d.m
plotOutlines.m
plotOutlines3D.m
plotSimple.m
read_txt.m
returnIndexed.m
sortMatrix.m
volttime.m
evaluateISR.m
%scr i pt eval uat eI SR. m
%
%Pur pose: Eval uat e and pl ot I SR f or PF si mul at i on.
%
%I nput : Si mul at i on dat a f i l es ar e i nput , and shoul d be pl aced i n
% C: / mat l ab7/ wor k,
% f i l e names shoul d be
% set t i ngs: set t i ngs2Txt . t xt
% condi t i ons: case2Txt . t xt
% Fr eq and t i me ar r ays: f r eq2Txt . t xt
% vol t age: vol t 2Txt . t xt
% Al t er nat i vel y, t he f i l e l ocat i ons coul d be added t o mat l ab pat h
%
%Out put : Pl ot s of t he I SR
%
Matlab ISR Source code and functions
90
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
%Load dat a
R=0;
cl c
di sp( ' Opt i ons: ' )
di sp( ' Pr ess " 1" t o use pr evi ousl y l oaded dat a. ' )
di sp( ' Pr ess " 2" t o l oad Power Fact or y dat a. ' )
di sp( ' Pr ess " 3" t o cancel . ' )
R=i nput ( ' Pr ess 1, 2 or 3: ' ) ;
i f R ==1
[ N, M] =si ze( a) ;
i f N==0
di sp( ' No dat a avai l abl e. PF dat a wi l l be l oaded. ' )
R=2;
end
di sp( ' New dat a not l oaded, pr evi ousl y l oaded dat a wi l l be used. ' )
end
i f R==2
di sp( ' Readi ng dat a. . . ' )
cl ear
a0=r ead_t xt ( ' set t i ngs2Txt . t xt ' ) ; %set ngs2Txt . t xt i s pr oduced i n pf
di sp( ' set t i ngs2Txt . t xt i s l oaded' )
a=r ead_t xt ( ' f r eq2Txt . t xt ' ) ; %f r eq_kpp. t xt i s pr oduced i n pf
di sp( ' f r eq2Txt . t xt i s l oaded' )
a1=r ead_t xt ( ' vol t 2Txt . t xt ' ) ; %vol t _kpp. t xt i s pr oduced i n pf
di sp( ' vol t _kpp. t xt i s l oaded' )
aX=r ead_t xt ( ' case2Txt . t xt ' ) ; %case_kpp. t xt i s pr oduced i n pf
a2( 1, : ) =aX( 1, : ) ; %a2 hol ds onl y pu val ues of gen and l oad
a2( 2, : ) =aX( 2, : ) ;
a3( 1, : ) =aX( 3, : ) ; %a3 hol ds onl y anct ual val ues of gen and l oad
a3( 2, : ) =aX( 4, : ) ;
[ N, M] =si ze( aX) ;
i f N==5
a4( 1, : ) =aX( 5, : ) ; %hol ds any t hi r d var i al be t hat i s beei ng
sweeped i n si mul at i on
el se
di sp( ' cases f i l e has t he f ol l owi ng number of var i abl es' )
di sp( N)
end
cl ear aX; %cl ear s t he var i abl e a4, as i t i s not used
anymor e.
di sp( ' case_kpp. t xt i s l oaded' )
di sp( ' Readi ng dat a compl et ed. ' )
el sei f R==3
er r or ( ' Oper at i on abor t ed' )
end
%char act er i st i cs and l i mi t s
%l i mi t s f or f r equency
%t i mes wher e f r eq shoul d be obser ved
t Bef or e = 15; %t o check f r eq bef or e i sl andi ng
t I sl and = 20; %t i me when gr i d goes t o i sl and mode ( ext er nal di sconnect ed)
t Af t er = 15+1; %f r equency shoul d be wi t hi n l i mi t s wi t hi n 15 sec f r omdi st .
%Li mi t s:
%f r equency l i mi t s
f Mi nBef or e=49. 99; %f r eq l i mi t bef or e i sl andi ng
f MaxBef or e=50. 01; %f r eq l i mi t bef or e i sl andi ng
f Mi nAf t er =49. 8; %f r eq l i mi t af t er i sl andi ng
f MaxAf t er =50. 2; %f r eq l i mi t af t er i sl andi ng
df dt MaxLi m=2. 5; %der i vat i ve f r eq l i mi t
%vol t age l i mi t s
vMi nBef or e=0. 5; %f r eq l i mi t bef or e i sl andi ng
vMaxBef or e=1. 5; %f r eq l i mi t bef or e i sl andi ng
vMi nAf t er =0. 8; %f r eq l i mi t af t er i sl andi ng
vMaxAf t er =1. 2; %f r eq l i mi t af t er i sl andi ng
Matlab ISR Source code and functions
91
[ N, M] =si ze( a) ;
st abl eI ndex=[ ] ; %cl ear i ng st abl e i ndexes bef or e st ar t i ng sweep
unst abl eI ndex=[ ] ; %cl ear i ng unst . i ndexes bef or e st ar t i ng sweep
nr St abl e=0; %cl ear i ng number of st abl e cases
nr Unst abl e=0; %cl ear i ng number of unst abl e cases
al l Cases=[ ] ;
al l St abl eCases=[ ] ;
al l Unst abl eCases=[ ] ;
%sor t dat a, f r eq, vol t , P and Load i nt o mat r i xes
k=1; %i s count er f or t he l oop and i ndexes wher e
%we ar e i n t he f r eq mat r i x.
k1=1; %i s count er f or t he l oop and i ndexes wher e
%we ar e i n t he vol t mat r i x.
whi l e k<=M
b=[ ] ; %r eset s t he mat r i xes
bb=[ ] ;
d=[ ] ;
h=1;
whi l e h<=N
i f a( h, k) ~= 0 %st oppes f i l l i ng b&c when val ues ar e zer o.
b( h, 1) =a( h, k) ; %b ar r ay hol ds f r equency val ues, whi l e. . .
bb( h, 1) =a( h, k+1) ; %c ar r ay hol ds t he t i me val ues, whi l e. . .
end
h=h+1;
end
h=1; %l oop f or cr eat i ng vol t ar r ays
i f k1<=M/ 2
whi l e h<=N
i f a1( h, k1) ~= 0 %st oppes f i l l i ng when val ues ar e zer o.
d( h, 1) =a1( h, k1) ; %d ar r ay hol ds vol t val ues.
end
h=h+1;
end
end
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%get f r eq dat a bef or e and af t er i sl andi ng
f Bef or e=vol t t i me( b, bb, t Bef or e) ; %f r eq bef or e i sl andi ng
vBef or e=f r eqt i me( d, bb, t Bef or e) ; %vol t age bef or e i sl andi ng
f Af t er =f r eqt i me( b, bb, t I sl and+t Af t er ) ; %f r eq af t er i sl andi ng
vAf t er =vol t t i me( d, bb, t I sl and+t Af t er ) ; %vol t af t er i sl andi ng
[ f DevMi n, f DevMax] =f r eqdev( b) ; %check f r eq devi at i on
df dt Max=maxdf dt ( b, bb) ; %check f r eq der i vat i ve
%f unct i on uses absol ut e val ue, so t her e
%i s no need f or mi n.
%check i f st abl e
st abl e=0; %var i abl e st abl e i s assumed 0( unst abl e)
%unt i l l check r eveal s 1( st abl e)
al l Cases( 1, k1) =f Bef or e;
al l Cases( 2, k1) =f Af t er ;
al l Cases( 3, k1) =df dt Max;
al l Cases( 4, k1) =vBef or e;
al l Cases( 5, k1) =vAf t er ;
%t hi s cr i t er i a checks onl y i f f r eq i s wi t hi n l i mi t s bef or e and
%af t er i sl andi ng, no vol t age or der i vat i ve cr i t er i a
Matlab ISR Source code and functions
92
%Consi der f r eq bef or e I sl and, af t er i sl and and der i vat i ve dur i ng
%whol e si mul at i on
%Consi der f r eq and vol t age bef or e and af t er , der i vat i ve not i ncl uded
i f f Bef or e<=f MaxBef or e && f Bef or e>=f Mi nBef or e. . . %f r eq cr i t
&& f Af t er <=f MaxAf t er && f Af t er >=f Mi nAf t er . . . %f r eq cr i t
&& vBef or e<vMaxBef or e && vBef or e>vMi nBef or e. . . %vol t cr i t
&& vAf t er <vMaxAf t er && vAf t er >vMi nAf t er %vol t cr i t
%
%%Consi der onl y f r eq cr i t er i on
% i f f Bef or e<=f MaxBef or e && f Bef or e>=f Mi nBef or e. . . %f r eq cr i t
% && f Af t er <=f MaxAf t er && f Af t er >=f Mi nAf t er . . . %f r eq cr i t
%
%%Consi der df / dt cr i t er i on
% i f f Bef or e<=df dt Max <= df dt MaxLi m. . . %der i vat i ve
%
%%Consi der onl y vol t age cr i t er i on
% i f f Bef or e<= vBef or e<vMaxBef or e && vBef or e>vMi nBef or e. . . %vol t cr i t
% && vAf t er <vMaxAf t er && vAf t er >vMi nAf t er %vol t cr i t
st abl e=1; %mar ki ng si mul at i on i nst ance as st abl e
end
%act i ons t o be t aken when st abl e case i s f ound can be added under
%t he f ol l owi ng " i f "
i f st abl e == 1
nr St abl e=nr St abl e+1;
%Save st abl e i ndexi s
%not e " ( k+1) / 2" wi l l i ndex t he r i ght col umn i n t he case
%mat r i x ( a2) .
st abl eI ndex( nr St abl e, 1) =( k+1) / 2;
al l St abl eCases( 1, nr St abl e) =f Bef or e;
al l St abl eCases( 2, nr St abl e) =f Af t er ;
al l St abl eCases( 3, nr St abl e) =df dt Max;
al l St abl eCases( 4, nr St abl e) =vBef or e;
al l St abl eCases( 5, nr St abl e) =vAf t er ;
el se
nr Unst abl e=nr Unst abl e+1;
%Save unst abl est abl e i ndexi s
%not e " ( k+1) / 2" wi l l i ndex t he r i ght col umn i n t he case
%mat r i x ( a2) .
unst abl eI ndex( nr Unst abl e, 1) =( k+1) / 2;
al l Unst abl eCases( 1, nr Unst abl e) =f Bef or e;
al l Unst abl eCases( 2, nr Unst abl e) =f Af t er ;
al l Unst abl eCases( 3, nr Unst abl e) =df dt Max;
al l Unst abl eCases( 4, nr Unst abl e) =vBef or e;
al l Unst abl eCases( 5, nr Unst abl e) =vAf t er ;
end
k1=k1+1;
k=k+2;
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
end
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%now St abl e cases have been f ound and i ndexed, I SR r egi on can t her ef or e be
%pl ot t ed:
%i f t her e ar e made Power f act or y si mul at i ons wher e t he t hi r d par amet er i s
%beei ng, sweeped, t hat i s not onl y l oad and gener at i on, t he r esul t s wi l l be
%sor t ed so t hat t he r esul t s can be di spl ayed cor r ect l y.
%check i f si mul at i ons have been set t o 3D ( done i n PF I SR scr i pt )
i f a0( 1, 1) ==1 %t hen t he pl ot has t he t hi r d par amet er .
a2st abl e= r et ur nI ndexed( a2, st abl eI ndex) ;
a3st abl e= r et ur nI ndexed( a3, st abl eI ndex) ;
a4st abl e= r et ur nI ndexed( a4, st abl eI ndex) ;
%f ul l pl ot wi t h X mar ki ng st abl e cases, O i s unst abl e
f i gur e
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
Matlab ISR Source code and functions
93
set ( f i gur enr , ' col or ' , [ 1 1 1] )
hol d on
i f nr St abl e ~=0 %so i f nr st abl e i s zer o, t hen not hi ng t o pl ot
pl ot I SR( [ a2; a4] , st abl eI ndex, ' x' )
end
i f nr Unst abl e ~=0 %so i f nr unst abl e i s zer o, t hen not hi ng t o pl ot
pl ot I SR( [ a2; a4] , unst abl eI ndex, ' r o' )
end
t i t l e( ' I SR r egi on 3D' )
yl abel ( ' Gener at or , Real Power Pr oduct i on' )
xl abel ( ' Load, Real Power Consumpt i on' )
zl abel ( ' 3r d par amet er ' )
axi s aut o
vi ew( 3)
hol d of f
%pl ot 3d out l i nes
pl ot 3DI SR( [ a2st abl e; a4st abl e] )
el sei f a0( 1, 1) ==0 %t hen i t s nor mal 2d pl ot
%pl ot wi t h pu val ues
f i gur e
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] )
hol d on
pl ot I SR2D( a2, st abl eI ndex, ' x' ) %pl ot s st abl e cases
pl ot I SR2D( a2, unst abl eI ndex, ' r o' ) %pl ot s unst abl e cases
t i t l e( ' I SR r egi on' )
yl abel ( ' Gener at or , Act i ve Power , p. u. ' )
xl abel ( ' Load, Act i ve Power Consumpt i on, p. u. ' )
axi s( [ 0. 1 1. 0 0. 1 1. ] )
vi ew( 2)
hol d of f
%pl ot wi t h act ual val ues
f i gur e
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] )
hol d on
pl ot I SR2D( a3, st abl eI ndex, ' x' ) %pl ot s st abl e cases
pl ot I SR2D( a3, unst abl eI ndex, ' r o' ) %pl ot s unst abl e cases
t i t l e( ' I SR r egi on' )
yl abel ( ' Gener at or , Act i ve Power , [ MW] ' )
xl abel ( ' Load, Act i ve Power Consumpt i on, [ MW] ' )
axi s( [ 0. 1*272 1. 0*272 0. 1*272 1*272] )
vi ew( 2)
hol d of f
%make out l i nepl ot of r egi on
%cr eat e out l i ne mat r i x f or pu pl ot
a2st abl e= r et ur nI ndexed( a2, st abl eI ndex) ;
I SRout l i nes=out l i neMat r i x( a2st abl e) ;
%pl ot out l i nes
f i gur e( 1)
hol d on
pl ot Out l i nes( I SRout l i nes)
hol d of f
%cr eat e out l i ne mat r i x f or act ual val ues pl ot
a3st abl e= r et ur nI ndexed( a3, st abl eI ndex) ;
I SRout l i nes=out l i neMat r i x( a3st abl e) ;
%pl ot out l i nes
f i gur e( 2)
hol d on
pl ot Out l i nes( I SRout l i nes)
hol d of f
end
Matlab ISR Source code and functions
94
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Freqdev.m
f unct i on [ mi n, max] =f r eqdev( f r eq)
%
%Pur pose: f i nds t he devi at i on, gi ven t hat i t s a 50Hz syst em, max and mi n
%
%I nput : f r eq i s a vect or of t he f r equency val ues.
%
%Out put : max r et ur ns t he doubl e val ue f or t he posi t i ve peak f r equency
% devi at i on
% mi n r et ur ns t he doubl e val ue f or t he negat at i ve( or l owest ) peak
% f r equency devi at i on
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( f r eq) ;
k=1;
max=0; %assumi ng 50Hz syst em, t he st ar t val ues f or max and mi n wi l l
mi n=0; %. . . as shown her e, 50Hz
whi l e k<=N
f 1=f r eq( k, 1) - 50; %- 50 because i t i s a 50Hz syst em
i f f 1>max
max=f 1;
end
i f f 1<mi n
mi n=f 1;
end
k=k+1;
end
%al t er nat i vel y, coul d have used f unct i ons max & mi n
r et ur n
freqtime.m
f unct i on f r eqt =f r eqt i me( f r eq, t i me, t 1)
%
%Pur pose: get s f r equency at chosen t i me i n t he si mul at i on
%
%I nput : f r eq i s a vect or of t he f r equency val ues.
% t i me i s a vect or of t he t i me val ues
% t 1 i s a doubl e val ue f or t he t i me of i nt er est , wher e f r eq wi l l
% be ext r act ed
%
%Out put : f r eqt i s t he f r equency at t he chosen t i me
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( f r eq) ;
k=0;
t 2=0;
whi l e t 2<=t 1
k=k+1;
t 2=t i me( k, 1) ;
end
f r eqt =f r eq( k, 1) ;
r et ur n
maxdfdt.m
Matlab ISR Source code and functions
95
f unct i on max=maxdf dt ( f r eq, t i me)
%
%Pur pose: f i nds t he hi ghest der i vat i ve f or t he f r equency t o be anal ysed
%
%I nput : f r eq i s a vect or of t he f r equency val ues.
% t i me shoul d be t he t i me vect or suppl i ed wi t h t he f r equency
%
%Out put : max r et ur ns t he doubl e val ue f or t he hi ghest der i vat i ve of t he
%suppl i ed f r eq, t i me
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( f r eq) ;
k=2;
max=0;
whi l e k<=N && f r eq( k, 1) > 5
f 1=f r eq( k- 1, 1) ;
f 2=f r eq( k, 1) ;
t 1=t i me( k- 1, 1) ;
t 2=t i me( k, 1) ;
%cal cul at e t he df / dt
df =abs( f 2- f 1) ;
dt =abs( t 2- t 1) ;
i f dt ~=0
df dt =df / dt ;
i f df dt >max
max=df dt ;
end
end
k=k+1;
end
r et ur n
outlineMatirx.m
f unct i on out Mat r i x=out l i neMat r i x( cases)
%
%Pur pose: Cr eat es out l i nes of t he I SR r egi on
%
%I nput : cases i s t he gen and l oad set t i ngs f or each si mul at i on
% i ndex, i ndexes whi ch ones of t he cases ar e st abl e
%
%Out put : OUT i s a x, y mat r i x of t he out l i nes of t he I SR r egi on
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( cases) ;
k=1;
k2=1;
whi l e k<=M
%get dat a
i f cases( 1, k) ~= 0
YX( k2, 1) =cases( 1, k) ; %gen
YX( k2, 2) =cases( 2, k) ; %l oad
k2=k2+1;
end
k=k+1;
Matlab ISR Source code and functions
96
end
%t he Gen par t i s al ways gr owi ng, whi l e l oad goes i n l oops, t her ef or e we
%know gen st ar t s at i t s l owest val ue and goes upwar ds.
%f i r st poi nt wi l l be bot t oml ef t ( mi n gen, mi n l oad)
Gen=YX( 1, 1) ;
[ N, M] =si ze( YX) ;
k=1;
p=1;
k1=1;
whi l e k <= N
i f YX( k, 1) ==Gen
t emp( k1, 1) =YX( k, 2) ; %saves t he l oad val ue f or each gen set t i ng i nt o an ar r ay
%needs anot her count er t hat st ar t s f r om1
%i n each l oop
el se
maxTemp( p, : ) =[ Gen, max( t emp) ] ;
mi nTemp( p, : ) =[ Gen, mi n( t emp) ] ;
t emp=[ ] ; %r eset s t emp and count er f or var i al bl e
k1=0;
Gen=YX( k, 1) ;
k=k- 1; %needs t o go down her e t o count er act +1 bel ow
p=p+1; %because one poi nt was f ound
end
i f k==N %f i nal l oop t o get t he hi gest gen val ue
maxTemp( p, : ) =[ Gen, max( t emp) ] ;
mi nTemp( p, : ) =[ Gen, mi n( t emp) ] ;
Gen=YX( k, 1) ;
end
k=k+1;
k1=k1+1;
end
%now t o make i t pl ot - abl e, t hey must be sor t ed:
[ N, M] =si ze( maxTemp) ;
p_count er =1;
p_count er 2=1;
whi l e p_count er <=N
out Mat r i x( p_count er 2, : ) =maxTemp( p_count er , : ) ;
p_count er =p_count er +1;
p_count er 2=p_count er 2+1;
end
p_count er =p_count er - 1;
whi l e p_count er >0
out Mat r i x( p_count er 2, : ) =mi nTemp( p_count er , : ) ;
p_count er =p_count er - 1;
p_count er 2=p_count er 2+1;
end
%t he l ast poi nt must be added t o be t he same as f i r st t o f i ni sh cl osed ar ea
[ N, M] =si ze( out Mat r i x) ;
out Mat r i x( N+1, : ) =out Mat r i x( 1, : ) ;
Matlab ISR Source code and functions
97
outlineMatrix3D.m
f unct i on out Mat r i x=out l i neMat r i x3D( cases)
%
%Pur pose: Cr eat es out l i nes of t he I SR r egi on
%
%I nput : cases i s t he gen and l oad set t i ngs f or each si mul at i on
% i ndex, i ndexes whi ch ones of t he cases ar e st abl e
%
%Out put : OUT i s a x, y mat r i x of t he out l i nes of t he I SR r egi on
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
ZZ=cases( 3, 1) ; %i ner t i a i s not changi n i n t hi s f unct i on, st or ed i n ZZ
[ N, M] =si ze( cases) ;
k=1;
k2=1;
whi l e k<=M
%get dat a
i f cases( 1, k) ~= 0
YX( k2, 1) =cases( 1, k) ; %gen
YX( k2, 2) =cases( 2, k) ; %l oad
k2=k2+1;
end
k=k+1;
end
%t he Gen par t i s al ways gr owi ng, whi l e l oad goes i n l oops, t her ef or e we
%know gen st ar t s at i t s l owest val ue and goes upwar ds.
%f i r st poi nt wi l l be bot t oml ef t ( mi n gen, mi n l oad)
Gen=YX( 1, 1) ;
[ N, M] =si ze( YX) ;
k=1;
p=1;
k1=1;
whi l e k <= N
i f YX( k, 1) ==Gen
t emp( k1, 1) =YX( k, 2) ; %saves t he l oad val ue f or each gen set t i ng i nt o an ar r ay
%needs anot her count er t hat st ar t s f r om1
%i n each l oop
el se
maxTemp( p, : ) =[ Gen, max( t emp) , ZZ] ;
mi nTemp( p, : ) =[ Gen, mi n( t emp) , ZZ] ;
t emp=[ ] ; %r eset s t emp and count er f or var i al bl e
k1=0;
Gen=YX( k, 1) ;
k=k- 1; %needs t o go down her e t o count er act +1 bel ow
p=p+1; %because one poi nt was f ound
end
i f k==N %f i nal l oop t o get t he hi gest gen val ue
maxTemp( p, : ) =[ Gen, max( t emp) , ZZ] ;
mi nTemp( p, : ) =[ Gen, mi n( t emp) , ZZ] ;
Gen=YX( k, 1) ;
end
k=k+1;
k1=k1+1;
end
Matlab ISR Source code and functions
98
%now t o make i t pl ot - abl e, t hey must be sor t ed:
[ N, M] =si ze( maxTemp) ;
p_count er =1;
p_count er 2=1;
whi l e p_count er <=N
out Mat r i x( p_count er 2, : ) =maxTemp( p_count er , : ) ;
p_count er =p_count er +1;
p_count er 2=p_count er 2+1;
end
p_count er =p_count er - 1;
whi l e p_count er >0
out Mat r i x( p_count er 2, : ) =mi nTemp( p_count er , : ) ;
p_count er =p_count er - 1;
p_count er 2=p_count er 2+1;
end
%t he l ast poi nt must be added t o be t he same as f i r st t o f i ni sh cl osed ar ea
[ N, M] =si ze( out Mat r i x) ;
out Mat r i x( N+1, : ) =out Mat r i x( 1, : ) ;
paraChangeCounter.m
f unct i on sor t edMat r i x=par aChangeCount er ( cases)
%
%Pur pose: sor t cases by t he val ue of t he t hi r d par amet er , t hi s hel ps wi t h
% pl ot t i ng t he I SR
%
%I nput : mat r i x of par amet er val ues
%
%Out put : mat r i x r et ur ns how of t en i t changed
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( cases) ;
k=1;
k2=1;
t emp=cases( 3, 1) ; %j ust put t i ng some val ue t hat wi l l not bef ound. . .
count er =1; %i n any par amet er s
whi l e k<=M
sor t edMat r i x( k2, count er ) =cases( k, 1) ;
sor t edMat r i x( k2, count er +1) =cases( k, 2) ;
sor t edMat r i x( k2, count er +2) =cases( k, 3) ;
i f cases( 3, k) ~=t emp
t emp=cases( 1, k) ;
count er =count er +3;
k2=0; %r eset t hi s count er because need t oo
%st ar t i n new l i ne i n sor t ed mat r i x
end
k2=k2+1;
k=k+1;
end
peakfreq.m
f unct i on [ mi n, max] =peakf r eq( f r eq)
%
%Pur pose: f i nds t he peak f r equenci es, max and mi n
%
%I nput : f r eq i s a vect or of t he f r equency val ues.
%
%Out put : max r et ur ns t he doubl e val ue f or t he posi t i ve peak f r equency
% mi n r et ur ns t he doubl e val ue f or t he negat at i ve( or l owest ) peak f r equency
%
Matlab ISR Source code and functions
99
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( f r eq) ;
k=1;
max=50; %assumi ng 50Hz syst em, t he st ar t val ues f or max and mi n wi l l
mi n=50; %. . . as shown her e, 50Hz
whi l e k<=N
f 1=f r eq( k, 1) ;
i f f 1>max
max=f 1;
end
i f f 1<mi n
mi n=f 1;
end
k=k+1;
end
%al t er nat i vel y, coul d have used f unct i ons max & mi n
r et ur n
plot3DISR.m
f unct i on pl ot 3DI SR( cases)
%
%Pur pose: Takes car e of dat a f or 3d pl ot t i ng and pl ot s
%
%I nput : cases i s t he st abl e gen, l oad and 3r d par amet er mat r i x
%
%Out put : pl ot of I SR r egi on i n 3d
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
%pl ot out l i nes of each most out er l oop, maki ng a 3D pl ot
sor t edCases=sor t Mat r i x( cases) ;
[ N, M] =si ze( sor t edCases) ;
k=1;
f i gur e
hol d on
whi l e k <= N
I SRout l i nes=out l i neMat r i x3D( [ sor t edCases( k, : ) ; sor t edCases( k+1, : ) ; sor t edCases( k+2, : ) ] ) ;
pl ot Out l i nes3D( I SRout l i nes)
k=k+3;
end
hol d of f
plotISR.m
f unct i on pl ot I SR( cases, i ndex, col or )
%
%Pur pose: pl ot s 3d of t he I SR r egi on, gen, l oad and a t hi r d var i abl e( f . x.
% i ner t i a)
%
%I nput : cases i s t he gen and l oad set t i ngs f or each si mul at i on
% i ndex, i ndexes whi ch ones of t he cases ar e st abl e
%
%Out put : pl ot of st abl e r egi on
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
%f i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
Matlab ISR Source code and functions
100
set ( f i gur enr , ' col or ' , [ 1 1 1] )
hol d on
[ N, M] =si ze( i ndex) ;
k=1;
whi l e k<=N
%get i ndex
i nd=i ndex( k, 1) ;
%get 3d dat a
y=cases( 1, i nd) ;
x=cases( 2, i nd) ;
z=cases( 3, i nd) ;
%mar k on pl ot wher e syst emi s st abl e
pl ot 3( x, y, z, col or ) ;
k=k+1;
end
hol d of f
plotISR2d.m
f unct i on pl ot I SR2D( cases, i ndex, col or )
%
%Pur pose: pl ot s 2d of t he I SR r egi on, onl y of gen and l oad ar e t he onl y
%var i abl es
%
%I nput : cases i s t he gen and l oad set t i ngs f or each si mul at i on
% i ndex, i ndexes whi ch ones of t he cases ar e st abl e
% col or shoul d be a st r i ng, i ndi cat i ng what col or t o pl ot and symbol
%
%Out put : pl ot of st abl e r egi on
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( i ndex) ;
i f N<1
di sp( ' f unct i on pl ot I SR2D( cases, i ndex) : t o f ew st abl e cases' )
r et ur n
end
k=1;
whi l e k<=N
%get i ndex
i nd=i ndex( k, 1) ;
%get 3d dat a
y=cases( 1, i nd) ; %gen
x=cases( 2, i nd) ; %l oad
%mar k on pl ot wher e syst emi s st abl e
pl ot ( x, y, col or ) ;
k=k+1;
end
plotOutlines.m
Matlab ISR Source code and functions
101
f unct i on pl ot Out l i nes( out Li neMat r i x)
%
%Pur pose: pl ot s out l i nes of t he I SR
%
%I nput : out Li neMat r i x i s t he out l i ne mat r i x, hol di ng t he out l i ne poi nt s
%
%Out put : pl ot s of t he I SR.
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
i f out Li neMat r i x ==1
di sp( ' f unct i on pl ot Out l i nes( out Li neMat r i x) : Not hi ng t o pl ot ' )
r et ur n
end
X=out Li neMat r i x( : , 1) ;
Y=out Li neMat r i x( : , 2) ;
pl ot ( Y, X, ' k' , ' Li neWi dt h' , 2)
plotOutlines3D.m
f unct i on pl ot Out l i nes3D( out Li neMat r i x)
%
%Pur pose: pl ot s out l i nes of t he I SR i n 3 di mensi on, i ncl udi ng t he t hi r d
% par amet er sweep ( not onl y l oad and gener at i on)
%
%I nput : out Li neMat r i x i s t he out l i ne mat r i x, hol di ng t he out l i ne poi nt s
%
%Out put : pl ot s of t he I SR 3d.
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
i f out Li neMat r i x ==1
di sp( ' f unct i on pl ot Out l i nes( out Li neMat r i x) : Not hi ng t o pl ot ' )
r et ur n
end
si ze( out Li neMat r i x)
X=out Li neMat r i x( : , 1) ;
Y=out Li neMat r i x( : , 2) ;
Z=out Li neMat r i x( : , 3) ;
pl ot 3( Y, X, Z)
plotSimple.m
f unct i on pl ot Si mpl e( cases, casenr )
%
%Pur pose: pl ot s t he f r eq over t i me
%
%I nput : cases i s al l t he f vect or s
% casenr i s t he number of whi ch one t o pl ot
%
%Out put : pl ot of f r equency f or chosen case.
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( cases) ;
casenr =casenr *2;
b=[ ] ; %r eset s t he mat r i xes
c=[ ] ;
Matlab ISR Source code and functions
102
h=1;
whi l e h<=N && cases( h, casenr - 1) >5
%st oppes f i l l i ng b&c when val ues ar e zer o.
b( h, 1) =cases( h, casenr - 1) ; %b ar r ay hol ds f r equency, whi l e. . .
c( h, 1) =cases( h, casenr ) ; %c ar r ay hol ds t he t i me.
h=h+1;
end
pl ot ( c, b)
read_txt.m
f unct i on b=r ead_t xt ( f i l ename) ;
%
%Pur pose: r eads a cost ummade Power f act or y var i abl e f i l e i n t xt f or mat
% ( Var i abl es saved i n col umns) .
%
%I nput : f i l ename shoul d be a st r i ng, t he name of t he f i l e t o l oad
%
%Out put : b r et ur ns t he doubl e val ue mat r i x wi t h t he i nf or mat i on st or ed i n
% t he t xt f i l e
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
f i d = f open( f i l ename) ;
c=0; %var onl y used as count er
whi l e 1
c= c+1;
t l i ne = f get l ( f i d) ;
%di sp( t l i ne)
i f ~i schar ( t l i ne) , br eak, end
i f t l i ne ~= - 1 %t hi s i s t o ski p f i nal st r i ng i n t l i ne whi ch i s - 1
a=st r 2num( t l i ne) ;
i f si ze( a) ~=[ 0, 0] %t o abvoi d f i l l i ng t he f i r st r ow wi t h bl anks
%di sp( a)
b( c, : ) =a;
el se
end
el se
end
end
f cl ose( f i d) ;
r et ur n
returnIndexed.m
f unct i on x=r et ur nI ndexed( dat a, i ndex)
%
%Pur pose: Ret ur ns t he i ndexed col umns f r omt he mat r i x/ ar r ay cal l ed dat a
%
%I nput : dat a i s a vect or or mat r i x
% i ndex shoul d i ndex t he col umns t hat wi l l be r et ur ned
Matlab ISR Source code and functions
103
%
%Out put : x i s t he r esul t i ng mat r i x
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( i ndex) ;
[ N, M] =si ze( i ndex) ;
i f N<1
di sp( ' f unct i on r et ur nI ndexed( dat a, i ndex) : t o f ew st abl e cases' )
x=1;
r et ur n
end
k=1;
whi l e k<=N
k2=i ndex( k, 1) ; %get s t he r ef er ence f r omt he i ndex mat r i x
x( : , k) =dat a( : , k2) ; %get s t he i ndexed val ue f r omdat a mat r i x
k=k+1;
end
sortMatrix.m
f unct i on sor t edMat r i x=sor t Mat r i x( cases)
%
%Pur pose: sor t cases by t he val ue of t he t hi r d par amet er , t hi s hel ps wi t h
% pl ot t i ng t he I SR
%
%I nput : mat r i x of st abl e par amet er val ues, Gen, Load and t hi r d par amet er
%
%Out put : mat r i x r et ur ns how of t en i t changed
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( cases) ;
k=1;
k2=1;
t emp=cases( 3, 1) ; %j ust put t i ng some val ue t hat wi l l not bef ound. . .
count er =1; %i n any par amet er s
count er 2=1;
whi l e k<=M
%i dent i f y change i n 3r d par amet er , i f i t changes, count er s ar e set
%abd t emp val ue f or compar i son i s updat ed.
i f cases( 3, k) ~=t emp
t emp=cases( 3, k) ;
count er =count er +3;
count er 2=count er 2+1; %r et ur ns t he number of changes i n par am
k2=1; %r eset t hi s count er because need t oo
%st ar t i n new l i ne i n sor t ed mat r i x
end
sor t edMat r i x( count er , k2) =cases( 1, k) ;
sor t edMat r i x( count er +1, k2) =cases( 2, k) ;
sor t edMat r i x( count er +2, k2) =cases( 3, k) ;
k2=k2+1;
k=k+1;
end
Matlab ISR Source code and functions
104
volttime.m
f unct i on vol t t =vol t t i me( vol t , t i me, t 1)
%
%Pur pose: get s vol t age at chosen t i me i n t he si mul at i on
%
%I nput : vol t i s a vect or of t he vol t age val ues.
% t i me i s a vect or of t he t i me val ues
% t 1 i s a doubl e val ue f or t he t i me of i nt er est , wher e vol t wi l l
% be ext r act ed
%
%Out put : vol t t i s t he vol t age at t he chosen t i me ( t 1)
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
[ N, M] =si ze( vol t ) ;
k=0;
t 2=0;
whi l e t 2<=t 1
k=k+1;
t 2=t i me( k, 1) ;
end
vol t t =vol t ( k, 1) ;
r et ur n
105
B
POWER FACTORY ISR SOURCE CODE
The following is the variables introduced in the basic options window:
Type Varname value description
int 3D 1 tellsmatlabifitshouldmake3dplotsor2d
double ScaleLoad 0.03 ScaleforLoads
double ScaleGen 0.03 ScaleforGens
double Pgenmaxpct 0.90 Percentageofbasegenmax
double Pgenminpct 0.10 Percentageofbasegenmin
double Ploadmaxpct 0.90 Percentageofbaseloadmax
double Ploadminpct 0.10 Percentageofbaseloadmin
double Tstop 40 s Stoptime,ortotalsimulationtime
double Tstart 0.01 s Starttime
double Tstep 0.01 s Steptime
double Tisland 20 s Islandingmoment
double Tobserve 15 s
Freq. observed time moment for assessment, after
islanding
double Tbefore 10 s Freq0,acquiredatthetimebeforeislanding
string Busisland 'Bus8' thebusforfrequencyobservationinisland
string Busexternal 'Bus1' thebusforfrequencyobservationinexternalgrid
string path
route/pathforoutputwindowfiles.(with*.outextension
filename)
string freqTxt 'C:\MATLAB7\work\freq2Txt.txt' Pathtofrequencyandtimeresultfile
string caseTxt 'C:\MATLAB7\work\case2Txt.txt' Pathtocaseresultfile
string voltTxt 'C:\MATLAB7\work\volt2Txt.txt' PathtoVoltageresultfile
string settingsTxt 'C:\MATLAB7\work\settings2Txt.txt'
Pathtosettings(todeterminehowtohandleresultfilesin
matlab)
double maxDiff 80 maxabsdiffofload&gen,orsimisskipped(savestime)
double xtramaxpct 15 Thiswillbeusedasamaxforthirdparamter
double xtraminpct 5 Thiswillbeusedasaminforthirdparamter
double xtraStep 5 Thiswillbeusedasastepsizeforthirdparamter
The following is the source code of the ISR script part from PF.
** the code is from [1] but modified for the purpose of this project.
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !
! I nt er nal Var i abl es def i ni t i ons!
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !
i nt sel ect ed; ! used f or r emi ndi ng oper at or of ' Gener al Sel ect i on' .
i nt l , g; ! used f or count i ng how many Loads and Gens.
Power Factory ISR Source Code
106
i nt i ; ! used f or i ncease of Load scal e
i nt j ; ! used f or i ncease of Gen scal e
i nt k;
i nt z, zz;
i nt Nval , Nvar ;
i nt Nf r eq, Nf r eq0; ! used t o i dent i f y t he ' Nf r eq' t h f r equency we want
i nt i 1; ! i 1 r epr esent s t he number of var i al be ' m: f ehz'
i nt i 5; ! i s t he vol t age m: u
i nt h;
i nt m;
i nt pNRow, r , r r , r r r ;
i nt a, b, c, d, aa, bb;
i nt dd;
! XXXX kpp addi t i on
i nt kp1, kp2, kp3, kp4, t i ckt ack;
doubl e kpp1, Nval Max, cor r Fact or , Pgenr at et ot 2, xt r aVal , t i ckt ackvar ;
! xxxxx
doubl e Pl oadmax, Pl oadmi n, Pgenmax, Pgenmi n;
doubl e Pgent ot , Pgent ot 1, Pl oadt ot , Pl oadr at et ot , Pgenr at et ot ; ! t ot al Power of Gens and
Loads
doubl e ppl i ni ;
doubl e x, y; ! used t o cal cul at e how many ci r cl es f or l oad
doubl e Scal el oadmi n, Scal el oadmax, Scal egenmi n, Scal egenmax;
doubl e Pgenr at e1, Pgenr at e2, Pgenr at e3, Pgenr at e4, Pgenr at e5;
doubl e Pgen1, Pgen2, Pgen3, Pgen4, Pgen5;
doubl e t i me, f r eq, f r eq0, f r eqr esA, f r eqr esB, l oadr esA, l oadr esB, l oadr es0;
doubl e mi , nj ;
doubl e val ueMat r i x;
doubl e val ueMat r i xSt abl e;
doubl e nor mal , mi n, max;
doubl e v1, v2;
doubl e mi ni mum, maxi mum, GenPower ;
doubl e P;
doubl e cc, cc1, cc2, l oadmi nt op, l oadmaxt op, l oadmi ndown, l oadmaxdown, pgenmax, pgenmi n;
doubl e val ue;
obj ect pComI nc, pComSi m, Obej ct I nRes; ! used f or get t i ng Commands.
obj ect O;
obj ect pEvent , pSwi t chEvt ;
obj ect swi t chevent ;
obj ect r es;
obj ect aGr f , aPg, aPg1, aPl ot 1, aPl ot 2, aPl ot 3, aPl ot 4;
obj ect bus1, bus2;
obj ect OO;
obj ect case;
obj ect Redi r ect ;
st r i ng gener at or ;
set sAl l Load, sAl l Gen; ! used f or col l ect i ng al l l oads and Gens.
set al l El ement s; ! hol ds al l el ement s
set Event s;
set Pl oad, Pgen;
set al l bus;
! - - - - - - - - - - - - - - - - !
! Pr ogr amst ar t i ng!
! - - - - - - - - - - - - - - - - !
Cl ear Out put ( ) ;
EchoOf f ( ) ;
Nval Max=0;
Mat r i xRes. I ni t ( 1, 6) ;
Mat r i xRes. Col Lbl ( ' f r eqr esA' , 1) ;
Mat r i xRes. Col Lbl ( ' l oadr esA' , 2) ;
Mat r i xRes. Col Lbl ( ' f r eqr esB' , 3) ;
Mat r i xRes. Col Lbl ( ' l oadr esB' , 4) ;
Mat r i xRes. Col Lbl ( ' l oadr es0' , 5) ;
Mat r i xRes. Col Lbl ( ' Pgent ot ' , 6) ;
Power Factory ISR Source Code
107
Mat r i xal l . I ni t ( 1, 4) ;
Mat r i xal l . Col Lbl ( ' f r eqr es' , 1) ;
Mat r i xal l . Col Lbl ( ' l oadr es' , 2) ;
Mat r i xal l . Col Lbl ( ' l oadr es0' , 3) ;
Mat r i xal l . Col Lbl ( ' Pgent ot ' , 4) ;
Mat r i xSt abl e. I ni t ( 1, 4) ;
Mat r i xSt abl e. Col Lbl ( ' f r eqr es' , 1) ;
Mat r i xSt abl e. Col Lbl ( ' l oadr es' , 2) ;
Mat r i xSt abl e. Col Lbl ( ' l oadr es0' , 3) ;
Mat r i xSt abl e. Col Lbl ( ' Pgent ot ' , 4) ;
Mat r i xMi nMax. I ni t ( 1, 3) ;
Mat r i xMi nMax. Col Lbl ( ' MI N' , 1) ;
Mat r i xMi nMax. Col Lbl ( ' MAX' , 2) ;
Mat r i xMi nMax. Col Lbl ( ' Pgent ot ' , 3) ;
Max. I ni t ( 1, 2) ;
Max. Col Lbl ( ' Max' , 1) ;
Max. Col Lbl ( ' Pgent ot ' , 2) ;
Mi n. I ni t ( 1, 2) ;
Mi n. Col Lbl ( ' Mi n' , 1) ;
Mi n. Col Lbl ( ' Pgent ot ' , 2) ;
Par aLLEL. I ni t ( 1, 2) ;
Par aLLEL. Col Lbl ( ' l oad' , 2) ;
Par aLLEL. Col Lbl ( ' Pgent ot ' , 2) ;
Mat r i xCur ve. I ni t ( 1, 18) ;
Mat r i xCur ve. Col Lbl ( ' MI NI MUM' , 1) ;
Mat r i xCur ve. Col Lbl ( ' MAXI MUM' , 2) ;
Mat r i xCur ve. Col Lbl ( ' TOTGEN' , 3) ;
Mat r i xCur ve. Col Lbl ( ' Pmax' , 4) ;
Mat r i xCur ve. Col Lbl ( ' Pmi n' , 5) ;
Mat r i xCur ve. Col Lbl ( ' Pl odl i mi t ' , 6) ;
Mat r i xCur ve. Col Lbl ( ' Pl odl i mi t 1' , 7) ;
Mat r i xCur ve. Col Lbl ( ' xaxi s' , 8) ;
Mat r i xCur ve. Col Lbl ( ' yaxi s' , 9) ;
Mat r i xCur ve. Col Lbl ( ' MI NI MUMpct ' , 10) ;
Mat r i xCur ve. Col Lbl ( ' MAXI MUMpct ' , 11) ;
Mat r i xCur ve. Col Lbl ( ' TOTGENpct ' , 12) ;
Mat r i xCur ve. Col Lbl ( ' Pmaxpct ' , 13) ;
Mat r i xCur ve. Col Lbl ( ' Pmi npct ' , 14) ;
Mat r i xCur ve. Col Lbl ( ' Pl odl i mi t pct ' , 15) ;
Mat r i xCur ve. Col Lbl ( ' Pl odl i mi t 1pct ' , 16) ;
Mat r i xCur ve. Col Lbl ( ' xaxi spct ' , 17) ;
Mat r i xCur ve. Col Lbl ( ' yaxi spct ' , 18) ;
Mat r i xXY. I ni t ( 1, 2) ;
Mat r i xXY. Col Lbl ( ' X' , 1) ;
Mat r i xXY. Col Lbl ( ' Y' , 2) ;
! I nt er nal Var i abl es def i ni t i ons
! Resul t s. I ni t ( ) ;
! pComI nc. p_r esvar =Resul t s;
! pComI nc. Execut e( ) ;
! Remi nd oper at or i f al l gr i d has been sel ect ed as ' Gener al Sel ect i on' on page ' Basi c
Opt i ons'
i nput ( sel ect ed, ' Al l i n " Gener al Sel ect i on" ?( 0- Yes, 1- No) ' ) ;
i f ( sel ect ed=1) {
exi t ( ) ;
}
out put ( ' Gener al Sel ect i on i s r eady. ' ) ;
! Get Commands: ' Cal cul at i on of I ni t i al Condi t i ons' &' Run Si mul at i on'
! pComLdf =Get CaseObj ect ( ' ComLdf ' ) ;
pComI nc=Get CaseObj ect ( ' ComI nc' ) ;
pComSi m=Get CaseObj ect ( ' ComSi m' ) ;
! Execut e commands: ' Cal cul at i on of I ni t i al Condi t i ons' &' Run Si mul at i on'
! pComSi m. Execut e( ) ;
! Get Al l l oads and Al l Gens
Power Factory ISR Source Code
108
sAl l Load=SEL. Al l Loads( ) ;
sAl l Gen=SEL. Al l Sym( ) ;
pComI nc. Execut e( ) ;
! Count how many l oads and Gens
l =sAl l Load. Count ( ) ;
g=sAl l Gen. Count ( ) ;
pr i nt f ( ' Ther e ar e \ cc%d \ caLoads and \ cc%d \ caGens. ' , l , g) ;
pr i nt f ( ' ( i ncl udi ng i n ser vi ce and out of ser vi ce. ) ' ) ;
! out put al l l oads' r at es
! ! Sor t obj ect s i n t he set t o t hei r name f r omA t o Z
sAl l Load. Sor t ToName( 0) ;
sAl l Gen. Sor t ToName( 0) ;
! - - - - - - - - - - - - - - - -
! Pr i nt al l l oads.
! - - - - - - - - - - - - - - - -
O=sAl l Load. Fi r st ( ) ;
! Q=sAl l Loador i gi n. Fi r st ( ) ;
! par amet er ' out ser v' r epr esent s ' out of ser vi ce' :
! 0 means i n ser vi ce, 1 means out of ser vi ce.
i f ( O) {
pr i nt f ( ' \ ceLOAD NAME | \ ccRATE MW' ) ;
}
! el se {
! pr i nt f ( ' \ ccTher e i s no l oad. ' ) ;
! exi t ( ) ; }
! par amet er ' out ser v' r epr esent s ' out of ser vi ce' : 0 means i n ser vi ce, 1 means out of
ser vi ce
Pl oadt ot =0; ! i ndi cat e t ot al power of l oads.
h=0;
whi l e ( O) {
i f ( O: out ser v=0)
{
h+=1;
pr i nt f ( ' \ ce%10s \ cc%f ' , O: l oc_name, O: pl i ni ) ;
! pr i nt f ( ' \ ce%10s \ cc%f ' , O: l oc_name, O: m: P: bus1) ;
! pr i nt f ( ' %10s %f ' , O: l oc_name, O: pl i ni ) ;
Pl oadt ot =Pl oadt ot +O: pl i ni ;
}
! Q: ppl i ni =O: pl i ni ;
O=sAl l Load. Next ( ) ;
! Q=sAl l Loador i gi n. Next ( ) ;
}
Pl oadr at et ot =Pl oadt ot ; ! st or e t he r at ed t ot al power t o ' Pl oadr at et ot '
i f ( h=0) {
pr i nt f ( ' \ ccTher e i s no l oads. ' ) ;
exi t ( ) ;
}
el se {
pr i nt f ( ' Tot al r at ed Load Power : \ cc%f \ caMW' , Pl oadr at et ot ) ;
pr i nt f ( ' Ther e ar e \ cc%d \ caLoads i n ser vi ce. ' , h) ;
}
Pl oadmax=Pl oadr at et ot *Pl oadmaxpct ;
Pl oadmi n=Pl oadr at et ot *Pl oadmi npct ;
pr i nt f ( ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ' ) ;
pr i nt f ( ' Pl oadmax=\ cc%f \ caMW Pl oadmi n=\ cc%f \ caMW' , Pl oadmax, Pl oadmi n) ;
pr i nt f ( ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ' ) ;
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! Def i ne Gen. Mat r i x, whi ch st or es r at ed power f or ever y Gen.
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! f r eqMat r i x. I ni t ( 1, 1) ;
! vol t Mat r i x. I ni t ( 1, 1) ;
! caseMat r i x. I ni t ( 1, 1) ;
Power Factory ISR Source Code
109
Mat r i xGen. I ni t ( 1, 1) ;
h=0;
O=sAl l Gen. Fi r st ( ) ;
whi l e ( O) {
i f ( O: out ser v=0)
{
h+=1;
Mat r i xGen. Resi ze( 1, h) ;
Mat r i xGen. Col Lbl ( O: l oc_name, h) ;
Mat r i xGen. Set ( 1, h, O: P_max) ;
}
O=sAl l Gen. Next ( ) ;
}
i f ( h=0) {
pr i nt f ( ' \ ccTher e i s no Gen. ' ) ;
exi t ( ) ;
}
! - - - - - - - - - - - - - - - - - - - - - -
! out put al l Gens' r at es
! - - - - - - - - - - - - - - - - - - - - - -
O=sAl l Gen. Fi r st ( ) ;
i f ( O) {
pr i nt f ( ' \ ceGEN NAME | \ ccRATE MW' ) ;
}
! el se {
! pr i nt f ( ' \ ccTher e i s no Gen. ' ) ;
! exi t ( ) ; }
m=1;
Pgenr at et ot =0; ! r at ed r eal power
! Pgenr at et ot 2=0; ! i s t he r at ed r eal power
whi l e ( m<=h)
{
gener at or =Mat r i xGen. Col Lbl ( m) ;
! val ueMat r i x=Mat r i xGen. Get ( 1, m) ; ! di spat ched
val ueMat r i x=Mat r i xGen. Get ( 1, m) ; ! r at ed power
pr i nt f ( ' \ ce%10s | \ cc%f ' , gener at or , val ueMat r i x) ;
Pgenr at et ot =Pgenr at et ot +val ueMat r i x; ! r eal di spat ched power
! Pgenr at et ot 2=Pgenr at et ot 2+val ueMat r i x2; ! ( r eal r at ed power )
m+=1;
}
! cor r Fact or = Pgenr at et ot / Pgenr at et ot 2; ! wi l l be used t o di spl ay act ual r at ed power on
pl ot s( not di spat ched)
pr i nt f ( ' Tot al Cur r ent Out put Gens: \ cc%f MW' , Pgenr at et ot ) ;
pr i nt f ( ' Tot al Rat ed Gens: \ cc%f MW' , Pgenr at et ot 2) ;
pr i nt f ( ' Ther e ar e \ cc%d Gens: ' , h) ;
pr i nt f ( ' Cur r ent Out put / Rat edout put = \ cc%f : ' , cor r Fact or ) ;
Pgenmax=Pgenr at et ot *Pgenmaxpct ;
Pgenmi n=Pgenr at et ot *Pgenmi npct ;
pr i nt f ( ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ' ) ;
pr i nt f ( ' Pgenmax=\ cc%f MW Pgenmi n=\ cc%f MW' , Pgenmax, Pgenmi n) ;
pr i nt f ( ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ' ) ;
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! def i ne si mul at i on t i me and i sl andi ng t i me
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pComSi m: t st op=Tst op; ! St op t i me, or si mul at i on t i me
pComI nc: t st ar t =Tst ar t ; ! St ar t t i me, can be negat i ve
! pComI nc: dt out =Tst ep; ! St ep t i me
pComI nc: dt gr d=Tst ep; ! St ep t i me: pComI nc: dt out above has no ef f ect .
pr i nt f ( ' Si mul at i on st ar t s at \ ceTst ar t =\ cc%8. 5f \ cas' , pComI nc: t st ar t ) ;
pr i nt f ( ' Ti me st ep i s: \ ceTst ep=\ cc%8. 5f \ cas' , pComI nc: dt out ) ;
pr i nt f ( ' Si mul at i on st ops at \ ceTst op=\ cc%8. 5f \ cas' , pComSi m: t st op) ;
! - - - - - - - - - - - - - - - - - - -
Power Factory ISR Source Code
110
! Sear ch Swi t ch Event
! - - - - - - - - - - - - - - - - - - -
pEvent =pComI nc: p_event ;
Event s=pEvent . Get Cont ent s( ) ;
pSwi t chEvt =Event s. Fi r st Fi l t ( ' *. Evt Swi t ch' ) ;
! pSwi t chEvt =Event s. Fi r st Fi l t ( ' i sl and. Evt Swi t ch' ) ;
! i f ( pSwi t chEvt . and. pSwi t chEvt : out ser v=0)
! {swi t chevent =pSwi t chEvt ;
! }
whi l e( pSwi t chEvt ) {
i f ( pSwi t chEvt : out ser v=0)
{swi t chevent =pSwi t chEvt ;
}
pSwi t chEvt =Event s. Next Fi l t ( ) ;
}
! i f ( pSwi t chEvt =0) {
! pr i nt f ( ' Ther e i s no Swi t chEvent . ' ) ;
! exi t ( ) ;
! }
swi t chevent : t i me=Ti sl and; ! i sl andi ng t i me
pr i nt f ( ' I sl and moment at \ ceTi sl and=\ cc%f \ cas' , Ti sl and) ;
! }
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! Def i ne change r ange f or l oads and Gen.
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! how many cycl es f or l oad change?
i =f l oor ( ( 1- Pl oadmi npct ) / Scal eLoad) *( - 1) ;
mi =f l oor ( ( Pl oadmaxpct - 1) / Scal eLoad) ;
Scal el oadmi n=1+Scal eLoad*i ;
Scal el oadmax=1+Scal eLoad*mi ;
! Scal el oadmax=1+Scal eLoad*f l oor ( ( Pl oadmax/ Pl oadr at et ot - 1) / Scal eLoad) ;
pr i nt f ( ' Load changes f r om \ cc%f \ cat o \ cc%f , \ caby Scal eLoad. ' , Scal el oadmi n,
Scal el oadmax) ;
! how many cycl es f or Gen. change?
j =f l oor ( ( 1- Pgenmi npct ) / Scal eGen) *( - 1) ;
nj =f l oor ( ( ( Pgenmax/ Pgenr at et ot ) - 1) / Scal eGen) ;
pr i nt f ( ' j i s \ cc%f \ ca and j n i s \ cc%f ' , j , nj ) ;
! j =f l oor ( ( 1- Pgenmi n/ Pgenr at et ot ) / Scal eGen) *( - 1) ;
Scal egenmi n=1+Scal eGen*j ;
Scal egenmax=1+Scal eGen*nj ;
! Scal egenmax=1+Scal eGen*f l oor ( ( Pgenmax/ Pgenr at et ot - 1) / Scal eGen) ;
pr i nt f ( ' Gen. changes f r om \ cc%f \ cat o \ cc%f , \ caby Scal eGen. ' , Scal egenmi n,
Scal egenmax) ;
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! def i ne var i abl es t o obser ve syst emf r equency
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
al l bus=SEL. Al l Bar s( ) ;
bus1=al l bus. Fi r st Fi l t ( Busi sl and) ;
bus2=al l bus. Fi r st Fi l t ( Busext er nal ) ;
NewI sl andi ngResul t s. AddVar s( bus1, ' m: f ehz' ) ;
NewI sl andi ngResul t s. AddVar s( bus2, ' m: f ehz' ) ;
NewI sl andi ngResul t s. AddVar s( bus1, ' m: u' ) ;
! pComI nc: p_r esvar =NewI sl andi ngResul t s;
! pComI nc. Execut e( ) ;
! pComSi m. Execut e( ) ;
! - - - - - - - - -
! dr aw pl ot
! - - - - - - - - -
pComI nc: p_r esvar =NewI sl andi ngResul t s;
aGr f =Get Gr aphBoar d( ) ;
Power Factory ISR Source Code
111
i f ( aGr f ) {
aPg=aGr f . Get Page( ' Fr equency' , 1) ;
i f ( aPg) {
aPl ot 1=aPg. Get VI ( ' Fr eq- i sl and' , ' Vi sPl ot ' , 1) ;
i f ( aPl ot 1) {
aPl ot 1. Cl ear ( ) ;
aPl ot 1. AddResVar s( NewI sl andi ngResul t s, ' m: f ehz' , bus1) ;
aPl ot 1. Set Scal eY( ) ; ! aut oscal e Y- axi s, i f no scal ei ng
aPl ot 1. Set Scal eX( ) ; ! aut oscal e X- axi s, i f no scal ei ng
}
aPl ot 2=aPg. Get VI ( ' Fr eq- Ext er nal ' , ' Vi sPl ot ' , 1) ;
i f ( aPl ot 2) {
aPl ot 2. Cl ear ( ) ;
aPl ot 2. AddResVar s( NewI sl andi ngResul t s, ' m: f ehz' , bus2) ;
aPl ot 2. Set Scal eY( ) ; ! aut oscal e Y- axi s
aPl ot 2. Set Scal eX( ) ; ! aut oscal e X- axi s
}
}
}
! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX st ar t
! Bef or e l oops st ar t , t he 3r d ( ext r a) par amet er must be saved so i t can be r est or ed
! Mat r i xXt r a. I ni t ( 1, 1) ;
! h=0;
! al l El ement s=Al l Rel evant ( ) ; ! add al l el ement s t o t he set
! O=al l El ement s. Fi r st Fi l t ( ' *. TypSym' ) ; ! Fi l t er so onl y synTyp ar e consi der ed, t hi s
hi l ds i ner t i a
! whi l e ( O) {
! h+=1;
! pr i nt f ( ' Xt r a i t emnumber %d i s bei ng pr ocessed' , h) ;
! Mat r i xXt r a. Resi ze( 1, h) ;
! Mat r i xXt r a. Set ( 1, h, O: hpn) ;
! O=al l El ement s. Next Fi l t ( ) ;
! }
! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end
! - - - - - - - - - - - - - - - - - - - -
! Two l oops st ar t her e
! - - - - - - - - - - - - - - - - - - - -
k=1;
z=1;
zz=1;
! - - - - - - - - - - - - - - - - - - - - -
! - - - - - - - - - - - - - - - - - - - - -
! OUTER LOOP f or 3r d par amet er .
! - - - - - - - - - - - - - - - - - - - - -
! - - - - - - - - - - - - - - - - - - - - -
f r eqr esA=0;
l oadr esA=0;
f r eqr esB=0;
l oadr esB=0;
kp2=1;
kp4=1;
xt r aVal =xt r ami npct ;
! st ar t 3r d l oop out si de l oad and gen l oop.
Power Factory ISR Source Code
112
whi l e ( xt r aVal <= xt r amaxpct )
{
! set each el ement t hat needs t o be changed her e, st ar t at xt r ami n t hen add i ncr ease by
xt r aval
O=al l El ement s. Fi r st Fi l t ( ' *. TypSym' ) ;
h=0;
! set count er par amet er f or gen l oop t o or i gi nal val ue
pr i nt f ( ' xt r aVal f oi ng f r om \ cc%f \ ca t o \ cc%f \ ca, now at \ cc%f ' ,
xt r ami npct , xt r amaxpct , xt r aVal ) ;
! - - - - - - - - - - - - - - - - - - - - -
! - - - - - - - - - - - - - - - - - - - - -
! OUTER LOOP f or Gen.
! - - - - - - - - - - - - - - - - - - - - -
t i ckt ack=1;
O=sAl l Gen. Fi r st ( ) ;
h=0;
whi l e ( O)
{
i f ( O: out ser v=0)
{
h+=1;
val ueMat r i x=Mat r i xGen. Get ( 1, h) ;
gener at or =Mat r i xGen. Col Lbl ( h) ;
O: pgi ni =val ueMat r i x*( 1+j *Scal eGen) +xt r aVal / 2*t i ckt ack; ! adds 5 MWt o f yr st , subt r act s
f r omnext
t i ckt ack=t i ckt ack*( - 1) ;
! Pgen1=O: pgi ni ;
Pgent ot =Pgent ot +O: pgi ni ;
pr i nt f ( ' Power of Gen\ cc%10s \ cai s changed t o \ cc%f \ ca, scal egenf acot r , \ cc%f , t i ckt ack
f l ag i s, %f ' , gener at or , O: pgi ni , 1+j *Scal eGen, t i ckt ack) ;
}
O=sAl l Gen. Next ( ) ;
}
! pr i nt f ( ' Now t he t ot al Gen. i s: %f ' , Pgent ot ) ;
! - - - - - - - - - - - - - - - - - - - - -
! I NNER LOOP f or l oad
! - - - - - - - - - - - - - - - - - - - - -
i =f l oor ( ( 1- Pl oadmi npct ) / Scal eLoad) *( - 1) ;
whi l e ( i <=mi ) {
Pl oadt ot =0;
! pr i nt f ( ' i =%d' , i ) ;
O=sAl l Load. Fi r st ( ) ;
whi l e ( O) {
! pr i nt f ( ' %10s %f ' , O: l oc_name, O: m: P: bus1) ;
i f ( O: out ser v=0)
{
O: scal e0=1+Scal eLoad*i ;
pComI nc. Execut e( ) ;
Pl oadt ot =Pl oadt ot +O: m: P: bus1;
}
O=sAl l Load. Next ( ) ;
}
! pr i nt f ( ' Now t he t ot al l oad i s: %f ' , Pl oadt ot ) ;
i f ( maxDi f f >=abs( Pl oadt ot - Pgent ot ) ) ! i f t he di f f er ence bet ween l oad and gen i s t o gr eat ,
t hen no need t o r un si m. assumed unst abl e
{
pComI nc. Execut e( ) ;
pComSi m. Execut e( ) ;
! ******Obt ai n f r eq. val ue at 15s, and j udge whet her f r eq. wi t hi n [ 49. 9, 50. 1]
! obt ai n t he want ed f r equency
Power Factory ISR Source Code
113
r es=pComI nc: p_r esvar ;
LoadResDat a( r es) ;
Nval =ResNval ( r es, 0) ;
Nvar =ResNvar s( r es) ;
i f ( Nval >Nval Max)
{
Nval Max=Nval ;
}
! pr i nt f ( ' %8. 5f ' , Nval ) ;
! pr i nt f ( ' %8. 5f ' , Nvar ) ;
i 1=ResI ndex( r es, bus1, ' m: f ehz' ) ;
i 5=ResI ndex( r es, bus1, ' m: u' ) ; ! Ret ur ns t he col umn number of t he
var i abl e m: u( vol t age) of obj ect Bus1( i sl and bus) i n t he r esul t obj ect ' r es'
Nf r eq=( ( ( Ti sl and+Tobser ve) / Tst ep) - Tst ar t / Tst ep) +1;
Nf r eq0=( ( Tbef or e/ Tst ep) - Tst ar t / Tst ep) +1;
Get ResDat a( t i me, r es, Nf r eq) ;
Get ResDat a( f r eq, r es, Nf r eq, i 1) ;
Get ResDat a( f r eq0, r es, Nf r eq0, i 1) ;
! XXXXXXXmy addi t i on
! save t he f r equency car act er i st i c t o mat r i x f i l e
! and vol t age t o mat r i x f i l e
kp1=1;
whi l e ( kp1<=Nval )
{
Get ResDat a( kpp1, r es, kp1, i 1) ; ! i 1 i ndexes f r equency
col umn
! kpp1 onl y t empor er i l y
st or es t he val ue r eached
f r eqMat r i x. Set ( kp1, kp2, kpp1) ; ! val ue put i nt o kpp
mat r i x
f r eqMat r i x. Set ( kp1, kp2+1, ( Tst op- Tst ar t ) / Nval *kp1+Tst ar t ) ; ! set s t i me val ue
cor r ect l y f or f or f r equency
Get ResDat a( kpp1, r es, kp1, i 5) ;
vol t Mat r i x. Set ( kp1, kp4, kpp1) ; ! val ue put i nt o kpp
mat r i x
kp1+=1;
}
! save t he Load and Gen dat e t o a mat r i x f i l e
caseMat r i x. Set ( 1, kp4, ( 1+j *Scal eGen) ) ; ! r ow one hol ds t ot al power gener at ed
by t he gener at or sbef or e i sl andi ng
caseMat r i x. Set ( 2, kp4, ( 1+Scal eLoad*i ) ) ; ! r ow t wo hol ds l oad pct / 2 bevause
t hen t he scal e f i t s ni cel y wi t h gen scal e.
caseMat r i x. Set ( 3, kp4, Pgent ot ) ; ! r ow t wo hol ds r eal gen power
caseMat r i x. Set ( 4, kp4, Pl oadt ot ) ; ! r ow t wo hol ds r eal l oad wi t hout l osses
caseMat r i x. Set ( 5, kp4, xt r aVal ) ; ! r ow hol ds val ue of i ner t i a or ot her par amet er
t hat i s beei ng sweeped.
kp4+=1;
kp2+=2;
! XXXXXXX
! J udge whet her f r eq. i s wi t hi n accept ed st andar d?
i f
( f r eq<50. 2. and. f r eq>49. 8. and. f r eq0<50. 01. and. f r eq0>49. 99. and. Pl oadt ot >Pl oadmi n. and. Pl oad
t ot <Pl oadmax)
{f r eqr esA=f r eq;
pr i nt f ( ' \ ceSt abl e\ ca: Pl oad=%f , Pgen=%f , di f f er ence=%f i n gen pct of l oad =\ ce%f ' ,
Pl oadt ot , Pgent ot , abs( Pl oadt ot - Pgent ot ) , ( Pl oadt ot - Pgent ot ) / Pgent ot ) ;
O=al l El ement s. Fi r st Fi l t ( ' *. TypSym' ) ;
Power Factory ISR Source Code
114
! ####t o make sur e 3r d par amet er i s changed ####
h=0;
whi l e ( O)
{
h+=1;
pr i nt f ( ' Par amet er of el ement %d set t o %f ' , h, O: hpn) ;
O=al l El ement s. Next Fi l t ( ) ;
}
! ####t o make sur e 3r d par amet er i s changed ####
l oadr esA=Pl oadt ot ;
! pr i nt f ( ' i =%d' , i ) ;
l oadr es0=Pl oadr at et ot *( 1+Scal eLoad*i ) ; ! used t o conf i r m
! whet her t he val ue of ' l oadr esA' i s cor r ect .
! pr i nt f ( ' Tot al Loads: %f MW_af t er i sl andi ng_st abl e' , Pl oadt ot ) ;
! Mat r i xal l . Col Lbl ( ' f r eqr es' , 1) ;
! Mat r i xal l . Col Lbl ( ' l oadr es' , 2) ;
! Mat r i xal l . Col Lbl ( ' Pgent ot ' , 3) ;
Mat r i xal l . Set ( z, 1, f r eqr esA) ;
Mat r i xal l . Set ( z, 2, l oadr esA) ;
Mat r i xal l . Set ( z, 3, l oadr es0) ;
Mat r i xal l . Set ( z, 4, Pgent ot ) ;
Mat r i xSt abl e. Set ( zz, 1, f r eqr esA) ;
Mat r i xSt abl e. Set ( zz, 2, l oadr esA) ;
Mat r i xSt abl e. Set ( zz, 3, l oadr es0) ;
Mat r i xSt abl e. Set ( zz, 4, Pgent ot ) ;
z+=1;
zz+=1;
! i +=1;
}
el se {
! l +=1;
pr i nt f ( ' f _bef or e = %f Hz f _af t er = %f Hz Load i s %f and gen i s %f ' ,
f r eq0, f r eq, 1+Scal eLoad*i , 1+j *Scal eGen) ;
pr i nt f ( ' \ ccUnst abl e\ ca: Pl oad=%f , Pgen=%f , di f f er ence=%f i n gen pct of l oad =\ cc%f ' ,
Pl oadt ot , Pgent ot , abs( Pl oadt ot - Pgent ot ) , ( Pl oadt ot - Pgent ot ) / Pgent ot ) ;
f r eqr esB=f r eq; l oadr esB=Pl oadt ot ;
! pr i nt i nf o f or each t hat i s not st abl e
l oadr es0=Pl oadr at et ot *( 1+Scal eLoad*i ) ;
z+=1;
! i +=1;
}
}! end of i f l oop, whi ch l i mi t s number of si mul at i ons of gen and l oad di f f i s t oo hi gh
i +=1;
} ! end of l oad l oop
j +=1;
}! end of gen l oop
xt r aVal =xt r aVal +xt r aSt ep;
}! end of my l oop, f or t he xt r a par amt er er ( out er most )
! Wr i t e t o f i l es - - - - - - - - - - - - - - - - - - -
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! wr i t e f r eqMat r i x f i l e t o t xt f i l e
f open( f r eqTxt , ' w' , 0) ; ! t hi s opens t he out put f i l e and
del et s what ever i s i n i t .
! out put Txt hol ds t he l ocat i on on
har ddi sk wher e f i l e wi l l be st or ed
kp3=1;
Set Li neFeed( 0) ; ! no aut omat i c l i ne br eaks
Power Factory ISR Source Code
115
whi l e( kp3<=Nval Max) ! out er l oop, sweeps each col umn
{
kp1=1;
whi l e ( kp1<=kp2- 1) ! now sweepi ng each r ow f or val ues
and appendi ng on t he back of st r i ng
{
! get mat r i xval ue
kpp1=f r eqMat r i x. Get ( kp3, kp1) ;
! pr i nt t o f i l e
f pr i nt f ( 0, ' %f \ t ' , kpp1) ;
kp1+=1;
}
f pr i nt f ( 0, ' \ n' ) ; ! i nser t a l i ne- f eed
kp3+=1;
}
f cl ose( 0) ;
Set Li neFeed( 1) ; ! no aut omat i c l i ne br eaks
! wr i t e vol t Mat r i x f i l e t o t xt f i l e
f open( vol t Txt , ' w' , 0) ; ! t hi s opens t he out put f i l e and
del et s what ever i s i n i t .
! out put Txt hol ds t he l ocat i on on
har ddi sk wher e f i l e wi l l be st or ed
kp3=1;
Set Li neFeed( 0) ;
whi l e( kp3<=Nval Max) ! out er l oop, sweeps each col umn
{
kp1=1;
whi l e ( kp1<kp4) ! now sweepi ng each r ow f or val ues and
appendi ng on t he back of st r i ng
{
! get mat r i xval ue
kpp1=vol t Mat r i x. Get ( kp3, kp1) ;
! pr i nt t o f i l e
f pr i nt f ( 0, ' %f \ t ' , kpp1) ;
kp1+=1;
}
f pr i nt f ( 0, ' \ n' ) ; ! i nser t a l i ne- f eed
kp3+=1;
}
f cl ose( 0) ;
Set Li neFeed( 1) ; ! aut omat i c l i ne br eaks
! wr i t e caseMat r i x f i l e t o t xt f i l e
f open( caseTxt , ' w' , 0) ; ! t hi s opens t he out put f i l e and del et s what ever i s i n
i t .
! out put Txt hol ds t he l ocat i on on har ddi sk wher e f i l e
wi l l be st or ed
Set Li neFeed( 0) ;
kp3=1;
whi l e( kp3<=5) ! set t o 4 r ows, because at t he moment onl y 4 var s ar e saved i n t he
mat r i x, can be changed l at er .
{
kp1=1;
whi l e ( kp1<kp4) ! now sweepi ng each r ow f or val ues and appendi ng on t he back of
st r i ng
{
! get mat r i xval ue
kpp1=caseMat r i x. Get ( kp3, kp1) ; ! kp3 i ndi cat es what r ow, her e r ow 1
i s gen dat a, r ow 2 i s l oad dat a
! wr i t e t o f i l e
f pr i nt f ( 0, ' %f \ t ' , kpp1) ;
Power Factory ISR Source Code
116
kp1+=1;
}
f pr i nt f ( 0, ' \ n' ) ; ! new l i ne
kp3+=1;
}
f cl ose( 0) ;
Set Li neFeed( 1) ; ! aut omat i c l i ne br eaks on.
! wr i t e Set t i ngs f i l e t o t xt f i l e
! set t i ngs wi l l be used t o i nf or mmat l ab what ki nd of si mul at i on i s bei ng i mpor t ed.
f open( set t i ngsTxt , ' w' , 0) ; ! t hi s opens t he out put f i l e and del et s what ever i s
i n i t .
! out put Txt hol ds t he l ocat i on on har ddi sk wher e f i l e
wi l l be st or ed
Set Li neFeed( 0) ;
! wr i t e t o f i l e
f pr i nt f ( 0, ' %f \ t ' , 3D) ; ! f i r st r ow wi l l i nf or mi f t he r esul t s ar e 1=3D or 0=2D
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Scal eLoad) ; ! second i nf or mst epsi ze i n l oad changes
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Scal eGen) ; ! t hi r d r ow wi l l i nf or mt epsi ze i n gen changes
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Pgenmaxpct *cor r Fact or ) ; ! 4 wi l l i nf or mMax Gen l i mi t , i n PU
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Pgenmi npct *cor r Fact or ) ; ! 5 wi l l i nf or mMi n Gen l i mi t , i n PU
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Pl oadmaxpct *cor r Fact or ) ; ! 6 wi l l i nf or mMmax l oad l i mi t , i n
PU
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Pl oadmi npct *cor r Fact or ) ; ! 7 wi l l i nf or m Mi n l oad l i mi t , i n
PU
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Tst op- Tst ar t ) ; ! 8 r ow wi l l i nf or mt ot al si mul at i on t i me
f pr i nt f ( 0, ' \ n' ) ;
f pr i nt f ( 0, ' %f \ t ' , Tst ep) ; ! 9 r ow wi l l i nf or mst epsi ze f or si mul at i on t i me
f pr i nt f ( 0, ' \ n' ) ;
f cl ose( 0) ;
Set Li neFeed( 1) ;
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
! Recover al l syst emdat a
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
Pgent ot =0;
O=sAl l Load. Fi r st ( ) ;
whi l e ( O) {
O: scal e0=1;
O=sAl l Load. Next ( ) ;
}
! r est or e ext r a par amet er
O=al l El ement s. Fi r st Fi l t ( ' *. TypSym' ) ; ! Fi l t er so onl y synTyp ar e consi der ed, t hi s hi l ds
i ner t i a
h=0;
whi l e ( O) {
h+=1;
kpp1=Mat r i xXt r a. Get ( 1, h) ;
O: hpn=kpp1;
O=al l El ement s. Next Fi l t ( ) ;
}
! r est or e gener at or dat a
O=sAl l Gen. Fi r st ( ) ;
h=0;
whi l e ( O)
{
i f ( O: out ser v=0)
{
h+=1;
val ueMat r i x=Mat r i xGen. Get ( 1, h) ;
O: pgi ni =val ueMat r i x;
Power Factory ISR Source Code
117
Pgent ot =Pgent ot +O: pgi ni ;
pr i nt f ( ' Power of Gen%d i s back t o %f MW. ' , h, val ueMat r i x) ;
}
O=sAl l Gen. Next ( ) ;
}
pr i nt f ( ' Tot al Gen. i s back t o %f MW. ' , Pgent ot ) ;
pComI nc. Execut e( ) ;
pComSi m. Execut e( ) ;
EchoOn( ) ;
119
C
COMPONENT DETAILS FOR THE PF DEMO
MODEL
This Appendix includes more details, than included in the main report, about each
component used in the island model.
There are three generators in the grid, their main parameters are as follows in Table C-1.
Generator Type Rated Power [MW] Rated Voltage [kV] Inertia [s] Control
G1 Sync. 247,5 16,5 9,55 VCO
G2 Sync. 192 18,0 4,165 VCO
G3 Sync. 128 13,8 2,756 VCO
Table C-1: Generators in the original island model
The three transformers as shown in Table C-2.
Transformer Rated Power [MVA] Rated HV [kV] Rated LV [kV]
T1 250 230 16,5
T2 200 230 18
T3 108,8 230 13,8
Table C-2: Transformers in the original island model.
Transmission lines, are labeled as overhead lines but can be assumed to be cables due to
the fact that they have very high capacitance, see Table C-3
Component Details for the PF demo model
120
Line Rated Current [kA] Impedance [] Susceptance[S]
Line 1 1,000 5,290+j44,965 332,70
Line 2a+b 1,000 16,928+j85,169 578,45
Line 3 1,000 4,4965+j38,088 281,66
Line 4 1,000 6,2951+j53,3232 395,08
Line 5 1,000 20,631+j89,83 676,75
Line 6 1,000 8,993+j48,668 298,69
Table C-3: Lines in the original island model.
There are three loads in the grid, see Table C-4
Loads Active Power [MW] Reactive Power [ MVAr]
Load A 125 50
Load B 90 30
Load C 108,8 23
Table C-4: Loads in the original island model.
Generators
G1- Details
Component Details for the PF demo model
121
Component Details for the PF demo model
122
Component Details for the PF demo model
123
G2 Details
Component Details for the PF demo model
124
Component Details for the PF demo model
125
G3 Details
Component Details for the PF demo model
126
Component Details for the PF demo model
127
Transformers
T1 Details
T2 Details
Component Details for the PF demo model
128
T3 Details
Component Details for the PF demo model
129
Lines:
Line 1 Details
Component Details for the PF demo model
130
Component Details for the PF demo model
131
Line 2 a Details
Component Details for the PF demo model
132
Line 2 b Details
Component Details for the PF demo model
133
Component Details for the PF demo model
134
Line 3 Details
Component Details for the PF demo model
135
Component Details for the PF demo model
136
Line 4 Details
Component Details for the PF demo model
137
Component Details for the PF demo model
138
Line 5 Details
Component Details for the PF demo model
139
Line 6 Details
Component Details for the PF demo model
140
Component Details for the PF demo model
141
143
D
MATLAB CALCULATIONS AND SCRIPTS
In this appendix the source code for the matlab calculations and plots introduced in the
main rapport is available. Also the files are included in the attached CD at the folder.
[CD-drive] :\Calculations\Matlab_Files \
Illustration of droop
Matlab code, droop.m:
%
%Pur pose: i l l ust r at e dr oop
%
%I nput : see par amt er s
%
%Out put : pl ot of P and f r el at i onshi p f or dr oop cont r ol l ed gener at or
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
%dr oop cur ve
%par amet er s:
R=0. 05; %dr oop
f _syst em=50; %syst emf r equency
%f r eq cal cul at i ons
del t a_f =R*f _syst em;
f _f ul l l oad=f _syst em- del t a_f / 2;
f _nol oad=f _syst em+del t a_f / 2; ;
%l oad set , i n pu.
p_nol oad=0 %no l oad
p_f ul l l oad=247. 5 %f ul l l oad
%sl ope
h=( f _f ul l l oad- f _nol oad)
%x- val ues
p=p_nol oad: 1: p_f ul l l oad;
%y- val ues
f =f _nol oad+p. *h/ p_f ul l l oad;
%pl ot
f i gur e( 1)
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] ) %set s col or s of f i gur e, al l whi t e
pl ot ( p, f )
axi s( [ p_nol oad p_f ul l l oad f _f ul l l oad- f _f ul l l oad*0. 02 f _nol oad+f _nol oad*0. 02] )
t i t l e( [ ' Rel at i onshi p bet ween power out put and f r equency.
f _n_o_l _o_a_d=' , num2st r ( f _nol oad) , ' Hz and f _f _u_l _l _l _o_a_d=' ,
num2st r ( f _f ul l l oad) , ' Hz' ] )
xl abel ( ' Gener at or Out put , [ pu] ' )
yl abel ( ' Fr equency [ Hz] ' )
Matlab Calculations and Scripts
144
Plot of ISR considering only steadty state frequency limits
Matlab code, steadystateISR.m:
%
%Pur pose: devel opi ng t heor et i cal st eady st at e f r equency I SR r egi on
%
%I nput : see par amt er s
%
%Out put : pl ot of t he I SR based on st eady st at e f r eq l i mi t s.
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
%assumi ng st eady st at e i s r eached wi t hi n 15 seconds.
%Li mi t s
f _max = 50. 2; %upper l i mi t f or al l owed f r equency.
f _mi n = 49. 8; %l ower l i mi t f or al l owed f r equency.
f _syst em= 50; %syst emf r equency
%par amet er s
P_r at ed = 192+128; %t ot al r at ed power wi t hi n t he i sl and
K_i sl and = 192+85. 33; %r egul at i ng const . f or al l gener at or s i n t he i sl and
%cal cul at i on of Power l i mi t s
P_expor t =( f _max- f _syst em) *K_i sl and;
P_i mpor t =( f _mi n- f _syst em) *K_i sl and;
%set X val ues, l oad as 0 t o Pr at ed
l oad=0: 1: P_r at ed;
%syt Y val ues f or l i mi t s f or when i sl and i s en expor t mode
P_l i m_expor t = l oad+P_expor t ;
%syt Y val ues f or l i mi t s f or when i sl and i s en i mpor t mode
P_l i m_i mpor t = l oad+P_i mpor t ;
%pl ot l i mi t s
f i gur e( 1)
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] ) %set s col or s of f i gur e, al l whi t e
pl ot ( l oad, P_l i m_expor t , l oad, P_l i m_i mpor t )
axi s( [ 0 P_r at ed 0 P_r at ed] )
t i t l e( ' St eady St at e Fr equency Li mi t s' )
yl abel ( ' Power Gener at i on pr e- i sl andi ng [ MW] ' )
xl abel ( ' Load [ MW] ' )
l egend( ' Upper l i mi t , Power expor t mode' , ' l ower l i mi t , Power i mpor t mode' . . .
, ' l ocat i on' , ' Sout hEast ' )
Developing df/dt=f(H)
Swing equation:
e m a
m
T T T
dt
d
J = =
J is combined moment of inertia for generator and turbine [kgm
2
]
m
is the angular velocity of the rotor [rad/s]
T
a
is the accelerating torque [Nm]
T
m
is the mechanical torque [Nm]
T
e
is the electrical torque [Nm]
J, Moment of inertia in terms of H(pu inertia)
Matlab Calculations and Scripts
145
base
m
S
H
J =
2
0
2
S is base value of appearant power
H is inertia in pu sec
P=T and E=HS
system
system
E
f P
dt
df
=
2
P is change in power
Analyzing frequency response of a system based on parameters, prime mover time
constant (T
a
), island system inertia (H) and generator controller droop (R)
Also plot of ISR considering only steadty state frequency derivative limits for the given
system parameters.
Matlab code, freqDerivative.m:
%scr i pt " f r eqDer i vat i ve. m"
%
%Pur pose: 1. anal yse t he f r eq. r esponse wi t h r espect t o di f f er ent par amet er s
% 2. def i ne an I SR based on t he f r equency der i vat i ve cr i t er i a
%
%I nput : see par amt er s
%
%Out put : f r equency r esponse
%
%wr i t t en 2009 as a par t of MSc t hesi s
%Kr i st j an P Pet ur sson, st nr . s071538
%par amt er s
%machi ne par amt er s
Pr at ed=[ 192 128] ; %r at ed P
Hgen=[ 4. 125 2. 765] ; %i ner t i a f act or
R=[ 2 3] ; %dr oop i n per sent age case2
%ot her par amt er s
f N=50; %syst emf r equency
Ta=0. 2; %Ta t i me const ant f or pr i me mover
dP=- 10;
t _st ep=0: 0. 002: 10; %si mul at i on t i me and st epsei ze, her e l i mi t ed
%t o 10 seconds
df dt cr i t er i a=2. 5; %cr i t er a f or accept abl e f r equency der i vat i ve
%Base val ues. Base val ues can be set her e do r epr esent r esul t s i n pu.
Sbase=1; %i n MVA
f base=1; %Hz
%Cal cul at i on of ot her base val ues
Kbase = Sbase/ f base; %MW/ HZ
Hbase = 1/ f base;
%Regul at i on const ant s f or each machi ne,
f or k=1: l engt h( Pr at ed)
K( k) =Pr at ed( k) / R( k) / f N*100;
end
%Ksyst emand f r equency and power mi smat ch( i n pu i f base val ues ar e set i n
%par amt er s)
Ksyst empu=sum( K/ Kbase) ;
f Npu=f N/ f base;
dPpu=dP/ Sbase;
Matlab Calculations and Scripts
146
%Rot at i onal ener gy of t he syst emconst ant ( p. u. i f set )
f or k=1: l engt h( Hgen)
Er ot ( k) =Hgen( k) *Pr at ed( k) ; %Ki net i c ener gy of t he syst em
end
Hsyst em= sum( Er ot ) / sum( Pr at ed) ;
%Syst emt r ansf er f unct i on:
%Ther e ar e many ways t o const r uct t he t r ansf er f unct i on, but I f eel t hat
%t he f ol l owi ng i s t he most i l l ust r at i ve, t hi s i s al so how i t i s shown i n
%t he r epor t
%The f ol l owi ng not at i on i s used
%E( s) i s t he t r ansf er f unct i on f or i ner t i a
%F( s) i s t he t r ansf er f unct i on f or pr i me mover
%G( s) i s t he t r ansf er f unct i on f or conot r ol l er ( gai n)
E=t f ( 1, [ 2*Hsyst em0] ) ; %i ner t i a
F=t f ( 1, [ Ta 1] ) ; %pr i me mover
G=Ksyst empu; %si mpl e gai n t o r epr esent t he dr oop cont r ol
H=E/ ( 1+E*F*G) %t he t r ansf er f unct i on
%
%i nf l uence of t he cont r ol l er dr oop par amet er , 3 set t i ngs t est ed
%========================================================================
%nor mal dr oop
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta 1] ) ;
G=Ksyst empu;
H=E/ ( 1+E*F*G)
f i gur e( 1)
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] ) %set s col or s of f i gur e, al l whi t e
[ y, x] =st ep( f N+dPpu*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' g' ) %
[ t emp1, t emp2] =si ze( y) ;
f _st eady1=y( t emp1, t emp2) ;
hol d on
%der i vat i ve
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' g' )
peak1=max( abs( a( : , 1) ) ) ;
hol d on
%i ncr eased dr oop
Rpct =200; %dr oop i ncr ease t o 200%
f or k=1: l engt h( Pr at ed)
K( k) =Pr at ed( k) / ( R( k) *Rpct / 100) / f N*100;
end
Ksyst empu=sum( K/ Kbase) ;
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta 1] ) ;
G=Ksyst empu;
H=E/ ( 1+E*F*G)
[ y, x] =st ep( f N+dPpu/ 1*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' b' )
[ t emp1, t emp2] =si ze( y) ;
f _st eady2=y( t emp1, t emp2) ;
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' b' )
peak2=max( abs( a( : , 1) ) ) ;
%
%decr eased dr oop
Rpct =50; %dr oop i ncr ease t o 50%
f or k=1: l engt h( Pr at ed)
K( k) =Pr at ed( k) / ( R( k) *Rpct / 100) / f N*100;
end
Ksyst empu=sum( K/ Kbase) ;
E=t f ( 1, [ 2*Hsyst em0] ) ;
Matlab Calculations and Scripts
147
F=t f ( 1, [ Ta 1] ) ;
G=Ksyst empu;
H=E/ ( 1+E*F*G)
[ y, x] =st ep( f N+dPpu*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' r ' )
[ t emp1, t emp2] =si ze( y) ;
f _st eady3=y( t emp1, t emp2) ;
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' r ' )
peak3=max( abs( a( : , 1) ) ) ;
%pl ot t i ng par amet er s, t ext and l egends
subpl ot ( 2, 1, 1) , l egend( [ ' R \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady1) , ' Hz' ] , [ ' R\ cdot 200% \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady2) , ' Hz' ] , [ ' R\ cdot 50% \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady3) , ' Hz' ] , ' Locat i on' , ' Sout hEast ' )
subpl ot ( 2, 1, 2) , l egend( [ ' R \ r i ght ar r ow df / dt = ' , num2st r ( peak1) ] , [ ' R\ cdot 200% \ r i ght ar r ow
df / dt = ' , num2st r ( peak2) ] , [ ' R\ cdot 50% \ r i ght ar r ow df / dt =
' , num2st r ( peak3) ] , ' Locat i on' , ' Sout hEast ' )
subpl ot ( 2, 1, 1) , t i t l e( [ ' Fr equency Response when Due t o I sl andi ng Tr ansi t i on, \ Del t aP =
' , num2st r ( dP) , ' MW' ] )
subpl ot ( 2, 1, 2) , t i t l e( [ ' Fr equency Der i vat i ve f or same Condi t i ons' ] )
subpl ot ( 2, 1, 2) , xl abel ( ' Ti me [ s] - I sl andi ng t r ansi t i on at t =0' )
subpl ot ( 2, 1, 1) , yl abel ( ' Fr equency [ Hz] ' )
subpl ot ( 2, 1, 2) , yl abel ( ' Fr equency [ Hz] ' )
hol d of f
%
%i nf l uence of t he gener at or i ner t i a, 3 set t i ngs t est ed
%========================================================================
%nor mal i ner t i a
%r eset t i ng dr oop as set i n par amet er s
f or k=1: l engt h( Pr at ed)
K( k) =Pr at ed( k) / R( k) / f N*100;
end
Ksyst empu=sum( K/ Kbase) ;
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta 1] ) ;
G=Ksyst empu; %XXX
H=E/ ( 1+E*F*G)
f i gur e( 2)
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] ) %set s col or s of f i gur e, al l whi t e
[ y, x] =st ep( f N+dPpu*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' g' ) %
[ t emp1, t emp2] =si ze( y) ;
f _st eady1=y( t emp1, t emp2) ;
hol d on
%der i vat i ve
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' g' )
peak1=max( abs( a( : , 1) ) ) ;
hol d on
%i ncr eased i ner t i a
Hpct =200; %i ner t i a i ncr ease t o 200%
f or k=1: l engt h( Hgen)
Er ot ( k) =Hgen( k) *Hpct / 100*Pr at ed( k) ; %Ki net i c ener gy of t he syst em
end
Hsyst em= sum( Er ot ) / sum( Pr at ed) ;
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta 1] ) ;
G=Ksyst empu;
H=E/ ( 1+E*F*G)
[ y, x] =st ep( f N+dPpu/ 1*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' b' )
[ t emp1, t emp2] =si ze( y) ;
f _st eady2=y( t emp1, t emp2) ;
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' b' )
peak2=max( abs( a( : , 1) ) ) ;
Matlab Calculations and Scripts
148
%decr eased i ner t i a
Hpct =50; %i ner t i a i ncr ease t o 50%
f or k=1: l engt h( Hgen)
Er ot ( k) =Hgen( k) *Hpct / 100*Pr at ed( k) ; %Ki net i c ener gy of t he syst em
end
Hsyst em= sum( Er ot ) / sum( Pr at ed) ;
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta 1] ) ;
G=Ksyst empu;
H=E/ ( 1+E*F*G)
[ y, x] =st ep( f N+dPpu*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' r ' )
[ t emp1, t emp2] =si ze( y) ;
f _st eady3=y( t emp1, t emp2) ;
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' r ' )
peak3=max( abs( a( : , 1) ) ) ;
%pl ot t i ng par amet er s, t ext and l egends
subpl ot ( 2, 1, 1) , l egend( [ ' H \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady1) , ' Hz' ] , [ ' H\ cdot 200% \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady2) , ' Hz' ] , [ ' H\ cdot 50% \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady3) , ' Hz' ] , ' Locat i on' , ' Sout hEast ' )
subpl ot ( 2, 1, 2) , l egend( [ ' H \ r i ght ar r ow df / dt = ' , num2st r ( peak1) ] , [ ' H\ cdot 200% \ r i ght ar r ow
df / dt = ' , num2st r ( peak2) ] , [ ' H\ cdot 50% \ r i ght ar r ow df / dt =
' , num2st r ( peak3) ] , ' Locat i on' , ' Sout hEast ' )
subpl ot ( 2, 1, 1) , t i t l e( [ ' Fr equency Response when Due t o I sl andi ng Tr ansi t i on, \ Del t aP =
' , num2st r ( dP) , ' MW' ] )
subpl ot ( 2, 1, 2) , t i t l e( [ ' Fr equency Der i vat i ve f or same Condi t i ons' ] )
subpl ot ( 2, 1, 2) , xl abel ( ' Ti me [ s] - I sl andi ng t r ansi t i on at t =0' )
subpl ot ( 2, 1, 1) , yl abel ( ' Fr equency [ Hz] ' )
subpl ot ( 2, 1, 2) , yl abel ( ' Fr equency [ Hz] ' )
subpl ot ( 2, 1, 1) , axi s( [ 0 10 49. 5 50. 2] )
subpl ot ( 2, 1, 2) , axi s( [ 0 10 - 3 2. 5] )
hol d of f
%
%i nf l uence of t he pr i me mover t i me const ant Ta, 3 set t i ngs t est ed
%========================================================================
%Nor mal pr i me mover t i me const ant Ta
%Reset t i ng i ner t i a as set i n par amet er s
f or k=1: l engt h( Hgen)
Er ot ( k) =Hgen( k) *Pr at ed( k) ; %Ki net i c ener gy of t he syst em
end
Hsyst em= sum( Er ot ) / sum( Pr at ed) ;
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta 1] ) ;
G=Ksyst empu; %XXX
H=E/ ( 1+E*F*G)
f i gur e( 3)
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] ) %set s col or s of f i gur e, al l whi t e
[ y, x] =st ep( f N+dPpu*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' g' )
[ t emp1, t emp2] =si ze( y) ;
f _st eady1=y( t emp1, t emp2) ;
hol d on
%der i vat i ve
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' g' )
peak1=max( abs( a( : , 1) ) ) ;
hol d on
%i ncr eased pr i me mover t i me const ant Ta
Tapct =200; %Ta i ncr ease t o 200%
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta*Tapct / 100 1] ) ;
G=Ksyst empu;
H=E/ ( 1+E*F*G)
[ y, x] =st ep( f N+dPpu/ 1*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' b' )
[ t emp1, t emp2] =si ze( y) ;
f _st eady2=y( t emp1, t emp2) ;
Matlab Calculations and Scripts
149
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' b' )
peak2=max( abs( a( : , 1) ) ) ;
%decr eased pr i me mover t i me const ant Ta
Tapct =50; %Ta i ncr ease t o 50%
E=t f ( 1, [ 2*Hsyst em0] ) ;
F=t f ( 1, [ Ta*Tapct / 100 1] ) ;
G=Ksyst empu;
H=E/ ( 1+E*F*G)
[ y, x] =st ep( f N+dPpu*H, t _st ep) ;
subpl ot ( 2, 1, 1) , pl ot ( x, y, ' r ' )
[ t emp1, t emp2] =si ze( y) ;
f _st eady3=y( t emp1, t emp2) ;
a=makedf dt ( y, x) ;
subpl ot ( 2, 1, 2) , pl ot ( a( : , 2) , a( : , 1) , ' r ' )
peak3=max( abs( a( : , 1) ) ) ;
%pl ot t i ng par amet er s, t ext and l egends
subpl ot ( 2, 1, 1) , l egend( [ ' T_a \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady1) , ' Hz' ] , [ ' T_a\ cdot 200% \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady2) , ' Hz' ] , [ ' T_a\ cdot 50% \ r i ght ar r ow f _s_t _e_a_d_y =
' , num2st r ( f _st eady3) , ' Hz' ] , ' Locat i on' , ' Sout hEast ' )
subpl ot ( 2, 1, 2) , l egend( [ ' T_a \ r i ght ar r ow df / dt = ' , num2st r ( peak1) ] , [ ' T_a\ cdot 200%
\ r i ght ar r ow df / dt = ' , num2st r ( peak2) ] , [ ' T_a\ cdot 50% \ r i ght ar r ow df / dt =
' , num2st r ( peak3) ] , ' Locat i on' , ' Sout hEast ' )
subpl ot ( 2, 1, 1) , t i t l e( [ ' Fr equency Response when Due t o I sl andi ng Tr ansi t i on, \ Del t aP =
' , num2st r ( dP) , ' MW' ] )
subpl ot ( 2, 1, 2) , t i t l e( [ ' Fr equency Der i vat i ve f or same Condi t i ons' ] )
subpl ot ( 2, 1, 2) , xl abel ( ' Ti me [ s] - I sl andi ng t r ansi t i on at t =0' )
subpl ot ( 2, 1, 1) , yl abel ( ' Fr equency [ Hz] ' )
subpl ot ( 2, 1, 2) , yl abel ( ' Fr equency [ Hz] ' )
subpl ot ( 2, 1, 1) , axi s( [ 0 10 49. 5 50. 2] )
subpl ot ( 2, 1, 2) , axi s( [ 0 10 - 3 2. 5] )
hol d of f
%
%I SR based on df / dt cr i t er i a
%========================================================================
%r eset t he t r ansf er f unct i on f or t he syst em:
f or k=1: l engt h( Pr at ed)
K( k) =Pr at ed( k) / R( k) / f N*100;
end
Ksyst empu=sum( K/ Kbase) ;
f Npu=f N/ f base;
dPpu=dP/ Sbase;
%Rot at i onal ener gy of t he syst emconst ant ( p. u. i f set )
f or k=1: l engt h( Hgen)
Er ot ( k) =Hgen( k) *Pr at ed( k) ; %Ki net i c ener gy of t he syst em
end
Hsyst em= sum( Er ot ) / sum( Pr at ed) ;
E=t f ( 1, [ 2*Hsyst em0] ) ; %i ner t i a
F=t f ( 1, [ Ta 1] ) ; %pr i me mover
G=Ksyst empu; %si mpl e gai n t o r epr esent t he dr oop cont r ol
H=E/ ( 1+E*F*G) %t he t r ansf er f unct i on
%set power mi smat ch ar r ay
dPvar =0: 0. 1: sum( Pr at ed) ;
%f i nd l i mi t s when i sl and i s i n i mpor t mode
f l ag=0; %f l ag f or when syst emi s no l onger wi t hi n cr i t er i a
k=1; %count er
whi l e f l ag ==0 && k<l engt h( dPvar )
[ y, x] =st ep( f N+dPvar ( k) *H, t _st ep) ;
a=makedf dt ( y, x) ; %cal cul at e t he der i vat i ve
peak=max( abs( a( : , 1) ) ) ; %get absol ut e hi ghest val ue of df / dt
i f peak > df dt cr i t er i a
f l ag = 1;
k=k- 1; %mi nus her e onl y t o compensat e f or l ast
%count af t er max val ue has been f ound
[ t emp1, t emp2] =si ze( y) ; %r egi st er st eady st at e f r eq
Matlab Calculations and Scripts
150
f _st eady=y( t emp1, t emp2) ;
end
k=k+1;
end
P_expor t =dPvar ( k) ;
di sp( [ ' ( expor t mode) Max dP = ' , num2st r ( dPvar ( k) ) , . . .
' r esul t i ng i n max df / dt = ' , num2st r ( peak) , . . .
' and st eady st at e f r equency f = ' , num2st r ( f _st eady) ] )
%f i ndi ng t he l ower l i mi t , when i sl and i s i n expor t mode
f l ag=0; %f l ag f or when syst emi s no l onger wi t i n cr i t er i a
k=1; %count er
dPvar =dPvar *( - 1) ;
whi l e f l ag ==0 && k<l engt h( dPvar )
[ y, x] =st ep( f N+dPvar ( k) *H, t _st ep) ;
a=makedf dt ( y, x) ; %cal cul at e t he der i vat i ve
peak=max( abs( a( : , 1) ) ) ; %get absol ut e hi ghest val ue of df / dt
i f peak > df dt cr i t er i a
f l ag = 1;
k=k- 1; %mi nus her e onl y t o compensat e f or l ast
%count af t er max val ue has been f ound
[ t emp1, t emp2] =si ze( y) ; %r egi st er st eady st at e f r eq
f _st eady=y( t emp1, t emp2) ;
end
k=k+1;
end
P_i mpor t =dPvar ( k) ;
di sp( [ ' ( i mpor t mode) Max dP = ' , num2st r ( dPvar ( k) ) , . . .
' r esul t i ng i n max df / dt = ' , num2st r ( peak) , . . .
' and st eady st at e f r equency f = ' , num2st r ( f _st eady) ] )
%pl ot t he I SR l i mi t s based on above
%set X val ues, l oad as 0 t o Pr at ed
l oad=0: 1: sum( Pr at ed) ;
%syt Y val ues f or l i mi t s f or when i sl and i s en expor t mode
P_l i m_expor t = l oad+P_expor t ;
%syt Y val ues f or l i mi t s f or when i sl and i s en i mpor t mode
P_l i m_i mpor t = l oad+P_i mpor t ;
%pl ot l i mi t s
f i gur e( 1)
cl f %cl ear s ol d gr aphi cs f r omf i gur e
f i gur enr =gcf ; %get s number of cr eat ed f i gur e
set ( f i gur enr , ' col or ' , [ 1 1 1] ) %set s col or s of f i gur e, al l whi t e
pl ot ( l oad, P_l i m_expor t , l oad, P_l i m_i mpor t )
axi s( [ 0 sum( Pr at ed) 0 sum( Pr at ed) ] )
t i t l e( ' Fr equency Der i vat i ve Li mi t s' )
yl abel ( ' Power Gener at i on pr e- i sl andi ng [ MW] ' )
xl abel ( ' Load [ MW] ' )
l egend( ' Upper l i mi t , Power expor t mode' , ' Lower l i mi t , Power i mpor t mode' . . .
, ' l ocat i on' , ' Sout hEast ' )
151
E
CONTENTS OF ATTACHED CD
Contents of CD
Calculations
Plot_3curves.fig
Steadystate_ISR.m
Droop.m
freqDerivative.m
freqdev.m
madedfdt.m
maxdfdt.m
Project Report
Influence of Different Generation on ISR.docx
Influence of Different Generation on ISR.pdf
Simulations
o Matlab Script functions
evaluateISR.m
freqdev.m
freqtime.m
maxdfdt.m
outlineMatrix3D.m
outlineMatrix.m
paraChangeCounter.m
peakFreq.m
plot3DISR.m
plot2DISR.m
plotISR.m
plotSimple.m
read_txt.m
returnIndexed.m
sortMatrix.m
test_of_stablematrix.m
volttime.m
o PF-projects
Contents of Attached CD
152
9bus aggregation.dz
9bus DFR.dz
9bus dispatch.dz
9bus droop.dz
9bus load shedding.dz
9bus prime mover.dz
9bus reference model.dz
9bus inertia.dz
9bus WT.dz
www.elektro.dtu.dk/cet
Department of Electrical Engineering
Centre for Electric Technology (CET)
Technical University of Denmark
Elektrovej 325
DK-2800 Kgs. Lyngby
Denmark
Tel: (+45) 45 25 35 00
Fax: (+45) 45 88 61 11
E-mail: cet@elektro.dtu.dk
[Skriv: ISBN XX-XXXXX-XX-X (eller slet)]