You are on page 1of 316

How­to use off­the­shelf software packages to perform power systems analysis 

www.vepi.hostse.com

Contents:
 Chapter 1: Spread sheets fundamentals.   
 Chapter 2: Basic operation and fundamental calculations of power systems analysis.   
 Chapter 3: Fault calculations.   
 Chapter 4: Load flow studies.   
 Appendix A: Using Quickbasis to perform power systems studies.   
Appendix B:Using HTML and Javascript to perform power systems studies.
Note: This on­line version of this book does not include the sketches and illustrations.
Chapter 1
Spread sheets fundamentals

Introduction:
Power systems analysis and calculations can be performed using off­the­shelf spread sheet software 
packages. The workbook (notebook) can be customized through the addition of menus and other 
toolbars (or modifying the existing ones). In this book Borland Quattro Pro and Microsoft Excel will be 
used to demonstrate how spread sheet programs can be modified and customized to become a tool for 
the electrical power systems analyst. 
Spread sheet fundamentals:
A standard spread sheet program that operates under DOS/Windows operating system will have the 
following main parts: 
1) The cells of the work sheet: the working area is divided into rectangles (which are called cells), each 
rectangle is identified by a letter (indicating a column) and a number (indicating a row). The workbook 
(or notebook as other suppliers of these packages call) will have more than one worksheet (or page). 
The workbook is a file that can accept user input and then be saved to the hard disk or floppy diskette. 
The user can move from one worksheet to another, add more worksheets or remove any of them. 
2) The menu bar: it will have menu elements and sub­elements that will allow the user to perform the 
tasks he/she would like to do like having a new worksheet appearing on the screen (on the monitor) in­
front of him/her, adding data, formatting it and then saving the file (by giving it a name) or opening an 
existing file making some modifications to it then saving it. 
3) The toolbar: it is a bar with small squares (icons), if any of the icons is pressed the specific task is 
performed. 
4) The data entry box: when the cursor (selector) is on a cell (i.e. a cell is chosen), the content (data) in 
the cell will appear in this box for the user to change. If the cell is empty, the user can enter the new 
data, it will appear in this box until he/she presses Enter or click the correct sign (adjacent to this box), 
after which the data is placed in the, previously, highlighted (chosen) cell. 
5) The message box (status bar): it is a box close to the bottom of the screen. When the mouse (cursor) 
is moved to a command (on the member) of the menu bar or to the icon on the toolbar, a brief 
description (help tip) of what this command or icon will do is displayed in such a box. 
Customizing such types of software packages is achieved through the use of macros and/or 
programming languages, function of the package itself. A macro is a stored series of keystrokes special 
keys, commands that can be played back. Macros are created by recording or typing them in. More 
about macros later in this chapter. 
The menu bars of spread sheets: 
For a typical software package operating under Windows platform on a PC, the following main items 
may be seen on the main menu of the program: FILE, EDIT, BLOCK, DATA, TOOLS, GRAPH, 
PROPERTY, VIEW, INSERT and  FORMAT. The file entry may have underneath it the following 
options: NEW (which will give the user a blank i.e. new work book), OPEN (which enables the user to 
open an existing file ­ the worksheets ­ to add to or modify), CLOSE which will cllose the file without 
saving the changes made from the last SAVE command), SAVE (which will save the document i.e. 
worksheets including all the changes or additions made up till this point), SAVEAS (save the worksheet 
on the screen under the name the user will enter at the prompt i.e. in the dialog box), PRINT 
PREVIEW (will show the user what he will get on the printer, if he gives the command PRINT to the 
machine), PRINT (will print the range to the printer i.e. producing a hard copy of what is shown on the 
screen), PAGE SETUP (enables the user to enter the page setup eg. margins, size,...). The last important 
item that may be found under FILE is Printer Setup (which gives the options to the user to select the 
printer, the port to which the printer is connected or to redirect to file ­ rather than to the printer port) 
Under the EDIT menu, there may be the following sub­menu items: Undo (revert to the condition 
before the last change/modification/typing,..etc.), Cut (remove the highlighted portion from the working 
document and put it in another location in the RAM, where it can be put ­ pasted­ into another portion 
of the current document or a new one), Copy (copies the highlighted portion in the current document 
into the RAM where it can be used later), Paste (taking what has been copied into the clipboard ­RAM­ 
to the current document at the position indicated by the cursor), Clear (delete all highlighted parts), 
Paste Special (gives the user the options of choosing to paste formula or value only avoid pasting 
blanks,..etc.), Paste Format (the pasted information will include formatted data), Goto (page, cell, 
column, row), Search & Replace (searches the first occurrence or all occurrences of the word or data 
inputted by the user and replace it or them with that or those specified by the user), Define Style (for 
the different styles eg. normal, currency, heading 1, heading 2,..etc., indicate the properties eg. 
alignment, format, protection, shading, text colour,..etc.). For the BLOCK menu item, the following can 
be found underneath it: Move (the user indicated data from which cell range ­block­ to which block of 
cells), Copy from which block to which one), Insert (allows the user to enter rows, columns, files & 
pages), Delete (allows the user to remove full rows, columns or pages), Fill (allows the user to 
automatically fill blocks, rows or columns with numbers depending on the series selected by the user), 
Names (allows the user to create names to certain areas ­ ranges or blocks­ of the worksheet to facilitate 
the manipulation of data, it also allows the user to delete unwanted names or all names), Transpose 
(exchange columns by rows and vice versa, the user enter the range ­from to­ that has to be transposed), 
Move Pages or worksheet (allows the user to move a page from a position to another within the file ­set 
of pages or worksheets­  before that specified by the user). Under the menu element, the following 
subitems: Sort (allows the user to enter the block to be sorted, the sort keys ­ primary & secondary, 
column ascending or descending and data i.e. labels ­text & values), Form (lets the user creates a form 
for entering & finding  records), Query (allows the user to set the data base block, criteria table & 
output blocks), Parse (breaks down long labels into individual cells used for example when word 
processing files are imported int worksheets of spread sheets programs), What­if (allows the user to 
modify one or two variables in the worksheet and observe the changes in other dependent variables in 
the worksheet, this feature is very important as an analysis tool to see, lets say, the profit due to the 
increase or decrease in volume of sales, or due to change in the number of the workforce or in the unit 
price of the different available products). Under the TOOLS main menu item, the following subitems 
may be found: Macro which provides the user with the necessary commands to create, run & debug 
macros; Spell check checks the spelling of the words in the notebook & graphics, Consolidator merges 
blocks (of cells) thus altering the data with the functions as selected by the user; Define group defines 
page groups for simultaneous operations on several pages; Combine merges 2 notebook files into one; 
Extract copies a part of a notebook to a separate file; Update links opens, updates, changes or deletes a 
notebook links; Analysis tools displays a list of advanced statistical, financial & engineering analysis 
tools; Speedbar designer allows the user to create his custom speedbar; Advanced math allows the user 
to access matrix & math tools. Under the GRAPH menu the following may be found: Type which 
changes the graph type (line, pie, ribbon, 3­D..etc.); Series defines or redefines the spread sheet data 
(which cells) to be plotted in the graph; Titles allows the user to add a title, subtitle & axis titles to the 
graph; New creates a new graph from the selected (cells); Edit brings a graph into a graph window 
ready for editing; Insert places an existing graph as a floating graph on a spread sheet page; Delete 
erases a graph from an active notebook; Copy copies a graph or selected attributes of a graph to a new 
or existing graph within the same notebook, what can be copied are graph style (all graph properties), 
graph , annotation objects or a combination thereof; View displays a full screen view of the graph. 
Under the PROPERTIES, the following may be found: Current object displays a dialog box for the 
current object which may be any of a check box, bitmap button, combo box, colour control; Application 
allows the user to change any of the following application properties display, currency, date/time 
formats, startup directory, currency/punctuation/date & time format; Active notebook allows the user to 
determine calculation mode, zoom factor, display of notebook macro library; Active page allows the 
user to enter page name, line colour, label alignment, display of zeros, default width, borders & 
gridlines. Under the VIEW menu item, the user may find Normal which allows the user to view the 
spread sheet as is; Page break preview shows the user where the page ends & allows him to adjust it; 
Toolbars allows the user to choose the toolbars he wants displayed on the screen like standard toolbar, 
formatting, chart, control tool box, drawings, forms, picture, Visual Basic,..etc.; Formula bar or Status 
bar allows the user to show or not show the formula or status bar; Full screen shows the notebook as full 
screen without any menus, control, tool or status bars; Zoom allows the user to set the magnification 
percentage of the displayed notebook on the screen (for example from 200% to custom magnification). 
Under the INSERT  menu item, the user may find Cells insert which allows the user to shift cells to the 
right, shift them to the left, insert an entire row or an entire column; Insert rows inserts a row at the 
cursor (highlighter); Insert columns inserts a column at the cursor; Worksheet inserts a worksheet and 
shows as the top sheet on the screen; Chart it gives the user the sequence of dialog boxes that would 
allow him to insert a chart including chart type (column, bar, line, pie, XY scatter, area, doughnut, 
surface, cylinder, cone, pyramid,..etc.),  range, series, titles (chart, X­axis & Y­axis), axis, guidelines, 
legend,  labels &  table; Page break inserts a page break; Function gives the user the choice from 
function category or function name; Name allows the user to define, paste, create, apply or label a name 
to a range, Picture inserts a picture from a gallery or inserts a picture file; Object allows the user to 
insert an object in the worksheet in front of him, as create new (becomes part of the current file) or as 
create from file (i.e. to later modify, the original application program is opened and the changes are 
made under the original application program control­DDE). Under the FORMAT, there are: Cells 
allows the user to  format the highlighted cells; Rows allows the user to set the height, hide/ unhide & 
auto fit; Columns allows the user to set the width,  auto fit, hide/ unhide & standard width; Sheet allows 
the user to rename it, hide/unhide, background; Style which can be modified by the user based on 
predefined characteristics (parameters in the style name) number appearance, alignment, font, borders, 
pattern & protection and Autoformat which allows the user to choose a pre formatted style with specific 
text font types, size, cell background colour, borders,...etc. (the dialog box shows a sample of the 
preformatted style). 
The macros: 
A macro is a stored series of keystrokes, special keys and commands that can be played back. Macros 
are created by typing or recording them. Macro commands can be divided into the following categories: 
keyboard, screen, interactive, program flow, cell, file, command equivalents, DDE, user interface 
building, object, miscellaneous and analysis tools. The first category can be subdivided into 4 sub­
categories: movement keys, function keys, status keys and other and is responsible for the emulation 
action of the various keys on the keyboard. The second is responsible for the display, the third will 
enable the user to create macros that display dialog boxes and pause for the user to enter data from the 
keyboard, the fourth gives the person preparing the macro the ability to loop and branch in a macro, the 
fifth will affect the data stored in specified cells, the sixth allows the operation on data in files other 
than the active ones, the seventh will allow the emulation of menu commands, the eighth (Dynamic  
Exchange) allows the communication with other Windows applications, the ninth allows the person 
preparing the macro to change the appearance of the menu bar, the tenth allows the macro creator to 
create/move resize/select/change the properties of objects (blocks, notebooks, graphs, graph objects, 
dialog boxes objects, floating objects & applications), the eleventh allows the insertion of characters & 
commands in the macro in addition to a variety of other tasks and finally the twelfth allows the 
performance of numerical  analyses. Macros are the heart of every application, they are the primary 
method, the user utilizes to pull all his application components together. Macros are used to display 
dialog boxes, to automate tasks, to duplicate keyboard & mouse actions, change the active menus, affect 
the screen display, select reposition resize objects, to prompt users for input. Planning before writing a 
macro may save a lot of time later. If the macro involves menu commands, step through them first, 
writing down each action involved. If it involves special macro commands, know exactly what the user 
has to enter as the command arguments after each macro command; its position can affect the macro's 
behaviour. Certain available application programs uses programming language like Visual Basic for 
application to customize the look and behaviour of such programs rather than macros. In either case the 
use of flow chart as part of the planning process can assist the programmer while entering the macro 
(by typing or recording) or writing the program. A flow chart is a diagram showing the actions & 
decisions a macro (or a program) steps through while running. Boxes in the chart contain an action the 
macro performs. Diamonds contain decisions the macro must make to determine the next step. Arrows 
show where to go after a step is completed. Arrows exiting a diamond have a decision listed next to 
them dictating the next step. Flow charts do not show actual macro (or programming language 
statements), they show the planning & logic behind a macro (a module or a program). 
When applications are created for the user's specific needs a couple of macros become very important. 
The first is the startup macro, which runs automatically upon opening the pertinent file. This macro 
must adjust the user interface tools of the program like the menu bars and tool bars. The second 
important macro is the exit one, which is responsible for the clean up steps when the user decides to 
exit or close the application. Such macro will reset the user interface tools to their default i.e. the menu 
bar and the tool bars will revert to their standard as furnished by the supplier software package. In 
Quattro Pro, each time the user opens a file (notebook), the software looks for a macro with 
_NBSTARTMACRO and if is found, the macro is run (executed). The exit macro (in Quattro Pro, it is 
named _NBEXITMACRO) is run after the command to close the notebook is given. The software 
branches to that macro and executing it before closing. In Quattro Pro, the user input is usually obtained 
through the dialog boxes. These are rectangular in shape with labels, push buttons, edit fields and other 
controls. The other controls are: check box, radio (option) button, spin control, rectangle and group box. 
The labels clarifies to the user what a control does. The push buttons perform a specific action when 
the user clicks it the developer (the person designing and writing the macros of the application) 
determines what that action is based on the user needs. The edit fields are the locations in the dialog 
boxes where the user types his input (specific information). When the OK push button is clicked by the 
user, it is such data that get acted upon by the macro. The check box presents a yes or no choice to the 
user. They are usually placed within group boxes. The option buttons are usually grouped to give the 
user a mutually exclusive list. The spin control allows the user clicking an arrow to increase or decrease 
the value it displays or to type a value in. The rectangle allows grouping (in appearance) two or more 
controls together. A group box contains other controls like radio buttons and check boxes with a title at 
the top. Link commands (statements) are most of the time attached to controls as link commands 
indicate to the controls what should happen when the user changes or selects the control. Link 
command will specify at least three things: event, action, object. The number of things to be specified 
is function of the control type, for instance a push button will specify three things event (eg. clicked), an 
action (do macro) and an object (the macro name). The edit field will specify five things: event (eg. 
valuechanged), an action (eg. send), an object (eg. value), another object (cell address eg. A:C2) and 
finally another object (eg. value). Most of the times the developer will have a list to pick from: events 
list, action list and object lists. Sometimes the objects are specified by the developer like a name of a 
macro or a cell in the notebook where he/she wants the inputted data to be placed in. A control can have 
more than one link command that has to respond to the same event. The list of link events will have the 
following options: init (the dialog box is about to appear, initial settings are set using this option), Init 
complete (it occurs after immediately after all controls have run all link commands that respond to Init, 
it is only available with dialog boxes themselves), OKExit (the user closes the dialog box, the link 
command runs before the dialog box closes), CancelExit (the user cancels the dialog box, the link 
command runs before the dialog box closes), Clicked (the user clicks the control), Right_bdown (the 
user right­clicks), Left_bdown (the user points to the control and is holding down the left mouse button, 
releasing the button generates a Clicked event), Doubleclick (theuser double clicks the control), 
Valuechanged (the user changes the value of the control eg. a text edit field, the event occurs any time 
the value is changed by user, link or macro command), Activate (the user has chosen the control for 
manipulation eg. clicking an edit field generates this event, Valuechanged trapped the final result), 
Deactivate (the user has chosen another control), Enter (the user presses Enter in an edit field), Lineup 
(the user increases the scroll bar's value by clicking a scroll arrow ­ available only on scroll bar 
controls), Linedown (the user decreases the scroll bar's value by clicking a scroll arrow), Pageup (the 
user increases  the scroll bar's value by clicking it between a scroll arrow and the scroll box), Pagedown 
(the user decreases the scroll bar's value by clicking it between the down scroll arrow and the scroll 
box), Thumb (the user clicks or drags the scroll bar's scroll box), Editdynamic (the user is inserting or 
deleting characters in the combo box's edit field, combo box controls only), Trigger (it is used to set 
link commands that can only be run by other link commands, it can not be generated by any user 
action), Alarm (the time of day specified in the timer's Alarm Time property has been reached ­ time 
controls only), Timer (the amount of time indicated in the timer's Timer Interval property has elapsed). 
The properties that are available to the developer to change and modify when it comes to the DIALOG 
BOX (WINDOW) are: the dimensions (specifies the exact size and position of the dialog window), the 
title (specifies the title of the dialog box, which the user will see), the position adjust (specifies how the 
dialog box moves when the controlling program window is resized), the grid options (shows or hides a 
grid and sets the number of pixels between grid lines), the name (it is used to identify the dialog box in 
macros, link commands and formulas), disabled option (disables all controls in the dialog box) and 
value (current setting of dialog box). The OK push button control which is a special case of the push 
button control has the following properties: bitmap(specifies a bit map file to appear on a button), label 
text (specifies the text appearing on the button), text draw flags (defines the location of label text on the 
bitmap button), default button (specifies the default button in the dialog box, which button is executed 
when Enter is pressed), button type (specifies the type of button), dimension (specifies the exact size 
and position of the bitmap button), hidden choice (specifies whether the bitmap button is visible in the 
dialog box, it is visible when editing), object ID (specifies the bitmap button's identification number), 
position adjust (specifies how an attached element moves when the bitmap button is resized), name 
(used to identify the bitmap button in macros, link commands & formulas), help line (a brief 
description indicating the purpose of such control), grayed choice (specifies whether the bitmap button 
can be used, if grayed it can not be used), disabled choice (behaves like grayed but does not dim the 
control), depend on (specifies the area in the parent program in which the bitmap will appear when the 
dialog box displays), tab stop (determines whether the bitmap button can be activated by pressing the 
tab key from the keyboard) , object help (determines the contents of Object help for the selected 
object), enabled choice (its function is the opposite of disabled), show (its function is the opposite of 
hidden), value (current setting of bitmap button). The developer can use the field type property to 
restrict the type of information the user can enter into edit field control (i.e. restrict the type of 
information the edit field will accept). There five types of fields: integer (restricts user entry to integers, 
this types adds three more properties: maximum, minimum and default referring to the integers to be 
inputted by the user), string (this is the default edit field type, it accepts any text a user enters including 
numbers), real (accepts any number or formula), block (accepts only cell addresses or block 
coordinates) and hidden (accepts any text but displays a pound (#) sign for each character entered). The 
edit field properties are: field type (determines the allowable type of input), edit length (specifies the 
maximum number of characters in the edit field), allow point mode (lets the pointer be used to select a 
block while a dialog box is displayed), show frame (displays a box around the field), terminate dialog 
option (if set to yes, pressing Enter triggers the default button ­mentioned above), convert text (allows 
insertion of a new line and tabs in an edit field), dimension (specifies the exact size & position of the 
edit field), hidden (specifies whether the edit field is visible in the dialog box), object ID (the edit 
field's identification number), position adjust (specifies how an attached element moves when the edit 
field is resized), name (is used to identify the edit field in macros, link commands and formulas), help 
line (a brief description that appears at the bottom of the parent program window), grayed option 
(specifies whether the edit field can be used or not), disabled option (behaves like grayed but does not 
dim the control), depend on (specifies the area in the parent program in which the edit field appears 
when the dialog box is displayed), process value (setting this property to yes lets the macro command 
{DODIALOG} access the edit field's value), tab stop (determines whether the edit field can be 
activated by Tab key), object help (determines the contents of Object Help for the selected object), 
enabled option (it is the opposite of disabled), show (it is the opposite of hidden), value (it is the current 
setting of the edit field). The label control properties are: label text (inputs text to appear adjacent to a 
dialog control), label font (determines label format), text draw flags (defines the location of label text 
adjacent to a dialog box control), dimension (specifies the exact and position of the label text), hidden 
(specifies whether the label is visible in the dialog box), object ID (it is the label text's identification 
number), position adjust (specifies how an attached element moves when its parent is resized), name (it 
is used to identify the label text), grayed option (specifies whether the can be used or not), disabled 
option (behaves like grayed but does not dim the control), depend on (specifies the area of the parent 
program in which the label text appears when the dialog box displays), process value (setting this 
property to yes lets the macro command {DODIALOG} access the label text's value), enabled (the 
opposite of disabled), show (the opposite of hidden) and value (the current setting of the label text). As 
can be seen from the aforementioned, certain properties are duplicated between the different types of 
controls. All the properties that may be found in the dialog box (UI) or in all the different types of 
controls are: add down button, alarm on, alarm time, allow point mode, attach child, bitmap, button 
type, convert text, current time, default, default button, depend on, dimension, disabled, draw to right, 
edit disabled, edit length, enabled, field type, fill color, frame color, grayed, grid option, group text, 
help line, hidden, history list, interval in units, label font, label text, list, list length, maximum, 
minimum, name, number of columns, object help, object ID, ordered, parameters, position adjust, 
process value, rectangle style, resize, selected, selection text, show, show frame, show time, tab stop, 
terminate dialog, text draw flags, timer on, title, units in milliseconds, value. The other controls that 
have not been mentioned so far are: bitmap button, color control, combo box, edit integer, file control, 
horizontal scroll bar, list box, pick list, scroll bar, and time control. A special notebook can be reserved 
for only macros. The macros stored in such notebook can be accessed from any other notebook. Some 
of the advantages of storing macros in a library are: it simplifies linked access; it makes easier to keep 
track of where macros are; the macros will not interfere with the notebook data and vice versa 
(although the last page iv can always be reserved for macros only); if macros are used for more than one 
notebook, using a library will save disk space; a separate set of macros can be created for each 
application or each notebook. Before starting to build an application, the developer should follow the 
following steps: 
1) Planning for an application: which includes determining the tasks that the user would like to 
accomplish; finding existing features or applications that perform tasks similar to those required by the 
user and obtain the user's opinion (how to modify these features to suit him best); keeping the 
application (the set of  macros) simple, the user interface (menus and toolbars) easy to use and all the 
development work well documented, always provide help messages and help lines for the users within 
the application (if the main user interface elements are not clear enough). 
2) Designing an application: during the development process, involve the user always and obtain his/her 
feedback; keeping all the macros, dialog boxes and menus for a single application organized in one 
notebook; define and follow a set of rules for naming and storing components of the applications; 
keeping all the application files in a specific directory; including all pertinent development notes in the 
application; limiting user access to critical components of the application; restoring the standard 
settings of the software after the user exits the application. 
The computer programming languages: 
Computer languages are code or statements or functions that control the operation of the personal 
computer and let it do what the user wants. These languages can broadly classified into procedural (for 
example Quickbasic) and object oriented (example C++). The basic tasks of any programming language 
can be summarized into: building loops and decision structures, defining & calling procedures 
(subroutines or functions), inputting/outputting to devices (printers, keyboard or monitor), 
inputting/outputting  to files (on hard or floppy disks), manipulating and transforming strings (to & 
from the different structures), displaying graphics images and setting traps for events & errors (making 
software package more robust). For example in Quickbasic there are statements (approximately 280 of 
them), functions, keywords and meta­commands. In Visual Basic for applications which come with 
Microsoft Excel program for example, there are statements (about 87), functions (about 156),  methods 
(about 11), 17 operators, 13 data types, 24 constants and 67 keywords. Procedural languages can be 
defined as a series of procedures that act upon. It is  a set of specific instructions executed one after the 
other. The data is quite separate from the procedures. A derived type of programming called structured 
which means breaking down complex tasks into self contained smaller ones. The most commonly used 
type of programming languages is the object oriented programming (OOP). This type of programming 
is built on 4 principles: encapsulation,  hiding, inheritance (reuse) and polymorphism. The property of 
being self­contained unit is called encapsulation, the encapsulated unit when is used without 
(necessarily) knowing how it works is called ­hiding. 
The creation of (new) user­defined types (classes) offers the encapsulation hiding properties to the 
program. A new type can be declared from an existing one (thus it is an extension of an existing object). 
It inherits the properties of the existing type (class) as well as additions to the new object can be made 
to modify its response and output. Polymorphism means the same name may take many forms but 
makes the right (expected) thing (through the choice of the right objects). The source code is a file 
written in one of the programming languages using the appropriate statements, techniques and syntax. 
This file is saved in an ASCII format. Most available development packages (programming software) 
have their own editing environment where the programmer can type/enter his/her source code and then 
saves the file. The next step would be to make the source code file an executable one, with which the 
computer can run it from its operating system. In order to achieve this goal, the source code file has to 
be compiled (the source code file remains as is, but two other files are created the one with .OBJ 
extension & the executable one with .EXE extension). The programmer can compile the source code 
file into an executable one at the operating system prompt (by inputting the appropriate command) or 
from the menu from within the development environment. Thus the compiler is a software that takes 
the high level language file and converts it into machine language. A library is a collection of linkable 
files that the programmer creates, are supplied by the compiler or are purchased separately. A function 
is a block of code that performs a service (adding 2 numbers together or printing a character to a 
screen). A class is a collection of data and related functions. The programmer may use the linker to 
create an operable program with libraries using the following steps: he/she prepares the source code file 
(written in high level language), compiles the source code file and finally links the files with .OBJ 
extension with the needed libraries to produce an operable program. In C++ language, the main files 
that are used to produce a program are: the header, methods and implementation. The methods file will 
refine the functions declared in the header file, the implementation one (having the main function in it) 
will use the header file (.H extension) & the methods file (.CPP extension) to get the required results 
from the program. For a short program, it will, typically, have the following components: list of header 
files, list of global variables & their  types, the base class, the definition of the functions declared in the 
class and finally the main function (the entry point to the program). The main topics of C++ language 
are: predefined & created classes, pointers & references, overloading functions & operators, creating 
objects at run time, arguments & return values, containers and templates. The main statements, 
keywords & functions in C++ language can be classified broadly into: prompts & user input,output  to 
screen or  file, control of program flow, looping  (iteration) of certain program instruction, operators & 
trigonometric functions, classes, specifiers, identifiers, pointers & references, constructors and 
operators. On the other hand, for the Quickbasic (which is a procedural language) the statements, 
functions and keywords can be classified broadly into: prompts & user  input, output  to screen or file, 
control of program flow, subroutines & programs chaining, looping (iterations) operators. Examples to 
show the syntax of Quickbasic language: INPUT which allows input from keyboard, PRINT prints  on 
screen, IF...THEN allows conditional execution based on the evaluation of the expression following IF. 
For the C++ language: cin allows input from the keyboard while the program is running, iostream.h (a 
header file) should be included in the source code file (# include <iostream.f>), cout outputs  to the 
screen, same header file as cin should be include in the source code file, if allows conditional execution 
based on the evaluation of the expression following the if, switch...case allows conditional execution 
based on the evaluation of the expression after switch and performs the instructions following the 
applicable case statement, while repeats a block of statements while a condition a true. Most of the 
examples using Excel program that will be given in this book use programs that were originally written 
in Quickbasic language, although slightly modified to suit the programming language provided with 
Excel (Visual Basic for Applications ­ VBA). The original programs were writtten in Quickbasic, by  
the author, they had their own user interface through menu screens and prompts. When they are 
adapted to the off­the­shelf software packages, the interface of the latter is used instead of the original 
interface. These original programs were written and given the title "The Series of Short Programs for 
Power Systems Analysts". 
Simple examples and analysis in Excel VBA language and Quattro Pro macros: 
Excel of Microsoft: Before getting to the examples, a few important definitions and other explanation 
of control and properties will be presented. 
Definition of common terms: 
Class module: is a module that contains the definition of a class, including its property & method 
definitions. 
Method: an action that an object performs (on itself). 
Collection: an object that contains several other objects. 
Event: an action recognized by an object. 
Module: a set of declarations followed by procedures. Procedures in a module are classified into  
functions and subroutines procedures. 
Module­level declarations: describe the code in the declaration section of a module. Any code outside a 
procedure is referred to as module level code. Declarations must be listed first, followed by procedures. 
Object: is an element of an application. 
Property: is an attribute of an object that defines one of the object's characteristics. 
Purpose of common commands and statements: 
Sub: declares the name, arguments and code that form the body of a Sub procedure. 
Private: is used at module level to declare private variables and allocate storage space. 
Set: assigns an object reference to a variable or property. 
With: executes a series of statements on a single object or a user defined type. 
Sheets property: returns a sheets collection that represents all the sheets in the workbook. 
Select method: selects the required object. 
Range property: return a Range object that represents a cell or a range of cells. 
CommandBars property: returns a CommandBars object that represents the software program 
command bars. 
ActiveMenuBar property: returns a CommandBar object that represents the active menu bar in the 
container application. 
Controls property: returns a CommandBarControls object that represents all the controls on the 
specified command bar or popup control. 
CommandBarControls property: is a collection of CommandBarControl objects that represent the 
command bar controls on a command bar. 
Add method: adds an object to a collection. 
InputBox method: displays a dialog box for user input, it returns the information entered into the dialog 
box (replaces Input statement in Quickbasic). 
MsgBox function: displays a message in a dialog box, waits for the user to click a button and returns an 
Integer indicating which button the user clicked. 
Print method: prints text in the Immediate pane of the Debug window. 
Print #: writes display­formatted data to a sequential file (equivalent to Quickbasic). 
Open: enables input/output to a file (equivalent to Quickbasic statement). 
Debug object: sends output to Immediate window at run time (it is used in conjunction with Print eg. 
Debug.Print) 
Microsoft Excel contents of Controls toolbox: the standard controls included in the controls tool box 
are: Check box, Text box, Command Button, Radio button, List box, Combo box, Toggle button, Spin 
button, Scroll bar, Label and Image. 
Properties of each of the commonly used controls: 
1) The properties of the check box that can be set by the developer (or user) are: Accelerator, 
Alignment, AutoSize, BackColor, BackStyle, BoundValue, Caption, ControlSource, ControlTipText, 
Enabled,  Font object, ForeColor, Height/Width, HelpContextID, LayoutEffect, Left/Top, Locked, 
MouseIcon, MousePointer, Name, Object, OldHeight/OldWidth, OldLeft/OldTop, Parent, Picture, 
PicturePosition, SpecialEffect, TabIndex, TabStop, Tag, TrippleState, Value, Visible & Wordwrap. 
2) The properties of the text box: AutoSize, AutoTab, AutoWordSelect, BackColor, BackStyle, 
BorderColor, BorderStyle, BoundValue, CanPaste, ControlSource, ControlTipText, CurLine, 
CurTargetX, CurX, DragBehavior, DropButtonStyle, Enabled, EnterFieldBehavior, EnterKeyBehavior, 
Font object, ForeColor, Height/Width, HelpContextID, HideSelection, IMEMode, IntegralHeight, 
LayoutEffect, Left/Top, LineCount, Locked, MaxLength, MouseIcon, Multiline, Name, Object, 
OldHeight/OldWidth, OldLeft/OldTop, Parent, PasswordChar, ScrollBArs, SelectionMargin, 
SelLength, SelStart, SelText, ShowDropButtonWhen, SpecialEffect, TabIndex, TabKeyBehavior, 
TabStop, Tag, Text, TextAlign, TextLength, Value, Visible, WordWrap. 
3) The properties of the command button: Accelerator, AutoSize, BackColor, BoundValue, Cancel, 
BackStyle, Caption, ControTipText, Default, Enabled, ForeColor, Height/Width, HelpContextID, 
LayoutEffect, Left/Top, Locked, MouseIcon, MousePointer, Name, Object, OldHeight/OldWidth, 
OldLeft/OldTop, Parent, Picture, PicturePosition, TabIndex, TabStop, Tag, TakeFocusOnClick, Value,  
Visible, WordWrap. 
4) The properties of the radio (option) button: Accelerator, Alignment, AutoSize, BackColor, 
BackStyle, BoundVAlue, Caption, ControlSource, ControlTipText, Enabled, Font object, Forecolor, 
GroupName, Height/Width, HelpContextID, LayoutEffect, Left/Top, Locked, MouseIcon, 
MousePointer, Name, Object, OldHeight/OldWidth, OldLeft/OldTop, Parent, Picture, PicturePosition, 
SpecialEffect, TabIndex, TabStop, Tag, TripleState, Value, Visible, WordWrap. 
5) The properties of the list box: BackColor, BorderColor, BorderStyle, BoundColumn, BoundValue, 
Column, ColumnCount, ColumnHeads, ColumnWidths, ControlSource, ControlTipText, Enabled, Font 
object, ForeColor, Height/Width, HelpContextID, IMEMode, IntegralHeight, LayoutEffect, Left/Top, 
List, ListCount, ListIndex, ListStyle, Locked, MatchEntry, MouseIcon, MousePointer, MultSelect, 
Name, Object, OldHeight/OldWidth, OldLrft/OldTop, Parent, RowSource, Selected, SpecialEffect, 
TabIndex, TabStop, Tag, Text, TextColumn, TopIndex, Value, Visible. 
6) The Properties of the combo box: AutoSize, AutoTab, AutoWordSelect, BackColor, BackStyle, 
BorderColor, BorderStyle, BoundColumn, BoundValue, CanPaste, ColumnCount, ColumnHeads, 
ColumnWidths, ControlSource, ControlTipText, CurTargetX, CurX, DragBehavior, DropButtonStyle, 
Enabled, EnterFieldBehavior, Font object, ForeColor, Height/Width, HelpContextID, HideSelection, 
IMEMode, LayoutEffect, Left/Top, LineCount, List, ListCount, ListIndex, ListRows, ListStyle, 
ListWidth, Locked, MatchEntry, MatchFound, MatchRequired, MaxLength, MouseIcon, MousePointer, 
Name, Object, OldHeight/OldWidth, OldLeft/OldTop, Parent, RowSource, SelectionMargin, 
SelLength, SelStart, SelText, ShowDropButtonWhen, SpecialEffect, Style, TabIndex, TabStop, 
Tag,Text, TextAlign, TextColumn, TextLength, TopIndex, Value, Visible. 
7) The properties of the toggle button: Accelerator, Alignment, AutoSize, BackColor, BackStyle, 
BoundValue, Caption, ControlSource, ControlTipText, Enabled, Font, ForeColor, Height/Width, 
HelpContextID, LayoutEffect, Left/Top, Locked, MouseIcon, MousePointer, Name, Object, 
OldHeight/OldWidth, OldLeft/OldTop, Parent, Picture, PicturePosition, SpecialEffect, TabIndex, 
TabStop, Tag, TripleState, Value, Visible, WordWrap. 
8) The properties of the spin button: BackColor, BoundValue, ControlSource, ControlTipText, Delay, 
Enabled, ForeColor, Height/Width, HelpContextID, LayoutEffect, Left/Top, Max/Min, MouseIcon, 
MousePointer, Name, Object, OldHeight/OldWidth, OldLeft/OldTop, Orientation, Parent, SmallRange, 
TabIndex, TabStop, Tag, Value, Visible. 
9) The properties of the scroll bar: BackColor, BounValue, ControlSource, ControlTipText, Delay, 
Enabled, ForeColor, Height/Width, HelpContextID, LargeChange, LayoutEffect, Left/Top, Max/Min, 
MouseIcon, MousePointer, Name, Object, OldHeight/OldWidth, OldLeft/OldTop, Orientation, Parent, 
ProportionalThumb, SmallChange, TabIndex, TabStop, Tag, Value, Visible. 
10) The properties of the label: Accelerator, AutoSize, BackColor, BackStyle, BorderColor, 
BorderStyle, Caption, ControlTipText, Enabled, Font Object, ForColor, Height/Width, LayoutEffect, 
Left/Top, MouseIcon, MousePointer, Name, Object, OldHeight/OldWidth, OldLeft/OldTop, Parent, 
Picture. 
11) The properties of the image: AutoSize, BackColor, BackStyle, BorderColor, BorderStyle, 
ControlTipText, Enabled, Height/Width, LayoutEffect, Left/Top, MouseIcon, MousePointer, Name, 
Object, OldHeight/OldWidth, OldLeft/OldTop, Parent, PictureAlignment,  PictureSizeMode, 
PictureTiling, SpecialEffect, Tag, Visible. 
A brief description for the purpose of each of the available properties of the controls contained in the 
toolbox: 
1) Accelerator: sets or retrieves the accelerator key for a control (ctrl + key from keyboard, eg. a or b or 
c or...etc.). 
2) Alignment: specifies the position of a control with respect to its caption, i.e. to its left or to its right. 
3) AutoSize: specifies whether an object automatically resizes to display its entire contents in the 
control (or does not resize and the contents are clipped). 
4) AutoTab: specifies whether an automatic tab occurs when a user enters the maximum allowable 
number of characters into the TextBox control or the text box portion of a ComboBox. 
5) AutoWordSelect: specifies whether a word or character is the basic unit used to extend a selection, it 
specifies how the selection extends or contracts in the edit region of a TextBox or ComboBox. 
6) BackColor: specifies the background colour of the object. 
7) BackStyle: returns or sets the background style for an object. 
8) BorderColor: specifies the color of an object's border. 
9) BorderStyle: specifies the type of border used by a control or form. 
10) BoundColumn: identifies the source of data in a multicolumn ComboBox or ListBox. 
11) BoundValue: contains the value of a control when that control receives the focus. 
12) CanPaste: specifies whether the Clipboard contains data that the object support. 
13) Caption: descriptive text that appears on an object to describe it. 
14) Column: specify one or more items in a ListBox or ComboBox. 
15) ColumnCount: specifies the number of columns to display in a ListBox or ComboBox control. 
16) ColumnHeads: displays a single row of column headings for list boxes and combo boxes and other 
similar objects. 
17) ColumnWidths: specifies the width of each column in a multicolumn combo or list box. 
18) ControlSource: identifies the data location used to set or store the Value property of a control. 
19) ControlTipText: specifies text that appears when the user briefly holds the mouse pointer over a 
control without clicking it. 
20) CurLine: specifies the current line of a control. 
21) CurTargetX: retrieves the preferred horizontal position of the insertion point in a multiline TextBox 
or ComboBox. 
22) CurX: specifies the current horizontal position of the insertion point in a multiline TextBox or 
ComboBox. 
23) Delay: specifies the delay for the SpinUp SpinDown & Change events on SpinButton or ScrollBar. 
24) DragBehavior: specifies whether the system enables the drag­and­drop feature for a TextBox or 
ComboBox 
25) DropButtonStyle: specifies the symbol displayed on the drop button in a combo box , eg. a plain 
button with no symbol, a down arrow button,...etc. 
26) Enabled: specifies whether a control can receive the focus and respond to user generated events 
27) EnterFieldBehavior: specifies the selection behaviour when entering a TextBox or ComboBox 
(selects the entire content i.e. highlights it or leaves the selection unchanged). 
28) EnterKeyBehavior: defines the effect of pressing ENTER in a TextBox (either creates a new line or 
moves on to the next control in the tab order, when the Multiline property is set to TRUE) . 
29) Font object: defines the characteristics of the text used by a control or form. 
30) ForeColor: specifies the foreground colour of an object 
31) GroupName: creates a group of mutually exclusive OptionButtton controls (clicking one button in 
the group will set the rest, in the group,to false). 
32) Height/Width: sets the height and width of an object (control). 
33) HelpContextID: associates a specific help file with a specific control. 
34) HideSelection: specifies whether selected text remains highlighted when a control does not have the 
focus. 
35) IMEMode: specifies the default run time mode of Input Method Editor for a control. 
36) LargeChange: specifies the amount of movement that occurs when the user clicks between the 
scroll box and scroll arrow. 
37) LayoutEffect:  indicates whether a control was moved during a layout change. 
38) Left/Top:sets the distance between a control and the left or top edge of the corm containing it. 
39) LineCount: returns the number of text lines in a TextBox or ComboBox. 
40) List: returns or sets the list entries of a ListBox or ComboBox. 
41) ListCount: returns the number of list entries in a control. 
42) ListIndex: identifies the currently selected item in a ListBox or ComboBox 
43) ListRows: specifies the maximum number of rows to be displayed in a list. 
44) ListStyle: specifies the visual appearance of the list in a ListBox or ComboBox. 
45) ListWidth: specifies the width of the list in a ComboBox. 
46) Locked: specifies whether a control can be edited or not. 
47) MatchEntry: returns or sets a value indicating how a ListBox or ComboBox searches its list as the 
user types in his choice. 
48) MatchFound: indicates whether the text that the user has typed into a ComboBox matches any of 
the entries in the list. 
49) MatchRequired: specifies whether a value entered in the text portion of a combo box must match an 
entry in the existing list portion of the control. The user can enter non­matching values, but may not 
leave the control until a matching value is entered. 
50) MaxLength: specifies the maximum number of characters a user can enter in a TextBox or 
ComboBox. 
51) Max/Min: specifies the maximum & minimum acceptable values for the value property of a 
ScrollBar or SinButton. 
52) MouseIcon: assigns a custom icon to an object. 
53) MousePointer: specifies the type of pointer when the user positions the mouse over a particular 
object. 
54) MultiLine: specifies whether a control can accept and display multiple line of text 
(EnterKeyBehavior depends on this property). 
55) MultiSelect: indicates whether the object permits multiple selection or not. 
56) Name: specifies the name of a control or an object or the name of a Font to associate wit a font 
object. 
57) Object: overrides a standard property or method when a new control has a property or method of 
the same name. 
58) OldHeight/OldWidth: returns the previous height or width in points of the control. 
59) OldLeft/OldTop: returns the distance (in points) between the previous position of a control and the 
left or top edge of the form that contains it. 
60) Orientation: specifies whether the SpinButton or ScrollBar is oriented vertically or horizontally. 
61) Parent: returns the name of the form/object /collection that contains a specific control, object or 
control. 
62)PasswordCharacter: specifies whether placeholder characters are displayed instead of the characters 
actually entered in a TextBox. 
63) Picture: specifies the bitmap to display on an object. 
64) PictureAlignment: specifies the location of a background picture. 
65) PicturePosition: specifies the location of the picture relative to its caption. 
66) PictureSizeMode: specifies how to display the background picture on a control, form or page. 
67) PictureTiling: to allow a picture to be tiled in a form or page. 
68) ProportionalThumb: specifies whether the size of the scroll box is proportional to the scrolling 
region or is fixed. 
69) RowSource: specifies the source providing a list for a ComboBox or ListBox. 
70) ScrollBars: specifies whether a control, form or page has vertical scroll bars, horizontal scroll bars 
or both. 
71) Selected: returns or sets the selection state of items in a ListBox. 
72) SelectionMargin: specifies whether the user can select a line of text by clicking in the region to the 
left of the text. 
73) SelLength: the number of characters selected in a text box or the text portion o a conbo box. 
74) SelStart: indicates the starting point of selected text or the insertion point if no text is selected. 
75) SelText: returns or sets the selected text of a control. 
76) ShowDropButtonWhen: specifies when to show the drop­down button for a ComboBox or TextBox. 

77) SmallChange: specifies the amount of movement that occurs when the user clicks either scroll 
arrow in a ScrollBar or SpinButton. 
78) SpecialEffect: specifies the visual appearance of an object. 
79) Style: specifies how the user can choose or set the control's value, this for ComboBox controls and 
for MultiPage & TabStrip controls it identifies the style of the tabs (on the control). 
80) TabIndex: specifies the position of a single object in the form's tab order. 
81) TabKeyBehavior: determines whether tabs are allowed  in the Edit Region. 
82) TabStop: indicates whether an object can receive focus when the user tabs to it. 
83) Tag: stores additional information about an object. 
84) Text: returns or sets the text in a TextBox and in combo boxes or ListBoxes, it changes the selected 
row. 
85) TextAlign: specifies how text is aligned in a control. 
86) TextColumn: identifies the column in a ComboBox or ListBox to display to the user. 
87) TextLength: returns the length (in characters) of text in the edit region of a text box or combo box. 
88) TopIndex: sets and returns the item that appears in the topmost position in the list. 
89) TripleState: determines whether a user can specify, from the user interface, the Null state for a 
CheckBox or ToggleButton. 
90) Value: specifies the state or content of a given control. 
91) Visible: specifies whether an object is visible or hidden. 
92) WordWrap: indicates whether the contents of a control automatically wrap at the end of a line. 
93) Default: designates the default command (push) button on a form. VBA for Excel examples. 
Quattro Pro of Borland: 
Borland Quattro Pro contents of Controls toolbox: as mentioned, previously, the controls are: bitmap 
button, edit (text) field, label, check box, radio button, spin control, rectangle, group box, push button, 
combo box, color control, file control, horizontal scroll bar, list box, pick list, scroll bar & time control. 
The example given hereafter will show the following:
1) How to add custom menu element between two of the standard elements appearing in the active 
menu bar supplied as part of the software package. It will be placed between the “Edit” and the “Block” 
menu elements. It shows the blocks (groups of cells) names in this example file. The macros and their 
locations on the page (worksheet) are also shown. An example for the look of a dialog box (dialog 3) 
related to a specific macro or action is also given. The dialog box has the OK button. When this button 
is clicked, the links instruction is executed running “parallel2” macro. Parallel2 macro shows the active 
page (which is a in this example) with the selector (highlighter or cursor) on cell number d1. 
2) The page with the labels and descriptive text for each entry in the text boxes of each of the dialog 
boxes are shown. Also, the results of the calculation (rather than the formulas used to arrive to the 
results) are shown. 
3) The print out of the spreadsheet with the option “Cell Formulas” marked is also shown. It shows 
labels, values entered by the user and formulas (in place of the calculated values). For example, the 
page is a (the first sheet of the workbook) and the cell J4 has the descriptive text “Equivalent element”, 
L4 cell has the formula [(1)/(1/L2)+1/L3)]. Cell L4 will have the result of the equation when the 
pertinent macro is run (it will nit show this equation). 
Note: the on­line version of this book does not include the Quattro Pro examples

contents
Chapter 2 
Basic operations and fundamental calculations of power systems analysis

Introduction: in any of the power systems problems that have to be solved, certain basic steps have to be 
performed ahead of the beginning of the analysis or the solution process. These preliminary operations 
can be any of the following: 
1) The combination of the a few series or parallel impedance elements (resistance or reactance). 
2) The conversion from wye to delta or vice versa of passive electrical system components. 
3) Per unit (pu) calculations for the electrical power distribution zone under study. 
4) Matrix manipulation and simultaneous equations solution. 
5) The formation of the system admittance­bus and impedance­bus models (matrices). 
Examples showing how to use Excel and Quattro Pro to solve for these fundamental variables or  
constants of the electrical power systems: 
Excel of Microsoft: 
For definition of common terms, contents of controls toolbox, properties of each of the commonly used 
controls, refer to Chapter 1. 
Chapter 2, eg. 1, Excel, Fundamental operations and basic calculations: 
1) The Workbook program 
Private Sub Workbook_Deactivate()   'When this file is deactivated (closed), this sub is run resetting 
the active 
Application.CommandBars.ActiveMenuBar.Reset  'menu bar to its previous state. 
End Sub 
Private Sub Workbook_Open() 'When this workbook is opened , this sub is run adding the customized 
menu 
Set myMenubar = Application.CommandBars.ActiveMenuBar 'elements to the active menu bar. When 
it is activate 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) ' and then 
reactivated, the 
newMenu.Caption = "&Choice  ????????"  ' customized menu elements will not appear. The user has to 
click any of 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1)  ' the workbook tabs to have such 
elements 
ctrl1.Caption = "&Series/parallel"  ' added.  If Sub Workbook_Activate is used, instead, then upon 
deactivation 
ctrl1.TooltipText = "Series/parallel"  'and activation of the workbook the customizes elements will 
appear as part 
ctrl1.Style = msoButtonCaption  'of the active menu bar. 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
Worksheets("Fault calc. for simple system").Activate 
End Sub 
2) First Worksheet program (series and parallel operations): 
Private Sub CommandButton1_Click() 
Range("O1").Select 
End Sub 
Private Sub CommandButton10_Click() 
Range("w8").Select 
End Sub 
Private Sub CommandButton2_Click() 
Range("AA1").Select 
End Sub 
Private Sub CommandButton4_Click() 
Range("A1").Select 
End Sub 
Private Sub CommandButton5_Click() 
Range("A1").Select 
End Sub 
Private Sub CommandButton6_Click() 
Range("R1").Select 
End Sub 
Private Sub CommandButton7_Click() 
Range("l3").Select 
End Sub 
Private Sub CommandButton8_Click() 
Range("i1").Select 
End Sub 
Private Sub CommandButton9_Click() 
Range("w2").Select 
End Sub 
Private Sub Worksheet_activate() 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Choice" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Series/parallel" 
ctrl1.TooltipText = "Series/parallel" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Series/parallel" 
Set ctrl11 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl11.Caption = "Se&ries calc.." 
ctrl11.TooltipText = "Series calc." 
ctrl11.Style = msoButtonCaption 
With ctrl11 
    .OnAction = "MySub11" 
End With 
Set ctrl12 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl12.Caption = "&Eight element calc." 
ctrl12.TooltipText = "Eight elements calc." 
ctrl12.Style = msoButtonCaption 
With ctrl12 
    .OnAction = "MySub12" 
End With 
Set ctrl13 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl13.Caption = "Se&ven element calc." 
ctrl13.TooltipText = "Seven elements calc." 
ctrl13.Style = msoButtonCaption 
With ctrl13 
    .OnAction = "MySub13" 
End With 
Set ctrl14 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl14.Caption = "S&ix element calc." 
ctrl14.TooltipText = "Six elements calc." 
ctrl14.Style = msoButtonCaption 
With ctrl14 
    .OnAction = "MySub14" 
End With 
Set ctrl15 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl15.Caption = "&Five element calc." 
ctrl15.TooltipText = "Five elements calc." 
ctrl15.Style = msoButtonCaption 
With ctrl15 
    .OnAction = "MySub15" 
End With 
Set ctrl16 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl16.Caption = "F&our element calc." 
ctrl16.TooltipText = "Four elements calc." 
ctrl16.Style = msoButtonCaption 
With ctrl16 
    .OnAction = "MySub16" 
End With 
Set ctrl17 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl17.Caption = "&Three element calc." 
ctrl17.TooltipText = "Three elements calc." 
ctrl17.Style = msoButtonCaption 
With ctrl17 
    .OnAction = "MySub17" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
CommandBars.ActiveMenuBar.Controls("Series/parallel").Delete 
CommandBars.ActiveMenuBar.Controls("Choice").Delete 
End Sub 
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) 
End Sub 
  
3) Second Worksheet program (wye to delta conversion and vice versa): 
Private Sub CommandButton1_Click() 
Range("m1").Select 
End Sub 
Private Sub CommandButton2_Click() 
Range("m5").Select 
End Sub 
Private Sub CommandButton3_Click() 
Range("A1").Select 
End Sub 
Private Sub CommandButton4_Click() 
Range("A1").Select 
End Sub 
Private Sub Worksheet_activate() 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Choice" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Series/parallel" 
ctrl1.TooltipText = "Series/parallel" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) 
End Sub 
  
4) Third Worksheet program (fault calculation for a simple system): 
Private Sub CommandButton1_Click() 
Range("m1").Select 
End Sub 
Private Sub CommandButton2_Click() 
Range("q1").Select 
End Sub 
Private Sub CommandButton3_Click() 
Range("u1").Select 
End Sub 
Private Sub CommandButton4_Click() 
Range("y1").Select 
End Sub 
Private Sub CommandButton5_Click() 
Range("a1").Select 
End Sub 
Private Sub CommandButton6_Click() 
Range("a1").Select 
End Sub 
Private Sub CommandButton7_Click() 
Range("a1").Select 
End Sub 
Private Sub CommandButton8_Click() 
Range("a1").Select 
End Sub 
Private Sub Worksheet_activate() 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Choice" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Series/parallel" 
ctrl1.TooltipText = "Series/parallel" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) 
End Sub 
5) Fourth Worksheet program (matrices manipulation): 
Private Sub Worksheet_activate() 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Choice" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Series/parallel" 
ctrl1.TooltipText = "Series/parallel" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Matrix manipulation" 
Set ctrl41 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl41.Caption = "&Two by two matrix" 
ctrl41.TooltipText = "2 by 2 matrix" 
ctrl41.Style = msoButtonCaption 
With ctrl41 
    .OnAction = "MySub41" 
End With 
Set ctrl42 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl42.Caption = "T&hree by three matrix" 
ctrl42.TooltipText = "3 X 3 matrix" 
ctrl42.Style = msoButtonCaption 
With ctrl42 
    .OnAction = "MySub42" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
CommandBars.ActiveMenuBar.Reset 
End Sub 
  
6) Fifth Worksheet program (simultaneous equations solution): 
Private Sub Worksheet_activate() 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Choice" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Series/parallel" 
ctrl1.TooltipText = "Series/parallel" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Simultaneous equations" 
Set ctrl51 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl51.Caption = "&Five equations solution" 
ctrl51.TooltipText = "Solution of 5 equations" 
ctrl51.Style = msoButtonCaption 
With ctrl51 
    .OnAction = "MySub51" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
CommandBars.ActiveMenuBar.Reset 
End Sub 
7) Sixth Worksheet program (per unit calculations): 
Private Sub Worksheet_activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Choice  ????????" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Series/parallel" 
ctrl1.TooltipText = "Series/parallel" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Number of transfo./system" 
Set ctrl61 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl61.Caption = "&One transfo." 
ctrl61.TooltipText = "One transfo. per system" 
ctrl61.Style = msoButtonCaption 
With ctrl61 
    .OnAction = "MySub61" 
End With 
Set ctrl62 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl62.Caption = "&Two transfo." 
ctrl62.TooltipText = "Two transfo. per system" 
ctrl62.Style = msoButtonCaption 
With ctrl62 
    .OnAction = "MySub62" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
CommandBars.ActiveMenuBar.Reset 
End Sub 
8) Seventh Worksheet program (system bus modelling): 
Private Sub Worksheet_activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Choice  ????????" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Series/parallel" 
ctrl1.TooltipText = "Series/parallel" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Wye/delta conv." 
ctrl2.TooltipText = "Wye/delta conv." 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "Short &circuit calc." 
ctrl3.TooltipText = "S.C. Calc." 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set ctrl4 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl4.Caption = "&Matrix manipulation" 
ctrl4.TooltipText = "Matrix manipulation" 
ctrl4.Style = msoButtonCaption 
With ctrl4 
    .OnAction = "MySub4" 
End With 
Set ctrl5 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl5.Caption = "Simultaneous e&quations solution" 
ctrl5.TooltipText = "Simultaneous Equations" 
ctrl5.Style = msoButtonCaption 
With ctrl5 
    .OnAction = "MySub5" 
End With 
Set ctrl6 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl6.Caption = "Per &unit calc." 
ctrl6.TooltipText = "Per­unit calculations" 
ctrl6.Style = msoButtonCaption 
With ctrl6 
    .OnAction = "MySub6" 
End With 
Set ctrl7 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl7.Caption = "S&ystem bus modelling" 
ctrl7.TooltipText = "System bus modelling" 
ctrl7.Style = msoButtonCaption 
With ctrl7 
    .OnAction = "MySub7" 
End With 
Set myMenubar = CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&System bus modelling" 
Set ctrl71 = newMenu.Controls.Add(Type:=msoControlPopup, Id:=1) 
ctrl71.Caption = "&Y­bus calculation" 
Set ctrl711 = ctrl71.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl711.Caption = "&Four­bus network Y calculation" 
ctrl711.TooltipText = "Calculation of system admittance­bus " 
ctrl711.Style = msoButtonCaption 
With ctrl711 
    .OnAction = "MySub711" 
End With 
Set ctrl72 = newMenu.Controls.Add(Type:=msoControlPopup, Id:=1) 
ctrl72.Caption = "&Z­bus calculation" 
Set ctrl721 = ctrl72.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl721.Caption = "F&our­bus network Z calculation" 
ctrl721.TooltipText = "Calculation of system impedance­bus " 
ctrl721.Style = msoButtonCaption 
With ctrl721 
    .OnAction = "MySub721" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
CommandBars.ActiveMenuBar.Reset 
End Sub 
Modules for all programs in the Workbook: 
Sub MySub1()  'This sub selects (moves the focus­user­ to) the sheet named "series or parallel 
elements" 
' MySub1 Macro 
' Macro recorded 8/31/00 by Hany Kheir 
Sheets("series or parallel elements").Select 
End Sub 
Sub MySub2() 
' MySub2 Macro 
' Macro recorded 8/31/00 by Hany Kheir 
Sheets("Y­D & vice versa transformation").Select 
End Sub 
Sub MySub3() 
' MySub3 Macro 
' Macro recorded 8/31/00 by Hany Kheir 
Sheets("Fault calc. for simple system").Select 
End Sub 
Sub MySub4() 
' MySub4 Macro 
' Macro recorded 8/31/00 by Hany Kheir 
Sheets("Matrices").Select 
End Sub 
Sub MySub5() 
Sheets("Simultaneous equations solution").Select 
End Sub 
Sub MySub6() 
Sheets("Per­unit calc.").Select 
End Sub 
Sub MySub7() 
Sheets("System bus modelling").Select 
End Sub 
 1) Modules for first Worksheet     (series/parallel operations)  
Sub MySub11() 
' Macro recorded 8/31/00 by Hany Kheir 
Range("aa1").Select 
End Sub 
Sub MySub12() 
' Macro recorded 8/31/00 by Hany Kheir 
Range("o1").Select 
End Sub 
Sub MySub13() 
' Macro recorded 8/31/00 by Hany Kheir 
Range("r1").Select 
End Sub 
Sub MySub14() 
' Macro recorded 8/31/00 by Hany Kheir 
Range("l3").Select 
End Sub 
Sub MySub15() 
Range("i1").Select 
End Sub 
Sub MySub16() 
Range("w2").Select 
End Sub 
Sub MySub17() 
Range("w8").Select 
End Sub 
2) Modules for the fourth Worksheet (matrices manipulation): 
Sub MySub41() 
' MySub41 Macro 
' Macro recorded 8/31/00 by Hany Kheir 
Sheets("matrices").Select  'This macro selects the sheet named "matrices". 
Range("b1").Select  'It moves the selector (cursor) to cell "b1" of the active sheet. 
x11 = InputBox("Enter element a11")  'The input box prompts the user to enter a value for the subject 
element. 
x12 = InputBox("Enter element a12")  'The input box prompts the user to enter a value for the subject 
element. 
x21 = InputBox("Enter element a21")  'The input box prompts the user to enter a value for the subject 
element. 
x22 = InputBox("Enter element a22")  'The input box prompts the user to enter a value for the subject 
element. 
Range("b1").Select 
Range("b1") = x11  'This statement assigns the variable x11 to cell "b1", it writes the value entered by 
the user in the 
                                'cell number "b1". 
Range("d1").Select 
Range("d1") = x12 
Range("b2").Select 
Range("b2") = x21 
Range("d2").Select 
Range("d2") = x22 
Range("f1").Select 
Range("f1") = x11 
Range("f2").Select 
Range("f2") = x12 
Range("g1").Select 
Range("g1") = x21 
Range("g2").Select 
Range("g2") = x22 
det = (x11 * x22) ­ (x12 * x21) 'The determinant of of the matrix is calculated. 
Range("a4").Select 
Range("a4") = det     'The value of the determinant is placed in cell a4. 
  
Range("b7").Select  'The  inverse matrix elements are placed in cells: b7, b8, d7, d8. 
x22i = x22 / det 
Range("b7") = x22i 
Range("d7").Select 
x12i = x12 / det 
Range("d7") = ­x12i 
Range("b8").Select 
x21i = x21 / det 
Range("b8") = ­x21i 
Range("d8").Select 
x11i = x11 / det 
Range("d8") = x11i 
End Sub 
Sub MySub42() 
Sheets("matrices").Select 
Range("b1").Select 
x11 = InputBox("Enter element a11") 
x12 = InputBox("Enter element a12") 
x13 = InputBox("Enter element a13") 
x21 = InputBox("Enter element a21") 
x22 = InputBox("Enter element a22") 
x23 = InputBox("Enter element a23") 
x31 = InputBox("Enter element a31") 
x32 = InputBox("Enter element a32") 
x33 = InputBox("Enter element a33") 
Range("b11") = x11 
Range("f15") = x11 
Range("d11") = x12 
Range("f16") = x12 
Range("f11") = x13 
Range("f17") = x13 
Range("b12") = x21 
Range("g15") = x21 
Range("d12") = x22 
Range("g16") = x22 
Range("f12") = x23 
Range("g17") = x23 
Range("b13") = x31 
Range("h15") = x31 
Range("d13") = x32 
Range("h16") = x32 
Range("f13") = x33 
Range("h17") = x33 
det = (x11) * ((x22) * (x33) ­ (x32) * (x23)) ­ (x12) * ((x21) * (x33) ­ (x23) * (x31)) + (x13) * ((x21) * 
(x32) ­­ (x22) * (x31)) 
Range("b15") = det 
Range("b21") = ((x22 * x33) ­ (x23 * x32)) / det 
Range("d21") = ­((x21 * x33) ­ (x23 * x31)) / det 
Range("f21") = ((x21 * x32) ­ (x31 * x22)) / det 
Range("b22") = ­((x12 * x33) ­ (x13 * x32)) / det 
Range("d22") = ((x11 * x33) ­ (x13 * x31)) / det 
Range("f22") = ­((x11 * x32) ­ (x31 * x12)) / det 
Range("b23") = ((x12 * x23) ­ (x13 * x22)) / det 
Range("d23") = ­((x11 * x23) ­ (x13 * x21)) / det 
Range("f23") = ((x11 * x22) ­ (x21 * x12)) / det 
End Sub 
3) Modules for the fifth Worksheet (Simultaneous equations solution): 
Sub MySub51() 
Sheets("Simultaneous equations solution").Select 
Range("b1").Select 
y11 = InputBox("Enter element a11") 
y12 = InputBox("Enter element a12") 
y13 = InputBox("Enter element a13") 
y14 = InputBox("Enter element a14") 
y15 = InputBox("Enter element a15") 
y21 = InputBox("Enter element a21") 
y22 = InputBox("Enter element a22") 
y23 = InputBox("Enter element a23") 
y24 = InputBox("Enter element a24") 
y25 = InputBox("Enter element a25") 
y31 = InputBox("Enter element a31") 
y32 = InputBox("Enter element a32") 
y33 = InputBox("Enter element a33") 
y34 = InputBox("Enter element a34") 
y35 = InputBox("Enter element a35") 
y41 = InputBox("Enter element a41") 
y42 = InputBox("Enter element a42") 
y43 = InputBox("Enter element a43") 
y44 = InputBox("Enter element a44") 
y45 = InputBox("Enter element a45") 
y51 = InputBox("Enter element a51") 
y52 = InputBox("Enter element a52") 
y53 = InputBox("Enter element a53") 
y54 = InputBox("Enter element a54") 
y55 = InputBox("Enter element a55") 
i1 = InputBox("Enter right hand side of first equation") 
i2 = InputBox("Enter right hand side of second equation") 
i3 = InputBox("Enter right hand side of third equation") 
i4 = InputBox("Enter right hand side of fourth equation") 
i5 = InputBox("Enter right hand side of fifth equation") 
Range("b2") = y11  'The value of element y11 of the left hand side of the equations is placed in cell b2. 
Range("d2") = y12 
Range("f2") = y13 
Range("h2") = y14 
Range("j2") = y15 
Range("b3") = y21 
Range("d3") = y22 
Range("f3") = y23 
Range("h3") = y24 
Range("j3") = y25 
Range("b4") = y31 
Range("d4") = y32 
Range("f4") = y33 
Range("h4") = y34 
Range("j4") = y35 
Range("b5") = y41 
Range("d5") = y42 
Range("f5") = y43 
Range("h5") = y44 
Range("j5") = y45 
Range("b6") = y51 
Range("d6") = y52 
Range("f6") = y53 
Range("h6") = y54 
Range("j6") = y55 
y110 = y11 / y11  'The steps of the calculations is starting here 
y120 = y12 / y11 
y130 = y13 / y11 
y140 = y14 / y11 
y150 = y15 / y11 
y220 = y22 ­ (y21) * (y12) / (y11) 
y230 = y23 ­ (y21) * (y13) / (y11) 
y240 = y24 ­ (y21) * (y14) / y11 
y250 = y25 ­ (y21) * (y15) / y11 
y320 = y32 ­ (y31) * (y12) / y11 
y330 = y33 ­ (y31) * (y13) / y11 
y340 = y34 ­ (y31) * (y14) / y11 
y350 = y35 ­ (y31) * (y15) / y11 
y420 = y42 ­ (y41) * (y12) / y11 
y430 = y43 ­ (y41) * (y13) / y11 
y440 = y44 ­ (y41) * (y14) / y11 
y450 = y45 ­ (y41) * (y15) / y11 
y520 = y52 ­ (y51) * (y12) / y11 
y530 = y53 ­ (y51) * (y13) / y11 
y540 = y54 ­ (y51) * (y14) / y11 
y550 = y55 ­ (y51) * (y15) / y11 
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
'the L matrix of the triangular factorization =" 
' y11 
' y21, y220 
' y31, y320, y331 
' y41, y420, y431, y442 
' y51, y520, y531, y542, y553 
' "the U matrix of the triangular factorization =" 
' y110, y120, y130, y140, y150 
' y211, y221, y231, y241, y251 
' y312, y322, y332, y342, y352 
' y413, y423, y433, y443, y453 
' 0, 0, 0, 0, 1 
v1 = i1 / y11 
v2 = (i2 ­ (v1) * (y21)) / y220 
v3 = (i3 ­ (v1) * (y31) ­ (y320) * (v2)) / y331 
v4 = (i4 ­ (v1) * (y41) ­ (y420) * (v2) ­ (v3) * (y431)) / y442 
v5 = (i5 ­ (v1) * (y51) ­ (y520) * (v2) ­ (v3) * (y531) ­ (v4) * (y542)) / y553 
f5 = v5 
f4 = (v4 ­ ((y453) * (f5)))  'The final step in the calculation process. 
f3 = (v3 ­ ((y342) * (f4)) ­ ((y352) * (f5))) 
f2 = (v2 ­ ((y231) * (f3)) ­ ((y241) * (f4)) ­ ((y251) * (f5))) 
f1 = (v1 ­ ((y120) * (f2)) ­ ((y130) * (f3)) ­ ((y140) * (f4)) ­ ((y150) * (f5))) 
Range("c9") = f1 'The solution: the first variable value is placed in cell c9. 
Range("c10") = f2  'The second variable value is placed in cell c10 
Range("c11") = f3 
Range("c12") = f4 
Range("c13") = f5 
projname = InputBox("Enter project name:") 'The projname variable will hold the project name entered 
by the user. 
pb = InputBox("Prepared by:")  'The variable pb will hold the data enterd by the user who prepared the 
analysis. 
projnum = InputBox("Project #:") 
da = InputBox("Date:") 
opap = InputBox("Enter 1 to overwrite file or 2 to append it") 'The opap variable will accept a 1 or a 2, 
the user 
              'preference to whether overwrite the file if it exists or append it i.e. add the data to the end of 
the file. 
If opap = 1 Then 
Filenam = InputBox("File name to save the output data in") 'Filenam will hold the file name enterd by 
the user 
Open Filenam For Output As #1  ' to save the data to. 
Print #1, "Project Name:"; projname, "Prepared By: "; pb   'The data stored in the variable projname 
will be written 
Print #1, "Project Number:"; projnum, "Date: "; da 'adjacent to the label "Project Name:" in the data 
file. 
Print #1, "the 5 variables x1,x2,x3,x4,x5 are equal respectively: "; f1, f2, f3, f4, f5 
Close #1 'After all the data is entered (if the file exists, it will be overwritten), the file (it has #1) is 
closed. 
End If 
If opap = 2 Then  'If the file exists, it will be appended. 
Filenam = InputBox("File name to save the output data in") 
Open Filenam For Append As #1 
Print #1, "Project Name:"; projname, "Prepared By: "; pb 
Print #1, "Project Number:"; projnum, "Date: "; da 
Print #1, "the 5 variables x1,x2,x3,x4,x5 are equal respectively: "; f1, f2, f3, f4, f5 
Close #1 
End If 
End Sub 
4) Modules for the sixth Worksheet (per unit calculations): 
Sub MySub62() 
Sheets("Per­unit calc.").Select '"Per­unit calc." Sheet is selected and displayed on the screen. 
Range("a1").Select   'In the above sheet, cell a1 is seelected. 
MsgBox Prompt:="base voltage on the primary of the first transformer = base voltage to be entered by 
user", _ 
        Title:="Note: & ???? ????? ????? ????", _    'The prompt, the title and the button in the message 
box are displayed 
        Buttons:=vbExclamation                       'on the screen. 
MsgBox Prompt:="All the loads are assumed to be on the secondary of the second transformer", _ 
        Title:="Note: & ???? ????? ????? ????", _ 
        Buttons:=vbExclamation 
prim1 = InputBox("primary voltage of first transfo. = ")  'Input boxes are used to get the user data, the 
input to the 
sec1 = InputBox("secondary voltage of first transfo. = ")  ' study. 
prim2 = InputBox("primary of second transfo. = ") 
sec2 = InputBox("secondary of second transfo. = ") 
vb = InputBox("base voltage in KV = ") 
vab = InputBox("base apparent power (MVA) in mva = ") 
mva1 = InputBox("the mva rating of transformer 1 = ") 
mva2 = InputBox(" the mva rating of transformer 2 = ") 
react1 = InputBox("the p.u. reactance of transformer 1 based on its VA or MVA & V or KV ratings") 
react2 = InputBox("the p.u. reactance of transformer 2 based on its VA and V ratings") 
reactl1 = InputBox("the reactance of the line in ohms") 
Load1 = InputBox("total number of motors or generators, max. 3 sets") 
heat = InputBox("if loads include lighting or heaters or the like, enter 1") 
Range("h4") = prim1 'The data entered by the user are written in the cells of the spread sheet. 
Range("h5") = sec1 
Range("h6") = prim2 
Range("h7") = sec2 
Range("h8") = vb 
Range("h9") = vab 
Range("h10") = mva1 
Range("h11") = mva2 
Range("h12") = react1 
Range("h13") = react2 
Range("h14") = reactl1 
Range("h15") = Load1 
Range("h16") = heat 
vb1 = vb * sec1 / (prim1)  'The necessary calculations starts here 
vb2 = vb1 * sec2 / (prim2) 
ib1 = (vab * 1000) / (vb1 * 1.7320508) 
ib2 = (vab * 1000) / (vb2 * 1.7320508) 
reactlpu = (reactl1) * (vab) / ((vb1) ^ 2) 
If Load1 = 1 Then   'The decisions the program takes and branching are based on the user inputted data. 

lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact1 = InputBox("reactance of load 1 = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb2) ^ 2) 
End If 
If Load1 = 2 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb2) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb2) ^ 2) 
End If 
If Load1 = 3 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
lreact3 = InputBox("react. of load 3 = ") 
lmva3 = InputBox("apparent power rating of load 3 in mva = ") 
lkv3 = InputBox("voltage rating of load 3 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb2) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb2) ^ 2) 
load3pu = lreact3 * (vab / lmva3) * ((lkv3 / vb2) ^ 2) 
End If 
Range("e18") = lreact1  'The results i.e. data outputted from the calculations are written to the cells in 
the spread 
Range("e19") = lmva1   'sheet. 
Range("e20") = lkv1 
Range("e21") = lreact2 
Range("eh22") = lmva2 
Range("e23") = lkv2 
Range("e24") = lreact3 
Range("e25") = lmva3 
Range("e26") = lkv3 
reactpu1 = react1 * (vab / mva1) * ((prim1 / vb) ^ 2) 
reactpu2 = react2 * (vab / mva2) * ((prim2 / vb1) ^ 2) 
Range("h18") = reactpu1 
Range("h19") = reactlpu 
Range("h20") = reactpu2 
Range("h21") = load1pu 
Range("h22") = load2pu 
Range("h23") = load3pu 
Range("h24") = ib1 
Range("h25") = ib2 
If h16 = 1 Then 
mw = InputBox("load mw = ") 
pf = InputBox("p.f. = ") 
bv = InputBox("bus voltage = ") 
bvr = bv / vb2 
lchr = (mw * (1000) / (1.732 * bv * pf)) / ib2 
Range("e28") = mw 
Range("e29") = pf 
Range("e30") = bv 
Range("h26") = bvr 
Range("h27") = lchr 
End If 
Range("f17").Select 
End Sub 
Sub MySub61() 
Sheets("Per­unit calc.").Select  'Theabove sub is run for a certain number of transformers in tandem, 
Range("q1").Select   'this sub is run for another number of transformers in tandem. The same procedure 

Range("s3") = ""       'and steps are used. The first few steps in this sub is to clear any data previously 
Range("s4") = ""       'stored in the cells. 
Range("s5") = "" 
Range("s6") = "" 
Range("s19") = "" 
Range("s20") = "" 
Range("s22") = 0 
Range("s23") = 0 
Range("s24") = 0 
Range("u19") = 0 
Range("u18") = 0 
Range("s7") = 0 
Range("s8") = 0 
Range("u3") = 0 
Range("u4") = 0 
Range("u5") = 0 
Range("s9") = 0 
Range("s10") = 0 
Range("s11") = 0 
Range("s12") = 0 
Range("s13") = 0 
Range("s14") = 0 
Range("s15") = 0 
Range("s16") = 0 
Range("s17") = 0 
Range("s18") = 0 
Range("u17") = 0 
Range("u9") = 0 
Range("u10") = 0 
Range("u14") = "" 
Range("u15") = "" 
Range("u16") = "" 
Range("u11") = "" 
Range("u12") = "" 
Range("u13") = "" 
MsgBox Prompt:="base voltage on the primary of the first transformer = base voltage to be entered by 
user", _ 
        Title:="Note: & ???? ????? ????? ????", _ 
        Buttons:=vbExclamation 
MsgBox Prompt:="All the loads are assumed to be on the secondary of the transformer", _ 
        Title:="Note: & ???? ????? ????? ????", _ 
        Buttons:=vbExclamation 
prim1 = InputBox("primary voltage of transfo. = ") 
sec1 = InputBox("secondary voltage of transfo. = ") 
bn = InputBox("number of buses on the sec. of transformer,including the sec. wdg. bus = ") 
mva1 = InputBox("the mva rating of transformer = ") 
vb = InputBox("base voltage in KV = ") 
vab = InputBox("base apparent power (MVA) in mva = ") 
vb1 = vb * sec1 / (prim1) 
ib1 = (vab * 1000) / (vb1 * 1.7320508) 
Range("s3") = prim1 
Range("s4") = sec1 
Range("s5") = bn 
Range("s6") = mva1 
Range("s19") = vb 
Range("s20") = vab 
If (bn = 2 Or bn = 1) Then 
react1 = InputBox("the reactance of transformer 1 based on its VA and V ratings, in p.u.") 
reactl1 = InputBox("the reactance of the line (between bus 1 and 2) in ohms") 
Load1 = InputBox("total number of motors ( or generators) at bus 1  ") 
heat = InputBox("if loads include lighting or heaters or the like, enter 1") 
Range("s21") = heat 
reactlpu = (reactl1) * (vab) / ((vb1) ^ 2) 
If Load1 = 1 Then 
lreact1 = InputBox("reactance of load1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
End If 
If Load1 = 2 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
End If 
If Load1 = 3 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
lreact3 = InputBox("react. of load 3 = ") 
lmva3 = InputBox("apparent power rating of load 3 in mva = ") 
lkv3 = InputBox("voltage rating of load 3 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
load3pu = lreact3 * (vab / lmva3) * ((lkv3 / vb1) ^ 2) 
End If 
reactpu1 = react1 * (vab / mva1) * ((prim1 / vb) ^ 2) 
'Print " the p.u. values on base mva and base KV for the tr.1, line 1, loads (or generators connected to 
the secondary of tr.1 = "; reactpu1, reactlpu, load1pu, load2pu, load3pu 
'Print "base current in second  = "; ib1, 
If heat = 1 Then 
mw = InputBox("load mw = ") 
pf = InputBox("p.f. = ") 
bv = InputBox("bus voltage = ") 
'Print " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1 
bvr = bv / vb1 
lchr = (mw * (1000) / (1.732 * bv * pf)) / ib1 
End If 
Range("s22") = mw 
Range("s23") = pf 
Range("s24") = bv 
Range("u19") = bvr 
Range("u18") = lchr 
Range("s7") = react1 
Range("s8") = reactl1 
Range("s9") = Load1 
Range("s10") = lreact1 
Range("s11") = lmva1 
Range("s12") = lkv1 
Range("s13") = lreact2 
Range("s14") = lmva2 
Range("s15") = lkv2 
Range("s16") = lreact3 
Range("s17") = lmva3 
Range("s18") = lkv3 
Range("u17") = ib1 
Range("u9") = reactpu1 
Range("u10") = reactlpu 
Range("u14") = load1pu 
Range("u15") = load2pu 
Range("u16") = load3pu 
End If 
If bn = 3 Then 
react1 = InputBox("the pu reactance of transformer 1 based on its VA and V ratings") 
reactl1 = InputBox("the reactance of the line, between bus 1 and 2 in ohms") 
reactl2 = InputBox("the reactance of the line, between bus 2 and 3 in ohms") 
Load1 = InputBox("total number of motors, or generators at bus 1  ") 
heat = InputBox("if loads include lighting or heaters or the like, enter 1") 
Range("s21") = heat 
reactlpu = (reactl1) * (vab) / ((vb1) ^ 2) 
reaclpu1 = (reactl2) * (vab) / ((vb1) ^ 2) 
If Load1 = 1 Then 
lreact1 = InputBox("reactance of load1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
End If 
If Load1 = 2 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
End If 
If Load1 = 3 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
lreact3 = InputBox("react. of load 3 = ") 
lmva3 = InputBox("apparent power rating of load 3 in mva = ") 
lkv3 = InputBox("voltage rating of load 3 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
load3pu = lreact3 * (vab / lmva3) * ((lkv3 / vb1) ^ 2) 
End If 
reactpu1 = react1 * (vab / mva1) * ((prim1 / vb) ^ 2) 
'Print " the p.u. values on base mva and base KV for the tr.1, line 1, loads (or generators connected to 
the secondary of tr.1 and line 2 = "; reactpu1, reactlpu, load1pu, load2pu, load3pu, reaclpu1 
'Print "base current in second  = "; ib1 
If heat = 1 Then 
mw = InputBox("load mw = ") 
pf = InputBox("p.f. = ") 
bv = InputBox("bus voltage = ") 
'Print " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1 
bvr = bv / vb1 
lchr = (mw * (1000) / (1.732 * bv * pf)) / ib1 
End If 
Range("s22") = mw 
Range("s23") = pf 
Range("s24") = bv 
Range("u19") = bvr 
Range("u18") = lchr 
Range("s7") = react1 
Range("s8") = reactl1 
Range("u3") = reactl2 
Range("s9") = Load1 
Range("s10") = lreact1 
Range("s11") = lmva1 
Range("s12") = lkv1 
Range("s13") = lreact2 
Range("s14") = lmva2 
Range("s15") = lkv2 
Range("s16") = lreact3 
Range("s17") = lmva3 
Range("s18") = lkv3 
Range("u17") = ib1 
Range("u9") = reactpu1 
Range("u10") = reactlpu 
Range("u14") = load1pu 
Range("u15") = load2pu 
Range("u16") = load3pu 
Range("u11") = reaclpu1 
End If 
If bn = 4 Then 
react1 = InputBox("the pu reactance of transformer 1 based on its VA and V ratings") 
reactl1 = InputBox("the reactance of the line, between bus 1 and 2, in ohms") 
reactl2 = InputBox("the reactance of the line, between bus 2 and 3, in ohms") 
reactl3 = InputBox("the reactance of the line, between bus 3 and 4, in ohms") 
Load1 = InputBox("total number of motors, or generators, at bus 1  ") 
heat = InputBox("if loads include lighting or heaters or the like, enter 1") 
Range("s21") = heat 
reactlpu = (reactl1) * (vab) / ((vb1) ^ 2) 
reaclpu1 = (reactl2) * (vab) / ((vb1) ^ 2) 
reaclpu2 = (reactl3) * (vab) / ((vb1) ^ 2) 
If Load1 = 1 Then 
lreact1 = InputBox("reactance of load1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
End If 
If Load1 = 2 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
End If 
If Load1 = 3 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
lreact3 = InputBox("react. of load 3 = ") 
lmva3 = InputBox("apparent power rating of load 3 in mva = ") 
lkv3 = InputBox("voltage rating of load 3 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
load3pu = lreact3 * (vab / lmva3) * ((lkv3 / vb1) ^ 2) 
End If 
reactpu1 = react1 * (vab / mva1) * ((prim1 / vb) ^ 2) 
'Print " the p.u. values on base mva and base KV for the tr.1, line 1, loads (or generators connected to 
the secondary of tr.1, line 2 and line 3 = "; reactpu1, reactlpu, load1pu, load2pu, load3pu, reaclpu1, 
reaclpu2 
'Print "base current in second  = "; ib1 
If heat = 1 Then 
mw = InputBox("load mw = ") 
pf = InputBox("p.f. = ") 
bv = InputBox("bus voltage = ") 
'Print " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1 
bvr = bv / vb1 
lchr = (mw * (1000) / (1.732 * bv * pf)) / ib1 
End If 
Range("s22") = mw 
Range("s23") = pf 
Range("s24") = bv 
Range("u19") = bvr 
Range("u18") = lchr 
Range("s7") = react1 
Range("s8") = reactl1 
Range("u4") = reactl3 
Range("s9") = Load1 
Range("s10") = lreact1 
Range("s11") = lmva1 
Range("s12") = lkv1 
Range("s13") = lreact2 
Range("s14") = lmva2 
Range("s15") = lkv2 
Range("s16") = lreact3 
Range("s17") = lmva3 
Range("s18") = lkv3 
Range("u17") = ib1 
Range("u9") = reactpu1 
Range("u10") = reactlpu 
Range("u14") = load1pu 
Range("u15") = load2pu 
Range("u16") = load3pu 
Range("u11") = reaclpu1 
Range("u12") = reaclpu2 
End If 
If bn = 5 Then 
react1 = InputBox("the pu reactance of transformer 1 based on its VA and V ratings") 
reactl1 = InputBox("the reactance of the line, between bus 1 and 2, in ohms") 
reactl2 = InputBox("the reactance of the line, between bus 2 and 3, in ohms") 
reactl3 = InputBox("the reactance of the line, between bus 3 and 4, in ohms") 
reactl4 = InputBox("the reactance of the line, between bus 4 and 5, in ohms") 
Load1 = InputBox("total number of motors ( or generators) at bus 1  ") 
heat = InputBox("if loads include lighting or heaters or the like, enter 1") 
Range("s21") = heat 
reactlpu = (reactl1) * (vab) / ((vb1) ^ 2) 
reaclpu1 = (reactl2) * (vab) / ((vb1) ^ 2) 
reaclpu2 = (reactl3) * (vab) / ((vb1) ^ 2) 
reaclpu3 = (reactl4) * (vab) / ((vb1) ^ 2) 
If Load1 = 1 Then 
lreact1 = InputBox("reactance of load1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
End If 
If Load1 = 2 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
End If 
If Load1 = 3 Then 
lreact1 = InputBox("reactance of load 1 = ") 
lmva1 = InputBox("apparent power rating of load 1 in mva = ") 
lkv1 = InputBox("voltage rating of load 1 in KV = ") 
lreact2 = InputBox("react. of load 2 = ") 
lmva2 = InputBox("apparent power rating of load 2 in mva = ") 
lkv2 = InputBox("voltage rating of load 2 in KV = ") 
lreact3 = InputBox("react. of load 3 = ") 
lmva3 = InputBox("apparent power rating of load 3 in mva = ") 
lkv3 = InputBox("voltage rating of load 3 in KV = ") 
load1pu = lreact1 * (vab / lmva1) * ((lkv1 / vb1) ^ 2) 
load2pu = lreact2 * (vab / lmva2) * ((lkv2 / vb1) ^ 2) 
load3pu = lreact3 * (vab / lmva3) * ((lkv3 / vb1) ^ 2) 
End If 
reactpu1 = react1 * (vab / mva1) * ((prim1 / vb) ^ 2) 
'Print " the p.u. values on base mva and base KV for the tr.1, line 1, loads (or generators connected to 
the secondary of tr.1, line 2, line 3 and 4 = "; reactpu1, reactlpu, load1pu, load2pu, load3pu, reaclpu1, 
reaclpu2, reaclpu3 
'Print "base current in second  = "; ib1 
If heat = 1 Then 
mw = InputBox("load mw = ") 
pf = InputBox("p.f. = ") 
bv = InputBox("bus voltage = ") 
'Print " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1 
bvr = bv / vb1 
lchr = (mw * (1000) / (1.732 * bv * pf)) / ib1 
End If 
Range("s22") = mw 
Range("s23") = pf 
Range("s24") = bv 
Range("u19") = bvr 
Range("u18") = lchr 
Range("s7") = react1 
Range("s8") = reactl1 
Range("u3") = reactl2 
Range("u4") = reactl3 
Range("u5") = reactl4 
Range("s9") = Load1 
Range("s10") = lreact1 
Range("s11") = lmva1 
Range("s12") = lkv1 
Range("s13") = lreact2 
Range("s14") = lmva2 
Range("s15") = lkv2 
Range("s16") = lreact3 
Range("s17") = lmva3 
Range("s18") = lkv3 
Range("u17") = ib1 
Range("u9") = reactpu1 
Range("u10") = reactlpu 
Range("u14") = load1pu 
Range("u15") = load2pu 
Range("u16") = load3pu 
Range("u11") = reaclpu1 
Range("u12") = reaclpu2 
Range("u13") = reaclpu3 
End If 
End Sub 
5) Modules for the seventh Worksheet (system bus modelling): 
Sub MySub711() 
r12 = InputBox("series resistance of line 1­2 in p.u.= ") 'The user enters the data into the series if the 
input boxes 
r13 = InputBox("series resistance of line 1­3 in p.u.= ") 'will appear on the screen sequentialy. 
r24 = InputBox("series resistance of line 2­4 in p.u.= ") 
r34 = InputBox("series resistance of line 3­4 in p.u.= ") 
x12 = InputBox("series reactance of line 1­2 in p.u.= ") 
x13 = InputBox("series reactance of line 1­3 in p.u.= ") 
x24 = InputBox("series reactance of line 2­4 in p.u.= ") 
x34 = InputBox("series reactance of line 3­4 in p.u.= ") 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5    'The calculation starts here, calculating the impedance and the 
angle 
z13 = ((r13) ^ 2 + (x13) ^ 2) ^ 0.5    'for the different segments (sections) of the system. 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z34 = ((r34) ^ 2 + (x34) ^ 2) ^ 0.5 
an12 = Atn(x12 / r12) 
an13 = Atn(x13 / r13) 
an24 = Atn(x24 / r24) 
an34 = Atn(x34 / r34) 
y12 = 1 / z12   'The admittance is calculated from the impedance previously calculated. 
y13 = 1 / z13 
y24 = 1 / z24 
y34 = 1 / z34 
g12 = y12 * Cos(­an12) 'The conductance is calculated. 
g13 = y13 * Cos(­an13) 
g24 = y24 * Cos(­an24) 
g34 = y34 * Cos(­an34) 
b12 = y12 * Sin(­an12)   'The susceptance is calculated. 
b13 = y13 * Sin(­an13) 
b24 = y24 * Sin(­an24) 
b34 = y34 * Sin(­an34) 
gb11 = g12 + g13   'The node equivalent self admittance. 
gb22 = g24 + g12 
gb33 = g34 + g13 
gb44 = g34 + g24 
gb12 = ­g12  'The equivalent branch admittance. 
gb21 = ­g12 
gb13 = ­g13 
gb31 = ­g13 
gb24 = ­g24 
gb42 = ­g24 
gb34 = ­g34 
gb43 = ­g34 
bb11 = b12 + b13  'The equivalent node self susceptance. 
bb22 = b24 + b12 
bb33 = b34 + b13 
bb44 = b34 + b24 
bb12 = ­b12    'The equivalent branch susceptance. 
bb21 = ­b12 
bb13 = ­b13 
bb31 = ­b13 
bb24 = ­b24 
bb42 = ­b24 
bb34 = ­b34 
bb43 = ­b34 
pb2 = ((gb22) * ((v2) ^ 2)) + ((v2 * v1) * (­y12 * Cos(­an12 + d1 ­ d2))) + ((v4 * v2) * (­y24 * Cos(­
an24 + d4 ­ d2))) 'These equations are not applicable, here. Their use will become obvious in Chapter 4 
"Load flow studies". 
pb3 = ((gb33) * ((v3) ^ 2)) + ((v3 * v1) * (­y13 * Cos(­an13 ­ d3 + d1))) + ((v4) * (v3) * (­y34 * Cos(­
an34 ­ d3 + d4))) 
pb4 = ((gb44) * ((v4) ^ 2)) + ((v4 * v2) * (­y24 * Cos(­an24 ­ d4 + d2))) + ((v3 * v4) * (­y34 * Cos(­
an34 ­ d4 + d3))) 
qb2 = ­((bb22) * ((v2) ^ 2)) ­ ((v2 * v1) * (­y12 * Sin(­an12 + d1 ­ d2))) ­ ((v4 * v2) * (­y24 * Sin(­
an24 + d4 ­ d2))) 
qb3 = ­((bb33) * ((v3) ^ 2)) ­ ((v3 * v1) * (­y13 * Sin(­an13 ­ d3 + d1))) ­ ((v4) * (v3) * (­y34 * Sin(­
an34 ­ d3 + d4))) 
Range("b3") = bb11       'The (solution) calculated equivalent conductances and susceptances are 
written to the 
Range("b8") = gb11       'applicable cells in the spread sheet. 
Range("d3") = gb12 
Range("d8") = bb12 
Range("f3") = gb13 
Range("f8") = bb13 
Range("h3") = gb14 
Range("h8") = bb14 
Range("b4") = gb21 
Range("b9") = bb21 
Range("d4") = gb22 
Range("d9") = bb22 
Range("f4") = gb23 
Range("f9") = bb23 
Range("h4") = gb24 
Range("h9") = bb24 
Range("b5") = gb31 
Range("b10") = bb31 
Range("d5") = gb32 
Range("d10") = bb32 
Range("f5") = gb33 
Range("f10") = bb33 
Range("h5") = gb34 
Range("h10") = bb34 
Range("b6") = gb41 
Range("b11") = bb41 
Range("d6") = gb42 
Range("d11") = bb42 
Range("f6") = gb43 
Range("f11") = bb43 
Range("h6") = gb44 
Range("h11") = bb44 
End Sub 
Sub MySub721()   'The calculation of the Z­bus. 
x01 = CDbl(InputBox("reactance between reference node and bus 1="))   'The data inputted by the user, 
using input 
x02 = CDbl(InputBox("reactance between reference node and bus 2="))   'box. The variable is 
converted to double 
x03 = CDbl(InputBox("reactance between reference node and bus 3="))   ' precission number data type. 
X01 is the 
x04 = CDbl(InputBox("reactance between reference node and bus 4="))   ' reactance between node 0 
and node 1. 
xx12 = CDbl(InputBox("reactance between bus 1 and bus 2="))               'X12 is the reactance between 
node 1 & 2. 
xx23 = CDbl(InputBox("reactance between bus 2 and bus 3=")) 
xx34 = CDbl(InputBox("reactance between bus 3 and bus 4=")) 
xx42 = CDbl(InputBox("reactance between bus 4 and bus 2=")) 
xx41 = CDbl(InputBox("reactance between bus 4 and bus 1=")) 
x11 = x01   'The first step in the calculation. 
x12 = x11 
x21 = x12 
x22 = x01 + xx12 
If x02 > 0 Then   'The branching and decision making based on the user input. If the user entered 
x11p = x11    'a vlue  higher than 0 for the variable x02, these steps are run. 
x12p = x12 
x21p = x21 
x22p = x22 
xp1 = x21 
xp2 = x22 
xpp = x02 + x22 
x1p = x12 
x2p = x22 
x111 = x11p ­ ((x1p) * (xp1) / (xpp)) 
x121 = x12p ­ ((x1p) * (xp2) / (xpp)) 
x211 = x21p ­ ((x2p) * (xp1) / (xpp)) 
x221 = x22p ­ ((x2p) * (xp2) / (xpp)) 
x131 = x121 
x231 = x221 
x311 = x211 
x321 = x221 
x331 = x221 + xx23 
Else         'If x02 variable as entered by the user is  equal to 0, these steps are followed by the program. 
x31 = x21 
x32 = x22 
x33 = xx23 + x22 
x13 = x12 
x23 = x22 
End If 
If (x111 = 0 And x221 = 0) Then  'If x111= 0 as well as x221 is equal to 0, then these steps are followed. 

x11b = x11 
x12b = x12 
x13b = x13 
x21b = x21 
x22b = x22 
x23b = x23 
x31b = x31 
x32b = x32 
x33b = x33 
Else     'Otherwise, these steps are followed. 
x11b = x111 
x12b = x121 
x13b = x131 
x21b = x211 
x22b = x221 
x23b = x231 
x31b = x311 
x32b = x321 
x33b = x331 
End If 
If x03 > 0 Then 
x11p1 = x11b 
x12p1 = x12b 
x13p1 = x13b 
x21p1 = x21b 
x22p1 = x22b 
x23p1 = x23b 
x31p1 = x31b 
x32p1 = x32b 
x33p1 = x33b 
xp12 = x31b 
xp22 = x32b 
xp32 = x33b 
xpp1 = x03 + x33b 
x1p2 = x13b 
x2p2 = x23b 
x3p2 = x33b 
x112 = x11p1 ­ ((x1p2) * (xp12) / (xpp1)) 
x122 = x12p1 ­ ((x1p2) * (xp22) / (xpp1)) 
x132 = x13p1 ­ ((x1p2) * (xp32) / (xpp1)) 
x212 = x21p1 ­ ((x2p2) * (xp12) / (xpp1)) 
x222 = x22p1 ­ ((x2p2) * (xp22) / (xpp1)) 
x232 = x23p1 ­ ((x2p2) * (xp32) / (xpp1)) 
x312 = x31p1 ­ ((x3p2) * (xp12) / (xpp1)) 
x322 = x32p1 ­ ((x3p2) * (xp22) / (xpp1)) 
x332 = x33p1 ­ ((x3p2) * (xp32) / (xpp1)) 
x142 = x132 
x242 = x232 
x342 = x332 
x412 = x312 
x422 = x322 
x432 = x332 
x442 = x332 + xx34 
Else 
x11d = x11 
x12d = x12 
x13d = x13 
x14d = x13 
x21d = x21 
x22d = x22 
x23d = x23 
x24d = x23 
x31d = x31 
x32d = x32 
x33d = x33 
x34d = x33 
x41d = x31 
x42d = x32 
x43d = x33 
x44d = x33 + xx34 
End If 
If (xx42 > 0 And x03 > 0) Then 
x1p3 = x122 ­ x142 
x2p3 = x222 ­ x242 
x3p3 = x322 ­ x342 
x4p3 = x422 ­ x442 
xp13 = x1p3 
xp23 = x2p3 
xp33 = x3p3 
xp43 = x4p3 
xpp3 = x222 + x442 ­ 2 * (x242) + xx42 
x11f = x112 ­ (x1p3) * (xp13) / (xpp3) 
x12f = x122 ­ (x1p3) * (xp23) / (xpp3) 
x13f = x132 ­ (x1p3) * (xp33) / (xpp3) 
x14f = x142 ­ (x1p3) * (xp43) / (xpp3) 
x21f = x212 ­ (x2p3) * (xp13) / (xpp3) 
x22f = x222 ­ (x2p3) * (xp23) / (xpp3) 
x23f = x232 ­ (x2p3) * (xp33) / (xpp3) 
x24f = x242 ­ (x2p3) * (xp43) / (xpp3) 
x31f = x312 ­ (x3p3) * (xp13) / (xpp3) 
x32f = x322 ­ (x3p3) * (xp23) / (xpp3) 
x33f = x332 ­ (x3p3) * (xp33) / (xpp3) 
x34f = x342 ­ (x3p3) * (xp43) / (xpp3) 
x41f = x412 ­ (x4p3) * (xp13) / (xpp3) 
x42f = x422 ­ (x4p3) * (xp23) / (xpp3) 
x43f = x432 ­ (x4p3) * (xp33) / (xpp3) 
x44f = x442 ­ (x4p3) * (xp43) / (xpp3) 
End If 
If (xx42 > 0 And x03 = 0) Then 
x1p3 = x12d ­ x14d 
x2p3 = x22d ­ x24d 
x3p3 = x32d ­ x34d 
x4p3 = x42d ­ x44d 
xp13 = x1p3 
xp23 = x2p3 
xp33 = x3p3 
xp43 = x4p3 
xpp3 = x22d + x44d ­ 2 * (x24d) + xx42 
x11f = x11d ­ (x1p3) * (xp13) / (xpp3) 
x12f = x12d ­ (x1p3) * (xp23) / (xpp3) 
x13f = x13d ­ (x1p3) * (xp33) / (xpp3) 
x14f = x14d ­ (x1p3) * (xp43) / (xpp3) 
x21f = x21d ­ (x2p3) * (xp13) / (xpp3) 
x22f = x22d ­ (x2p3) * (xp23) / (xpp3) 
x23f = x23d ­ (x2p3) * (xp33) / (xpp3) 
x24f = x24d ­ (x2p3) * (xp43) / (xpp3) 
x31f = x31d ­ (x3p3) * (xp13) / (xpp3) 
x32f = x32d ­ (x3p3) * (xp23) / (xpp3) 
x33f = x33d ­ (x3p3) * (xp33) / (xpp3) 
x34f = x34d ­ (x3p3) * (xp43) / (xpp3) 
x41f = x41d ­ (x4p3) * (xp13) / (xpp3) 
x42f = x42d ­ (x4p3) * (xp23) / (xpp3) 
x43f = x43d ­ (x4p3) * (xp33) / (xpp3) 
x44f = x44d ­ (x4p3) * (xp43) / (xpp3) 
End If 
If xx41 > 0 Then 
x1p4 = x11f ­ x14f 
x2p4 = x21f ­ x24f 
x3p4 = x31f ­ x34f 
x4p4 = x41f ­ x44f 
xp14 = x1p4 
xp24 = x2p4 
xp34 = x3p4 
xp44 = x4p4 
xpp4 = x11f + x44f ­ 2 * (x14f) + xx41 
x11f1 = x11f ­ (x1p4) * (xp14) / (xpp4) 
x12f1 = x12f ­ (x1p4) * (xp24) / (xpp4) 
x13f1 = x13f ­ (x1p4) * (xp34) / (xpp4) 
x14f1 = x14f ­ (x1p4) * (xp44) / (xpp4) 
x21f1 = x21f ­ (x2p4) * (xp14) / (xpp4) 
x22f1 = x22f ­ (x2p4) * (xp24) / (xpp4) 
x23f1 = x23f ­ (x2p4) * (xp34) / (xpp4) 
x24f1 = x24f ­ (x2p4) * (xp44) / (xpp4) 
x31f1 = x31f ­ (x3p4) * (xp14) / (xpp4) 
x32f1 = x32f ­ (x3p4) * (xp24) / (xpp4) 
x33f1 = x33f ­ (x3p4) * (xp34) / (xpp4) 
x34f1 = x34f ­ (x3p4) * (xp44) / (xpp4) 
x41f1 = x41f ­ (x4p4) * (xp14) / (xpp4) 
x42f1 = x42f ­ (x4p4) * (xp24) / (xpp4) 
x43f1 = x43f ­ (x4p4) * (xp34) / (xpp4) 
x44f1 = x44f ­ (x4p4) * (xp44) / (xpp4) 
End If 
If xx41 = 0 Then 
Debug.Print x11f, x12f, x13f, x14f 
Debug.Print x21f, x22f, x23f, x24f 
Debug.Print x31f, x32f, x33f, x34f 
Debug.Print x41f, x42f, x43f, x44f 
Range("b16") = x11f  'The results (outputted data) are written to the appropriate cells in the spread 
sheet. 
Range("d16") = x12f 
Range("f16") = x13f 
Range("h16") = x14f 
Range("b17") = x21f 
Range("d17") = x22f 
Range("f17") = x23f 
Range("h17") = x24f 
Range("b18") = x31f 
Range("d18") = x32f 
Range("f18") = x33f 
Range("h18") = x34f 
Range("b19") = x41f 
Range("d19") = x42f 
Range("f19") = x43f 
Range("h19") = x44f 
Else 
Debug.Print x11f1, x12f1, x13f1, x14f1 
Debug.Print x21f1, x22f1, x23f1, x24f1 
Debug.Print x31f1, x32f1, x33f1, x34f1 
Debug.Print x41f1, x42f1, x43f1, x44f1 
Range("b16") = x11f1 
Range("d16") = x12f1 
Range("f16") = x13f1 
Range("h16") = x14f1 
Range("b17") = x21f1 
Range("d17") = x22f1 
Range("f17") = x23f1 
Range("h17") = x24f1 
Range("b18") = x31f1 
Range("d18") = x32f1 
Range("f18") = x33f1 
Range("h18") = x34f1 
Range("b19") = x41f1 
Range("d19") = x42f1 
Range("f19") = x43f1 
Range("h19") = x44f1 
End If 
End Sub 
  
  
Quattro Pro of Borland: 
The next few pages will have the following: 
1) The layout of the macros spread sheet page. It shows the address of the cells (the top bar having the 
letters and the side bar having the numbers). All the macros used to customized the spread sheet 
program, so that it can perform certain fundamental calcaulations are also shown. They are shown on 
page 61. 
3) The additional menu element (Power) that will be added to the standard menu bar (between the Edit 
and the Block ) with its drop down elements is also shown. It is shown on page 62. 
4) The block names (i.e. the names given to each macro) as well as the macros themselves are listed on 
page 62. 
5) The sequence of operation of a macro when certain cutomized spread sheet file is openend is given 
on page 63. The procedure to name a cell or a block of cells is also given on page 63. 
6) Pages 65 to 78 give a few example of the printouts from the program itself. A couple of options are 
used when producing these printouts. The layout of the working area of the spread sheet (where the 
user enters the data or the cells where the user entered data are written to­if dialog boxes are used to 
accept user's data) including the section where the results of the calculation are written to is shown. 
Note: the on­line version of this book does not include the Quattro Pro examples

contents

Chapter 3 
Fault calculations

Introduction: 
Faults in power systems are imminent. Thus from the generating point all the way downstream to the 
utilization point passing through the transmission and the distribution systems, fault sensing devices 
(instrument transformers & relays) and sections isolating equipment (circuit breakers, load break and 
disconnect switches) are mounted or installed. The size of such devices are based on the fault currents 
and other conditions that will be detected  (be present) on the system when a fault occurs. The types of 
faults that can occur in a power systems (which may be intermittent ­temporary­ or permanent­
continuous) are: ssingle phase to ground (which is the most common, line to line, double line to ground 
and 3 phase fault. Another type of fault is an open onductor (which is equivalent t a blown fuse in one 
of the three phases of a circuit). The 3 phase induction motor can not tolerate this condition of single 
phasing without burning out (failing). Thus sensing the negative sequence current or voltage in this 
case is quite important to protect the motor from being damaged due to the presence of a single phase 
condition upstream the motor. The causes of faults in a power system are numerous, just to list a few: 
inslator breaking, dirt on the insulator, broken wire, a tree branch falling on the line, an animal short 
circutong a phase or more, frequent ocuurence of transient overvoltages (lightning or frequent 
switching), overvoltage conditions persisting for long periods, digging into cables, overloading cables 
for prolonged periods of time, bad quality of products and workmanships. Under short circuit 
conditions high magnitudes of current flows from the source to the fault (point of short circuit) 
stressing thermally and mechanicaslly all the components in its way (that it passes through). Thus, 
prompt detection and isolation of the specific faulty zone should be achieved. The resons being to 
maintain the supply of power to all zones that are outside the faulty section and also to maintain 
stability othe system (does not cause the synchronous generators on the system to run out of 
synchronizm­fall out of step). 
Examples showing how to use Excel and Quattro Pro to solve for the fault currents and bus voltages in  
a power system under the different fault conditions: 
  
Excel of Microsoft: 
1) Workbook Program: 
Private Sub Workbook_Deactivate() 
Application.CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Workbook_Activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "F&ault Calculations" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Radial systems calculations" 
ctrl1.TooltipText = "Radial systems" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Network systems calculations" 
ctrl2.TooltipText = "Network (Grid) systems" 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "&Basic calculations" 
ctrl3.TooltipText = "Fundamental operations" 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
End Sub 
2) Worksheet 1 (Radial systems calculations) program: 
Private Sub Worksheet_Deactivate() 
Application.CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Worksheet_activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Fault Calculations" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Radial systems calculations" 
ctrl1.TooltipText = "Radial systems" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Network systems calculations" 
ctrl2.TooltipText = "Network (Grid) systems" 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "&Basic calculations" 
ctrl3.TooltipText = "Fundamental operations" 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Radial systems" 
Set ctrl11 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl11.Caption = "&One bus system" 
ctrl11.TooltipText = "Radial systems" 
ctrl11.Style = msoButtonCaption 
With ctrl11 
    .OnAction = "MySub11" 
End With 
Set ctrl12 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl12.Caption = "&Two bus system" 
ctrl12.TooltipText = "Radial systems" 
ctrl12.Style = msoButtonCaption 
With ctrl12 
    .OnAction = "MySub12" 
End With 
Set ctrl13 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl13.Caption = "T&hree bus system" 
ctrl13.TooltipText = "Radial systems" 
ctrl13.Style = msoButtonCaption 
With ctrl13 
    .OnAction = "MySub13" 
End With 
Set ctrl14 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl14.Caption = "&Four bus system" 
ctrl14.TooltipText = "Radial systems" 
ctrl14.Style = msoButtonCaption 
With ctrl14 
    .OnAction = "MySub14" 
End With 
End Sub 
3) Worksheet 2 (Network systems calculations) program: 
Private Sub Worksheet_Deactivate() 
Application.CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Worksheet_activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Fault Calculations" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Radial systems calculations" 
ctrl1.TooltipText = "Radial systems" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Network systems calculations" 
ctrl2.TooltipText = "Network (Grid) systems" 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "&Basic calculations" 
ctrl3.TooltipText = "Fundamental operations" 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Network systems" 
Set ctrl21 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl21.Caption = "&Four bus system" 
ctrl21.TooltipText = "Network (grid) systems" 
ctrl21.Style = msoButtonCaption 
With ctrl21 
    .OnAction = "MySub21" 
End With 
Set ctrl22 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl22.Caption = "F&ive bus system" 
ctrl22.TooltipText = "Network (grid) systems" 
ctrl22.Style = msoButtonCaption 
With ctrl22 
    .OnAction = "MySub22" 
End With 
End Sub 
USER BOXES (DIALOG BOXES): 
1) User dialog box 1 (Radial systems, 1 bus): 
Private Sub CommandButton1_Click() 
TextBox1 = Range("z5") 
TextBox2 = Range("z6") 
TextBox3 = Range("z7") 
TextBox4 = Range("z8") 
TextBox5 = Range("z9") 
TextBox6 = Range("z10") 
TextBox7 = Range("z11") 
TextBox8 = Range("z12") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm1 
End Sub 
Private Sub Label2_Click() 
End Sub 
Private Sub Label7_Click() 
End Sub 
Private Sub TextBox5_Change() 
Range("b9") = TextBox5 
End Sub 
Private Sub TextBox6_Change() 
Range("b10") = TextBox6 
End Sub 
Private Sub TextBox7_Change() 
Range("b11") = TextBox7 
End Sub 
Private Sub TextBox8_Change() 
Range("b12") = TextBox8 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b5") 
TextBox2 = Range("b6") 
TextBox3 = Range("b7") 
TextBox4 = Range("b8") 
TextBox5 = Range("b9") 
TextBox6 = Range("b10") 
TextBox7 = Range("b11") 
TextBox8 = Range("b12") 
Range("z5") = Range("b5") 
Range("z6") = Range("b6") 
Range("z7") = Range("b7") 
Range("z8") = Range("b8") 
Range("z9") = Range("b9") 
Range("z10") = Range("b10") 
Range("z11") = Range("b11") 
Range("z12") = Range("b12") 
End Sub 
Private Sub TextBox1_Change() 
On Error GoTo errorhandler 
Range("b5") = TextBox1 
errorhandler: 
If Err.Number = 13 Then 
Range("b5") = InputBox("Enter a number, 0 or more") 
TextBox1 = Range("b5") 
Resume Next 
End If 
End Sub 
Private Sub TextBox2_Change() 
Range("b6") = (TextBox2) 
End Sub 
Private Sub TextBox3_Change() 
Range("b7") = (TextBox3) 
End Sub 
Private Sub TextBox4_Change() 
Range("b8") = (TextBox4) 
End Sub 
2) User form 2 (Radial syatems, 2 bus): 
Private Sub CommandButton1_Click() 
TextBox1 = Range("z20") 
TextBox2 = Range("z21") 
TextBox3 = Range("z22") 
TextBox4 = Range("z26") 
TextBox5 = Range("z27") 
TextBox6 = Range("z28") 
TextBox7 = Range("z29") 
TextBox8 = Range("z30") 
TextBox9 = Range("z23") 
TextBox10 = Range("z24") 
TextBox11 = Range("z25") 
TextBox12 = Range("z31") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm2 
End Sub 
Private Sub TextBox1_Change() 
On Error GoTo errorhandler 
Range("b20") = TextBox1 
errorhandler: 
If Err.Number = 13 Then 
Range("b20") = InputBox("Enter a number, 0 or more") 
TextBox1 = Range("b20") 
Resume Next 
End If 
End Sub 
Private Sub TextBox10_Change() 
Range("b24") = (TextBox10) 
End Sub 
Private Sub TextBox11_Change() 
Range("b25") = (TextBox11) 
End Sub 
Private Sub TextBox12_Change() 
Range("b31") = (TextBox12) 
End Sub 
Private Sub TextBox2_Change() 
Range("b21") = (TextBox2) 
End Sub 
Private Sub TextBox3_Change() 
Range("b22") = (TextBox3) 
End Sub 
Private Sub TextBox4_Change() 
Range("b26") = (TextBox4) 
End Sub 
Private Sub TextBox5_Change() 
Range("b27") = (TextBox5) 
End Sub 
Private Sub TextBox6_Change() 
Range("b28") = (TextBox6) 
End Sub 
Private Sub TextBox7_Change() 
Range("b29") = (TextBox7) 
End Sub 
Private Sub TextBox8_Change() 
Range("b30") = (TextBox8) 
End Sub 
Private Sub TextBox9_Change() 
Range("b23") = (TextBox9) 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b20") 
TextBox2 = Range("b21") 
TextBox3 = Range("b22") 
TextBox4 = Range("b26") 
TextBox5 = Range("b27") 
TextBox6 = Range("b28") 
TextBox7 = Range("b29") 
TextBox8 = Range("b30") 
TextBox9 = Range("b23") 
TextBox10 = Range("b24") 
TextBox11 = Range("b25") 
TextBox12 = Range("b31") 
 Range("z20") = Range("b20") 
 Range("z21") = Range("b21") 
 Range("z22") = Range("b22") 
 Range("z26") = Range("b26") 
 Range("z27") = Range("b27") 
 Range("z28") = Range("b28") 
 Range("z29") = Range("b29") 
 Range("z30") = Range("b30") 
 Range("z23") = Range("b23") 
 Range("z24") = Range("b24") 
 Range("z25") = Range("b25") 
 Range("z31") = Range("b31") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
3) User form (dialog box) 3 (Radial systems, 3 bus): 
Private Sub CommandButton1_Click() 
TextBox1 = Range("z48") 
TextBox2 = Range("z49") 
TextBox3 = Range("z50") 
TextBox4 = Range("z57") 
TextBox5 = Range("z58") 
TextBox6 = Range("z59") 
TextBox7 = Range("z60") 
TextBox8 = Range("z61") 
TextBox9 = Range("z51") 
TextBox10 = Range("z52") 
TextBox11 = Range("z53") 
TextBox12 = Range("z62") 
TextBox13 = Range("z54") 
TextBox14 = Range("z55") 
TextBox15 = Range("z56") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm3 
End Sub 
Private Sub TextBox1_Change() 
Range("b48") = (TextBox1) 
End Sub 
Private Sub TextBox10_Change() 
Range("b52") = (TextBox10) 
End Sub 
Private Sub TextBox11_Change() 
Range("b53") = (TextBox11) 
End Sub 
Private Sub TextBox12_Change() 
Range("b62") = (TextBox12) 
End Sub 
Private Sub TextBox13_Change() 
Range("b54") = (TextBox13) 
End Sub 
Private Sub TextBox14_Change() 
Range("b55") = (TextBox14) 
End Sub 
Private Sub TextBox15_Change() 
Range("b56") = (TextBox15) 
End Sub 
Private Sub TextBox2_Change() 
Range("b49") = (TextBox2) 
End Sub 
Private Sub TextBox3_Change() 
Range("b50") = (TextBox3) 
End Sub 
Private Sub TextBox4_Change() 
Range("b57") = (TextBox4) 
End Sub 
Private Sub TextBox5_Change() 
Range("b58") = (TextBox5) 
End Sub 
Private Sub TextBox6_Change() 
Range("b59") = (TextBox6) 
End Sub 
Private Sub TextBox7_Change() 
Range("b60") = (TextBox7) 
End Sub 
Private Sub TextBox8_Change() 
Range("b61") = (TextBox8) 
End Sub 
Private Sub TextBox9_Change() 
Range("b51") = (TextBox9) 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b48") 
TextBox2 = Range("b49") 
TextBox3 = Range("b50") 
TextBox4 = Range("b57") 
TextBox5 = Range("b58") 
TextBox6 = Range("b59") 
TextBox7 = Range("b60") 
TextBox8 = Range("b61") 
TextBox9 = Range("b51") 
TextBox10 = Range("b52") 
TextBox11 = Range("b53") 
TextBox12 = Range("b62") 
TextBox13 = Range("b54") 
TextBox14 = Range("b55") 
TextBox15 = Range("b56") 
 Range("z48") = Range("b48") 
 Range("z49") = Range("b49") 
 Range("z50") = Range("b50") 
 Range("z51") = Range("b51") 
 Range("z52") = Range("b52") 
 Range("z53") = Range("b53") 
 Range("z54") = Range("b54") 
 Range("z55") = Range("b55") 
 Range("z56") = Range("b56") 
 Range("z57") = Range("b57") 
 Range("z58") = Range("b58") 
 Range("z59") = Range("b59") 
 Range("z60") = Range("b60") 
 Range("z60") = Range("b61") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
4) User form 4 (Radial systems, 4 bus): 
Private Sub CommandButton1_Click() 
TextBox1 = Range("z86") 
TextBox2 = Range("z87") 
TextBox3 = Range("z88") 
TextBox4 = Range("z98") 
TextBox5 = Range("z99") 
TextBox6 = Range("z100") 
TextBox7 = Range("z101") 
TextBox8 = Range("z102") 
TextBox9 = Range("z89") 
TextBox10 = Range("z90") 
TextBox11 = Range("z91") 
TextBox12 = Range("z103") 
TextBox13 = Range("z92") 
TextBox14 = Range("z93") 
TextBox15 = Range("z94") 
TextBox16 = Range("z95") 
TextBox17 = Range("z96") 
TextBox18 = Range("z97") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm4 
End Sub 
Private Sub TextBox1_Change() 
Range("b86") = (TextBox1) 
End Sub 
Private Sub TextBox10_Change() 
Range("b90") = (TextBox10) 
End Sub 
Private Sub TextBox11_Change() 
Range("b91") = (TextBox11) 
End Sub 
Private Sub TextBox12_Change() 
Range("b103") = (TextBox12) 
End Sub 
Private Sub TextBox13_Change() 
Range("b92") = (TextBox13) 
End Sub 
Private Sub TextBox14_Change() 
Range("b93") = (TextBox14) 
End Sub 
Private Sub TextBox15_Change() 
Range("b94") = (TextBox15) 
End Sub 
Private Sub TextBox16_Change() 
Range("b95") = (TextBox16) 
End Sub 
Private Sub TextBox17_Change() 
Range("b96") = (TextBox17) 
End Sub 
Private Sub TextBox18_Change() 
Range("b97") = (TextBox18) 
End Sub 
Private Sub TextBox2_Change() 
Range("b87") = (TextBox2) 
End Sub 
Private Sub TextBox3_Change() 
Range("b88") = (TextBox3) 
End Sub 
Private Sub TextBox4_Change() 
Range("b98") = (TextBox4) 
End Sub 
Private Sub TextBox5_Change() 
Range("b99") = (TextBox5) 
End Sub 
Private Sub TextBox6_Change() 
Range("b100") = (TextBox6) 
End Sub 
Private Sub TextBox7_Change() 
Range("b101") = (TextBox7) 
End Sub 
Private Sub TextBox8_Change() 
Range("b102") = (TextBox8) 
End Sub 
Private Sub TextBox9_Change() 
Range("b89") = (TextBox9) 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b86") 
TextBox2 = Range("b87") 
TextBox3 = Range("b88") 
TextBox4 = Range("b98") 
TextBox5 = Range("b99") 
TextBox6 = Range("b100") 
TextBox7 = Range("b101") 
TextBox8 = Range("b102") 
TextBox9 = Range("b89") 
TextBox10 = Range("b90") 
TextBox11 = Range("b91") 
TextBox12 = Range("b103") 
TextBox13 = Range("b92") 
TextBox14 = Range("b93") 
TextBox15 = Range("b94") 
TextBox16 = Range("b95") 
TextBox17 = Range("b96") 
TextBox18 = Range("b97") 
 Range("z86") = Range("b86") 
 Range("z87") = Range("b87") 
 Range("z88") = Range("b88") 
 Range("z89") = Range("b89") 
 Range("z90") = Range("b90") 
 Range("z91") = Range("b91") 
 Range("z92") = Range("b92") 
 Range("z93") = Range("b93") 
 Range("z94") = Range("b94") 
 Range("z95") = Range("b95") 
 Range("z96") = Range("b96") 
 Range("z97") = Range("b97") 
 Range("z98") = Range("b98") 
 Range("z99") = Range("b99") 
 Range("z100") = Range("b100") 
 Range("z101") = Range("b101") 
 Range("z102") = Range("b102") 
 Range("z103") = Range("b103") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
5) User form 5 (Network systems, 4 bus): 
Private Sub CommandButton1_Click() 
TextBox1 = Range("b12") 
TextBox2 = Range("b13") 
TextBox3 = Range("b14") 
TextBox4 = Range("b15") 
TextBox5 = Range("b16") 
TextBox6 = Range("b17") 
TextBox7 = Range("b18") 
TextBox8 = Range("b19") 
TextBox9 = Range("b20") 
TextBox10 = Range("b21") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm5 
End Sub 
Private Sub TextBox1_Change() 
Range("b12") = (TextBox1) 
End Sub 
Private Sub TextBox10_Change() 
Range("b21") = (TextBox10) 
End Sub 
Private Sub TextBox2_Change() 
Range("b13") = (TextBox2) 
End Sub 
Private Sub TextBox3_Change() 
Range("b14") = (TextBox3) 
End Sub 
Private Sub TextBox4_Change() 
Range("b15") = (TextBox4) 
End Sub 
Private Sub TextBox5_Change() 
Range("b16") = (TextBox5) 
End Sub 
Private Sub TextBox6_Change() 
Range("b17") = (TextBox6) 
End Sub 
Private Sub TextBox7_Change() 
Range("b18") = (TextBox7) 
End Sub 
Private Sub TextBox8_Change() 
Range("b19") = (TextBox8) 
End Sub 
Private Sub TextBox9_Change() 
Range("b20") = (TextBox9) 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b12") 
TextBox2 = Range("b13") 
TextBox3 = Range("b14") 
TextBox4 = Range("b15") 
TextBox5 = Range("b16") 
TextBox6 = Range("b17") 
TextBox7 = Range("b18") 
TextBox8 = Range("b19") 
TextBox9 = Range("b20") 
TextBox10 = Range("b21") 
 Range("z12") = Range("b12") 
 Range("z13") = Range("b13") 
 Range("z14") = Range("b14") 
 Range("z15") = Range("b15") 
 Range("z16") = Range("b16") 
 Range("z17") = Range("b17") 
 Range("z18") = Range("b18") 
 Range("z19") = Range("b19") 
 Range("z20") = Range("b20") 
 Range("z21") = Range("b21") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
6) User form 6 (Network systems, 5 bus): 
Private Sub CommandButton1_Click() 
TextBox1 = Range("b38") 
TextBox2 = Range("b39") 
TextBox3 = Range("b40") 
TextBox4 = Range("b41") 
TextBox5 = Range("b42") 
TextBox6 = Range("b43") 
TextBox7 = Range("b44") 
TextBox8 = Range("b45") 
TextBox9 = Range("b47") 
TextBox10 = Range("b48") 
TextBox11 = Range("b46") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm6 
End Sub 
Private Sub TextBox1_Change() 
Range("b38") = (TextBox1) 
End Sub 
Private Sub TextBox10_Change() 
Range("b48") = (TextBox10) 
End Sub 
Private Sub TextBox11_Change() 
Range("b46") = (TextBox11) 
End Sub 
Private Sub TextBox2_Change() 
Range("b39") = (TextBox2) 
End Sub 
Private Sub TextBox3_Change() 
Range("b40") = (TextBox3) 
End Sub 
Private Sub TextBox4_Change() 
Range("b41") = (TextBox4) 
End Sub 
Private Sub TextBox5_Change() 
Range("b42") = (TextBox5) 
End Sub 
Private Sub TextBox6_Change() 
Range("b43") = (TextBox6) 
End Sub 
Private Sub TextBox7_Change() 
Range("b44") = (TextBox7) 
End Sub 
Private Sub TextBox8_Change() 
Range("b45") = (TextBox8) 
End Sub 
Private Sub TextBox9_Change() 
Range("b47") = (TextBox9) 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b38") 
TextBox2 = Range("b39") 
TextBox3 = Range("b40") 
TextBox4 = Range("b41") 
TextBox5 = Range("b42") 
TextBox6 = Range("b43") 
TextBox7 = Range("b44") 
TextBox8 = Range("b45") 
TextBox9 = Range("b47") 
TextBox10 = Range("b48") 
TextBox11 = Range("b46") 
 Range("z38") = Range("b38") 
 Range("z39") = Range("b39") 
 Range("z40") = Range("b40") 
 Range("z41") = Range("b41") 
 Range("z42") = Range("b42") 
 Range("z43") = Range("b43") 
 Range("z44") = Range("b44") 
 Range("z45") = Range("b45") 
 Range("z46") = Range("b46") 
 Range("z47") = Range("b47") 
 Range("z48") = Range("b48") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
Fault calculations for a single bus radial systems 
  
  
Positive sequence reactance: 0.25 
Negative sequence reactance: 0.35 
Zero sequence reactance:       0.1 
Prefault Voltage:                     1 
Type of fault: 1, 2, 3 or 4: 4 
Transformer neutral reactor: 0 
Generator reactor, if any: N/A 
Transfo. connection method: N/A 
The fault current in p.u.: 4 
  
Modules 
Sub MySub1() 
Worksheets("Radial Systems Calculations").Activate 
End Sub 
Note: When the variable ft in the following subroutines is equal 1, this means the fault is of the line to 
line, equal 2 is of the line to ground, equal 3 is of the double line to ground & 4 is of the 3­phase type. 
Sub MySub11() 
UserForm1.Show  'When this sub is chosen, it will display the user form (dialog box) on the screen. 
a001 = Range("b10") 
xx011 = Range("b5") 
xx012 = Range("b6") 
xx010 = Range("b7") 
x111 = xx011 'The positive sequence equivalent of the system under study is calculated. 
x112 = xx012 'The negative sequence equivalent of the system is calculated. 
x110 = xx010 + (3 * a001) 'The zero sequence equivalent is calculated including any grounding 
reactors. 
vf = Range("b8")  'The prefault voltage value as set by the user is placed in cell b8. 
ft = Range("b9") 'The type of fault (number) is placed in cell c9. 
If ft = 2 Then  'If the number for the fault type entered by the user = 2, then this if will be executed. 
ifault = 3 * (vf) / (x111 + x112 + x110)  'The fault current is calculated. 
End If 
If ft = 4 Then    'The statements under this if will be executed if the if condition is met. 
ifault = vf / x111 'The fault current is calculated 
End If 
If ft = 1 Then 
ifault1 = vf / (x111 + x112) 
ifault = 0.866 * 2 * ifault1 
End If 
If ft = 3 Then 
ifault1 = vf / (x111 + ((x112) * (x110) / (x112 + x110))) 
ifault2 = ((ifault1) * (x112)) / (x112 + x110) 
ifault = 3 * (ifault2) 
End If 
Range("b13") = ifault 'The calculated fault current is written to cell number b13 
Range("a13").Select  'The selector is placed in cell b13. 
End Sub 
Sub MySub12() 
UserForm2.Show 
xx011 = Range("b20") 
xx012 = Range("b21") 
xx010 = Range("b22") 
xx121 = Range("b23") 
xx122 = Range("b24") 
xx120 = Range("b25") 
x111 = xx011 + xx121 
x112 = xx012 + xx122 
y12 = xx011 
y122 = xx012 
b03 = Range("b30") 'This number corresponds to the transformer winding connection type. 
b02 = Range("b28") 'This is the transformer neutral grounding reactor. 
b01 = Range("b29") 'This is the generator neutral grounding reactor, if applicable 
vsense = Range("b31") 
If b03 = 2 Then 'The winding connection grounded wye/grounded wye corresponds to b03=2 
x110 = xx010 + xx120 + 3 * (b01 + b02) 
y120 = xx010 + 3 * (b01 + b02) 
End If 
If b03 = 1 Then 'This b03=1 corresponds to delta/grounded wye. 
x110 = xx120 + 3 * (b02) 
y120 = 0 
End If 
If b03 = 3 Then 'When b03=3, this means adelta/delta trnasormer winding connection. 
MsgBox Prompt:="zero sequence current has no path,i.e. Zo = infinity", Title:="Note,??????", 
Buttons:=vbOKOnly 
End If 
vf = Range("b26") 
ft = Range("b27") 
If (ft = 2 And b03 = 2) Then 
ifault = 3 * (vf) / (x111 + x112 + x110) 
If vsense = 1 Then  'This is the calculation for the voltage sensitivity. 
vs10 = ­y120 * (ifault / 3) 
vs11 = vf ­ (y12) * (ifault / 3) 
vs12 = ­(ifault / 3) * (y122) 
vsaf = vs10 + vs11 + vs12 
vsbr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsbi = (­0.866) * (vs11) + (0.866) * (vs12) 
vsbf = ((vsbr) ^ 2 + (vsbi) ^ 2) ^ 0.5 
vscr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsci = (0.866) * (vs11) + (­0.866) * (vs12) 
vscf = ((vscr) ^ 2 + (vsci) ^ 2) ^ 0.5 
Range("b36") = vs10 
Range("b37") = vs11 
Range("b38") = vs12 
Range("b39") = vsaf 
Range("b40") = vsbf 
Range("b41") = vscf 
End If 
End If 
If (ft = 2 And b03 = 1) Then 
ifault = 3 * (vf) / (x111 + x112 + x110) 
If vsense = 1 Then 
vs10 = ­y120 * (ifault / 3) 
vs11 = vf ­ (y12) * (ifault / 3) 
vs12 = ­(ifault / 3) * (y122) 
vsaf = vs10 + vs11 + vs12 
vsbr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsbi = ((­0.866) * (vs11)) + ((0.866) * (vs12)) 
vsbf = ((vsbr) ^ 2 + (vsbi) ^ 2) ^ 0.5 
vscr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsci = ((0.866) * (vs11)) + ((­0.866) * (vs12)) 
vscf = ((vscr) ^ 2 + (vsci) ^ 2) ^ 0.5 
Range("b36") = vs10 
Range("b37") = vs11 
Range("b38") = vs12 
Range("b39") = vsaf 
Range("b40") = vsbf 
Range("b41") = vscf 
End If 
End If 
If ft = 4 Then 
ifault = vf / x111 
If vsense = 1 Then 
xyz = (vf * (1 ­ y12 / x111)) 
Range("b34") = xyz 
End If 
End If 
If ft = 1 Then 
ifault1 = vf / (x111 + x112) 
ifault = 0.866 * 2 * ifault1 
End If 
If (ft = 3 And b03 = 2) Then 
ifault1 = vf / (x111 + ((x112) * (x110) / (x112 + x110))) 
ifault2 = ((ifault1) * (x112)) / (x112 + x110) 
ifault = 3 * (ifault2) 
End If 
If (ft = 3 And b03 = 1) Then 
ifault1 = vf / (x111 + ((x112) * (x110) / (x112 + x110))) 
ifault2 = ((ifault1) * (x112)) / (x112 + x110) 
ifault = 3 * (ifault2) 
End If 
Range("b32") = ifault 
Range("b32").Select 
'Print "fault current =; ifault   'In QuickBasic, this command prints the result to the screen 
'INPUT "Project Name: ", projnam$ 'Starting at this point (which is not applicable to this software 
package) the data 
'INPUT "Project Number: ", projnum$  ' entered by the user is used when the data file is created (or 
appended) and 
'INPUT "prepared by:", pb$   ' the required data is saved into it. It is shown for refernce and to those 
who are 
'INPUT "date:", da$   'familiar with QuickBasic programming language. As the spread sheet program 
Excel is used 
'INPUT "feeder no.: ", feedno$ 'to store the inputted data as well as the results,there is no need to create 
a data file to 
'INPUT "fault on bus no.:", busno$  ' hold such information. 
'INPUT "comments:", comment$ 
'INPUT "type of fault", typef$ 
'INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
If opap = 1 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Output As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
Print #1, "feeder no.: ", feedno$ 
Print #1, "fault on bus no.:", busno$ 
Print #1, "comments:", Comment$ 
Print #1, "type of fault", typef$ 
Print #1, "the equivalent sequence networks: positive, negative and zero:" 
Print #1, x111, x112, x110 
Print #1, "fault current in p.u.="; ifault 
If ft = 4 And vsense = 1 Then Print #1, "voltage on bus 1 at time of fault on bus 2 (in p.u.) = ", vf * (1 ­ 
y12 / x111) 
If ft = 2 And vsense = 1 Then Print #1, "voltage on bus 1, phases A,B,C ="; vsaf, vsbf, vscf 
Close #1 
End If 
If opap = 2 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Append As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
Print #1, "feeder no.: ", feedno$ 
Print #1, "fault on bus no.:", busno$ 
Print #1, "comments:", Comment$ 
Print #1, "type of fault", typef$ 
Print #1, "the equivalent sequence networks: positive, negative and zero:" 
Print #1, x111, x112, x110 
Print #1, "fault current in p.u.="; ifault 
If ft = 4 And vsense = 1 Then Print #1, "voltage on bus 1 at time of fault on bus 2 (in p.u.) = ", vf * (1 ­ 
y12 / x111) 
If ft = 2 And vsense = 1 Then Print #1, "voltage on bus 1, phases A,B,C ="; vsaf, vsbf, vscf 
Close #1 
End If 
End Sub 
Sub MySub13() 
UserForm3.Show 
xx011 = Range("b48") 
xx012 = Range("b49") 
xx010 = Range("b50") 
xx121 = Range("b51") 
xx122 = Range("b52") 
xx120 = Range("b53") 
xx231 = Range("b54") 
xx232 = Range("b55") 
xx230 = Range("b56") 
x111 = xx011 + xx121 + xx231 
x112 = xx012 + xx122 + xx232 
y13 = xx011 
y23 = xx011 + xx121 
y132 = xx012 
y232 = xx012 + xx122 
c03 = Range("b61") 
c02 = Range("b59") 
c01 = Range("b60") 
vsense = Range("b62") 
If c03 = 2 Then 
x110 = xx010 + xx120 + 3 * (c01 + c02) + xx230 
y130 = xx010 + 3 * (c01 + c02) 
y230 = xx010 + xx120 + 3 * (c01 + c02) 
End If 
If c03 = 1 Then 
x110 = xx120 + 3 * (c02) + xx230 
y130 = 0 
y230 = xx120 + 3 * (c02) 
End If 
If c03 = 3 Then 
MsgBox Prompt:="zero sequence current has no path,i.e. Zo = infinity", Title:="Note,??????", 
Buttons:=vbOKOnly 
End If 
vf = Range("b57") 
ft = Range("b58") 
If (ft = 2 And c03 = 2) Then 
ifault = 3 * (vf) / (x111 + x112 + x110) 
If vsense = 1 Then 
vs10 = ­y130 * (ifault / 3) 
vs11 = vf ­ (y13) * (ifault / 3) 
vs12 = ­(ifault / 3) * (y132) 
vsaf = vs10 + vs11 + vs12 
vsbr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsbi = (­0.866) * (vs11) + (0.866) * (vs12) 
vsbf = ((vsbr) ^ 2 + (vsbi) ^ 2) ^ 0.5 
vscr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsci = (0.866) * (vs11) + (­0.866) * (vs12) 
vscf = ((vscr) ^ 2 + (vsci) ^ 2) ^ 0.5 
vs210 = ­y230 * (ifault / 3) 
vs211 = vf ­ (y23) * (ifault / 3) 
vs212 = ­(ifault / 3) * (y232) 
vs2af = vs210 + vs211 + vs212 
vs2br = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2bi = (­0.866) * (vs211) + (0.866) * (vs212) 
vs2bf = ((vs2br) ^ 2 + (vs2bi) ^ 2) ^ 0.5 
vs2cr = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2ci = (0.866) * (vs211) + (­0.866) * (vs212) 
vs2cf = ((vs2cr) ^ 2 + (vs2ci) ^ 2) ^ 0.5 
 Range("b68") = vs10 
 Range("b69") = vs11 
 Range("b70") = vs12 
 Range("b71") = vsaf 
 Range("b72") = vsbf 
 Range("b73") = vscf 
 Range("b74") = vs210 
 Range("b75") = vs211 
 Range("b76") = vs212 
 Range("b77") = vs2af 
 Range("b78") = vs2bf 
 Range("b79") = vs2cf 
End If 
End If 
If (ft = 2 And c03 = 1) Then 
ifault = 3 * (vf) / (x111 + x112 + x110) 
If vsense = 1 Then 
vs10 = ­y130 * (ifault / 3) 
vs11 = vf ­ (y13) * (ifault / 3) 
vs12 = ­(ifault / 3) * (y132) 
vsaf = vs10 + vs11 + vs12 
vsbr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsbi = (­0.866) * (vs11) + (0.866) * (vs12) 
vsbf = ((vsbr) ^ 2 + (vsbi) ^ 2) ^ 0.5 
vscr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsci = (0.866) * (vs11) + (­0.866) * (vs12) 
vscf = ((vscr) ^ 2 + (vsci) ^ 2) ^ 0.5 
vs210 = ­y230 * (ifault / 3) 
vs211 = vf ­ (y23) * (ifault / 3) 
vs212 = ­(ifault / 3) * (y232) 
vs2af = vs210 + vs211 + vs212 
vs2br = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2bi = (­0.866) * (vs211) + (0.866) * (vs212) 
vs2bf = ((vs2br) ^ 2 + (vs2bi) ^ 2) ^ 0.5 
vs2cr = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2ci = (0.866) * (vs211) + (­0.866) * (vs212) 
vs2cf = ((vs2cr) ^ 2 + (vs2ci) ^ 2) ^ 0.5 
 Range("b68") = vs10 
 Range("b69") = vs11 
 Range("b70") = vs12 
 Range("b71") = vsaf 
 Range("b72") = vsbf 
 Range("b73") = vscf 
 Range("b74") = vs210 
 Range("b75") = vs211 
 Range("b76") = vs212 
 Range("b77") = vs2af 
 Range("b78") = vs2bf 
 Range("b79") = vs2cf 
End If 
End If 
If ft = 4 Then 
ifault = vf / x111 
If vsense = 1 Then 
Range("b65") = (vf * (1 ­ y13 / x111)) 
Range("b66") = (vf * (1 ­ y23 / x111)) 
End If 
End If 
If ft = 1 Then 
ifault1 = vf / (x111 + x112) 
ifault = 0.866 * 2 * ifault1 
End If 
If ft = 3 And c3 = 2 Then 
ifault1 = vf / (x111 + ((x112) * (x110) / (x112 + x110))) 
ifault2 = ((ifault1) * (x112)) / (x112 + x110) 
ifault = 3 * (ifault2) 
End If 
If ft = 3 And c3 = 1 Then 
ifault1 = vf / (x111 + ((x112) * (x110) / (x112 + x110))) 
ifault2 = ((ifault1) * (x112)) / (x112 + x110) 
ifault = 3 * (ifault2) 
End If 
Range("b63") = ifault 
Range("b63").Select 
'INPUT "Project Name: ", projnam$ 
'INPUT "Project Number: ", projnum$ 
'INPUT "prepared by:", pb$ 
'INPUT "date:", da$ 
'INPUT "feeder no.: ", feedno$ 
'INPUT "fault on bus no.:", busno$ 
'INPUT "comments:", comment$ 
'INPUT "type of fault", typef$ 
'INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
If opap = 1 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Output As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
Print #1, "feeder no.: ", feedno$ 
Print #1, "fault on bus no.:", busno$ 
Print #1, "comments:", Comment$ 
Print #1, "type of fault", typef$ 
Print #1, "the equivalent sequence networks: positive, negative and zero:" 
Print #1, x111, x112, x110 
Print #1, "fault current in p.u.="; ifault 
If ft = 4 And vsense = 1 Then 
Print #1, "voltage on bus 1 at time of fault on bus 3 (in p.u.) = ", vf * (1 ­ y13 / x111) 
Print #1, "voltage on bus 2 at time of fault on bus 3 (in p.u.) = ", vf * (1 ­ y23 / x111) 
End If 
If ft = 2 And vsense = 1 Then 
Print #1, "voltage on bus 1, phases A,B,C ="; vsaf, vsbf, vscf 
Print #1, "voltage on bus 2, phases A,B,C ="; vs2af, vs2bf, vs2cf 
End If 
Close #1 
End If 
If opap = 2 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Append As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
Print #1, "feeder no.: ", feedno$ 
Print #1, "fault on bus no.:", busno$ 
Print #1, "comments:", Comment$ 
Print #1, "type of fault", typef$ 
Print #1, "the equivalent sequence networks: positive, negative and zero:" 
Print #1, x111, x112, x110 
Print #1, "fault current in p.u.="; ifault 
If ft = 4 And vsense = 1 Then 
Print #1, "voltage on bus 1 at time of fault on bus 3 (in p.u.) = ", vf * (1 ­ y13 / x111) 
Print #1, "voltage on bus 2 at time of fault on bus 3 (in p.u.) = ", vf * (1 ­ y23 / x111) 
End If 
If ft = 2 And vsense = 1 Then 
Print #1, "voltage on bus 1, phases A,B,C ="; vsaf, vsbf, vscf 
Print #1, "voltage on bus 2, phases A,B,C ="; vs2af, vs2bf, vs2cf 
End If 
Close #1 
End If 
End Sub 
Sub MySub14() 
UserForm4.Show 
'INPUT "positive sequence reactance between node 0 and bus 1 in p.u.="; xx011, this is the prompt and 
the variable 'value to be inputted by the user when using the program as written using QuickBasic & 
operating under DOS. 
'INPUT "negative sequence reactance between node 0 and bus 1 in p.u.="; xx012 
'INPUT "zero sequence reactance between node 0 and bus 1 in p.u.="; xx010 
'INPUT "positive sequence reactance between bus 1 and bus 2 in p.u.="; xx121 
'INPUT "negative sequence reactance between bus 1 and bus 2 in p.u.="; xx122 
'INPUT "zero sequence reactance between bus 1 and bus 2 in p.u.="; xx120 
'INPUT "positive sequence reactance between bus 2 and bus 3 in p.u.="; xx231 
'INPUT "negative sequence reactance between bus 2 and bus 3 in p.u.="; xx232 
'INPUT "zero sequence reactance between bus 2 and bus 3 in p.u.="; xx230 
'INPUT "positive sequence reactance between bus 3 and bus 4 in p.u.="; xx341 
'INPUT "negative sequence reactance between bus 3 and bus 4 in p.u.="; xx342 
'INPUT "zero sequence reactance between bus 3 and bus 4 in p.u.="; xx340 
xx011 = Range("b86") 'Using Excel, the value of the variable x011 is enterd into cell b86. 
xx012 = Range("b82") 
xx010 = Range("b88") 
xx121 = Range("b89") 
xx122 = Range("b90") 
xx120 = Range("b91") 
xx231 = Range("b92") 
xx232 = Range("b93") 
xx230 = Range("b94") 
xx341 = Range("b95") 
xx342 = Range("b96") 
xx340 = Range("b97") 
x111 = xx011 + xx121 + xx231 + xx341 
x112 = xx012 + xx122 + xx232 + xx342 
y14 = xx011 
y24 = xx011 + xx121 
y34 = xx011 + xx121 + xx231 
y142 = xx012 
y242 = xx012 + xx122 
y342 = xx012 + xx122 + xx232 
d3 = Range("b102") 
d2 = Range("b100") 
d1 = Range("b101") 
If d3 = 2 Then 
x110 = xx010 + xx120 + 3 * (d1 + d2) + xx230 + xx340 
y140 = xx010 + 3 * (d1 + d2) 
y240 = xx010 + xx120 + 3 * (d1 + d2) 
y340 = xx010 + xx120 + xx230 + 3 * (d1 + d2) 
End If 
If d3 = 1 Then 
x110 = xx120 + 3 * (d2) + xx230 + xx340 
y140 = 0 
y240 = xx120 + 3 * (d2) 
y340 = xx120 + xx230 + 3 * (d2) 
End If 
If d3 = 3 Then 
MsgBox Prompt:="zero sequence current has no path,i.e. Zo = infinity", Title:="Note,??????", 
Buttons:=vbOKOnly 
End If 
'Print "positive sequence reactance = "; x111 
'Print "negative sequence reactance = "; x112 
'Print "zero sequence reactance = "; x110 
vf = Range("b98") 
ft = Range("b99") 
vsense = Range("b103") 
If ft = 2 And d3 = 2 Then 
ifault = 3 * (vf) / (x111 + x112 + x110) 
If vsense = 1 Then 
vs10 = ­y140 * (ifault / 3) 
vs11 = vf ­ (y14) * (ifault / 3) 
vs12 = ­(ifault / 3) * (y142) 
vsaf = vs10 + vs11 + vs12 
vsbr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsbi = (­0.866) * (vs11) + (0.866) * (vs12) 
vsbf = ((vsbr) ^ 2 + (vsbi) ^ 2) ^ 0.5 
vscr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsci = (0.866) * (vs11) + (­0.866) * (vs12) 
vscf = ((vscr) ^ 2 + (vsci) ^ 2) ^ 0.5 
vs210 = ­y240 * (ifault / 3) 
vs211 = vf ­ (y24) * (ifault / 3) 
vs212 = ­(ifault / 3) * (y242) 
vs2af = vs210 + vs211 + vs212 
vs2br = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2bi = (­0.866) * (vs211) + (0.866) * (vs212) 
vs2bf = ((vs2br) ^ 2 + (vs2bi) ^ 2) ^ 0.5 
vs2cr = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2ci = (0.866) * (vs211) + (­0.866) * (vs212) 
vs2cf = ((vs2cr) ^ 2 + (vs2ci) ^ 2) ^ 0.5 
vs310 = ­y340 * (ifault / 3) 
vs311 = vf ­ (y34) * (ifault / 3) 
vs312 = ­(ifault / 3) * (y342) 
vs3af = vs310 + vs311 + vs312 
vs3br = vs310 + (­0.5) * (vs311) + (­0.5) * (vs312) 
vs3bi = (­0.866) * (vs311) + (0.866) * (vs312) 
vs3bf = ((vs3br) ^ 2 + (vs3bi) ^ 2) ^ 0.5 
vs3cr = vs310 + (­0.5) * (vs311) + (­0.5) * (vs312) 
vs3ci = (0.866) * (vs311) + (­0.866) * (vs312) 
vs3cf = ((vs3cr) ^ 2 + (vs3ci) ^ 2) ^ 0.5 
 Range("b110") = vs10 
 Range("b111") = vs11 
 Range("b112") = vs12 
 Range("b113") = vsaf 
 Range("b114") = vsbf 
 Range("b115") = vscf 
 Range("b116") = vs210 
 Range("b117") = vs211 
 Range("b118") = vs212 
 Range("b119") = vs2af 
 Range("b120") = vs2bf 
 Range("b121") = vs2cf 
 Range("b122") = vs310 
 Range("b123") = vs311 
 Range("b124") = vs312 
 Range("b125") = vs3af 
 Range("b126") = vs3bf 
 Range("b127") = vs3cf 
End If 
End If 
If ft = 2 And d3 = 1 Then 
ifault = 3 * (vf) / (x111 + x112 + x110) 
If vsense = 1 Then 
vs10 = ­y140 * (ifault / 3) 
vs11 = vf ­ (y14) * (ifault / 3) 
vs12 = ­(ifault / 3) * (y142) 
vsaf = vs10 + vs11 + vs12 
vsbr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsbi = (­0.866) * (vs11) + (0.866) * (vs12) 
vsbf = ((vsbr) ^ 2 + (vsbi) ^ 2) ^ 0.5 
vscr = vs10 + (­0.5) * (vs11) + (­0.5) * (vs12) 
vsci = (0.866) * (vs11) + (­0.866) * (vs12) 
vscf = ((vscr) ^ 2 + (vsci) ^ 2) ^ 0.5 
vs210 = ­y240 * (ifault / 3) 
vs211 = vf ­ (y24) * (ifault / 3) 
vs212 = ­(ifault / 3) * (y242) 
vs2af = vs210 + vs211 + vs212 
vs2br = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2bi = (­0.866) * (vs211) + (0.866) * (vs212) 
vs2bf = ((vs2br) ^ 2 + (vs2bi) ^ 2) ^ 0.5 
vs2cr = vs210 + (­0.5) * (vs211) + (­0.5) * (vs212) 
vs2ci = (0.866) * (vs211) + (­0.866) * (vs212) 
vs2cf = ((vs2cr) ^ 2 + (vs2ci) ^ 2) ^ 0.5 
vs310 = ­y340 * (ifault / 3) 
vs311 = vf ­ (y34) * (ifault / 3) 
vs312 = ­(ifault / 3) * (y342) 
vs3af = vs310 + vs311 + vs312 
vs3br = vs310 + (­0.5) * (vs311) + (­0.5) * (vs312) 
vs3bi = (­0.866) * (vs311) + (0.866) * (vs312) 
vs3bf = ((vs3br) ^ 2 + (vs3bi) ^ 2) ^ 0.5 
vs3cr = vs310 + (­0.5) * (vs311) + (­0.5) * (vs312) 
vs3ci = (0.866) * (vs311) + (­0.866) * (vs312) 
vs3cf = ((vs3cr) ^ 2 + (vs3ci) ^ 2) ^ 0.5 
 Range("b110") = vs10 
 Range("b111") = vs11 
 Range("b112") = vs12 
 Range("b113") = vsaf 
 Range("b114") = vsbf 
 Range("b115") = vscf 
 Range("b116") = vs210 
 Range("b117") = vs211 
 Range("b118") = vs212 
 Range("b119") = vs2af 
 Range("b120") = vs2bf 
 Range("b121") = vs2cf 
 Range("b122") = vs310 
 Range("b123") = vs311 
 Range("b124") = vs312 
 Range("b125") = vs3af 
 Range("b126") = vs3bf 
 Range("b127") = vs3cf 
End If 
End If 
If ft = 4 Then 
ifault = vf / x111 
If vsense = 1 Then 
Range("b106") = (vf * (1 ­ y14 / x111)) 
Range("b107") = (vf * (1 ­ y24 / x111)) 
Range("b108") = (vf * (1 ­ y34 / x111)) 
End If 
End If 
If ft = 1 Then 
ifault1 = vf / (x111 + x112) 
ifault = 0.866 * 2 * ifault1 
End If 
If ft = 3 And d3 = 2 Then 
ifault1 = vf / (x111 + ((x112) * (x110) / (x112 + x110))) 
ifault2 = ((ifault1) * (x112)) / (x112 + x110) 
ifault = 3 * (ifault2) 
End If 
If ft = 3 And d3 = 1 Then 
ifault1 = vf / (x111 + ((x112) * (x110) / (x112 + x110))) 
ifault2 = ((ifault1) * (x112)) / (x112 + x110) 
ifault = 3 * (ifault2) 
End If 
Range("b104") = ifault 
Range("b104").Select 
'Print "fault current ="; ifault 
'INPUT "Project Name: ", projnam$ 
'INPUT "Project Number: ", projnum$ 
'INPUT "prepared by:", pb$ 
'INPUT "date:", da$ 
'INPUT "feeder no.: ", feedno$ 
'INPUT "fault on bus no.:", busno$ 
'INPUT "comments:", comment$ 
'INPUT "type of fault", typef$ 
'INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
If opap = 1 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Output As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
Print #1, "feeder no.: ", feedno$ 
Print #1, "fault on bus no.:", busno$ 
Print #1, "comments:", Comment$ 
Print #1, "type of fault", typef$ 
Print #1, "the equivalent sequence networks: positive, negative and zero:" 
Print #1, x111, x112, x110 
Print #1, "fault current ="; ifault 
If ft = 4 And vsense = 1 Then 
Print #1, "voltage on bus 1 at time of fault on bus 4 (in p.u.) = ", vf * (1 ­ y14 / x111) 
Print #1, "voltage on bus 2 at time of fault on bus 4 (in p.u.) = ", vf * (1 ­ y24 / x111) 
Print #1, "voltage on bus 3 at time of fault on bus 4 (in p.u.) = ", vf * (1 ­ y34 / x111) 
End If 
If ft = 2 And vsense = 1 Then 
Print #1, "voltage on bus 1, phases A,B,C ="; vsaf, vsbf, vscf 
Print #1, "voltage on bus 2, phases A,B,C ="; vs2af, vs2bf, vs2cf 
Print #1, "voltage on bus 3, phases A,B,C ="; vs3af; vs3bf, vs3cf 
End If 
Close #1 
End If 
If opap = 2 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Append As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
Print #1, "feeder no.: ", feedno$ 
Print #1, "fault on bus no.:", busno$ 
Print #1, "comments:", Comment$ 
Print #1, "type of fault", typef$ 
Print #1, "the equivalent sequence networks: positive, negative and zero:" 
Print #1, x111, x112, x110 
Print #1, "fault current ="; ifault 
If ft = 4 And vsense = 1 Then 
Print #1, "voltage on bus 1 at time of fault on bus 4 (in p.u.) = ", vf * (1 ­ y14 / x111) 
Print #1, "voltage on bus 2 at time of fault on bus 4 (in p.u.) = ", vf * (1 ­ y24 / x111) 
Print #1, "voltage on bus 3 at time of fault on bus 4 (in p.u.) = ", vf * (1 ­ y34 / x111) 
End If 
If ft = 2 And vsense = 1 Then 
Print #1, "voltage on bus 1, phases A,B,C ="; vsaf, vsbf, vscf 
Print #1, "voltage on bus 2, phases A,B,C ="; vs2af, vs2bf, vs2cf 
Print #1, "voltage on bus 3, phases A,B,C ="; vs3af; vs3bf, vs3cf 
End If 
Close #1 
End If 
End Sub 
  
Sub MySub2() 
Worksheets("Network Systems Calculations").Activate 
End Sub 
Sheet 2 (Network systems fault calculations, 4­bus): 
Sub MySub21() 
UserForm5.Show 
x01 = Range("b12") 
x02 = Range("b13") 
x03 = Range("b14") 
xx12 = Range("b15") 
xx21 = Range("b15") 
xx23 = Range("b16") 
xx32 = Range("b16") 
xx34 = Range("b17") 
xx43 = Range("b17") 
xx14 = Range("b18") 
xx41 = Range("b18") 
xx24 = Range("b19") 
xx42 = Range("b19") 
bn = Range("b20") 
vf = Range("b21") 
x11 = x01 
x12 = x11 
x21 = x12 
x22 = x01 + xx12 
x11 = x01 
x12 = x11 
x21 = x12 
x22 = x01 + xx12 
If x02 > 0 Then 
x11p = x11 
x12p = x12 
x21p = x21 
x22p = x22 
xp1 = x21 
xp2 = x22 
xpp = x02 + x22 
x1p = x12 
x2p = x22 
x111 = x11p ­ ((x1p) * (xp1) / (xpp)) 
x121 = x12p ­ ((x1p) * (xp2) / (xpp)) 
x211 = x21p ­ ((x2p) * (xp1) / (xpp)) 
x221 = x22p ­ ((x2p) * (xp2) / (xpp)) 
x131 = x121 
x231 = x221 
x311 = x211 
x321 = x221 
x331 = x221 + xx23 
Else 
x31 = x21 
x32 = x22 
x33 = xx23 + x22 
x13 = x12 
x23 = x22 
End If 
If (x111 = 0 And x221 = 0) Then 
x11b = x11 
x12b = x12 
x13b = x13 
x21b = x21 
x22b = x22 
x23b = x23 
x31b = x31 
x32b = x32 
x33b = x33 
Else 
x11b = x111 
x12b = x121 
x13b = x131 
x21b = x211 
x22b = x221 
x23b = x231 
x31b = x311 
x32b = x321 
x33b = x331 
End If 
If x03 > 0 Then 
x11p1 = x11b 
x12p1 = x12b 
x13p1 = x13b 
x21p1 = x21b 
x22p1 = x22b 
x23p1 = x23b 
x31p1 = x31b 
x32p1 = x32b 
x33p1 = x33b 
xp12 = x31b 
xp22 = x32b 
xp32 = x33b 
xpp1 = x03 + x33b 
x1p2 = x13b 
x2p2 = x23b 
x3p2 = x33b 
x112 = x11p1 ­ ((x1p2) * (xp12) / (xpp1)) 
x122 = x12p1 ­ ((x1p2) * (xp22) / (xpp1)) 
x132 = x13p1 ­ ((x1p2) * (xp32) / (xpp1)) 
x212 = x21p1 ­ ((x2p2) * (xp12) / (xpp1)) 
x222 = x22p1 ­ ((x2p2) * (xp22) / (xpp1)) 
x232 = x23p1 ­ ((x2p2) * (xp32) / (xpp1)) 
x312 = x31p1 ­ ((x3p2) * (xp12) / (xpp1)) 
x322 = x32p1 ­ ((x3p2) * (xp22) / (xpp1)) 
x332 = x33p1 ­ ((x3p2) * (xp32) / (xpp1)) 
x142 = x132 
x242 = x232 
x342 = x332 
x412 = x312 
x422 = x322 
x432 = x332 
x442 = x332 + xx34 
Else 
x11d = x11 
x12d = x12 
x13d = x13 
x14d = x13 
x21d = x21 
x22d = x22 
x23d = x23 
x24d = x23 
x31d = x31 
x32d = x32 
x33d = x33 
x34d = x33 
x41d = x31 
x42d = x32 
x43d = x33 
x44d = x33 + xx34 
End If 
If (xx42 > 0 And x03 > 0) Then 
x1p3 = x122 ­ x142 
x2p3 = x222 ­ x242 
x3p3 = x322 ­ x342 
x4p3 = x422 ­ x442 
xp13 = x1p3 
xp23 = x2p3 
xp33 = x3p3 
xp43 = x4p3 
xpp3 = x222 + x442 ­ 2 * (x242) + xx42 
x11f = x112 ­ (x1p3) * (xp13) / (xpp3) 
x12f = x122 ­ (x1p3) * (xp23) / (xpp3) 
x13f = x132 ­ (x1p3) * (xp33) / (xpp3) 
x14f = x142 ­ (x1p3) * (xp43) / (xpp3) 
x21f = x212 ­ (x2p3) * (xp13) / (xpp3) 
x22f = x222 ­ (x2p3) * (xp23) / (xpp3) 
x23f = x232 ­ (x2p3) * (xp33) / (xpp3) 
x24f = x242 ­ (x2p3) * (xp43) / (xpp3) 
x31f = x312 ­ (x3p3) * (xp13) / (xpp3) 
x32f = x322 ­ (x3p3) * (xp23) / (xpp3) 
x33f = x332 ­ (x3p3) * (xp33) / (xpp3) 
x34f = x342 ­ (x3p3) * (xp43) / (xpp3) 
x41f = x412 ­ (x4p3) * (xp13) / (xpp3) 
x42f = x422 ­ (x4p3) * (xp23) / (xpp3) 
x43f = x432 ­ (x4p3) * (xp33) / (xpp3) 
x44f = x442 ­ (x4p3) * (xp43) / (xpp3) 
End If 
If (xx42 > 0 And x03 = 0) Then 
x1p3 = x12d ­ x14d 
x2p3 = x22d ­ x24d 
x3p3 = x32d ­ x34d 
x4p3 = x42d ­ x44d 
xp13 = x1p3 
xp23 = x2p3 
xp33 = x3p3 
xp43 = x4p3 
xpp3 = x22d + x44d ­ 2 * (x24d) + xx42 
x11f = x11d ­ (x1p3) * (xp13) / (xpp3) 
x12f = x12d ­ (x1p3) * (xp23) / (xpp3) 
x13f = x13d ­ (x1p3) * (xp33) / (xpp3) 
x14f = x14d ­ (x1p3) * (xp43) / (xpp3) 
x21f = x21d ­ (x2p3) * (xp13) / (xpp3) 
x22f = x22d ­ (x2p3) * (xp23) / (xpp3) 
x23f = x23d ­ (x2p3) * (xp33) / (xpp3) 
x24f = x24d ­ (x2p3) * (xp43) / (xpp3) 
x31f = x31d ­ (x3p3) * (xp13) / (xpp3) 
x32f = x32d ­ (x3p3) * (xp23) / (xpp3) 
x33f = x33d ­ (x3p3) * (xp33) / (xpp3) 
x34f = x34d ­ (x3p3) * (xp43) / (xpp3) 
x41f = x41d ­ (x4p3) * (xp13) / (xpp3) 
x42f = x42d ­ (x4p3) * (xp23) / (xpp3) 
x43f = x43d ­ (x4p3) * (xp33) / (xpp3) 
x44f = x44d ­ (x4p3) * (xp43) / (xpp3) 
End If 
If xx41 > 0 Then 
x1p4 = x11f ­ x14f 
x2p4 = x21f ­ x24f 
x3p4 = x31f ­ x34f 
x4p4 = x41f ­ x44f 
xp14 = x1p4 
xp24 = x2p4 
xp34 = x3p4 
xp44 = x4p4 
xpp4 = x11f + x44f ­ 2 * (x14f) + xx41 
x11f1 = x11f ­ (x1p4) * (xp14) / (xpp4) 
x12f1 = x12f ­ (x1p4) * (xp24) / (xpp4) 
x13f1 = x13f ­ (x1p4) * (xp34) / (xpp4) 
x14f1 = x14f ­ (x1p4) * (xp44) / (xpp4) 
x21f1 = x21f ­ (x2p4) * (xp14) / (xpp4) 
x22f1 = x22f ­ (x2p4) * (xp24) / (xpp4) 
x23f1 = x23f ­ (x2p4) * (xp34) / (xpp4) 
x24f1 = x24f ­ (x2p4) * (xp44) / (xpp4) 
x31f1 = x31f ­ (x3p4) * (xp14) / (xpp4) 
x32f1 = x32f ­ (x3p4) * (xp24) / (xpp4) 
x33f1 = x33f ­ (x3p4) * (xp34) / (xpp4) 
x34f1 = x34f ­ (x3p4) * (xp44) / (xpp4) 
x41f1 = x41f ­ (x4p4) * (xp14) / (xpp4) 
x42f1 = x42f ­ (x4p4) * (xp24) / (xpp4) 
x43f1 = x43f ­ (x4p4) * (xp34) / (xpp4) 
x44f1 = x44f ­ (x4p4) * (xp44) / (xpp4) 
End If 
If xx41 = 0 Then 
Debug.Print x11f, x12f, x13f, x14f 
Debug.Print x21f, x22f, x23f, x24f 
Debug.Print x31f, x32f, x33f, x34f 
Debug.Print x41f, x42f, x43f, x44f 
xxc11 = x11f 
xxc12 = x12f 
xxc13 = x13f 
xxc14 = x14f 
xxc21 = x21f 
xxc22 = x22f 
xxc23 = x23f 
xxc24 = x24f 
xxc31 = x31f 
xxc32 = x32f 
xxc33 = x33f 
xxc34 = x34f 
xxc41 = x41f 
xxc42 = x42f 
xxc43 = x43f 
xxc44 = x44f 
Range("d16") = x11f 
Range("d17") = x12f 
Range("d18") = x13f 
Range("d19") = x14f 
Range("d20") = x21f 
Range("d21") = x22f 
Range("d22") = x23f 
Range("d23") = x24f 
Range("d24") = x31f 
Range("d25") = x32f 
Range("d26") = x33f 
Range("d27") = x34f 
Range("d28") = x41f 
Range("d29") = x42f 
Range("d30") = x43f 
Range("d31") = x44f 
Else 
xxc11 = x11f1 
xxc12 = x12f1 
xxc13 = x13f1 
xxc14 = x14f1 
xxc21 = x21f1 
xxc22 = x22f1 
xxc23 = x23f1 
xxc24 = x24f1 
xxc31 = x31f1 
xxc32 = x32f1 
xxc33 = x33f1 
xxc34 = x34f1 
xxc41 = x41f1 
xxc42 = x42f1 
xxc43 = x43f1 
xxc44 = x44f1 
End If 
If bn = 1 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc11 
Range("b22") = vf / xxc11 
End If 
If bn = 1 Then 
'Print "voltage on buses 2,3,4 respectively are in p.u.="; (vf ­ (xxc12 / xxc11)), (vf ­ (xxc13 / xxc11)), 
(vf ­ (xxc14 / xxc11)) 
Range("a23") = "voltage on bus 2" 
Range("b23") = (vf ­ (xxc12 / xxc11)) 
Range("a24") = "voltage on bus 3" 
Range("b24") = (vf ­ (xxc13 / xxc11)) 
Range("a25") = "voltage on bus 4" 
Range("b25") = (vf ­ (xxc14 / xxc11)) 
End If 
If bn = 2 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc22 
Range("b22") = vf / xxc22 
End If 
If bn = 2 Then 
'Print "voltage on buses 1,3,4 respectively are in p.u.="; (vf ­ (xxc12 / xxc22)), (vf ­ (xxc23 / xxc22)), 
(vf ­ (xxc24 / xxc22)) 
Range("a23") = "voltage on bus 1" 
Range("b23") = (vf ­ (xxc12 / xxc22)) 
Range("a24") = "voltage on bus 3" 
Range("b24") = (vf ­ (xxc23 / xxc22)) 
Range("a25") = "voltage on bus 4" 
Range("b25") = (vf ­ (xxc24 / xxc22)) 
End If 
If bn = 3 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc33 
Range("b22") = vf / xxc33 
End If 
If bn = 3 Then 
'Print "voltage on buses 1,2,4 respectively are in p.u.="; (vf ­ (xxc13 / xxc33)), (vf ­ (xxc32 / xxc33)), 
(vf ­ (xxc34 / xxc33)) 
Range("a23") = "voltage on bus 1" 
Range("b23") = (vf ­ (xxc13 / xxc33)) 
Range("a24") = "voltage on bus 2" 
Range("b24") = (vf ­ (xxc32 / xxc33)) 
Range("a25") = "voltage on bus 4" 
Range("b25") = (vf ­ (xxc34 / xxc33)) 
End If 
If bn = 4 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc44 
Range("b22") = vf / xxc44 
End If 
If bn = 4 Then 
'Print "voltage on buses 1,2,3 respectively are in p.u.="; (vf ­ (xxc14 / xxc44)), (vf ­ (xxc24 / xxc44)), 
(vf ­ (xxc34 / xxc44)) 
Range("a23") = "voltage on bus 1" 
Range("b23") = (vf ­ (xxc14 / xxc44)) 
Range("a24") = "voltage on bus 2" 
Range("b24") = (vf ­ (xxc24 / xxc44)) 
Range("a25") = "voltage on bus 3" 
Range("b25") = (vf ­ (xxc34 / xxc44)) 
End If 
'INPUT "Project Name:"; projnam$ 
'INPUT "Prepared By: "; pb$ 
'INPUT "Project Number:"; projnum$ 
'INPUT "Date: "; da$ 
'INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
If opap = 1 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Output As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
If bn = 1 Then Print #1, "3 phase fault at bus 1 s.c.c. in p.u. =­j"; vf / xxc11, "voltage on buses 2,3,4 
respectively are in p.u.="; (vf ­ (xxc12 / xxc11)), (vf ­ (xxc13 / xxc11)), (vf ­ (xxc14 / xxc11)) 
If bn = 2 Then Print #1, "3 phase fault at bus 2 s.c.c. in p.u. =­j"; vf / xxc22; "voltage on buses 1,3,4 
respectively are in p.u.="; (vf ­ (xxc12 / xxc22)), (vf ­ (xxc23 / xxc22)), (vf ­ (xxc24 / xxc22)) 
If bn = 3 Then Print #1, "3 phase fault at bus 3 s.c.c. in p.u. =­j"; vf / xxc33, "voltage on buses 1,2,4 
respectively are in p.u.="; (vf ­ (xxc13 / xxc33)), (vf ­ (xxc32 / xxc33)), (vf ­ (xxc34 / xxc33)) 
If bn = 4 Then Print #1, "3 phase fault at bus 4 s.c.c. in p.u. =­j"; vf / xxc44, "voltage on buses 1,2,3 
respectively are in p.u.="; (vf ­ (xxc14 / xxc44)), (vf ­ (xxc24 / xxc44)), (vf ­ (xxc34 / xxc44)) 
Close #1 
End If 
If opap = 2 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Append As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
If bn = 1 Then Print #1, "3 phase fault at bus 1 s.c.c. in p.u. =­j"; vf / xxc11, "voltage on buses 2,3,4 
respectively are in p.u.="; (vf ­ (xxc12 / xxc11)), (vf ­ (xxc13 / xxc11)), (vf ­ (xxc14 / xxc11)) 
If bn = 2 Then Print #1, "3 phase fault at bus 2 s.c.c. in p.u. =­j"; vf / xxc22; "voltage on buses 1,3,4 
respectively are in p.u.="; (vf ­ (xxc12 / xxc22)), (vf ­ (xxc23 / xxc22)), (vf ­ (xxc24 / xxc22)) 
If bn = 3 Then Print #1, "3 phase fault at bus 3 s.c.c. in p.u. =­j"; vf / xxc33, "voltage on buses 1,2,4 
respectively are in p.u.="; (vf ­ (xxc13 / xxc33)), (vf ­ (xxc32 / xxc33)), (vf ­ (xxc34 / xxc33)) 
If bn = 4 Then Print #1, "3 phase fault at bus 4 s.c.c. in p.u. =­j"; vf / xxc44, "voltage on buses 1,2,3 
respectively are in p.u.="; (vf ­ (xxc14 / xxc44)), (vf ­ (xxc24 / xxc44)), (vf ­ (xxc34 / xxc44)) 
Close #1 
End If 
End Sub 
  
  
  
  
  
  
  
  
  
Sub MySub22() 
'DECLARE SUB d (b1!, b2!, b3!, b4!, b5!, b6!, b7!, b8!, b9!, b10!, b11!, b12!, b13!, b14!, b15!, b16!, 
b17!, b18!, b19!, b20!, b21!, b22!, b23!, b24!, b25!, b26!) 
'DECLARE SUB c (a1!, a2!, a3!, a4!, a5!, a6!, a7!, a8!, a9!, a10!, a11!, a12!, a13!, a14!, a15!, a16!, 
a17!, a18!, a19!, a20!, a21!, a22!, a23!, a24!, a25!, a26!) 
'DECLARE SUB b (x11b, x12b, x13b, x21b, x22b, x23b, x31b, x32b, x33b, x03, xx34, xx45) 
'DECLARE SUB a (x11, x12, x21, x22, x02, xx23) 
'COMMON SHARED x111, x121, x131, x211, x221, x231, x311, x321, x331 
'COMMON SHARED x112, x122, x132, x142, x212, x222, x232, x242, x312, x322, x332, x342, x412, 
x422, x432, x442, x51, x52, x53, x54, x55, x15, x25, x35, x45 
'COMMON SHARED x11f, x12f, x13f, x14f, x15f, x21f, x22f, x23f, x24f, x25f, x31f, x32f, x33f, x34f, 
x35f, x41f, x42f, x43f, x44f, x45f, x51f, x52f, x53f, x54f, x55f 
'COMMON SHARED x11f1, x12f1, x13f1, x14f1, x15f1, x21f1, x22f1, x23f1, x24f1, x25f1, x31f1, 
x32f1, x33f1, x34f1, x35f1, x41f1, x42f1, x43f1, x44f1, x45f1, x51f1, x52f1, x53f1, x54f1, x55f1 
'CLS 
'Print "The Series of Short Programs for Power Systems Analysts­ P/D version, 1999" 
'Print "a program to calculate the impedance bus matrix for 4 buses, with 3 sources, side branches, and 
x35=x25=x24=x31=0, symmetrical fault currents on any of the 4 buses and voltage sensitivity on the 
others" 
'Open "sccalcn5.dat" For Input As #1 
'Input #1, x01, x02, x03, x04, xx12, xx23, xx34, xx45, xx53, xx51, vf 
'Close #1 
UserForm6.Show 
x01 = Range("b38") 
x02 = Range("b39") 
x03 = Range("b40") 
xx12 = Range("b41") 
xx21 = Range("b41") 
xx23 = Range("b42") 
xx32 = Range("b42") 
xx34 = Range("b43") 
xx43 = Range("b43") 
xx54 = Range("b44") 
xx45 = Range("b44") 
xx15 = Range("b45") 
xx51 = Range("b45") 
xx35 = Range("b46") 
xx53 = Range("b46") 
bn = Range("b47") 
vf = Range("b48") 
x11 = x01 
x12 = x11 
x21 = x12 
x22 = x01 + xx12 
Debug.Print "reactances after first step", x11, x12, x21, x22 
If x02 > 0 Then 
x11p = x11 
x12p = x12 
x21p = x21 
x22p = x22 
xp1 = x21 
xp2 = x22 
xpp = x02 + x22 
x1p = x12 
x2p = x22 
x111 = x11p ­ ((x1p) * (xp1) / (xpp)) 
x121 = x12p ­ ((x1p) * (xp2) / (xpp)) 
x211 = x21p ­ ((x2p) * (xp1) / (xpp)) 
x221 = x22p ­ ((x2p) * (xp2) / (xpp)) 
x131 = x121 
x231 = x221 
x311 = x211 
x321 = x221 
x331 = x221 + xx23 
Else 
x31 = x21 
x32 = x22 
x33 = xx23 + x22 
x13 = x12 
x23 = x22 
End If 
If (x111 = 0 And x221 = 0) Then 
x11b = x11 
x12b = x12 
x13b = x13 
x21b = x21 
x22b = x22 
x23b = x23 
x31b = x31 
x32b = x32 
x33b = x33 
Else 
x11b = x111 
x12b = x121 
x13b = x131 
x21b = x211 
x22b = x221 
x23b = x231 
x31b = x311 
x32b = x321 
x33b = x331 
End If 
If x03 > 0 Then 
x11p1 = x11b 
x12p1 = x12b 
x13p1 = x13b 
x21p1 = x21b 
x22p1 = x22b 
x23p1 = x23b 
x31p1 = x31b 
x32p1 = x32b 
x33p1 = x33b 
xp12 = x31b 
xp22 = x32b 
xp32 = x33b 
xpp1 = x03 + x33b 
x1p2 = x13b 
x2p2 = x23b 
x3p2 = x33b 
x112 = x11p1 ­ ((x1p2) * (xp12) / (xpp1)) 
x122 = x12p1 ­ ((x1p2) * (xp22) / (xpp1)) 
x132 = x13p1 ­ ((x1p2) * (xp32) / (xpp1)) 
x212 = x21p1 ­ ((x2p2) * (xp12) / (xpp1)) 
x222 = x22p1 ­ ((x2p2) * (xp22) / (xpp1)) 
x232 = x23p1 ­ ((x2p2) * (xp32) / (xpp1)) 
x312 = x31p1 ­ ((x3p2) * (xp12) / (xpp1)) 
x322 = x32p1 ­ ((x3p2) * (xp22) / (xpp1)) 
x332 = x33p1 ­ ((x3p2) * (xp32) / (xpp1)) 
x142 = x132 
x242 = x232 
x342 = x332 
x412 = x312 
x422 = x322 
x432 = x332 
x442 = x332 + xx34 
x51 = x412 
x52 = x422 
x53 = x432 
x54 = x442 
x55 = x442 + xx45 
x15 = x142 
x25 = x242 
x35 = x342 
x45 = x442 
Else 
x11d = x11 
x12d = x12 
x13d = x13 
x14d = x13 
x21d = x21 
x22d = x22 
x23d = x23 
x24d = x23 
x31d = x31 
x32d = x32 
x33d = x33 
x34d = x33 
x41d = x31 
x42d = x32 
x43d = x33 
x44d = x33 + xx34 
x51d = x41d 
x52d = x42d 
x53d = x43d 
x54d = x44d 
x55d = x44d + xx45 
x15d = x14d 
x25d = x24d 
x35d = x34d 
x45d = x44d 
End If 
If (xx53 > 0 And x03 > 0) Then 
x1p3 = x132 ­ x15 
x2p3 = x232 ­ x25 
x3p3 = x332 ­ x35 
x4p3 = x432 ­ x45 
x5p3 = x53 ­ x55 
xp13 = x1p3 
xp23 = x2p3 
xp33 = x3p3 
xp43 = x4p3 
xp53 = x5p3 
xpp3 = x332 + x55 ­ 2 * (x35) + xx53 
x11f = x112 ­ (x1p3) * (xp13) / (xpp3) 
x12f = x122 ­ (x1p3) * (xp23) / (xpp3) 
x13f = x132 ­ (x1p3) * (xp33) / (xpp3) 
x14f = x142 ­ (x1p3) * (xp43) / (xpp3) 
x15f = x15 ­ (x1p3) * (xp53) / (xpp3) 
x21f = x212 ­ (x2p3) * (xp13) / (xpp3) 
x22f = x222 ­ (x2p3) * (xp23) / (xpp3) 
x23f = x232 ­ (x2p3) * (xp33) / (xpp3) 
x24f = x242 ­ (x2p3) * (xp43) / (xpp3) 
x25f = x25 ­ (x2p3) * (xp53) / (xpp3) 
x31f = x312 ­ (x3p3) * (xp13) / (xpp3) 
x32f = x322 ­ (x3p3) * (xp23) / (xpp3) 
x33f = x332 ­ (x3p3) * (xp33) / (xpp3) 
x34f = x342 ­ (x3p3) * (xp43) / (xpp3) 
x35f = x35 ­ (x3p3) * (xp53) / (xpp3) 
x41f = x412 ­ (x4p3) * (xp13) / (xpp3) 
x42f = x422 ­ (x4p3) * (xp23) / (xpp3) 
x43f = x432 ­ (x4p3) * (xp33) / (xpp3) 
x44f = x442 ­ (x4p3) * (xp43) / (xpp3) 
x45f = x45 ­ (x4p3) * (xp53) / (xpp3) 
x51f = x51 ­ (x5p3) * (xp13) / (xpp3) 
x52f = x52 ­ (x5p3) * (xp23) / (xpp3) 
x53f = x53 ­ (x5p3) * (xp33) / (xpp3) 
x54f = x54 ­ (x5p3) * (xp43) / (xpp3) 
x55f = x55 ­ (x5p3) * (xp53) / (xpp3) 
End If 
If (xx53 > 0 And x03 = 0) Then 
x1p3 = x13d ­ x15d 
x2p3 = x23d ­ x25d 
x3p3 = x33d ­ x35d 
x4p3 = x43d ­ x45d 
x5p3 = x53d ­ x55d 
xp13 = x1p3 
xp23 = x2p3 
xp33 = x3p3 
xp43 = x4p3 
xp53 = x5p3 
xpp3 = x33d + x55d ­ 2 * (x35d) + xx53 
x11f = x11d ­ (x1p3) * (xp13) / (xpp3) 
x12f = x12d ­ (x1p3) * (xp23) / (xpp3) 
x13f = x13d ­ (x1p3) * (xp33) / (xpp3) 
x14f = x14d ­ (x1p3) * (xp43) / (xpp3) 
x15f = x15d ­ (x1p3) * (xp53) / (xpp3) 
x21f = x21d ­ (x2p3) * (xp13) / (xpp3) 
x22f = x22d ­ (x2p3) * (xp23) / (xpp3) 
x23f = x23d ­ (x2p3) * (xp33) / (xpp3) 
x24f = x24d ­ (x2p3) * (xp43) / (xpp3) 
x25f = x25d ­ (x2p3) * (xp53) / (xpp3) 
x31f = x31d ­ (x3p3) * (xp13) / (xpp3) 
x32f = x32d ­ (x3p3) * (xp23) / (xpp3) 
x33f = x33d ­ (x3p3) * (xp33) / (xpp3) 
x34f = x34d ­ (x3p3) * (xp43) / (xpp3) 
x35f = x35d ­ (x3p3) * (xp53) / (xpp3) 
x41f = x41d ­ (x4p3) * (xp13) / (xpp3) 
x42f = x42d ­ (x4p3) * (xp23) / (xpp3) 
x43f = x43d ­ (x4p3) * (xp33) / (xpp3) 
x44f = x44d ­ (x4p3) * (xp43) / (xpp3) 
x45f = x45d ­ (x4p3) * (xp53) / (xpp3) 
x51f = x51d ­ (x5p3) * (xp13) / (xpp3) 
x52f = x52d ­ (x5p3) * (xp23) / (xpp3) 
x53f = x53d ­ (x5p3) * (xp33) / (xpp3) 
x54f = x54d ­ (x5p3) * (xp43) / (xpp3) 
x55f = x55d ­ (x5p3) * (xp53) / (xpp3) 
End If 
If xx51 = 0 Then 
Debug.Print x11f, x12f, x13f, x14f, x15f 
Debug.Print x21f, x22f, x23f, x24f, x25f 
Debug.Print x31f, x32f, x33f, x34f, x35f 
Debug.Print x41f, x42f, x43f, x44f, x45f 
Debug.Print x51f, x52f, x53f, x54f, x55f 
xxc11 = x11f 
xxc12 = x12f 
xxc13 = x13f 
xxc14 = x14f 
xxc15 = x15f 
xxc21 = x21f 
xxc22 = x22f 
xxc23 = x23f 
xxc24 = x24f 
xxc25 = x25f 
xxc31 = x31f 
xxc32 = x32f 
xxc33 = x33f 
xxc34 = x34f 
xxc35 = x35f 
xxc41 = x41f 
xxc42 = x42f 
xxc43 = x43f 
xxc44 = x44f 
xxc45 = x45f 
xxc51 = x51f 
xxc52 = x52f 
xxc53 = x53f 
xxc54 = x54f 
xxc55 = x55f 
Else 
x1p4 = x11f ­ x15f 
x2p4 = x21f ­ x25f 
x3p4 = x31f ­ x35f 
x4p4 = x41f ­ x45f 
x5p4 = x51f ­ x55f 
xp14 = x1p4 
xp24 = x2p4 
xp34 = x3p4 
xp44 = x4p4 
xp54 = x5p4 
xpp4 = x11f + x55f ­ 2 * (x15f) + xx51 
x11f1 = x11f ­ (x1p4) * (xp14) / (xpp4) 
x12f1 = x12f ­ (x1p4) * (xp24) / (xpp4) 
x13f1 = x13f ­ (x1p4) * (xp34) / (xpp4) 
x14f1 = x14f ­ (x1p4) * (xp44) / (xpp4) 
x15f1 = x15f ­ (x1p4) * (xp54) / (xpp4) 
x21f1 = x21f ­ (x2p4) * (xp14) / (xpp4) 
x22f1 = x22f ­ (x2p4) * (xp24) / (xpp4) 
x23f1 = x23f ­ (x2p4) * (xp34) / (xpp4) 
x24f1 = x24f ­ (x2p4) * (xp44) / (xpp4) 
x25f1 = x25f ­ (x2p4) * (xp54) / (xpp4) 
x31f1 = x31f ­ (x3p4) * (xp14) / (xpp4) 
x32f1 = x32f ­ (x3p4) * (xp24) / (xpp4) 
x33f1 = x33f ­ (x3p4) * (xp34) / (xpp4) 
x34f1 = x34f ­ (x3p4) * (xp44) / (xpp4) 
x35f1 = x35f ­ (x3p4) * (xp54) / (xpp4) 
x41f1 = x41f ­ (x4p4) * (xp14) / (xpp4) 
x42f1 = x42f ­ (x4p4) * (xp24) / (xpp4) 
x43f1 = x43f ­ (x4p4) * (xp34) / (xpp4) 
x44f1 = x44f ­ (x4p4) * (xp44) / (xpp4) 
x45f1 = x45f ­ (x4p4) * (xp54) / (xpp4) 
x51f1 = x51f ­ (x5p4) * (xp14) / (xpp4) 
x52f1 = x52f ­ (x5p4) * (xp24) / (xpp4) 
x53f1 = x53f ­ (x5p4) * (xp34) / (xpp4) 
x54f1 = x54f ­ (x5p4) * (xp44) / (xpp4) 
x55f1 = x55f ­ (x5p4) * (xp54) / (xpp4) 
End If 
Debug.Print x11f1; x12f1; x13f1; x14f1; x15f1 
Debug.Print x21f1; x22f1; x23f1; x24f1; x25f1 
Debug.Print x31f1; x32f1; x33f1; x34f1; x35f1 
Debug.Print x41f1; x42f1; x43f1; x44f1; x45f1 
Debug.Print x51f1; x52f1; x53f1; x54f1; x55f1 
xxc11 = x11f1 
xxc12 = x12f1 
xxc13 = x13f1 
xxc14 = x14f1 
xxc15 = x15f1 
xxc21 = x21f1 
xxc22 = x22f1 
xxc23 = x23f1 
xxc24 = x24f1 
xxc25 = x25f1 
xxc31 = x31f1 
xxc32 = x32f1 
xxc33 = x33f1 
xxc34 = x34f1 
xxc35 = x35f1 
xxc41 = x41f1 
xxc42 = x42f1 
xxc43 = x43f1 
xxc44 = x44f1 
xxc45 = x45f1 
xxc51 = x51f1 
xxc52 = x52f1 
xxc53 = x53f1 
xxc54 = x54f1 
xxc55 = x55f1 
'INPUT "3 phase fault on bus number", bn 
If bn = 1 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc11 
Range("b49") = vf / xxc11 
End If 
If bn = 1 Then 
'Print "voltage on buses 2,3,4,5 respectively are in p.u.="; (vf ­ (xxc12 / xxc11)), (vf ­ (xxc13 / xxc11)), 
(vf ­ (xxc14 / xxc11)), (vf ­ (xxc15 / xxc11)) 
Range("a50") = "voltage on bus 2" 
Range("b50") = (vf ­ (xxc12 / xxc11)) 
Range("a51") = "voltage on bus 3" 
Range("b51") = (vf ­ (xxc13 / xxc11)) 
Range("a52") = "voltage on bus 4" 
Range("b52") = (vf ­ (xxc14 / xxc11)) 
Range("a53") = "voltage on bus 5" 
Range("b53") = (vf ­ (xxc15 / xxc11)) 
End If 
If bn = 2 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc22 
Range("b49") = vf / xxc22 
End If 
If bn = 2 Then 
'Print "voltage on buses 1,3,4,5 respectively are in p.u.="; (vf ­ (xxc12 / xxc22)), (vf ­ (xxc23 / xxc22)), 
(vf ­ (xxc24 / xxc22)), (vf ­ (xxc25 / xxc22)) 
Range("a50") = "voltage on bus 1" 
Range("b50") = (vf ­ (xxc12 / xxc22)) 
Range("a51") = "voltage on bus 3" 
Range("b51") = (vf ­ (xxc23 / xxc22)) 
Range("a52") = "voltage on bus 4" 
Range("b52") = (vf ­ (xxc24 / xxc22)) 
Range("a53") = "voltage on bus 5" 
Range("b53") = (vf ­ (xxc25 / xxc22)) 
End If 
If bn = 3 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc33 
Range("b49") = vf / xxc33 
End If 
If bn = 3 Then 
'Print "voltage on buses 1,2,4,5 respectively are in p.u.="; (vf ­ (xxc13 / xxc33)), (vf ­ (xxc32 / xxc33)), 
(vf ­ (xxc34 / xxc33)), (vf ­ (xxc35 / xxc33)) 
Range("a50") = "voltage on bus 1" 
Range("b50") = (vf ­ (xxc13 / xxc33)) 
Range("a51") = "voltage on bus 2" 
Range("b51") = (vf ­ (xxc32 / xxc33)) 
Range("a52") = "voltage on bus 4" 
Range("b52") = (vf ­ (xxc34 / xxc33)) 
Range("a53") = "voltage on bus 5" 
Range("b53") = (vf ­ (xxc35 / xxc33)) 
End If 
If bn = 4 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc44 
Range("b49") = vf / xxc44 
End If 
If bn = 4 Then 
'Print "voltage on buses 1,2,3,5 respectively are in p.u.="; (vf ­ (xxc14 / xxc44)), (vf ­ (xxc24 / xxc44)), 
(vf ­ (xxc34 / xxc44)), (vf ­ (xxc45 / xxc44)) 
Range("a50") = "voltage on bus 1" 
Range("b50") = (vf ­ (xxc14 / xxc44)) 
Range("a51") = "voltage on bus 2" 
Range("b51") = (vf ­ (xxc24 / xxc44)) 
Range("a52") = "voltage on bus 3" 
Range("b52") = (vf ­ (xxc34 / xxc44)) 
Range("a53") = "voltage on bus 5" 
Range("b53") = (vf ­ (xxc45 / xxc44)) 
End If 
If bn = 5 Then 
'Print "3 phase fault current in p.u. =­j"; vf / xxc55 
Range("b49") = vf / xxc55 
End If 
If bn = 5 Then 
'Print "voltage on buses 1,2,3,4 respectively are in p.u.="; (vf ­ (xxc15 / xxc55)), (vf ­ (xxc25 / xxc55)), 
(vf ­ (xxc35 / xxc55)), (vf ­ (xxc45 / xxc55)) 
Range("a50") = "voltage on bus 1" 
Range("b50") = (vf ­ (xxc15 / xxc55)) 
Range("a51") = "voltage on bus 2" 
Range("b51") = (vf ­ (xxc25 / xxc55)) 
Range("a52") = "voltage on bus 3" 
Range("b52") = (vf ­ (xxc35 / xxc55)) 
Range("a53") = "voltage on bus 4" 
Range("b53") = (vf ­ (xxc45 / xxc55)) 
End If 
Range("b49").Select 
'INPUT "Project Name:"; projnam$ 
'INPUT "Prepared By: "; pb$ 
'INPUT "Project Number:"; projnum$ 
'INPUT "Date: "; da$ 
'INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
If opap = 1 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Output As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
If bn = 1 Then Print #1, "3 phase fault at bus 1 s.c.c. in p.u. =­j"; vf / xxc11, "voltage on buses 2,3,4,5 
respectively are in p.u.="; (vf ­ (xxc12 / xxc11)), (vf ­ (xxc13 / xxc11)), (vf ­ (xxc14 / xxc11)), (vf ­ 
(xxc15 / xxc11)) 
If bn = 2 Then Print #1, "3 phase fault at bus 2 s.c.c. in p.u. =­j"; vf / xxc22; "voltage on buses 1,3,4,5 
respectively are in p.u.="; (vf ­ (xxc12 / xxc22)), (vf ­ (xxc23 / xxc22)), (vf ­ (xxc24 / xxc22)), (vf ­ 
(xxc25 / xxc22)) 
If bn = 3 Then Print #1, "3 phase fault at bus 3 s.c.c. in p.u. =­j"; vf / xxc33, "voltage on buses 1,2,4,5 
respectively are in p.u.="; (vf ­ (xxc13 / xxc33)), (vf ­ (xxc32 / xxc33)), (vf ­ (xxc34 / xxc33)), (vf ­ 
(xxc35 / xxc33)) 
If bn = 4 Then Print #1, "3 phase fault at bus 4 s.c.c. in p.u. =­j"; vf / xxc44, "voltage on buses 1,2,3,5 
respectively are in p.u.="; (vf ­ (xxc14 / xxc44)), (vf ­ (xxc24 / xxc44)), (vf ­ (xxc34 / xxc44)), (vf ­ 
(xxc45 / xxc44)) 
If bn = 5 Then Print #1, "3 phase fault at bus 5 s.c.c. in p.u. =­j"; vf / xxc55; "voltage on buses 1,2,3,4 
respectively are in p.u.="; (vf ­ (xxc15 / xxc55)), (vf ­ (xxc25 / xxc55)), (vf ­ (xxc35 / xxc55)), (vf ­ 
(xxc45 / xxc55)) 
Close #1 
End If 
If opap = 2 Then 
'INPUT "filename to save this file under: ", filename$ 
Open FileName$ For Append As #1 
Print #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
Print #1, "Project Number:"; projnum$, "Date: "; da$ 
If bn = 1 Then Print #1, "3 phase fault at bus 1 s.c.c. in p.u. =­j"; vf / xxc11, "voltage on buses 2,3,4,5 
respectively are in p.u.="; (vf ­ (xxc12 / xxc11)), (vf ­ (xxc13 / xxc11)), (vf ­ (xxc14 / xxc11)), (vf ­ 
(xxc15 / xxc11)) 
If bn = 2 Then Print #1, "3 phase fault at bus 2 s.c.c. in p.u. =­j"; vf / xxc22; "voltage on buses 1,3,4,5 
respectively are in p.u.="; (vf ­ (xxc12 / xxc22)), (vf ­ (xxc23 / xxc22)), (vf ­ (xxc24 / xxc22)), (vf ­ 
(xxc25 / xxc22)) 
If bn = 3 Then Print #1, "3 phase fault at bus 3 s.c.c. in p.u. =­j"; vf / xxc33, "voltage on buses 1,2,4,5 
respectively are in p.u.="; (vf ­ (xxc13 / xxc33)), (vf ­ (xxc32 / xxc33)), (vf ­ (xxc34 / xxc33)), (vf ­ 
(xxc35 / xxc33)) 
If bn = 4 Then Print #1, "3 phase fault at bus 4 s.c.c. in p.u. =­j"; vf / xxc44, "voltage on buses 1,2,3,5 
respectively are in p.u.="; (vf ­ (xxc14 / xxc44)), (vf ­ (xxc24 / xxc44)), (vf ­ (xxc34 / xxc44)), (vf ­ 
(xxc45 / xxc44)) 
If bn = 5 Then Print #1, "3 phase fault at bus 5 s.c.c. in p.u. =­j"; vf / xxc55; "voltage on buses 1,2,3,4 
respectively are in p.u.="; (vf ­ (xxc15 / xxc55)), (vf ­ (xxc25 / xxc55)), (vf ­ (xxc35 / xxc55)), (vf ­ 
(xxc45 / xxc55)) 
Close #1 
End If 
'Print "enter 1 to go to main menu, 2 to go to short circuit calculations menu" 
End Sub 
Sub MySub3() 
Workbooks.Open "c:\my documents\howto\htpsach2.xls" 
Worksheets("series or parallel elements").Activate 
End Sub 
Note: On page 106 under the first else statement, it is assumed that if there is no source connected 
between bus 3 and the reference node then there will be no one connected between bus 2 and the 
reference node. If the case is that there may be a source at bus 2 with no one on bus 3, then replace the 
values shown on the side with those having a suffix b. The same applies to page 114, the statements 
under the first else in the page. 
Quattro Pro of Borland 
The next few pages will show a file that runs under Quattro Pro. It will show the necessary macros to 
run  short circuit studies for a 2­bus radial system and a 5­bus network (with side branches) system. 
Based on these sample models any similar studies with other number of buses can be modelled and the 
subject analysis can be performed. The 5­bus network can, also,  calculate 3­phase short circuit values 
and the voltage on the unfaulty buses (voltage sensitivity analysis) for a radial system with 5 buses. The 
2 bus radial system example given calculates fault currents for line to line, line to ground, line to line to 
ground and line to line to line faults in 3 phase systems. For the line to ground and 3 phase faults, the 
option to perform a voltage sensitivity analysis is provided. 
Note: the on­line version of this book does not include the Quattro Pro examples

contents
Chapter 4 
Load flow studies

Introduction: 
Load flow studies are performed on power systems,among other reasons,  to allow the proper sizing of 
the series system components. This study will give the level of power (current) flowing from one bus to 
the other under different load conditions. Thus, the cables, splices, circuit breakers, fuses, and other 
components will be sized accordingly. It may also give the values of overloads for short duration, which 
is also included when sizing the electrical system components. Another reason for running such studies 
would be the investigation of the effects of starting squirrel cage induction motors in the system over 
the different buses (bus voltage reduction during the staring period of the motor). It can also be run to 
see the effect of applying capacitors to the differnt points in the system to reduce ther reactive power 
flowing and improve the bus voltage. In general, the input to the study will be: the resistance & 
reactance of the different segments in the system (between the different buses), the active & reactive 
power consumed at the different system buses, the voltage (usually taken as 1) and phase angle (usually 
taken as 0) for the first iteration, the MVA base for the system (usually taken as 100). To solve this type 
of problems, iterative methods are used, fast decoupled, Newton­Rapphson or Rung Kutta. In this book, 
for the radial system, Fast Decoupled method is used; for network ones, Newton­Raphson is used. The 
iterative methods, using the data inputted by the user, will construct the Y­bus matrix, then calculating 
the active power balance as well as the reactive power balance at the different nodes (buses). Assuming 
the problem is diverging, substituting the calculated voltages and phase angles calculated n this 
iteration into the next iteration, the difference between the power inflowing (active & reactive) to the 
different buses will equal or be close enough within very close limits to the outflowing power (active & 
reactive). Under this last condition, the voltages as well as the phase angles are registerd and the power 
(ctive and reactive) flowing between the buses are calculated. It is quite known that the phase angle 
affects the active power flow and the voltage affects thereactive power flow. 
  
Examples showing how to use Excel to solve for the load flow studies including bus voltages & phase  
angles at each of the buses (nodes) and the power flow between the different buses: 
The menu when the load flow calculation file is opened under Excel 
Microsoft Excel: 
WORKBOOKS & WORKSHEETS PROGRAMS 
Private Sub Workbook_Deactivate() 
Application.CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Workbook_Open() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Load flow Calculations" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Radial systems calculations" 
ctrl1.TooltipText = "Radial systems" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Network systems calculations" 
ctrl2.TooltipText = "Network systems" 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "&Basic calculations" 
ctrl3.TooltipText = "Fundamental operations" 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
End Sub 
Private Sub Workbook_Activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Load flow Calculations" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Radial systems calculations" 
ctrl1.TooltipText = "Radial systems" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Network systems calculations" 
ctrl2.TooltipText = "Network systems" 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "&Basic calculations" 
ctrl3.TooltipText = "Fundamental operations" 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
Application.CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Worksheet_activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Load flow Calculations" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Radial systems calculations" 
ctrl1.TooltipText = "Radial systems" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Network systems calculations" 
ctrl2.TooltipText = "Network (Grid) systems" 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "&Basic calculations" 
ctrl3.TooltipText = "Fundamental operations" 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Radial systems" 
Set ctrl11 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl11.Caption = "&One feeder, 2­bus system" 
ctrl11.TooltipText = "Radial systems" 
ctrl11.Style = msoButtonCaption 
With ctrl11 
    .OnAction = "MySub11" 
End With 
Set ctrl12 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl12.Caption = "O&ne feeder, 3­bus system" 
ctrl12.TooltipText = "Radial systems" 
ctrl12.Style = msoButtonCaption 
With ctrl12 
    .OnAction = "MySub12" 
End With 
Set ctrl13 = newMenu.Controls.Add(Type:=msoControlPopup, Id:=1) 
ctrl13.Caption = "T&hree feeders, up to 10 buses" 
Set ctrl131 = ctrl13.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl131.Caption = "Three feeders, &five­bus" 
ctrl131.TooltipText = "Radial systems" 
ctrl131.Style = msoButtonCaption 
With ctrl131 
    .OnAction = "MySub131" 
End With 
Set ctrl132 = ctrl13.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl132.Caption = "Three feeders, &six­bus" 
ctrl132.TooltipText = "Radial systems" 
ctrl132.Style = msoButtonCaption 
With ctrl132 
    .OnAction = "MySub132" 
End With 
Set ctrl133 = ctrl13.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl133.Caption = "Three feeders, se&ven­bus" 
ctrl133.TooltipText = "Radial systems" 
ctrl133.Style = msoButtonCaption 
With ctrl133 
    .OnAction = "MySub133" 
End With 
Set ctrl134 = ctrl13.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl134.Caption = "Three feeders, &eight­bus" 
ctrl134.TooltipText = "Radial systems" 
ctrl134.Style = msoButtonCaption 
With ctrl134 
    .OnAction = "MySub134" 
End With 
Set ctrl135 = ctrl13.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl135.Caption = "Three feeders, &nine­bus" 
ctrl135.TooltipText = "Radial systems" 
ctrl135.Style = msoButtonCaption 
With ctrl135 
    .OnAction = "MySub135" 
End With 
Set ctrl136 = ctrl13.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl136.Caption = "Three feeders, &ten­bus" 
ctrl136.TooltipText = "Radial systems" 
ctrl136.Style = msoButtonCaption 
With ctrl136 
    .OnAction = "MySub136" 
End With 
End Sub 
Private Sub Worksheet_Deactivate() 
Application.CommandBars.ActiveMenuBar.Reset 
End Sub 
Private Sub Worksheet_activate() 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Load flow Calculations" 
Set ctrl1 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl1.Caption = "&Radial systems calculations" 
ctrl1.TooltipText = "Radial systems" 
ctrl1.Style = msoButtonCaption 
With ctrl1 
    .OnAction = "MySub1" 
End With 
Set ctrl2 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl2.Caption = "&Network systems calculations" 
ctrl2.TooltipText = "Network (Grid) systems" 
ctrl2.Style = msoButtonCaption 
With ctrl2 
    .OnAction = "MySub2" 
End With 
Set ctrl3 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl3.Caption = "&Basic calculations" 
ctrl3.TooltipText = "Fundamental operations" 
ctrl3.Style = msoButtonCaption 
With ctrl3 
    .OnAction = "MySub3" 
End With 
Set myMenubar = Application.CommandBars.ActiveMenuBar 
Set newMenu = myMenubar.Controls.Add(Type:=msoControlPopup, temporary:=True) 
newMenu.Caption = "&Network systems" 
Set ctrl21 = newMenu.Controls.Add(Type:=msoControlButton, Id:=1) 
ctrl21.Caption = "&Four bus system" 
ctrl21.TooltipText = "Network (grid) systems" 
ctrl21.Style = msoButtonCaption 
With ctrl21 
    .OnAction = "MySub21" 
End With 
End Sub 
USER FORMS (DIALOG BOXES) 
Private Sub CommandButton1_Click() 
TextBox1 = Range("z2") 
TextBox2 = Range("z3") 
TextBox3 = Range("z4") 
TextBox4 = Range("z5") 
TextBox5 = Range("z6") 
TextBox6 = Range("z9") 
TextBox7 = Range("z10") 
TextBox8 = Range("z7 ") 
TextBox9 = Range("z8") 
TextBox10 = Range("z11") 
TextBox11 = Range("z12") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm1 
End Sub 
Private Sub TextBox1_Change() 
On Error GoTo errorhandler 
Range("b2") = TextBox1 
errorhandler: 
If Err.Number = 13 Then 
Range("b2") = InputBox("Enter a number, 0 or more") 
TextBox1 = Range("b2") 
Resume Next 
End If 
End Sub 
Private Sub TextBox10_Change() 
Range("b11") = TextBox10 
End Sub 
Private Sub TextBox11_Change() 
Range("b12") = TextBox11 
End Sub 
Private Sub TextBox2_Change() 
Range("b3") = TextBox2 
End Sub 
Private Sub TextBox3_Change() 
Range("b4") = TextBox3 
End Sub 
Private Sub TextBox4_Change() 
Range("b5") = TextBox4 
End Sub 
Private Sub TextBox5_Change() 
Range("b6") = TextBox5 
End Sub 
Private Sub TextBox6_Change() 
Range("b9") = TextBox6 
End Sub 
Private Sub TextBox7_Change() 
Range("b10") = TextBox7 
End Sub 
Private Sub TextBox8_Change() 
Range("b7") = TextBox8 
End Sub 
Private Sub TextBox9_Change() 
Range("b8") = TextBox9 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b2") 
TextBox2 = Range("b3") 
TextBox3 = Range("b4") 
TextBox4 = Range("b5") 
TextBox5 = Range("b6") 
TextBox6 = Range("b9") 
TextBox7 = Range("b10") 
TextBox8 = Range("b7") 
TextBox9 = Range("b8") 
TextBox10 = Range("b11") 
TextBox11 = Range("b12") 
Range("z2") = Range("b2") 
Range("z3") = Range("b3") 
Range("z4") = Range("b4") 
Range("z5") = Range("b5") 
Range("z6") = Range("b6") 
Range("z7") = Range("b7") 
Range("z8") = Range("b8") 
Range("z9") = Range("b9") 
Range("z10") = Range("b10") 
Range("z11") = Range("b11") 
Range("z12") = Range("b12") 
End Sub 
Private Sub CommandButton1_Click() 
TextBox1 = Range("z26") 
TextBox2 = Range("zb27") 
TextBox3 = Range("z28") 
TextBox4 = Range("z29") 
TextBox5 = Range("z30") 
TextBox6 = Range("z31") 
TextBox7 = Range("z32") 
TextBox8 = Range("z33") 
TextBox9 = Range("z34") 
TextBox10 = Range("z35") 
TextBox11 = Range("z36") 
TextBox12 = Range("z37") 
TextBox13 = Range("z38") 
TextBox14 = Range("z39") 
TextBox15 = Range("z40") 
TextBox16 = Range("z41") 
TextBox17 = Range("z42") 
TextBox18 = Range("z43") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm2 
End Sub 
Private Sub TextBox1_Change() 
Range("b26") = TextBox1 
End Sub 
Private Sub TextBox10_Change() 
Range("b35") = TextBox10 
End Sub 
Private Sub TextBox11_Change() 
Range("b36") = TextBox11 
End Sub 
Private Sub TextBox12_Change() 
Range("b37") = TextBox12 
End Sub 
Private Sub TextBox13_Change() 
Range("b38") = TextBox13 
End Sub 
Private Sub TextBox14_Change() 
Range("b39") = TextBox14 
End Sub 
Private Sub TextBox15_Change() 
Range("b40") = TextBox15 
End Sub 
Private Sub TextBox16_Change() 
Range("b41") = TextBox16 
End Sub 
Private Sub TextBox17_Change() 
Range("b42") = TextBox17 
End Sub 
Private Sub TextBox18_Change() 
Range("b43") = TextBox18 
End Sub 
Private Sub TextBox2_Change() 
Range("b27") = TextBox2 
End Sub 
Private Sub TextBox3_Change() 
Range("b28") = TextBox3 
End Sub 
Private Sub TextBox4_Change() 
Range("b29") = TextBox4 
End Sub 
Private Sub TextBox5_Change() 
Range("b30") = TextBox5 
End Sub 
Private Sub TextBox6_Change() 
Range("b31") = TextBox6 
End Sub 
Private Sub TextBox7_Change() 
Range("b32") = TextBox7 
End Sub 
Private Sub TextBox8_Change() 
Range("b33") = TextBox8 
End Sub 
Private Sub TextBox9_Change() 
Range("b34") = TextBox9 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b26") 
TextBox2 = Range("b27") 
TextBox3 = Range("b28") 
TextBox4 = Range("b29") 
TextBox5 = Range("b30") 
TextBox6 = Range("b31") 
TextBox7 = Range("b32") 
TextBox8 = Range("b33") 
TextBox9 = Range("b34") 
TextBox10 = Range("b35") 
TextBox11 = Range("b36") 
TextBox12 = Range("b37") 
TextBox13 = Range("b38") 
TextBox14 = Range("b39") 
TextBox15 = Range("b40") 
TextBox16 = Range("b41") 
TextBox17 = Range("b42") 
TextBox18 = Range("b43") 
Range("z26") = Range("b26") 
Range("z27") = Range("b27") 
Range("z28") = Range("b28") 
Range("z29") = Range("b29") 
Range("z30") = Range("b30") 
Range("z31") = Range("b31") 
Range("z32") = Range("b32") 
Range("z33") = Range("b33") 
Range("z31") = Range("b34") 
Range("z35") = Range("b35") 
Range("z36") = Range("b36") 
Range("z37") = Range("b37") 
Range("z38") = Range("b38") 
Range("z39") = Range("b39") 
Range("z40") = Range("b40") 
Range("z41") = Range("b41") 
Range("z42") = Range("b42") 
Range("z43") = Range("b43") 
End Sub 
Private Sub CommandButton1_Click() 
'reset button 
TextBox1 = Range("z65") 
TextBox2 = Range("z66") 
TextBox3 = Range("z67") 
TextBox4 = Range("z68") 
TextBox5 = Range("z74") 
TextBox6 = Range("z75") 
TextBox7 = Range("z76") 
TextBox8 = Range("z77") 
TextBox9 = Range("z83") 
TextBox10 = Range("z84") 
TextBox11 = Range("z85") 
TextBox12 = Range("z86") 
TextBox13 = Range("z109") 
TextBox14 = Range("z110") 
TextBox15 = Range("z111") 
TextBox16 = Range("z112") 
TextBox17 = Range("z113") 
TextBox18 = Range("z87") 
TextBox19 = Range("z89") 
TextBox20 = Range("z90") 
TextBox21 = Range("z91") 
TextBox22 = Range("z92") 
TextBox23 = Range("z93") 
TextBox24 = Range("z99") 
TextBox25 = Range("z100") 
TextBox26 = Range("z101") 
TextBox27 = Range("z102") 
TextBox28 = Range("z103") 
TextBox29 = Range("z119") 
TextBox30 = Range("z120") 
TextBox31 = Range("z121") 
TextBox32 = Range("z122") 
TextBox33 = Range("z123") 
TextBox34 = Range("z129") 
TextBox35 = Range("z130") 
End Sub 
Private Sub CommandButton2_Click() 
Unload UserForm3 
Range("b132").Select 
End Sub 
Private Sub TextBox1_Change() 
Range("b65") = TextBox1 
End Sub 
Private Sub TextBox10_Change() 
Range("b84") = TextBox10 
End Sub 
Private Sub TextBox11_Change() 
Range("b85") = TextBox11 
End Sub 
Private Sub TextBox12_Change() 
Range("b86") = TextBox12 
End Sub 
Private Sub TextBox13_Change() 
Range("b109") = TextBox13 
End Sub 
Private Sub TextBox14_Change() 
Range("b110") = TextBox14 
End Sub 
Private Sub TextBox15_Change() 
Range("b111") = TextBox15 
End Sub 
Private Sub TextBox16_Change() 
Range("b112") = TextBox16 
End Sub 
Private Sub TextBox17_Change() 
Range("b113") = TextBox17 
End Sub 
Private Sub TextBox18_Change() 
Range("b87") = TextBox18 
End Sub 
Private Sub TextBox19_Change() 
Range("b89") = TextBox19 
End Sub 
Private Sub TextBox2_Change() 
Range("b66") = TextBox2 
End Sub 
Private Sub TextBox20_Change() 
Range("b90") = TextBox20 
End Sub 
Private Sub TextBox21_Change() 
Range("b91") = TextBox21 
End Sub 
Private Sub TextBox22_Change() 
Range("b92") = TextBox22 
End Sub 
Private Sub TextBox23_Change() 
Range("b93") = TextBox23 
End Sub 
Private Sub TextBox24_Change() 
Range("b99") = TextBox24 
End Sub 
Private Sub TextBox25_Change() 
Range("b100") = TextBox25 
End Sub 
Private Sub TextBox26_Change() 
Range("b101") = TextBox26 
End Sub 
Private Sub TextBox27_Change() 
Range("b102") = TextBox27 
End Sub 
Private Sub TextBox28_Change() 
Range("b103") = TextBox28 
End Sub 
Private Sub TextBox29_Change() 
Range("b119") = TextBox29 
End Sub 
Private Sub TextBox3_Change() 
Range("b67") = TextBox3 
End Sub 
Private Sub TextBox30_Change() 
Range("b120") = TextBox30 
End Sub 
Private Sub TextBox31_Change() 
Range("b121") = TextBox31 
End Sub 
Private Sub TextBox32_Change() 
Range("b122") = TextBox32 
End Sub 
Private Sub TextBox33_Change() 
Range("b123") = TextBox33 
End Sub 
Private Sub TextBox34_Change() 
Range("b129") = TextBox34 
End Sub 
Private Sub TextBox35_Change() 
Range("b130") = TextBox35 
End Sub 
Private Sub TextBox4_Change() 
Range("b68") = TextBox4 
End Sub 
Private Sub TextBox5_Change() 
Range("b74") = TextBox5 
End Sub 
Private Sub TextBox6_Change() 
Range("b75") = TextBox6 
End Sub 
Private Sub TextBox7_Change() 
Range("b76") = TextBox7 
End Sub 
Private Sub TextBox8_Change() 
Range("b77") = TextBox8 
End Sub 
Private Sub TextBox9_Change() 
Range("b83") = TextBox9 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("b65") 
TextBox2 = Range("b66") 
TextBox3 = Range("b67") 
TextBox4 = Range("b68") 
TextBox5 = Range("b74") 
TextBox6 = Range("b75") 
TextBox7 = Range("b76") 
TextBox8 = Range("b77") 
TextBox9 = Range("b83") 
TextBox10 = Range("b84") 
TextBox11 = Range("b85") 
TextBox12 = Range("b86") 
TextBox13 = Range("b109") 
TextBox14 = Range("b110") 
TextBox15 = Range("b111") 
TextBox16 = Range("b112") 
TextBox17 = Range("b113") 
TextBox18 = Range("b87") 
TextBox19 = Range("b89") 
TextBox20 = Range("b90") 
TextBox21 = Range("b91") 
TextBox22 = Range("b92") 
TextBox23 = Range("b93") 
TextBox24 = Range("b99") 
TextBox25 = Range("b100") 
TextBox26 = Range("b101") 
TextBox27 = Range("b102") 
TextBox28 = Range("b103") 
TextBox29 = Range("b119") 
TextBox30 = Range("b120") 
TextBox31 = Range("b121") 
TextBox32 = Range("b122") 
TextBox33 = Range("b123") 
TextBox34 = Range("b129") 
TextBox35 = Range("b130") 
Range("z65") = Range("b65") 
Range("z66") = Range("b66") 
Range("z67") = Range("b67") 
Range("z68") = Range("b68") 
Range("z74") = Range("b74") 
Range("z75") = Range("b75") 
Range("z76") = Range("b76") 
Range("z77") = Range("b77") 
Range("z83") = Range("b83") 
Range("z84") = Range("b84") 
Range("z85") = Range("b85") 
Range("z86") = Range("b86") 
Range("z109") = Range("b109") 
Range("z110") = Range("b110") 
Range("z111") = Range("b111") 
Range("z112") = Range("b112") 
Range("z113") = Range("b113") 
Range("z87") = Range("b87") 
Range("z89") = Range("b89") 
Range("z90") = Range("b90") 
Range("z91") = Range("b91") 
Range("z92") = Range("b92") 
Range("z93") = Range("b93") 
Range("z99") = Range("b99") 
Range("z100") = Range("b100") 
Range("z101") = Range("b101") 
Range("z102") = Range("b102") 
Range("z103") = Range("b103") 
Range("z119") = Range("b119") 
Range("z120") = Range("b120") 
Range("z121") = Range("b121") 
Range("z122") = Range("b122") 
Range("z123") = Range("b123") 
Range("z129") = Range("b129") 
Range("z130") = Range("b130") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
UserForm4 (load flow for 3 feeders, 6­bus system): 
Private Sub CommandButton1_Click() 
Range("aa65") = Range("b65") 
Range("aa66") = Range("b66") 
Range("aa67") = Range("b67") 
Range("aa68") = Range("b68") 
Range("aa69") = Range("b69") 
Range("aa74") = Range("b74") 
Range("aa75") = Range("b75") 
Range("aa76") = Range("b76") 
Range("aa77") = Range("b77") 
Range("aa78") = Range("b78") 
Range("aa83") = Range("b83") 
Range("aa84") = Range("b84") 
Range("aa85") = Range("b85") 
Range("aa86") = Range("b86") 
Range("aa87") = Range("b87") 
Range("aa89") = Range("b89") 
Range("aa90") = Range("b90") 
Range("aa91") = Range("b91") 
Range("aa92") = Range("b92") 
Range("aa93") = Range("b93") 
Range("aa99") = Range("b99") 
Range("aa100") = Range("b100") 
Range("aa101") = Range("b101") 
Range("aa102") = Range("b102") 
Range("aa103") = Range("b103") 
Unload UserForm4 
UserForm4a.Show 
End Sub 
Private Sub CommandButton2_Click() 
'reset button 
TextBox1 = Range("aa65") 
TextBox2 = Range("aa66") 
TextBox3 = Range("aa67") 
TextBox4 = Range("aa68") 
TextBox5 = Range("aa69") 
TextBox6 = Range("aa74") 
TextBox7 = Range("aa75") 
TextBox8 = Range("aa76") 
TextBox9 = Range("aa77") 
TextBox10 = Range("aa78") 
TextBox11 = Range("aa83") 
TextBox12 = Range("aa84") 
TextBox13 = Range("aa85") 
TextBox14 = Range("aa86") 
TextBox15 = Range("aa87") 
TextBox16 = Range("aa89") 
TextBox17 = Range("aa90") 
TextBox18 = Range("aa91") 
TextBox19 = Range("aa92") 
TextBox20 = Range("aa93") 
TextBox21 = Range("aa99") 
TextBox22 = Range("aa100") 
TextBox23 = Range("aa101") 
TextBox24 = Range("aa102") 
TextBox25 = Range("aa103") 
End Sub 
Private Sub TextBox1_Change() 
Range("b65") = TextBox1 
End Sub 
Private Sub TextBox10_Change() 
Range("b78") = TextBox10 
End Sub 
Private Sub TextBox11_Change() 
Range("b83") = TextBox11 
End Sub 
Private Sub TextBox12_Change() 
Range("b84") = TextBox12 
End Sub 
Private Sub TextBox13_Change() 
Range("b85") = TextBox13 
End Sub 
Private Sub TextBox14_Change() 
Range("b86") = TextBox14 
End Sub 
Private Sub TextBox15_Change() 
Range("b87") = TextBox15 
End Sub 
Private Sub TextBox16_Change() 
Range("b89") = TextBox16 
End Sub 
Private Sub TextBox17_Change() 
Range("b90") = TextBox17 
End Sub 
Private Sub TextBox18_Change() 
Range("b91") = TextBox18 
End Sub 
Private Sub TextBox19_Change() 
Range("b92") = TextBox19 
End Sub 
Private Sub TextBox2_Change() 
Range("b66") = TextBox2 
End Sub 
Private Sub TextBox20_Change() 
Range("b93") = TextBox20 
End Sub 
Private Sub TextBox21_Change() 
Range("b99") = TextBox21 
End Sub 
Private Sub TextBox22_Change() 
Range("b100") = TextBox22 
End Sub 
Private Sub TextBox23_Change() 
Range("b101") = TextBox23 
End Sub 
Private Sub TextBox24_Change() 
Range("b102") = TextBox24 
End Sub 
Private Sub TextBox25_Change() 
Range("b103") = TextBox25 
End Sub 
Private Sub TextBox3_Change() 
Range("b67") = TextBox3 
End Sub 
Private Sub TextBox4_Change() 
Range("b68") = TextBox4 
End Sub 
Private Sub TextBox5_Change() 
Range("b69") = TextBox5 
End Sub 
Private Sub TextBox6_Change() 
Range("b74") = TextBox6 
End Sub 
Private Sub TextBox7_Change() 
Range("b75") = TextBox7 
End Sub 
Private Sub TextBox8_Change() 
Range("b76") = TextBox8 
End Sub 
Private Sub TextBox9_Change() 
Range("b77") = TextBox9 
End Sub 
Private Sub UserForm_Activate() 
TextBox1 = Range("aa65") 
TextBox2 = Range("aa66") 
TextBox3 = Range("aa67") 
TextBox4 = Range("aa68") 
TextBox5 = Range("aa69") 
TextBox6 = Range("aa74") 
TextBox7 = Range("aa75") 
TextBox8 = Range("aa76") 
TextBox9 = Range("aa77") 
TextBox10 = Range("aa78") 
TextBox11 = Range("aa83") 
TextBox12 = Range("aa84") 
TextBox13 = Range("aa85") 
TextBox14 = Range("aa86") 
TextBox15 = Range("aa87") 
TextBox16 = Range("aa89") 
TextBox17 = Range("aa90") 
TextBox18 = Range("aa91") 
TextBox19 = Range("aa92") 
TextBox20 = Range("aa93") 
TextBox21 = Range("aa99") 
TextBox22 = Range("aa100") 
TextBox23 = Range("aa101") 
TextBox24 = Range("aa102") 
TextBox25 = Range("aa103") 
End Sub 
Private Sub UserForm_Deactivate() 
Range("aa65") = Range("b65") 
Range("aa66") = Range("b66") 
Range("aa67") = Range("b67") 
Range("aa68") = Range("b68") 
Range("aa69") = Range("b69") 
Range("aa74") = Range("b74") 
Range("aa75") = Range("b75") 
Range("aa76") = Range("b76") 
Range("aa87") = Range("b87") 
Range("aa78") = Range("b78") 
Range("aa83") = Range("b83") 
Range("aa84") = Range("b84") 
Range("aa85") = Range("b85") 
Range("aa86") = Range("b86") 
Range("aa87") = Range("b87") 
Range("aa89") = Range("b89") 
Range("aa90") = Range("b90") 
Range("aa91") = Range("b91") 
Range("aa92") = Range("b92") 
Range("aa93") = Range("b93") 
Range("aa99") = Range("b99") 
Range("aa100") = Range("b100") 
Range("aa101") = Range("b101") 
Range("aa102") = Range("b102") 
Range("aa103") = Range("b103") 
End Sub 
UserForm4a (load flow for 3 feeders, 6­bus system): 
Private Sub CommandButton1_Click() 
Range("aa94") = Range("b94") 
Range("aa104") = Range("b104") 
Range("aa109") = Range("b109") 
Range("aa110") = Range("b110") 
Range("aa111") = Range("b111") 
Range("aa112") = Range("b112") 
Range("aa113") = Range("b113") 
Range("aa114") = Range("b114") 
Range("aa119") = Range("b119") 
Range("aa120") = Range("b120") 
Range("aa121") = Range("b121") 
Range("aa122") = Range("b122") 
Range("aa123") = Range("b123") 
Range("aa124") = Range("b124") 
Range("aa129") = Range("b129") 
Range("aa130") = Range("b130") 
Unload UserForm4a 
UserForm4.Show 
End Sub 
Private Sub CommandButton2_Click() 
'reset button 
TextBox13 = Range("aa94") 
TextBox14 = Range("aa104") 
TextBox15 = Range("aa109") 
TextBox16 = Range("aa110") 
TextBox17 = Range("aa111") 
TextBox18 = Range("aa112") 
TextBox19 = Range("aa113") 
TextBox20 = Range("aa114") 
TextBox21 = Range("aa119") 
TextBox22 = Range("aa120") 
TextBox23 = Range("aa121") 
TextBox24 = Range("aa122") 
TextBox25 = Range("aa123") 
TextBox26 = Range("aa124") 
TextBox27 = Range("aa129") 
TextBox28 = Range("aa130") 
End Sub 
Private Sub CommandButton3_Click() 
Unload UserForm4a 
Range("b132").Select 
End Sub 
Private Sub TextBox13_Change() 
Range("b94") = TextBox13 
End Sub 
Private Sub TextBox14_Change() 
Range("b104") = TextBox14 
End Sub 
Private Sub TextBox15_Change() 
Range("b109") = TextBox15 
End Sub 
Private Sub TextBox16_Change() 
Range("b110") = TextBox16 
End Sub 
Private Sub TextBox17_Change() 
Range("b111") = TextBox17 
End Sub 
Private Sub TextBox18_Change() 
Range("b112") = TextBox18 
End Sub 
Private Sub TextBox19_Change() 
Range("b113") = TextBox19 
End Sub 
Private Sub TextBox20_Change() 
Range("b114") = TextBox20 
End Sub 
Private Sub TextBox21_Change() 
Range("b119") = TextBox21 
End Sub 
Private Sub TextBox22_Change() 
Range("b120") = TextBox22 
End Sub 
Private Sub TextBox23_Change() 
Range("b121") = TextBox23 
End Sub 
Private Sub TextBox24_Change() 
Range("b122") = TextBox24 
End Sub 
Private Sub TextBox25_Change() 
Range("b123") = TextBox25 
End Sub 
Private Sub TextBox26_Change() 
Range("b124") = TextBox26 
End Sub 
Private Sub TextBox27_Change() 
Range("b129") = TextBox27 
End Sub 
Private Sub TextBox28_Change() 
Range("b130") = TextBox28 
End Sub 
Private Sub UserForm_Activate() 
TextBox13 = Range("aa94") 
TextBox14 = Range("aa104") 
TextBox15 = Range("aa109") 
TextBox16 = Range("aa110") 
TextBox17 = Range("aa111") 
TextBox18 = Range("aa112") 
TextBox19 = Range("aa113") 
TextBox20 = Range("aa114") 
TextBox21 = Range("aa119") 
TextBox22 = Range("aa120") 
TextBox23 = Range("aa121") 
TextBox24 = Range("aa122") 
TextBox25 = Range("aa123") 
TextBox26 = Range("aa124") 
TextBox27 = Range("aa129") 
TextBox28 = Range("aa130") 
End Sub 
Private Sub UserForm_Deactivate() 
Range("aa94") = Range("b945") 
Range("aa104") = Range("b104") 
Range("aa109") = Range("b109") 
Range("aa110") = Range("b110") 
Range("aa111") = Range("b111") 
Range("aa112") = Range("b112") 
Range("aa113") = Range("b113") 
Range("aa114") = Range("b114") 
Range("aa119") = Range("b119") 
Range("aa120") = Range("b120") 
Range("aa121") = Range("b121") 
Range("aa122") = Range("b122") 
Range("aa123") = Range("b123") 
Range("aa124") = Range("b124") 
Range("aa129") = Range("b129") 
Range("aa130") = Range("b130") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
NOTE: Dialog boxes (UserForms5 & 5a, UserForm6 & 6a and UserForm7 & 7a) will not be given here 
as they are similar to the ones given above (UserForm4 & 4a) and those given below (Userform8 & 8a), 
except with the necessary modifications to reflect the number of buses in the system. 
UserForm8 (load flow for 3 feeders, 10­bus system) 
Private Sub CommandButton1_Click() 
Range("ae65") = Range("b65") 
Range("ae66") = Range("b66") 
Range("ae67") = Range("b67") 
Range("ae68") = Range("b68") 
Range("ae69") = Range("b69") 
Range("ae70") = Range("b70") 
Range("ae71") = Range("b71") 
Range("ae72") = Range("b72") 
Range("ae73") = Range("b73") 
Range("ae74") = Range("b74") 
Range("ae75") = Range("b75") 
Range("ae76") = Range("b76") 
Range("ae77") = Range("b77") 
Range("ae78") = Range("b78") 
Range("ae79") = Range("b79") 
Range("ae80") = Range("b80") 
Range("ae81") = Range("b81") 
Range("ae82") = Range("b82") 
Range("ae83") = Range("b83") 
Range("ae84") = Range("b84") 
Range("ae85") = Range("b85") 
Range("ae86") = Range("b86") 
Range("ae87") = Range("b87") 
Range("ae88") = Range("b88") 
Range("ae89") = Range("b89") 
Range("ae90") = Range("b90") 
Range("ae91") = Range("b91") 
Range("ae92") = Range("b92") 
Range("ae93") = Range("b93") 
Range("ae94") = Range("b94") 
Range("ae95") = Range("b95") 
Range("ae96") = Range("b96") 
Range("ae97") = Range("b97") 
Unload UserForm8 
UserForm8a.Show 
End Sub 
Private Sub CommandButton2_Click() 
'reset button 
TextBox13 = Range("ae65") 
TextBox14 = Range("ae66") 
TextBox15 = Range("ae67") 
TextBox16 = Range("ae68") 
TextBox17 = Range("ae69") 
TextBox18 = Range("ae70") 
TextBox19 = Range("ae71") 
TextBox20 = Range("ae72") 
TextBox21 = Range("ae73") 
TextBox22 = Range("ae74") 
TextBox23 = Range("ae75") 
TextBox24 = Range("ae76") 
TextBox25 = Range("ae77") 
TextBox26 = Range("ae78") 
TextBox27 = Range("ae79") 
TextBox28 = Range("ae80") 
TextBox29 = Range("ae81") 
TextBox30 = Range("ae82") 
TextBox31 = Range("ae83") 
TextBox32 = Range("ae84") 
TextBox33 = Range("ae85") 
TextBox34 = Range("ae86") 
TextBox35 = Range("ae87") 
TextBox36 = Range("ae88") 
TextBox37 = Range("ae89") 
TextBox38 = Range("ae90") 
TextBox39 = Range("ae91") 
TextBox40 = Range("ae92") 
TextBox41 = Range("ae93") 
TextBox42 = Range("ae94") 
TextBox43 = Range("ae95") 
TextBox44 = Range("ae96") 
TextBox45 = Range("ae97") 
End Sub 
Private Sub TextBox13_Change() 
Range("b65") = TextBox13 
End Sub 
Private Sub TextBox14_Change() 
Range("b66") = TextBox14 
End Sub 
Private Sub TextBox15_Change() 
Range("b67") = TextBox15 
End Sub 
Private Sub TextBox16_Change() 
Range("b68") = TextBox16 
End Sub 
Private Sub TextBox17_Change() 
Range("b69") = TextBox17 
End Sub 
Private Sub TextBox18_Change() 
Range("b70") = TextBox18 
End Sub 
Private Sub TextBox19_Change() 
Range("b71") = TextBox19 
End Sub 
Private Sub TextBox20_Change() 
Range("b72") = TextBox20 
End Sub 
Private Sub TextBox21_Change() 
Range("b73") = TextBox21 
End Sub 
Private Sub TextBox22_Change() 
Range("b74") = TextBox22 
End Sub 
Private Sub TextBox23_Change() 
Range("b75") = TextBox23 
End Sub 
Private Sub TextBox24_Change() 
Range("b76") = TextBox24 
End Sub 
Private Sub TextBox25_Change() 
Range("b77") = TextBox25 
End Sub 
Private Sub TextBox26_Change() 
Range("b78") = TextBox26 
End Sub 
Private Sub TextBox27_Change() 
Range("b79") = TextBox27 
End Sub 
Private Sub TextBox28_Change() 
Range("b80") = TextBox28 
End Sub 
Private Sub TextBox29_Change() 
Range("b81") = TextBox29 
End Sub 
Private Sub TextBox30_Change() 
Range("b82") = TextBox30 
End Sub 
Private Sub TextBox31_Change() 
Range("b83") = TextBox31 
End Sub 
Private Sub TextBox32_Change() 
Range("b84") = TextBox32 
End Sub 
Private Sub TextBox33_Change() 
Range("b85") = TextBox33 
End Sub 
Private Sub TextBox34_Change() 
Range("b86") = TextBox34 
End Sub 
Private Sub TextBox35_Change() 
Range("b87") = TextBox35 
End Sub 
Private Sub TextBox36_Change() 
Range("b88") = TextBox36 
End Sub 
Private Sub TextBox37_Change() 
Range("b89") = TextBox37 
End Sub 
Private Sub TextBox38_Change() 
Range("b90") = TextBox38 
End Sub 
Private Sub TextBox39_Change() 
Range("b91") = TextBox39 
End Sub 
Private Sub TextBox40_Change() 
Range("b92") = TextBox40 
End Sub 
Private Sub TextBox41_Change() 
Range("b93") = TextBox41 
End Sub 
Private Sub TextBox42_Change() 
Range("b94") = TextBox42 
End Sub 
Private Sub TextBox43_Change() 
Range("b95") = TextBox43 
End Sub 
Private Sub TextBox44_Change() 
Range("b96") = TextBox44 
End Sub 
Private Sub TextBox45_Change() 
Range("b97") = TextBox45 
End Sub 
Private Sub UserForm_Activate() 
TextBox13 = Range("ae65") 
TextBox14 = Range("ae66") 
TextBox15 = Range("ae67") 
TextBox16 = Range("ae68") 
TextBox17 = Range("ae69") 
TextBox18 = Range("ae70") 
TextBox19 = Range("ae71") 
TextBox20 = Range("ae72") 
TextBox21 = Range("ae73") 
TextBox22 = Range("ae74") 
TextBox23 = Range("ae75") 
TextBox24 = Range("ae76") 
TextBox25 = Range("ae77") 
TextBox26 = Range("ae78") 
TextBox27 = Range("ae79") 
TextBox28 = Range("ae80") 
TextBox29 = Range("ae81") 
TextBox30 = Range("ae82") 
TextBox31 = Range("ae83") 
TextBox32 = Range("ae84") 
TextBox33 = Range("ae85") 
TextBox34 = Range("ae86") 
TextBox35 = Range("ae87") 
TextBox36 = Range("ae88") 
TextBox37 = Range("ae89") 
TextBox38 = Range("ae90") 
TextBox39 = Range("ae91") 
TextBox40 = Range("ae92") 
TextBox41 = Range("ae93") 
TextBox42 = Range("ae94") 
TextBox43 = Range("ae95") 
TextBox44 = Range("ae96") 
TextBox45 = Range("ae97") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
Private Sub UserForm_Deactivate() 
Range("ae65") = Range("b65") 
Range("ae66") = Range("b66") 
Range("ae67") = Range("b67") 
Range("ae68") = Range("b68") 
Range("ae69") = Range("b69") 
Range("ae70") = Range("b70") 
Range("ae71") = Range("b71") 
Range("ae72") = Range("b72") 
Range("ae73") = Range("b73") 
Range("ae74") = Range("b74") 
Range("ae75") = Range("b75") 
Range("ae76") = Range("b76") 
Range("ae77") = Range("b77") 
Range("ae78") = Range("b78") 
Range("ae79") = Range("b79") 
Range("ae80") = Range("b80") 
Range("ae81") = Range("b81") 
Range("ae82") = Range("b82") 
Range("ae83") = Range("b83") 
Range("ae84") = Range("b84") 
Range("ae85") = Range("b85") 
Range("ae86") = Range("b86") 
Range("ae87") = Range("b87") 
Range("ae88") = Range("b88") 
Range("ae89") = Range("b89") 
Range("ae90") = Range("b90") 
Range("ae91") = Range("b91") 
Range("ae92") = Range("b92") 
Range("ae93") = Range("b93") 
Range("ae94") = Range("b94") 
Range("ae95") = Range("b95") 
Range("ae96") = Range("b96") 
Range("ae97") = Range("b97") 
End Sub 
UserForm8a (load flow for 3 feeders, 10­bus system) 
Private Sub CommandButton1_Click() 
Range("ae98") = Range("b98") 
Range("ae99") = Range("b99") 
Range("ae100") = Range("b100") 
Range("ae101") = Range("b101") 
Range("ae102") = Range("b102") 
Range("ae103") = Range("b103") 
Range("ae104") = Range("b104") 
Range("ae105") = Range("b105") 
Range("ae106") = Range("b106") 
Range("ae107") = Range("b107") 
Range("ae108") = Range("b108") 
Range("ae109") = Range("b109") 
Range("ae110") = Range("b110") 
Range("ae111") = Range("b111") 
Range("ae112") = Range("b112") 
Range("ae113") = Range("b113") 
Range("ae114") = Range("b114") 
Range("ae115") = Range("b115") 
Range("ae116") = Range("b116") 
Range("ae117") = Range("b117") 
Range("ae118") = Range("b118") 
Range("ae119") = Range("b119") 
Range("ae120") = Range("b120") 
Range("ae121") = Range("b121") 
Range("ae122") = Range("b122") 
Range("ae123") = Range("b123") 
Range("ae124") = Range("b124") 
Range("ae125") = Range("b125") 
Range("ae126") = Range("b126") 
Range("ae127") = Range("b127") 
Range("ae128") = Range("b128") 
Range("ae129") = Range("b129") 
Range("ae130") = Range("b130") 
Unload UserForm8a 
UserForm8.Show 
End Sub 
Private Sub CommandButton2_Click() 
'reset button 
TextBox13 = Range("ae98") 
TextBox14 = Range("ae99") 
TextBox15 = Range("ae100") 
TextBox16 = Range("ae101") 
TextBox17 = Range("ae102") 
TextBox18 = Range("ae103") 
TextBox19 = Range("ae104") 
TextBox20 = Range("ae105") 
TextBox21 = Range("ae106") 
TextBox22 = Range("ae107") 
TextBox23 = Range("ae108") 
TextBox24 = Range("ae109") 
TextBox25 = Range("ae110") 
TextBox26 = Range("ae111") 
TextBox27 = Range("ae112") 
TextBox28 = Range("ae113") 
TextBox29 = Range("ae114") 
TextBox30 = Range("ae115") 
TextBox31 = Range("ae116") 
TextBox32 = Range("ae117") 
TextBox33 = Range("ae118") 
TextBox34 = Range("ae119") 
TextBox35 = Range("ae120") 
TextBox36 = Range("ae121") 
TextBox37 = Range("ae122") 
TextBox38 = Range("ae123") 
TextBox39 = Range("ae124") 
TextBox40 = Range("ae125") 
TextBox41 = Range("ae126") 
TextBox42 = Range("ae127") 
TextBox43 = Range("ae128") 
TextBox44 = Range("ae129") 
TextBox45 = Range("ae130") 
End Sub 
Private Sub CommandButton3_Click() 
Unload UserForm8a 
Range("b132").Select 
End Sub 
Private Sub TextBox13_Change() 
Range("b98") = TextBox13 
End Sub 
Private Sub TextBox14_Change() 
Range("b99") = TextBox14 
End Sub 
Private Sub TextBox15_Change() 
Range("b100") = TextBox15 
End Sub 
Private Sub TextBox16_Change() 
Range("b101") = TextBox16 
End Sub 
Private Sub TextBox17_Change() 
Range("b102") = TextBox17 
End Sub 
Private Sub TextBox18_Change() 
Range("b103") = TextBox18 
End Sub 
Private Sub TextBox19_Change() 
Range("b104") = TextBox19 
End Sub 
Private Sub TextBox20_Change() 
Range("b105") = TextBox20 
End Sub 
Private Sub TextBox21_Change() 
Range("b106") = TextBox21 
End Sub 
Private Sub TextBox22_Change() 
Range("b107") = TextBox22 
End Sub 
Private Sub TextBox23_Change() 
Range("b108") = TextBox23 
End Sub 
Private Sub TextBox24_Change() 
Range("b109") = TextBox24 
End Sub 
Private Sub TextBox25_Change() 
Range("b110") = TextBox25 
End Sub 
Private Sub TextBox26_Change() 
Range("b111") = TextBox26 
End Sub 
Private Sub TextBox27_Change() 
Range("b112") = TextBox27 
End Sub 
Private Sub TextBox28_Change() 
Range("b113") = TextBox28 
End Sub 
Private Sub TextBox29_Change() 
Range("b114") = TextBox29 
End Sub 
Private Sub TextBox30_Change() 
Range("b115") = TextBox30 
End Sub 
Private Sub TextBox31_Change() 
Range("b116") = TextBox31 
End Sub 
Private Sub TextBox32_Change() 
Range("b117") = TextBox32 
End Sub 
Private Sub TextBox33_Change() 
Range("b118") = TextBox33 
End Sub 
Private Sub TextBox34_Change() 
Range("b119") = TextBox34 
End Sub 
Private Sub TextBox35_Change() 
Range("b120") = TextBox35 
End Sub 
Private Sub TextBox36_Change() 
Range("b121") = TextBox36 
End Sub 
Private Sub TextBox37_Change() 
Range("b122") = TextBox37 
End Sub 
Private Sub TextBox38_Change() 
Range("b123") = TextBox38 
End Sub 
Private Sub TextBox39_Change() 
Range("b124") = TextBox39 
End Sub 
Private Sub TextBox40_Change() 
Range("b125") = TextBox40 
End Sub 
Private Sub TextBox41_Change() 
Range("b126") = TextBox41 
End Sub 
Private Sub TextBox42_Change() 
Range("b127") = TextBox42 
End Sub 
Private Sub TextBox43_Change() 
Range("b128") = TextBox43 
End Sub 
Private Sub TextBox44_Change() 
Range("b129") = TextBox44 
End Sub 
Private Sub TextBox45_Change() 
Range("b130") = TextBox45 
End Sub 
Private Sub UserForm_Activate() 
TextBox13 = Range("ae98") 
TextBox14 = Range("ae99") 
TextBox15 = Range("ae100") 
TextBox16 = Range("ae101") 
TextBox17 = Range("ae102") 
TextBox18 = Range("ae103") 
TextBox19 = Range("ae104") 
TextBox20 = Range("ae105") 
TextBox21 = Range("ae106") 
TextBox22 = Range("ae107") 
TextBox23 = Range("ae108") 
TextBox24 = Range("ae109") 
TextBox25 = Range("ae110") 
TextBox26 = Range("ae111") 
TextBox27 = Range("ae112") 
TextBox28 = Range("ae113") 
TextBox29 = Range("ae114") 
TextBox30 = Range("ae115") 
TextBox31 = Range("ae116") 
TextBox32 = Range("ae117") 
TextBox33 = Range("ae118") 
TextBox34 = Range("ae119") 
TextBox35 = Range("ae120") 
TextBox36 = Range("ae121") 
TextBox37 = Range("ae122") 
TextBox38 = Range("ae123") 
TextBox39 = Range("ae124") 
TextBox40 = Range("ae125") 
TextBox41 = Range("ae126") 
TextBox42 = Range("ae127") 
TextBox43 = Range("ae128") 
TextBox44 = Range("ae129") 
TextBox45 = Range("ae130") 
End Sub 
Private Sub UserForm_Click() 
End Sub 
Private Sub UserForm_Deactivate() 
Range("ae98") = Range("b98") 
Range("ae99") = Range("b99") 
Range("ae100") = Range("b100") 
Range("ae101") = Range("b101") 
Range("ae102") = Range("b102") 
Range("ae103") = Range("b103") 
Range("ae104") = Range("b104") 
Range("ae105") = Range("b105") 
Range("ae106") = Range("b106") 
Range("ae107") = Range("b107") 
Range("ae108") = Range("b108") 
Range("ae109") = Range("b109") 
Range("ae110") = Range("b110") 
Range("ae111") = Range("b111") 
Range("ae112") = Range("b112") 
Range("ae113") = Range("b113") 
Range("ae114") = Range("b114") 
Range("ae115") = Range("b115") 
Range("ae116") = Range("b116") 
Range("ae117") = Range("b117") 
Range("ae118") = Range("b118") 
Range("ae119") = Range("b119") 
Range("ae120") = Range("b120") 
Range("ae121") = Range("b121") 
Range("ae122") = Range("b122") 
Range("ae123") = Range("b123") 
Range("ae124") = Range("b124") 
Range("ae125") = Range("b125") 
Range("ae126") = Range("b126") 
Range("ae127") = Range("b127") 
Range("ae128") = Range("b128") 
Range("ae129") = Range("b129") 
Range("ae130") = Range("b130") 
End Sub 
MODULES 
Sub MySub11() 
'INPUT "series resistance of the slack bus to bus 2 in p.u. ="; r12 
'INPUT "series reactance of the slack bus to bus 2 in p.u."; x12 
'INPUT "MVAC per line  slack bus to 2"; mvac12 
'INPUT "voltage at the slack bus in p.u."; v1 
'INPUT "voltage at bus 2 in p.u. ="; v2 
'INPUT "phase angle at bus 1 in rad. ="; d1 
'INPUT "phase angle at bus 2 in rad. ="; d2 
'INPUT "active power in mw scheduled at bus 1 (slack)"; p1 
'INPUT "active power in mw at bus 2"; p2 
'INPUT "reactive power in mvar scheduled at bus 1"; q1 
'INPUT "reactive power in mvar scheduled at bus 2"; q2 
UserForm1.Show 
r12 = Range("b2") 
x12 = Range("b3") 
mvac12 = Range("b4") 
v1 = Range("b5") 
d1 = Range("b6") 
v2 = Range("b7") 
d2 = Range("b8") 
p1 = Range("b9") 
p2 = Range("b10") 
q1 = Range("b11") 
q2 = Range("b12") 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
y12 = 1 / z12 
an12 = Atn(x12 / r12) 
g12 = y12 * Cos(­an12) 
b12 = y12 * Sin(­an12) 
yc12 = (mvac12) / 200 
gb11 = g12 
gb22 = g12 
gb12 = ­g12 
gb21 = ­g12 
bb11 = b12 + yc12 
bb22 = b12 + yc12 
bb12 = ­b12 
bb21 = ­b12 
pb2 = ((gb22) * ((v2) ^ 2)) + ((v2 * v1) * (­y12 * Cos(­an12 + d1 ­ d2))) 
diffp2 = ((p2 / 100) ­ pb2) / v2 
d21 = ­(diffp2) / bb22 
dq2 = (1 / v2) * ((q2 / 100) + ((bb22) * (v2 ^ 2)) + ((v1 * v2) * (­y12 * Sin(­an12 + d1 ­ d21)))) 
dv2 = ­(dq2) / bb22 
v21 = v2 + dv1 
pb21 = ((gb22) * ((v21) ^ 2)) + ((v21 * v1) * (­y12 * Cos(­an12 + d1 ­ d21))) 
diffp21 = ((p2 / 100) ­ pb21) / v21 
d22 = ­(diffp21) / bb22 
dd22 = d22 + d21 
dq21 = (1 / v21) * ((q2 / 100) + ((bb22) * (v21 ^ 2)) + ((v1 * v21) * (­y12 * Sin(­an12 + d1 ­ dd22)))) 
dv22 = ­(dq21) / bb22 
v22 = v21 + dv22 
pb22 = ((gb22) * ((v22) ^ 2)) + ((v22 * v1) * (­y12 * Cos(­an12 + d1 ­ dd22))) 
diffp22 = ((p2 / 100) ­ pb22) / v22 
d23 = ­(diffp22) / bb22 
dd23 = d23 + dd22 
dq22 = (1 / v22) * ((q2 / 100) + ((bb22) * (v22 ^ 2)) + ((v1 * v22) * (­y12 * Sin(­an12 + d1 ­ dd23)))) 
dv23 = ­(dq22) / bb22 
v23 = v22 + dv23 
Range("b14") = v23 
Range("b15") = dd23 
Range("c15") = dd23 * 180 / 3.14159265 
Range("b16") = (((v1 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­an12 + dd23 ­ d1)))) 
Range("b17") = (((v23 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­an12 ­ dd23 + d1)))) 
Range("b18") = (­(v1 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­an12 + dd23 ­ d1))) 
Range("b19") = (­(v23 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­an12 ­ dd23 + d1))) 
Range("b20") = diffp2 
Range("c20") = dq2 
Range("b21") = diffp21 
Range("c21") = dq21 
Range("b22") = diffp22 
Range("c22") = dq22 
'Print "voltage at bus 2: "; v23 
'Print "phase angle at bus 2: "; dd23; "rad", "in degrees="; dd23 * 180 / 3.14159265 
'Print " all active and reactive power values are in p.u." 
'Print "active power in p.u.from bus 1 towards 2:"; (((v1 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­
an12 + dd23 ­ d1)))) 
'Print "active power in p.u.from bus 2 towards 1:"; (((v23 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­
an12 ­ dd23 + d1)))) 
'Print "reactive power from bus 1 towards 2:"; (­(v1 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­
an12 + dd23 ­ d1))) 
'Print "reactive power from bus 2 towards 1:"; (­(v23 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­
an12 ­ dd23 + d1))) 
'Print "mismatches", diffp2, diffp21, diffp22, dq2, dq21, dq22 
End Sub 
Sub MySub12() 
'INPUT "series resistance of the slack bus to bus 2 in p.u. ="; r12 
'INPUT "series resistance from bus 2 to bus 3 in p.u. ="; r23 
'INPUT "series reactance of the slack bus to bus 2 in p.u. ="; x12 
'INPUT "series reactance from bus 2 to bus 3 in p.u."; x23 
'INPUT "MVAC per line slack bus to 2"; mvac12 
'INPUT "MVAC per line bus 2 to 3"; mvac23 
'INPUT "voltage at the slack bus in p.u. ="; v1 
'INPUT "voltage at bus 2 in p.u. ="; v2 
'INPUT "voltage at bus 3 in p.u. ="; v3 
'INPUT "phase angle at bus 1 in rad. ="; d1 
'INPUT "phase angle at bus 2 in rad. ="; d2 
'INPUT "phase angle at bus 3 in rad. ="; d3 
'INPUT "active power in mw scheduled at bus 1 (slack)"; p1 
'INPUT "active power in mw at bus 2"; p2 
'INPUT "active power in mw at bus 3"; p3 
'INPUT "reactive power in mvar scheduled at bus 1"; q1 
'INPUT "reactive power in mvar scheduled at bus 2"; q2 
'INPUT "reactive power in mvar scheduled at bus 3"; q3 
UserForm2.Show 
r12 = Range("b26") 
r23 = Range("b27") 
x12 = Range("b28") 
x23 = Range("b29") 
mvac12 = Range("b30") 
mvac23 = Range("b31") 
v1 = Range("b32") 
v2 = Range("b33") 
v3 = Range("b34") 
d1 = Range("b35") 
d2 = Range("b36") 
d3 = Range("b37") 
p1 = Range("b38") 
p2 = Range("b39") 
p3 = Range("b40") 
q1 = Range("b41") 
q2 = Range("b42") 
q3 = Range("b43") 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z23 = ((r23) ^ 2 + (x23) ^ 2) ^ 0.5 
y12 = 1 / z12 
y23 = 1 / z23 
an12 = Atn(x12 / r12) 
an23 = Atn(x23 / r23) 
g12 = y12 * Cos(­an12) 
g23 = y23 * Cos(­an23) 
b12 = y12 * Sin(­an12) 
b23 = y23 * Sin(­an23) 
yc12 = (mvac12) / 200 
yc23 = (mvac23) / 200 
gb11 = g12 
gb22 = g12 + g23 
gb33 = g23 
gb12 = ­g12 
gb21 = ­g12 
gb23 = ­g23 
gb32 = ­g23 
bb11 = b12 + yc12 
bb22 = b12 + yc12 + b23 + yc23 
bb33 = b23 + yc23 
bb12 = ­b12 
bb21 = ­b12 
bb23 = ­b23 
bb32 = ­b23 
pb2 = ((gb22) * ((v2) ^ 2)) + ((v2 * v1) * (­y12 * Cos(­an12 + d1 ­ d2)) + (v2 * v3) * (­y23 * Cos(­
an23 + d3 ­ d2))) 
pb3 = ((gb33) * ((v3) ^ 2)) + ((v2 * v3) * (­y23 * Cos(­an23 + d2 ­ d3))) 
diffp2 = ((p2 / 100) ­ pb2) / v2 
diffp3 = ((p3 / 100) ­ pb3) / v3 
deter = bb22 * (bb33) ­ bb23 * (bb32) 
aa11 = ­bb33 / deter 
aa12 = bb23 / deter 
aa21 = bb32 / deter 
aa22 = ­bb22 / deter 
d21 = (diffp2 * aa11) + (aa12 * diffp3) 
d31 = (aa21 * diffp2) + (aa22 * diffp3) 
dq2 = (1 / v2) * ((q2 / 100) + ((bb22) * (v2 ^ 2)) + ((v1 * v2) * (­y12 * Sin(­an12 + d1 ­ d21))) + ((v3 * 
v2) * (­y23 * Sin(­an23 + d31 ­ d21)))) 
dq3 = (1 / v3) * ((q3 / 100) + ((bb33) * (v3 ^ 2)) + ((v3 * v2) * (­y23 * Sin(­an23 + d21 ­ d31)))) 
dv2 = (aa11 * dq2) + (aa12 * dq3) 
dv3 = (aa21 * dq2) + (aa22 * dq3) 
v21 = v2 + dv2 
v31 = v3 + dv3 
pb21 = ((gb22) * ((v21) ^ 2)) + ((v21 * v1) * (­y12 * Cos(­an12 + d1 ­ d21)) + (v21 * v31) * (­y23 * 
Cos(­an23 ++ d31 ­ d21))) 
pb31 = ((gb33) * ((v31) ^ 2)) + ((v21 * v31) * (­y23 * Cos(­an23 + d21 ­ d31))) 
diffp21 = ((p2 / 100) ­ pb21) / v21 
diffp31 = ((p3 / 100) ­ pb31) / v31 
dd22 = (diffp21 * aa11) + (aa12 * diffp31) 
dd32 = (aa21 * diffp21) + (aa22 * diffp31) 
d22 = d21 + dd22 
d32 = d31 + dd32 
dq21 = (1 / v21) * ((q2 / 100) + ((bb22) * (v21 ^ 2)) + ((v1 * v21) * (­y12 * Sin(­an12 + d1 ­ d22))) + 
((v31 * v21) * (­y23 * Sin(­an23 + d32 ­ d22)))) 
dq31 = (1 / v31) * ((q3 / 100) + ((bb33) * (v31 ^ 2)) + ((v31 * v21) * (­y23 * Sin(­an23 + d22 ­ d32)))) 
dv21 = (aa11 * dq21) + (aa12 * dq31) 
dv31 = (aa12 * dq21) + (aa22 * dq31) 
v22 = v21 + dv21 
v32 = v31 + dv31 
pb22 = ((gb22) * ((v22) ^ 2)) + ((v22 * v1) * (­y12 * Cos(­an12 + d1 ­ d22)) + (v22 * v32) * (­y23 * 
Cos(­an23 ++ d32 ­ d22))) 
pb32 = ((gb33) * ((v32) ^ 2)) + ((v22 * v32) * (­y23 * Cos(­an23 + d22 ­ d32))) 
diffp22 = ((p2 / 100) ­ pb22) / v22 
diffp32 = ((p3 / 100) ­ pb32) / v32 
dd23 = (diffp22 * aa11) + (aa12 * diffp32) 
dd33 = (aa21 * diffp22) + (aa22 * diffp32) 
d23 = d22 + dd23 
d33 = d32 + dd33 
dq22 = (1 / v22) * ((q2 / 100) + ((bb22) * (v22 ^ 2)) + ((v1 * v22) * (­y12 * Sin(­an12 + d1 ­ d23))) + 
((v32 * v22) * (­y23 * Sin(­an23 + d33 ­ d23)))) 
dq32 = (1 / v32) * ((q3 / 100) + ((bb33) * (v32 ^ 2)) + ((v32 * v22) * (­y23 * Sin(­an23 + d23 ­ d33)))) 
dv22 = (aa11 * dq22) ­ (aa12 * dq32) 
dv32 = ­(aa12 * dq22) + (aa22 * dq32) 
v23 = v22 + dv22 
v33 = v32 + dv32 
Range("b45") = v23 
Range("b46") = v33 
Range("b47") = d23 
Range("c47") = d23 * 180 / 3.14159265 
Range("b48") = d33 
Range("c48") = d33 * 180 / 3.14159265 
Range("b49") = (((v1 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­an12 + d23 ­ d1)))) 
Range("b50") = (((v23 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­an12 ­ d23 + d1)))) 
Range("b51") = (((v23 ^ 2) * (g23)) + ((v23) * (v33) * (­y23) * (Cos(­an23 + d33 ­ d23)))) 
Range("b52") = (((v33 ^ 2) * (g23)) + ((v23) * (v33) * (­y23) * (Cos(­an23 ­ d33 + d23)))) 
Range("b53") = (­(v1 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­an12 + d23 ­ d1))) 
Range("b54") = (­(v23 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­an12 ­ d23 + d1))) 
Range("b55") = (­(v23 ^ 2) * (b23 + yc23) ­ (v23) * (v33) * (­y23) * (Sin(­an23 + d33 ­ d23))) 
Range("b56") = (­(v33 ^ 2) * (b23 + yc23) ­ (v23) * (v33) * (­y23) * (Sin(­an23 ­ d33 + d23))) 
Range("b57") = diffp2 
Range("c57") = dq2 
Range("b58") = diffp3 
Range("c58") = dq3 
Range("b59") = diffp21 
Range("c59") = dq21 
Range("b60") = diffp31 
Range("c60") = dq31 
Range("b61") = diffp22 
Range("c61") = dq22 
Range("b62") = diffp32 
Range("c62") = dq32 
'Print "voltage at bus 2: "; v23 
'Print "phase angle at bus 2: "; d23; "rad"; "in degrees:"; d23 * 180 / 3.14159265 
'Print "voltage at bus 3: "; v33 
'Print "phase angle at bus 3: "; d33; "rad"; "in degrees:"; d33 * 180 / 3.14159265 
'Print " all active and reactive power values are in p.u." 
'Print "active power in p.u.from bus 2 towards 3:"; (((v23 ^ 2) * (g23)) + ((v23) * (v33) * (­y23) * 
(Cos(­an23 + d33 ­ d23)))) 
'Print "active power in p.u.from bus 1 towards 2:"; (((v1 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­
an12 + d23 ­ d1)))) 
'Print "active power in p.u.from bus 2 towards 1:"; (((v23 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­
an12 ­ d23 + d1)))) 
'Print "active power in p.u.from bus 3 towards 2:"; (((v33 ^ 2) * (g23)) + ((v23) * (v33) * (­y23) * 
(Cos(­an23 ­ d33 + d23)))) 
'Print "reactive power from bus 2 towards 3:"; (­(v23 ^ 2) * (b23 + yc23) ­ (v23) * (v33) * (­y23) * 
(Sin(­an23 + d33 ­ d23))) 
'Print "reactive power from bus 1 towards 2:"; (­(v1 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­
an12 + d23 ­ d1))) 
'Print "reactive power from bus 2 towards 1:"; (­(v23 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­
an12 ­ d23 + d1))) 
'Print "reactive power from bus 3 towards 2:"; (­(v33 ^ 2) * (b23 + yc23) ­ (v23) * (v33) * (­y23) * 
(Sin(­an23 ­ d33 + d23))) 
'Print "mismatches", diffp2, diffp21, diffp22, dq2, dq21, dq22, diffp3, diffp31, diffp32, dq3, dq31, dq32 
End Sub 
Sub Mysub131() 
'Print "enter zeros for r and x if the circuit ends at a bus number less than 10" 
Dim d(30, 30) 
Dim dd(30, 30) 
Dim diffp(30, 30) 
Dim dq(30, 30) 
Dim dq1(30, 30) 
Dim dq2(30, 30) 
Dim dq3(30, 30) 
Dim dq4(30, 30) 
Dim dv(30, 30) 
Dim intv(30, 30) 
Dim intu(30, 30) 
Dim v(30, 30) 
Dim pb(30, 30) 
Dim pb1(30, 30) 
'If x47 = 0 And r47 = 0 And x58 = 0 And r58 = 0 And r69 = 0 And x69 = 0 And r710 = 0 And x710 = 0 
Then 
UserForm3.Show 
r12 = Range("b65") 
r23 = Range("b66") 
r24 = Range("b67") 
r25 = Range("b68") 
Range("b69") = "not applicable" 
Range("b70") = "not applicable" 
Range("b71") = "not applicable" 
Range("b72") = "not applicable" 
Range("b73") = "not applicable" 
x12 = Range("b74") 
x23 = Range("b75") 
x24 = Range("b76") 
x25 = Range("b77") 
Range("b78") = "not applicable" 
Range("b79") = "not applicable" 
Range("b80") = "not applicable" 
Range("b81") = "not applicable" 
Range("b82") = "not applicable" 
mvac12 = Range("b83") 
mvac23 = Range("b84") 
mvac24 = Range("b85") 
mvac25 = Range("b86") 
xmotst = Range("b87") 
Range("b88") = "not applicable" 
v1 = Range("b89") 
v(2, 1) = Range("b90") 
v(3, 1) = Range("b91") 
v(4, 1) = Range("b92") 
v(5, 1) = Range("b93") 
Range("b94") = "not applicable" 
Range("b95") = "not applicable" 
Range("b96") = "not applicable" 
Range("b97") = "not applicable" 
Range("b98") = "not applicable" 
d1 = Range("b99") 
d(2, 1) = Range("b100") 
d(3, 1) = Range("b101") 
d(4, 1) = Range("b102") 
d(5, 1) = Range("b103") 
Range("b104") = "not applicable" 
Range("b105") = "not applicable" 
Range("b106") = "not applicable" 
Range("b107") = "not applicable" 
Range("b108") = "not applicable" 
p1 = Range("b109") 
p2 = Range("b110") 
p3 = Range("b111") 
p4 = Range("b112") 
p5 = Range("b113") 
Range("b114") = "not applicable" 
Range("b115") = "not applicable" 
Range("b116") = "not applicable" 
Range("b117") = "not applicable" 
Range("b118") = "not applicable" 
q1 = Range("b119") 
q2 = Range("b120") 
q3 = Range("b121") 
q4 = Range("b122") 
q5 = Range("b123") 
Range("b124") = "not applicable" 
Range("b125") = "not applicable" 
Range("b126") = "not applicable" 
Range("b127") = "not applicable" 
Range("b128") = "not applicable" 
mvab = Range("b129") 
nit = Range("b130") 
r36 = 0.01 
x36 = 0.05 
p6 = 0 
q6 = 0 
v(6, 1) = 1 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z23 = ((r23) ^ 2 + (x23) ^ 2) ^ 0.5 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z25 = ((r25) ^ 2 + (x25) ^ 2) ^ 0.5 
z36 = ((r36) ^ 2 + (x36) ^ 2) ^ 0.5 
y12 = 1 / z12 
y23 = 1 / z23 
y24 = 1 / z24 
y25 = 1 / z25 
y36 = 1 / z36 
an12 = Atn(x12 / r12) 
an23 = Atn(x23 / r23) 
an24 = Atn(x24 / r24) 
an25 = Atn(x25 / r25) 
an36 = Atn(x36 / r36) 
b12 = y12 * Sin(­an12) 
b23 = y23 * Sin(­an23) 
b24 = y24 * Sin(­an24) 
b25 = y25 * Sin(­an25) 
b36 = y36 * Sin(­an36) 
yc12 = (mvac12) / mvab 
yc23 = (mvac23) / mvab 
yc24 = (mvac24) / mvab 
yc25 = (mvac25) / mvab 
g12 = y12 * Cos(­an12) 
g23 = y23 * Cos(­an23) 
g24 = y24 * Cos(­an24) 
g25 = y25 * Cos(­an25) 
g36 = y36 * Cos(­an36) 
gb22 = g12 + g23 + g24 + g25 
gb33 = g23 + g36 
gb44 = g24 
gb55 = g25 
gb66 = g36 
gb12 = ­g12 
gb21 = ­g12 
gb23 = ­g23 
gb32 = ­g23 
gb24 = ­g24 
gb42 = ­g24 
gb25 = ­g25 
gb52 = ­g25 
gb36 = ­g36 
gb63 = ­g36 
bb11 = b12 + yc12 
bb22 = b12 + b23 + yc23 + b24 + yc24 + b25 + yc25 
bb33 = b23 + b36 
bb55 = b25 
bb66 = b36 
If xmotst < 0 Then bb44 = b24 + (1 / xmotst) 
If xmotst = 0 Then bb44 = b24 
bb12 = ­b12 
bb21 = ­b12 
bb23 = ­b23 
bb32 = ­b23 
bb24 = ­b24 
bb42 = ­b24 
bb25 = ­b25 
bb52 = ­b25 
bb36 = ­b36 
bb63 = ­b36 
y110 = bb22 / bb22 
y120 = ­bb23 / ­bb22 
y130 = ­bb24 / ­bb22 
y140 = ­bb25 / ­bb22 
y150 = ­bb26 / ­bb22 
y220 = ­bb33 ­ (­bb32) * (­bb23) / (­bb22) 
y230 = ­bb34 ­ (­bb32) * (­bb24) / (­bb22) 
y240 = ­bb35 ­ (­bb32) * (­bb25) / ­bb22 
y250 = ­bb36 ­ (­bb32) * (­bb26) / ­bb22 
y320 = ­bb43 ­ (­bb42) * (­bb23) / ­bb22 
y330 = ­bb44 ­ (­bb42) * (­bb24) / ­bb22 
y340 = ­bb45 ­ (­bb42) * (­bb25) / ­bb22 
y350 = ­bb46 ­ (­bb42) * (­bb26) / ­bb22 
y420 = ­bb53 ­ (­bb52) * (­bb23) / ­bb22 
y430 = ­bb54 ­ (­bb52) * (­bb24) / ­bb22 
y440 = ­bb55 ­ (­bb52) * (­bb25) / ­bb22 
y450 = ­bb56 ­ (­bb52) * (­bb26) / ­bb22 
y520 = ­bb63 ­ (­bb62) * (­bb23) / ­bb22 
y530 = ­bb64 ­ (­bb62) * (­bb24) / ­bb22 
y540 = ­bb65 ­ (­bb62) * (­bb25) / ­bb22 
y550 = ­bb66 ­ (­bb62) * (­bb26) / ­bb22 
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
For i = 1 To nit 
pb1(2, i) = (v(2, i) * v(4, i)) * (­y24 * Cos(­an24 + d(4, i) ­ d(2, i))) + (v(2, i) * v(5, i)) * (­y25 * Cos(­
an25 + d(5, i) ­ d(2, i))) 
pb(2, i) = ((gb22) * ((v(2, i)) ^ 2)) + ((v(2, i) * v1) * (­y12 * Cos(­an12 + d1 ­ d(2, i))) + (v(2, i) * v(3, 
i)) * (­y23 * Cos(­an23 + d(3, i) ­ d(2, i))) + pb1(2, i)) 
pb(3, i) = ((gb33) * ((v(3, i)) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Cos(­an23 + d(2, i) ­ d(3, i))) + (v(3, i) 
* v(6, i)) * (­y36 * Cos(­an36 + d(6, i) ­ d(3, i)))) 
pb(4, i) = ((gb44) * ((v(4, i)) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Cos(­an24 + d(2, i) ­ d(4, i)))) 
pb(5, i) = ((gb55) * ((v(5, i)) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Cos(­an25 + d(2, i) ­ d(5, i)))) 
pb(6, i) = ((gb66) * ((v(6, i)) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Cos(­an36 + d(3, i) ­ d(6, i)))) 
diffp(2, i) = (1 / v(2, i)) * ((p2 / mvab) ­ pb(2, i)) 
diffp(3, i) = (1 / v(3, i)) * ((p3 / mvab) ­ pb(3, i)) 
diffp(4, i) = (1 / v(4, i)) * ((p4 / mvab) ­ pb(4, i)) 
diffp(5, i) = (1 / v(5, i)) * ((p5 / mvab) ­ pb(5, i)) 
diffp(6, i) = (1 / v(6, i)) * ((p6 / mvab) ­ pb(6, i)) 
intu(1, i) = diffp(2, i) / ­bb22 
intu(2, i) = (diffp(3, i) ­ (­bb32 * intu(1, i))) / y220 
intu(3, i) = (diffp(4, i) ­ (­bb42 * intu(1, i)) ­ (intu(2, i) * y320)) / y331 
intu(4, i) = (diffp(5, i) ­ (­bb52 * intu(1, i)) ­ (intu(2, i) * y420) ­ (intu(3, i) * y431)) / y442 
intu(5, i) = (diffp(6, i) ­ (intu(1, i)) * (­bb62) ­ (y520) * (intu(2, i)) ­ (intu(3, i)) * (y531) ­ (intu(4, i)) * 
(y542)) / y553 
dd(6, i) = intu(5, i) 
dd(5, i) = intu(4, i) ­ (dd(6, i) * y453) 
dd(4, i) = intu(3, i) ­ (dd(5, i) * y342) ­ (dd(6, i) * y352) 
dd(3, i) = intu(2, i) ­ (dd(4, i) * y231) ­ (y241 * dd(5, i)) ­ (y251 * dd(6, i)) 
dd(2, i) = intu(1, i) ­ (dd(3, i) * y120) ­ (y130 * dd(4, i)) ­ (y140 * dd(5, i)) ­ (dd(6, i) * y150) 
d(2, i + 1) = d(2, i) + dd(2, i) 
d(3, i + 1) = d(3, i) + dd(3, i) 
d(4, i + 1) = d(4, i) + dd(4, i) 
d(5, i + 1) = d(5, i) + dd(5, i) 
d(6, i + 1) = d(6, i) + dd(6, i) 
dq2(2, i) = ((v(2, i) * v(4, i)) * (­y24 * Sin(­an24 ­ d(2, i + 1) + d(4, i + 1)))) 
dq1(2, i) = ((v(2, i) * v(5, i)) * (­y25 * Sin(­an25 ­ d(2, i + 1) + d(5, i + 1)))) 
dq3(2, i) = ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(3, i + 1) ­ d(2, i + 1)))) 
dq4(2, i) = ((v1 * v(2, i)) * (­y12 * Sin(­an12 + d1 ­ d(2, i + 1)))) 
dq(2, i) = ((q2 / mvab) + ((bb22) * (v(2, i) ^ 2)) + dq1(2, i) + dq2(2, i) + dq3(2, i) + dq4(2, i)) / v(2, i) 
dq(3, i) = ((q3 / mvab) + ((bb33) * (v(3, i) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(2, i + 1) ­ 
d(3, i + 1)))) + ((v(3, i) * v(6, i)) * (­y36 * Sin(­an36 + d(3, i + 1) ­ d(3, i + 1))))) / v(3, i) 
dq(4, i) = ((q4 / mvab) + ((bb44) * (v(4, i) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Sin(­an24 ­ d(4, i + 1) + 
d(2, i + 1))))) / v(4, i) 
dq(5, i) = ((q5 / mvab) + ((bb55) * (v(5, i) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Sin(­an25 ­ d(5, i + 1) + 
d(2, i + 1))))) / v(5, i) 
dq(6, i) = ((q6 / mvab) + ((bb66) * (v(6, i) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Sin(­an36 ­ d(6, i + 1) + 
d(3, i + 1))))) / v(6, i) 
intv(1, i) = dq(2, i) / ­bb22 
intv(2, i) = (dq(3, i) ­ (­bb32 * intv(1, i))) / y220 
intv(3, i) = (dq(4, i) ­ (­bb42 * intv(1, i)) ­ (intv(2, i) * y320)) / y331 
intv(4, i) = (dq(5, i) ­ (­bb52 * intv(1, i)) ­ (intv(2, i) * y420) ­ (intv(3, i) * y431)) / y442 
intv(5, i) = (dq(6, i) ­ (intv(1, i)) * (­bb62) ­ (y520) * (intv(2, i)) ­ (intv(3, i)) * (y531) ­ (intv(4, i)) * 
(y542)) / y553 
dv(6, i) = intv(5, i) 
dv(5, i) = intv(4, i) ­ (dv(6, i) * y453) 
dv(4, i) = intv(3, i) ­ (dv(5, i) * y342) ­ (dv(6, i) * y352) 
dv(3, i) = intv(2, i) ­ (dv(4, i) * y231) ­ (y241 * dv(5, i)) ­ (y251 * dv(6, i)) 
dv(2, i) = intv(1, i) ­ (dv(3, i) * y120) ­ (y130 * dv(4, i)) ­ (y140 * dv(5, i)) ­ (dv(6, i) * y150) 
v(2, i + 1) = v(2, i) + dv(2, i) 
v(3, i + 1) = v(3, i) + dv(3, i) 
v(4, i + 1) = v(4, i) + dv(4, i) 
v(5, i + 1) = v(5, i) + dv(5, i) 
v(6, i + 1) = v(6, i) + dv(6, i) 
  
v(2, i) = v(2, i + 1) 
v(3, i) = v(3, i + 1) 
v(4, i) = v(4, i + 1) 
v(5, i) = v(5, i + 1) 
v(6, i) = v(6, i + 1) 
 d(2, i) = d(2, i + 1) 
 d(3, i) = d(3, i + 1) 
 d(4, i) = d(4, i + 1) 
 d(5, i) = d(5, i + 1) 
 d(6, i) = d(6, i + 1) 
Next i 
'Print "voltage at bus 2: "; v(2, i) 
'Print "phase angle at bus 2: "; d(2, i); "rad"; "in degrees:"; d(2, i) * 180 / 3.14159265 
'Print "voltage at bus 3: "; v(3, i) 
'Print "phase angle at bus 3: "; d(3, i); "rad"; "in degrees:"; d(3, i) * 180 / 3.14159265 
'Print "voltage at bus 4: "; v(4, i) 
'Print "phase angle at bus 4: "; d(4, i); "rad"; "in degrees:"; d(4, i) * 180 / 3.14159265 
'Print "voltage at bus 5: "; v(5, i) 
'Print "phase angle at bus 5: "; d(5, i); "rad"; "in degrees:"; d(5, i) * 180 / 3.14159265 
'Print "voltage at bus 6: "; v(6, i) 
'Print "phase angle at bus 6: "; d(6, i); "rad"; "in degrees:"; d(6, i) * 180 / 3.14159265 
act2 = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
act1 = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 
act6 = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
act5 = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 
act4 = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 
act3 = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
act8 = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 
act7 = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 
act9 = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 
act10 = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 
'Print "active power in p.u.from bus 2 towards 3:"; act1 
'Print "active power in p.u.from bus 1 towards 2:"; act2 
'Print "active power in p.u.from bus 2 towards 1:"; act3 
'Print "active power in p.u.from bus 3 towards 2:"; act4 
'Print "active power in p.u.from bus 4 towards 2:"; act5 
'Print "active power in p.u.from bus 2 towards 4:"; act6 
'Print "active power in p.u.from bus 5 towards 2:"; act7 
'Print "active power in p.u.from bus 2 towards 5:"; act8 
'Print "active power in p.u.from bus 3 towards 6:"; act9 
'Print "active power in p.u.from bus 6 towards 3:"; act10 
react1 = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 + d(3, i) 
­ d(2, i))))) 
react2 = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
react5 = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
react6 = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(4, i) 
­ d(2, i))))) 
react7 = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
react8 = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(5, i) 
­ d(2, i))))) 
react3 = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + d1 ­ d(2, 
i))))) 
react4 = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
react9 = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
react10 = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
'Print "reactive power from bus 2 towards 3:"; react1 
'Print "reactive power from bus 1 towards 2:"; react2 
'Print "reactive power from bus 2 towards 1:"; react3 
'Print "reactive power from bus 3 towards 2:"; react4 
'Print "reactive power from bus 4 towards 2:"; react5 
'Print "reactive power from bus 2 towards 4:"; react6 
'Print "reactive power from bus 5 towards 2:"; react7 
'Print "reactive power from bus 2 towards 5:"; react8 
'Print "reactive power from bus 3 towards 6:"; react9 
'Print "reactive power from bus 6 towards 3:"; react10 
For i = nit ­ 1 To nit 
'Print diffp(2, i), diffp(3, i), diffp(4, i), diffp(5, i), diffp(6, i), dq(2, i), dq(3, i), dq(4, i), dq(5, i), dq(6, i) 
Next i 
Range("a132") = "The voltage on bus 2 in pu" 
Range("b132") = v(2, i) 
Range("a133") = "The voltage on bus 3 in pu" 
Range("b133") = v(3, i) 
Range("a134") = "The voltage on bus 4 in pu" 
Range("b134") = v(4, i) 
Range("a135") = "The voltage on bus 5 in pu" 
Range("b135") = v(5, i) 
Range("a136") = "The voltage on bus 6 in pu" 
Range("b136") = "not applicable" 
Range("a137") = "The voltage on bus 7 in pu" 
Range("b137") = "not applicable" 
Range("a138") = "The voltage on bus 8 in pu" 
Range("b138") = "not applicable" 
Range("a139") = "The voltage on bus 9 in pu" 
Range("b139") = "not applicable" 
Range("a140") = "The voltage on bus 10 in pu" 
Range("b140") = "not applicable" 
Range("a141") = "The phase angle at bus 2 in rad. & degrees" 
Range("b141") = d(2, i) 
Range("c141") = d(2, i) * 180 / 3.14159265 
Range("a142") = "The phase angle at bus 3 in rad. & degrees" 
Range("b142") = d(3, i) 
Range("c142") = d(3, i) * 180 / 3.14159265 
Range("a143") = "The phase angle at bus 4 in rad. & degrees" 
Range("b143") = d(4, i) 
Range("c143") = d(4, i) * 180 / 3.14159265 
Range("a144") = "The phase angle at bus 5 in rad. & degrees" 
Range("b144") = d(5, i) 
Range("c144") = d(5, i) * 180 / 3.14159265 
Range("a145") = "The voltage on bus 6 in pu" 
Range("b145") = "not applicable" 
Range("c145") = "not applicable" 
Range("a146") = "The voltage on bus 7 in pu" 
Range("b146") = "not applicable" 
Range("c146") = "not applicable" 
Range("a147") = "The voltage on bus 8 in pu" 
Range("b147") = "not applicable" 
Range("c147") = "not applicable" 
Range("a148") = "The voltage on bus 9 in pu" 
Range("b148") = "not applicable" 
Range("c148") = "not applicable" 
Range("a149") = "The voltage on bus 10 in pu" 
Range("b149") = "not applicable" 
Range("c149") = "not applicable" 
Range("a150") = "The active power flowing from bus 1 to 2 in pu" 
Range("b150") = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
Range("a151") = "The active power flowing from bus 2 to 1 in pu" 
Range("b151") = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
Range("a152") = "The active power flowing from bus 2 to 3 in pu" 
Range("b152") = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 

Range("a153") = "The active power flowing from bus 3 to 2 in pu" 
Range("b153") = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 

Range("a154") = "The active power flowing from bus 2 to 4 in pu" 
Range("b154") = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 

Range("a155") = "The active power flowing from bus 4 to 2 in pu" 
Range("b155") = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 

Range("a156") = "The active power flowing from bus 2 to 5 in pu" 
Range("b156") = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 

Range("a157") = "The active power flowing from bus 5 to 2 in pu" 
Range("b157") = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 

Range("a158") = "The active power flowing from bus 3 to 6 in pu" 
Range("b158") = "not applicable" 
Range("a159") = "The active power flowing from bus 6 to 3 in pu" 
Range("b159") = "not applicable" 
Range("a160") = "The active power flowing from bus 4 to 7 in pu" 
Range("b160") = "not applicable" 
Range("a161") = "The active power flowing from bus 7 to 4 in pu" 
Range("b161") = "not applicable" 
Range("a162") = "The active power flowing from bus 5 to 8 in pu" 
Range("b162") = "not applicable" 
Range("a163") = "The active power flowing from bus 8 to 5 in pu" 
Range("b163") = "not applicable" 
Range("a164") = "The active power flowing from bus 6 to 9 in pu" 
Range("b164") = "not applicable" 
Range("a165") = "The active power flowing from bus 9 to 6 in pu" 
Range("b165") = "not applicable" 
Range("a166") = "The active power flowing from bus 7 to 10 in pu" 
Range("b166") = "not applicable" 
Range("a167") = "The active power flowing from bus 10 to 7 in pu" 
Range("b167") = "not applicable" 
Range("a168") = "The reactive power flowing from bus 1 to 2 in pu" 
Range("b168") = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
Range("a169") = "The reactive power flowing from bus 2 to 1 in pu" 
Range("b169") = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + 
d1 ­ d(2, i))))) 
Range("a170") = "The reactive power flowing from bus 2 to 3 in pu" 
Range("b170") = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 
+ d(3, i) ­ d(2, i))))) 
Range("a171") = "The reactive power flowing from bus 3 to 2 in pu" 
Range("b171") = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
Range("a172") = "The reactive power flowing from bus 2 to 4 in pu" 
Range("b172") = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 
+ d(4, i) ­ d(2, i))))) 
Range("a173") = "The reactive power flowing from bus 4 to 2 in pu" 
Range("b173") = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
Range("a174") = "The reactive power flowing from bus 2 to 5 in pu" 
Range("b174") = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 
+ d(5, i) ­ d(2, i))))) 
Range("a175") = "The reactive power flowing from bus 5 to 2 in pu" 
Range("b175") = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
Range("a176") = "The reactive power flowing from bus 3 to 6 in pu" 
Range("b176") = "not applicable" 
Range("a177") = "The reactive power flowing from bus 6 to 3 in pu" 
Range("b177") = "not applicable" 
Range("a178") = "The reactive power flowing from bus 4 to 7 in pu" 
Range("b178") = "not applicable" 
Range("a179") = "The reactive power flowing from bus 7 to 4 in pu" 
Range("b179") = "not applicable" 
Range("a180") = "The reactive power flowing from bus 5 to 8 in pu" 
Range("b180") = "not applicable" 
Range("a181") = "The reactive power flowing from bus 8 to 5 in pu" 
Range("b181") = "not applicable" 
Range("a182") = "The reactive power flowing from bus 6 to 9 in pu" 
Range("b182") = "not applicable" 
Range("a183") = "The reactive power flowing from bus 9 to 6 in pu" 
Range("b183") = "not applicable" 
Range("a184") = "The reactive power flowing from bus 7 to 10 in pu" 
Range("b184") = "not applicable" 
Range("a185") = "The reactive power flowing from bus 10 to 7 in pu" 
Range("b185") = "not applicable" 
End Sub 
Sub MySub132() 
'Print "enter zeros for r and x if the circuit ends at a bus number less than 10" 
Dim d(30, 30) 
Dim dd(30, 30) 
Dim diffp(30, 30) 
Dim dq(30, 30) 
Dim dq1(30, 30) 
Dim dq2(30, 30) 
Dim dq3(30, 30) 
Dim dq4(30, 30) 
Dim dv(30, 30) 
Dim intv(30, 30) 
Dim intu(30, 30) 
Dim v(30, 30) 
Dim pb(30, 30) 
Dim pb1(30, 30) 
'If x47 = 0 And r47 = 0 And x58 = 0 And r58 = 0 And r69 = 0 And x69 = 0 And r710 = 0 And x710 = 0 
Then 
UserForm4.Show 
r12 = Range("b65") 
r23 = Range("b66") 
r24 = Range("b67") 
r25 = Range("b68") 
r36 = Range("b69") 
Range("b70") = "not applicable" 
Range("b71") = "not applicable" 
Range("b72") = "not applicable" 
Range("b73") = "not applicable" 
x12 = Range("b74") 
x23 = Range("b75") 
x24 = Range("b76") 
x25 = Range("b77") 
x36 = Range("b78") 
Range("b79") = "not applicable" 
Range("b80") = "not applicable" 
Range("b81") = "not applicable" 
Range("b82") = "not applicable" 
mvac12 = Range("b83") 
mvac23 = Range("b84") 
mvac24 = Range("b85") 
mvac25 = Range("b86") 
xmotst = Range("b87") 
Range("b88") = "not applicable" 
v1 = Range("b89") 
v(2, 1) = Range("b90") 
v(3, 1) = Range("b91") 
v(4, 1) = Range("b92") 
v(5, 1) = Range("b93") 
v(6, 1) = Range("b94") 
Range("b95") = "not applicable" 
Range("b96") = "not applicable" 
Range("b97") = "not applicable" 
Range("b98") = "not applicable" 
d1 = Range("b99") 
d(2, 1) = Range("b100") 
d(3, 1) = Range("b101") 
d(4, 1) = Range("b102") 
d(5, 1) = Range("b103") 
d(6, 1) = Range("b104") 
Range("b105") = "not applicable" 
Range("b106") = "not applicable" 
Range("b107") = "not applicable" 
Range("b108") = "not applicable" 
p1 = Range("b109") 
p2 = Range("b110") 
p3 = Range("b111") 
p4 = Range("b112") 
p5 = Range("b113") 
p6 = Range("b114") 
Range("b115") = "not applicable" 
Range("b116") = "not applicable" 
Range("b117") = "not applicable" 
Range("b118") = "not applicable" 
q1 = Range("b119") 
q2 = Range("b120") 
q3 = Range("b121") 
q4 = Range("b122") 
q5 = Range("b123") 
q6 = Range("b124") 
Range("b125") = "not applicable" 
Range("b126") = "not applicable" 
Range("b127") = "not applicable" 
Range("b128") = "not applicable" 
mvab = Range("b129") 
nit = Range("b130") 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z23 = ((r23) ^ 2 + (x23) ^ 2) ^ 0.5 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z25 = ((r25) ^ 2 + (x25) ^ 2) ^ 0.5 
z36 = ((r36) ^ 2 + (x36) ^ 2) ^ 0.5 
y12 = 1 / z12 
y23 = 1 / z23 
y24 = 1 / z24 
y25 = 1 / z25 
y36 = 1 / z36 
an12 = Atn(x12 / r12) 
an23 = Atn(x23 / r23) 
an24 = Atn(x24 / r24) 
an25 = Atn(x25 / r25) 
an36 = Atn(x36 / r36) 
b12 = y12 * Sin(­an12) 
b23 = y23 * Sin(­an23) 
b24 = y24 * Sin(­an24) 
b25 = y25 * Sin(­an25) 
b36 = y36 * Sin(­an36) 
yc12 = (mvac12) / mvab 
yc23 = (mvac23) / mvab 
yc24 = (mvac24) / mvab 
yc25 = (mvac25) / mvab 
g12 = y12 * Cos(­an12) 
g23 = y23 * Cos(­an23) 
g24 = y24 * Cos(­an24) 
g25 = y25 * Cos(­an25) 
g36 = y36 * Cos(­an36) 
gb22 = g12 + g23 + g24 + g25 
gb33 = g23 + g36 
gb44 = g24 
gb55 = g25 
gb66 = g36 
gb12 = ­g12 
gb21 = ­g12 
gb23 = ­g23 
gb32 = ­g23 
gb24 = ­g24 
gb42 = ­g24 
gb25 = ­g25 
gb52 = ­g25 
gb36 = ­g36 
gb63 = ­g36 
bb11 = b12 + yc12 
bb22 = b12 + b23 + yc23 + b24 + yc24 + b25 + yc25 
bb33 = b23 + b36 
bb55 = b25 
bb66 = b36 
If xmotst < 0 Then bb44 = b24 + (1 / xmotst) 
If xmotst = 0 Then bb44 = b24 
bb12 = ­b12 
bb21 = ­b12 
bb23 = ­b23 
bb32 = ­b23 
bb24 = ­b24 
bb42 = ­b24 
bb25 = ­b25 
bb52 = ­b25 
bb36 = ­b36 
bb63 = ­b36 
y110 = bb22 / bb22 
y120 = ­bb23 / ­bb22 
y130 = ­bb24 / ­bb22 
y140 = ­bb25 / ­bb22 
y150 = ­bb26 / ­bb22 
y220 = ­bb33 ­ (­bb32) * (­bb23) / (­bb22) 
y230 = ­bb34 ­ (­bb32) * (­bb24) / (­bb22) 
y240 = ­bb35 ­ (­bb32) * (­bb25) / ­bb22 
y250 = ­bb36 ­ (­bb32) * (­bb26) / ­bb22 
y320 = ­bb43 ­ (­bb42) * (­bb23) / ­bb22 
y330 = ­bb44 ­ (­bb42) * (­bb24) / ­bb22 
y340 = ­bb45 ­ (­bb42) * (­bb25) / ­bb22 
y350 = ­bb46 ­ (­bb42) * (­bb26) / ­bb22 
y420 = ­bb53 ­ (­bb52) * (­bb23) / ­bb22 
y430 = ­bb54 ­ (­bb52) * (­bb24) / ­bb22 
y440 = ­bb55 ­ (­bb52) * (­bb25) / ­bb22 
y450 = ­bb56 ­ (­bb52) * (­bb26) / ­bb22 
y520 = ­bb63 ­ (­bb62) * (­bb23) / ­bb22 
y530 = ­bb64 ­ (­bb62) * (­bb24) / ­bb22 
y540 = ­bb65 ­ (­bb62) * (­bb25) / ­bb22 
y550 = ­bb66 ­ (­bb62) * (­bb26) / ­bb22 
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
For i = 1 To nit 
pb1(2, i) = (v(2, i) * v(4, i)) * (­y24 * Cos(­an24 + d(4, i) ­ d(2, i))) + (v(2, i) * v(5, i)) * (­y25 * Cos(­
an25 + d(5, i) ­ d(2, i))) 
pb(2, i) = ((gb22) * ((v(2, i)) ^ 2)) + ((v(2, i) * v1) * (­y12 * Cos(­an12 + d1 ­ d(2, i))) + (v(2, i) * v(3, 
i)) * (­y23 * Cos(­an23 + d(3, i) ­ d(2, i))) + pb1(2, i)) 
pb(3, i) = ((gb33) * ((v(3, i)) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Cos(­an23 + d(2, i) ­ d(3, i))) + (v(3, i) 
* v(6, i)) * (­y36 * Cos(­an36 + d(6, i) ­ d(3, i)))) 
pb(4, i) = ((gb44) * ((v(4, i)) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Cos(­an24 + d(2, i) ­ d(4, i)))) 
pb(5, i) = ((gb55) * ((v(5, i)) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Cos(­an25 + d(2, i) ­ d(5, i)))) 
pb(6, i) = ((gb66) * ((v(6, i)) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Cos(­an36 + d(3, i) ­ d(6, i)))) 
diffp(2, i) = (1 / v(2, i)) * ((p2 / mvab) ­ pb(2, i)) 
diffp(3, i) = (1 / v(3, i)) * ((p3 / mvab) ­ pb(3, i)) 
diffp(4, i) = (1 / v(4, i)) * ((p4 / mvab) ­ pb(4, i)) 
diffp(5, i) = (1 / v(5, i)) * ((p5 / mvab) ­ pb(5, i)) 
diffp(6, i) = (1 / v(6, i)) * ((p6 / mvab) ­ pb(6, i)) 
intu(1, i) = diffp(2, i) / ­bb22 
intu(2, i) = (diffp(3, i) ­ (­bb32 * intu(1, i))) / y220 
intu(3, i) = (diffp(4, i) ­ (­bb42 * intu(1, i)) ­ (intu(2, i) * y320)) / y331 
intu(4, i) = (diffp(5, i) ­ (­bb52 * intu(1, i)) ­ (intu(2, i) * y420) ­ (intu(3, i) * y431)) / y442 
intu(5, i) = (diffp(6, i) ­ (intu(1, i)) * (­bb62) ­ (y520) * (intu(2, i)) ­ (intu(3, i)) * (y531) ­ (intu(4, i)) * 
(y542)) / y553 
dd(6, i) = intu(5, i) 
dd(5, i) = intu(4, i) ­ (dd(6, i) * y453) 
dd(4, i) = intu(3, i) ­ (dd(5, i) * y342) ­ (dd(6, i) * y352) 
dd(3, i) = intu(2, i) ­ (dd(4, i) * y231) ­ (y241 * dd(5, i)) ­ (y251 * dd(6, i)) 
dd(2, i) = intu(1, i) ­ (dd(3, i) * y120) ­ (y130 * dd(4, i)) ­ (y140 * dd(5, i)) ­ (dd(6, i) * y150) 
d(2, i + 1) = d(2, i) + dd(2, i) 
d(3, i + 1) = d(3, i) + dd(3, i) 
d(4, i + 1) = d(4, i) + dd(4, i) 
d(5, i + 1) = d(5, i) + dd(5, i) 
d(6, i + 1) = d(6, i) + dd(6, i) 
dq2(2, i) = ((v(2, i) * v(4, i)) * (­y24 * Sin(­an24 ­ d(2, i + 1) + d(4, i + 1)))) 
dq1(2, i) = ((v(2, i) * v(5, i)) * (­y25 * Sin(­an25 ­ d(2, i + 1) + d(5, i + 1)))) 
dq3(2, i) = ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(3, i + 1) ­ d(2, i + 1)))) 
dq4(2, i) = ((v1 * v(2, i)) * (­y12 * Sin(­an12 + d1 ­ d(2, i + 1)))) 
dq(2, i) = ((q2 / mvab) + ((bb22) * (v(2, i) ^ 2)) + dq1(2, i) + dq2(2, i) + dq3(2, i) + dq4(2, i)) / v(2, i) 
dq(3, i) = ((q3 / mvab) + ((bb33) * (v(3, i) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(2, i + 1) ­ 
d(3, i + 1)))) + ((v(3, i) * v(6, i)) * (­y36 * Sin(­an36 + d(3, i + 1) ­ d(3, i + 1))))) / v(3, i) 
dq(4, i) = ((q4 / mvab) + ((bb44) * (v(4, i) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Sin(­an24 ­ d(4, i + 1) + 
d(2, i + 1))))) / v(4, i) 
dq(5, i) = ((q5 / mvab) + ((bb55) * (v(5, i) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Sin(­an25 ­ d(5, i + 1) + 
d(2, i + 1))))) / v(5, i) 
dq(6, i) = ((q6 / mvab) + ((bb66) * (v(6, i) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Sin(­an36 ­ d(6, i + 1) + 
d(3, i + 1))))) / v(6, i) 
intv(1, i) = dq(2, i) / ­bb22 
intv(2, i) = (dq(3, i) ­ (­bb32 * intv(1, i))) / y220 
intv(3, i) = (dq(4, i) ­ (­bb42 * intv(1, i)) ­ (intv(2, i) * y320)) / y331 
intv(4, i) = (dq(5, i) ­ (­bb52 * intv(1, i)) ­ (intv(2, i) * y420) ­ (intv(3, i) * y431)) / y442 
intv(5, i) = (dq(6, i) ­ (intv(1, i)) * (­bb62) ­ (y520) * (intv(2, i)) ­ (intv(3, i)) * (y531) ­ (intv(4, i)) * 
(y542)) / y553 
dv(6, i) = intv(5, i) 
dv(5, i) = intv(4, i) ­ (dv(6, i) * y453) 
dv(4, i) = intv(3, i) ­ (dv(5, i) * y342) ­ (dv(6, i) * y352) 
dv(3, i) = intv(2, i) ­ (dv(4, i) * y231) ­ (y241 * dv(5, i)) ­ (y251 * dv(6, i)) 
dv(2, i) = intv(1, i) ­ (dv(3, i) * y120) ­ (y130 * dv(4, i)) ­ (y140 * dv(5, i)) ­ (dv(6, i) * y150) 
v(2, i + 1) = v(2, i) + dv(2, i) 
v(3, i + 1) = v(3, i) + dv(3, i) 
v(4, i + 1) = v(4, i) + dv(4, i) 
v(5, i + 1) = v(5, i) + dv(5, i) 
v(6, i + 1) = v(6, i) + dv(6, i) 
  
v(2, i) = v(2, i + 1) 
v(3, i) = v(3, i + 1) 
v(4, i) = v(4, i + 1) 
v(5, i) = v(5, i + 1) 
v(6, i) = v(6, i + 1) 
 d(2, i) = d(2, i + 1) 
 d(3, i) = d(3, i + 1) 
 d(4, i) = d(4, i + 1) 
 d(5, i) = d(5, i + 1) 
 d(6, i) = d(6, i + 1) 
Next i 
'Print "voltage at bus 2: "; v(2, i) 
'Print "phase angle at bus 2: "; d(2, i); "rad"; "in degrees:"; d(2, i) * 180 / 3.14159265 
'Print "voltage at bus 3: "; v(3, i) 
'Print "phase angle at bus 3: "; d(3, i); "rad"; "in degrees:"; d(3, i) * 180 / 3.14159265 
'Print "voltage at bus 4: "; v(4, i) 
'Print "phase angle at bus 4: "; d(4, i); "rad"; "in degrees:"; d(4, i) * 180 / 3.14159265 
'Print "voltage at bus 5: "; v(5, i) 
'Print "phase angle at bus 5: "; d(5, i); "rad"; "in degrees:"; d(5, i) * 180 / 3.14159265 
'Print "voltage at bus 6: "; v(6, i) 
'Print "phase angle at bus 6: "; d(6, i); "rad"; "in degrees:"; d(6, i) * 180 / 3.14159265 
act2 = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
act1 = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 
act6 = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
act5 = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 
act4 = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 
act3 = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
act8 = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 
act7 = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 
act9 = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 
act10 = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 
'Print "active power in p.u.from bus 2 towards 3:"; act1 
'Print "active power in p.u.from bus 1 towards 2:"; act2 
'Print "active power in p.u.from bus 2 towards 1:"; act3 
'Print "active power in p.u.from bus 3 towards 2:"; act4 
'Print "active power in p.u.from bus 4 towards 2:"; act5 
'Print "active power in p.u.from bus 2 towards 4:"; act6 
'Print "active power in p.u.from bus 5 towards 2:"; act7 
'Print "active power in p.u.from bus 2 towards 5:"; act8 
'Print "active power in p.u.from bus 3 towards 6:"; act9 
'Print "active power in p.u.from bus 6 towards 3:"; act10 
react1 = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 + d(3, i) 
­ d(2, i))))) 
react2 = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
react5 = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
react6 = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(4, i) 
­ d(2, i))))) 
react7 = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
react8 = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(5, i) 
­ d(2, i))))) 
react3 = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + d1 ­ d(2, 
i))))) 
react4 = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
react9 = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
react10 = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
'Print "reactive power from bus 2 towards 3:"; react1 
'Print "reactive power from bus 1 towards 2:"; react2 
'Print "reactive power from bus 2 towards 1:"; react3 
'Print "reactive power from bus 3 towards 2:"; react4 
'Print "reactive power from bus 4 towards 2:"; react5 
'Print "reactive power from bus 2 towards 4:"; react6 
'Print "reactive power from bus 5 towards 2:"; react7 
'Print "reactive power from bus 2 towards 5:"; react8 
'Print "reactive power from bus 3 towards 6:"; react9 
'Print "reactive power from bus 6 towards 3:"; react10 
For i = nit ­ 1 To nit 
'Print diffp(2, i), diffp(3, i), diffp(4, i), diffp(5, i), diffp(6, i), dq(2, i), dq(3, i), dq(4, i), dq(5, i), dq(6, i) 
Next i 
Range("a132") = "The voltage on bus 2 in pu" 
Range("b132") = v(2, i) 
Range("a133") = "The voltage on bus 3 in pu" 
Range("b133") = v(3, i) 
Range("a134") = "The voltage on bus 4 in pu" 
Range("b134") = v(4, i) 
Range("a135") = "The voltage on bus 5 in pu" 
Range("b135") = v(5, i) 
Range("a136") = "The voltage on bus 6 in pu" 
Range("b136") = v(6, i) 
Range("a137") = "The voltage on bus 7 in pu" 
Range("b137") = "not applicable" 
Range("a138") = "The voltage on bus 8 in pu" 
Range("b138") = "not applicable" 
Range("a139") = "The voltage on bus 9 in pu" 
Range("b139") = "not applicable" 
Range("a140") = "The voltage on bus 10 in pu" 
Range("b140") = "not applicable" 
Range("a141") = "The phase angle at bus 2 in rad. & degrees" 
Range("b141") = d(2, i) 
Range("c141") = d(2, i) * 180 / 3.14159265 
Range("a142") = "The phase angle at bus 3 in rad. & degrees" 
Range("b142") = d(3, i) 
Range("c142") = d(3, i) * 180 / 3.14159265 
Range("a143") = "The phase angle at bus 4 in rad. & degrees" 
Range("b143") = d(4, i) 
Range("c143") = d(4, i) * 180 / 3.14159265 
Range("a144") = "The phase angle at bus 5 in rad. & degrees" 
Range("b144") = d(5, i) 
Range("c144") = d(5, i) * 180 / 3.14159265 
Range("a145") = "The voltage on bus 6 in pu" 
Range("b145") = d(6, i) 
Range("c145") = d(6, i) * 180 / 3.14159265 
Range("a146") = "The voltage on bus 7 in pu" 
Range("b146") = "not applicable" 
Range("c146") = "not applicable" 
Range("a147") = "The voltage on bus 8 in pu" 
Range("b147") = "not applicable" 
Range("c147") = "not applicable" 
Range("a148") = "The voltage on bus 9 in pu" 
Range("b148") = "not applicable" 
Range("c148") = "not applicable" 
Range("a149") = "The voltage on bus 10 in pu" 
Range("b149") = "not applicable" 
Range("c149") = "not applicable" 
Range("a150") = "The active power flowing from bus 1 to 2 in pu" 
Range("b150") = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
Range("a151") = "The active power flowing from bus 2 to 1 in pu" 
Range("b151") = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
Range("a152") = "The active power flowing from bus 2 to 3 in pu" 
Range("b152") = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 

Range("a153") = "The active power flowing from bus 3 to 2 in pu" 
Range("b153") = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 

Range("a154") = "The active power flowing from bus 2 to 4 in pu" 
Range("b154") = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
Range("a155") = "The active power flowing from bus 4 to 2 in pu" 
Range("b155") = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 

Range("a156") = "The active power flowing from bus 2 to 5 in pu" 
Range("b156") = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 

Range("a157") = "The active power flowing from bus 5 to 2 in pu" 
Range("b157") = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 

Range("a158") = "The active power flowing from bus 3 to 6 in pu" 
Range("b158") = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 

Range("a159") = "The active power flowing from bus 6 to 3 in pu" 
Range("b159") = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 

Range("a160") = "The active power flowing from bus 4 to 7 in pu" 
Range("b160") = "not applicable" 
Range("a161") = "The active power flowing from bus 7 to 4 in pu" 
Range("b161") = "not applicable" 
Range("a162") = "The active power flowing from bus 5 to 8 in pu" 
Range("b162") = "not applicable" 
Range("a163") = "The active power flowing from bus 8 to 5 in pu" 
Range("b163") = "not applicable" 
Range("a164") = "The active power flowing from bus 6 to 9 in pu" 
Range("b164") = "not applicable" 
Range("a165") = "The active power flowing from bus 9 to 6 in pu" 
Range("b165") = "not applicable" 
Range("a166") = "The active power flowing from bus 7 to 10 in pu" 
Range("b166") = "not applicable" 
Range("a167") = "The active power flowing from bus 10 to 7 in pu" 
Range("b167") = "not applicable" 
Range("a168") = "The reactive power flowing from bus 1 to 2 in pu" 
Range("b168") = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
Range("a169") = "The reactive power flowing from bus 2 to 1 in pu" 
Range("b169") = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + 
d1 ­ d(2, i))))) 
Range("a170") = "The reactive power flowing from bus 2 to 3 in pu" 
Range("b170") = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 
+ d(3, i) ­ d(2, i))))) 
Range("a171") = "The reactive power flowing from bus 3 to 2 in pu" 
Range("b171") = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
Range("a172") = "The reactive power flowing from bus 2 to 4 in pu" 
Range("b172") = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 
+ d(4, i) ­ d(2, i))))) 
Range("a173") = "The reactive power flowing from bus 4 to 2 in pu" 
Range("b173") = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
Range("a174") = "The reactive power flowing from bus 2 to 5 in pu" 
Range("b174") = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 
+ d(5, i) ­ d(2, i))))) 
Range("a175") = "The reactive power flowing from bus 5 to 2 in pu" 
Range("b175") = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
Range("a176") = "The reactive power flowing from bus 3 to 6 in pu" 
Range("b176") = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
Range("a177") = "The reactive power flowing from bus 6 to 3 in pu" 
Range("b177") = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
Range("a178") = "The reactive power flowing from bus 4 to 7 in pu" 
Range("b178") = "not applicable" 
Range("a179") = "The reactive power flowing from bus 7 to 4 in pu" 
Range("b179") = "not applicable" 
Range("a180") = "The reactive power flowing from bus 5 to 8 in pu" 
Range("b180") = "not applicable" 
Range("a181") = "The reactive power flowing from bus 8 to 5 in pu" 
Range("b181") = "not applicable" 
Range("a182") = "The reactive power flowing from bus 6 to 9 in pu" 
Range("b182") = "not applicable" 
Range("a183") = "The reactive power flowing from bus 9 to 6 in pu" 
Range("b183") = "not applicable" 
Range("a184") = "The reactive power flowing from bus 7 to 10 in pu" 
Range("b184") = "not applicable" 
Range("a185") = "The reactive power flowing from bus 10 to 7 in pu" 
Range("b185") = "not applicable" 
End Sub 
Sub Mysub133() 
Dim d(30, 30) 
Dim dd(30, 30) 
Dim diffp(30, 30) 
Dim dq(30, 30) 
Dim dq1(30, 30) 
Dim dq2(30, 30) 
Dim dq3(30, 30) 
Dim dq4(30, 30) 
Dim dv(30, 30) 
Dim intv(30, 30) 
Dim intu(30, 30) 
Dim v(30, 30) 
Dim pb(30, 30) 
Dim pb1(30, 30) 
'If r58 = 0 And x58 = 0 And r69 = 0 And x69 = 0 And r710 = 0 And x710 = 0 Then 
UserForm5.Show 
r12 = Range("b65") 
r23 = Range("b66") 
r24 = Range("b67") 
r25 = Range("b68") 
r36 = Range("b69") 
r47 = Range("b70") 
Range("b71") = "not applicable" 
Range("b72") = "not applicable" 
Range("b73") = "not applicable" 
x12 = Range("b74") 
x23 = Range("b75") 
x24 = Range("b76") 
x25 = Range("b77") 
x36 = Range("b78") 
x47 = Range("b79") 
Range("b80") = "not applicable" 
Range("b81") = "not applicable" 
Range("b82") = "not applicable" 
mvac12 = Range("b83") 
mvac23 = Range("b84") 
mvac24 = Range("b85") 
mvac25 = Range("b86") 
xmotst = Range("b87") 
xmotst1 = Range("b88") 
v1 = Range("b89") 
v(2, 1) = Range("b90") 
v(3, 1) = Range("b91") 
v(4, 1) = Range("b92") 
v(5, 1) = Range("b93") 
v(6, 1) = Range("b94") 
v(7, 1) = Range("b95") 
Range("b96") = "not applicable" 
Range("b97") = "not applicable" 
Range("b98") = "not applicable" 
d1 = Range("b99") 
d(2, 1) = Range("b100") 
d(3, 1) = Range("b101") 
d(4, 1) = Range("b102") 
d(5, 1) = Range("b103") 
d(6, 1) = Range("b104") 
d(7, 1) = Range("b105") 
Range("b106") = "not applicable" 
Range("b107") = "not applicable" 
Range("b108") = "not applicable" 
p1 = Range("b109") 
p2 = Range("b110") 
p3 = Range("b111") 
p4 = Range("b112") 
p5 = Range("b113") 
p6 = Range("b114") 
p7 = Range("b115") 
Range("b116") = "not applicable" 
Range("b117") = "not applicable" 
Range("b118") = "not applicable" 
q1 = Range("b119") 
q2 = Range("b120") 
q3 = Range("b121") 
q4 = Range("b122") 
q5 = Range("b123") 
q6 = Range("b124") 
q7 = Range("b125") 
Range("b126") = "not applicable" 
Range("b127") = "not applicable" 
Range("b128") = "not applicable" 
mvab = Range("b129") 
nit = Range("b130") 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z23 = ((r23) ^ 2 + (x23) ^ 2) ^ 0.5 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z25 = ((r25) ^ 2 + (x25) ^ 2) ^ 0.5 
z36 = ((r36) ^ 2 + (x36) ^ 2) ^ 0.5 
z47 = ((r47) ^ 2 + (x47) ^ 2) ^ 0.5 
y12 = 1 / z12 
y23 = 1 / z23 
y24 = 1 / z24 
y25 = 1 / z25 
y36 = 1 / z36 
y47 = 1 / z47 
an12 = Atn(x12 / r12) 
an23 = Atn(x23 / r23) 
an24 = Atn(x24 / r24) 
an25 = Atn(x25 / r25) 
an36 = Atn(x36 / r36) 
an47 = Atn(x47 / r47) 
b12 = y12 * Sin(­an12) 
b23 = y23 * Sin(­an23) 
b24 = y24 * Sin(­an24) 
b25 = y25 * Sin(­an25) 
b36 = y36 * Sin(­an36) 
b47 = y47 * Sin(­an47) 
yc12 = (mvac12) / mvab 
yc23 = (mvac23) / mvab 
yc24 = (mvac24) / mvab 
yc25 = (mvac25) / mvab 
g12 = y12 * Cos(­an12) 
g23 = y23 * Cos(­an23) 
g24 = y24 * Cos(­an24) 
g25 = y25 * Cos(­an25) 
g36 = y36 * Cos(­an36) 
g47 = y47 * Cos(­an47) 
gb22 = g12 + g23 + g24 + g25 
gb33 = g23 + g36 
gb44 = g24 + g47 
gb55 = g25 
gb66 = g36 
gb77 = g47 
gb12 = ­g12 
gb21 = ­g12 
gb23 = ­g23 
gb32 = ­g23 
gb24 = ­g24 
gb42 = ­g24 
gb25 = ­g25 
gb52 = ­g25 
gb36 = ­g36 
gb63 = ­g36 
gb47 = ­g47 
gb47 = ­g47 
bb11 = b12 + yc12 
bb22 = b12 + b23 + yc23 + b24 + yc24 + b25 + yc25 
bb33 = b23 + b36 
bb55 = b25 
bb66 = b36 
If xmotst < 0 Then bb44 = b24 + b47 + (1 / xmotst) 
If xmotst = 0 Then bb44 = b24 + b47 
If xmotst1 < 0 Then bb77 = b47 + (1 / xmotst1) 
If xmotst1 = 0 Then bb77 = b47 
bb12 = ­b12 
bb21 = ­b12 
bb23 = ­b23 
bb32 = ­b23 
bb24 = ­b24 
bb42 = ­b24 
bb25 = ­b25 
bb52 = ­b25 
bb36 = ­b36 
bb63 = ­b36 
bb47 = ­b47 
bb74 = ­b47 
y110 = bb22 / bb22 
y120 = ­bb23 / ­bb22 
y130 = ­bb24 / ­bb22 
y140 = ­bb25 / ­bb22 
y150 = ­bb26 / ­bb22 
y160 = ­bb27 / ­bb22 
y220 = ­bb33 ­ (­bb32) * (­bb23) / (­bb22) 
y230 = ­bb34 ­ (­bb32) * (­bb24) / (­bb22) 
y240 = ­bb35 ­ (­bb32) * (­bb25) / ­bb22 
y250 = ­bb36 ­ (­bb32) * (­bb26) / ­bb22 
y260 = ­bb37 ­ (­bb32) * (­bb27) / ­bb22 
y320 = ­bb43 ­ (­bb42) * (­bb23) / ­bb22 
y330 = ­bb44 ­ (­bb42) * (­bb24) / ­bb22 
y340 = ­bb45 ­ (­bb42) * (­bb25) / ­bb22 
y350 = ­bb46 ­ (­bb42) * (­bb26) / ­bb22 
y360 = ­bb47 ­ (­bb42) * (­bb27) / ­bb22 
y420 = ­bb53 ­ (­bb52) * (­bb23) / ­bb22 
y430 = ­bb54 ­ (­bb52) * (­bb24) / ­bb22 
y440 = ­bb55 ­ (­bb52) * (­bb25) / ­bb22 
y450 = ­bb56 ­ (­bb52) * (­bb26) / ­bb22 
y460 = ­bb57 ­ (­bb52) * (­bb27) / ­bb22 
y520 = ­bb63 ­ (­bb62) * (­bb23) / ­bb22 
y530 = ­bb64 ­ (­bb62) * (­bb24) / ­bb22 
y540 = ­bb65 ­ (­bb62) * (­bb25) / ­bb22 
y550 = ­bb66 ­ (­bb62) * (­bb26) / ­bb22 
y560 = ­bb67 ­ (­bb62) * (­bb27) / ­bb22 
y620 = ­bb73 ­ (­bb72) * (­bb23) / ­bb22 
y630 = ­bb74 ­ (­bb72) * (­bb24) / ­bb22 
y640 = ­bb75 ­ (­bb72) * (­bb25) / ­bb22 
y650 = ­bb76 ­ (­bb72) * (­bb26) / ­bb22 
y660 = ­bb77 ­ (­bb72) * (­bb27) / ­bb22 
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y261 = y260 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y361 = y360 ­ (y320) * (y260) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y461 = y460 ­ (y420) * (y260) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y561 = y560 ­ (y520) * (y260) / y220 
y631 = y630 ­ (y620) * (y230) / y220 
y641 = y640 ­ (y620) * (y240) / y220 
y651 = y650 ­ (y620) * (y250) / y220 
y661 = y660 ­ (y620) * (y260) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y362 = y361 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y462 = y461 ­ (y431) * (y361) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y562 = y561 ­ (y531) * (y361) / y331 
y642 = y641 ­ (y631) * (y341) / y331 
y652 = y651 ­ (y631) * (y351) / y331 
y662 = y661 ­ (y631) * (y361) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y463 = y462 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
y563 = y562 ­ (y542) * (y462) / y442 
y653 = y652 ­ (y642) * (y452) / y442 
y663 = y662 ­ (y642) * (y462) / y442 
y554 = y553 / y553 
y564 = y563 / y553 
y664 = y663 ­ (y653) * (y563) / y553 
For i = 1 To nit 
pb1(2, i) = (v(2, i) * v(4, i)) * (­y24 * Cos(­an24 + d(4, i) ­ d(2, i))) + (v(2, i) * v(5, i)) * (­y25 * Cos(­
an25 + d(5, i) ­ d(2, i))) 
pb(2, i) = ((gb22) * ((v(2, i)) ^ 2)) + ((v(2, i) * v1) * (­y12 * Cos(­an12 + d1 ­ d(2, i))) + (v(2, i) * v(3, 
i)) * (­y23 * Cos(­an23 + d(3, i) ­ d(2, i))) + pb1(2, i)) 
pb(3, i) = ((gb33) * ((v(3, i)) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Cos(­an23 + d(2, i) ­ d(3, i))) + (v(3, i) 
* v(6, i)) * (­y36 * Cos(­an36 + d(6, i) ­ d(3, i)))) 
pb(4, i) = ((gb44) * ((v(4, i)) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Cos(­an24 + d(2, i) ­ d(4, i))) + (v(4, i) 
* v(7, i)) * (­y47 * Cos(­an47 + d(7, i) ­ d(4, i)))) 
pb(5, i) = ((gb55) * ((v(5, i)) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Cos(­an25 + d(2, i) ­ d(5, i)))) 
pb(6, i) = ((gb66) * ((v(6, i)) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Cos(­an36 + d(3, i) ­ d(6, i)))) 
pb(7, i) = ((gb77) * ((v(7, i)) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Cos(­an47 + d(4, i) ­ d(7, i)))) 
diffp(2, i) = (1 / v(2, i)) * ((p2 / mvab) ­ pb(2, i)) 
diffp(3, i) = (1 / v(3, i)) * ((p3 / mvab) ­ pb(3, i)) 
diffp(4, i) = (1 / v(4, i)) * ((p4 / mvab) ­ pb(4, i)) 
diffp(5, i) = (1 / v(5, i)) * ((p5 / mvab) ­ pb(5, i)) 
diffp(6, i) = (1 / v(6, i)) * ((p6 / mvab) ­ pb(6, i)) 
diffp(7, i) = (1 / v(7, i)) * ((p7 / mvab) ­ pb(7, i)) 
intu(1, i) = diffp(2, i) / ­bb22 
intu(2, i) = (diffp(3, i) ­ (intu(1, i)) * (­bb32)) / y220 
intu(3, i) = (diffp(4, i) ­ (intu(1, i)) * (­bb42) ­ (y320) * (intu(2, i))) / y331 
intu(4, i) = (diffp(5, i) ­ (intu(1, i)) * (­bb52) ­ (y420) * (intu(2, i)) ­ (intu(3, i)) * (y431)) / y442 
intu(5, i) = (diffp(6, i) ­ (intu(1, i)) * (­bb62) ­ (y520) * (intu(2, i)) ­ (intu(3, i)) * (y531) ­ (intu(4, i)) * 
(y542)) / y553 
intu(6, i) = (diffp(7, i) ­ (intu(1, i)) * (­bb72) ­ (y620) * (intu(2, i)) ­ (y631) * (intu(3, i)) ­ (y642) * 
(intu(4, i)) ­ (y653) * (intu(5, i))) / y664 
dd(7, i) = intu(6, i) 
dd(6, i) = (intu(5, i) ­ ((y564) * (dd(7, i)))) 
dd(5, i) = (intu(4, i) ­ ((y453) * (dd(6, i))) ­ ((y463) * (dd(7, i)))) 
dd(4, i) = (intu(3, i) ­ ((y342) * (dd(5, i))) ­ ((y352) * (dd(6, i))) ­ ((y362) * (dd(7, i)))) 
dd(3, i) = (intu(2, i) ­ ((y231) * (dd(4, i))) ­ ((y241) * (dd(5, i))) ­ ((y251) * (dd(6, i))) ­ ((y261) * (dd(7, 
i)))) 
dd(2, i) = (intu(1, i) ­ ((y120) * (dd(3, i))) ­ ((y130) * (dd(4, i))) ­ ((y140) * (dd(5, i))) ­ ((y150) * (dd(6, 
i))) ­ ((y160) * (dd(7, i)))) 
d(2, i + 1) = d(2, i) + dd(2, i) 
d(3, i + 1) = d(3, i) + dd(3, i) 
d(4, i + 1) = d(4, i) + dd(4, i) 
d(5, i + 1) = d(5, i) + dd(5, i) 
d(6, i + 1) = d(6, i) + dd(6, i) 
d(7, i + 1) = d(7, i) + dd(7, i) 
dq2(2, i) = ((v(2, i) * v(4, i)) * (­y24 * Sin(­an24 ­ d(2, i + 1) + d(4, i + 1)))) 
dq1(2, i) = ((v(2, i) * v(5, i)) * (­y25 * Sin(­an25 ­ d(2, i + 1) + d(5, i + 1)))) 
dq3(2, i) = ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(3, i + 1) ­ d(2, i + 1)))) 
dq4(2, i) = ((v1 * v(2, i)) * (­y12 * Sin(­an12 + d1 ­ d(2, i + 1)))) 
dq(2, i) = ((q2 / mvab) + ((bb22) * (v(2, i) ^ 2)) + dq1(2, i) + dq2(2, i) + dq3(2, i) + dq4(2, i)) / v(2, i) 
dq(3, i) = ((q3 / mvab) + ((bb33) * (v(3, i) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(2, i + 1) ­ 
d(3, i + 1)))) + ((v(3, i) * v(6, i)) * (­y36 * Sin(­an36 + d(6, i + 1) ­ d(3, i + 1))))) / v(3, i) 
dq(4, i) = ((q4 / mvab) + ((bb44) * (v(4, i) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Sin(­an24 ­ d(4, i + 1) + 
d(2, i + 1)))) + ((v(4, i) * v(7, i)) * (­y47 * Sin(­an47 ­ d(4, i + 1) + d(7, i + 1))))) / v(4, i) 
dq(5, i) = ((q5 / mvab) + ((bb55) * (v(5, i) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Sin(­an25 ­ d(5, i + 1) + 
d(2, i + 1))))) / v(5, i) 
dq(6, i) = ((q6 / mvab) + ((bb66) * (v(6, i) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Sin(­an36 ­ d(6, i + 1) + 
d(3, i + 1))))) / v(6, i) 
dq(7, i) = ((q7 / mvab) + ((bb77) * (v(7, i) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Sin(­an47 ­ d(7, i + 1) + 
d(4, i + 1))))) / v(7, i) 
intv(1, i) = dq(2, i) / ­bb22 
intv(2, i) = (dq(3, i) ­ (intv(1, i)) * (­bb32)) / y220 
intv(3, i) = (dq(4, i) ­ (intv(1, i)) * (­bb42) ­ (y320) * (intv(2, i))) / y331 
intv(4, i) = (dq(5, i) ­ (intv(1, i)) * (­bb52) ­ (y420) * (intv(2, i)) ­ (intv(3, i)) * (y431)) / y442 
intv(5, i) = (dq(6, i) ­ (intv(1, i)) * (­bb62) ­ (y520) * (intv(2, i)) ­ (intv(3, i)) * (y531) ­ (intv(4, i)) * 
(y542)) / y553 
intv(6, i) = (dq(7, i) ­ (intv(1, i)) * (­bb72) ­ (y620) * (intv(2, i)) ­ (y631) * (intv(3, i)) ­ (y642) * (intv(4, 
i)) ­ (y653) * (intv(5, i))) / y664 
dv(7, i) = intv(6, i) 
dv(6, i) = (intv(5, i) ­ ((y564) * (dv(7, i)))) 
dv(5, i) = (intv(4, i) ­ ((y453) * (dv(6, i))) ­ ((y463) * (dv(7, i)))) 
dv(4, i) = (intv(3, i) ­ ((y342) * (dv(5, i))) ­ ((y352) * (dv(6, i))) ­ ((y362) * (dv(7, i)))) 
dv(3, i) = (intv(2, i) ­ ((y231) * (dv(4, i))) ­ ((y241) * (dv(5, i))) ­ ((y251) * (dv(6, i))) ­ ((y261) * (dv(7, 
i)))) 
dv(2, i) = (intv(1, i) ­ ((y120) * (dv(3, i))) ­ ((y130) * (dv(4, i))) ­ ((y140) * (dv(5, i))) ­ ((y150) * (dv(6, 
i))) ­ ((y160) * (dv(7, i)))) 
  
v(2, i + 1) = v(2, i) + dv(2, i) 
v(3, i + 1) = v(3, i) + dv(3, i) 
v(4, i + 1) = v(4, i) + dv(4, i) 
v(5, i + 1) = v(5, i) + dv(5, i) 
v(6, i + 1) = v(6, i) + dv(6, i) 
v(7, i + 1) = v(7, i) + dv(7, i) 
v(2, i) = v(2, i + 1) 
v(3, i) = v(3, i + 1) 
v(4, i) = v(4, i + 1) 
v(5, i) = v(5, i + 1) 
v(6, i) = v(6, i + 1) 
v(7, i) = v(7, i + 1) 
 d(2, i) = d(2, i + 1) 
 d(3, i) = d(3, i + 1) 
 d(4, i) = d(4, i + 1) 
 d(5, i) = d(5, i + 1) 
 d(6, i) = d(6, i + 1) 
 d(7, i) = d(7, i + 1) 
Next i 
'Print "voltage at bus 2: "; v(2, I) 
'Print "phase angle at bus 2: "; d(2, I); "rad"; "in degrees:"; d(2, I) * 180 / 3.14159265 
'Print "voltage at bus 3: "; v(3, I) 
'Print "phase angle at bus 3: "; d(3, I); "rad"; "in degrees:"; d(3, I) * 180 / 3.14159265 
'Print "voltage at bus 4: "; v(4, I) 
'Print "phase angle at bus 4: "; d(4, I); "rad"; "in degrees:"; d(4, I) * 180 / 3.14159265 
'Print "voltage at bus 5: "; v(5, I) 
'Print "phase angle at bus 5: "; d(5, I); "rad"; "in degrees:"; d(5, I) * 180 / 3.14159265 
'Print "voltage at bus 6: "; v(6, I) 
'Print "phase angle at bus 6: "; d(6, I); "rad"; "in degrees:"; d(6, I) * 180 / 3.14159265 
'Print "voltage at bus 7: "; v(7, I) 
'Print "phase angle at bus 7: "; d(7, I); "rad"; "in degrees:"; d(7, I) * 180 / 3.14159265 
act2 = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
act1 = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 
act6 = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
act5 = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 
act4 = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 
act3 = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
act8 = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 
act7 = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 
act9 = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 
act10 = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 
act11 = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
act12 = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
'Print "active power in p.u.from bus 2 towards 3:"; act1 
'Print "active power in p.u.from bus 1 towards 2:"; act2 
'Print "active power in p.u.from bus 2 towards 1:"; act3 
'Print "active power in p.u.from bus 3 towards 2:"; act4 
'Print "active power in p.u.from bus 4 towards 2:"; act5 
'Print "active power in p.u.from bus 2 towards 4:"; act6 
'Print "active power in p.u.from bus 5 towards 2:"; act7 
'Print "active power in p.u.from bus 2 towards 5:"; act8 
'Print "active power in p.u.from bus 3 towards 6:"; act9 
'Print "active power in p.u.from bus 6 towards 3:"; act10 
'Print "active power in p.u.from bus 4 towards 7:"; act11 
'Print "active power in p.u.from bus 7 towards 4:"; act12 
react1 = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 + d(3, i) 
­ d(2, i))))) 
react2 = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
react5 = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
react6 = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(4, i) 
­ d(2, i))))) 
react7 = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
react8 = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(5, i) 
­ d(2, i))))) 
react3 = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + d1 ­ d(2, 
i))))) 
react4 = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
react9 = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
react10 = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
react11 = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
react12 = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
'Print "reactive power from bus 2 towards 3:"; react1 
'Print "reactive power from bus 1 towards 2:"; react2 
'Print "reactive power from bus 2 towards 1:"; react3 
'Print "reactive power from bus 3 towards 2:"; react4 
'Print "reactive power from bus 4 towards 2:"; react5 
'Print "reactive power from bus 2 towards 4:"; react6 
'Print "reactive power from bus 5 towards 2:"; react7 
'Print "reactive power from bus 2 towards 5:"; react8 
'Print "reactive power from bus 3 towards 6:"; react9 
'Print "reactive power from bus 6 towards 3:"; react10 
'Print "reactive power from bus 4 towards 7:"; react11 
'Print "reactive power from bus 7 towards 4:"; react12 
Range("a132") = "The voltage on bus 2 in pu" 
Range("b132") = v(2, i) 
Range("a133") = "The voltage on bus 3 in pu" 
Range("b133") = v(3, i) 
Range("a134") = "The voltage on bus 4 in pu" 
Range("b134") = v(4, i) 
Range("a135") = "The voltage on bus 5 in pu" 
Range("b135") = v(5, i) 
Range("a136") = "The voltage on bus 6 in pu" 
Range("b136") = v(6, i) 
Range("a137") = "The voltage on bus 7 in pu" 
Range("b137") = v(7, i) 
Range("a138") = "The voltage on bus 8 in pu" 
Range("b138") = "not applicable" 
Range("a139") = "The voltage on bus 9 in pu" 
Range("b139") = "not applicable" 
Range("a140") = "The voltage on bus 10 in pu" 
Range("b140") = "not applicable" 
Range("a141") = "The phase angle at bus 2 in rad. & degrees" 
Range("b141") = d(2, i) 
Range("c141") = d(2, i) * 180 / 3.14159265 
Range("a142") = "The phase angle at bus 3 in rad. & degrees" 
Range("b142") = d(3, i) 
Range("c142") = d(3, i) * 180 / 3.14159265 
Range("a143") = "The phase angle at bus 4 in rad. & degrees" 
Range("b143") = d(4, i) 
Range("c143") = d(4, i) * 180 / 3.14159265 
Range("a144") = "The phase angle at bus 5 in rad. & degrees" 
Range("b144") = d(5, i) 
Range("c144") = d(5, i) * 180 / 3.14159265 
Range("a145") = "The phase angle at bus 6 in pu" 
Range("b145") = d(6, i) 
Range("c145") = d(6, i) * 180 / 3.14159265 
Range("a146") = "The phase angle at bus 7 in pu" 
Range("b146") = d(7, i) 
Range("c146") = d(7, i) * 180 / 3.14159265 
Range("a147") = "The phase angle at bus 8 in pu" 
Range("b147") = "not applicable" 
Range("c147") = "not applicable" 
Range("a148") = "The phase angle at bus 9 in pu" 
Range("b148") = "not applicable" 
Range("c148") = "not applicable" 
Range("a149") = "The phase angle at bus 10 in pu" 
Range("b149") = "not applicable" 
Range("c149") = "not applicable" 
Range("a150") = "The active power flowing from bus 1 to 2 in pu" 
Range("b150") = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
Range("a151") = "The active power flowing from bus 2 to 1 in pu" 
Range("b151") = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
Range("a152") = "The active power flowing from bus 2 to 3 in pu" 
Range("b152") = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 

Range("a153") = "The active power flowing from bus 3 to 2 in pu" 
Range("b153") = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 

Range("a154") = "The active power flowing from bus 2 to 4 in pu" 
Range("b154") = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
Range("a155") = "The active power flowing from bus 4 to 2 in pu" 
Range("b155") = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 

Range("a156") = "The active power flowing from bus 2 to 5 in pu" 
Range("b156") = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 

Range("a157") = "The active power flowing from bus 5 to 2 in pu" 
Range("b157") = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 

Range("a158") = "The active power flowing from bus 3 to 6 in pu" 
Range("b158") = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 

Range("a159") = "The active power flowing from bus 6 to 3 in pu" 
Range("b159") = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 

Range("a160") = "The active power flowing from bus 4 to 7 in pu" 
Range("b160") = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
Range("a161") = "The active power flowing from bus 7 to 4 in pu" 
Range("b161") = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
Range("a162") = "The active power flowing from bus 5 to 8 in pu" 
Range("b162") = "not applicable" 
Range("a163") = "The active power flowing from bus 8 to 5 in pu" 
Range("b163") = "not applicable" 
Range("a164") = "The active power flowing from bus 6 to 9 in pu" 
Range("b164") = "not applicable" 
Range("a165") = "The active power flowing from bus 9 to 6 in pu" 
Range("b165") = "not applicable" 
Range("a166") = "The active power flowing from bus 7 to 10 in pu" 
Range("b166") = "not applicable" 
Range("a167") = "The active power flowing from bus 10 to 7 in pu" 
Range("b167") = "not applicable" 
Range("a168") = "The reactive power flowing from bus 1 to 2 in pu" 
Range("b168") = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
Range("a169") = "The reactive power flowing from bus 2 to 1 in pu" 
Range("b169") = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + 
d1 ­ d(2, i))))) 
Range("a170") = "The reactive power flowing from bus 2 to 3 in pu" 
Range("b170") = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 
+ d(3, i) ­ d(2, i))))) 
Range("a171") = "The reactive power flowing from bus 3 to 2 in pu" 
Range("b171") = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
Range("a172") = "The reactive power flowing from bus 2 to 4 in pu" 
Range("b172") = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 
+ d(4, i) ­ d(2, i))))) 
Range("a173") = "The reactive power flowing from bus 4 to 2 in pu" 
Range("b173") = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
Range("a174") = "The reactive power flowing from bus 2 to 5 in pu" 
Range("b174") = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 
+ d(5, i) ­ d(2, i))))) 
Range("a175") = "The reactive power flowing from bus 5 to 2 in pu" 
Range("b175") = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
Range("a176") = "The reactive power flowing from bus 3 to 6 in pu" 
Range("b176") = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
Range("a177") = "The reactive power flowing from bus 6 to 3 in pu" 
Range("b177") = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
Range("a178") = "The reactive power flowing from bus 4 to 7 in pu" 
Range("b178") = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
Range("a179") = "The reactive power flowing from bus 7 to 4 in pu" 
Range("b179") = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
Range("a180") = "The reactive power flowing from bus 5 to 8 in pu" 
Range("b180") = "not applicable" 
Range("a181") = "The reactive power flowing from bus 8 to 5 in pu" 
Range("b181") = "not applicable" 
Range("a182") = "The reactive power flowing from bus 6 to 9 in pu" 
Range("b182") = "not applicable" 
Range("a183") = "The reactive power flowing from bus 9 to 6 in pu" 
Range("b183") = "not applicable" 
Range("a184") = "The reactive power flowing from bus 7 to 10 in pu" 
Range("b184") = "not applicable" 
Range("a185") = "The reactive power flowing from bus 10 to 7 in pu" 
Range("b185") = "not applicable" 
For i = nit ­ 1 To nit 
'Print diffp(2, i), diffp(3, i), diffp(4, i), diffp(5, i), diffp(6, i), dq(2, i), dq(3, i), dq(4, i), dq(5, i), dq(6, i) 
Next i 
End Sub 
Sub Mysub134() 
Dim d(30, 30) 
Dim dd(30, 30) 
Dim diffp(30, 30) 
Dim dq(30, 30) 
Dim dq1(30, 30) 
Dim dq2(30, 30) 
Dim dq3(30, 30) 
Dim dq4(30, 30) 
Dim dv(30, 30) 
Dim intv(30, 30) 
Dim intu(30, 30) 
Dim v(30, 30) 
Dim pb(30, 30) 
Dim pb1(30, 30) 
UserForm6.Show 
r12 = Range("b65") 
r23 = Range("b66") 
r24 = Range("b67") 
r25 = Range("b68") 
r36 = Range("b69") 
r47 = Range("b70") 
r58 = Range("b71") 
Range("b72") = "not applicable" 
Range("b73") = "not applicable" 
x12 = Range("b74") 
x23 = Range("b75") 
x24 = Range("b76") 
x25 = Range("b77") 
x36 = Range("b78") 
x47 = Range("b79") 
x58 = Range("b80") 
Range("b81") = "not applicable" 
Range("b82") = "not applicable" 
mvac12 = Range("b83") 
mvac23 = Range("b84") 
mvac24 = Range("b85") 
mvac25 = Range("b86") 
xmotst = Range("b87") 
xmotst1 = Range("b88") 
v1 = Range("b89") 
v(2, 1) = Range("b90") 
v(3, 1) = Range("b91") 
v(4, 1) = Range("b92") 
v(5, 1) = Range("b93") 
v(6, 1) = Range("b94") 
v(7, 1) = Range("b95") 
v(8, 1) = Range("b96") 
Range("b97") = "not applicable" 
Range("b98") = "not applicable" 
d1 = Range("b99") 
d(2, 1) = Range("b100") 
d(3, 1) = Range("b101") 
d(4, 1) = Range("b102") 
d(5, 1) = Range("b103") 
d(6, 1) = Range("b104") 
d(7, 1) = Range("b105") 
d(8, 1) = Range("b106") 
Range("b107") = "not applicable" 
Range("b108") = "not applicable" 
p1 = Range("b109") 
p2 = Range("b110") 
p3 = Range("b111") 
p4 = Range("b112") 
p5 = Range("b113") 
p6 = Range("b114") 
p7 = Range("b115") 
p8 = Range("b116") 
Range("b117") = "not applicable" 
Range("b118") = "not applicable" 
q1 = Range("b119") 
q2 = Range("b120") 
q3 = Range("b121") 
q4 = Range("b122") 
q5 = Range("b123") 
q6 = Range("b124") 
q7 = Range("b125") 
q8 = Range("b126") 
Range("b127") = "not applicable" 
Range("b128") = "not applicable" 
mvab = Range("b129") 
nit = Range("b130") 
'If r69 = 0 And x69 = 0 And x710 = 0 And r710 = 0 Then 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z23 = ((r23) ^ 2 + (x23) ^ 2) ^ 0.5 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z25 = ((r25) ^ 2 + (x25) ^ 2) ^ 0.5 
z36 = ((r36) ^ 2 + (x36) ^ 2) ^ 0.5 
z47 = ((r47) ^ 2 + (x47) ^ 2) ^ 0.5 
z58 = ((r58) ^ 2 + (x58) ^ 2) ^ 0.5 
y12 = 1 / z12 
y23 = 1 / z23 
y24 = 1 / z24 
y25 = 1 / z25 
y36 = 1 / z36 
y47 = 1 / z47 
y58 = 1 / z58 
an12 = Atn(x12 / r12) 
an23 = Atn(x23 / r23) 
an24 = Atn(x24 / r24) 
an25 = Atn(x25 / r25) 
an36 = Atn(x36 / r36) 
an47 = Atn(x47 / r47) 
an58 = Atn(x58 / r58) 
b12 = y12 * Sin(­an12) 
b23 = y23 * Sin(­an23) 
b24 = y24 * Sin(­an24) 
b25 = y25 * Sin(­an25) 
b36 = y36 * Sin(­an36) 
b47 = y47 * Sin(­an47) 
b58 = y58 * Sin(­an58) 
yc12 = (mvac12) / mvab 
yc23 = (mvac23) / mvab 
yc24 = (mvac24) / mvab 
yc25 = (mvac25) / mvab 
g12 = y12 * Cos(­an12) 
g23 = y23 * Cos(­an23) 
g24 = y24 * Cos(­an24) 
g25 = y25 * Cos(­an25) 
g36 = y36 * Cos(­an36) 
g47 = y47 * Cos(­an47) 
g58 = y58 * Cos(­an58) 
gb22 = g12 + g23 + g24 + g25 
gb33 = g23 + g36 
gb44 = g24 + g47 
gb55 = g25 + g58 
gb66 = g36 
gb77 = g47 
gb88 = g58 
gb12 = ­g12 
gb21 = ­g12 
gb23 = ­g23 
gb32 = ­g23 
gb24 = ­g24 
gb42 = ­g24 
gb25 = ­g25 
gb52 = ­g25 
gb36 = ­g36 
gb63 = ­g36 
gb47 = ­g47 
gb47 = ­g47 
gb58 = ­g58 
gb85 = ­g58 
bb11 = b12 + yc12 
bb22 = b12 + b23 + yc23 + b24 + yc24 + b25 + yc25 
bb33 = b23 + b36 
bb55 = b25 + b58 
bb66 = b36 
bb88 = b58 
If xmotst < 0 Then bb44 = b24 + b47 + (1 / xmotst) 
If xmotst = 0 Then bb44 = b24 + b47 
If xmotst1 < 0 Then bb77 = b47 + (1 / xmotst1) 
If xmotst1 = 0 Then bb77 = b47 
bb12 = ­b12 
bb21 = ­b12 
bb23 = ­b23 
bb32 = ­b23 
bb24 = ­b24 
bb42 = ­b24 
bb25 = ­b25 
bb52 = ­b25 
bb36 = ­b36 
bb63 = ­b36 
bb47 = ­b47 
bb74 = ­b47 
bb58 = ­b58 
bb85 = ­b58 
y110 = bb22 / bb22 
y120 = ­bb23 / ­bb22 
y130 = ­bb24 / ­bb22 
y140 = ­bb25 / ­bb22 
y150 = ­bb26 / ­bb22 
y160 = ­bb27 / ­bb22 
y170 = ­bb28 / ­bb22 
y220 = ­bb33 ­ (­bb32) * (­bb23) / (­bb22) 
y230 = ­bb34 ­ (­bb32) * (­bb24) / (­bb22) 
y240 = ­bb35 ­ (­bb32) * (­bb25) / ­bb22 
y250 = ­bb36 ­ (­bb32) * (­bb26) / ­bb22 
y260 = ­bb37 ­ (­bb32) * (­bb27) / ­bb22 
y270 = ­bb38 ­ (­bb32) * (­bb28) / ­bb22 
y320 = ­bb43 ­ (­bb42) * (­bb23) / ­bb22 
y330 = ­bb44 ­ (­bb42) * (­bb24) / ­bb22 
y340 = ­bb45 ­ (­bb42) * (­bb25) / ­bb22 
y350 = ­bb46 ­ (­bb42) * (­bb26) / ­bb22 
y360 = ­bb47 ­ (­bb42) * (­bb27) / ­bb22 
y370 = ­bb48 ­ (­bb42) * (­bb28) / ­bb22 
y420 = ­bb53 ­ (­bb52) * (­bb23) / ­bb22 
y430 = ­bb54 ­ (­bb52) * (­bb24) / ­bb22 
y440 = ­bb55 ­ (­bb52) * (­bb25) / ­bb22 
y450 = ­bb56 ­ (­bb52) * (­bb26) / ­bb22 
y460 = ­bb57 ­ (­bb52) * (­bb27) / ­bb22 
y470 = ­bb58 ­ (­bb52) * (­bb28) / ­bb22 
y520 = ­bb63 ­ (­bb62) * (­bb23) / ­bb22 
y530 = ­bb64 ­ (­bb62) * (­bb24) / ­bb22 
y540 = ­bb65 ­ (­bb62) * (­bb25) / ­bb22 
y550 = ­bb66 ­ (­bb62) * (­bb26) / ­bb22 
y560 = ­bb67 ­ (­bb62) * (­bb27) / ­bb22 
y570 = ­bb68 ­ (­bb62) * (­bb28) / ­bb22 
y620 = ­bb73 ­ (­bb72) * (­bb23) / ­bb22 
y630 = ­bb74 ­ (­bb72) * (­bb24) / ­bb22 
y640 = ­bb75 ­ (­bb72) * (­bb25) / ­bb22 
y650 = ­bb76 ­ (­bb72) * (­bb26) / ­bb22 
y660 = ­bb77 ­ (­bb72) * (­bb27) / ­bb22 
y670 = ­bb78 ­ (­bb72) * (­bb28) / ­bb22 
y720 = ­bb83 ­ (­bb82) * (­bb23) / ­bb22 
y730 = ­bb84 ­ (­bb82) * (­bb24) / ­bb22 
y740 = ­bb85 ­ (­bb82) * (­bb25) / ­bb22 
y750 = ­bb86 ­ (­bb82) * (­bb26) / ­bb22 
y760 = ­bb87 ­ (­bb82) * (­bb27) / ­bb22 
y770 = ­bb88 ­ (­bb82) * (­bb28) / ­bb22 
  
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y261 = y260 / y220 
y271 = y270 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y361 = y360 ­ (y320) * (y260) / y220 
y371 = y370 ­ (y320) * (y270) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y461 = y460 ­ (y420) * (y260) / y220 
y471 = y470 ­ (y420) * (y270) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y561 = y560 ­ (y520) * (y260) / y220 
y571 = y570 ­ (y520) * (y270) / y220 
y631 = y630 ­ (y620) * (y230) / y220 
y641 = y640 ­ (y620) * (y240) / y220 
y651 = y650 ­ (y620) * (y250) / y220 
y661 = y660 ­ (y620) * (y260) / y220 
y671 = y670 ­ (y620) * (y270) / y220 
y731 = y730 ­ (y720) * (y230) / y220 
y741 = y740 ­ (y720) * (y240) / y220 
y751 = y750 ­ (y720) * (y250) / y220 
y761 = y760 ­ (y720) * (y260) / y220 
y771 = y770 ­ (y720) * (y270) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y362 = y361 / y331 
y372 = y371 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y462 = y461 ­ (y431) * (y361) / y331 
y472 = y471 ­ (y431) * (y371) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y562 = y561 ­ (y531) * (y361) / y331 
y572 = y571 ­ (y531) * (y371) / y331 
y642 = y641 ­ (y631) * (y341) / y331 
y652 = y651 ­ (y631) * (y351) / y331 
y662 = y661 ­ (y631) * (y361) / y331 
y672 = y671 ­ (y631) * (y371) / y331 
y742 = y741 ­ (y731) * (y341) / y331 
y752 = y751 ­ (y731) * (y351) / y331 
y762 = y761 ­ (y731) * (y361) / y331 
y772 = y771 ­ (y731) * (y371) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y463 = y462 / y442 
y473 = y472 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
y563 = y562 ­ (y542) * (y462) / y442 
y573 = y572 ­ (y542) * (y472) / y442 
y653 = y652 ­ (y642) * (y452) / y442 
y663 = y662 ­ (y642) * (y462) / y442 
y673 = y672 ­ (y642) * (y472) / y442 
y753 = y752 ­ (y742) * (y452) / y442 
y763 = y762 ­ (y742) * (y462) / y442 
y773 = y772 ­ (y742) * (y472) / y442 
y554 = y553 / y553 
y564 = y563 / y553 
y574 = y573 / y553 
y664 = y663 ­ (y653) * (y563) / y553 
y674 = y673 ­ (y653) * (y573) / y553 
y764 = y763 ­ (y753) * (y563) / y553 
y774 = y773 ­ (y753) * (y573) / y553 
y665 = y664 / y664 
y675 = y674 / y664 
y775 = y774 ­ (y764) * (y674) / y664 
  
For i = 1 To nit 
pb1(2, i) = (v(2, i) * v(4, i)) * (­y24 * Cos(­an24 + d(4, i) ­ d(2, i))) + (v(2, i) * v(5, i)) * (­y25 * Cos(­
an25 + d(5, i) ­ d(2, i))) 
pb(2, i) = ((gb22) * ((v(2, i)) ^ 2)) + ((v(2, i) * v1) * (­y12 * Cos(­an12 + d1 ­ d(2, i))) + (v(2, i) * v(3, 
i)) * (­y23 * Cos(­an23 + d(3, i) ­ d(2, i))) + pb1(2, i)) 
pb(3, i) = ((gb33) * ((v(3, i)) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Cos(­an23 + d(2, i) ­ d(3, i))) + (v(3, i) 
* v(6, i)) * (­y36 * Cos(­an36 + d(6, i) ­ d(3, i)))) 
pb(4, i) = ((gb44) * ((v(4, i)) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Cos(­an24 + d(2, i) ­ d(4, i))) + (v(4, i) 
* v(7, i)) * (­y47 * Cos(­an47 + d(7, i) ­ d(4, i)))) 
pb(5, i) = ((gb55) * ((v(5, i)) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Cos(­an25 + d(2, i) ­ d(5, i))) + (v(5, i) 
* v(8, i)) * (­y58 * Cos(­an58 + d(8, i) ­ d(5, i)))) 
pb(6, i) = ((gb66) * ((v(6, i)) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Cos(­an36 + d(3, i) ­ d(6, i)))) 
pb(7, i) = ((gb77) * ((v(7, i)) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Cos(­an47 + d(4, i) ­ d(7, i)))) 
pb(8, i) = ((gb88) * ((v(8, i)) ^ 2)) + ((v(8, i) * v(5, i)) * (­y58 * Cos(­an58 + d(5, i) ­ d(8, i)))) 
diffp(2, i) = (1 / v(2, i)) * ((p2 / mvab) ­ pb(2, i)) 
diffp(3, i) = (1 / v(3, i)) * ((p3 / mvab) ­ pb(3, i)) 
diffp(4, i) = (1 / v(4, i)) * ((p4 / mvab) ­ pb(4, i)) 
diffp(5, i) = (1 / v(5, i)) * ((p5 / mvab) ­ pb(5, i)) 
diffp(6, i) = (1 / v(6, i)) * ((p6 / mvab) ­ pb(6, i)) 
diffp(7, i) = (1 / v(7, i)) * ((p7 / mvab) ­ pb(7, i)) 
diffp(8, i) = (1 / v(8, i)) * ((p8 / mvab) ­ pb(8, i)) 
intu(1, i) = diffp(2, i) / ­bb22 
intu(2, i) = (diffp(3, i) ­ (intu(1, i)) * (­bb32)) / y220 
intu(3, i) = (diffp(4, i) ­ (intu(1, i)) * (­bb42) ­ (y320) * (intu(2, i))) / y331 
intu(4, i) = (diffp(5, i) ­ (intu(1, i)) * (­bb52) ­ (y420) * (intu(2, i)) ­ (intu(3, i)) * (y431)) / y442 
intu(5, i) = (diffp(6, i) ­ (intu(1, i)) * (­bb62) ­ (y520) * (intu(2, i)) ­ (intu(3, i)) * (y531) ­ (intu(4, i)) * 
(y542)) / y553 
intu(6, i) = (diffp(7, i) ­ (intu(1, i)) * (­bb72) ­ (y620) * (intu(2, i)) ­ (y631) * (intu(3, i)) ­ (y642) * 
(intu(4, i)) ­ (y653) * (intu(5, i))) / y664 
intu(7, i) = (diffp(8, i) ­ (intu(1, i)) * (­bb82) ­ (y720) * (intu(2, i)) ­ (y731) * (intu(3, i)) ­ (y742) * 
(intu(4, i)) ­ (y753) * (intu(5, i)) ­ (y764) * (intu(6, i))) / y775 
dd(8, i) = intu(7, i) 
dd(7, i) = (intu(6, i) ­ ((y675) * (dd(8, i)))) 
dd(6, i) = (intu(5, i) ­ ((y564) * (dd(7, i))) ­ ((y574) * (dd(8, i)))) 
dd(5, i) = (intu(4, i) ­ ((y453) * (dd(6, i))) ­ ((y463) * (dd(7, i))) ­ ((y473) * (dd(8, i)))) 
dd(4, i) = (intu(3, i) ­ ((y342) * (dd(5, i))) ­ ((y352) * (dd(6, i))) ­ ((y362) * (dd(7, i))) ­ ((y372) * (dd(8, 
i)))) 
dd(3, i) = (intu(2, i) ­ ((y231) * (dd(4, i))) ­ ((y241) * (dd(5, i))) ­ ((y251) * (dd(6, i))) ­ ((y261) * (dd(7, 
i))) ­ ((y271) * (dd(8, i)))) 
dd(2, i) = (intu(1, i) ­ ((y120) * (dd(3, i))) ­ ((y130) * (dd(4, i))) ­ ((y140) * (dd(5, i))) ­ ((y150) * (dd(6, 
i))) ­ ((y160) * (dd(7, i))) ­ ((y170) * (dd(8, i)))) 
d(2, i + 1) = d(2, i) + dd(2, i) 
d(3, i + 1) = d(3, i) + dd(3, i) 
d(4, i + 1) = d(4, i) + dd(4, i) 
d(5, i + 1) = d(5, i) + dd(5, i) 
d(6, i + 1) = d(6, i) + dd(6, i) 
d(7, i + 1) = d(7, i) + dd(7, i) 
d(8, i + 1) = d(8, i) + dd(8, i) 
dq2(2, i) = ((v(2, i) * v(4, i)) * (­y24 * Sin(­an24 ­ d(2, i + 1) + d(4, i + 1)))) 
dq1(2, i) = ((v(2, i) * v(5, i)) * (­y25 * Sin(­an25 ­ d(2, i + 1) + d(5, i + 1)))) 
dq3(2, i) = ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(3, i + 1) ­ d(2, i + 1)))) 
dq4(2, i) = ((v1 * v(2, i)) * (­y12 * Sin(­an12 + d1 ­ d(2, i + 1)))) 
dq(2, i) = ((q2 / mvab) + ((bb22) * (v(2, i) ^ 2)) + dq1(2, i) + dq2(2, i) + dq3(2, i) + dq4(2, i)) / v(2, i) 
dq(3, i) = ((q3 / mvab) + ((bb33) * (v(3, i) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(2, i + 1) ­ 
d(3, i + 1)))) + ((v(3, i) * v(6, i)) * (­y36 * Sin(­an36 + d(6, i + 1) ­ d(3, i + 1))))) / v(3, i) 
dq(4, i) = ((q4 / mvab) + ((bb44) * (v(4, i) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Sin(­an24 ­ d(4, i + 1) + 
d(2, i + 1)))) + ((v(4, i) * v(7, i)) * (­y47 * Sin(­an47 ­ d(4, i + 1) + d(7, i + 1))))) / v(4, i) 
dq(5, i) = ((q5 / mvab) + ((bb55) * (v(5, i) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Sin(­an25 ­ d(5, i + 1) + 
d(2, i + 1)))) + ((v(5, i) * v(8, i)) * (­y58 * Sin(­an58 ­ d(5, i + 1) + d(8, i + 1))))) / v(5, i) 
dq(6, i) = ((q6 / mvab) + ((bb66) * (v(6, i) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Sin(­an36 ­ d(6, i + 1) + 
d(3, i + 1))))) / v(6, i) 
dq(7, i) = ((q7 / mvab) + ((bb77) * (v(7, i) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Sin(­an47 ­ d(7, i + 1) + 
d(4, i + 1))))) / v(7, i) 
dq(8, i) = ((q8 / mvab) + ((bb88) * (v(8, i) ^ 2)) + ((v(8, i) * v(5, i)) * (­y58 * Sin(­an58 ­ d(8, i + 1) + 
d(5, i + 1))))) / v(8, i) 
intv(1, i) = dq(2, i) / ­bb22 
intv(2, i) = (dq(3, i) ­ (intv(1, i)) * (­bb32)) / y220 
intv(3, i) = (dq(4, i) ­ (intv(1, i)) * (­bb42) ­ (y320) * (intv(2, i))) / y331 
intv(4, i) = (dq(5, i) ­ (intv(1, i)) * (­bb52) ­ (y420) * (intv(2, i)) ­ (intv(3, i)) * (y431)) / y442 
intv(5, i) = (dq(6, i) ­ (intv(1, i)) * (­bb62) ­ (y520) * (intv(2, i)) ­ (intv(3, i)) * (y531) ­ (intv(4, i)) * 
(y542)) / y553 
intv(6, i) = (dq(7, i) ­ (intv(1, i)) * (­bb72) ­ (y620) * (intv(2, i)) ­ (y631) * (intv(3, i)) ­ (y642) * (intv(4, 
i)) ­ (y653) * (intv(5, i))) / y664 
intv(7, i) = (dq(8, i) ­ (intv(1, i)) * (­bb82) ­ (y720) * (intv(2, i)) ­ (y731) * (intv(3, i)) ­ (y742) * (intv(4, 
i)) ­ (y753) * (intv(5, i)) ­ (y764) * (intv(6, i))) / y775 
dv(8, i) = intv(7, i) 
dv(7, i) = (intv(6, i) ­ ((y675) * (dv(8, i)))) 
dv(6, i) = (intv(5, i) ­ ((y564) * (dv(7, i))) ­ ((y574) * (dv(8, i)))) 
dv(5, i) = (intv(4, i) ­ ((y453) * (dv(6, i))) ­ ((y463) * (dv(7, i))) ­ ((y473) * (dv(8, i)))) 
dv(4, i) = (intv(3, i) ­ ((y342) * (dv(5, i))) ­ ((y352) * (dv(6, i))) ­ ((y362) * (dv(7, i))) ­ ((y372) * (dv(8, 
i)))) 
dv(3, i) = (intv(2, i) ­ ((y231) * (dv(4, i))) ­ ((y241) * (dv(5, i))) ­ ((y251) * (dv(6, i))) ­ ((y261) * (dv(7, 
i))) ­ ((y271) * (dv(8, i)))) 
dv(2, i) = (intv(1, i) ­ ((y120) * (dv(3, i))) ­ ((y130) * (dv(4, i))) ­ ((y140) * (dv(5, i))) ­ ((y150) * (dv(6, 
i))) ­ ((y160) * (dv(7, i))) ­ ((y170) * (dv(8, i)))) 
  
v(2, i + 1) = v(2, i) + dv(2, i) 
v(3, i + 1) = v(3, i) + dv(3, i) 
v(4, i + 1) = v(4, i) + dv(4, i) 
v(5, i + 1) = v(5, i) + dv(5, i) 
v(6, i + 1) = v(6, i) + dv(6, i) 
v(7, i + 1) = v(7, i) + dv(7, i) 
v(8, i + 1) = v(8, i) + dv(8, i) 
v(2, i) = v(2, i + 1) 
v(3, i) = v(3, i + 1) 
v(4, i) = v(4, i + 1) 
v(5, i) = v(5, i + 1) 
v(6, i) = v(6, i + 1) 
v(7, i) = v(7, i + 1) 
v(8, i) = v(8, i + 1) 
 d(2, i) = d(2, i + 1) 
 d(3, i) = d(3, i + 1) 
 d(4, i) = d(4, i + 1) 
 d(5, i) = d(5, i + 1) 
 d(6, i) = d(6, i + 1) 
 d(7, i) = d(7, i + 1) 
 d(8, i) = d(8, i + 1) 
Next i 
'Print "voltage at bus 2: "; v(2, i) 
'Print "phase angle at bus 2: "; d(2, i); "rad"; "in degrees:"; d(2, i) * 180 / 3.14159265 
'Print "voltage at bus 3: "; v(3, i) 
'Print "phase angle at bus 3: "; d(3, i); "rad"; "in degrees:"; d(3, i) * 180 / 3.14159265 
'Print "voltage at bus 4: "; v(4, i) 
'Print "phase angle at bus 4: "; d(4, i); "rad"; "in degrees:"; d(4, i) * 180 / 3.14159265 
'Print "voltage at bus 5: "; v(5, i) 
'Print "phase angle at bus 5: "; d(5, i); "rad"; "in degrees:"; d(5, i) * 180 / 3.14159265 
'Print "voltage at bus 6: "; v(6, i) 
'Print "phase angle at bus 6: "; d(6, i); "rad"; "in degrees:"; d(6, i) * 180 / 3.14159265 
'Print "voltage at bus 7: "; v(7, i) 
'Print "phase angle at bus 7: "; d(7, i); "rad"; "in degrees:"; d(7, i) * 180 / 3.14159265 
'Print "voltage at bus 8: "; v(8, i) 
'Print "phase angle at bus 8: "; d(8, i); "rad"; "in degrees:"; d(8, i) * 180 / 3.14159265 
act2 = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
act1 = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 
act6 = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
act5 = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 
act4 = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 
act3 = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
act8 = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 
act7 = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 
act9 = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 
act10 = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 
act11 = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
act12 = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
act13 = (((v(5, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(8, i) ­ d(5, i))))) 
act14 = (((v(8, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(5, i) ­ d(8, i))))) 
'Print "active power in p.u.from bus 2 towards 3:"; act1 
'Print "active power in p.u.from bus 1 towards 2:"; act2 
'Print "active power in p.u.from bus 2 towards 1:"; act3 
'Print "active power in p.u.from bus 3 towards 2:"; act4 
'Print "active power in p.u.from bus 4 towards 2:"; act5 
'Print "active power in p.u.from bus 2 towards 4:"; act6 
'Print "active power in p.u.from bus 5 towards 2:"; act7 
'Print "active power in p.u.from bus 2 towards 5:"; act8 
'Print "active power in p.u.from bus 3 towards 6:"; act9 
'Print "active power in p.u.from bus 6 towards 3:"; act10 
'Print "active power in p.u.from bus 4 towards 7:"; act11 
'Print "active power in p.u.from bus 7 towards 4:"; act12 
'Print "active power in p.u.from bus 5 towards 8:"; act13 
'Print "active power in p.u.from bus 8 towards 5:"; act14 
react1 = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 + d(3, i) 
­ d(2, i))))) 
react2 = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
react5 = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
react6 = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(4, i) 
­ d(2, i))))) 
react7 = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
react8 = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(5, i) 
­ d(2, i))))) 
react3 = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + d1 ­ d(2, 
i))))) 
react4 = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
react9 = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
react10 = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
react11 = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
react12 = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
react13 = (­(v(5, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(8, i) ­ d(5, i))))) 
react14 = (­(v(8, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(5, i) ­ d(8, i))))) 
'Print "reactive power from bus 2 towards 3:"; react1 
'Print "reactive power from bus 1 towards 2:"; react2 
'Print "reactive power from bus 2 towards 1:"; react3 
'Print "reactive power from bus 3 towards 2:"; react4 
'Print "reactive power from bus 4 towards 2:"; react5 
'Print "reactive power from bus 2 towards 4:"; react6 
'Print "reactive power from bus 5 towards 2:"; react7 
'Print "reactive power from bus 2 towards 5:"; react8 
'Print "reactive power from bus 3 towards 6:"; react9 
'Print "reactive power from bus 6 towards 3:"; react10 
'Print "reactive power from bus 4 towards 7:"; react11 
'Print "reactive power from bus 7 towards 4:"; react12 
'Print "reactive power from bus 5 towards 8:"; react13 
'Print "reactive power from bus 8 towards 5:"; react14 
Range("a132") = "The voltage on bus 2 in pu" 
Range("b132") = v(2, i) 
Range("a133") = "The voltage on bus 3 in pu" 
Range("b133") = v(3, i) 
Range("a134") = "The voltage on bus 4 in pu" 
Range("b134") = v(4, i) 
Range("a135") = "The voltage on bus 5 in pu" 
Range("b135") = v(5, i) 
Range("a136") = "The voltage on bus 6 in pu" 
Range("b136") = v(6, i) 
Range("a137") = "The voltage on bus 7 in pu" 
Range("b137") = v(7, i) 
Range("a138") = "The voltage on bus 8 in pu" 
Range("b138") = v(8, i) 
Range("a139") = "The voltage on bus 9 in pu" 
Range("b139") = "not applicable" 
Range("a140") = "The voltage on bus 10 in pu" 
Range("b140") = "not applicable" 
Range("a141") = "The phase angle at bus 2 in rad. & degrees" 
Range("b141") = d(2, i) 
Range("c141") = d(2, i) * 180 / 3.14159265 
Range("a142") = "The phase angle at bus 3 in rad. & degrees" 
Range("b142") = d(3, i) 
Range("c142") = d(3, i) * 180 / 3.14159265 
Range("a143") = "The phase angle at bus 4 in rad. & degrees" 
Range("b143") = d(4, i) 
Range("c143") = d(4, i) * 180 / 3.14159265 
Range("a144") = "The phase angle at bus 5 in rad. & degrees" 
Range("b144") = d(5, i) 
Range("c144") = d(5, i) * 180 / 3.14159265 
Range("a145") = "The phase angle at bus 6 in pu" 
Range("b145") = d(6, i) 
Range("c145") = d(6, i) * 180 / 3.14159265 
Range("a146") = "The phase angle at bus 7 in pu" 
Range("b146") = d(7, i) 
Range("c146") = d(7, i) * 180 / 3.14159265 
Range("a147") = "The phase angle at bus 8 in pu" 
Range("b147") = d(8, i) 
Range("c147") = d(8, i) * 180 / 3.14159265 
Range("a148") = "The phase angle at bus 9 in pu" 
Range("b148") = "not applicable" 
Range("c148") = "not applicable" 
Range("a149") = "The phase angle at bus 10 in pu" 
Range("b149") = "not applicable" 
Range("c149") = "not applicable" 
Range("a150") = "The active power flowing from bus 1 to 2 in pu" 
Range("b150") = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
Range("a151") = "The active power flowing from bus 2 to 1 in pu" 
Range("b151") = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
Range("a152") = "The active power flowing from bus 2 to 3 in pu" 
Range("b152") = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 

Range("a153") = "The active power flowing from bus 3 to 2 in pu" 
Range("b153") = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 

Range("a154") = "The active power flowing from bus 2 to 4 in pu" 
Range("b154") = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 

Range("a155") = "The active power flowing from bus 4 to 2 in pu" 
Range("b155") = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 

Range("a156") = "The active power flowing from bus 2 to 5 in pu" 
Range("b156") = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 

Range("a157") = "The active power flowing from bus 5 to 2 in pu" 
Range("b157") = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 

Range("a158") = "The active power flowing from bus 3 to 6 in pu" 
Range("b158") = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 

Range("a159") = "The active power flowing from bus 6 to 3 in pu" 
Range("b159") = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 

Range("a160") = "The active power flowing from bus 4 to 7 in pu" 
Range("b160") = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
Range("a161") = "The active power flowing from bus 7 to 4 in pu" 
Range("b161") = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
Range("a162") = "The active power flowing from bus 5 to 8 in pu" 
Range("b162") = (((v(5, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(8, i) ­ d(5, i))))) 

Range("a163") = "The active power flowing from bus 8 to 5 in pu" 
Range("b163") = (((v(8, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(5, i) ­ d(8, i))))) 

Range("a164") = "The active power flowing from bus 6 to 9 in pu" 
Range("b164") = "not applicable" 
Range("a165") = "The active power flowing from bus 9 to 6 in pu" 
Range("b165") = "not applicable" 
Range("a166") = "The active power flowing from bus 7 to 10 in pu" 
Range("b166") = "not applicable" 
Range("a167") = "The active power flowing from bus 10 to 7 in pu" 
Range("b167") = "not applicable" 
Range("a168") = "The reactive power flowing from bus 1 to 2 in pu" 
Range("b168") = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
Range("a169") = "The reactive power flowing from bus 2 to 1 in pu" 
Range("b169") = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + 
d1 ­ d(2, i))))) 
Range("a170") = "The reactive power flowing from bus 2 to 3 in pu" 
Range("b170") = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 
+ d(3, i) ­ d(2, i))))) 
Range("a171") = "The reactive power flowing from bus 3 to 2 in pu" 
Range("b171") = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
Range("a172") = "The reactive power flowing from bus 2 to 4 in pu" 
Range("b172") = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 
+ d(4, i) ­ d(2, i))))) 
Range("a173") = "The reactive power flowing from bus 4 to 2 in pu" 
Range("b173") = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
Range("a174") = "The reactive power flowing from bus 2 to 5 in pu" 
Range("b174") = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 
+ d(5, i) ­ d(2, i))))) 
Range("a175") = "The reactive power flowing from bus 5 to 2 in pu" 
Range("b175") = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
Range("a176") = "The reactive power flowing from bus 3 to 6 in pu" 
Range("b176") = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
Range("a177") = "The reactive power flowing from bus 6 to 3 in pu" 
Range("b177") = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
Range("a178") = "The reactive power flowing from bus 4 to 7 in pu" 
Range("b178") = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
Range("a179") = "The reactive power flowing from bus 7 to 4 in pu" 
Range("b179") = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
Range("a180") = "The reactive power flowing from bus 5 to 8 in pu" 
Range("b180") = (­(v(5, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(8, i) ­ d(5, i))))) 
Range("a181") = "The reactive power flowing from bus 8 to 5 in pu" 
Range("b181") = (­(v(8, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(5, i) ­ d(8, i))))) 
Range("a182") = "The reactive power flowing from bus 6 to 9 in pu" 
Range("b182") = "not applicable" 
Range("a183") = "The reactive power flowing from bus 9 to 6 in pu" 
Range("b183") = "not applicable" 
Range("a184") = "The reactive power flowing from bus 7 to 10 in pu" 
Range("b184") = "not applicable" 
Range("a185") = "The reactive power flowing from bus 10 to 7 in pu" 
Range("b185") = "not applicable" 
For i = nit ­ 1 To nit 
'Print diffp(2, i), diffp(3, i), diffp(4, i), diffp(5, i), diffp(6, i), dq(2, i), dq(3, i), dq(4, i), dq(5, i), dq(6, i) 
Next i 
End Sub 
Sub MySub135() 
Dim d(30, 30) 
Dim dd(30, 30) 
Dim diffp(30, 30) 
Dim dq(30, 30) 
Dim dq1(30, 30) 
Dim dq2(30, 30) 
Dim dq3(30, 30) 
Dim dq4(30, 30) 
Dim dv(30, 30) 
Dim intv(30, 30) 
Dim intu(30, 30) 
Dim v(30, 30) 
Dim pb(30, 30) 
Dim pb1(30, 30) 
UserForm7.Show 
r12 = Range("b65") 
r23 = Range("b66") 
r24 = Range("b67") 
r25 = Range("b68") 
r36 = Range("b69") 
r47 = Range("b70") 
r58 = Range("b71") 
r69 = Range("b72") 
Range("b73") = "not applicable" 
x12 = Range("b74") 
x23 = Range("b75") 
x24 = Range("b76") 
x25 = Range("b77") 
x36 = Range("b78") 
x47 = Range("b79") 
x58 = Range("b80") 
x69 = Range("b81") 
Range("b82") = "not applicable" 
mvac12 = Range("b83") 
mvac23 = Range("b84") 
mvac24 = Range("b85") 
mvac25 = Range("b86") 
xmotst = Range("b87") 
xmotst1 = Range("b88") 
v1 = Range("b89") 
v(2, 1) = Range("b90") 
v(3, 1) = Range("b91") 
v(4, 1) = Range("b92") 
v(5, 1) = Range("b93") 
v(6, 1) = Range("b94") 
v(7, 1) = Range("b95") 
v(8, 1) = Range("b96") 
v(9, 1) = Range("b97") 
Range("b98") = "not applicable" 
d1 = Range("b99") 
d(2, 1) = Range("b100") 
d(3, 1) = Range("b101") 
d(4, 1) = Range("b102") 
d(5, 1) = Range("b103") 
d(6, 1) = Range("b104") 
d(7, 1) = Range("b105") 
d(8, 1) = Range("b106") 
d(9, 1) = Range("b107") 
Range("b108") = "not applicable" 
p1 = Range("b109") 
p2 = Range("b110") 
p3 = Range("b111") 
p4 = Range("b112") 
p5 = Range("b113") 
p6 = Range("b114") 
p7 = Range("b115") 
p8 = Range("b116") 
p9 = Range("b117") 
Range("b118") = "not applicable" 
q1 = Range("b119") 
q2 = Range("b120") 
q3 = Range("b121") 
q4 = Range("b122") 
q5 = Range("b123") 
q6 = Range("b124") 
q7 = Range("b125") 
q8 = Range("b126") 
q9 = Range("b127") 
Range("b128") = "not applicable" 
mvab = Range("b129") 
nit = Range("b130") 
'If x710 = 0 And r710 = 0 Then 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z23 = ((r23) ^ 2 + (x23) ^ 2) ^ 0.5 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z25 = ((r25) ^ 2 + (x25) ^ 2) ^ 0.5 
z36 = ((r36) ^ 2 + (x36) ^ 2) ^ 0.5 
z47 = ((r47) ^ 2 + (x47) ^ 2) ^ 0.5 
z58 = ((r58) ^ 2 + (x58) ^ 2) ^ 0.5 
z69 = ((r69) ^ 2 + (x69) ^ 2) ^ 0.5 
y12 = 1 / z12 
y23 = 1 / z23 
y24 = 1 / z24 
y25 = 1 / z25 
y36 = 1 / z36 
y47 = 1 / z47 
y58 = 1 / z58 
y69 = 1 / z69 
an12 = Atn(x12 / r12) 
an23 = Atn(x23 / r23) 
an24 = Atn(x24 / r24) 
an25 = Atn(x25 / r25) 
an36 = Atn(x36 / r36) 
an47 = Atn(x47 / r47) 
an58 = Atn(x58 / r58) 
an69 = Atn(x69 / r69) 
b12 = y12 * Sin(­an12) 
b23 = y23 * Sin(­an23) 
b24 = y24 * Sin(­an24) 
b25 = y25 * Sin(­an25) 
b36 = y36 * Sin(­an36) 
b47 = y47 * Sin(­an47) 
b58 = y58 * Sin(­an58) 
b69 = y69 * Sin(­an69) 
yc12 = (mvac12) / mvab 
yc23 = (mvac23) / mvab 
yc24 = (mvac24) / mvab 
yc25 = (mvac25) / mvab 
g12 = y12 * Cos(­an12) 
g23 = y23 * Cos(­an23) 
g24 = y24 * Cos(­an24) 
g25 = y25 * Cos(­an25) 
g36 = y36 * Cos(­an36) 
g47 = y47 * Cos(­an47) 
g58 = y58 * Cos(­an58) 
g69 = y69 * Cos(­an69) 
gb22 = g12 + g23 + g24 + g25 
gb33 = g23 + g36 
gb44 = g24 + g47 
gb55 = g25 + g58 
gb66 = g36 + g69 
gb77 = g47 
gb88 = g58 
gb99 = g69 
gb12 = ­g12 
gb21 = ­g12 
gb23 = ­g23 
gb32 = ­g23 
gb24 = ­g24 
gb42 = ­g24 
gb25 = ­g25 
gb52 = ­g25 
gb36 = ­g36 
gb63 = ­g36 
gb47 = ­g47 
gb47 = ­g47 
gb58 = ­g58 
gb85 = ­g58 
gb69 = ­g69 
gb96 = ­g69 
bb11 = b12 + yc12 
bb22 = b12 + b23 + yc23 + b24 + yc24 + b25 + yc25 
bb33 = b23 + b36 
bb55 = b25 + b58 
bb66 = b36 + b69 
bb88 = b58 
bb99 = b69 
If xmotst < 0 Then bb44 = b24 + b47 + (1 / xmotst) 
If xmotst = 0 Then bb44 = b24 + b47 
If xmotst1 < 0 Then bb77 = b47 + (1 / xmotst1) 
If xmotst1 = 0 Then bb77 = b47 
bb12 = ­b12 
bb21 = ­b12 
bb23 = ­b23 
bb32 = ­b23 
bb24 = ­b24 
bb42 = ­b24 
bb25 = ­b25 
bb52 = ­b25 
bb36 = ­b36 
bb63 = ­b36 
bb47 = ­b47 
bb74 = ­b47 
bb58 = ­b58 
bb85 = ­b58 
bb69 = ­b69 
bb96 = ­b69 
For i = 1 To nit 
pb1(2, i) = (v(2, i) * v(4, i)) * (­y24 * Cos(­an24 + d(4, i) ­ d(2, i))) + (v(2, i) * v(5, i)) * (­y25 * Cos(­
an25 + d(5, i) ­ d(2, i))) 
pb(2, i) = ((gb22) * ((v(2, i)) ^ 2)) + ((v(2, i) * v1) * (­y12 * Cos(­an12 + d1 ­ d(2, i))) + (v(2, i) * v(3, 
i)) * (­y23 * Cos(­an23 + d(3, i) ­ d(2, i))) + pb1(2, i)) 
pb(3, i) = ((gb33) * ((v(3, i)) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Cos(­an23 + d(2, i) ­ d(3, i))) + (v(3, i) 
* v(6, i)) * (­y36 * Cos(­an36 + d(6, i) ­ d(3, i)))) 
pb(4, i) = ((gb44) * ((v(4, i)) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Cos(­an24 + d(2, i) ­ d(4, i))) + (v(4, i) 
* v(7, i)) * (­y47 * Cos(­an47 + d(7, i) ­ d(4, i)))) 
pb(5, i) = ((gb55) * ((v(5, i)) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Cos(­an25 + d(2, i) ­ d(5, i))) + (v(5, i) 
* v(8, i)) * (­y58 * Cos(­an58 + d(8, i) ­ d(5, i)))) 
pb(6, i) = ((gb66) * ((v(6, i)) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Cos(­an36 + d(3, i) ­ d(6, i))) + (v(6, i) 
* v(9, i)) * (­y69 * Cos(­an69 + d(9, i) ­ d(6, i)))) 
pb(7, i) = ((gb77) * ((v(7, i)) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Cos(­an47 + d(4, i) ­ d(7, i)))) 
pb(8, i) = ((gb88) * ((v(8, i)) ^ 2)) + ((v(8, i) * v(5, i)) * (­y58 * Cos(­an58 + d(5, i) ­ d(8, i)))) 
pb(9, i) = ((gb99) * ((v(9, i)) ^ 2)) + ((v(9, i) * v(6, i)) * (­y69 * Cos(­an69 + d(6, i) ­ d(9, i)))) 
diffp(2, i) = (1 / v(2, i)) * ((p2 / mvab) ­ pb(2, i)) 
diffp(3, i) = (1 / v(3, i)) * ((p3 / mvab) ­ pb(3, i)) 
diffp(4, i) = (1 / v(4, i)) * ((p4 / mvab) ­ pb(4, i)) 
diffp(5, i) = (1 / v(5, i)) * ((p5 / mvab) ­ pb(5, i)) 
diffp(6, i) = (1 / v(6, i)) * ((p6 / mvab) ­ pb(6, i)) 
diffp(7, i) = (1 / v(7, i)) * ((p7 / mvab) ­ pb(7, i)) 
diffp(8, i) = (1 / v(8, i)) * ((p8 / mvab) ­ pb(8, i)) 
diffp(9, i) = (1 / v(9, i)) * ((p9 / mvab) ­ pb(9, i)) 
y110 = bb22 / bb22 
y120 = ­bb23 / ­bb22 
y130 = ­bb24 / ­bb22 
y140 = ­bb25 / ­bb22 
y150 = ­bb26 / ­bb22 
y160 = ­bb27 / ­bb22 
y170 = ­bb28 / ­bb22 
y180 = ­bb29 / ­bb22 
y220 = ­bb33 ­ (­bb32) * (­bb23) / (­bb22) 
y230 = ­bb34 ­ (­bb32) * (­bb24) / (­bb22) 
y240 = ­bb35 ­ (­bb32) * (­bb25) / ­bb22 
y250 = ­bb36 ­ (­bb32) * (­bb26) / ­bb22 
y260 = ­bb37 ­ (­bb32) * (­bb27) / ­bb22 
y270 = ­bb38 ­ (­bb32) * (­bb28) / ­bb22 
y280 = ­bb39 ­ (­bb32) * (­bb29) / ­bb22 
y320 = ­bb43 ­ (­bb42) * (­bb23) / ­bb22 
y330 = ­bb44 ­ (­bb42) * (­bb24) / ­bb22 
y340 = ­bb45 ­ (­bb42) * (­bb25) / ­bb22 
y350 = ­bb46 ­ (­bb42) * (­bb26) / ­bb22 
y360 = ­bb47 ­ (­bb42) * (­bb27) / ­bb22 
y370 = ­bb48 ­ (­bb42) * (­bb28) / ­bb22 
y380 = ­bb49 ­ (­bb42) * (­bb29) / ­bb22 
y420 = ­bb53 ­ (­bb52) * (­bb23) / ­bb22 
y430 = ­bb54 ­ (­bb52) * (­bb24) / ­bb22 
y440 = ­bb55 ­ (­bb52) * (­bb25) / ­bb22 
y450 = ­bb56 ­ (­bb52) * (­bb26) / ­bb22 
y460 = ­bb57 ­ (­bb52) * (­bb27) / ­bb22 
y470 = ­bb58 ­ (­bb52) * (­bb28) / ­bb22 
y480 = ­bb59 ­ (­bb52) * (­bb29) / ­bb22 
y520 = ­bb63 ­ (­bb62) * (­bb23) / ­bb22 
y530 = ­bb64 ­ (­bb62) * (­bb24) / ­bb22 
y540 = ­bb65 ­ (­bb62) * (­bb25) / ­bb22 
y550 = ­bb66 ­ (­bb62) * (­bb26) / ­bb22 
y560 = ­bb67 ­ (­bb62) * (­bb27) / ­bb22 
y570 = ­bb68 ­ (­bb62) * (­bb28) / ­bb22 
y580 = ­bb69 ­ (­bb62) * (­bb29) / ­bb22 
y620 = ­bb73 ­ (­bb72) * (­bb23) / ­bb22 
y630 = ­bb74 ­ (­bb72) * (­bb24) / ­bb22 
y640 = ­bb75 ­ (­bb72) * (­bb25) / ­bb22 
y650 = ­bb76 ­ (­bb72) * (­bb26) / ­bb22 
y660 = ­bb77 ­ (­bb72) * (­bb27) / ­bb22 
y670 = ­bb78 ­ (­bb72) * (­bb28) / ­bb22 
y680 = ­bb79 ­ (­bb72) * (­bb29) / ­bb22 
y720 = ­bb83 ­ (­bb82) * (­bb23) / ­bb22 
y730 = ­bb84 ­ (­bb82) * (­bb24) / ­bb22 
y740 = ­bb85 ­ (­bb82) * (­bb25) / ­bb22 
y750 = ­bb86 ­ (­bb82) * (­bb26) / ­bb22 
y760 = ­bb87 ­ (­bb82) * (­bb27) / ­bb22 
y770 = ­bb88 ­ (­bb82) * (­bb28) / ­bb22 
y780 = ­bb89 ­ (­bb82) * (­bb29) / ­bb22 
y820 = ­bb93 ­ (­bb92) * (­bb23) / ­bb22 
y830 = ­bb94 ­ (­bb92) * (­bb24) / ­bb22 
y840 = ­bb95 ­ (­bb92) * (­bb25) / ­bb22 
y850 = ­bb96 ­ (­bb92) * (­bb26) / ­bb22 
y860 = ­bb97 ­ (­bb92) * (­bb27) / ­bb22 
y870 = ­bb98 ­ (­bb92) * (­bb28) / ­bb22 
y880 = ­bb99 ­ (­bb92) * (­bb29) / ­bb22 
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y261 = y260 / y220 
y271 = y270 / y220 
y281 = y280 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y361 = y360 ­ (y320) * (y260) / y220 
y371 = y370 ­ (y320) * (y270) / y220 
y381 = y380 ­ (y320) * (y280) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y461 = y460 ­ (y420) * (y260) / y220 
y471 = y470 ­ (y420) * (y270) / y220 
y481 = y480 ­ (y420) * (y280) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y561 = y560 ­ (y520) * (y260) / y220 
y571 = y570 ­ (y520) * (y270) / y220 
y581 = y580 ­ (y520) * (y280) / y220 
y631 = y630 ­ (y620) * (y230) / y220 
y641 = y640 ­ (y620) * (y240) / y220 
y651 = y650 ­ (y620) * (y250) / y220 
y661 = y660 ­ (y620) * (y260) / y220 
y671 = y670 ­ (y620) * (y270) / y220 
y681 = y680 ­ (y620) * (y280) / y220 
y731 = y730 ­ (y720) * (y230) / y220 
y741 = y740 ­ (y720) * (y240) / y220 
y751 = y750 ­ (y720) * (y250) / y220 
y761 = y760 ­ (y720) * (y260) / y220 
y771 = y770 ­ (y720) * (y270) / y220 
y781 = y780 ­ (y720) * (y280) / y220 
y831 = y830 ­ (y820) * (y230) / y220 
y841 = y840 ­ (y820) * (y240) / y220 
y851 = y850 ­ (y820) * (y250) / y220 
y861 = y860 ­ (y820) * (y260) / y220 
y871 = y870 ­ (y820) * (y270) / y220 
y881 = y880 ­ (y820) * (y280) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y362 = y361 / y331 
y372 = y371 / y331 
y382 = y381 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y462 = y461 ­ (y431) * (y361) / y331 
y472 = y471 ­ (y431) * (y371) / y331 
y482 = y481 ­ (y431) * (y381) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y562 = y561 ­ (y531) * (y361) / y331 
y572 = y571 ­ (y531) * (y371) / y331 
y582 = y581 ­ (y531) * (y381) / y331 
y642 = y641 ­ (y631) * (y341) / y331 
y652 = y651 ­ (y631) * (y351) / y331 
y662 = y661 ­ (y631) * (y361) / y331 
y672 = y671 ­ (y631) * (y371) / y331 
y682 = y681 ­ (y631) * (y381) / y331 
y742 = y741 ­ (y731) * (y341) / y331 
y752 = y751 ­ (y731) * (y351) / y331 
y762 = y761 ­ (y731) * (y361) / y331 
y772 = y771 ­ (y731) * (y371) / y331 
y782 = y781 ­ (y731) * (y381) / y331 
y842 = y841 ­ (y831) * (y341) / y331 
y852 = y851 ­ (y831) * (y351) / y331 
y862 = y861 ­ (y831) * (y361) / y331 
y872 = y871 ­ (y831) * (y371) / y331 
y882 = y881 ­ (y831) * (y381) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y463 = y462 / y442 
y473 = y472 / y442 
y483 = y482 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
y563 = y562 ­ (y542) * (y462) / y442 
y573 = y572 ­ (y542) * (y472) / y442 
y583 = y582 ­ (y542) * (y482) / y442 
y653 = y652 ­ (y642) * (y452) / y442 
y663 = y662 ­ (y642) * (y462) / y442 
y673 = y672 ­ (y642) * (y472) / y442 
y683 = y682 ­ (y642) * (y482) / y442 
y753 = y752 ­ (y742) * (y452) / y442 
y763 = y762 ­ (y742) * (y462) / y442 
y773 = y772 ­ (y742) * (y472) / y442 
y783 = y782 ­ (y742) * (y482) / y442 
y853 = y852 ­ (y842) * (y452) / y442 
y863 = y862 ­ (y842) * (y462) / y442 
y873 = y872 ­ (y842) * (y472) / y442 
y883 = y882 ­ (y842) * (y482) / y442 
y554 = y553 / y553 
y564 = y563 / y553 
y574 = y573 / y553 
y584 = y583 / y553 
y664 = y663 ­ (y653) * (y563) / y553 
y674 = y673 ­ (y653) * (y573) / y553 
y684 = y683 ­ (y653) * (y583) / y553 
y764 = y763 ­ (y753) * (y563) / y553 
y774 = y773 ­ (y753) * (y573) / y553 
y784 = y783 ­ (y753) * (y583) / y553 
y864 = y863 ­ (y853) * (y563) / y553 
y874 = y873 ­ (y853) * (y573) / y553 
y884 = y883 ­ (y853) * (y583) / y553 
  
y665 = y664 / y664 
y675 = y674 / y664 
y685 = y684 / y664 
y775 = y774 ­ (y764) * (y674) / y664 
y785 = y784 ­ (y764) * (y684) / y664 
y875 = y874 ­ (y864) * (y674) / y664 
y885 = y884 ­ (y864) * (y684) / y664 
y776 = y775 / y775 
y786 = y785 / y775 
y886 = y885 ­ (y875) * (y785) / y775 
intu(1, i) = diffp(2, i) / ­bb22 
intu(2, i) = (diffp(3, i) ­ (intu(1, i)) * (­bb32)) / y220 
intu(3, i) = (diffp(4, i) ­ (intu(1, i)) * (­bb42) ­ (y320) * (intu(2, i))) / y331 
intu(4, i) = (diffp(5, i) ­ (intu(1, i)) * (­bb52) ­ (y420) * (intu(2, i)) ­ (intu(3, i)) * (y431)) / y442 
intu(5, i) = (diffp(6, i) ­ (intu(1, i)) * (­bb62) ­ (y520) * (intu(2, i)) ­ (intu(3, i)) * (y531) ­ (intu(4, i)) * 
(y542)) / y553 
intu(6, i) = (diffp(7, i) ­ (intu(1, i)) * (­bb72) ­ (y620) * (intu(2, i)) ­ (y631) * (intu(3, i)) ­ (y642) * 
(intu(4, i)) ­ (y653) * (intu(5, i))) / y664 
intu(7, i) = (diffp(8, i) ­ (intu(1, i)) * (­bb82) ­ (y720) * (intu(2, i)) ­ (y731) * (intu(3, i)) ­ (y742) * 
(intu(4, i)) ­ (y753) * (intu(5, i)) ­ (y764) * (intu(6, i))) / y775 
intu(8, i) = (diffp(9, i) ­ (intu(1, i)) * (­bb92) ­ (y820) * (intu(2, i)) ­ (y831) * (intu(3, i)) ­ (y842) * 
(intu(4, i)) ­ (y853) * (intu(5, i)) ­ (y864) * (intu(6, i)) ­ (y875) * (intu(7, i))) / y886 
dd(9, i) = intu(8, i) 
dd(8, i) = (intu(7, i) ­ ((y786) * (dd(9, i)))) 
dd(7, i) = (intu(6, i) ­ ((y675) * (dd(8, i))) ­ ((y685) * (dd(9, i)))) 
dd(6, i) = (intu(5, i) ­ ((y564) * (dd(7, i))) ­ ((y574) * (dd(8, i))) ­ ((y584) * (dd(9, i)))) 
dd(5, i) = (intu(4, i) ­ ((y453) * (dd(6, i))) ­ ((y463) * (dd(7, i))) ­ ((y473) * (dd(8, i))) ­ ((y483) * (dd(9, 
i)))) 
dd(4, i) = (intu(3, i) ­ ((y342) * (dd(5, i))) ­ ((y352) * (dd(6, i))) ­ ((y362) * (dd(7, i))) ­ ((y372) * (dd(8, 
i))) ­ ((y382) * (dd(9, i)))) 
dd(3, i) = (intu(2, i) ­ ((y231) * (dd(4, i))) ­ ((y241) * (dd(5, i))) ­ ((y251) * (dd(6, i))) ­ ((y261) * (dd(7, 
i))) ­ ((y271) * (dd(8, i))) ­ ((y281) * (dd(9, i)))) 
dd(2, i) = (intu(1, i) ­ ((y120) * (dd(3, i))) ­ ((y130) * (dd(4, i))) ­ ((y140) * (dd(5, i))) ­ ((y150) * (dd(6, 
i))) ­ ((y160) * (dd(7, i))) ­ ((y170) * (dd(8, i))) ­ ((y180) * (dd(9, i)))) 
d(2, i + 1) = d(2, i) + dd(2, i) 
d(3, i + 1) = d(3, i) + dd(3, i) 
d(4, i + 1) = d(4, i) + dd(4, i) 
d(5, i + 1) = d(5, i) + dd(5, i) 
d(6, i + 1) = d(6, i) + dd(6, i) 
d(7, i + 1) = d(7, i) + dd(7, i) 
d(8, i + 1) = d(8, i) + dd(8, i) 
d(9, i + 1) = d(9, i) + dd(9, i) 
dq1(2, i) = ((v1 * v(2, i)) * (­y12 * Sin(­an12 + d1 ­ d(2, i + 1)))) 
dq2(2, i) = ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(3, i + 1) ­ d(2, i + 1)))) 
dq3(2, i) = ((v(2, i) * v(4, i)) * (­y24 * Sin(­an24 ­ d(2, i + 1) + d(4, i + 1)))) 
dq4(2, i) = ((v(2, i) * v(5, i)) * (­y25 * Sin(­an25 + d(5, i + 1) ­ d(2, i + 1)))) 
dq(2, i) = ((q2 / mvab) + ((bb22) * (v(2, i) ^ 2)) + dq1(2, i) + dq2(2, i) + dq3(2, i) + dq4(2, i)) / v(2, i) 
dq(3, i) = ((q3 / mvab) + ((bb33) * (v(3, i) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(2, i + 1) ­ 
d(3, i + 1)))) + ((v(3, i) * v(6, i)) * (­y36 * Sin(­an36 + d(6, i + 1) ­ d(3, i + 1))))) / v(3, i) 
dq(4, i) = ((q4 / mvab) + ((bb44) * (v(4, i) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Sin(­an24 ­ d(4, i + 1) + 
d(2, i + 1)))) + ((v(4, i) * v(7, i)) * (­y47 * Sin(­an47 ­ d(4, i + 1) + d(7, i + 1))))) / v(4, i) 
dq(5, i) = ((q5 / mvab) + ((bb55) * (v(5, i) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Sin(­an25 ­ d(5, i + 1) + 
d(2, i + 1)))) + ((v(5, i) * v(8, i)) * (­y58 * Sin(­an58 ­ d(5, i + 1) + d(8, i + 1))))) / v(5, i) 
dq(6, i) = ((q6 / mvab) + ((bb66) * (v(6, i) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Sin(­an36 ­ d(6, i + 1) + 
d(3, i + 1)))) + ((v(6, i) * v(9, i)) * (­y69 * Sin(­an69 ­ d(6, i + 1) + d(9, i + 1))))) / v(6, i) 
dq(7, i) = ((q7 / mvab) + ((bb77) * (v(7, i) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Sin(­an47 ­ d(7, i + 1) + 
d(4, i + 1))))) / v(7, i) 
dq(8, i) = ((q8 / mvab) + ((bb88) * (v(8, i) ^ 2)) + ((v(8, i) * v(5, i)) * (­y58 * Sin(­an58 ­ d(8, i + 1) + 
d(5, i + 1))))) / v(8, i) 
dq(9, i) = ((q9 / mvab) + ((bb99) * (v(9, i) ^ 2)) + ((v(9, i) * v(6, i)) * (­y69 * Sin(­an69 ­ d(9, i + 1) + 
d(6, i + 1))))) / v(9, i) 
intv(1, i) = dq(2, i) / ­bb22 
intv(2, i) = (dq(3, i) ­ (intv(1, i)) * (­bb32)) / y220 
intv(3, i) = (dq(4, i) ­ (intv(1, i)) * (­bb42) ­ (y320) * (intv(2, i))) / y331 
intv(4, i) = (dq(5, i) ­ (intv(1, i)) * (­bb52) ­ (y420) * (intv(2, i)) ­ (intv(3, i)) * (y431)) / y442 
intv(5, i) = (dq(6, i) ­ (intv(1, i)) * (­bb62) ­ (y520) * (intv(2, i)) ­ (intv(3, i)) * (y531) ­ (intv(4, i)) * 
(y542)) / y553 
intv(6, i) = (dq(7, i) ­ (intv(1, i)) * (­bb72) ­ (y620) * (intv(2, i)) ­ (y631) * (intv(3, i)) ­ (y642) * (intv(4, 
i)) ­ (y653) * (intv(5, i))) / y664 
intv(7, i) = (dq(8, i) ­ (intv(1, i)) * (­bb82) ­ (y720) * (intv(2, i)) ­ (y731) * (intv(3, i)) ­ (y742) * (intv(4, 
i)) ­ (y753) * (intv(5, i)) ­ (y764) * (intv(6, i))) / y775 
intv(8, i) = (dq(9, i) ­ (intv(1, i)) * (­bb92) ­ (y820) * (intv(2, i)) ­ (y831) * (intv(3, i)) ­ (y842) * (intv(4, 
i)) ­ (y853) * (intv(5, i)) ­ (y864) * (intv(6, i)) ­ (y875) * (intv(7, i))) / y886 
dv(9, i) = intv(8, i) 
dv(8, i) = (intv(7, i) ­ ((y786) * (dv(9, i)))) 
dv(7, i) = (intv(6, i) ­ ((y675) * (dv(8, i))) ­ ((y685) * (dv(9, i)))) 
dv(6, i) = (intv(5, i) ­ ((y564) * (dv(7, i))) ­ ((y574) * (dv(8, i))) ­ ((y584) * (dv(9, i)))) 
dv(5, i) = (intv(4, i) ­ ((y453) * (dv(6, i))) ­ ((y463) * (dv(7, i))) ­ ((y473) * (dv(8, i))) ­ ((y483) * (dv(9, 
i)))) 
dv(4, i) = (intv(3, i) ­ ((y342) * (dv(5, i))) ­ ((y352) * (dv(6, i))) ­ ((y362) * (dv(7, i))) ­ ((y372) * (dv(8, 
i))) ­ ((y382) * (dv(9, i)))) 
dv(3, i) = (intv(2, i) ­ ((y231) * (dv(4, i))) ­ ((y241) * (dv(5, i))) ­ ((y251) * (dv(6, i))) ­ ((y261) * (dv(7, 
i))) ­ ((y271) * (dv(8, i))) ­ ((y281) * (dv(9, i)))) 
dv(2, i) = (intv(1, i) ­ ((y120) * (dv(3, i))) ­ ((y130) * (dv(4, i))) ­ ((y140) * (dv(5, i))) ­ ((y150) * (dv(6, 
i))) ­ ((y160) * (dv(7, i))) ­ ((y170) * (dv(8, i))) ­ ((y180) * (dv(9, i)))) 
v(2, i + 1) = v(2, i) + dv(2, i) 
v(3, i + 1) = v(3, i) + dv(3, i) 
v(4, i + 1) = v(4, i) + dv(4, i) 
v(5, i + 1) = v(5, i) + dv(5, i) 
v(6, i + 1) = v(6, i) + dv(6, i) 
v(7, i + 1) = v(7, i) + dv(7, i) 
v(8, i + 1) = v(8, i) + dv(8, i) 
v(9, i + 1) = v(9, i) + dv(9, i) 
v(2, i) = v(2, i + 1) 
v(3, i) = v(3, i + 1) 
v(4, i) = v(4, i + 1) 
v(5, i) = v(5, i + 1) 
v(6, i) = v(6, i + 1) 
v(7, i) = v(7, i + 1) 
v(8, i) = v(8, i + 1) 
v(9, i) = v(9, i + 1) 
 d(2, i) = d(2, i + 1) 
 d(3, i) = d(3, i + 1) 
 d(4, i) = d(4, i + 1) 
 d(5, i) = d(5, i + 1) 
 d(6, i) = d(6, i + 1) 
 d(7, i) = d(7, i + 1) 
 d(8, i) = d(8, i + 1) 
 d(9, i) = d(9, i + 1) 
Next i 
'Print "voltage at bus 2: "; v(2, i) 
'Print "phase angle at bus 2: "; d(2, i); "rad"; "in degrees:"; d(2, i) * 180 / 3.14159265 
'Print "voltage at bus 3: "; v(3, i) 
'Print "phase angle at bus 3: "; d(3, i); "rad"; "in degrees:"; d(3, i) * 180 / 3.14159265 
'Print "voltage at bus 4: "; v(4, i) 
'Print "phase angle at bus 4: "; d(4, i); "rad"; "in degrees:"; d(4, i) * 180 / 3.14159265 
'Print "voltage at bus 5: "; v(5, i) 
'Print "phase angle at bus 5: "; d(5, i); "rad"; "in degrees:"; d(5, i) * 180 / 3.14159265 
'Print "voltage at bus 6: "; v(6, i) 
'Print "phase angle at bus 6: "; d(6, i); "rad"; "in degrees:"; d(6, i) * 180 / 3.14159265 
'Print "voltage at bus 7: "; v(7, i) 
'Print "phase angle at bus 7: "; d(7, i); "rad"; "in degrees:"; d(7, i) * 180 / 3.14159265 
'Print "voltage at bus 8: "; v(8, i) 
'Print "phase angle at bus 8: "; d(8, i); "rad"; "in degrees:"; d(8, i) * 180 / 3.14159265 
'Print "voltage at bus 9: "; v(9, i) 
'Print "phase angle at bus 9: "; d(9, i); "rad"; "in degrees:"; d(9, i) * 180 / 3.14159265 
act2 = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
act1 = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 
act6 = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
act5 = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 
act4 = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 
act3 = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
act8 = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 
act7 = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 
act9 = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 
act10 = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 
act11 = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
act12 = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
act13 = (((v(5, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(8, i) ­ d(5, i))))) 
act14 = (((v(8, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(5, i) ­ d(8, i))))) 
act15 = (((v(6, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(9, i) ­ d(6, i))))) 
act16 = (((v(9, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(6, i) ­ d(9, i))))) 
'Print "active power in p.u.from bus 2 towards 3:"; act1 
'Print "active power in p.u.from bus 1 towards 2:"; act2 
'Print "active power in p.u.from bus 2 towards 1:"; act3 
'Print "active power in p.u.from bus 3 towards 2:"; act4 
'Print "active power in p.u.from bus 4 towards 2:"; act5 
'Print "active power in p.u.from bus 2 towards 4:"; act6 
'Print "active power in p.u.from bus 5 towards 2:"; act7 
'Print "active power in p.u.from bus 2 towards 5:"; act8 
'Print "active power in p.u.from bus 3 towards 6:"; act9 
'Print "active power in p.u.from bus 6 towards 3:"; act10 
'Print "active power in p.u.from bus 4 towards 7:"; act11 
'Print "active power in p.u.from bus 7 towards 4:"; act12 
'Print "active power in p.u.from bus 5 towards 8:"; act13 
'Print "active power in p.u.from bus 8 towards 5:"; act14 
'Print "active power in p.u.from bus 6 towards 9:"; act15 
'Print "active power in p.u.from bus 9 towards 6:"; act16 
react1 = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 + d(3, i) 
­ d(2, i))))) 
react2 = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
react5 = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
react6 = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(4, i) 
­ d(2, i))))) 
react7 = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
react8 = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(5, i) 
­ d(2, i))))) 
react3 = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + d1 ­ d(2, 
i))))) 
react4 = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
react9 = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
react10 = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
react11 = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
react12 = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
react13 = (­(v(5, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(8, i) ­ d(5, i))))) 
react14 = (­(v(8, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(5, i) ­ d(8, i))))) 
react15 = (­(v(6, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(9, i) ­ d(6, i))))) 
react16 = (­(v(9, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(6, i) ­ d(9, i))))) 
'Print "reactive power from bus 2 towards 3:"; react1 
'Print "reactive power from bus 1 towards 2:"; react2 
'Print "reactive power from bus 2 towards 1:"; react3 
'Print "reactive power from bus 3 towards 2:"; react4 
'Print "reactive power from bus 4 towards 2:"; react5 
'Print "reactive power from bus 2 towards 4:"; react6 
'Print "reactive power from bus 5 towards 2:"; react7 
'Print "reactive power from bus 2 towards 5:"; react8 
'Print "reactive power from bus 3 towards 6:"; react9 
'Print "reactive power from bus 6 towards 3:"; react10 
'Print "reactive power from bus 4 towards 7:"; react11 
'Print "reactive power from bus 7 towards 4:"; react12 
'Print "reactive power from bus 5 towards 8:"; react13 
'Print "reactive power from bus 8 towards 5:"; react14 
'Print "reactive power from bus 6 towards 9:"; react15 
'Print "reactive power from bus 9 towards 6:"; react16 
Range("a132") = "The voltage on bus 2 in pu" 
Range("b132") = v(2, i) 
Range("a133") = "The voltage on bus 3 in pu" 
Range("b133") = v(3, i) 
Range("a134") = "The voltage on bus 4 in pu" 
Range("b134") = v(4, i) 
Range("a135") = "The voltage on bus 5 in pu" 
Range("b135") = v(5, i) 
Range("a136") = "The voltage on bus 6 in pu" 
Range("b136") = v(6, i) 
Range("a137") = "The voltage on bus 7 in pu" 
Range("b137") = v(7, i) 
Range("a138") = "The voltage on bus 8 in pu" 
Range("b138") = v(8, i) 
Range("a139") = "The voltage on bus 9 in pu" 
Range("b139") = v(9, i) 
Range("a140") = "The voltage on bus 10 in pu" 
Range("b140") = "not applicable" 
Range("a141") = "The phase angle at bus 2 in rad. & degrees" 
Range("b141") = d(2, i) 
Range("c141") = d(2, i) * 180 / 3.14159265 
Range("a142") = "The phase angle at bus 3 in rad. & degrees" 
Range("b142") = d(3, i) 
Range("c142") = d(3, i) * 180 / 3.14159265 
Range("a143") = "The phase angle at bus 4 in rad. & degrees" 
Range("b143") = d(4, i) 
Range("c143") = d(4, i) * 180 / 3.14159265 
Range("a144") = "The phase angle at bus 5 in rad. & degrees" 
Range("b144") = d(5, i) 
Range("c144") = d(5, i) * 180 / 3.14159265 
Range("a145") = "The phase angle at bus 6 in pu" 
Range("b145") = d(6, i) 
Range("c145") = d(6, i) * 180 / 3.14159265 
Range("a146") = "The phase angle at bus 7 in pu" 
Range("b146") = d(7, i) 
Range("c146") = d(7, i) * 180 / 3.14159265 
Range("a147") = "The phase angle at bus 8 in pu" 
Range("b147") = d(8, i) 
Range("c147") = d(8, i) * 180 / 3.14159265 
Range("a148") = "The phase angle at bus 9 in pu" 
Range("b148") = d(9, i) 
Range("c148") = d(9, i) * 180 / 3.14159265 
Range("a149") = "The phase angle at bus 10 in pu" 
Range("b149") = "not applicable" 
Range("c149") = "not applicable" 
Range("a150") = "The active power flowing from bus 1 to 2 in pu" 
Range("b150") = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
Range("a151") = "The active power flowing from bus 2 to 1 in pu" 
Range("b151") = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
Range("a152") = "The active power flowing from bus 2 to 3 in pu" 
Range("b152") = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 

Range("a153") = "The active power flowing from bus 3 to 2 in pu" 
Range("b153") = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 

Range("a154") = "The active power flowing from bus 2 to 4 in pu" 
Range("b154") = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 

Range("a155") = "The active power flowing from bus 4 to 2 in pu" 
Range("b155") = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 

Range("a156") = "The active power flowing from bus 2 to 5 in pu" 
Range("b156") = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 

Range("a157") = "The active power flowing from bus 5 to 2 in pu" 
Range("b157") = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 

Range("a158") = "The active power flowing from bus 3 to 6 in pu" 
Range("b158") = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 

Range("a159") = "The active power flowing from bus 6 to 3 in pu" 
Range("b159") = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 

Range("a160") = "The active power flowing from bus 4 to 7 in pu" 
Range("b160") = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
Range("a161") = "The active power flowing from bus 7 to 4 in pu" 
Range("b161") = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
Range("a162") = "The active power flowing from bus 5 to 8 in pu" 
Range("b162") = (((v(5, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(8, i) ­ d(5, i))))) 

Range("a163") = "The active power flowing from bus 8 to 5 in pu" 
Range("b163") = (((v(8, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(5, i) ­ d(8, i))))) 

Range("a164") = "The active power flowing from bus 6 to 9 in pu" 
Range("b164") = (((v(6, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(9, i) ­ d(6, i))))) 

Range("a165") = "The active power flowing from bus 9 to 6 in pu" 
Range("b165") = (((v(9, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(6, i) ­ d(9, i))))) 

Range("a166") = "The active power flowing from bus 7 to 10 in pu" 
Range("b166") = "not applicable" 
Range("a167") = "The active power flowing from bus 10 to 7 in pu" 
Range("b167") = "not applicable" 
Range("a168") = "The reactive power flowing from bus 1 to 2 in pu" 
Range("b168") = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
Range("a169") = "The reactive power flowing from bus 2 to 1 in pu" 
Range("b169") = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + 
d1 ­ d(2, i))))) 
Range("a170") = "The reactive power flowing from bus 2 to 3 in pu" 
Range("b170") = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 
+ d(3, i) ­ d(2, i))))) 
Range("a171") = "The reactive power flowing from bus 3 to 2 in pu" 
Range("b171") = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
Range("a172") = "The reactive power flowing from bus 2 to 4 in pu" 
Range("b172") = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 
+ d(4, i) ­ d(2, i))))) 
Range("a173") = "The reactive power flowing from bus 4 to 2 in pu" 
Range("b173") = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
Range("a174") = "The reactive power flowing from bus 2 to 5 in pu" 
Range("b174") = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 
+ d(5, i) ­ d(2, i))))) 
Range("a175") = "The reactive power flowing from bus 5 to 2 in pu" 
Range("b175") = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
Range("a176") = "The reactive power flowing from bus 3 to 6 in pu" 
Range("b176") = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
Range("a177") = "The reactive power flowing from bus 6 to 3 in pu" 
Range("b177") = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
Range("a178") = "The reactive power flowing from bus 4 to 7 in pu" 
Range("b178") = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
Range("a179") = "The reactive power flowing from bus 7 to 4 in pu" 
Range("b179") = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
Range("a180") = "The reactive power flowing from bus 5 to 8 in pu" 
Range("b180") = (­(v(5, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(8, i) ­ d(5, i))))) 
Range("a181") = "The reactive power flowing from bus 8 to 5 in pu" 
Range("b181") = (­(v(8, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(5, i) ­ d(8, i))))) 
Range("a182") = "The reactive power flowing from bus 6 to 9 in pu" 
Range("b182") = (­(v(6, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(9, i) ­ d(6, i))))) 
Range("a183") = "The reactive power flowing from bus 9 to 6 in pu" 
Range("b183") = (­(v(9, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(6, i) ­ d(9, i))))) 
Range("a184") = "The reactive power flowing from bus 7 to 10 in pu" 
Range("b184") = "not applicable" 
Range("a185") = "The reactive power flowing from bus 10 to 7 in pu" 
Range("b185") = "not applicable" 
For i = nit ­ 1 To nit 
'Print diffp(2, i), diffp(3, i), diffp(4, i), diffp(5, i), diffp(6, i), dq(2, i), dq(3, i), dq(4, i), dq(5, i), dq(6, i) 
Next i 
End Sub 
Sub MySub136() 
Dim d(30, 30) 
Dim dd(30, 30) 
Dim diffp(30, 30) 
Dim dq(30, 30) 
Dim dq1(30, 30) 
Dim dq2(30, 30) 
Dim dq3(30, 30) 
Dim dq4(30, 30) 
Dim dv(30, 30) 
Dim intv(30, 30) 
Dim intu(30, 30) 
Dim in1(30, 30) 
Dim intv1(30, 30) 
Dim v(30, 30) 
Dim pb(30, 30) 
Dim pb1(30, 30) 
UserForm8.Show 
r12 = Range("b65") 
r23 = Range("b66") 
r24 = Range("b67") 
r25 = Range("b68") 
r36 = Range("b69") 
r47 = Range("b70") 
r58 = Range("b71") 
r69 = Range("b72") 
r710 = Range("b73") 
x12 = Range("b74") 
x23 = Range("b75") 
x24 = Range("b76") 
x25 = Range("b77") 
x36 = Range("b78") 
x47 = Range("b79") 
x58 = Range("b80") 
x69 = Range("b81") 
x710 = Range("b82") 
mvac12 = Range("b83") 
mvac23 = Range("b84") 
mvac24 = Range("b85") 
mvac25 = Range("b86") 
xmotst = Range("b87") 
xmotst1 = Range("b88") 
v1 = Range("b89") 
v(2, 1) = Range("b90") 
v(3, 1) = Range("b91") 
v(4, 1) = Range("b92") 
v(5, 1) = Range("b93") 
v(6, 1) = Range("b94") 
v(7, 1) = Range("b95") 
v(8, 1) = Range("b96") 
v(9, 1) = Range("b97") 
v(10, 1) = Range("b98") 
d1 = Range("b99") 
d(2, 1) = Range("b100") 
d(3, 1) = Range("b101") 
d(4, 1) = Range("b102") 
d(5, 1) = Range("b103") 
d(6, 1) = Range("b104") 
d(7, 1) = Range("b105") 
d(8, 1) = Range("b106") 
d(9, 1) = Range("b107") 
d(10, 1) = Range("b108") 
p1 = Range("b109") 
p2 = Range("b110") 
p3 = Range("b111") 
p4 = Range("b112") 
p5 = Range("b113") 
p6 = Range("b114") 
p7 = Range("b115") 
p8 = Range("b116") 
p9 = Range("b117") 
p10 = Range("b118") 
q1 = Range("b119") 
q2 = Range("b120") 
q3 = Range("b121") 
q4 = Range("b122") 
q5 = Range("b123") 
q6 = Range("b124") 
q7 = Range("b125") 
q8 = Range("b126") 
q9 = Range("b127") 
q10 = Range("b128") 
mvab = Range("b129") 
nit = Range("b130") 
'If x710 > 0 And r710 > 0 Then 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z23 = ((r23) ^ 2 + (x23) ^ 2) ^ 0.5 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z25 = ((r25) ^ 2 + (x25) ^ 2) ^ 0.5 
z36 = ((r36) ^ 2 + (x36) ^ 2) ^ 0.5 
z47 = ((r47) ^ 2 + (x47) ^ 2) ^ 0.5 
z58 = ((r58) ^ 2 + (x58) ^ 2) ^ 0.5 
z69 = ((r69) ^ 2 + (x69) ^ 2) ^ 0.5 
z710 = ((r710) ^ 2 + (x710) ^ 2) ^ 0.5 
y12 = 1 / z12 
y23 = 1 / z23 
y24 = 1 / z24 
y25 = 1 / z25 
y36 = 1 / z36 
y47 = 1 / z47 
y58 = 1 / z58 
y69 = 1 / z69 
y710 = 1 / z710 
an12 = Atn(x12 / r12) 
an23 = Atn(x23 / r23) 
an24 = Atn(x24 / r24) 
an25 = Atn(x25 / r25) 
an36 = Atn(x36 / r36) 
an47 = Atn(x47 / r47) 
an58 = Atn(x58 / r58) 
an69 = Atn(x69 / r69) 
an710 = Atn(x710 / r710) 
b12 = y12 * Sin(­an12) 
b23 = y23 * Sin(­an23) 
b24 = y24 * Sin(­an24) 
b25 = y25 * Sin(­an25) 
b36 = y36 * Sin(­an36) 
b47 = y47 * Sin(­an47) 
b58 = y58 * Sin(­an58) 
b69 = y69 * Sin(­an69) 
b710 = y710 * Sin(­an710) 
yc12 = (mvac12) / mvab 
yc23 = (mvac23) / mvab 
yc24 = (mvac24) / mvab 
yc25 = (mvac25) / mvab 
g12 = y12 * Cos(­an12) 
g23 = y23 * Cos(­an23) 
g24 = y24 * Cos(­an24) 
g25 = y25 * Cos(­an25) 
g36 = y36 * Cos(­an36) 
g47 = y47 * Cos(­an47) 
g58 = y58 * Cos(­an58) 
g69 = y69 * Cos(­an69) 
g710 = y710 * Cos(­an710) 
gb22 = g12 + g23 + g24 + g25 
gb33 = g23 + g36 
gb44 = g24 + g47 
gb55 = g25 + g58 
gb66 = g36 + g69 
gb77 = g47 + g710 
gb88 = g58 
gb99 = g69 
gb1010 = g710 
gb12 = ­g12 
gb21 = ­g12 
gb23 = ­g23 
gb32 = ­g23 
gb24 = ­g24 
gb42 = ­g24 
gb25 = ­g25 
gb52 = ­g25 
gb36 = ­g36 
gb63 = ­g36 
gb47 = ­g47 
gb74 = ­g47 
gb58 = ­g58 
gb85 = ­g58 
gb69 = ­g69 
gb96 = ­g69 
gb710 = ­g710 
gb107 = ­g710 
bb11 = b12 + yc12 
bb22 = b12 + b23 + yc23 + b24 + yc24 + b25 + yc25 
bb33 = b23 + b36 
bb55 = b25 + b58 
bb66 = b36 + b69 
bb88 = b58 
bb99 = b69 
bb1010 = b710 
If xmotst < 0 Then bb44 = b24 + b47 + (1 / xmotst) 
If xmotst = 0 Then bb44 = b24 + b47 
If xmotst1 < 0 Then bb77 = b47 + b710 + (1 / xmotst1) 
If xmotst1 = 0 Then bb77 = b47 + b710 
bb12 = ­b12 
bb21 = ­b12 
bb23 = ­b23 
bb32 = ­b23 
bb24 = ­b24 
bb42 = ­b24 
bb25 = ­b25 
bb52 = ­b25 
bb36 = ­b36 
bb63 = ­b36 
bb47 = ­b47 
bb74 = ­b47 
bb58 = ­b58 
bb85 = ­b58 
bb69 = ­b69 
bb96 = ­b69 
bb710 = ­b710 
bb107 = ­b710 
For i = 1 To nit 
pb1(2, i) = (v(2, i) * v(4, i)) * (­y24 * Cos(­an24 + d(4, i) ­ d(2, i))) + (v(2, i) * v(5, i)) * (­y25 * Cos(­
an25 + d(5, i) ­ d(2, i))) 
pb(2, i) = ((gb22) * ((v(2, i)) ^ 2)) + ((v(2, i) * v1) * (­y12 * Cos(­an12 + d1 ­ d(2, i))) + (v(2, i) * v(3, 
i)) * (­y23 * Cos(­an23 + d(3, i) ­ d(2, i))) + pb1(2, i)) 
pb(3, i) = ((gb33) * ((v(3, i)) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Cos(­an23 + d(2, i) ­ d(3, i))) + (v(3, i) 
* v(6, i)) * (­y36 * Cos(­an36 + d(6, i) ­ d(3, i)))) 
pb(4, i) = ((gb44) * ((v(4, i)) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Cos(­an24 + d(2, i) ­ d(4, i))) + (v(4, i) 
* v(7, i)) * (­y47 * Cos(­an47 + d(7, i) ­ d(4, i)))) 
pb(5, i) = ((gb55) * ((v(5, i)) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Cos(­an25 + d(2, i) ­ d(5, i))) + (v(5, i) 
* v(8, i)) * (­y58 * Cos(­an58 + d(8, i) ­ d(5, i)))) 
pb(6, i) = ((gb66) * ((v(6, i)) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Cos(­an36 + d(3, i) ­ d(6, i))) + (v(6, i) 
* v(9, i)) * (­y69 * Cos(­an69 + d(9, i) ­ d(6, i)))) 
pb(7, i) = ((gb77) * ((v(7, i)) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Cos(­an47 + d(4, i) ­ d(7, i))) + (v(7, i) * 
v(10, i)) * (­y710 * Cos(­an710 + d(10, i) ­ d(7, i)))) 
pb(8, i) = ((gb88) * ((v(8, i)) ^ 2)) + ((v(8, i) * v(5, i)) * (­y58 * Cos(­an58 + d(5, i) ­ d(8, i)))) 
pb(9, i) = ((gb99) * ((v(9, i)) ^ 2)) + ((v(9, i) * v(6, i)) * (­y69 * Cos(­an69 + d(6, i) ­ d(9, i)))) 
pb(10, i) = ((gb1010) * ((v(10, i)) ^ 2)) + ((v(10, i) * v(7, i)) * (­y710 * Cos(­an710 + d(7, i) ­ d(10, i)))) 
diffp(2, i) = (1 / v(2, i)) * ((p2 / mvab) ­ pb(2, i)) 
diffp(3, i) = (1 / v(3, i)) * ((p3 / mvab) ­ pb(3, i)) 
diffp(4, i) = (1 / v(4, i)) * ((p4 / mvab) ­ pb(4, i)) 
diffp(5, i) = (1 / v(5, i)) * ((p5 / mvab) ­ pb(5, i)) 
diffp(6, i) = (1 / v(6, i)) * ((p6 / mvab) ­ pb(6, i)) 
diffp(7, i) = (1 / v(7, i)) * ((p7 / mvab) ­ pb(7, i)) 
diffp(8, i) = (1 / v(8, i)) * ((p8 / mvab) ­ pb(8, i)) 
diffp(9, i) = (1 / v(9, i)) * ((p9 / mvab) ­ pb(9, i)) 
diffp(10, i) = (1 / v(10, i)) * ((p10 / mvab) ­ pb(10, i)) 
y110 = bb22 / bb22 
y120 = ­bb23 / ­bb22 
y130 = ­bb24 / ­bb22 
y140 = ­bb25 / ­bb22 
y150 = ­bb26 / ­bb22 
y160 = ­bb27 / ­bb22 
y170 = ­bb28 / ­bb22 
y180 = ­bb29 / ­bb22 
y190 = ­bb210 / ­bb22 
y220 = ­bb33 ­ (­bb32) * (­bb23) / (­bb22) 
y230 = ­bb34 ­ (­bb32) * (­bb24) / (­bb22) 
y240 = ­bb35 ­ (­bb32) * (­bb25) / ­bb22 
y250 = ­bb36 ­ (­bb32) * (­bb26) / ­bb22 
y260 = ­bb37 ­ (­bb32) * (­bb27) / ­bb22 
y270 = ­bb38 ­ (­bb32) * (­bb28) / ­bb22 
y280 = ­bb39 ­ (­bb32) * (­bb29) / ­bb22 
y290 = ­bb310 ­ (­bb32) * (­bb210) / ­bb22 
y320 = ­bb43 ­ (­bb42) * (­bb23) / ­bb22 
y330 = ­bb44 ­ (­bb42) * (­bb24) / ­bb22 
y340 = ­bb45 ­ (­bb42) * (­bb25) / ­bb22 
y350 = ­bb46 ­ (­bb42) * (­bb26) / ­bb22 
y360 = ­bb47 ­ (­bb42) * (­bb27) / ­bb22 
y370 = ­bb48 ­ (­bb42) * (­bb28) / ­bb22 
y380 = ­bb49 ­ (­bb42) * (­bb29) / ­bb22 
y390 = ­bb410 ­ (­bb42) * (­bb210) / ­bb22 
y420 = ­bb53 ­ (­bb52) * (­bb23) / ­bb22 
y430 = ­bb54 ­ (­bb52) * (­bb24) / ­bb22 
y440 = ­bb55 ­ (­bb52) * (­bb25) / ­bb22 
y450 = ­bb56 ­ (­bb52) * (­bb26) / ­bb22 
y460 = ­bb57 ­ (­bb52) * (­bb27) / ­bb22 
y470 = ­bb58 ­ (­bb52) * (­bb28) / ­bb22 
y480 = ­bb59 ­ (­bb52) * (­bb29) / ­bb22 
y490 = ­bb510 ­ (­bb52) * (­bb210) / ­bb22 
y520 = ­bb63 ­ (­bb62) * (­bb23) / ­bb22 
y530 = ­bb64 ­ (­bb62) * (­bb24) / ­bb22 
y540 = ­bb65 ­ (­bb62) * (­bb25) / ­bb22 
y550 = ­bb66 ­ (­bb62) * (­bb26) / ­bb22 
y560 = ­bb67 ­ (­bb62) * (­bb27) / ­bb22 
y570 = ­bb68 ­ (­bb62) * (­bb28) / ­bb22 
y580 = ­bb69 ­ (­bb62) * (­bb29) / ­bb22 
y590 = ­bb610 ­ (­bb62) * (­bb210) / ­bb22 
y620 = ­bb73 ­ (­bb72) * (­bb23) / ­bb22 
y630 = ­bb74 ­ (­bb72) * (­bb24) / ­bb22 
y640 = ­bb75 ­ (­bb72) * (­bb25) / ­bb22 
y650 = ­bb76 ­ (­bb72) * (­bb26) / ­bb22 
y660 = ­bb77 ­ (­bb72) * (­bb27) / ­bb22 
y670 = ­bb78 ­ (­bb72) * (­bb28) / ­bb22 
y680 = ­bb79 ­ (­bb72) * (­bb29) / ­bb22 
y690 = ­bb710 ­ (­bb72) * (­bb210) / ­bb22 
y720 = ­bb83 ­ (­bb82) * (­bb23) / ­bb22 
y730 = ­bb84 ­ (­bb82) * (­bb24) / ­bb22 
y740 = ­bb85 ­ (­bb82) * (­bb25) / ­bb22 
y750 = ­bb86 ­ (­bb82) * (­bb26) / ­bb22 
y760 = ­bb87 ­ (­bb82) * (­bb27) / ­bb22 
y770 = ­bb88 ­ (­bb82) * (­bb28) / ­bb22 
y780 = ­bb89 ­ (­bb82) * (­bb29) / ­bb22 
y790 = ­bb810 ­ (­bb82) * (­bb210) / ­bb22 
y820 = ­bb93 ­ (­bb92) * (­bb23) / ­bb22 
y830 = ­bb94 ­ (­bb92) * (­bb24) / ­bb22 
y840 = ­bb95 ­ (­bb92) * (­bb25) / ­bb22 
y850 = ­bb96 ­ (­bb92) * (­bb26) / ­bb22 
y860 = ­bb97 ­ (­bb92) * (­bb27) / ­bb22 
y870 = ­bb98 ­ (­bb92) * (­bb28) / ­bb22 
y880 = ­bb99 ­ (­bb92) * (­bb29) / ­bb22 
y890 = ­bb910 ­ (­bb92) * (­bb210) / ­bb22 
y920 = ­bb103 ­ (­bb102) * (­bb23) / ­bb22 
y930 = ­bb104 ­ (­bb102) * (­bb24) / ­bb22 
y940 = ­bb105 ­ (­bb102) * (­bb25) / ­bb22 
y950 = ­bb106 ­ (­bb102) * (­bb26) / ­bb22 
y960 = ­bb107 ­ (­bb102) * (­bb27) / ­bb22 
y970 = ­bb108 ­ (­bb102) * (­bb28) / ­bb22 
y980 = ­bb109 ­ (­bb102) * (­bb29) / ­bb22 
y990 = ­bb1010 ­ (­bb102) * (­bb210) / ­bb22 
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y261 = y260 / y220 
y271 = y270 / y220 
y281 = y280 / y220 
y291 = y290 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y361 = y360 ­ (y320) * (y260) / y220 
y371 = y370 ­ (y320) * (y270) / y220 
y381 = y380 ­ (y320) * (y280) / y220 
y391 = y390 ­ (y320) * (y290) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y461 = y460 ­ (y420) * (y260) / y220 
y471 = y470 ­ (y420) * (y270) / y220 
y481 = y480 ­ (y420) * (y280) / y220 
y491 = y490 ­ (y420) * (y290) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y561 = y560 ­ (y520) * (y260) / y220 
y571 = y570 ­ (y520) * (y270) / y220 
y581 = y580 ­ (y520) * (y280) / y220 
y591 = y590 ­ (y520) * (y290) / y220 
y631 = y630 ­ (y620) * (y230) / y220 
y641 = y640 ­ (y620) * (y240) / y220 
y651 = y650 ­ (y620) * (y250) / y220 
y661 = y660 ­ (y620) * (y260) / y220 
y671 = y670 ­ (y620) * (y270) / y220 
y681 = y680 ­ (y620) * (y280) / y220 
y691 = y690 ­ (y620) * (y290) / y220 
y731 = y730 ­ (y720) * (y230) / y220 
y741 = y740 ­ (y720) * (y240) / y220 
y751 = y750 ­ (y720) * (y250) / y220 
y761 = y760 ­ (y720) * (y260) / y220 
y771 = y770 ­ (y720) * (y270) / y220 
y781 = y780 ­ (y720) * (y280) / y220 
y791 = y790 ­ (y720) * (y290) / y220 
y831 = y830 ­ (y820) * (y230) / y220 
y841 = y840 ­ (y820) * (y240) / y220 
y851 = y850 ­ (y820) * (y250) / y220 
y861 = y860 ­ (y820) * (y260) / y220 
y871 = y870 ­ (y820) * (y270) / y220 
y881 = y880 ­ (y820) * (y280) / y220 
y891 = y890 ­ (y820) * (y290) / y220 
y931 = y930 ­ (y920) * (y230) / y220 
y941 = y940 ­ (y920) * (y240) / y220 
y951 = y950 ­ (y920) * (y250) / y220 
y961 = y960 ­ (y920) * (y260) / y220 
y971 = y970 ­ (y920) * (y270) / y220 
y981 = y980 ­ (y920) * (y280) / y220 
y991 = y990 ­ (y920) * (y290) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y362 = y361 / y331 
y372 = y371 / y331 
y382 = y381 / y331 
y392 = y391 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y462 = y461 ­ (y431) * (y361) / y331 
y472 = y471 ­ (y431) * (y371) / y331 
y482 = y481 ­ (y431) * (y381) / y331 
y492 = y491 ­ (y431) * (y391) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y562 = y561 ­ (y531) * (y361) / y331 
y572 = y571 ­ (y531) * (y371) / y331 
y582 = y581 ­ (y531) * (y381) / y331 
y592 = y591 ­ (y531) * (y391) / y331 
y642 = y641 ­ (y631) * (y341) / y331 
y652 = y651 ­ (y631) * (y351) / y331 
y662 = y661 ­ (y631) * (y361) / y331 
y672 = y671 ­ (y631) * (y371) / y331 
y682 = y681 ­ (y631) * (y381) / y331 
y692 = y691 ­ (y631) * (y391) / y331 
y742 = y741 ­ (y731) * (y341) / y331 
y752 = y751 ­ (y731) * (y351) / y331 
y762 = y761 ­ (y731) * (y361) / y331 
y772 = y771 ­ (y731) * (y371) / y331 
y782 = y781 ­ (y731) * (y381) / y331 
y792 = y791 ­ (y731) * (y391) / y331 
y842 = y841 ­ (y831) * (y341) / y331 
y852 = y851 ­ (y831) * (y351) / y331 
y862 = y861 ­ (y831) * (y361) / y331 
y872 = y871 ­ (y831) * (y371) / y331 
y882 = y881 ­ (y831) * (y381) / y331 
y892 = y891 ­ (y831) * (y391) / y331 
y942 = y941 ­ (y931) * (y341) / y331 
y952 = y951 ­ (y931) * (y351) / y331 
y962 = y961 ­ (y931) * (y361) / y331 
y972 = y971 ­ (y931) * (y371) / y331 
y982 = y981 ­ (y931) * (y381) / y331 
y992 = y991 ­ (y931) * (y391) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y463 = y462 / y442 
y473 = y472 / y442 
y483 = y482 / y442 
y493 = y492 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
y563 = y562 ­ (y542) * (y462) / y442 
y573 = y572 ­ (y542) * (y472) / y442 
y583 = y582 ­ (y542) * (y482) / y442 
y593 = y592 ­ (y542) * (y492) / y442 
y653 = y652 ­ (y642) * (y452) / y442 
y663 = y662 ­ (y642) * (y462) / y442 
y673 = y672 ­ (y642) * (y472) / y442 
y683 = y682 ­ (y642) * (y482) / y442 
y693 = y692 ­ (y642) * (y492) / y442 
y753 = y752 ­ (y742) * (y452) / y442 
y763 = y762 ­ (y742) * (y462) / y442 
y773 = y772 ­ (y742) * (y472) / y442 
y783 = y782 ­ (y742) * (y482) / y442 
y793 = y792 ­ (y742) * (y492) / y442 
y853 = y852 ­ (y842) * (y452) / y442 
y863 = y862 ­ (y842) * (y462) / y442 
y873 = y872 ­ (y842) * (y472) / y442 
y883 = y882 ­ (y842) * (y482) / y442 
y893 = y892 ­ (y842) * (y492) / y442 
y953 = y952 ­ (y942) * (y452) / y442 
y963 = y962 ­ (y942) * (y462) / y442 
y973 = y972 ­ (y942) * (y472) / y442 
y983 = y982 ­ (y942) * (y482) / y442 
y993 = y992 ­ (y942) * (y492) / y442 
y554 = y553 / y553 
y564 = y563 / y553 
y574 = y573 / y553 
y584 = y583 / y553 
y594 = y593 / y553 
y664 = y663 ­ (y653) * (y563) / y553 
y674 = y673 ­ (y653) * (y573) / y553 
y684 = y683 ­ (y653) * (y583) / y553 
y694 = y693 ­ (y653) * (y593) / y553 
y764 = y763 ­ (y753) * (y563) / y553 
y774 = y773 ­ (y753) * (y573) / y553 
y784 = y783 ­ (y753) * (y583) / y553 
y794 = y793 ­ (y753) * (y593) / y553 
y864 = y863 ­ (y853) * (y563) / y553 
y874 = y873 ­ (y853) * (y573) / y553 
y884 = y883 ­ (y853) * (y583) / y553 
y894 = y893 ­ (y853) * (y593) / y553 
y964 = y963 ­ (y953) * (y563) / y553 
y974 = y973 ­ (y953) * (y573) / y553 
y984 = y983 ­ (y953) * (y583) / y553 
y994 = y993 ­ (y953) * (y593) / y553 
y665 = y664 / y664 
y675 = y674 / y664 
y685 = y684 / y664 
y695 = y694 / y664 
y775 = y774 ­ (y764) * (y674) / y664 
y785 = y784 ­ (y764) * (y684) / y664 
y795 = y794 ­ (y764) * (y694) / y664 
y875 = y874 ­ (y864) * (y674) / y664 
y885 = y884 ­ (y864) * (y684) / y664 
y895 = y894 ­ (y864) * (y694) / y664 
y975 = y974 ­ (y964) * (y674) / y664 
y985 = y984 ­ (y964) * (y684) / y664 
y995 = y994 ­ (y964) * (y694) / y664 
  
y776 = y775 / y775 
y786 = y785 / y775 
y796 = y795 / y775 
y886 = y885 ­ (y875) * (y785) / y775 
y896 = y895 ­ (y875) * (y795) / y775 
y986 = y985 ­ (y975) * (y785) / y775 
y996 = y995 ­ (y975) * (y795) / y775 
y887 = y886 / y886 
y897 = y896 / y886 
y997 = y996 ­ (y986) * (y896) / y886 
intu(1, i) = diffp(2, i) / ­bb22 
intu(2, i) = (diffp(3, i) ­ (intu(1, i)) * (­bb32)) / y220 
intu(3, i) = (diffp(4, i) ­ (intu(1, i)) * (­bb42) ­ (y320) * (intu(2, i))) / y331 
intu(4, i) = (diffp(5, i) ­ (intu(1, i)) * (­bb52) ­ (y420) * (intu(2, i)) ­ (intu(3, i)) * (y431)) / y442 
intu(5, i) = (diffp(6, i) ­ (intu(1, i)) * (­bb62) ­ (y520) * (intu(2, i)) ­ (intu(3, i)) * (y531) ­ (intu(4, i)) * 
(y542)) / y553 
intu(6, i) = (diffp(7, i) ­ (intu(1, i)) * (­bb72) ­ (y620) * (intu(2, i)) ­ (y631) * (intu(3, i)) ­ (y642) * 
(intu(4, i)) ­ (y653) * (intu(5, i))) / y664 
intu(7, i) = (diffp(8, i) ­ (intu(1, i)) * (­bb82) ­ (y720) * (intu(2, i)) ­ (y731) * (intu(3, i)) ­ (y742) * 
(intu(4, i)) ­ (y753) * (intu(5, i)) ­ (y764) * (intu(6, i))) / y775 
intu(8, i) = (diffp(9, i) ­ (intu(1, i)) * (­bb92) ­ (y820) * (intu(2, i)) ­ (y831) * (intu(3, i)) ­ (y842) * 
(intu(4, i)) ­ (y853) * (intu(5, i)) ­ (y864) * (intu(6, i)) ­ (y875) * (intu(7, i))) / y886 
in1(9, i) = ­(intu(5, i)) * (y953) ­ (intu(6, i)) * (y964) ­ (intu(7, i)) * (y975) ­ (intu(8, i)) * (y986) 
intu(9, i) = (diffp(10, i) ­ (­bb102) * (intu(1, i)) ­ (y920) * (intu(2, i)) ­ (intu(3, i)) * (y931) ­ (intu(4, i)) 
* (y942) + in1(9, i)) / y997 
dd(10, i) = intu(9, i) 
dd(9, i) = (intu(8, i) ­ ((y897) * (dd(10, i)))) 
dd(8, i) = (intu(7, i) ­ ((y786) * (dd(9, i))) ­ ((dd(10, i)) * (y796))) 
dd(7, i) = (intu(6, i) ­ ((y675) * (dd(8, i))) ­ ((y685) * (dd(9, i))) ­ ((y695) * (dd(10, i)))) 
dd(6, i) = (intu(5, i) ­ ((y564) * (dd(7, i))) ­ ((y574) * (dd(8, i))) ­ ((y584) * (dd(9, i))) ­ ((dd(10, i)) * 
(yy594))) 
dd(5, i) = (intu(4, i) ­ ((y453) * (dd(6, i))) ­ ((y463) * (dd(7, i))) ­ ((y473) * (dd(8, i))) ­ ((y483) * (dd(9, 
i))) ­ ((dd(10, i)) * (y493))) 
dd(4, i) = (intu(3, i) ­ ((y342) * (dd(5, i))) ­ ((y352) * (dd(6, i))) ­ ((y362) * (dd(7, i))) ­ ((y372) * (dd(8, 
i))) ­ ((y382) * (dd(9, i))) ­ ((dd(10, i)) * (y392))) 
dd(3, i) = (intu(2, i) ­ ((y231) * (dd(4, i))) ­ ((y241) * (dd(5, i))) ­ ((y251) * (dd(6, i))) ­ ((y261) * (dd(7, 
i))) ­ ((y271) * (dd(8, i))) ­ ((y281) * (dd(9, i))) ­ ((dd(10, i)) * (yy292))) 
dd(2, i) = (intu(1, i) ­ ((y120) * (dd(3, i))) ­ ((y130) * (dd(4, i))) ­ ((y140) * (dd(5, i))) ­ ((y150) * (dd(6, 
i))) ­ ((y160) * (dd(7, i))) ­ ((y170) * (dd(8, i))) ­ ((y180) * (dd(9, i))) ­ ((dd(10, i)) * (y190))) 
d(2, i + 1) = d(2, i) + dd(2, i) 
d(3, i + 1) = d(3, i) + dd(3, i) 
d(4, i + 1) = d(4, i) + dd(4, i) 
d(5, i + 1) = d(5, i) + dd(5, i) 
d(6, i + 1) = d(6, i) + dd(6, i) 
d(7, i + 1) = d(7, i) + dd(7, i) 
d(8, i + 1) = d(8, i) + dd(8, i) 
d(9, i + 1) = d(9, i) + dd(9, i) 
d(10, i + 1) = d(10, i) + dd(10, i) 
dq2(2, i) = ((v(2, i) * v(4, i)) * (­y24 * Sin(­an24 ­ d(2, i + 1) + d(4, i + 1)))) 
dq1(2, i) = ((v(2, i) * v(5, i)) * (­y25 * Sin(­an25 ­ d(2, i + 1) + d(5, i + 1)))) 
dq3(2, i) = ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(3, i + 1) ­ d(2, i + 1)))) 
dq4(2, i) = ((v1 * v(2, i)) * (­y12 * Sin(­an12 + d1 ­ d(2, i + 1)))) 
dq(2, i) = ((q2 / mvab) + ((bb22) * (v(2, i) ^ 2)) + dq1(2, i) + dq2(2, i) + dq3(2, i) + dq4(2, i)) / v(2, i) 
dq(3, i) = ((q3 / mvab) + ((bb33) * (v(3, i) ^ 2)) + ((v(3, i) * v(2, i)) * (­y23 * Sin(­an23 + d(2, i + 1) ­ 
d(3, i + 1)))) + ((v(3, i) * v(6, i)) * (­y36 * Sin(­an36 + d(6, i + 1) ­ d(3, i + 1))))) / v(3, i) 
dq(4, i) = ((q4 / mvab) + ((bb44) * (v(4, i) ^ 2)) + ((v(4, i) * v(2, i)) * (­y24 * Sin(­an24 ­ d(4, i + 1) + 
d(2, i + 1)))) + ((v(4, i) * v(7, i)) * (­y47 * Sin(­an47 ­ d(4, i + 1) + d(7, i + 1))))) / v(4, i) 
dq(5, i) = ((q5 / mvab) + ((bb55) * (v(5, i) ^ 2)) + ((v(5, i) * v(2, i)) * (­y25 * Sin(­an25 ­ d(5, i + 1) + 
d(2, i + 1)))) + ((v(5, i) * v(8, i)) * (­y58 * Sin(­an58 ­ d(5, i + 1) + d(8, i + 1))))) / v(5, i) 
dq(6, i) = ((q6 / mvab) + ((bb66) * (v(6, i) ^ 2)) + ((v(6, i) * v(3, i)) * (­y36 * Sin(­an36 ­ d(6, i + 1) + 
d(3, i + 1)))) + ((v(6, i) * v(9, i)) * (­y69 * Sin(­an69 ­ d(6, i + 1) + d(9, i + 1))))) / v(6, i) 
dq(7, i) = ((q7 / mvab) + ((bb77) * (v(7, i) ^ 2)) + ((v(7, i) * v(4, i)) * (­y47 * Sin(­an47 ­ d(7, i + 1) + 
d(4, i + 1)))) + ((v(7, i) * v(10, i)) * (­y710 * Sin(­an710 ­ d(7, i + 1) + d(10, i + 1))))) / v(7, i) 
dq(8, i) = ((q8 / mvab) + ((bb88) * (v(8, i) ^ 2)) + ((v(8, i) * v(5, i)) * (­y58 * Sin(­an58 ­ d(8, i + 1) + 
d(5, i + 1))))) / v(8, i) 
dq(9, i) = ((q9 / mvab) + ((bb99) * (v(9, i) ^ 2)) + ((v(9, i) * v(6, i)) * (­y69 * Sin(­an69 ­ d(9, i + 1) + 
d(6, i + 1))))) / v(9, i) 
dq(10, i) = ((q10 / mvab) + ((bb1010) * (v(10, i) ^ 2)) + ((v(10, i) * v(7, i)) * (­y710 * Sin(­an710 ­ d(10, 
i + 1) + d(7, i + 1))))) / v(10, i) 
intv(1, i) = dq(2, i) / ­bb22 
intv(2, i) = (dq(3, i) ­ (intv(1, i)) * (­bb32)) / y220 
intv(3, i) = (dq(4, i) ­ (intv(1, i)) * (­bb42) ­ (y320) * (intv(2, i))) / y331 
intv(4, i) = (dq(5, i) ­ (intv(1, i)) * (­bb52) ­ (y420) * (intv(2, i)) ­ (intv(3, i)) * (y431)) / y442 
intv(5, i) = (dq(6, i) ­ (intv(1, i)) * (­bb62) ­ (y520) * (intv(2, i)) ­ (intv(3, i)) * (y531) ­ (intv(4, i)) * 
(y542)) / y553 
intv(6, i) = (dq(7, i) ­ (intv(1, i)) * (­bb72) ­ (y620) * (intv(2, i)) ­ (y631) * (intv(3, i)) ­ (y642) * (intv(4, 
i)) ­ (y653) * (intv(5, i))) / y664 
intv(7, i) = (dq(8, i) ­ (intv(1, i)) * (­bb82) ­ (y720) * (intv(2, i)) ­ (y731) * (intv(3, i)) ­ (y742) * (intv(4, 
i)) ­ (y753) * (intv(5, i)) ­ (y764) * (intv(6, i))) / y775 
intv(8, i) = (dq(9, i) ­ (intv(1, i)) * (­bb92) ­ (y820) * (intv(2, i)) ­ (y831) * (intv(3, i)) ­ (y842) * (intv(4, 
i)) ­ (y853) * (intv(5, i)) ­ (y864) * (intv(6, i)) ­ (y875) * (intv(7, i))) / y886 
intv1(9, i) = ­(intv(4, i)) * (y942) ­ (intv(5, i)) * (y953) ­ (intv(6, i)) * (y964) ­ (intv(7, i)) * (y975) ­ 
(intv(8, i)) * (y986) 
intv(9, i) = (dq(10, i) ­ (­bb102) * (intv(1, i)) ­ (y920) * (intv(2, i)) ­ (intv(3, i)) * (y931) + intv1(9, i)) / 
y997 
dv(10, i) = intv(9, i) 
dv(9, i) = (intv(8, i) ­ ((y897) * (dv(10, i)))) 
dv(8, i) = (intv(7, i) ­ ((y786) * (dv(9, i))) ­ ((dv(10, i)) * (y796))) 
dv(7, i) = (intv(6, i) ­ ((y675) * (dv(8, i))) ­ ((y685) * (dv(9, i))) ­ ((y695) * (dv(10, i)))) 
dv(6, i) = (intv(5, i) ­ ((y564) * (dv(7, i))) ­ ((y574) * (dv(8, i))) ­ ((y584) * (dv(9, i))) ­ ((dv(10, i)) * 
(yy594))) 
dv(5, i) = (intv(4, i) ­ ((y453) * (dv(6, i))) ­ ((y463) * (dv(7, i))) ­ ((y473) * (dv(8, i))) ­ ((y483) * (dv(9, 
i))) ­ ((dv(10, i)) * (y493))) 
dv(4, i) = (intv(3, i) ­ ((y342) * (dv(5, i))) ­ ((y352) * (dv(6, i))) ­ ((y362) * (dv(7, i))) ­ ((y372) * (dv(8, 
i))) ­ ((y382) * (dv(9, i))) ­ ((dv(10, i)) * (y392))) 
dv(3, i) = (intv(2, i) ­ ((y231) * (dv(4, i))) ­ ((y241) * (dv(5, i))) ­ ((y251) * (dv(6, i))) ­ ((y261) * (dv(7, 
i))) ­ ((y271) * (dv(8, i))) ­ ((y281) * (dv(9, i))) ­ ((dv(10, i)) * (yy292))) 
dv(2, i) = (intv(1, i) ­ ((y120) * (dv(3, i))) ­ ((y130) * (dv(4, i))) ­ ((y140) * (dv(5, i))) ­ ((y150) * (dv(6, 
i))) ­ ((y160) * (dv(7, i))) ­ ((y170) * (dv(8, i))) ­ ((y180) * (dv(9, i))) ­ ((dv(10, i)) * (y190))) 
v(2, i + 1) = v(2, i) + dv(2, i) 
v(3, i + 1) = v(3, i) + dv(3, i) 
v(4, i + 1) = v(4, i) + dv(4, i) 
v(5, i + 1) = v(5, i) + dv(5, i) 
v(6, i + 1) = v(6, i) + dv(6, i) 
v(7, i + 1) = v(7, i) + dv(7, i) 
v(8, i + 1) = v(8, i) + dv(8, i) 
v(9, i + 1) = v(9, i) + dv(9, i) 
v(10, i + 1) = v(10, i) + dv(10, i) 
v(2, i) = v(2, i + 1) 
v(3, i) = v(3, i + 1) 
v(4, i) = v(4, i + 1) 
v(5, i) = v(5, i + 1) 
v(6, i) = v(6, i + 1) 
v(7, i) = v(7, i + 1) 
v(8, i) = v(8, i + 1) 
v(9, i) = v(9, i + 1) 
v(10, i) = v(10, i + 1) 
 d(2, i) = d(2, i + 1) 
 d(3, i) = d(3, i + 1) 
 d(4, i) = d(4, i + 1) 
 d(5, i) = d(5, i + 1) 
 d(6, i) = d(6, i + 1) 
 d(7, i) = d(7, i + 1) 
 d(8, i) = d(8, i + 1) 
 d(9, i) = d(9, i + 1) 
 d(10, i) = d(10, i + 1) 
Next i 
'Print "voltage at bus 2: "; v(2, i) 
'Print "phase angle at bus 2: "; d(2, i); "rad"; "in degrees:"; d(2, i) * 180 / 3.14159265 
'Print "voltage at bus 3: "; v(3, i) 
'Print "phase angle at bus 3: "; d(3, i); "rad"; "in degrees:"; d(3, i) * 180 / 3.14159265 
'Print "voltage at bus 4: "; v(4, i) 
'Print "phase angle at bus 4: "; d(4, i); "rad"; "in degrees:"; d(4, i) * 180 / 3.14159265 
'Print "voltage at bus 5: "; v(5, i) 
'Print "phase angle at bus 5: "; d(5, i); "rad"; "in degrees:"; d(5, i) * 180 / 3.14159265 
'Print "voltage at bus 6: "; v(6, i) 
'Print "phase angle at bus 6: "; d(6, i); "rad"; "in degrees:"; d(6, i) * 180 / 3.14159265 
'Print "voltage at bus 7: "; v(7, i) 
'Print "phase angle at bus 7: "; d(7, i); "rad"; "in degrees:"; d(7, i) * 180 / 3.14159265 
'Print "voltage at bus 8: "; v(8, i) 
'Print "phase angle at bus 8: "; d(8, i); "rad"; "in degrees:"; d(8, i) * 180 / 3.14159265 
'Print "voltage at bus 9: "; v(9, i) 
'Print "phase angle at bus 9: "; d(9, i); "rad"; "in degrees:"; d(9, i) * 180 / 3.14159265 
'Print "voltage at bus 10: "; v(10, i) 
'Print "phase angle at bus 10: "; d(10, i); "rad"; "in degrees:"; d(10, i) * 180 / 3.14159265 
  
act2 = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
act1 = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 
act6 = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 
act5 = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 
act4 = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 
act3 = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
act8 = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 
act7 = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 
act9 = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 
act10 = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 
act11 = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
act12 = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
act13 = (((v(5, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(8, i) ­ d(5, i))))) 
act14 = (((v(8, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(5, i) ­ d(8, i))))) 
act15 = (((v(6, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(9, i) ­ d(6, i))))) 
act16 = (((v(9, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(6, i) ­ d(9, i))))) 
act17 = (((v(7, i) ^ 2) * (g710)) + ((v(7, i)) * (v(10, i)) * (­y710) * (Cos(­an710 + d(10, i) ­ d(7, i))))) 
act18 = (((v(10, i) ^ 2) * (g710)) + ((v(7, i)) * (v(10, i)) * (­y710) * (Cos(­an710 + d(7, i) ­ d(10, i))))) 
'Print "active power in p.u.from bus 2 towards 3:"; act1 
'Print "active power in p.u.from bus 1 towards 2:"; act2 
'Print "active power in p.u.from bus 2 towards 1:"; act3 
'Print "active power in p.u.from bus 3 towards 2:"; act4 
'Print "active power in p.u.from bus 4 towards 2:"; act5 
'Print "active power in p.u.from bus 2 towards 4:"; act6 
'Print "active power in p.u.from bus 5 towards 2:"; act7 
'Print "active power in p.u.from bus 2 towards 5:"; act8 
'Print "active power in p.u.from bus 3 towards 6:"; act9 
'Print "active power in p.u.from bus 6 towards 3:"; act10 
'Print "active power in p.u.from bus 4 towards 7:"; act11 
'Print "active power in p.u.from bus 7 towards 4:"; act12 
'Print "active power in p.u.from bus 5 towards 8:"; act13 
'Print "active power in p.u.from bus 8 towards 5:"; act14 
'Print "active power in p.u.from bus 6 towards 9:"; act15 
'Print "active power in p.u.from bus 9 towards 6:"; act16 
'Print "active power in p.u.from bus 7 towards 10:"; act17 
'Print "active power in p.u.from bus 10 towards 7:"; act18 
react1 = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 + d(3, i) 
­ d(2, i))))) 
react2 = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
react5 = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
react6 = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(4, i) 
­ d(2, i))))) 
react7 = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
react8 = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(5, i) 
­ d(2, i))))) 
react3 = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + d1 ­ d(2, 
i))))) 
react4 = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
react9 = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
react10 = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
react11 = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
react12 = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
react13 = (­(v(5, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(8, i) ­ d(5, i))))) 
react14 = (­(v(8, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(5, i) ­ d(8, i))))) 
react15 = (­(v(6, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(9, i) ­ d(6, i))))) 
react16 = (­(v(9, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(6, i) ­ d(9, i))))) 
react17 = (­(v(7, i) ^ 2) * (b710) ­ ((v(7, i)) * (v(10, i)) * (­y710) * (Sin(­an710 + d(10, i) ­ d(7, i))))) 
react18 = (­(v(10, i) ^ 2) * (b710) ­ ((v(7, i)) * (v(10, i)) * (­y710) * (Sin(­an710 + d(7, i) ­ d(10, i))))) 
'Print "reactive power from bus 2 towards 3:"; react1 
'Print "reactive power from bus 1 towards 2:"; react2 
'Print "reactive power from bus 2 towards 1:"; react3 
'Print "reactive power from bus 3 towards 2:"; react4 
'Print "reactive power from bus 4 towards 2:"; react5 
'Print "reactive power from bus 2 towards 4:"; react6 
'Print "reactive power from bus 5 towards 2:"; react7 
'Print "reactive power from bus 2 towards 5:"; react8 
'Print "reactive power from bus 3 towards 6:"; react9 
'Print "reactive power from bus 6 towards 3:"; react10 
'Print "reactive power from bus 4 towards 7:"; react11 
'Print "reactive power from bus 7 towards 4:"; react12 
'Print "reactive power from bus 5 towards 8:"; react13 
'Print "reactive power from bus 8 towards 5:"; react14 
'Print "reactive power from bus 6 towards 9:"; react15 
'Print "reactive power from bus 9 towards 6:"; react16 
'Print "reactive power from bus 7 towards 10:"; react17 
'Print "reactive power from bus 10 towards 7:"; react18 
Range("a132") = "The voltage on bus 2 in pu" 
Range("b132") = v(2, i) 
Range("a133") = "The voltage on bus 3 in pu" 
Range("b133") = v(3, i) 
Range("a134") = "The voltage on bus 4 in pu" 
Range("b134") = v(4, i) 
Range("a135") = "The voltage on bus 5 in pu" 
Range("b135") = v(5, i) 
Range("a136") = "The voltage on bus 6 in pu" 
Range("b136") = v(6, i) 
Range("a137") = "The voltage on bus 7 in pu" 
Range("b137") = v(7, i) 
Range("a138") = "The voltage on bus 8 in pu" 
Range("b138") = v(8, i) 
Range("a139") = "The voltage on bus 9 in pu" 
Range("b139") = v(9, i) 
Range("a140") = "The voltage on bus 10 in pu" 
Range("b140") = v(10, i) 
Range("a141") = "The phase angle at bus 2 in rad. & degrees" 
Range("b141") = d(2, i) 
Range("c141") = d(2, i) * 180 / 3.14159265 
Range("a142") = "The phase angle at bus 3 in rad. & degrees" 
Range("b142") = d(3, i) 
Range("c142") = d(3, i) * 180 / 3.14159265 
Range("a143") = "The phase angle at bus 4 in rad. & degrees" 
Range("b143") = d(4, i) 
Range("c143") = d(4, i) * 180 / 3.14159265 
Range("a144") = "The phase angle at bus 5 in rad. & degrees" 
Range("b144") = d(5, i) 
Range("c144") = d(5, i) * 180 / 3.14159265 
Range("a145") = "The phase angle at bus 6 in pu" 
Range("b145") = d(6, i) 
Range("c145") = d(6, i) * 180 / 3.14159265 
Range("a146") = "The phase angle at bus 7 in pu" 
Range("b146") = d(7, i) 
Range("c146") = d(7, i) * 180 / 3.14159265 
Range("a147") = "The phase angle at bus 8 in pu" 
Range("b147") = d(8, i) 
Range("c147") = d(8, i) * 180 / 3.14159265 
Range("a148") = "The phase angle at bus 9 in pu" 
Range("b148") = d(9, i) 
Range("c148") = d(9, i) * 180 / 3.14159265 
Range("a149") = "The phase angle at bus 10 in pu" 
Range("b149") = d(10, i) 
Range("c149") = d(10, i) * 180 / 3.14159265 
Range("a150") = "The active power flowing from bus 1 to 2 in pu" 
Range("b150") = (((v1 ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 + d(2, i) ­ d1)))) 
Range("a151") = "The active power flowing from bus 2 to 1 in pu" 
Range("b151") = (((v(2, i) ^ 2) * (g12)) + ((v1) * (v(2, i)) * (­y12) * (Cos(­an12 ­ d(2, i) + d1)))) 
Range("a152") = "The active power flowing from bus 2 to 3 in pu" 
Range("b152") = (((v(2, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 + d(3, i) ­ d(2, i))))) 

Range("a153") = "The active power flowing from bus 3 to 2 in pu" 
Range("b153") = (((v(3, i) ^ 2) * (g23)) + ((v(2, i)) * (v(3, i)) * (­y23) * (Cos(­an23 ­ d(3, i) + d(2, i))))) 

Range("a154") = "The active power flowing from bus 2 to 4 in pu" 
Range("b154") = (((v(2, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(4, i) ­ d(2, i))))) 

Range("a155") = "The active power flowing from bus 4 to 2 in pu" 
Range("b155") = (((v(4, i) ^ 2) * (g24)) + ((v(4, i)) * (v(2, i)) * (­y24) * (Cos(­an24 + d(2, i) ­ d(4, i))))) 

Range("a156") = "The active power flowing from bus 2 to 5 in pu" 
Range("b156") = (((v(2, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(5, i) ­ d(2, i))))) 

Range("a157") = "The active power flowing from bus 5 to 2 in pu" 
Range("b157") = (((v(5, i) ^ 2) * (g25)) + ((v(5, i)) * (v(2, i)) * (­y25) * (Cos(­an25 + d(2, i) ­ d(5, i))))) 

Range("a158") = "The active power flowing from bus 3 to 6 in pu" 
Range("b158") = (((v(3, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(6, i) ­ d(3, i))))) 

Range("a159") = "The active power flowing from bus 6 to 3 in pu" 
Range("b159") = (((v(6, i) ^ 2) * (g36)) + ((v(3, i)) * (v(6, i)) * (­y36) * (Cos(­an36 + d(3, i) ­ d(6, i))))) 
Range("a160") = "The active power flowing from bus 4 to 7 in pu" 
Range("b160") = (((v(4, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(7, i) ­ d(4, i))))) 
Range("a161") = "The active power flowing from bus 7 to 4 in pu" 
Range("b161") = (((v(7, i) ^ 2) * (g47)) + ((v(4, i)) * (v(7, i)) * (­y47) * (Cos(­an47 + d(4, i) ­ d(7, i))))) 
Range("a162") = "The active power flowing from bus 5 to 8 in pu" 
Range("b162") = (((v(5, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(8, i) ­ d(5, i))))) 

Range("a163") = "The active power flowing from bus 8 to 5 in pu" 
Range("b163") = (((v(8, i) ^ 2) * (g58)) + ((v(5, i)) * (v(8, i)) * (­y58) * (Cos(­an58 + d(5, i) ­ d(8, i))))) 

Range("a164") = "The active power flowing from bus 6 to 9 in pu" 
Range("b164") = (((v(6, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(9, i) ­ d(6, i))))) 

Range("a165") = "The active power flowing from bus 9 to 6 in pu" 
Range("b165") = (((v(9, i) ^ 2) * (g69)) + ((v(6, i)) * (v(9, i)) * (­y69) * (Cos(­an69 + d(6, i) ­ d(9, i))))) 

Range("a166") = "The active power flowing from bus 7 to 10 in pu" 
Range("b166") = (((v(7, i) ^ 2) * (g710)) + ((v(7, i)) * (v(10, i)) * (­y710) * (Cos(­an710 + d(10, i) ­ d(7, 
i))))) 
Range("a167") = "The active power flowing from bus 10 to 7 in pu" 
Range("b167") = (((v(10, i) ^ 2) * (g710)) + ((v(7, i)) * (v(10, i)) * (­y710) * (Cos(­an710 + d(7, i) ­ 
d(10, i))))) 
Range("a168") = "The reactive power flowing from bus 1 to 2 in pu" 
Range("b168") = (­(v1 ^ 2) * (b12 + yc12) ­ ((v1) * (v(2, i)) * (­y12) * (Sin(­an12 + d(2, i) ­ d1)))) 
Range("a169") = "The reactive power flowing from bus 2 to 1 in pu" 
Range("b169") = (­(v(2, i) ^ 2) * (b12 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v1) * (­y12) * (Sin(­an12 + 
d1 ­ d(2, i))))) 
Range("a170") = "The reactive power flowing from bus 2 to 3 in pu" 
Range("b170") = (­(v(2, i) ^ 2) * (b23 + yc23 + yc24 + yc25) ­ ((v(2, i)) * (v(3, i)) * (­y23) * (Sin(­an23 
+ d(3, i) ­ d(2, i))))) 
Range("a171") = "The reactive power flowing from bus 3 to 2 in pu" 
Range("b171") = (­(v(3, i) ^ 2) * (b23) ­ ((v(3, i)) * (v(2, i)) * (­y23) * (Sin(­an23 + d(2, i) ­ d(3, i))))) 
Range("a172") = "The reactive power flowing from bus 2 to 4 in pu" 
Range("b172") = (­(v(2, i) ^ 2) * (b24 + yc24 + yc25 + yc23) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 
+ d(4, i) ­ d(2, i))))) 
Range("a173") = "The reactive power flowing from bus 4 to 2 in pu" 
Range("b173") = (­(v(4, i) ^ 2) * (b24) ­ ((v(4, i)) * (v(2, i)) * (­y24) * (Sin(­an24 + d(2, i) ­ d(4, i))))) 
Range("a174") = "The reactive power flowing from bus 2 to 5 in pu" 
Range("b174") = (­(v(2, i) ^ 2) * (b25 + yc24 + yc23 + yc25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 
+ d(5, i) ­ d(2, i))))) 
Range("a175") = "The reactive power flowing from bus 5 to 2 in pu" 
Range("b175") = (­(v(5, i) ^ 2) * (b25) ­ ((v(5, i)) * (v(2, i)) * (­y25) * (Sin(­an25 + d(2, i) ­ d(5, i))))) 
Range("a176") = "The reactive power flowing from bus 3 to 6 in pu" 
Range("b176") = (­(v(3, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(6, i) ­ d(3, i))))) 
Range("a177") = "The reactive power flowing from bus 6 to 3 in pu" 
Range("b177") = (­(v(6, i) ^ 2) * (b36) ­ ((v(3, i)) * (v(6, i)) * (­y36) * (Sin(­an36 + d(3, i) ­ d(6, i))))) 
Range("a178") = "The reactive power flowing from bus 4 to 7 in pu" 
Range("b178") = (­(v(4, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(7, i) ­ d(4, i))))) 
Range("a179") = "The reactive power flowing from bus 7 to 4 in pu" 
Range("b179") = (­(v(7, i) ^ 2) * (b47) ­ ((v(4, i)) * (v(7, i)) * (­y47) * (Sin(­an47 + d(4, i) ­ d(7, i))))) 
Range("a180") = "The reactive power flowing from bus 5 to 8 in pu" 
Range("b180") = (­(v(5, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(8, i) ­ d(5, i))))) 
Range("a181") = "The reactive power flowing from bus 8 to 5 in pu" 
Range("b181") = (­(v(8, i) ^ 2) * (b58) ­ ((v(5, i)) * (v(8, i)) * (­y58) * (Sin(­an58 + d(5, i) ­ d(8, i))))) 
Range("a182") = "The reactive power flowing from bus 6 to 9 in pu" 
Range("b182") = (­(v(6, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(9, i) ­ d(6, i))))) 
Range("a183") = "The reactive power flowing from bus 9 to 6 in pu" 
Range("b183") = (­(v(9, i) ^ 2) * (b69) ­ ((v(6, i)) * (v(9, i)) * (­y69) * (Sin(­an69 + d(6, i) ­ d(9, i))))) 
Range("a184") = "The reactive power flowing from bus 7 to 10 in pu" 
Range("b184") = (­(v(7, i) ^ 2) * (b710) ­ ((v(7, i)) * (v(10, i)) * (­y710) * (Sin(­an710 + d(10, i) ­ d(7, 
i))))) 
Range("a185") = "The reactive power flowing from bus 10 to 7 in pu" 
Range("b185") = (­(v(10, i) ^ 2) * (b710) ­ ((v(7, i)) * (v(10, i)) * (­y710) * (Sin(­an710 + d(7, i) ­ d(10, 
i))))) 
For i = nit ­ 1 To nit 
'Print diffp(2, i), diffp(3, i), diffp(4, i), diffp(5, i), diffp(6, i), diffp(7, i), diffp(8, i), diffp(9, i), diffp(10, 
i), dq(2, i), dq(3, i), dq(4, i), dq(5, i), dq(6, i), dq(7, i), dq(8, i), dq(9, i), dq(10, i) 
Next i 
End Sub 
Sub MySub21() 
Range("b2").Select 
r12 = Range("b2") 
r13 = Range("b3") 
r24 = Range("b4") 
r34 = Range("b5") 
x12 = Range("b6") 
x13 = Range("b7") 
x24 = Range("b8") 
x34 = Range("b9") 
mvac12 = Range("b10") 
mvac13 = Range("b11") 
mvac24 = Range("b12") 
mvac34 = Range("b13") 
v1 = Range("b14") 
v2 = Range("b15") 
v3 = Range("b16") 
v4 = Range("b17") 
d1 = Range("b18") 
d2 = Range("b19") 
d3 = Range("b20") 
d4 = Range("b21") 
p1 = Range("b22") 
p2 = Range("b23") 
p3 = Range("b24") 
p4 = Range("b25") 
q1 = Range("b26") 
q2 = Range("b27") 
q3 = Range("b28") 
q4 = Range("b29") 
kvb = Range("b30") 
z12 = ((r12) ^ 2 + (x12) ^ 2) ^ 0.5 
z13 = ((r13) ^ 2 + (x13) ^ 2) ^ 0.5 
z24 = ((r24) ^ 2 + (x24) ^ 2) ^ 0.5 
z34 = ((r34) ^ 2 + (x34) ^ 2) ^ 0.5 
an12 = Atn(x12 / r12) 
an13 = Atn(x13 / r13) 
an24 = Atn(x24 / r24) 
an34 = Atn(x34 / r34) 
y12 = 1 / z12 
y13 = 1 / z13 
y24 = 1 / z24 
y34 = 1 / z34 
g12 = y12 * Cos(­an12) 
g13 = y13 * Cos(­an13) 
g24 = y24 * Cos(­an24) 
g34 = y34 * Cos(­an34) 
b12 = y12 * Sin(­an12) 
b13 = y13 * Sin(­an13) 
b24 = y24 * Sin(­an24) 
b34 = y34 * Sin(­an34) 
yc12 = (mvac12) / (200) 
yc13 = (mvac13) / (200) 
yc24 = (mvac24) / (200) 
yc34 = (mvac34) / (200) 
gb11 = g12 + g13 
gb22 = g24 + g12 
gb33 = g34 + g13 
gb44 = g34 + g24 
gb12 = ­g12 
gb21 = ­g12 
gb13 = ­g13 
gb31 = ­g13 
gb24 = ­g24 
gb42 = ­g24 
gb34 = ­g34 
gb43 = ­g34 
bb11 = b12 + b13 + yc12 + yc13 
bb22 = b24 + b12 + yc12 + yc24 
bb33 = b34 + b13 + yc13 + yc34 
bb44 = b34 + b24 + yc34 + yc24 
bb12 = ­b12 
bb21 = ­b12 
bb13 = ­b13 
bb31 = ­b13 
bb24 = ­b24 
bb42 = ­b24 
bb34 = ­b34 
bb43 = ­b34 
pb2 = ((gb22) * ((v2) ^ 2)) + ((v2 * v1) * (­y12 * Cos(­an12 + d1 ­ d2))) + ((v4 * v2) * (­y24 * Cos(­
an24 + d4 ­ d2))) 
pb3 = ((gb33) * ((v3) ^ 2)) + ((v3 * v1) * (­y13 * Cos(­an13 ­ d3 + d1))) + ((v4) * (v3) * (­y34 * Cos(­
an34 ­ d3 + d4))) 
pb4 = ((gb44) * ((v4) ^ 2)) + ((v4 * v2) * (­y24 * Cos(­an24 ­ d4 + d2))) + ((v3 * v4) * (­y34 * Cos(­
an34 ­ d4 + d3))) 
qb2 = ­((bb22) * ((v2) ^ 2)) ­ ((v2 * v1) * (­y12 * Sin(­an12 + d1 ­ d2))) ­ ((v4 * v2) * (­y24 * Sin(­
an24 + d4 ­ d2))) 
qb3 = ­((bb33) * ((v3) ^ 2)) ­ ((v3 * v1) * (­y13 * Sin(­an13 ­ d3 + d1))) ­ ((v4) * (v3) * (­y34 * Sin(­
an34 ­ d3 + d4))) 
diffp2 = ((p2 / 100) ­ pb2) 
diffp3 = ((p3 / 100) ­ pb3) 
diffp4 = ((p4 / 100) ­ pb4) 
diffq2 = ((q2 / 100) ­ qb2) 
diffq3 = ((q3 / 100) ­ qb3) 
m22 = ((v2 * v1) * (­y12 * Sin(­an12 + d1 ­ d2))) + ((v2 * v4) * (­y24 * Sin(­an24 + d4 ­ d2))) 
m33 = ((v3 * v1) * (­y13 * Sin(­an13 ­ d3 + d1))) + ((v4 * v3) * (­y34 * Sin(­an34 ­ d3 + d4))) 
m44 = ((v2 * v4) * (­y24 * Sin(­an24 ­ d4 + d2))) + ((v4 * v3) * (­y34 * Sin(­an34 + d3 ­ d4))) 
m23 = ­((v2 * v3) * (­y23 * Sin(­an23 ­ d2 + d3))) 
m32 = ­((v2 * v3) * (­y23 * Sin(­an23 ­ d3 + d2))) 
m24 = ­((v2 * v4) * (­y24 * Sin(­an24 ­ d2 + d4))) 
m42 = ­((v2 * v4) * (­y24 * Sin(­an24 ­ d4 + d2))) 
m34 = ­((v4 * v3) * (­y34 * Sin(­an34 + d4 ­ d3))) 
m43 = ­((v4 * v3) * (­y34 * Sin(­an34 + d3 ­ d4))) 
n22 = ((v2 * v1) * (­y12 * Cos(­an12 + d1 ­ d2))) + ((v2 * v4) * (­y24 * Cos(­an24 + d4 ­ d2))) 
n33 = ((v3 * v1) * (­y13 * Cos(­an13 ­ d3 + d1))) + ((v4 * v3) * (­y34 * Cos(­an34 ­ d3 + d4))) 
n23 = ­((v2 * v3) * (­y23 * Cos(­an23 + d3 ­ d2))) 
n32 = ­((v2 * v3) * (­y23 * Cos(­an23 ­ d3 + d2))) 
n34 = ­((v3 * v4) * (­y34 * Cos(­an34 + d4 ­ d3))) 
n43 = ­((v3 * v4) * (­y34 * Cos(­an34 ­ d4 + d3))) 
n24 = ­((v2 * v4) * (­y24 * Cos(­an24 ­ d2 + d4))) 
n42 = ­((v2 * v4) * (­y24 * Cos(­an24 + d2 ­ d4))) 
mm25 = n22 + (2 * (v2 ^ 2) * (gb22)) 
mm26 = ­n23 
mm35 = ­n32 
mm36 = n33 + (2 * (v3 ^ 2) * (gb33)) 
mm45 = ­n42 
mm46 = ­n34 
nn25 = ­m22 ­ (2 * (v2 ^ 2) * (bb22)) 
nn26 = m23 
nn35 = m32 
nn36 = ­m33 ­ (2 * (v3 ^ 2) * (bb33)) 
y110 = m22 / m22 
y120 = m23 / m22 
y130 = m24 / m22 
y140 = mm25 / m22 
y150 = mm26 / m22 
y220 = m33 ­ (m32) * (m23) / (m22) 
y230 = m34 ­ (m32) * (m24) / (m22) 
y240 = mm35 ­ (m32) * (mm25) / m22 
y250 = mm36 ­ (m32) * (mm26) / m22 
y320 = m43 ­ (m42) * (m23) / m22 
y330 = m44 ­ (m42) * (m24) / m22 
y340 = mm45 ­ (m42) * (mm25) / m22 
y350 = mm46 ­ (m42) * (mm26) / m22 
y420 = n23 ­ (n22) * (m23) / m22 
y430 = n24 ­ (n22) * (m24) / m22 
y440 = nn25 ­ (n22) * (mm25) / m22 
y450 = nn26 ­ (n22) * (mm26) / m22 
y520 = n33 ­ (n32) * (m23) / m22 
y530 = n34 ­ (n32) * (m24) / m22 
y540 = nn35 ­ (n32) * (mm25) / m22 
y550 = nn36 ­ (n32) * (mm26) / m22 
y221 = y220 / y220 
y231 = y230 / y220 
y241 = y240 / y220 
y251 = y250 / y220 
y331 = y330 ­ (y320) * (y230) / y220 
y341 = y340 ­ (y320) * (y240) / y220 
y351 = y350 ­ (y320) * (y250) / y220 
y431 = y430 ­ (y420) * (y230) / y220 
y441 = y440 ­ (y420) * (y240) / y220 
y451 = y450 ­ (y420) * (y250) / y220 
y531 = y530 ­ (y520) * (y230) / y220 
y541 = y540 ­ (y520) * (y240) / y220 
y551 = y550 ­ (y520) * (y250) / y220 
y332 = y331 / y331 
y342 = y341 / y331 
y352 = y351 / y331 
y442 = y441 ­ (y431) * (y341) / y331 
y452 = y451 ­ (y431) * (y351) / y331 
y542 = y541 ­ (y531) * (y341) / y331 
y552 = y551 ­ (y531) * (y351) / y331 
y443 = y442 / y442 
y453 = y452 / y442 
y553 = y552 ­ (y542) * (y452) / y442 
'Print "the bus admittance matrix of the 4 bus system" 
'Print "Y11 = "; gb11; "+j"; bb11 
'Print "Y12 = "; gb12; "+j"; bb12 
'Print "Y13 = "; gb13; "+j"; bb13 
'Print "Y14 = "; gb14; "+j"; bb14 
'Print "Y21 = "; gb21; "+j"; bb21 
'Print "Y22 = "; gb22; "+j"; bb22 
'Print "Y23 = "; gb23; "+j"; bb23 
'Print "Y24 = "; gb24; "+j"; bb24 
'Print "Y31 = "; gb31; "+j"; bb31 
'Print "Y32 = "; gb32; "+j"; bb32 
'Print "Y33 = "; gb33; "+j"; bb33 
'Print "Y34 = "; gb34; "+j"; bb34 
'Print "Y41 = "; gb41; "+j"; bb41 
'Print "Y42 = "; gb42; "+j"; bb42 
'Print "Y43 = "; gb43; "+j"; bb43 
'Print "Y44 = "; gb44; "+j"; bb44 
'Print " Jacobian matrix : " 
'Print m22; m23; m24; mm25; mm26; mm27 
'Print m32; m33; m34; mm35; mm36; mm37 
'Print m42; m43; m44; mm45; mm46; mm47 
'Print n22; n23; n24; nn25; nn26; nn27 
'Print n32; n33; n34; nn35; nn36; nn37 
'Print "the mismatches: dp2, dp3, dp4, dq2,dq3 respectively:"; diffp2; diffp3; diffp4; diffq2; diffq3 
x1 = diffp2 / m22 
x2 = (diffp3 ­ (x1) * (m32)) / y220 
x3 = (diffp4 ­ (x1) * (m42) ­ (y320) * (x2)) / y331 
x4 = (diffq2 ­ (x1) * (n22) ­ (y420) * (x2) ­ (x3) * (y431)) / y442 
x5 = (diffq3 ­ (x1) * (n32) ­ (y520) * (x2) ­ (x3) * (y531) ­ (x4) * (y542)) / y553 
f5 = x5 
f4 = (x4 ­ ((y453) * (f5))) 
f3 = (x3 ­ ((y342) * (f4)) ­ ((y352) * (f5))) 
f2 = (x2 ­ ((y231) * (f3)) ­ (y241) * (f4) ­ (y251) * (f5)) 
f1 = (x1 ­ ((y120) * (f2)) ­ ((y130) * (f3)) ­ ((y140) * (f4)) ­ ((y150) * (f5))) 
'Print f1; "rad", f2; "rad.", f3, f4, f5 
v21 = v2 * (1 + f4) 
v31 = v3 * (1 + f5) 
d21 = d2 + f1 
d31 = d3 + f2 
d41 = d4 + f3 
'Print "after first iteration, voltages and phase angles at buses 1,2,3,4: "; 0; 1, v21; d21, v31; d31, 1.02; 
d41 
'Print d21 * 180 / 3.141592654; "deg", d31 * 180 / 3.141592654; "deg", d41 * 180 / 3.141592654 
pb21 = ((gb22) * ((v21) ^ 2)) + ((v21 * v1) * (­y12 * Cos(­an12 + d1 ­ d21))) + ((v4 * v21) * (­y24 * 
Cos(­an24 + d41 ­ d21))) 
pb31 = ((gb33) * ((v31) ^ 2)) + ((v31 * v1) * (­y13 * Cos(­an13 ­ d31 + d1))) + ((v4) * (v31) * (­y34 * 
Cos(­an34 ­ d31 + d41))) 
pb41 = ((gb44) * ((v4) ^ 2)) + ((v4 * v21) * (­y24 * Cos(­an24 ­ d41 + d21))) + ((v31 * v4) * (­y34 * 
Cos(­an34 ­ d41 + d31))) 
qb21 = ­((bb22) * ((v21) ^ 2)) ­ ((v21 * v1) * (­y12 * Sin(­an12 + d1 ­ d21))) ­ ((v4 * v21) * (­y24 * 
Sin(­an24 + d41 ­ d21))) 
qb31 = ­((bb33) * ((v31) ^ 2)) ­ ((v31 * v1) * (­y13 * Sin(­an13 ­ d31 + d1))) ­ ((v4) * (v31) * (­y34 * 
Sin(­an34 ­ d31 + d41))) 
diffp21 = ((p2 / 100) ­ pb21) 
diffp31 = ((p3 / 100) ­ pb31) 
diffp41 = ((p4 / 100) ­ pb41) 
diffq21 = ((q2 / 100) ­ qb21) 
diffq31 = ((q3 / 100) ­ qb31) 
m221 = ((v21 * v1) * (­y12 * Sin(­an12 + d1 ­ d21))) + ((v21 * v4) * (­y24 * Sin(­an24 + d41 ­ d21))) 
m331 = ((v31 * v1) * (­y13 * Sin(­an13 ­ d31 + d1))) + ((v4 * v31) * (­y34 * Sin(­an34 ­ d31 + d41))) 
m441 = ((v21 * v4) * (­y24 * Sin(­an24 ­ d41 + d21))) + ((v4 * v31) * (­y34 * Sin(­an34 + d31 ­ d41))) 
m231 = ­((v21 * v31) * (­y23 * Sin(­an23 ­ d21 + d31))) 
m321 = ­((v21 * v31) * (­y23 * Sin(­an23 ­ d31 + d21))) 
m241 = ­((v21 * v4) * (­y24 * Sin(­an24 ­ d21 + d41))) 
m421 = ­((v21 * v4) * (­y24 * Sin(­an24 ­ d41 + d21))) 
m341 = ­((v4 * v31) * (­y34 * Sin(­an34 + d41 ­ d31))) 
m431 = ­((v4 * v31) * (­y34 * Sin(­an34 + d31 ­ d41))) 
n221 = ((v21 * v1) * (­y12 * Cos(­an12 + d1 ­ d21))) + ((v21 * v4) * (­y24 * Cos(­an24 + d41 ­ d21))) 
n331 = ((v31 * v1) * (­y13 * Cos(­an13 ­ d31 + d1))) + ((v4 * v31) * (­y34 * Cos(­an34 ­ d31 + d41))) 
n231 = ­((v21 * v31) * (­y23 * Cos(­an23 + d31 ­ d21))) 
n321 = ­((v21 * v31) * (­y23 * Cos(­an23 ­ d31 + d21))) 
n341 = ­((v31 * v4) * (­y34 * Cos(­an34 + d41 ­ d31))) 
n431 = ­((v31 * v4) * (­y34 * Cos(­an34 ­ d41 + d31))) 
n241 = ­((v21 * v4) * (­y24 * Cos(­an24 ­ d21 + d41))) 
n421 = ­((v21 * v4) * (­y24 * Cos(­an24 + d21 ­ d41))) 
mm251 = n221 + (2 * (v21 ^ 2) * (gb22)) 
mm261 = ­n231 
mm351 = ­n321 
mm361 = n331 + (2 * (v31 ^ 2) * (gb33)) 
mm451 = ­n421 
mm461 = ­n341 
nn251 = ­m221 ­ (2 * (v21 ^ 2) * (bb22)) 
nn261 = m231 
nn351 = m321 
nn361 = ­m331 ­ (2 * (v31 ^ 2) * (bb33)) 
y1101 = m221 / m221 
y1201 = m231 / m221 
y1301 = m241 / m221 
y1401 = mm251 / m221 
y1501 = mm261 / m221 
y2201 = m331 ­ (m321) * (m231) / (m221) 
y2301 = m341 ­ (m321) * (m241) / (m221) 
y2401 = mm351 ­ (m321) * (mm251) / m221 
y2501 = mm361 ­ (m321) * (mm261) / m221 
y3201 = m431 ­ (m421) * (m231) / m221 
y3301 = m441 ­ (m421) * (m241) / m221 
y3401 = mm451 ­ (m421) * (mm251) / m221 
y3501 = mm461 ­ (m421) * (mm261) / m221 
y4201 = n231 ­ (n221) * (m231) / m221 
y4301 = n241 ­ (n221) * (m241) / m221 
y4401 = nn251 ­ (n221) * (mm251) / m221 
y4501 = nn261 ­ (n221) * (mm261) / m221 
y5201 = n331 ­ (n321) * (m231) / m221 
y5301 = n341 ­ (n321) * (m241) / m221 
y5401 = nn351 ­ (n321) * (mm251) / m221 
y5501 = nn361 ­ (n321) * (mm261) / m221 
y2211 = y2201 / y2201 
y2311 = y2301 / y2201 
y2411 = y2401 / y2201 
y2511 = y2501 / y2201 
y3311 = y3301 ­ (y3201) * (y2301) / y2201 
y3411 = y3401 ­ (y3201) * (y2401) / y2201 
y3511 = y3501 ­ (y3201) * (y2501) / y2201 
y4311 = y4301 ­ (y4201) * (y2301) / y2201 
y4411 = y4401 ­ (y4201) * (y2401) / y2201 
y4511 = y4501 ­ (y4201) * (y2501) / y2201 
y5311 = y5301 ­ (y5201) * (y2301) / y2201 
y5411 = y5401 ­ (y5201) * (y2401) / y2201 
y5511 = y5501 ­ (y5201) * (y2501) / y2201 
y3321 = y3311 / y3311 
y3421 = y3411 / y3311 
y3521 = y3511 / y3311 
y4421 = y4411 ­ (y4311) * (y3411) / y3311 
y4521 = y4511 ­ (y4311) * (y3511) / y3311 
y5421 = y5411 ­ (y5311) * (y3411) / y3311 
y5521 = y5511 ­ (y5311) * (y3511) / y3311 
y4431 = y4421 / y4421 
y4531 = y4521 / y4421 
y5531 = y5521 ­ (y5421) * (y4521) / y4421 
'Print "the mismatches: dp2, dp3, dp4, dq2,dq3 respectively:"; diffp21; diffp31; diffp41; diffq21; diffq31 

xx1 = diffp21 / m221 
xx2 = (diffp31 ­ (xx1) * (m321)) / y2201 
xx3 = (diffp41 ­ (xx1) * (m421) ­ (y3201) * (xx2)) / y3311 
xx4 = (diffq21 ­ (xx1) * (n221) ­ (y4201) * (xx2) ­ (xx3) * (y4311)) / y4421 
xx5 = (diffq31 ­ (xx1) * (n321) ­ (y5201) * (xx2) ­ (xx3) * (y5311) ­ (xx4) * (y5421)) / y5531 
f51 = xx5 
f41 = (xx4 ­ ((y4531) * (f51))) 
f31 = (xx3 ­ ((y3421) * (f41)) ­ ((y3521) * (f51))) 
f21 = (xx2 ­ ((y2311) * (f31)) ­ (y2411) * (f41) ­ (y2511) * (f51)) 
f11 = (xx1 ­ ((y1201) * (f21)) ­ ((y1301) * (f31)) ­ ((y1401) * (f41)) ­ ((y1501) * (f51))) 
'Print f11; "rad", f21; "rad.", f31, f41, f51 
v22 = v21 * (1 + f41) 
v32 = v31 * (1 + f51) 
d22 = d21 + f11 
d32 = d31 + f21 
d42 = d41 + f31 
'Print "after second iteration, voltages and phase angles at buses 1,2,3,4: "; 0; 1, v22; d22, v32; d32, 
1.02; d42 
'Print d22 * 180 / 3.141592654; "deg", d32 * 180 / 3.141592654; "deg", d42 * 180 / 3.141592654 
pb22 = ((gb22) * ((v22) ^ 2)) + ((v22 * v1) * (­y12 * Cos(­an12 + d1 ­ d22))) + ((v4 * v22) * (­y24 * 
Cos(­an24 + d42 ­ d22))) 
pb32 = ((gb33) * ((v32) ^ 2)) + ((v32 * v1) * (­y13 * Cos(­an13 ­ d32 + d1))) + ((v4) * (v32) * (­y34 * 
Cos(­an34 ­ d32 + d42))) 
pb42 = ((gb44) * ((v4) ^ 2)) + ((v4 * v21) * (­y24 * Cos(­an24 ­ d42 + d22))) + ((v32 * v4) * (­y34 * 
Cos(­an34 ­ d42 + d32))) 
qb22 = ­((bb22) * ((v22) ^ 2)) ­ ((v22 * v1) * (­y12 * Sin(­an12 + d1 ­ d22))) ­ ((v4 * v22) * (­y24 * 
Sin(­an24 + d42 ­ d22))) 
qb32 = ­((bb33) * ((v32) ^ 2)) ­ ((v32 * v1) * (­y13 * Sin(­an13 ­ d32 + d1))) ­ ((v4) * (v32) * (­y34 * 
Sin(­an34 ­ d32 + d42))) 
diffp22 = ((p2 / 100) ­ pb22) 
diffp32 = ((p3 / 100) ­ pb32) 
diffp42 = ((p4 / 100) ­ pb42) 
diffq22 = ((q2 / 100) ­ qb22) 
diffq32 = ((q3 / 100) ­ qb32) 
m222 = ((v22 * v1) * (­y12 * Sin(­an12 + d1 ­ d22))) + ((v22 * v4) * (­y24 * Sin(­an24 + d42 ­ d22))) 
m332 = ((v32 * v1) * (­y13 * Sin(­an13 ­ d32 + d1))) + ((v4 * v32) * (­y34 * Sin(­an34 ­ d32 + d42))) 
m442 = ((v22 * v4) * (­y24 * Sin(­an24 ­ d42 + d22))) + ((v4 * v32) * (­y34 * Sin(­an34 + d32 ­ d42))) 

m232 = ­((v22 * v32) * (­y23 * Sin(­an23 ­ d22 + d32))) 
m322 = ­((v22 * v32) * (­y23 * Sin(­an23 ­ d32 + d22))) 
m242 = ­((v22 * v4) * (­y24 * Sin(­an24 ­ d22 + d42))) 
m422 = ­((v22 * v4) * (­y24 * Sin(­an24 ­ d42 + d22))) 
m342 = ­((v4 * v32) * (­y34 * Sin(­an34 + d42 ­ d32))) 
m432 = ­((v4 * v32) * (­y34 * Sin(­an34 + d32 ­ d42))) 
n222 = ((v22 * v1) * (­y12 * Cos(­an12 + d1 ­ d22))) + ((v22 * v4) * (­y24 * Cos(­an24 + d42 ­ d22))) 
n332 = ((v32 * v1) * (­y13 * Cos(­an13 ­ d32 + d2))) + ((v4 * v32) * (­y34 * Cos(­an34 ­ d32 + d42))) 
n232 = ­((v22 * v32) * (­y23 * Cos(­an23 + d32 ­ d22))) 
n322 = ­((v22 * v32) * (­y23 * Cos(­an23 ­ d32 + d22))) 
n342 = ­((v32 * v4) * (­y34 * Cos(­an34 + d42 ­ d32))) 
n432 = ­((v32 * v4) * (­y34 * Cos(­an34 ­ d42 + d32))) 
n242 = ­((v22 * v4) * (­y24 * Cos(­an24 ­ d22 + d42))) 
n422 = ­((v22 * v4) * (­y24 * Cos(­an24 + d22 ­ d42))) 
mm252 = n222 + (2 * (v22 ^ 2) * (gb22)) 
mm262 = ­n232 
mm352 = ­n322 
mm362 = n332 + (2 * (v32 ^ 2) * (gb33)) 
mm452 = ­n422 
mm462 = ­n342 
nn252 = ­m222 ­ (2 * (v22 ^ 2) * (bb22)) 
nn262 = m232 
nn352 = m322 
nn362 = ­m332 ­ (2 * (v32 ^ 2) * (bb33)) 
y1102 = m222 / m222 
y1202 = m232 / m222 
y1302 = m242 / m222 
y1402 = mm252 / m222 
y1502 = mm262 / m222 
y2202 = m332 ­ (m322) * (m232) / (m222) 
y2302 = m342 ­ (m322) * (m242) / (m222) 
y2402 = mm352 ­ (m322) * (mm252) / m222 
y2502 = mm362 ­ (m322) * (mm262) / m222 
y3202 = m432 ­ (m422) * (m232) / m222 
y3302 = m442 ­ (m422) * (m242) / m222 
y3402 = mm452 ­ (m422) * (mm252) / m222 
y3502 = mm462 ­ (m422) * (mm262) / m222 
y4202 = n232 ­ (n222) * (m232) / m222 
y4302 = n242 ­ (n222) * (m242) / m222 
y4402 = nn252 ­ (n222) * (mm252) / m222 
y4502 = nn262 ­ (n222) * (mm262) / m222 
y5202 = n332 ­ (n322) * (m232) / m222 
y5302 = n342 ­ (n322) * (m242) / m222 
y5402 = nn352 ­ (n322) * (mm252) / m222 
y5502 = nn362 ­ (n322) * (mm262) / m222 
y2212 = y2202 / y2202 
y2312 = y2302 / y2202 
y2412 = y2402 / y2202 
y2512 = y2502 / y2202 
y3312 = y3302 ­ (y3202) * (y2302) / y2202 
y3412 = y3402 ­ (y3202) * (y2402) / y2202 
y3512 = y3502 ­ (y3202) * (y2502) / y2202 
y4312 = y4302 ­ (y4202) * (y2302) / y2202 
y4412 = y4402 ­ (y4202) * (y2402) / y2202 
y4512 = y4502 ­ (y4202) * (y2502) / y2202 
y5312 = y5302 ­ (y5202) * (y2302) / y2202 
y5412 = y5402 ­ (y5202) * (y2402) / y2202 
y5512 = y5502 ­ (y5202) * (y2502) / y2202 
y3322 = y3312 / y3312 
y3422 = y3412 / y3312 
y3522 = y3512 / y3312 
y4422 = y4412 ­ (y4312) * (y3412) / y3312 
y4522 = y4512 ­ (y4312) * (y3512) / y3312 
y5422 = y5412 ­ (y5312) * (y3412) / y3312 
y5522 = y5512 ­ (y5312) * (y3512) / y3312 
y4432 = y4422 / y4422 
y4532 = y4522 / y4422 
y5532 = y5522 ­ (y5422) * (y4522) / y4422 
'Print "the mismatches: dp2, dp3, dp4, dq2,dq3 respectively:"; diffp22; diffp32; diffp42; diffq22; 
diffq32 
xx11 = diffp22 / m222 
xx21 = (diffp32 ­ (xx11) * (m322)) / y2202 
xx31 = (diffp42 ­ (xx11) * (m422) ­ (y3202) * (xx21)) / y3312 
xx41 = (diffq22 ­ (xx11) * (n222) ­ (y4202) * (xx21) ­ (xx31) * (y4312)) / y4422 
xx51 = (diffq32 ­ (xx11) * (n322) ­ (y5202) * (xx21) ­ (xx31) * (y5312) ­ (xx41) * (y5422)) / y5532 
f52 = xx51 
f42 = (xx41 ­ ((y4532) * (f52))) 
f32 = (xx31 ­ ((y3422) * (f42)) ­ ((y3522) * (f52))) 
f22 = (xx21 ­ ((y2312) * (f32)) ­ (y2412) * (f42) ­ (y2512) * (f52)) 
f12 = (xx11 ­ ((y1202) * (f22)) ­ ((y1302) * (f32)) ­ ((y1402) * (f42)) ­ ((y1502) * (f52))) 
'Print f12; "rad", f22; "rad.", f32, f42, f52 
v23 = v22 * (1 + f42) 
v33 = v32 * (1 + f52) 
d23 = d22 + f12 
d33 = d32 + f22 
d43 = d42 + f32 
Range("b32") = v1 
Range("b33") = v23 
Range("b34") = v33 
Range("b35") = v43 
Range("b36") = d1 
Range("c36") = d1 * 180 / 3.14159265 
Range("b37") = d23 
Range("c37") = d23 * 180 / 3.14159265 
Range("b38") = d33 
Range("c38") = d33 * 180 / 3.14159265 
Range("b39") = d43 
Range("c39") = d43 * 180 / 3.14159265 
Range("b40") = (((v1 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­an12 + d23 ­ d1)))) 
Range("b41") = (((v23 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­an12 ­ d23 + d1)))) 
Range("b42") = (((v1 ^ 2) * (g13)) + ((v1) * (v33) * (­y13) * (Cos(­an13 + d33 ­ d1)))) 
Range("b43") = (((v33 ^ 2) * (g13)) + ((v1) * (v33) * (­y13) * (Cos(­an13 ­ d33 + d1)))) 
Range("b44") = (((v23 ^ 2) * (g24)) + ((v23) * (v4) * (­y24) * (Cos(­an24 ­ d23 + d43)))) 
Range("b45") = (((v4 ^ 2) * (g24)) + ((v23) * (v4) * (­y24) * (Cos(­an24 + d23 ­ d43)))) 
Range("b46") = (((v33 ^ 2) * (g34)) + ((v4) * (v33) * (­y34) * (Cos(­an34 + d43 ­ d33)))) 
Range("b47") = (((v4 ^ 2) * (g34)) + ((v4) * (v33) * (­y34) * (Cos(­an34 + d33 ­ d43)))) 
Range("b48") = (­(v1 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­an12 + d23 ­ d1))) 
Range("b49") = (­(v23 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­an12 ­ d23 + d1))) 
Range("b50") = (­(v1 ^ 2) * (b13 + yc13) ­ (v1) * (v33) * (­y13) * (Sin(­an13 + d33 ­ d1))) 
Range("b51") = (­(v33 ^ 2) * (b13 + yc13) ­ (v1) * (v33) * (­y13) * (Sin(­an13 ­ d33 + d1))) 
Range("b52") = (­(v23 ^ 2) * (b24 + yc24) ­ (v23) * (v4) * (­y24) * (Sin(­an24 ­ d23 + d43))) 
Range("b53") = (­(v4 ^ 2) * (b24 + yc24) ­ (v23) * (v4) * (­y24) * (Sin(­an24 + d23 ­ d43))) 
Range("b54") = (­(v33 ^ 2) * (b34 + yc34) ­ (v4) * (v33) * (­y34) * (Sin(­an34 + d43 ­ d33))) 
Range("b55") = (­(v4 ^ 2) * (b34 + yc34) ­ (v4) * (v33) * (­y34) * (Sin(­an34 + d33 ­ d43))) 
'Print "after third iteration, voltages and phase angles at buses 1,2,3,4: "; 0; 1, v23; d23, v33; d33, 1.02; 
d43 
'Print d23 * 180 / 3.141592654; "deg", d33 * 180 / 3.141592654; "deg", d43 * 180 / 3.141592654 
'Print "active and reactive powers are in p.u." 
'Print "active power in p.u.from bus 1 towards 3:"; (((v1 ^ 2) * (g13)) + ((v1) * (v33) * (­y13) * (Cos(­
an13 + d33 ­ d1)))) 
'Print "active power in p.u.from bus 1 towards 2:"; (((v1 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­
an12 + d23 ­ d1)))) 
'Print "active power in p.u.from bus 2 towards 1:"; (((v23 ^ 2) * (g12)) + ((v1) * (v23) * (­y12) * (Cos(­
an12 ­ d23 + d1)))) 
'Print "active power in p.u.from bus 3 towards 1:"; (((v33 ^ 2) * (g13)) + ((v1) * (v33) * (­y13) * (Cos(­
an13 ­ d33 + d1)))) 
'Print "active power in p.u.from bus 2 towards 4:"; (((v23 ^ 2) * (g24)) + ((v23) * (v4) * (­y24) * (Cos(­
an24 ­ d23 + d43)))) 
'Print "active power in p.u.from bus 4 towards 2:"; (((v4 ^ 2) * (g24)) + ((v23) * (v4) * (­y24) * (Cos(­
an24 + d23 ­ d43)))) 
'Print "active power in p.u.from bus 4 towards 3:"; (((v4 ^ 2) * (g34)) + ((v4) * (v33) * (­y34) * (Cos(­
an34 + d33 ­ d43)))) 
'Print "active power in p.u.from bus 3 towards 4:"; (((v33 ^ 2) * (g34)) + ((v4) * (v33) * (­y34) * (Cos(­
an34 + d43 ­ d33)))) 
'Print "reactive power from bus 1 towards 3:"; (­(v1 ^ 2) * (b13 + yc13) ­ (v1) * (v33) * (­y13) * (Sin(­
an13 + d33 ­ d1))) 
'Print "reactive power from bus 1 towards 2:"; (­(v1 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­
an12 + d23 ­ d1))) 
'Print "reactive power from bus 2 towards 1:"; (­(v23 ^ 2) * (b12 + yc12) ­ (v1) * (v23) * (­y12) * (Sin(­
an12 ­ d23 + d1))) 
'Print "reactive power from bus 3 towards 1:"; (­(v33 ^ 2) * (b13 + yc13) ­ (v1) * (v33) * (­y13) * (Sin(­
an13 ­ d33 + d1))) 
'Print "reactive power from bus 2 towards 4:"; (­(v23 ^ 2) * (b24 + yc24) ­ (v23) * (v4) * (­y24) * (Sin(­
an24 ­ d23 + d43))) 
'Print "reactive power from bus 4 towards 2:"; (­(v4 ^ 2) * (b24 + yc24) ­ (v23) * (v4) * (­y24) * (Sin(­
an24 + d23 ­ d43))) 
'Print "reactive power from bus 4 towards 3:"; (­(v4 ^ 2) * (b34 + yc34) ­ (v4) * (v33) * (­y34) * (Sin(­
an34 + d33 ­ d43))) 
'Print "reactive power from bus 3 towards 4:"; (­(v33 ^ 2) * (b34 + yc34) ­ (v4) * (v33) * (­y34) * (Sin(­
an34 + d43 ­ d33))) 
End Sub 
General comments and notes regarding the above programs: 
1) The previous examples solve the load flow problem. They give the voltages and phase angles at each 
of the buses in the system plus the power (active & reactive) flowing into and from each of the buses. 
They cover the following systems: 
1­1) Radial system: 
1­1­1) Single feeder with two buses (including the slack), it is given to present the simplest problem in 
load flow analysis and to offer the basis for the more complex systems. 
1­1­2) Single feeder with three buses (including the slack bus). 
1­1­3) Three feeders with 5, 6, 7, 8, 9 or 10 buses (including the slack bus). 
1­2) Network (grid) system with 4 buses. 
2) Pages 153 to 155, inclusive, include the user form code for system 1­1­1, above. Pages 155 to 157 
include the user form (dialog box) for system 1­1­2, above. Pages 157 to 161 include the code for system 
1­1­3 with 5 buses, above. The corresponding modules (in the module section starting at page 176) for 
these systems are: Sub MySub11() on page 176, Sub MySub12() on page 178 and Sub MySub 131 () on 
page 181, respectively. The user forms for these systems include one screen. By refering to the 
corresponding user form code, the reader will notice the following: The commandbutton1 (the push 
button) is the reset button i.e. when clicked or chosen will reset the values in the user form to the 
previous values (given in ranges: z2 to zz12, z26 to z43 & z65 to zz130, respectively,  in the worksheet ­ 
spread sheet). The commandbutton2, when cclicked will unload (remove) the user form from the screen 
and continue with the following statements in the calling module ­ procedure or subroutine, Sub 
MySub11(), Sub MySub12() & Sub MySub131(), respectively for the above three examples. For all 
three examples, these steps will calculate the required values, the results, write them to the indicated 
(appropriate) cells in the worksheet and takes the user to the portion of the worksheet where he or she 
can find these results. Upon activation of the form (when the user picks the system from the menu bar, 
the pertinent module is called and the statement in the code are executed, one of the first is showing the 
dialog box ­ user form), the UserForm_Activate sub will read the data written previously to the cells in 
the worksheet (the indicated cells) into the text boxs (show these values in the user form). There is a 
portion in the worksheet to which the reset command button will refer to when clicked. The 
UserForm_Aactivate will update this range with the new data entered in the work range during the 
previous session, this will take place when the form is activated (loaded). 
3) Starting from module Sub MySub()132 to Sub MySub136(), inclusive, the user will use two dialog 
boxes to enter the pertinent data regarding the system under study. The dialog boxes (user forms) will 
have the following names: UserForm4/4a, UserForm5/5a, UserForm6/6a, UserForm7/7a and 
UserForm8/8a, respectively. The controls (components), for example on UserForm4 are labels, text 
boxes (edit fields) and command buttons (2 of them). The controls on the second, UserForm4a for 
example, are labels, text boxes and command buttons (3 of them). 
The command buttons on the first user form are: the move to next form (dialog box) and the reset 
button. The command buttons on the second user form are: move to previous form, reset values of form 
and run the analysis buttons. The move to next form button will perform the following tasks: copy the 
range of cells where the user entered the new data to the reset range of the worksheet (note: after the 
user finishes entering the data in each text box, the content of the text box is written to the appropriate 
cells ­working area­ in the worksheet), it will unload the user form and will show the next. The reset 
button will reset the values in the text boxes of the form to the previous ones, copying from the reset 
area (the range of cells) of the worksheet to the text boxes. The move to the previous form  will do 
exactly as the move to the next form but unloading removing the second form (presently displayed on 
the monitor) and showing the previously displayed one. The run the analysis button will remove the 
user form (the second one) from the screen and take the user to the area in the worksheet where he or 
she will find the results of the analysis. The procedures UserForm_Deactivate will write the data 
(entered by the user in this session) in the working area cells to the reset range, the UserForm_Activate 
will put in the text boxes the values previously written to the reset area (range of cells).

contents
Appendix A

The following is an example program taken from the original package written in Quickbasic computer 
language. 
DECLARE SUB ff () 
DECLARE SUB zz () 
DECLARE SUB ee () 
DECLARE SUB dd () 
DECLARE SUB cc () 
DECLARE SUB bb () 
DECLARE SUB aa () 
CLS 
PRINT "The Series of Short Programs for Power Systems Analysts" 
PRINT "a program to calculate a reliability index for industrial/commercial system" 
PRINT "type of system: enter 1 for simple radial, 2 for primary selective to utility supply, 3 for primary 
selective to load side, 4 for primary selective to primary of xfo, 5 for secondary selective & 6 for radial 
with spares." 
PRINT "for typical values of failures per year and hours of downtime per failure, enter 10." 
INPUT "the choice:"; tys 
IF tys = 1 THEN CALL aa 
IF tys = 3 THEN CALL bb 
IF tys = 2 THEN CALL cc 
IF tys = 4 THEN CALL dd 
IF tys = 5 THEN CALL ee 
IF tys = 6 THEN CALL ff 
IF tys = 10 THEN 
cardscreen: 
DATA "????????????????????????????????????????????????????????????????????????????????" 
DATA "³EQUIPMENT CATEGORY               FAILURES/YEAR      HOURS OF 
DOWNTIME/FAILURE ³" 
DATA "³protective relays                 .0002                        5              ³" 
DATA "³0­600 V c.b.                      .0027                        4              ³" 
DATA "³above 600V c.b.                   .0036                        83.1           ³" 
DATA "³0­600 V cable (/1000 ft)          .00141                       10.5           ³" 
DATA "³1000 V and over(/1000ft)          .00613                       26.5           ³" 
DATA "³0­600 V cable terminations        .0001                         3.8           ³" 
DATA "³above 600 V cable terminations    .0003                        25             ³" 
DATA "³enclosed disconnect switches      .0061                         3.6           ³" 
DATA "³transformers                      .003                         342            ³" 
DATA "³bare l.v. swgr bus (with 7 c.b.)  .0024                         24            ³" 
DATA "³bare l.v.swgr bus (with 5 c.b.)   .0017                         24            ³" 
DATA "³insulated m.v. swgr bus (1 c.b.)  .0034                         26.8          ³" 
DATA "³insulated m.v. swgr bus (2 c.b.)  .0068                         26.8          ³" 
DATA "³DATA REGARDING ELECTRIC POWER UTILITY RELIABILITY FACTORS                     
³" 
DATA "³­Single circuit                   1.956                         1.32          ³" 
DATA "³­Double circuits                                                              ³" 
DATA "³loss of both circuits             .312                          .52           ³" 
DATA "³NOTES: 1)above data are for repair of failed component not for replacement.   ³" 
DATA "³       2)% of total breakers to fail while opening is 9.                      ³" 
DATA "³                                                                              ³" 
DATA "????????????????????????????????????????????????????????????????????????????????" 
RESTORE cardscreen 
FOR row = 1 TO 23 
LOCATE row, 1 
READ tmp$ 
PRINT tmp$ 
NEXT 
LOCATE 24, 1 
PRINT "press any key to exit" 
DO 
LOOP WHILE INKEY$ = "" 
END IF 
SUB aa 
INPUT "power source from electric utility: failure per year"; fpyu 
INPUT "power source from electric utility: hours of downtime per failure"; hpfu 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main + feeder): failure per year"; fpycbl 
INPUT "l.v. circuit breakers (main + feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = fpyu * hpfu 
k2 = fpypr * hpfpr 
k3 = fpycbm * hpfcbm 
k4 = fpysbm * hpfsbm 
k5 = fpycm * locm * hpfcm / 1000 
k6 = fpyctm * qctm * hpfctm 
k7 = fpyds * hpfds 
k8 = fpytr * hpftr 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k1 + k2 + k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds + fpytr + 
fpycbl + fpysbl + (fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year for the utility (power source) = "; k1 
PRINT "forced hours of downtime/year for the protective relays ="; k2 
PRINT "forced hours of downtime/year for the m.v. circuit breakers = "; k3 
PRINT "forced hours of downtime/year for the m.v. insulated bus = "; k4 
PRINT "forced hours of downtime/year for the m.v. cables = "; k5 
PRINT "forced hours of downtime/year for the cable terminations = "; k6 
PRINT "forced hours of downtime/year for the disconnect switch = "; k7 
PRINT "forced hours of downtime/year for the power transfo. = "; k8 
PRINT "forced hours of downtime/year for the l.v. c.b. (main + feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
IF rec = 1 THEN 
PRINT "minimum revenue requirement, $/year"; inter2 
PRINT "failure rate per year = "; tfpy 
END IF 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END SUB 
SUB bb 
INPUT "switchover type: enter 1 for delayed and 2 for automatic transfer scheme:"; som 
IF som = 1 THEN 
INPUT "power source from electric utility: for loss of single circuit, failure per year"; fpyu1 
INPUT "power source from electric utility: for loss of double circuit, failure per year"; fpyu2 
INPUT "power source from electric utility: for loss of double circuit hours of downtime per failure"; 
hpfu2 
INPUT "power source from electric utility: switchover time in minutes from source 1 to 2"; so12 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main + feeder): failure per year"; fpycbl 
INPUT "l.v. circuit breakers (main + feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = (fpyu1 ­ fpyu2 + fpypr + fpycbm) * (so12 / 60) 
k2 = fpyu2 * hpfu2 
k3 = k1 + k2 
k4 = fpysbm * hpfsbm 
k5 = fpycm * locm * hpfcm / 1000 
k6 = fpyctm * qctm * hpfctm 
k7 = fpyds * hpfds 
k8 = fpytr * hpftr 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu1 ­ fpyu2 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds + 
fpytr + fpycbl + fpysbl + (fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year up to the load side of m.v. c.bs. = "; k3 + k4 
PRINT "forced hours of downtime/year for the m.v. insulated bus = "; k4 
PRINT "forced hours of downtime/year for the m.v. cables = "; k5 
PRINT "forced hours of downtime/year for the cable terminations = "; k6 
PRINT "forced hours of downtime/year for the disconnect switch = "; k7 
PRINT "forced hours of downtime/year for the power transfo. = "; k8 
PRINT "forced hours of downtime/year for the l.v. c.b. (main + feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
IF rec = 1 THEN 
PRINT "minimum revenue requirement, $/year"; inter2 
PRINT "failure rate per year = "; tfpy 
END IF 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END IF 
IF som = 2 THEN 
INPUT "power source from electric utility: for loss of single circuit, failure per year"; fpyu1 
INPUT "power source from electric utility: for loss of double circuit, failure per year"; fpyu2 
INPUT "power source from electric utility: for loss of double circuit hours of downtime per failure"; 
hpfu2 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main + feeder): failure per year"; fpycbl 
INPUT "l.v. circuit breakers (main + feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = (fpyu1 ­ fpyu2 + fpypr + fpycbm) * (so12 / 60) 
k2 = fpyu2 * hpfu2 
k3 = k1 + k2 
k4 = fpysbm * hpfsbm 
k5 = fpycm * locm * hpfcm / 1000 
k6 = fpyctm * qctm * hpfctm 
k7 = fpyds * hpfds 
k8 = fpytr * hpftr 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu2 + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds + fpytr + fpycbl + fpysbl + 
(fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year up to the load side of m.v. c.bs. = "; k3 + k4 
PRINT "forced hours of downtime/year for the m.v. insulated bus = "; k4 
PRINT "forced hours of downtime/year for the m.v. cables = "; k5 
PRINT "forced hours of downtime/year for the cable terminations = "; k6 
PRINT "forced hours of downtime/year for the disconnect switch = "; k7 
PRINT "forced hours of downtime/year for the power transfo. = "; k8 
PRINT "forced hours of downtime/year for the l.v. c.b. (main + feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
IF rec = 1 THEN 
PRINT "minimum revenue requirement, $/year"; inter2 
PRINT "failure rate per year = "; tfpy 
END IF 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END IF 
END SUB 
SUB cc 
INPUT "switchover type: enter 1 for delayed and 2 for automatic transfer scheme:"; som 
IF som = 1 THEN 
INPUT "power source from electric utility: for loss of single circuit, failure per year"; fpyu1 
INPUT "power source from electric utility: for loss of double circuit, failure per year"; fpyu2 
INPUT "power source from electric utility: for loss of double circuit hours of downtime per failure"; 
hpfu2 
INPUT "power source from electric utility: switchover time in minutes from source 1 to 2"; so12 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main + feeder): failure per year"; fpycbl 
INPUT "l.v. circuit breakers (main + feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = ((fpyu1 ­ fpyu2) * (so12 / 60)) + (fpyu2 * hpfu2) 
k2 = fpypr * hpfpr 
k3 = fpycbm * hpfcbm 
k4 = fpysbm * hpfsbm 
k5 = fpycm * locm * hpfcm / 1000 
k6 = fpyctm * qctm * hpfctm 
k7 = fpyds * hpfds 
k8 = fpytr * hpftr 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k1 + k2 + k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu1 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds + fpytr + 
fpycbl + fpysbl + (fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year for the utility (power source) = "; k1 
PRINT "forced hours of downtime/year for the protective relays ="; k2 
PRINT "forced hours of downtime/year for the m.v. circuit breakers = "; k3 
PRINT "forced hours of downtime/year for the m.v. insulated bus = "; k4 
PRINT "forced hours of downtime/year for the m.v. cables = "; k5 
PRINT "forced hours of downtime/year for the cable terminations = "; k6 
PRINT "forced hours of downtime/year for the disconnect switch = "; k7 
PRINT "forced hours of downtime/year for the power transfo. = "; k8 
PRINT "forced hours of downtime/year for the l.v. c.b. (main + feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
IF rec = 1 THEN 
PRINT "minimum revenue requirement, $/year"; inter2 
PRINT "failure rate per year = "; tfpy 
END IF 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END IF 
IF som = 2 THEN 
INPUT "power source from electric utility: for loss of single circuit, failure per year"; fpyu1 
INPUT "power source from electric utility: for loss of double circuit, failure per year"; fpyu2 
INPUT "power source from electric utility: for loss of double circuit hours of downtime per failure"; 
hpfu2 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main + feeder): failure per year"; fpycbl 
INPUT "l.v. circuit breakers (main + feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = ((fpyu1 ­ fpyu2) * (so12 / 60)) + (fpyu2 * hpfu2) 
k2 = fpypr * hpfpr 
k3 = fpycbm * hpfcbm 
k4 = fpysbm * hpfsbm 
k5 = fpycm * locm * hpfcm / 1000 
k6 = fpyctm * qctm * hpfctm 
k7 = fpyds * hpfds 
k8 = fpytr * hpftr 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k1 + k2 + k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu2 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds + fpytr + 
fpycbl + fpysbl + (fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year for the utility (power source) = "; k1 
PRINT "forced hours of downtime/year for the protective relays ="; k2 
PRINT "forced hours of downtime/year for the m.v. circuit breakers = "; k3 
PRINT "forced hours of downtime/year for the m.v. insulated bus = "; k4 
PRINT "forced hours of downtime/year for the m.v. cables = "; k5 
PRINT "forced hours of downtime/year for the cable terminations = "; k6 
PRINT "forced hours of downtime/year for the disconnect switch = "; k7 
PRINT "forced hours of downtime/year for the power transfo. = "; k8 
PRINT "forced hours of downtime/year for the l.v. c.b. (main + feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
IF rec = 1 THEN 
PRINT "minimum revenue requirement, $/year"; inter2 
PRINT "failure rate per year = "; tfpy 
END IF 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END IF 
END SUB 
SUB dd 
INPUT "power source from electric utility: for loss of single circuit, failure per year"; fpyu1 
INPUT "power source from electric utility: for loss of double circuit, failure per year"; fpyu2 
INPUT "power source from electric utility: for loss of double circuit hours of downtime per failure"; 
hpfu2 
INPUT "power source from electric utility: switchover time in minutes from source 1 to 2"; so12 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main + feeder): failure per year"; fpycbl 
INPUT "l.v. circuit breakers (main + feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = (fpyu1 ­ fpyu2 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds) * 
(so12 / 60) 
k2 = fpyu2 * hpfu2 
k3 = k1 + k2 
k8 = fpytr * hpftr 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k1 + k2 + k8 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu1 ­ fpyu2 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds + 
fpytr + fpycbl + fpysbl + (fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year up to the primary of the power transfo. = "; k3 
PRINT "forced hours of downtime/year for the loss of both power sources ="; k2 
PRINT "forced hours of downtime/year for the power transfo. = "; k8 
PRINT "forced hours of downtime/year for the l.v. c.b. (main + feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END SUB 
SUB ee 
INPUT "switchover type: enter 1 for delayed and 2 for automatic transfer scheme:"; som 
IF som = 1 THEN 
INPUT "power source from electric utility: for loss of single circuit, failure per year"; fpyu1 
INPUT "power source from electric utility: for loss of double circuit, failure per year"; fpyu2 
INPUT "power source from electric utility: for loss of double circuit hours of downtime per failure"; 
hpfu2 
INPUT "power source from electric utility: switchover time in minutes from source 1 to 2"; so12 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main) : failure per year"; fpycbl1 
INPUT "l.v. circuit breakers (main): hours of downtime per failure"; hpfcbl1 
INPUT "l.v. circuit breakers (feeder) : failure per year"; fpycbl 
INPUT "l.v. circuit breakers (feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = (fpyu1 ­ fpyu2 + fpytr + fpycbl1 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * 
qctm) + fpyds) * (so12 / 60) 
k2 = fpyu2 * hpfu2 
k3 = k1 + k2 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k1 + k2 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu1 ­ fpyu2 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * qctm) + fpyds + 
fpytr + fpycbl + fpycbl1 + fpysbl + (fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year up to the l.v. swgr bus = "; k3 
PRINT "forced hours of downtime/year for loss of both power sources ="; k2 
PRINT "forced hours of downtime/year for the l.v. c.b. (feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
IF rec = 1 THEN 
PRINT "minimum revenue requirement, $/year"; inter2 
PRINT "failure rate per year = "; tfpy 
END IF 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END IF 
IF som = 2 THEN 
INPUT "power source from electric utility: for loss of single circuit, failure per year"; fpyu1 
INPUT "power source from electric utility: for loss of double circuit, failure per year"; fpyu2 
INPUT "power source from electric utility: for loss of double circuit hours of downtime per failure"; 
hpfu2 
INPUT "protective relays: failure per year"; fpypr 
INPUT "protective relays: hours of downtime per failure"; hpfpr 
INPUT "metal clad circuit breakers (m.v.): failure per year"; fpycbm 
INPUT "metal clad circuit breakers (m.v.): hours of downtime per failure"; hpfcbm 
INPUT "switchgear bus­insulated: failure per year"; fpysbm 
INPUT "switchgear bus­insulated: hours of downtime per failure"; hpfsbm 
INPUT "m.v. cable: failure per year/1000 ft"; fpycm 
INPUT "m.v. cable: distance in ft"; locm 
INPUT "m.v. cable: hours of downtime per failure"; hpfcm 
INPUT "cable termination: failure per year"; fpyctm 
INPUT "cable termination: quantity"; qctm 
INPUT "cable termination: hours of downtime per failure"; hpfctm 
INPUT "disconnect switch: failure per year"; fpyds 
INPUT "disconnect switch: hours of downtime per failure"; hpfds 
INPUT "power transfo.: failure per year"; fpytr 
INPUT "power transfo.: hours of downtime per failure"; hpftr 
INPUT "l.v. circuit breakers (main) : failure per year"; fpycbl1 
INPUT "l.v. circuit breakers (main): hours of downtime per failure"; hpfcbl1 
INPUT "l.v. circuit breakers (feeder) : failure per year"; fpycbl 
INPUT "l.v. circuit breakers (feeder): hours of downtime per failure"; hpfcbl 
INPUT "switchgear bus­bare: failure per year"; fpysbl 
INPUT "switchgear bus­bare: hours of downtime per failure"; hpfsbl 
INPUT "l.v. cable: failure per year/1000 ft"; fpycl 
INPUT "l.v. cable: distance in ft"; locl 
INPUT "l.v. cable: hours of downtime per failure"; hpfcl 
INPUT "cable termination (l.v.): failure per year"; fpyctl 
INPUT "cable termination (l.v.): quantity"; qctl 
INPUT "cable termination (l.v.): hours of downtime per failure"; hpfctl 
INPUT "a factor to include for l.v. breakers failure while opening, enter 1 if to be included in the 
calculations: "; cbof 
IF cbof = 1 THEN 
INPUT "quantity of breakers = "; cbofq 
INPUT "percent of breakers failure while opening in % = "; cbofp 
INPUT "circuit breakers: failure per year"; cboffpy 
INPUT "circuit breakers: hours of downtime per failure"; cbofhpf 
END IF 
k1 = (fpyu1 ­ fpyu2 + fpytr + fpycbl1 + fpypr + fpycbm + fpysbm + (fpycm * locm / 1000) + (fpyctm * 
qctm) + fpyds) * (so12 / 60) 
k2 = fpyu2 * hpfu2 
k3 = k1 + k2 
k9 = fpycbl * hpfcbl 
k10 = fpysbl * hpfsbl 
k11 = fpycl * locl * hpfcl / 1000 
k12 = fpyctl * qctl * hpfctl 
k13 = cbofq * cbofp * cboffpy * cbofhpf 
k = k1 + k2 + k9 + k10 + k11 + k12 + k13 
INPUT "if reliability economics calculation is required, enter 1"; rec 
IF rec = 1 THEN 
INPUT " plant start­up time, hours/failure"; pst 
INPUT "revenues lost per hour of plant downtime, $/h"; rl 
INPUT "variable expenses saved, $/h"; ves 
INPUT "variable expenses incurred/failure"; vei 
INPUT "total investment in electrical plant in $"; ti 
INPUT "fixed investment charges, $/year"; fic 
tfpy = fpyu2 + fpycbl1 + fpysbl + (fpycl * locl / 1000) + (fpyctl * qctl) + (cbofq * cbofp * cboffpy) 
inter = (((k / tfpy) + pst) * (rl ­ ves)) + vei 
inter1 = inter * tfpy 
inter2 = (ti * fic) + inter1 
END IF 
PRINT "forced hours of downtime/year up to the l.v. swgr bus = "; k3 
PRINT "forced hours of downtime/year for loss of both power sources ="; k2 
PRINT "forced hours of downtime/year for the l.v. c.b. (feeder) = "; k9 
PRINT "forced hours of downtime/year for the l.v. bare bus = "; k10 
PRINT "forced hours of downtime/year for the l.v. cables = "; k11 
PRINT "forced hours of downtime/year for the l.v. cable terminations = "; k12 
PRINT "forced hours of downtime/year for the breakers failing on opening = "; k13 
PRINT "forced hours of downtime/year for the above system = "; k 
IF rec = 1 THEN 
PRINT "minimum revenue requirement, $/year"; inter2 
PRINT "failure rate per year = "; tfpy 
END IF 
INPUT "Project Name: ", projnam$ 
INPUT "Project Number: ", projnum$ 
INPUT "prepared by:", pb$ 
INPUT "date:", da$ 
INPUT "feeder no.: ", feedno$ 
INPUT "type of system:", busno$ 
INPUT "comments:", comment$ 
INPUT "type of fault", typef$ 
INPUT "if you want to append file enter 2 or overwrite it enter 1, your choice: ", opap 
IF opap = 1 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR OUTPUT AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
IF opap = 2 THEN 
INPUT "filename to save this file under: ", filename$ 
OPEN filename$ FOR APPEND AS #1 
PRINT #1, "Project Name:"; projnam$, "Prepared By: "; pb$ 
PRINT #1, "Project Number:"; projnum$, "Date: "; da$ 
PRINT #1, "feeder no.: ", feedno$ 
PRINT #1, "type of system:", busno$ 
PRINT #1, "comments:", comment$ 
PRINT #1, "forced hours of downtime/year"; k 
IF rec = 1 THEN 
PRINT #1, "minimum revenue requirement, $/year = "; inter2 
PRINT #1, "failure rate per year = "; tfpy 
END IF 
CLOSE #1 
END IF 
END IF 
END SUB 
SUB ff 
PRINT "this module is not included in the program" 
END SUB

contents

Appendix B
The following program is written in HTML/Javascript, it is for the fundamental power systems analysis 
& calculations. It runs under Netscape Communicator, Firefox, Seamonkey, Epiphany, Flock or 
Microsoft Explorer. It can be put on a server and accessed through the Internet. The calculations 
included in this program are: Wye­delta conversion & vice versa, the equivalent of a few parallel 
branches, matrix manipulation (2 by 2 & 3 by 3), simultaneous equations solution using triangular 
factorization method, per unit calculations for certain configurations, Z­bus modeling & Y­ bus 
modeling.

<!doctype html public "­//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http­equiv="Content­Type" content="text/html; charset=iso­8859­1">
   <meta name="Author" content="Hany Kheir">
   <meta name="GENERATOR" content="Mozilla/4.7 [en] (Win98; I) [Netscape]">
   <title>How to use off the shelf software packages to perform power systems 
analysis</title>
</head>
<body>
<center><b>Appendix B</center></b>
The following program is written in HTML/Javascript, it is for the fundamental 
power systems analysis & calculations. It runs under Netscape Communicator & 
Microsoft Explorer. It can be put on a server and accessed through the Internet. 
The calculations included in this program are: Wye­delta conversion & vice versa, 
the equivalent of a few parallel branches, matrix manipulation (2 by 2 & 3 by 3), 
simultaneous equations solution using triangular factorization method, per unit 
calculations for certain configurations, Z­bus modeling & Y­ bus modeling.  

<br>Note: to view the source code, either use the browser menu or save the file and 
then open it in any text editor program, like Wordpad for instance.

<HTML>
<HEAD>
   <META HTTP­EQUIV="Content­Type" CONTENT="text/html; charset=iso­8859­1">
   <META NAME="Author" CONTENT="Hany Kheir">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.01 [en] (Win95; I) [Netscape]">
   <TITLE>Fundamental Calculations</TITLE>
</HEAD>
<BODY>
<script language="javascript">
<!­­
function wyedelta () {
x=parseFloat(this.document.forms[0].text0.value);
y=parseFloat(this.document.forms[0].elements["text1"].value);
z=parseFloat(this.document.forms[0].elements[2].value);
a=(x*y/z)+x+y;
b=(y*z/x)+y+z;
c=(x*z/y)+x+z;
this.document.forms[0].text3.value=a;
this.document.forms[0].text4.value=b;
this.document.forms[0].text5.value=c; }

function deltawye () {
x=parseFloat(this.document.forms[0].text6.value);
y=parseFloat(this.document.forms[0].elements["text7"].value);
z=parseFloat(this.document.forms[0].elements[9].value);
a=(x*z)/(x+y+z);
b=(x*y)/(x+y+z);
c=(y*z)/(x+y+z);
this.document.forms[0].text9.value=a;
this.document.forms[0].text10.value=b;
this.document.forms[0].text11.value=c; }

function parallel(){
a=this.document.forms[0].tnope.value;
if (a==2){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
aa=((1/b)+(1/c));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
if (a==3){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
d=parseFloat(this.document.forms[0].par2.value);
aa=((1/b)+(1/c)+(1/d));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
if (a==4){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
d=parseFloat(this.document.forms[0].par2.value);
e=parseFloat(this.document.forms[0].par3.value);
aa=((1/b)+(1/c)+(1/d)+(1/e));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
if (a==5){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
d=parseFloat(this.document.forms[0].par2.value);
e=parseFloat(this.document.forms[0].par3.value);
f=parseFloat(this.document.forms[0].par4.value);
aa=((1/b)+(1/c)+(1/d)+(1/e)+(1/f));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
if (a==6){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
d=parseFloat(this.document.forms[0].par2.value);
e=parseFloat(this.document.forms[0].par3.value);
f=parseFloat(this.document.forms[0].par4.value);
g=parseFloat(this.document.forms[0].par5.value);
aa=((1/b)+(1/c)+(1/d)+(1/e)+(1/f)+(1/g));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
if (a==7){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
d=parseFloat(this.document.forms[0].par2.value);
e=parseFloat(this.document.forms[0].par3.value);
f=parseFloat(this.document.forms[0].par4.value);
g=parseFloat(this.document.forms[0].par5.value);
h=parseFloat(this.document.forms[0].par6.value);
aa=((1/b)+(1/c)+(1/d)+(1/e)+(1/f)+(1/g)+(1/h));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
if (a==8){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
d=parseFloat(this.document.forms[0].par2.value);
e=parseFloat(this.document.forms[0].par3.value);
f=parseFloat(this.document.forms[0].par4.value);
g=parseFloat(this.document.forms[0].par5.value);
h=parseFloat(this.document.forms[0].par6.value);
i=parseFloat(this.document.forms[0].par7.value);
aa=((1/b)+(1/c)+(1/d)+(1/e)+(1/f)+(1/g)+(1/h)+(1/i));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
if (a==9){
b=parseFloat(this.document.forms[0].par0.value);
c=parseFloat(this.document.forms[0].par1.value);
d=parseFloat(this.document.forms[0].par2.value);
e=parseFloat(this.document.forms[0].par3.value);
f=parseFloat(this.document.forms[0].par4.value);
g=parseFloat(this.document.forms[0].par5.value);
h=parseFloat(this.document.forms[0].par6.value);
i=parseFloat(this.document.forms[0].par7.value);
j=parseFloat(this.document.forms[0].par8.value);
aa=((1/b)+(1/c)+(1/d)+(1/e)+(1/f)+(1/g)+(1/h)+(1/i)+(1/j));
res=1/aa;
this.document.forms[0].pres0.value=a;
this.document.forms[0].pres1.value=res}
}
function matrix() {
a=this.document.forms[0].noroc.value;
if (a==2){
a11=parseFloat(this.document.forms[0].mat0.value);
a12=parseFloat(this.document.forms[0].mat1.value);
a21=parseFloat(this.document.forms[0].mat3.value);
a22=parseFloat(this.document.forms[0].mat4.value);
this.document.forms[0].mat2.value=0;
this.document.forms[0].mat5.value=0;
this.document.forms[0].mat6.value=0;
this.document.forms[0].mat7.value=0;
this.document.forms[0].mat8.value=0;
det = (a11*a22)­(a12*a21) ;
b11 = a22/det ;
b12 = ­a12/det  ;
b21 = ­a21/det  ;
b22 = a11/det ;
this.document.forms[0].mat9.value=b11;
this.document.forms[0].mat10.value=b12;
this.document.forms[0].mat12.value=b21;
this.document.forms[0].mat13.value=b22;
this.document.forms[0].mat11.value=0;
this.document.forms[0].mat14.value=0;
this.document.forms[0].mat15.value=0;
this.document.forms[0].mat16.value=0;
this.document.forms[0].mat17.value=0;
}
if (a==3){
a11=parseFloat(this.document.forms[0].mat0.value);
a12=parseFloat(this.document.forms[0].mat1.value);
a13=parseFloat(this.document.forms[0].mat2.value);
a21=parseFloat(this.document.forms[0].mat3.value);
a22=parseFloat(this.document.forms[0].mat4.value);
a23=parseFloat(this.document.forms[0].mat5.value);
a31=parseFloat(this.document.forms[0].mat6.value);
a32=parseFloat(this.document.forms[0].mat7.value);
a33=parseFloat(this.document.forms[0].mat8.value);
det = (a11*(a22*a33­a32*a23))­(a12*(a21*a33­a23*a31))+(a13*(a21*a32­a22*a31)) ;
b11 = (a22*a33­a23*a32)/det   ;
b12 = ­(a12*a33­a13*a32)/det  ;
b13 = (a12*a23­a13*a22)/det   ;
b21 = ­(a21*a33­a31*a23)/det  ;
b22 = (a11*a33­a13*a31)/det   ;
b23 = ­(a11*a23­a13*a21)/det  ;
b31 = (a21*a32­a31*a22)/det   ;
b32 = ­(a11*a32­a12*a31)/det  ;
b33 = (a11*a22­a21*a12)/det   ;
this.document.forms[0].mat9.value=b11;
this.document.forms[0].mat10.value=b12;
this.document.forms[0].mat11.value=b13;
this.document.forms[0].mat12.value=b21;
this.document.forms[0].mat13.value=b22;
this.document.forms[0].mat14.value=b23;
this.document.forms[0].mat15.value=b31;
this.document.forms[0].mat16.value=b32;
this.document.forms[0].mat17.value=b33;}
}
function simultaneous() {
a=this.document.forms[0].sen.value;
if (a==4){
a11=parseFloat(this.document.forms[0].sim0.value);
a12=parseFloat(this.document.forms[0].sim1.value);
a13=parseFloat(this.document.forms[0].sim2.value);
a14=parseFloat(this.document.forms[0].sim3.value);
a21=parseFloat(this.document.forms[0].sim5.value);
a22=parseFloat(this.document.forms[0].sim6.value);
a23=parseFloat(this.document.forms[0].sim7.value);
a24=parseFloat(this.document.forms[0].sim8.value);
a31=parseFloat(this.document.forms[0].sim10.value);
a32=parseFloat(this.document.forms[0].sim11.value);
a33=parseFloat(this.document.forms[0].sim12.value);
a34=parseFloat(this.document.forms[0].sim13.value);
a41=parseFloat(this.document.forms[0].sim15.value);
a42=parseFloat(this.document.forms[0].sim16.value);
a43=parseFloat(this.document.forms[0].sim17.value);
a44=parseFloat(this.document.forms[0].sim18.value);
m1=parseFloat(this.document.forms[0].rhs0.value);
m2=parseFloat(this.document.forms[0].rhs1.value);
m3=parseFloat(this.document.forms[0].rhs2.value);
m4=parseFloat(this.document.forms[0].rhs3.value);
y110 = a11 / a11 ;
y120 = a12 / a11 ;
y130 = a13 / a11 ;
y140 = a14 / a11 ;
y220 = a22 ­ (a21) * (a12) / (a11) ;
y230 = a23 ­ (a21) * (a13) / (a11) ;
y240 = a24 ­ (a21) * (a14) / a11   ;
y320 = a32 ­ (a31) * (a12) / a11   ;
y330 = a33 ­ (a31) * (a13) / a11   ;
y340 = a34 ­ (a31) * (a14) / a11   ;
y420 = a42 ­ (a41) * (a12) / a11   ;
y430 = a43 ­ (a41) * (a13) / a11   ;
y440 = a44 ­ (a41) * (a14) / a11   ;
y221 = y220 / y220  ;
y231 = y230 / y220  ;
y241 = y240 / y220  ;
y331 = y330 ­ (y320) * (y230) / y220  ;
y341 = y340 ­ (y320) * (y240) / y220  ;
y431 = y430 ­ (y420) * (y230) / y220  ;
y441 = y440 ­ (y420) * (y240) / y220  ;
y332 = y331 / y331  ;
y342 = y341 / y331  ;
y442 = y441 ­ (y431) * (y341) / y331 ;
v1 = m1 / a11 ;
v2 = (m2 ­ (v1) * (a21)) / y220   ;
v3 = (m3 ­ (v1) * (a31) ­ (y320) * (v2)) / y331    ;
v4 = (m4 ­ (v1) * (a41) ­ (y420) * (v2) ­ (v3) * (y431)) / y442  ;
f4 = v4  ;
f3 = (v3 ­ ((y342) * (f4)))  ;
f2 = (v2 ­ ((y231) * (f3)) ­ ((y241) * (f4)))  ;
f1 = (v1 ­ ((y120) * (f2)) ­ ((y130) * (f3)) ­ ((y140) * (f4)));
this.document.forms[0].sres0.value=f1;
this.document.forms[0].sres1.value=f2;
this.document.forms[0].sres2.value=f3;
this.document.forms[0].sres3.value=f4;
}
if (a==5){
a11=parseFloat(this.document.forms[0].sim0.value);
a12=parseFloat(this.document.forms[0].sim1.value);
a13=parseFloat(this.document.forms[0].sim2.value);
a14=parseFloat(this.document.forms[0].sim3.value);
a15=parseFloat(this.document.forms[0].sim4.value);
a21=parseFloat(this.document.forms[0].sim5.value);
a22=parseFloat(this.document.forms[0].sim6.value);
a23=parseFloat(this.document.forms[0].sim7.value);
a24=parseFloat(this.document.forms[0].sim8.value);
a25=parseFloat(this.document.forms[0].sim9.value);
a31=parseFloat(this.document.forms[0].sim10.value);
a32=parseFloat(this.document.forms[0].sim11.value);
a33=parseFloat(this.document.forms[0].sim12.value);
a34=parseFloat(this.document.forms[0].sim13.value);
a35=parseFloat(this.document.forms[0].sim14.value);
a41=parseFloat(this.document.forms[0].sim15.value);
a42=parseFloat(this.document.forms[0].sim16.value);
a43=parseFloat(this.document.forms[0].sim17.value);
a44=parseFloat(this.document.forms[0].sim18.value);
a45=parseFloat(this.document.forms[0].sim19.value);
a51=parseFloat(this.document.forms[0].sim20.value);
a52=parseFloat(this.document.forms[0].sim21.value);
a53=parseFloat(this.document.forms[0].sim22.value);
a54=parseFloat(this.document.forms[0].sim23.value);
a55=parseFloat(this.document.forms[0].sim24.value);
m1=parseFloat(this.document.forms[0].rhs0.value);
m2=parseFloat(this.document.forms[0].rhs1.value);
m3=parseFloat(this.document.forms[0].rhs2.value);
m4=parseFloat(this.document.forms[0].rhs3.value);
m5=parseFloat(this.document.forms[0].rhs4.value);
y110 = a11 / a11 ;
y120 = a12 / a11  ;
y130 = a13 / a11  ;
y140 = a14 / a11  ;
y150 = a15 / a11  ;
y220 = a22 ­ (a21) * (a12) / (a11) ;
y230 = a23 ­ (a21) * (a13) / (a11) ;
y240 = a24 ­ (a21) * (a14) / a11  ;
y250 = a25 ­ (a21) * (a15) / a11  ;
y320 = a32 ­ (a31) * (a12) / a11  ;
y330 = a33 ­ (a31) * (a13) / a11  ;
y340 = a34 ­ (a31) * (a14) / a11  ;
y350 = a35 ­ (a31) * (a15) / a11  ;
y420 = a42 ­ (a41) * (a12) / a11  ;
y430 = a43 ­ (a41) * (a13) / a11  ;
y440 = a44 ­ (a41) * (a14) / a11  ;
y450 = a45 ­ (a41) * (a15) / a11  ;
y520 = a52 ­ (a51) * (a12) / a11  ;
y530 = a53 ­ (a51) * (a13) / a11  ;
y540 = a54 ­ (a51) * (a14) / a11  ;
y550 = a55 ­ (a51) * (a15) / a11  ;
y221 = y220 / y220  ;
y231 = y230 / y220  ;
y241 = y240 / y220  ;
y251 = y250 / y220  ;
y331 = y330 ­ (y320) * (y230) / y220  ;
y341 = y340 ­ (y320) * (y240) / y220  ;
y351 = y350 ­ (y320) * (y250) / y220  ;
y431 = y430 ­ (y420) * (y230) / y220  ;
y441 = y440 ­ (y420) * (y240) / y220  ;
y451 = y450 ­ (y420) * (y250) / y220  ;
y531 = y530 ­ (y520) * (y230) / y220  ;
y541 = y540 ­ (y520) * (y240) / y220  ;
y551 = y550 ­ (y520) * (y250) / y220  ;
y332 = y331 / y331  ;
y342 = y341 / y331  ;
y352 = y351 / y331  ;
y442 = y441 ­ (y431) * (y341) / y331  ;
y452 = y451 ­ (y431) * (y351) / y331  ;
y542 = y541 ­ (y531) * (y341) / y331  ;
y552 = y551 ­ (y531) * (y351) / y331  ;
y443 = y442 / y442  ;
y453 = y452 / y442  ;
y553 = y552 ­ (y542) * (y452) / y442  ;
v1 = m1 / a11 ;
v2 = (m2 ­ (v1) * (a21)) / y220   ;
v3 = (m3 ­ (v1) * (a31) ­ (y320) * (v2)) / y331    ;
v4 = (m4 ­ (v1) * (a41) ­ (y420) * (v2) ­ (v3) * (y431)) / y442  ;
v5 = (m5 ­ (v1) * (a51) ­ (y520) * (v2) ­ (v3) * (y531) ­ (v4) * (y542)) / y553;
f5 = v5 ;
f4 = (v4 ­ ((y453) * (f5))) ;
f3 = (v3 ­ ((y342) * (f4)) ­ ((y352) * (f5)))  ;
f2 = (v2 ­ ((y231) * (f3)) ­ ((y241) * (f4)) ­ ((y251) * (f5)))  ;
f1 = (v1 ­ ((y120) * (f2)) ­ ((y130) * (f3)) ­ ((y140) * (f4)) ­ ((y150) * (f5)));
this.document.forms[0].sres0.value=f1;
this.document.forms[0].sres1.value=f2;
this.document.forms[0].sres2.value=f3;
this.document.forms[0].sres3.value=f4;
this.document.forms[0].sres4.value=f5;
}
}
function pu1() {
z1=parseFloat(this.document.forms[0].perunit0.value);
z2=parseFloat(this.document.forms[0].perunit1.value);
prim1=parseFloat(this.document.forms[0].perunit2.value);
sec1=parseFloat(this.document.forms[0].perunit3.value);
mva1=parseFloat(this.document.forms[0].perunit4.value);
reactl1=parseFloat(this.document.forms[0].perunit7.value);
reactl2=parseFloat(this.document.forms[0].perunit8.value);
reactl3=parseFloat(this.document.forms[0].perunit9.value);
reactl4=parseFloat(this.document.forms[0].perunit10.value);
react1=parseFloat(this.document.forms[0].perunit6.value);
bv = parseFloat(this.document.forms[0].perunit22.value);
pf = parseFloat(this.document.forms[0].perunit21.value);
mw =parseFloat(this.document.forms[0].perunit20.value);
lreact1=parseFloat(this.document.forms[0].perunit11.value);
lmva1=parseFloat(this.document.forms[0].perunit12.value);
lkv1=parseFloat(this.document.forms[0].perunit13.value);
lreact2=parseFloat(this.document.forms[0].perunit14.value);
lmva2=parseFloat(this.document.forms[0].perunit15.value);
lkv2=parseFloat(this.document.forms[0].perunit16.value);
lreact3=parseFloat(this.document.forms[0].perunit17.value);
lmva3=parseFloat(this.document.forms[0].perunit18.value);
lkv3=parseFloat(this.document.forms[0].perunit19.value);
ib=z2*1000/(z1*1.7320508);
vb1 = z1 * sec1 / (prim1);
ib1 = (z2 * 1000) / (vb1 * 1.7320508);
reactpu1 = react1 * (z2 / mva1) * ((prim1 / z1) * (prim1 / z1) );
reactlpu = (reactl1) * (z2) / ((vb1) * (vb1));
reaclpu1 = (reactl2) * (z2) / ((vb1) * (vb1));
reaclpu2 = (reactl3) * (z2) / ((vb1) * (vb1));
reaclpu3 = (reactl4) * (z2) / ((vb1) * (vb1));
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) * (lkv1/vb1));
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) * (lkv2/vb1));
load3pu = lreact3 * (z2 / lmva3) * ((lkv3 / vb1) * (lkv3/vb1));
puvfll= bv / vb1;
pucfll=(mw * (1000) / (1.732 * bv * pf)) / ib1;
this.document.forms[0].peres0.value=ib;
this.document.forms[0].peres1.value=vb1;
this.document.forms[0].peres2.value=ib1;
this.document.forms[0].peres3.value=reactpu1;
this.document.forms[0].peres4.value=reactlpu;
this.document.forms[0].peres5.value=reaclpu1;
this.document.forms[0].peres6.value=reaclpu2;
this.document.forms[0].peres7.value=reaclpu3;
this.document.forms[0].peres8.value=load1pu;
this.document.forms[0].peres9.value=load2pu;
this.document.forms[0].peres10.value=load3pu;
this.document.forms[0].peres11.value=puvfll;
this.document.forms[0].peres12.value=pucfll;
}

function pu2() {
a1=parseFloat(this.document.forms[0].perunit23.value);
a2=parseFloat(this.document.forms[0].perunit24.value);
prim1=parseFloat(this.document.forms[0].perunit25.value);
sec1=parseFloat(this.document.forms[0].perunit26.value);
mva1=parseFloat(this.document.forms[0].perunit27.value);
react1=parseFloat(this.document.forms[0].perunit28.value);
prim2=parseFloat(this.document.forms[0].perunit29.value);
sec2=parseFloat(this.document.forms[0].perunit30.value);
mva2=parseFloat(this.document.forms[0].perunit31.value);
react2=parseFloat(this.document.forms[0].perunit32.value);
reactl1=parseFloat(this.document.forms[0].perunit33.value);
lreact1=parseFloat(this.document.forms[0].perunit34.value);
lmva1=parseFloat(this.document.forms[0].perunit35.value);
lkv1=parseFloat(this.document.forms[0].perunit36.value);
lreact2=parseFloat(this.document.forms[0].perunit37.value);
lmva2=parseFloat(this.document.forms[0].perunit38.value);
lkv2=parseFloat(this.document.forms[0].perunit39.value);
lreact3=parseFloat(this.document.forms[0].perunit40.value);
lmva3=parseFloat(this.document.forms[0].perunit41.value);
lkv3=parseFloat(this.document.forms[0].perunit42.value);
mw =parseFloat(this.document.forms[0].perunit43.value);
pf = parseFloat(this.document.forms[0].perunit44.value);
bv = parseFloat(this.document.forms[0].perunit45.value);
vb1 = a1 * sec1 / (prim1);
vb2 = vb1 * sec2 / (prim2);
ib1 = (a2 * 1000) / (vb1 * 1.7320508);
ib2 = (a2 * 1000) / (vb2 * 1.7320508);
reactlpu = (reactl1) * (a2) / ((vb1) * (vb1));
load1pu = lreact1 * (a2 / lmva1) * ((lkv1 / vb2) * (lkv1 / vb2));
load2pu = lreact2 * (a2 / lmva2) * ((lkv2 / vb2) * (lkv2 / vb2));
load3pu = lreact3 * (a2 / lmva3) * ((lkv3 / vb2) * (lkv3 / vb2));
reactpu1 = react1 * (a2 / mva1) * ((prim1 / a1) * (prim1 / a1));
reactpu2 = react2 * (a2 / mva2) * ((prim2 / vb1) * (prim2 / vb1));
puvfll=bv / vb2; 
pucfll=(mw * (1000) / (1.732 * bv * pf)) / ib2;
this.document.forms[0].peres13.value=ib1;
this.document.forms[0].peres14.value=vb1;
this.document.forms[0].peres15.value=ib2;
this.document.forms[0].peres16.value=vb2;
this.document.forms[0].peres17.value=reactlpu;
this.document.forms[0].peres18.value=reactpu1;
this.document.forms[0].peres19.value=reactpu2;
this.document.forms[0].peres20.value=load1pu;
this.document.forms[0].peres21.value=load2pu;
this.document.forms[0].peres22.value=load3pu;
this.document.forms[0].peres23.value=puvfll;
this.document.forms[0].peres24.value=pucfll;
}

function pu4(){   
b1=parseFloat(this.document.forms[0].perunit46.value);
b2=parseFloat(this.document.forms[0].perunit47.value);
prim1=parseFloat(this.document.forms[0].perunit48.value);
sec1=parseFloat(this.document.forms[0].perunit49.value);
mva1=parseFloat(this.document.forms[0].perunit50.value);
react1=parseFloat(this.document.forms[0].perunit51.value);
prim2=parseFloat(this.document.forms[0].perunit52.value);
sec2=parseFloat(this.document.forms[0].perunit53.value);
mva2=parseFloat(this.document.forms[0].perunit54.value);
react2=parseFloat(this.document.forms[0].perunit55.value);
prim3=parseFloat(this.document.forms[0].perunit56.value);
sec3=parseFloat(this.document.forms[0].perunit57.value);
mva3=parseFloat(this.document.forms[0].perunit58.value);
react3=parseFloat(this.document.forms[0].perunit59.value);
prim4=parseFloat(this.document.forms[0].perunit60.value);
sec4=parseFloat(this.document.forms[0].perunit61.value);
mva4=parseFloat(this.document.forms[0].perunit62.value);
react4=parseFloat(this.document.forms[0].perunit63.value);
reactl1=parseFloat(this.document.forms[0].perunit64.value);
reactl2=parseFloat(this.document.forms[0].perunit65.value);
lreact1=parseFloat(this.document.forms[0].perunit66.value);
lmva1=parseFloat(this.document.forms[0].perunit67.value);
lkv1=parseFloat(this.document.forms[0].perunit68.value);
lreact2=parseFloat(this.document.forms[0].perunit69.value);
lmva2=parseFloat(this.document.forms[0].perunit70.value);
lkv2=parseFloat(this.document.forms[0].perunit71.value);
lreact3=parseFloat(this.document.forms[0].perunit72.value);
lmva3=parseFloat(this.document.forms[0].perunit73.value);
lkv3=parseFloat(this.document.forms[0].perunit74.value);
mw =parseFloat(this.document.forms[0].perunit75.value);
pf = parseFloat(this.document.forms[0].perunit76.value);
bv = parseFloat(this.document.forms[0].perunit77.value);
lreact11=parseFloat(this.document.forms[0].perunit78.value);
lmva11=parseFloat(this.document.forms[0].perunit79.value);
lkv11=parseFloat(this.document.forms[0].perunit80.value);
lreact21=parseFloat(this.document.forms[0].perunit81.value);
lmva21=parseFloat(this.document.forms[0].perunit82.value);
lkv21=parseFloat(this.document.forms[0].perunit83.value);
lreact31=parseFloat(this.document.forms[0].perunit84.value);
lmva31=parseFloat(this.document.forms[0].perunit85.value);
lkv31=parseFloat(this.document.forms[0].perunit86.value);
mw1 =parseFloat(this.document.forms[0].perunit87.value);
pf1 = parseFloat(this.document.forms[0].perunit88.value);
bv1 = parseFloat(this.document.forms[0].perunit89.value);
vb1 = b1 * sec1 / (prim1);
ib1 = (b2 * 1000) / (vb1 * 1.7320508);
vb2 = vb1 * sec2 / (prim2);
ib2 = (b2 * 1000) / (vb2 * 1.7320508);
vb3 = vb2 * sec3 / (prim3);
ib3 = (b2 * 1000) / (vb3 * 1.7320508);
vb4 = vb3 * sec4 / (prim4);
ib4 = (b2 * 1000) / (vb4 * 1.7320508);
reactlpu = (reactl1) * (b2) / ((vb1) * (vb1));
reaclpu2 = (reactl2) * (b2) / ((vb3) * (vb3));
reacpu11 = react1 * (b2 / mva1) * ((prim1 / b1) *(prim1 / b1));
reacpu21 = react2 * (b2 / mva2) * ((prim2 / vb1) *(prim2 / vb1));
reacpu31 = react3 * (b2 / mva3) * ((prim3 / vb2) *(prim3 / vb2));
reacpu41 = react4 * (b2 / mva4) * ((prim4 / vb3) *(prim4 / vb3));
load1pu = lreact1 * (b2 / lmva1) * ((lkv1 / vb2) *(lkv1 / vb2));
load2pu = lreact2 * (b2 / lmva2) * ((lkv2 / vb2) *(lkv2 / vb2));
load3pu = lreact3 * (b2 / lmva3) * ((lkv3 / vb2) *(lkv3 / vb2));
puvfll2= bv / vb2;
pucfll2= (mw * (1000) / (1.732 * bv * pf)) / ib2;
load1pu1 = lreact11 * (b2 / lmva11) * ((lkv11 / vb4) *(lkv11 / vb4));
load2pu1 = lreact21 * (b2 / lmva21) * ((lkv21 / vb4) *(lkv21 / vb4));
load3pu1 = lreact31 * (b2 / lmva31) * ((lkv31 / vb4) *(lkv31 / vb4));
puvfll4= bv1 / vb4; 
pucfll4=(mw1 * (1000) / (1.732 * bv1 * pf1)) / ib4;
this.document.forms[0].peres25.value=ib1;
this.document.forms[0].peres26.value=vb1;
this.document.forms[0].peres27.value=ib2;
this.document.forms[0].peres28.value=vb2;
this.document.forms[0].peres29.value=ib3;
this.document.forms[0].peres30.value=vb3;
this.document.forms[0].peres31.value=ib4;
this.document.forms[0].peres32.value=vb4;
this.document.forms[0].peres33.value=reactlpu;
this.document.forms[0].peres34.value=reaclpu2;
this.document.forms[0].peres35.value=reacpu11;
this.document.forms[0].peres36.value=reacpu21;
this.document.forms[0].peres37.value=reacpu31;
this.document.forms[0].peres38.value=reacpu41;
this.document.forms[0].peres39.value=load1pu;
this.document.forms[0].peres40.value=load2pu;
this.document.forms[0].peres41.value=load3pu;
this.document.forms[0].peres42.value=puvfll2;
this.document.forms[0].peres43.value=pucfll2;
this.document.forms[0].peres44.value=load1pu1;
this.document.forms[0].peres45.value=load2pu1;
this.document.forms[0].peres46.value=load3pu1;
this.document.forms[0].peres47.value=puvfll4;
this.document.forms[0].peres48.value=pucfll4;
}

function zybus0() {
x01=parseFloat(this.document.forms[0].zbus0.value);
x02=parseFloat(this.document.forms[0].zbus1.value);
x03=parseFloat(this.document.forms[0].zbus2.value);
xx12=parseFloat(this.document.forms[0].zbus3.value);
xx23=parseFloat(this.document.forms[0].zbus4.value);
xx34=parseFloat(this.document.forms[0].zbus5.value);
xx42=parseFloat(this.document.forms[0].zbus6.value);
xx41=parseFloat(this.document.forms[0].zbus7.value);
x11 = x01;
x12 = x11;
x21 = x12;
x22 = x01 + xx12;

if (x02>0) {
x11p = x11;
x12p = x12;
x21p = x21;
x22p = x22;
xp1 = x21;
xp2 = x22;
xpp = x02 + x22;
x1p = x12;
x2p = x22;
x111 = x11p ­ ((x1p) * (xp1) / (xpp));
x121 = x12p ­ ((x1p) * (xp2) / (xpp));
x211 = x21p ­ ((x2p) * (xp1) / (xpp));
x221 = x22p ­ ((x2p) * (xp2) / (xpp));
x131 = x121;
x231 = x221;
x311 = x211;
x321 = x221;
x331 = x221 + xx23;
x11b = x111;
x12b = x121;
x13b = x131;
x21b = x211;
x22b = x221;
x23b = x231;
x31b = x311;
x32b = x321;
x33b = x331;}

if (x02==0) {
x31 = x21;
x32 = x22;
x33 = xx23 + x22;
x13 = x12;
x23 = x22;
x11b = x11;
x12b = x12;
x13b = x13;
x21b = x21;
x22b = x22;
x23b = x23;
x31b = x31;
x32b = x32;
x33b = x33;}

if ((xx42>0) && (x03>0)) {
x11p1 = x11b;
x12p1 = x12b;
x13p1 = x13b;
x21p1 = x21b;
x22p1 = x22b;
x23p1 = x23b;
x31p1 = x31b;
x32p1 = x32b;
x33p1 = x33b;
xp12 = x31b;
xp22 = x32b;
xp32 = x33b;
xpp1 = x03 + x33b;
x1p2 = x13b;
x2p2 = x23b;
x3p2 = x33b;
x112 = x11p1 ­ ((x1p2) * (xp12) / (xpp1));
x122 = x12p1 ­ ((x1p2) * (xp22) / (xpp1));
x132 = x13p1 ­ ((x1p2) * (xp32) / (xpp1));
x212 = x21p1 ­ ((x2p2) * (xp12) / (xpp1));
x222 = x22p1 ­ ((x2p2) * (xp22) / (xpp1));
x232 = x23p1 ­ ((x2p2) * (xp32) / (xpp1));
x312 = x31p1 ­ ((x3p2) * (xp12) / (xpp1));
x322 = x32p1 ­ ((x3p2) * (xp22) / (xpp1));
x332 = x33p1 ­ ((x3p2) * (xp32) / (xpp1));
x142 = x132;
x242 = x232;
x342 = x332;
x412 = x312;
x422 = x322;
x432 = x332;
x442 = x332 + xx34;
x1p3 = x122 ­ x142;
x2p3 = x222 ­ x242;
x3p3 = x322 ­ x342;
x4p3 = x422 ­ x442;
xp13 = x1p3;
xp23 = x2p3;
xp33 = x3p3;
xp43 = x4p3;
xpp3 = x222 + x442 ­ 2 * (x242) + xx42;
x11f = x112 ­ (x1p3) * (xp13) / (xpp3);
x12f = x122 ­ (x1p3) * (xp23) / (xpp3);
x13f = x132 ­ (x1p3) * (xp33) / (xpp3);
x14f = x142 ­ (x1p3) * (xp43) / (xpp3);
x21f = x212 ­ (x2p3) * (xp13) / (xpp3);
x22f = x222 ­ (x2p3) * (xp23) / (xpp3);
x23f = x232 ­ (x2p3) * (xp33) / (xpp3);
x24f = x242 ­ (x2p3) * (xp43) / (xpp3);
x31f = x312 ­ (x3p3) * (xp13) / (xpp3);
x32f = x322 ­ (x3p3) * (xp23) / (xpp3);
x33f = x332 ­ (x3p3) * (xp33) / (xpp3);
x34f = x342 ­ (x3p3) * (xp43) / (xpp3);
x41f = x412 ­ (x4p3) * (xp13) / (xpp3);
x42f = x422 ­ (x4p3) * (xp23) / (xpp3);
x43f = x432 ­ (x4p3) * (xp33) / (xpp3);
x44f = x442 ­ (x4p3) * (xp43) / (xpp3);}

if ((xx42>0) && (x03==0)) {
x11d = x11;
x12d = x12;
x13d = x13;
x14d = x13;
x21d = x21;
x22d = x22;
x23d = x23;
x24d = x23;
x31d = x31;
x32d = x32;
x33d = x33;
x34d = x33;
x41d = x31;
x42d = x32;
x43d = x33;
x44d = x33 + xx34;
x1p3 = x12d ­ x14d;
x2p3 = x22d ­ x24d;
x3p3 = x32d ­ x34d;
x4p3 = x42d ­ x44d;
xp13 = x1p3;
xp23 = x2p3;
xp33 = x3p3;
xp43 = x4p3;
xpp3 = x22d + x44d ­ 2 * (x24d) + xx42;
x11f = x11d ­ (x1p3) * (xp13) / (xpp3);
x12f = x12d ­ (x1p3) * (xp23) / (xpp3);
x13f = x13d ­ (x1p3) * (xp33) / (xpp3);
x14f = x14d ­ (x1p3) * (xp43) / (xpp3);
x21f = x21d ­ (x2p3) * (xp13) / (xpp3);
x22f = x22d ­ (x2p3) * (xp23) / (xpp3);
x23f = x23d ­ (x2p3) * (xp33) / (xpp3);
x24f = x24d ­ (x2p3) * (xp43) / (xpp3);
x31f = x31d ­ (x3p3) * (xp13) / (xpp3);
x32f = x32d ­ (x3p3) * (xp23) / (xpp3);
x33f = x33d ­ (x3p3) * (xp33) / (xpp3);
x34f = x34d ­ (x3p3) * (xp43) / (xpp3);
x41f = x41d ­ (x4p3) * (xp13) / (xpp3);
x42f = x42d ­ (x4p3) * (xp23) / (xpp3);
x43f = x43d ­ (x4p3) * (xp33) / (xpp3);
x44f = x44d ­ (x4p3) * (xp43) / (xpp3);}

if (xx41>0) {
x1p4 = x11f ­ x14f;
x2p4 = x21f ­ x24f;
x3p4 = x31f ­ x34f;
x4p4 = x41f ­ x44f;
xp14 = x1p4;
xp24 = x2p4;
xp34 = x3p4;
xp44 = x4p4;
xpp4 = x11f + x44f ­ 2 * (x14f) + xx41;
x11f1 = x11f ­ (x1p4) * (xp14) / (xpp4);
x12f1 = x12f ­ (x1p4) * (xp24) / (xpp4);
x13f1 = x13f ­ (x1p4) * (xp34) / (xpp4);
x14f1 = x14f ­ (x1p4) * (xp44) / (xpp4);
x21f1 = x21f ­ (x2p4) * (xp14) / (xpp4);
x22f1 = x22f ­ (x2p4) * (xp24) / (xpp4);
x23f1 = x23f ­ (x2p4) * (xp34) / (xpp4);
x24f1 = x24f ­ (x2p4) * (xp44) / (xpp4);
x31f1 = x31f ­ (x3p4) * (xp14) / (xpp4);
x32f1 = x32f ­ (x3p4) * (xp24) / (xpp4);
x33f1 = x33f ­ (x3p4) * (xp34) / (xpp4);
x34f1 = x34f ­ (x3p4) * (xp44) / (xpp4);
x41f1 = x41f ­ (x4p4) * (xp14) / (xpp4);
x42f1 = x42f ­ (x4p4) * (xp24) / (xpp4);
x43f1 = x43f ­ (x4p4) * (xp34) / (xpp4);
x44f1 = x44f ­ (x4p4) * (xp44) / (xpp4);
this.document.forms[0].zbus8.value=x11f1;
this.document.forms[0].zbus9.value=x12f1;
this.document.forms[0].zbus10.value=x13f1;
this.document.forms[0].zbus11.value=x14f1;
this.document.forms[0].zbus12.value=x21f1;
this.document.forms[0].zbus13.value=x22f1;
this.document.forms[0].zbus14.value=x23f1;
this.document.forms[0].zbus15.value=x24f1;
this.document.forms[0].zbus16.value=x31f1;
this.document.forms[0].zbus17.value=x32f1;
this.document.forms[0].zbus18.value=x33f1;
this.document.forms[0].zbus19.value=x34f1;
this.document.forms[0].zbus20.value=x41f1;
this.document.forms[0].zbus21.value=x42f1;
this.document.forms[0].zbus22.value=x43f1;
this.document.forms[0].zbus23.value=x44f1;}

if (xx41==0)  {
this.document.forms[0].zbus8.value=x11f;
this.document.forms[0].zbus9.value=x12f;
this.document.forms[0].zbus10.value=x13f;
this.document.forms[0].zbus11.value=x14f;
this.document.forms[0].zbus12.value=x21f;
this.document.forms[0].zbus13.value=x22f;
this.document.forms[0].zbus14.value=x23f;
this.document.forms[0].zbus15.value=x24f;
this.document.forms[0].zbus16.value=x31f;
this.document.forms[0].zbus17.value=x32f;
this.document.forms[0].zbus18.value=x33f;
this.document.forms[0].zbus19.value=x34f;
this.document.forms[0].zbus20.value=x41f;
this.document.forms[0].zbus21.value=x42f;
this.document.forms[0].zbus22.value=x43f;
this.document.forms[0].zbus23.value=x44f;}
}

function zybus1() {
r12=parseFloat(this.document.forms[0].rbus0.value);
x12=parseFloat(this.document.forms[0].xbus0.value);
r13=parseFloat(this.document.forms[0].rbus1.value);
x13=parseFloat(this.document.forms[0].xbus1.value);
r24=parseFloat(this.document.forms[0].rbus2.value);
x24=parseFloat(this.document.forms[0].xbus2.value);
r34=parseFloat(this.document.forms[0].rbus3.value);
x34=parseFloat(this.document.forms[0].xbus3.value);

z12 = Math.sqrt ((r12 * r12) + (x12 * x12)) 
z13 = Math.sqrt ((r13 * r13) + (x13 * x13)) 
z24 = Math.sqrt ((r24 * r24) + (x24 * x24)) 
z34 = Math.sqrt ((r34 * r34) + (x34 * x34))
an12 = Math.atan(x12 / r12)
an13 = Math.atan(x13 / r13)
an24 = Math.atan(x24 / r24)
an34 = Math.atan(x34 / r34)
y12 = 1 / z12
y13 = 1 / z13
y24 = 1 / z24
y34 = 1 / z34
g12 = y12 * Math.cos(­an12)
g13 = y13 * Math.cos(­an13)
g24 = y24 * Math.cos(­an24)
g34 = y34 * Math.cos(­an34)
b12 = y12 * Math.sin(­an12)
b13 = y13 * Math.sin(­an13)
b24 = y24 * Math.sin(­an24)
b34 = y34 * Math.sin(­an34)
gb11 = g12 + g13
gb22 = g24 + g12
gb33 = g34 + g13
gb44 = g34 + g24
gb12 = ­g12
gb21 = ­g12
gb13 = ­g13
gb31 = ­g13
gb24 = ­g24
gb42 = ­g24
gb34 = ­g34
gb43 = ­g34
bb11 = b12 + b13
bb22 = b24 + b12
bb33 = b34 + b13
bb44 = b34 + b24
bb12 = ­b12
bb21 = ­b12
bb13 = ­b13
bb31 = ­b13
bb24 = ­b24
bb42 = ­b24
bb34 = ­b34
bb43 = ­b34
gb14=bb14=0;
gb41=bb41=0;
gb23=bb23=0;
gb32=bb32=0;

this.document.forms[0].gbus0.value=gb11;
this.document.forms[0].gbus1.value=gb12;
this.document.forms[0].gbus2.value=gb13;
this.document.forms[0].gbus3.value=gb14;
this.document.forms[0].gbus4.value=gb21;
this.document.forms[0].gbus5.value=gb22;
this.document.forms[0].gbus6.value=gb23;
this.document.forms[0].gbus7.value=gb24;
this.document.forms[0].gbus8.value=gb31;
this.document.forms[0].gbus9.value=gb32;
this.document.forms[0].gbus10.value=gb33;
this.document.forms[0].gbus11.value=gb34;
this.document.forms[0].gbus12.value=gb41;
this.document.forms[0].gbus13.value=gb42;
this.document.forms[0].gbus14.value=gb43;
this.document.forms[0].gbus15.value=gb44;
this.document.forms[0].bbus0.value=bb11;
this.document.forms[0].bbus1.value=bb12;
this.document.forms[0].bbus2.value=bb13;
this.document.forms[0].bbus3.value=bb14;
this.document.forms[0].bbus4.value=bb21;
this.document.forms[0].bbus5.value=bb22;
this.document.forms[0].bbus6.value=bb23;
this.document.forms[0].bbus7.value=bb24;
this.document.forms[0].bbus8.value=bb31;
this.document.forms[0].bbus9.value=bb32;
this.document.forms[0].bbus10.value=bb33;
this.document.forms[0].bbus11.value=bb34;
this.document.forms[0].bbus12.value=bb41;
this.document.forms[0].bbus13.value=bb42;
this.document.forms[0].bbus14.value=bb43;
this.document.forms[0].bbus15.value=bb44;
}

//­­></script>
<CENTER><B><U><FONT COLOR="#000066"><FONT SIZE=+2>The Power Systems Analysis
Tools</FONT></FONT></U></B></CENTER>

<CENTER><B><U><FONT COLOR="#000066"><FONT SIZE=+2></FONT></FONT></U></B></CENTER>

<CENTER><a href="epdmis00.htm" onmouseover="window.status='click to go to the 
EPDMIS page';return true" onmouseout="window.status='';return true"><IMG 
SRC="epdmis01.gif" alt="click to go to EPDMIS page" HEIGHT=124 
WIDTH=336></a></CENTER>

<CENTER><IMG SRC="fabcalc.gif" HEIGHT=62 WIDTH=319></CENTER>
&nbsp;
<TABLE BORDER COLS=6 WIDTH="100%" >
<TR>
<TD BGCOLOR="#CCCCCC"><a href="#wyedelta">Wye/Delta conversion and vice 
versa.</a></TD>

<TD BGCOLOR="#FF6666"><a href="#parallel">The equivalent of&nbsp; few parallel 
branches.</a></TD>

<TD BGCOLOR="#FFCC33"><a href="#matrix">Matrix manipulation (2 by 2 &amp; 3 x 
3).</a></TD>

<TD BGCOLOR="#FFFF99"><a href="#simultaneous">Simultaneous equations 
solution.</a></TD>

<TD BGCOLOR="#66FFFF"><a href="#perunit">Per unit calc. for 1,2,4 &amp; 6 
Transformers</a></TD>

<TD BGCOLOR="#FF99FF"><a href="#zybus">Z­bus and Y­bus calculations.</TD>
</TR>
</TABLE>

&nbsp;
<form>
<UL>
<LI>
<a name="wyedelta">Wye to Delta and vice versa transformation:</a><br>
<u>Wye to delta:</u><br>Element 1­n:<input name = "text0" size=11 type="text" 
value="X,R or Z1­n">Element 2­n:<input name = "text1" type="text" size=11 
value="X,R or Z2­n">Element 3­n:<input name = "text2" type="text" size=11 
value="X,R or Z3­n"><br>
<img src="wyedelta.gif"> 
<input type="button" value="click to obtain the results" onclick="wyedelta()"><br>
<b><i>The values of the elements of the equivalent DELTA:<br>
Element 1­2:<input name = "text3" size=11 type="text" value="">Element 2­3:<input 
name = "text4" type="text" size=11 value="">Element 1­3:<input name = "text5" 
type="text" size=11 value=""></b></i><br>

<u>Delta to wye:</u><br>Element 1­2:<input name = "text6" size=11 type="text" 
value="X,R or Z1­2">Element 2­3:<input name = "text7" type="text" size=11 
value="X,R or Z2­3">Element 3­1:<input name = "text8" type="text" size=11 
value="X,R or Z3­1"><br>
<input type="button" value="click to obtain the results" onclick="deltawye()"><br>
<b><i>The values of the elements of the equivalent Wye:<br>
Element 1­n:<input name = "text9" size=11 type="text" value="">Element 2­n:<input 
name = "text10" type="text" size=11 value="">Element 3­n:<input name = "text11" 
type="text" size=11 value=""></b></i><br>
<hr size=1 width="50%"><br>
</LI>
<li><a name="parallel">The equivalent of a few parallel branches (resistance or 
reactance elements):</a><br>
The Total Number of the parallel elements<input name="tnope" size=5 type="text" 
value="2"<br>

<br>First element:<input name = "par0" size=11 type="text" value="1">Second 
element:<input name = "par1" type="text" size=11 value="1">Third element:<input 
name = "par2" type="text" size=11 value="1"><br>
Fourth element:<input name = "par3" size=11 type="text" value="1">Fifth 
element:<input name = "par4" type="text" size=11 value="1">Sixth element:<input 
name = "par5" type="text" size=11 value="1"><br>
Seventh element:<input name = "par6" size=11 type="text" value="1">Eighth 
element:<input name = "par7" type="text" size=11 value="1">Nineth element:<input 
name = "par8" type="text" size=9 value="1"><br>
<input type="button" value="click to obtain the result" onclick="parallel()"><br>
The equivalent of the<input name = "pres0" size=3 type="text" 
value="">elements:<input name = "pres1" type="text" size=11 value="1"><br>
<hr size=1 width="50%"><br>

</li>
<li><a name="matrix">The inversion of a matrix (2 by 2 & 3 by 3):</a><br>
The Number of rows or columns in the square matrix, enter 2 or 3:<input 
name="noroc" size=3 type="text" value="2"<br>
<br>a11 (for 2x2 or 3x3):<input name = "mat0" size=7 type="text" value="1">a12 (for 
2x2 or 3x3):<input name = "mat1" type="text" size=7 value="1">a13 (for 3x3 
only):<input name = "mat2" type="text" size=7 value="1"><br>
<br>a21 (for 2x2 or 3x3):<input name = "mat3" size=7 type="text" value="1">a22 (for 
2x2 or 3x3):<input name = "mat4" type="text" size=7 value="1">a13 (for 3x3 
only):<input name = "mat5" type="text" size=7 value="1"><br>
<br>a31 (for 3x3 only):<input name = "mat6" size=7 type="text" value="1">a32 (for 
3x3 only):<input name = "mat7" type="text" size=7 value="1">a33 (for 3x3 
only):<input name = "mat8" type="text" size=7 value="1"><br>

<input type="button" value="click to obtain the inverted matrix" 
onclick="matrix()"><br>
<br>a11 (for 2x2 or 3x3):<input name = "mat9" size=7 type="text" value="1">a12 (for 
2x2 or 3x3):<input name = "mat10" type="text" size=7 value="1">a13 (for 3x3 
only):<input name = "mat11" type="text" size=7 value="1"><br>
<br>a21 (for 2x2 or 3x3):<input name = "mat12" size=7 type="text" value="1">a22 
(for 2x2 or 3x3):<input name = "mat13" type="text" size=7 value="1">a13 (for 3x3 
only):<input name = "mat14" type="text" size=7 value="1"><br>
<br>a31 (for 3x3 only):<input name = "mat15" size=7 type="text" value="1">a32 (for 
3x3 only):<input name = "mat16" type="text" size=7 value="1">a33 (for 3x3 
only):<input name = "mat17" type="text" size=7 value="1"><br>
<hr size=1 width="50%"><br>
</li>
<li><a name="simultaneous">Simultaneous equations solution (4 or 5 
equations):</a><br>

The Number of equations, enter 4 or 5:<input name="sen" size=3 type="text" 
value="4"<br>
<br>a11:<input name = "sim0" size=5 type="text" value="1">a12:<input name = "sim1" 
type="text" size=5 value="1">a13:<input name = "sim2" type="text" size=5 value="1">
a14:<input name = "sim3" size=5 type="text" value="1">a15 (for 5 eq. only):<input 
name = "sim4" type="text" size=7 value="1"><br>
a21:<input name = "sim5" size=5 type="text" value="1">a22:<input name = "sim6" 
type="text" size=5 value="1">a23:<input name = "sim7" type="text" size=5 value="1">
a24:<input name = "sim8" size=5 type="text" value="1">a25 (for 5 eq. only):<input 
name = "sim9" type="text" size=7 value="1"><br>
a31:<input name = "sim10" size=5 type="text" value="1">a32:<input name = "sim11" 
type="text" size=5 value="1">a33:<input name = "sim12" type="text" size=5 
value="1">

a34:<input name = "sim13" size=5 type="text" value="1">a35 (for 5 eq. only):<input 
name = "sim14" type="text" size=7 value="1"><br>
a41:<input name = "sim15" size=5 type="text" value="1">a42:<input name = "sim16" 
type="text" size=5 value="1">a43:<input name = "sim17" type="text" size=5 
value="1">
a44:<input name = "sim18" size=5 type="text" value="1">a45 (for 5 eq. only):<input 
name = "sim19" type="text" size=7 value="1"><br>
a51:<input name = "sim20" size=5 type="text" value="1">a52:<input name = "sim21" 
type="text" size=5 value="1">a53:<input name = "sim22" type="text" size=5 
value="1">
a54:<input name = "sim23" size=5 type="text" value="1">a55 (for 5 eq. only):<input 
name = "sim24" type="text" size=7 value="1"><br>

Right hand side of eq.1:<input name = "rhs0" size=5 type="text" value="1">R.H.S. of 
eq. 2:<input name = "rhs1" type="text" size=5 value="1">R.H.S of eq. 3:<input name 
= "rhs2" type="text" size=5 value="1"><br>
R.H.S. of 4:<input name = "rhs3" size=5 type="text" value="1">R.H.S. of 5 (for 5 
eq. only):<input name = "rhs4" type="text" size=7 value="1"><br>
<input type="button" value="click to obtain the solution" 
onclick="simultaneous()"><br>
X1:<input name = "sres0" size=5 type="text" value="1">X2:<input name = "sres1" 
type="text" size=5 value="1">X3:<input name = "sres2" type="text" size=5 value="1">
X4:<input name = "sres3" size=5 type="text" value="1">X5 (for 5 eq. only):<input 
name = "sres4" type="text" size=7 value="1"><br>
<hr size=1 width="100%"><br>
</li>

<li><a name="perunit">Per unit calculation (1,2,4 or 6 transformers):</a><br>
<p><b>*** One transformer</b></p>Base voltage,KV,at primary of the 
transformer:<input name = "perunit0" size=5 type="text" value="220">Base MVA of the 
system:<input name = "perunit1" type="text" size=5 value="100">
Primary volt. in KV of the transformer:<input name = "perunit2" size=5 type="text" 
value="220">Secondary volt. of transformer in KV:<input name = "perunit3" 
type="text" size=5 value="25"><br>
MVA of the transf.:<input name = "perunit4" size=5 type="text" value="100"># of 
buses on sec. of trannsfo. including the sec. bus:<input name = "perunit5" 
type="text" size=5 value="5"><br>
Per unit reactance of the transformer :<input name = "perunit6" size=5 type="text" 
value=".1">Line reactance in ohms bet. bus 1 & 2:<input name = "perunit7" 
type="text" size=5 value="50"><br>
Line reactance in ohms bet. bus 2 & 3:<input name = "perunit8" size=5 type="text" 
value="50">Line reactance in ohms bet. bus 3 & 4:<input name = "perunit9" 
type="text" size=5 value="50"><br>

Line reactance in ohms bet. bus 4 & 5:<input name = "perunit10" type="text" size=5 
value="50"><br>
Load 1 reactance in pu, if present:<input name = "perunit11" type="text" size=5 
value=".25">Load 1 MVA rating, if present:<input name = "perunit12" type="text" 
size=5 value="5"><br>
Load 1 volt. rating in KV, if present:<input name = "perunit13" type="text" size=5 
value="25">Load 2 reactance in pu, if present:<input name = "perunit14" type="text" 
size=5 value=".25"><br>
Load 2 MVA rating, if present:<input name = "perunit15" type="text" size=5 
value="25">Load 2 KV rating, if present:<input name = "perunit16" type="text" 
size=5 value="25"><br>
Load 3 reactance in pu, if present:<input name = "perunit17" type="text" size=5 
value=".25">Load 3 MVA rating, if present:<input name = "perunit18" type="text" 
size=5 value="25"><br>
Load 3 KV rating, if present:<input name = "perunit19" type="text" size=5 
value="25">Heating & lighting load MW, if available:<input name = "perunit20" 
type="text" size=5 value="1"><br>

Power factor of heating & lighting loads:<input name = "perunit21" type="text" 
size=5 value=".95">Bus voltage in KV:<input name = "perunit22" type="text" size=5 
value="5"><br>
<p align=center><u>ALL LOADS ARE ASSUMED TO BE CONNECTED TO BUS 1 (THE SECONDARY OF 
THE TRANSFORMER)</u></p>
<input type="button" value="click to obtain the solution" onclick="pu1()"><br>
Base current on prim. of transfo. in Amps.:<input name = "peres0" size=5 
type="text" value="1">Base volt. on the sec. of transfo.:<input name = "peres1" 
type="text" size=5 value="1"><br>
Base current on transfo. sec.:<input name = "peres2" type="text" size=5 
value="1">Transfo. pu reactance<input name = "peres3" size=5 type="text" 
value="1"><br>
Line 1 reactance pu:<input name = "peres4" type="text" size=7 value="1">Line 2 
react. pu:<input name = "peres5" type="text" size=7 value="1"><br>
Line 3 reactance pu:<input name = "peres6" type="text" size=7 value="1">Line 4 
react. pu:<input name = "peres7" type="text" size=7 value="1"><br>

Load 1 reactance pu:<input name = "peres8" type="text" size=7 value="1">Load 2 
react. pu:<input name = "peres9" type="text" size=7 value="1"><br>
Load 3 reactance pu:<input name = "peres10" type="text" size=7 value="1">Lighting 
load volt in pu:<input name = "peres11" type="text" size=7 value="1"><br>
Lighting load current in pu:<input name = "peres12" type="text" size=7 
value="1"><br>
<hr size=1 width="50%"><br>

<p><b>*** Two transformers</b></p>Base voltage,KV,at primary of the 
transformer:<input name = "perunit23" size=5 type="text" value="220">Base MVA of 
the system:<input name = "perunit24" type="text" size=5 value="100">
Primary volt. in KV of the 1<sup>st</sup> transfo.:<input name = "perunit25" size=5 
type="text" value="220">Secondary volt. of 1<sup>st</sup> transfo. in KV:<input 
name = "perunit26" type="text" size=5 value="25"><br>

MVA of 1<sup>st</sup> transf.:<input name = "perunit27" size=5 type="text" 
value="100">Per unit reactance of the 1<sup>st</sup> transfo.:<input name = 
"perunit28" type="text" size=5 value="5"><br>
Primary volt. in KV of 2<sup>nd</sup> transformer:<input name = "perunit29" size=5 
type="text" value=".1">Secondary volt. of 2<sup>nd</sup> transfo. in KV:<input name 
= "perunit30" type="text" size=5 value="50"><br>

MVA of 2<sup>nd</sup> transfo.:<input name = "perunit31" size=5 type="text" 
value="100">Per unit reactance of the 2<sup>nd</sup> transfo.:<input name = 
"perunit32" type="text" size=5 value="5"><br>
Line reactance in ohms (bet. sec. of transfo. 1 and prim. of transfo. 2):<input 
name = "perunit33" type="text" size=5 value="50"><br>
Load 1 reactance in pu, if present:<input name = "perunit34" type="text" size=5 
value=".25">Load 1 MVA rating, if present:<input name = "perunit35" type="text" 
size=5 value="5"><br>
Load 1 volt. rating in KV, if present:<input name = "perunit36" type="text" size=5 
value="25">Load 2 reactance in pu, if present:<input name = "perunit37" type="text" 
size=5 value=".25"><br>

Load 2 MVA rating, if present:<input name = "perunit38" type="text" size=5 
value="25">Load 2 KV rating, if present:<input name = "perunit39" type="text" 
size=5 value="25"><br>
Load 3 reactance in pu, if present:<input name = "perunit40" type="text" size=5 
value=".25">Load 3 MVA rating, if present:<input name = "perunit41" type="text" 
size=5 value="25"><br>
Load 3 KV rating, if present:<input name = "perunit42" type="text" size=5 
value="25">Heating & lighting load MW, if available:<input name = "perunit43" 
type="text" size=5 value="1"><br>
Power factor of heating & lighting loads:<input name = "perunit44" type="text" 
size=5 value=".95">Bus voltage in KV:<input name = "perunit45" type="text" size=5 
value="5"><br>
<p align=center><u>ALL LOADS ARE ASSUMED TO BE CONNECTED TO THE SECONDARY OF THE 
FIRST TRANSFORMER</u></p>
<input type="button" value="click to obtain the solution" onclick="pu2()"><br>

Base current on 1<sup>st</sup> transfo. sec. in Amps.:<input name = "peres13" 
size=5 type="text" value="1">Base volt. on sec. of 1<sup>st</sup> transfo.:<input 
name = "peres14" type="text" size=5 value="1"><br>
Base current on 2<sup>nd</sup> transfo. sec.:<input name = "peres15" type="text" 
size=5 value="1">Base volt. on sec. of 2<sup>nd</sup> transfo.:<input name = 
"peres16" size=5 type="text" value="1"><br>

Line reactance in pu:<input name = "peres17" type="text" size=7 value="1"><br>
1<sup>st</sup> transfo. reactance in pu:<input name = "peres18" type="text" size=7 
value="1">2<sup>nd</sup> transfo. reactance in pu:<input name = "peres19" 
type="text" size=7 value="1"><br>
Load 1 reactance pu:<input name = "peres20" type="text" size=7 value="1">Load 2 
react. pu:<input name = "peres21" type="text" size=7 value="1"><br>
Load 3 reactance pu:<input name = "peres22" type="text" size=7 value="1">Lighting 
load volt in pu:<input name = "peres23" type="text" size=7 value="1"><br>

Lighting load current in pu:<input name = "peres24" type="text" size=7 
value="1"><br>
<hr size=1 width="50%"><br>

<p><b>*** Four transformers</b></p>Base voltage,KV,at primary of the 1 
<sup>st</sup> transfo.:<input name = "perunit46" size=5 type="text" 
value="220">Base MVA of the system:<input name = "perunit47" type="text" size=5 
value="100">
Primary volt. in KV of the 1<sup>st</sup> transfo.:<input name = "perunit48" size=5 
type="text" value="220">Secondary volt. of 1<sup>st</sup> transfo. in KV:<input 
name = "perunit49" type="text" size=5 value="25"><br>

MVA of 1<sup>st</sup> transf.:<input name = "perunit50" size=5 type="text" 
value="100">Per unit reactance of the 1<sup>st</sup> transfo.:<input name = 
"perunit51" type="text" size=5 value="5"><br>
Primary volt. in KV of 2<sup>nd</sup> transformer:<input name = "perunit52" size=5 
type="text" value=".1">Secondary volt. of 2<sup>nd</sup> transfo. in KV:<input name 
= "perunit53" type="text" size=5 value="50"><br>

MVA of 2<sup>nd</sup> transfo.:<input name = "perunit54" size=5 type="text" 
value="100">Per unit reactance of the 2<sup>nd</sup> transfo.:<input name = 
"perunit55" type="text" size=5 value="5"><br>
Primary volt. in KV of the 3<sup>rd</sup> transfo.:<input name = "perunit56" size=5 
type="text" value="220">Secondary volt. of 3<sup>rd</sup> transfo. in KV:<input 
name = "perunit57" type="text" size=5 value="25"><br>

MVA of 3<sup>rd</sup> transf.:<input name = "perunit58" size=5 type="text" 
value="100">Per unit reactance of the 3<sup>rd</sup> transfo.:<input name = 
"perunit59" type="text" size=5 value="5"><br>
Primary volt. in KV of 4<sup>th</sup> transformer:<input name = "perunit60" size=5 
type="text" value=".1">Secondary volt. of 4<sup>th</sup> transfo. in KV:<input name 
= "perunit61" type="text" size=5 value="50"><br>

MVA of 4<sup>th</sup> transfo.:<input name = "perunit62" size=5 type="text" 
value="100">Per unit reactance of the 4<sup>th</sup> transfo.:<input name = 
"perunit63" type="text" size=5 value="5"><br>
Reactance of 1<sup>st</sup> line in ohms (bet. sec. of transfo. 1 and prim. of 
transfo. 2):<input name = "perunit64" type="text" size=5 value="50"><br>
Reactance of 2<sup>nd</sup> line in ohms (bet. sec. of transfo. 3 and prim. of 
transfo. 4):<input name = "perunit65" type="text" size=5 value="50"><br>

Load 1 react. @ sec. bus of transfo. 2 in pu:<input name = "perunit66" type="text" 
size=5 value=".25">Load 1 MVA rating:<input name = "perunit67" type="text" size=5 
value="5"><br>
Load 1 volt. rating in KV:<input name = "perunit68" type="text" size=5 
value="25">Load 2 react. @ sec. bus of transfo. 2:<input name = "perunit69" 
type="text" size=5 value=".25"><br>
Load 2 MVA rating:<input name = "perunit70" type="text" size=5 
value="25">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load 2 KV rating:<input name = 
"perunit71" type="text" size=5 value="25"><br>
Load 3 react.@ sec. bus of transfo. 2 in pu:<input name = "perunit72" type="text" 
size=5 value=".25">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load 3 MVA rating:<input 
name = "perunit73" type="text" size=5 value="25"><br>
Load 3 KV rating:<input name = "perunit74" type="text" size=5 value="25">Heating & 
lighting load MW, if available:<input name = "perunit75" type="text" size=5 
value="1"><br>
Power factor of heating & lighting loads:<input name = "perunit76" type="text" 
size=5 value=".95">Bus voltage in KV:<input name = "perunit77" type="text" size=5 
value="5"><br>

Load 1 react. @ sec. bus of transfo. 4 in pu:<input name = "perunit78" type="text" 
size=5 value=".25">Load 1 MVA rating:<input name = "perunit79" type="text" size=5 
value="5"><br>
Load 1 volt. rating in KV:<input name = "perunit80" type="text" size=5 
value="25">Load 2 react. @ sec. bus of transfo. 4:<input name = "perunit81" 
type="text" size=5 value=".25"><br>
Load 2 MVA rating:<input name = "perunit82" type="text" size=5 
value="25">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load 2 KV rating:<input name = 
"perunit83" type="text" size=5 value="25"><br>
Load 3 react.@ sec. bus of transfo. 4 in pu:<input name = "perunit84" type="text" 
size=5 value=".25">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load 3 MVA rating:<input 
name = "perunit85" type="text" size=5 value="25"><br>
Load 3 KV rating:<input name = "perunit86" type="text" size=5 value="25">Heating & 
lighting load MW, if available:<input name = "perunit87" type="text" size=5 
value="1"><br>
Power factor of heating & lighting loads:<input name = "perunit88" type="text" 
size=5 value=".95">Bus voltage in KV:<input name = "perunit89" type="text" size=5 
value="5"><br>

<p align=center><u>LOADS ARE ASSUMED TO BE CONNECTED TO THE SECONDARY OF THE SECOND 
& FOURTH TRANSFORMERS</u></p>
<input type="button" value="click to obtain the solution" onclick="pu4()"><br>
Base current on 1<sup>st</sup> transfo. sec. in Amps.:<input name = "peres25" 
size=5 type="text" value="1">Base volt. on sec. of 1<sup>st</sup> transfo.:<input 
name = "peres26" type="text" size=5 value="1"><br>
Base current on 2<sup>nd</sup> transfo. sec.:<input name = "peres27" type="text" 
size=5 value="1">Base volt. on sec. of 2<sup>nd</sup> transfo.:<input name = 
"peres28" size=5 type="text" value="1"><br>

Base current on 3<sup>rd</sup> transfo. sec. in Amps.:<input name = "peres29" 
size=5 type="text" value="1">Base volt. on sec. of 3<sup>rd</sup> transfo.:<input 
name = "peres30" type="text" size=5 value="1"><br>
Base current on 4<sup>th</sup> transfo. sec.:<input name = "peres31" type="text" 
size=5 value="1">Base volt. on sec. of 4<sup>th</sup> transfo.:<input name = 
"peres32" size=5 type="text" value="1"><br>

Line reactance between sec. of transfo. 1 & prim. of transfo. 2 in pu:<input name = 
"peres33" type="text" size=7 value="1"><br>
Line reactance between sec. of transfo. 3 & prim. of transfo. 4 in pu:<input name = 
"peres34" type="text" size=7 value="1"><br>
1<sup>st</sup> transfo. reactance in pu:<input name = "peres35" type="text" size=7 
value="1">2<sup>nd</sup> transfo. reactance in pu:<input name = "peres36" 
type="text" size=7 value="1"><br>
3<sup>rd</sup> transfo. reactance in pu:<input name = "peres37" type="text" size=7 
value="1">4<sup>th</sup> transfo. reactance in pu:<input name = "peres38" 
type="text" size=7 value="1"><br>

Load 1 react. on sec. of transfo. 2 pu:<input name = "peres39" type="text" size=7 
value="1">Load 2 react. pu:<input name = "peres40" type="text" size=7 
value="1"><br>
Load 3 reactance pu:<input name = "peres41" type="text" size=7 value="1">Lighting 
load volt in pu:<input name = "peres42" type="text" size=7 value="1"><br>
Lighting load current in pu:<input name = "peres43" type="text" size=7 
value="1"><br>
Load 1 react. on sec. of transfo. 4 pu:<input name = "peres44" type="text" size=7 
value="1">Load 2 react. pu:<input name = "peres45" type="text" size=7 
value="1"><br>
Load 3 reactance pu:<input name = "peres46" type="text" size=7 value="1">Lighting 
load volt in pu:<input name = "peres47" type="text" size=7 value="1"><br>
Lighting load current in pu:<input name = "peres48" type="text" size=7 
value="1"><br>
<hr size=1 width="50%"><br>

<p align="center"><b>*** Six transformers: 
</b><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NOT IMPLEMENTED YET</i><br>
<hr size=1 width="100%"><br></p>
</li>
<li><a name="zybus"><p><b>**Z­bus for 4­bus network</b></p>Reactance between node 0 
(reference node) & bus 1 = <input name = "zbus0" type="text" size=5 value="1"><br>
React. between node 0 & bus 2 = <input name = "zbus1" type="text" size=5 
value="1">&nbsp;&nbsp;React. between node 0 & bus 3 = <input name = "zbus2" 
type="text" size=5 value="1"><br>
React. between bus 1 & 2 = <input name = "zbus3" type="text" size=5 
value="1">&nbsp;&nbsp;React. between node 2 & bus 3 = <input name = "zbus4" 
type="text" size=5 value="1"><br>

React. between bus 3 & 4 = <input name = "zbus5" type="text" size=5 
value="1">&nbsp;&nbsp;React. between node 4 & bus 2 = <input name = "zbus6" 
type="text" size=5 value="1"><br>
React. between bus 4 & 1 = <input name = "zbus7" type="text" size=5 value="1"><br>
<input type="button" value="click to get the Z­bus matrix" onclick="zybus0()"><br>
Z11 = <input name = "zbus8" type="text" size=5 value="1">&nbsp;&nbsp;Z12 = <input 
name = "zbus9" type="text" size=5 value="1">&nbsp;&nbsp;Z13 = <input name = 
"zbus10" type="text" size=5 value="1">&nbsp;&nbsp;Z14 = <input name = "zbus11" 
type="text" size=5 value="1"><br>
Z21 = <input name = "zbus12" type="text" size=5 value="1">&nbsp;&nbsp;Z22 = <input 
name = "zbus13" type="text" size=5 value="1">&nbsp;&nbsp;Z23 = <input name = 
"zbus14" type="text" size=5 value="1">&nbsp;&nbsp;Z24 = <input name = "zbus15" 
type="text" size=5 value="1"><br>

Z31 = <input name = "zbus16" type="text" size=5 value="1">&nbsp;&nbsp;Z32 = <input 
name = "zbus17" type="text" size=5 value="1">&nbsp;&nbsp;Z33 = <input name = 
"zbus18" type="text" size=5 value="1">&nbsp;&nbsp;Z34 = <input name = "zbus19" 
type="text" size=5 value="1"><br>
Z41 = <input name = "zbus20" type="text" size=5 value="1">&nbsp;&nbsp;Z42 = <input 
name = "zbus21" type="text" size=5 value="1">&nbsp;&nbsp;Z43 = <input name = 
"zbus22" type="text" size=5 value="1">&nbsp;&nbsp;Z44 = <input name = "zbus23" 
type="text" size=5 value="1"><br>
<hr size=1 width="50%"><br></p>
<p><b>**Y­bus for 4­bus network</b></p>Resistance between bus 1 & 2= <input name = 
"rbus0" type="text" size=5 value="1">Reactance between bus 1 & 2= <input name = 
"xbus0" type="text" size=5 value="1"><br>

Resistance between bus 1 & bus 3 = <input name = "rbus1" type="text" size=5 
value="1">&nbsp;&nbsp;Reactance between bus 1 & 3 = <input name = "xbus1" 
type="text" size=5 value="1"><br>
Resistance between bus 2 & bus 4 = <input name = "rbus2" type="text" size=5 
value="1">&nbsp;&nbsp;Reactance between bus 2 & 4 = <input name = "xbus2" 
type="text" size=5 value="1"><br>
Resistance between bus 3 & bus 4 = <input name = "rbus3" type="text" size=5 
value="1">&nbsp;&nbsp;Reactance between bus 3 & 4 = <input name = "xbus3" 
type="text" size=5 value="1"><br>
<input type="button" value="click to get the Y­bus matrix" onclick="zybus1()"><br>
G11 (conductance) = <input name = "gbus0" type="text" size=5 
value="1">&nbsp;&nbsp;G12 = <input name = "gbus1" type="text" size=5 
value="1">&nbsp;&nbsp;G13 = <input name = "gbus2" type="text" size=5 
value="1">&nbsp;&nbsp;G14 = <input name = "gbus3" type="text" size=5 value="1"><br>

G21 = <input name = "gbus4" type="text" size=5 value="1">&nbsp;&nbsp;G22 = <input 
name = "gbus5" type="text" size=5 value="1">&nbsp;&nbsp;G23 = <input name = "gbus6" 
type="text" size=5 value="1">&nbsp;&nbsp;Z24 = <input name = "gbus7" type="text" 
size=5 value="1"><br>
G31 = <input name = "gbus8" type="text" size=5 value="1">&nbsp;&nbsp;G32 = <input 
name = "gbus9" type="text" size=5 value="1">&nbsp;&nbsp;G33 = <input name = 
"gbus10" type="text" size=5 value="1">&nbsp;&nbsp;Z34 = <input name = "gbus11" 
type="text" size=5 value="1"><br>
G41 = <input name = "gbus12" type="text" size=5 value="1">&nbsp;&nbsp;G42 = <input 
name = "gbus13" type="text" size=5 value="1">&nbsp;&nbsp;G43 = <input name = 
"gbus14" type="text" size=5 value="1">&nbsp;&nbsp;Z44 = <input name = "gbus15" 
type="text" size=5 value="1"><br>
B11 (susceptance) = <input name = "bbus0" type="text" size=5 
value="1">&nbsp;&nbsp;B12 = <input name = "bbus1" type="text" size=5 
value="1">&nbsp;&nbsp;B13 = <input name = "bbus2" type="text" size=5 
value="1">&nbsp;&nbsp;B14 = <input name = "bbus3" type="text" size=5 value="1"><br>

B21 = <input name = "bbus4" type="text" size=5 value="1">&nbsp;&nbsp;B22 = <input 
name = "bbus5" type="text" size=5 value="1">&nbsp;&nbsp;B23 = <input name = "bbus6" 
type="text" size=5 value="1">&nbsp;&nbsp;B24 = <input name = "bbus7" type="text" 
size=5 value="1"><br>
B31 = <input name = "bbus8" type="text" size=5 value="1">&nbsp;&nbsp;B32 = <input 
name = "bbus9" type="text" size=5 value="1">&nbsp;&nbsp;B33 = <input name = 
"bbus10" type="text" size=5 value="1">&nbsp;&nbsp;B34 = <input name = "bbus11" 
type="text" size=5 value="1"><br>
B41 = <input name = "bbus12" type="text" size=5 value="1">&nbsp;&nbsp;B42 = <input 
name = "bbus13" type="text" size=5 value="1">&nbsp;&nbsp;B43 = <input name = 
"bbus14" type="text" size=5 value="1">&nbsp;&nbsp;B44 = <input name = "bbus15" 
type="text" size=5 value="1"><br>
<hr size=2 width="100%"><br></p>
</li>
</UL>
</form>
</BODY>
</HTML>
&nbsp;
</body>
</html>

contents

You might also like