Professional Documents
Culture Documents
Introduction: distribution system automation is built on 5 pillars which are computer programming,
computer aided design & drafting (CADD), system supervisory & data acquisition systems (SCADA),
local networks including LAN & WAN and geographic information systems (GIS) including global
positioning system (GPS) software & receivers. Computer programming can be classified broadly into
system programming & application programming. System programming is mainly concerned with the
programming for the hardware components to get them to function as required i.e. writing drivers and
hardware specific programs & software. Application programming involves writing the appropriate
procedures to get the different computer elements to function in order, accept user input, to perform the
appropriate calculations and to output the results in an easy & understandable fashion to the user. To
program a computer, a computer programming language is used. Programming languages can be
classified into: machine level (native language), low level (assembly language) and high level languages
(eg. Fortran, Pascal, Cobol, Basic, C, C++, Visual Basic & C#). High level languages can be further
classified into procedural or object oriented languages. Another way to classify high level languages is
whether it requires a compiler or not, those languages that do not require a compiler are called script
languages. Examples for script languages are Javascript, Tcl/Tk, perl & VBS. Certain languages (with
or without their integrated development environment IDE) are only available commercially, others are
available free of charge (just to be downloaded through the Internet). Certain languages (with their
compilers) are suitable for cross platform, others have a version for each operating system (platform),
example for operating systems are: Windows, Mac, Linux,..
In this guide, specific tasks to be performed and problems to be solved as part of a power system
analysis process will be identified. The programs that solve for some of these tasks or problems will be
given, written in more than one computer programming language. One example written in gtkmm is
part of the electrical power systems distribution management information system (EPDMIS). To
compile and run GTKMM under Windows, follow the following steps:
1) Download & install MingW.
2) Download & install DevCpp.
3) Download & unzip GTK library under c:\MingW.
4) Download & install gtkmm library under c:\DevCpp.
5) Download & install msys
6) Copy the source code into /home/user_name/ directory of C:\msys.
7) Compile source code, example for command line compiling statements in msys window:
1. export PKG_CONFIG_PATH=c:/DevCpp/gtkmm/pkgconfig
2. g++ 'pkgconfig –cflags gtkmm2.4' example.cc o example 'pkgconfig –libs gtkmm2.4'
8) Run executable (.exe) Windows file
The languages used are: QB, C++, VBA, VB.net, Pascal, SmallEiffel, GTKMM, Perl, TCL/TK, Python
& JS. The basic functions that any programming language must offer are: user interface (interactivity)
i.e. must accept user input at run time, must output results to the screen, must offer the facility that
allows saving data & information to the hard drive (mass storage devices) i.e. saving inputted data &
calculated ones for further referencing or printing, the language should provide means to allow decision
making during program execution based on intermediate/calculated results as well as user
input/response and finally it should allow for looping through the instructions/statements of a program.
Saying Hello in different programming languages:
Pascal:
program hello;
begin
writeln('Hello world from Pascal');
end.
SmallEiffel:
class SIMPLE
creation
make
feature
make is
do
io.put_string("Hello from SmallEiffel.%N");
io.put_new_line
end;
end
Active Perl:
print "Hello from ActivePerl!";
Tcl:
puts stdout {Hello from TCL/TK};
Tk:
#exec wish "$0" $@"
button .hello text "Hello from Tk" command {
puts stdout "Hello from Tk"; destroy .
}
pack .hello
Python:
print "Hello from the Python"
Fundamental calculations in electrical power systems analysis:
The fundamental calculations (i.e. tasks that the computer programs have to perform) can be any of the
following: the calculation of the equivalent of a few series or parallel elements or branches, the
conversion from wye to delta & vice versa, matrix manipulation, simultaneous equations calculations,
per unit calculations, bus modeling and short circuit calculations for simple radial system. The other
calculations involved in power systems analysis i.e. problems that must be solved are: short circuit
calculations for radial (complex and with multiple feeders) and network (grid) systems, load flow
calculations including losses evaluation for radial as well as network systems, reliability analysis,
stability calculations, transients analysis and economical evaluations for the application and
modification of power systems.
Pascal:
Example, calculating the equivalent of a few resistive or reactive parallel branches, converting wye to
delta & vice versa:
program test1 (input,output,fdata);
var choice,noe,q:char;
var el1,el2,el3,el4,el5,result,result0,result1:real;
var fdata:text;
var fname:packed array [1..12] of char;
begin
while (choice<>'q') do
begin
writeln ('enter a for equivalent of parallel elements, b for YtoDelta conversion');
writeln ('enter c for DeltatoY conversion & enter q to exit');
readln(choice);
if choice = 'a' then
begin
writeln('number of elements');
readln(noe);
if noe ='2' then
begin
writeln('first branch');
readln(el1);
writeln('second branch');
readln(el2);
result:=(el1*el2)/(el1+el2);
writeln(result:4:2);
writeln('enter filname to save the data to:');
readln(fname);
assign(fdata,fname);
rewrite(fdata);
write(fdata,'result:');
write(fdata,result);
close(fdata);
end;
if noe='3'then
begin
writeln('first branch');
readln(el1);
writeln('second branch');
readln(el2);
writeln('third branch');
readln(el3);
result:=1/((1/el1)+(1/el2)+(1/el3));
writeln(result:4:2);
writeln('enter filname to save the data to:');
readln(fname);
assign(fdata,fname);
rewrite(fdata);
write(fdata,'result:');
write(fdata,result);
close(fdata);
end;
if noe='4'then
begin
writeln('first branch');
readln(el1);
writeln('second branch');
readln(el2);
writeln('third branch');
readln(el3);
writeln('fourth branch');
readln(el4);
result:=1/((1/el1)+(1/el2)+(1/el3)+(1/el4));
writeln(result:4:2);
writeln('enter filname to save the data to:');
readln(fname);
assign(fdata,fname);
rewrite(fdata);
write(fdata,'result:');
write(fdata,result);
close(fdata);
end;
if noe='5'then
begin
writeln('first branch');
readln(el1);
writeln('second branch');
readln(el2);
writeln('third branch');
readln(el3);
writeln('fourth branch');
readln(el4);
writeln('fifth branch');
readln(el5);
result1:=1/((1/el1)+(1/el2)+(1/el3)+(1/el4)+(1/el5));
writeln(result:4:2);
writeln('enter filname to save the data to:');
readln(fname);
assign(fdata,fname);
rewrite(fdata);
write(fdata,'result:');
write(fdata,result);
close(fdata);
end
end;
if choice = 'b' then
begin
writeln('1n element');
readln(el1);
writeln('2n element');
readln(el3);
writeln('3n element');
readln(el2);
writeln('12 element');
result:=(el1+el3)+(el1*el3/el2);
writeln(result:4:2);
writeln('23 element');
result0:=(el2+el3)+(el2*el3/el1);
writeln(result0:4:2);
writeln('31 element');
result1:=(el1+el2)+(el1*el2/el3);
writeln(result1:4:2);
writeln('enter filname to save the data to:');
readln(fname);
assign(fdata,fname);
rewrite(fdata);
writeln(fdata,'element 1n, element 2n & element 3n, respectively:');
write (fdata,result:4:2,',');
write (fdata,result0:4:2,',');
write (fdata,result1:4:2,'.');
close(fdata);
end;
if choice = 'c' then
begin
writeln('12 element');
readln(el2);
writeln('23 element');
readln(el1);
writeln('31 element');
readln(el3);
writeln('1n element');
result:=(el2*el3)/(el1+el3+el2);
writeln(result:4:2);
writeln('2n element');
result0:=(el1*el2)/(el2+el3+el1);
writeln(result0:4:2);
writeln('3n element');
result1:=(el1*el3)/(el1+el2+el3);
writeln(result1:4:2);
writeln('enter filname to save the data to:');
readln(fname);
assign(fdata,fname);
rewrite(fdata);
writeln(fdata,'element 1n, element 2n & element 3n, respectively:');
write (fdata,result:4:2, ',');
write (fdata,result0:4:2,',');
write (fdata,result1:4:2,'.');
close(fdata);
end
end
end.
SmallEiffel:
Example, calculation of the equivalent of a few parallel branches & wye to delta conversion:
class FUNDAMEO
creation
make
feature
noe:integer;
el1,el2,el3:real;
first:character;
filenam:string
filenam0:string
io1:STD_FILE_WRITE
make is
do
from
until first ='q'
loop
menu
end loop
end make
menu is
do
io.put_string("%Nenter a for equivalent of parallel branches, b for wyetodelta conversion,%Nc for
delta to wye conv.: %N");
io.read_character;
first:=io.last_character;
if first = 'a' then do_selectiona
end first='a'
if first = 'b' then do_selectionb
end first='b'
if first = 'c' then do_selectionc
end first='c'
end menu
do_selectiona is
do
io.put_string("enter # of parallel branches: ")
io.read_integer
noe:=io.last_integer
if noe = 2
then
io.put_string("enter value of first element: ");
io.read_real;
el1:=io.last_real;
io.put_string("enter second element: ");
io.read_real;
el2:=io.last_real;
io.put_string("the result: ");
io.put_real(el1*el2/(el1+el2));
io.put_string("%N")
end if noe=2
if noe = 3
then
io.put_string("enter value of first element: ")
io.read_real
el1:=io.last_real
io.put_string("enter second element: ")
io.read_real
el2:=io.last_real
io.put_string("enter third element: ")
io.read_real
el3:=io.last_real
io.put_string("the result: ")
io.put_real(1/((1/el1)+(1/el2)+(1/el3)))
io.put_string("%N")
end if noe=3
end do_selectiona
do_selectionb is
do
io.put_string("enter value of 1n element: ");
io.read_real;
el1:=io.last_real;
io.put_string("enter 2n element: ");
io.read_real;
el3:=io.last_real;
io.put_string("enter 3n element: ");
io.read_real;
el2:=io.last_real;
io.put_string("the result: ");
io.put_real((el1+el3)+(el1*el3/el2));
io.put_string(",");
io.put_real((el2+el3)+(el2*el3/el1));
io.put_string(" & ");
io.put_real((el1+el2)+(el1*el2/el3))
io.put_string("%N")
io.put_string("to save data to a file enter 1; to append existing file enter 2: ")
io.read_integer
if io.last_integer = 1 then
io.put_string("enter file name to save file under: ")
io.read_word
filenam:=io.last_string
io.put_string(filenam)
!!io1.connect_to(filenam)
io1.put_string("the result = ")
io1.put_real((el1+el3)+(el1*el3/el2));
io1.put_string(",");
io1.put_real((el2+el3)+(el2*el3/el1));
io1.put_string(" & ");
io1.put_real((el1+el2)+(el1*el2/el3))
io1.put_string("%N")
io1.disconnect
end if file saving
if io.last_integer = 2 then
io.put_string("%N")
io.put_string("enter result file name: ")
io.read_word
filenam0:=io.last_string
!!io1.connect_to(filenam0)
io.put_string("enter file name to be appended: ")
io.read_word
filenam:=io.last_string
io1.append_file(filenam)
io1.put_string("the result = ")
io1.put_real((el1+el3)+(el1*el3/el2));
io1.put_string(",");
io1.put_real((el2+el3)+(el2*el3/el1));
io1.put_string(" & ");
io1.put_real((el1+el2)+(el1*el2/el3))
io1.put_string("%N")
io1.disconnect
end append file
end do_selectionb
do_selectionc is
do
io1.put_string(" not implemented yet ");
end do_selectionc
end FUNDAMEO
GTKMM:
Example: deltatowye conversion:
#include <gtkmm.h>
#include <gtkmm/main.h>
#include <iostream>
#include <stdio.h>
#include <fstream>
char filename[20];
gchar buf[16];
double x1, x2, x3, z1, z2, z3;
class ExampleWindow : public Gtk::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Signal handlers:
virtual void on_button_add();
virtual void on_button_close();
//Child widgets:
Gtk::Frame m_Frame_Accelerated;
Gtk::HBox m_HBox_Accelerated, m_HBox_Buttons;
Gtk::VBox m_VBox_Main, m_VBox, m_VBox_Accelerated, m_VBox_Value;
Gtk::Label m_Label_Value1, m_Label_Value, m_Label_ShowValue, m_Label_ShowValue1,
m_Label_ShowValue2, m_Label_Value2, m_Label_Value3, m_Label_Value4, m_Label_Value5;
Gtk::Adjustment m_adjustment_value, m_adjustment_value1, m_adjustment_value2;
Gtk::SpinButton m_SpinButton_Value, m_SpinButton_Value1, m_SpinButton_Value2;
Gtk::Button m_Button_Add, m_Button_Close;
};
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
//Shows the window and returns when it is closed.
Gtk::Main::run(window);
return 0;
}
ExampleWindow::ExampleWindow()
:
m_Frame_Accelerated("Accelerated"),
m_VBox_Main(false, 5),
m_Label_Value("Value of element 12: "),
m_Label_Value1("Value of element 23: "),
m_Label_Value2("Value of element 31: "),
m_Label_Value3("Value of element 1n: "),
m_Label_Value4("Value of element 2n: "),
m_Label_Value5("Value of element 3n: "),
m_adjustment_value(0.0, 10000.0, 10000.0, 0.1, 100.0, 0.0),
m_SpinButton_Value(m_adjustment_value, 1.0, 2),
m_adjustment_value1(0.0, 10000.0, 10000.0, 0.1, 100.0, 0.0),
m_SpinButton_Value1(m_adjustment_value1, 1.0, 2),
m_adjustment_value2(0.0, 10000.0, 10000.0, 0.1, 100.0, 0.0),
m_SpinButton_Value2(m_adjustment_value2, 1.0, 2),
m_Button_Add("Calculate transformation delta to wye"),
m_Button_Close("Close")
{
set_title("delta to wye");
m_VBox_Main.set_border_width(10);
add(m_VBox_Main);
m_VBox.set_border_width(5);
//Accelerated:
m_VBox_Main.pack_start(m_Frame_Accelerated);
m_VBox_Accelerated.set_border_width(5);
m_Frame_Accelerated.add(m_VBox_Accelerated);
m_VBox_Accelerated.pack_start(m_HBox_Accelerated, Gtk::PACK_EXPAND_WIDGET, 5);
m_HBox_Accelerated.pack_start(m_VBox_Value, Gtk::PACK_EXPAND_WIDGET, 5);
m_Label_Value.set_alignment(Gtk::ALIGN_LEFT);
m_VBox_Value.pack_start(m_Label_Value);
m_SpinButton_Value.set_wrap();
m_SpinButton_Value.set_size_request(100, 1);
m_VBox_Value.pack_start(m_SpinButton_Value);
m_Label_Value1.set_alignment(Gtk::ALIGN_LEFT);
m_VBox_Value.pack_start(m_Label_Value1);
m_SpinButton_Value1.set_wrap();
m_SpinButton_Value1.set_size_request(100, 1);
m_VBox_Value.pack_start(m_SpinButton_Value1);
m_Label_Value2.set_alignment(Gtk::ALIGN_LEFT);
m_VBox_Value.pack_start(m_Label_Value2);
m_SpinButton_Value2.set_wrap();
m_SpinButton_Value2.set_size_request(100, 1);
m_VBox_Value.pack_start(m_SpinButton_Value2);
//Buttons:
m_VBox_Accelerated.pack_start (m_HBox_Buttons, Gtk::PACK_SHRINK, 5);
m_Label_Value3.set_alignment(Gtk::ALIGN_LEFT);
m_VBox_Value.pack_start(m_Label_Value3);
m_VBox_Accelerated.pack_start(m_Label_ShowValue);
m_Label_ShowValue.set_text("0");
m_Label_Value4.set_alignment(Gtk::ALIGN_LEFT);
m_VBox_Value.pack_start(m_Label_Value4);
m_VBox_Accelerated.pack_start(m_Label_ShowValue1);
m_Label_ShowValue1.set_text("0");
m_Label_Value5.set_alignment(Gtk::ALIGN_LEFT);
m_VBox_Value.pack_start(m_Label_Value5);
m_VBox_Accelerated.pack_start(m_Label_ShowValue2);
m_Label_ShowValue2.set_text("0");
//Close button:
m_Button_Close.signal_clicked().connect( sigc::mem_fun(*this,
&ExampleWindow::on_button_close) );
m_VBox_Main.pack_start(m_Button_Close, Gtk::PACK_SHRINK);
m_Button_Add.signal_clicked().connect( sigc::mem_fun(*this,
&ExampleWindow::on_button_add) );
m_VBox_Main.pack_start(m_Button_Add, Gtk::PACK_SHRINK);
show_all_children();
}
ExampleWindow::~ExampleWindow()
{std::cout << "bye." << std::endl;
}
void ExampleWindow::on_button_close()
{
hide();
}
void ExampleWindow::on_button_add()
{
x1 = m_SpinButton_Value.get_value();
x2 = m_SpinButton_Value1.get_value();
x3 = m_SpinButton_Value2.get_value();
z1 =(x3*x1)/(x2+x1+x3) ;
z2 =(x2*x1)/(x2+x1+x3);
z3 =(x2*x3)/(x2+x1+x3);
sprintf (buf, "%0.*f", m_SpinButton_Value.get_digits(), z1);
m_Label_ShowValue.set_text(buf);
sprintf (buf, "%0.*f", m_SpinButton_Value.get_digits(), z2);
m_Label_ShowValue1.set_text(buf);
sprintf (buf, "%0.*f", m_SpinButton_Value.get_digits(), z3);
m_Label_ShowValue2.set_text(buf);
}
Example: EPDMIS, Constants of electrical power systems:
#include <gtkmm.h>
#include <gtkmm/main.h>
#include <gtkmm/stock.h>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/liststore.h>
using namespace std;
class SimEq : public Gtk::Window
{
public:
SimEq();
virtual ~SimEq();
protected:
//Signal handlers:
virtual void on_button_clicked();
virtual void on_button_clicked1();
virtual void on_button_clicked2();
virtual void on_button_clicked3();
virtual void on_button_clicked4();
virtual void on_button_clicked5();
virtual void on_button_clicked6();
virtual void on_button_clicked7();
virtual void on_button_clicked8();
virtual void on_button_clicked9();
virtual void on_button_clicked10();
virtual void on_button_clicked11();
virtual void on_button_clicked12();
virtual void on_button_clicked13();
virtual void on_button_clicked14();
Glib::RefPtr<Gtk::UIManager> m_refUIManager;
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
Glib::RefPtr<Gtk::RadioAction> m_refChoiceOne, m_refChoiceTwo;
virtual void on_menu_file_quit();
//Member widgets:
Gtk::Button m_button, m_button0, m_button1, m_button2, m_button3, m_button4, m_button5;
Gtk::ScrolledWindow m_ScrolledWindow1, m_ScrolledWindow;
Gtk::VBox m_VBox_Main, m_HBox, m_VBox, m_Box;
protected:
//Signal handlers:
virtual void on_combo_changed();
//Tree model columns:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{ add(m_col_id); add(m_col_name); }
Gtk::TreeModelColumn<int> m_col_id;
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
};
ModelColumns m_Columns;
//Child widgets:
Gtk::ComboBox m_Combo;
Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
};
class ExampleWindow : public Gtk::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Signal handlers:
virtual void on_button_quit();
//Tree model columns:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{ add(m_col_id); add(m_col_name); add(m_col_namef); add(m_col_namei); add(m_col_names);}
Gtk::TreeModelColumn<unsigned int> m_col_id;
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
Gtk::TreeModelColumn<Glib::ustring> m_col_namef;
Gtk::TreeModelColumn<Glib::ustring> m_col_namei;
Gtk::TreeModelColumn<Glib::ustring> m_col_names;
};
ModelColumns m_Columns;
//Child widgets:
Gtk::VBox m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::TreeView m_TreeView;
Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
Gtk::HButtonBox m_ButtonBox;
Gtk::Button m_Button_Quit;
};
class ExampleWindow1 : public Gtk::Window
{
public:
ExampleWindow1();
virtual ~ExampleWindow1();
protected:
//Signal handlers:
virtual void on_button_quit();
//Tree model columns:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{ add(m_col_id); add(m_col_name); add(m_col_namef); add(m_col_namei); add(m_col_names);}
Gtk::TreeModelColumn<unsigned int> m_col_id;
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
Gtk::TreeModelColumn<Glib::ustring> m_col_namef;
Gtk::TreeModelColumn<Glib::ustring> m_col_namei;
Gtk::TreeModelColumn<Glib::ustring> m_col_names;
};
ModelColumns m_Columns;
//Child widgets:
Gtk::VBox m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::TreeView m_TreeView;
Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
Gtk::HButtonBox m_ButtonBox;
Gtk::Button m_Button_Quit;
};
class ExampleWindow2 : public Gtk::Window
{
public:
ExampleWindow2();
virtual ~ExampleWindow2();
protected:
//Signal handlers:
virtual void on_button_quit();
//Tree model columns:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{ add(m_col_id); add(m_col_name); add(m_col_namef); add(m_col_namei); add(m_col_names);}
Gtk::TreeModelColumn<unsigned int> m_col_id;
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
Gtk::TreeModelColumn<Glib::ustring> m_col_namef;
Gtk::TreeModelColumn<Glib::ustring> m_col_namei;
Gtk::TreeModelColumn<Glib::ustring> m_col_names;
};
ModelColumns m_Columns;
//Child widgets:
Gtk::VBox m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::TreeView m_TreeView;
Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
Gtk::HButtonBox m_ButtonBox;
Gtk::Button m_Button_Quit;
};
class ExampleWindow3 : public Gtk::Window
{
public:
ExampleWindow3();
virtual ~ExampleWindow3();
protected:
//Signal handlers:
virtual void on_button_quit();
//Tree model columns:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{ add(m_col_id); add(m_col_name); add(m_col_namef); add(m_col_namei); add(m_col_names);}
Gtk::TreeModelColumn<unsigned int> m_col_id;
Gtk::TreeModelColumn<Glib::ustring> m_col_name;
Gtk::TreeModelColumn<Glib::ustring> m_col_namef;
Gtk::TreeModelColumn<Glib::ustring> m_col_namei;
Gtk::TreeModelColumn<Glib::ustring> m_col_names;
};
ModelColumns m_Columns;
//Child widgets:
Gtk::VBox m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::TreeView m_TreeView;
Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
Gtk::HButtonBox m_ButtonBox;
Gtk::Button m_Button_Quit;
};
class ExampleWindow4 : public Gtk::Window
{
public:
ExampleWindow4();
virtual ~ExampleWindow4();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow5 : public Gtk::Window
{
public:
ExampleWindow5();
virtual ~ExampleWindow5();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow6 : public Gtk::Window
{
public:
ExampleWindow6();
virtual ~ExampleWindow6();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow7 : public Gtk::Window
{
public:
ExampleWindow7();
virtual ~ExampleWindow7();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow8 : public Gtk::Window
{
public:
ExampleWindow8();
virtual ~ExampleWindow8();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow9 : public Gtk::Window
{
public:
ExampleWindow9();
virtual ~ExampleWindow9();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow10 : public Gtk::Window
{
public:
ExampleWindow10();
virtual ~ExampleWindow10();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow11 : public Gtk::Window
{
public:
ExampleWindow11();
virtual ~ExampleWindow11();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow12 : public Gtk::Window
{
public:
ExampleWindow12();
virtual ~ExampleWindow12();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow13 : public Gtk::Window
{
public:
ExampleWindow13();
virtual ~ExampleWindow13();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
class ExampleWindow14 : public Gtk::Window
{
public:
ExampleWindow14();
virtual ~ExampleWindow14();
protected:
//Signal handlers:
virtual void on_button_close();
//Member widgets:
Gtk::Button m_button;
};
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
SimEq window;
//Shows the window and returns when it is closed.
Gtk::Main::run(window);
return 0;
}
SimEq::SimEq()
: m_button("")
{
set_title("EPDMIS (Electrical Power Distribution Management Information System): Constants of
power systems elements");
//Create actions for menus and toolbars:
m_refActionGroup = Gtk::ActionGroup::create();
//sub menu:
m_refActionGroup>add(Gtk::Action::create("Rel",
Gtk::Stock::NEW, "Reliability data", "Reliability data"),
sigc::mem_fun(*this, &SimEq::on_button_clicked));
m_refActionGroup>add(Gtk::Action::create("Ind",
Gtk::Stock::NEW, "Typical inductance values for induction & synchronous machines",
"Typical inductance values for induction & synchronous machines"),
sigc::mem_fun(*this, &SimEq::on_button_clicked1));
m_refActionGroup>add(Gtk::Action::create("Concu",
Gtk::Stock::NEW, "Constants of copper conductors", "Constants of copper conductors"),
sigc::mem_fun(*this, &SimEq::on_button_clicked2));
m_refActionGroup>add(Gtk::Action::create("Conal",
Gtk::Stock::NEW, "Constants of aluminum conductors", "Constants of aluminum
conductors"),
sigc::mem_fun(*this, &SimEq::on_button_clicked3));
m_refActionGroup>add(Gtk::Action::create("Consp",
Gtk::Stock::NEW, "Conductors spacing factors", "Conductors spacing factors"),
sigc::mem_fun(*this, &SimEq::on_button_clicked4));
m_refActionGroup>add(Gtk::Action::create("Reca",
Gtk::Stock::NEW, "Typical reactance of 3 phase cable circuits", "Typical reactance of 3 phase
cable circuits"),
sigc::mem_fun(*this, &SimEq::on_button_clicked5));
m_refActionGroup>add(Gtk::Action::create("XR",
Gtk::Stock::NEW, "Typical X/R ratios of electric machines", "Typical X/R ratios of elecytic
machines"),
sigc::mem_fun(*this, &SimEq::on_button_clicked6));
m_refActionGroup>add(Gtk::Action::create("Captr",
Gtk::Stock::NEW, "Typical capacitance values to ground of transformer windings", "Typical
capacitance values to ground of transformer windings"),
sigc::mem_fun(*this, &SimEq::on_button_clicked7));
m_refActionGroup>add(Gtk::Action::create("Capob",
Gtk::Stock::NEW, "Typical capacitance values to ground of outdoor bushings", "Typical
capacitance values to ground of outdoor bushings"),
sigc::mem_fun(*this, &SimEq::on_button_clicked8));
m_refActionGroup>add(Gtk::Action::create("Capgen",
Gtk::Stock::NEW, "Typical capacitance values to ground of generator armatures", "Typical
capacitance values to ground of generator armatures"),
sigc::mem_fun(*this, &SimEq::on_button_clicked9));
m_refActionGroup>add(Gtk::Action::create("Capins",
Gtk::Stock::NEW, "Typical capacitance values to ground of instrument transformers", "Typical
capacitance values to ground of instrument transformers"),
sigc::mem_fun(*this, &SimEq::on_button_clicked10));
m_refActionGroup>add(Gtk::Action::create("Cappb",
Gtk::Stock::NEW, "Typical capacitance values to ground of phase bus", "Typical capacitance
values to ground of phase bus"),
sigc::mem_fun(*this, &SimEq::on_button_clicked11));
m_refActionGroup>add(Gtk::Action::create("Impdist",
Gtk::Stock::NEW, "Typical impedance values of distribution transformers", "Typical
impedance values of distribution transformers"),
sigc::mem_fun(*this, &SimEq::on_button_clicked12));
m_refActionGroup>add(Gtk::Action::create("Imppo",
Gtk::Stock::NEW, "Typical impedance values of power transformers up to 10 MVA", "Typical
impedance values of power transformers up to 10 MVA"),
sigc::mem_fun(*this, &SimEq::on_button_clicked13));
m_refActionGroup>add(Gtk::Action::create("Imppo10",
Gtk::Stock::NEW, "Typical impedance values of power transformers above to 10 MVA",
"Typical impedance values of power transformers above to 10 MVA"),
sigc::mem_fun(*this, &SimEq::on_button_clicked14));
//choices menu:
m_refActionGroup>add(Gtk::Action::create("FileMenu", "Choices"));
//Submenu.
m_refActionGroup>add(Gtk::Action::create("FileNew", Gtk::Stock::NEW));
m_refActionGroup>add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
sigc::mem_fun(*this, &SimEq::on_menu_file_quit));
m_refUIManager = Gtk::UIManager::create();
m_refUIManager>insert_action_group(m_refActionGroup);
add_accel_group(m_refUIManager>get_accel_group());
//Layout the actions in a menubar and toolbar:
Glib::ustring ui_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu action='FileMenu'>"
" <menu action='FileNew'>"
" <menuitem action='Rel'/>"
" <menuitem action='Ind'/>"
" <menuitem action='Concu'/>"
" <menuitem action='Conal'/>"
" <menuitem action='Consp'/>"
" <menuitem action='Reca'/>"
" <menuitem action='XR'/>"
" <menuitem action='Captr'/>"
" <menuitem action='Capob'/>"
" <menuitem action='Capgen'/>"
" <menuitem action='Capins'/>"
" <menuitem action='Cappb'/>"
" <menuitem action='Impdist'/>"
" <menuitem action='Imppo'/>"
" <menuitem action='Imppo10'/>"
" </menu>"
" <separator/>"
" <menuitem action='FileQuit'/>"
" </menu>"
" </menubar>"
" <toolbar name='ToolBar'>"
" <toolitem action='Rel'/>"
" <toolitem action='Ind'/>"
" <toolitem action='Concu'/>"
" <toolitem action='Concu'/>"
" <toolitem action='Conal'/>"
" <toolitem action='Consp'/>"
" <toolitem action='Reca'/>"
" <toolitem action='XR'/>"
" <toolitem action='Captr'/>"
" <toolitem action='Capob'/>"
" <toolitem action='Capgen'/>"
" <toolitem action='Capins'/>"
" <toolitem action='Cappb'/>"
" <toolitem action='Impdist'/>"
" <toolitem action='Imppo'/>"
" <toolitem action='Imppo10'/>"
" <toolitem action='FileQuit'/>"
" </toolbar>"
"</ui>";
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
m_refUIManager>add_ui_from_string(ui_info);
}
catch(const Glib::Error& ex)
{
std::cerr << "building menus failed: " << ex.what();
}
#else
std::auto_ptr<Glib::Error> ex;
m_refUIManager>add_ui_from_string(ui_info, ex);
if(ex.get())
{
std::cerr << "building menus failed: " << ex>what();
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
add(m_HBox);
set_border_width(10);
//Get the menubar and toolbar widgets, and add them to a container widget:
Gtk::Widget* pMenubar = m_refUIManager>get_widget("/MenuBar");
if(pMenubar)
m_HBox.pack_start(*pMenubar, Gtk::PACK_SHRINK);
Gtk::Widget* pToolbar = m_refUIManager>get_widget("/ToolBar") ;
if(pToolbar)
m_HBox.pack_start(*pToolbar, Gtk::PACK_SHRINK);
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
m_ScrolledWindow.add(m_VBox_Main);
m_HBox.pack_start(m_VBox);
m_VBox.pack_start(m_ScrolledWindow);
//Create the Tree model:
//m_refTreeModel = Gtk::TreeStore::create(m_Columns);
m_refTreeModel = Gtk::ListStore::create(m_Columns);
m_Combo.set_model(m_refTreeModel);
//Fill the ComboBox's Tree Model:
Gtk::TreeModel::Row row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Reliability data";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 2;
row[m_Columns.m_col_name] = "Typical inductance values for induction & synchronous machines";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 3;
row[m_Columns.m_col_name] = "Constants of copper conductors";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 4;
row[m_Columns.m_col_name] = "Constants of aluminum conductors";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 5;
row[m_Columns.m_col_name] = "Conductors spacing factors";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 6;
row[m_Columns.m_col_name] = "Typical reactance of 3 phase cable circuits";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 7;
row[m_Columns.m_col_name] = "Typical X/R ratios of electric machines";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 8;
row[m_Columns.m_col_name] = "Typical capacitance values to ground of transformer windings";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 9;
row[m_Columns.m_col_name] = "Typical capacitance values to ground of outdoor bushings";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 10;
row[m_Columns.m_col_name] = "Typical capacitance values to ground of generator armatures";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 11;
row[m_Columns.m_col_name] = "Typical capacitance values to ground of instrument transformers";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 12;
row[m_Columns.m_col_name] = "Typical capacitance values to ground of phase bus";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 13;
row[m_Columns.m_col_name] = "Typical impedance values of distribution transformers";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 14;
row[m_Columns.m_col_name] = "Typical impedance values of power transformers up to 10 MVA";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 15;
row[m_Columns.m_col_name] = "Typical impedance values of power transformers above 10 MVA";
//Add the model columns to the Combo (which is a kind of view),
//rendering them in the default way:
m_Combo.pack_start(m_Columns.m_col_id);
m_Combo.pack_start(m_Columns.m_col_name);
//Add the ComboBox
m_VBox_Main.pack_start(m_Combo, Gtk::PACK_SHRINK);
//Connect signal handler:
m_Combo.signal_changed().connect( sigc::mem_fun(*this, &SimEq::on_combo_changed) );
show_all_children();
}
ExampleWindow::ExampleWindow()
: m_Button_Quit("Quit")
{
set_title("EPDMIS, Reliability data");
set_border_width(5);
set_default_size(400, 200);
add(m_VBox);
//Add the TreeView, inside a ScrolledWindow, with the button underneath:
m_ScrolledWindow.add(m_TreeView);
//Only show the scrollbars when they are necessary:
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_VBox.pack_start(m_ScrolledWindow);
m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
m_ButtonBox.set_border_width(5);
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
m_Button_Quit.signal_clicked().connect( sigc::mem_fun(*this,
&ExampleWindow::on_button_quit) );
//Create the Tree model:
m_refTreeModel = Gtk::ListStore::create(m_Columns);
m_TreeView.set_model(m_refTreeModel);
//Fill the TreeView's model
Gtk::TreeModel::Row row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "protective relays";
row[m_Columns.m_col_namef] = ".0002";
row[m_Columns.m_col_namei] = "5";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 2;
row[m_Columns.m_col_name] = "0 to 600 V circuit breakers";
row[m_Columns.m_col_namef] = ".0027";
row[m_Columns.m_col_namei] = "4";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 3;
row[m_Columns.m_col_name] = "above 600 V circuit breakers";
row[m_Columns.m_col_namef] = ".0036";
row[m_Columns.m_col_namei] = "83.1 for repair";
row[m_Columns.m_col_names] = "2.1 when spares are available for replacement";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 4;
row[m_Columns.m_col_name] = "0 to 600 V cable, per 1000 ft";
row[m_Columns.m_col_namef] = ".00141";
row[m_Columns.m_col_namei] = "10.5";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 5;
row[m_Columns.m_col_name] = "1000 V and above cable, per 1000 ft";
row[m_Columns.m_col_namef] = ".00613";
row[m_Columns.m_col_namei] = "26.5 for repair";
row[m_Columns.m_col_names] = "19 for replacement of faulty section";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 6;
row[m_Columns.m_col_name] = "0 to 600 V cable termination";
row[m_Columns.m_col_namef] = ".0001";
row[m_Columns.m_col_namei] = "3.8";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 7;
row[m_Columns.m_col_name] = "above 600 V terminations";
row[m_Columns.m_col_namef] = ".0003";
row[m_Columns.m_col_namei] = "25";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 8;
row[m_Columns.m_col_name] = "enclosed disconnect switches";
row[m_Columns.m_col_namef] = ".0061";
row[m_Columns.m_col_namei] = "3.6";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 9;
row[m_Columns.m_col_name] = "transformers";
row[m_Columns.m_col_namef] = ".003";
row[m_Columns.m_col_namei] = "324 to repair";
row[m_Columns.m_col_names] = "130 to replace";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 10;
row[m_Columns.m_col_name] = "bare low voltage switchgear bus (with 7 circuit breakers)";
row[m_Columns.m_col_namef] = ".0024";
row[m_Columns.m_col_namei] = "24";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 11;
row[m_Columns.m_col_name] = "bare low voltage switchgear bus (with 5 circuit breakers)";
row[m_Columns.m_col_namef] = ".0017";
row[m_Columns.m_col_namei] = "24";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 12;
row[m_Columns.m_col_name] = "insulated medium voltage switchgear bus, with 1 circuit breaker";
row[m_Columns.m_col_namef] = ".0034";
row[m_Columns.m_col_namei] = "26.8";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 13;
row[m_Columns.m_col_name] = "insulated medium voltage switchgear bus, with 2 circuit breakers";
row[m_Columns.m_col_namef] = ".0068";
row[m_Columns.m_col_namei] = "26.8";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 14;
row[m_Columns.m_col_name] = "Data regarding electric power utility reliability factors:";
row[m_Columns.m_col_namef] = " ";
row[m_Columns.m_col_namei] = " ";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 15;
row[m_Columns.m_col_name] = "Data: utility: single circuit";
row[m_Columns.m_col_namef] = "1.956";
row[m_Columns.m_col_namei] = "1.32";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 16;
row[m_Columns.m_col_name] = "Data: utility: double circuit: loss of both circuits";
row[m_Columns.m_col_namef] = ".312";
row[m_Columns.m_col_namei] = ".52";
row[m_Columns.m_col_names] = " ";
//Add the TreeView's view columns:
m_TreeView.append_column("ID", m_Columns.m_col_id);
m_TreeView.append_column("Equipment", m_Columns.m_col_name);
m_TreeView.append_column("Failure per year (rate)", m_Columns.m_col_namef);
m_TreeView.append_column("Hours of downtime per failure", m_Columns.m_col_namei);
m_TreeView.append_column("Notes", m_Columns.m_col_names);
//Make all the columns reorderable:
//This is not necessary, but it's nice to show the feature.
//You can use TreeView::set_column_drag_function() to more
//finely control column drag and drop.
for(guint i = 0; i < 5; i++)
{
Gtk::TreeView::Column* pColumn = m_TreeView.get_column(i);
pColumn>set_reorderable();
pColumn>set_sort_column(i);
}
show_all_children();
}
ExampleWindow1::ExampleWindow1()
: m_Button_Quit("Quit")
{
set_title("EPDMIS, Typical inductance values for induction & synchronous machines");
set_border_width(5);
set_default_size(400, 200);
add(m_VBox);
//Add the TreeView, inside a ScrolledWindow, with the button underneath:
m_ScrolledWindow.add(m_TreeView);
//Only show the scrollbars when they are necessary:
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_VBox.pack_start(m_ScrolledWindow);
m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
m_ButtonBox.set_border_width(5);
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
m_Button_Quit.signal_clicked().connect( sigc::mem_fun(*this,
&ExampleWindow1::on_button_quit) );
//Create the Tree model:
m_refTreeModel = Gtk::ListStore::create(m_Columns);
m_TreeView.set_model(m_refTreeModel);
//Fill the TreeView's model
Gtk::TreeModel::Row row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "TURBINE GENERATORS: 2POLES";
row[m_Columns.m_col_namef] = ".09";
row[m_Columns.m_col_namei] = ".15";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 2;
row[m_Columns.m_col_name] = "TURBINE GENERATORS: 4POLES";
row[m_Columns.m_col_namef] = ".15";
row[m_Columns.m_col_namei] = ".23";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 3;
row[m_Columns.m_col_name] = "SALIENT POLE GENERATORS WITH DAMPER WINDINGS:
12POLES OR LESS";
row[m_Columns.m_col_namef] = ".16";
row[m_Columns.m_col_namei] = ".33";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 4;
row[m_Columns.m_col_name] = "SALIENT POLE GENERATORS WITH DAMPER WINDINGS:
14POLES OR MORE";
row[m_Columns.m_col_namef] = ".21";
row[m_Columns.m_col_namei] = ".33";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 5;
row[m_Columns.m_col_name] = "SYNCHRONOUS MOTORS: 6POLES";
row[m_Columns.m_col_namef] = ".15";
row[m_Columns.m_col_namei] = ".23";
row[m_Columns.m_col_names] = "KVAbase = HP RATING FOR .8 P.F. MOTORS";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 6;
row[m_Columns.m_col_name] = "SYNCHRONOUS MOTORS: 814 POLES";
row[m_Columns.m_col_namef] = ".2";
row[m_Columns.m_col_namei] = ".3";
row[m_Columns.m_col_names] = "KVAbase = .8 X HP RATING FOR 1 P.F. MOTORS.";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 7;
row[m_Columns.m_col_name] = "SYNCHRONOUS MOTORS: 16POLES OR MORE";
row[m_Columns.m_col_namef] = ".28";
row[m_Columns.m_col_namei] = ".4";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 8;
row[m_Columns.m_col_name] = "SYNCHRONOUS CONDENSERS";
row[m_Columns.m_col_namef] = ".24";
row[m_Columns.m_col_namei] = ".37";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 9;
row[m_Columns.m_col_name] = "SYNCHRONOUS CONVERTERS: 600 V DIRECT CURRENT";
row[m_Columns.m_col_namef] = ".2";
row[m_Columns.m_col_namei] = "";
row[m_Columns.m_col_names] = "";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 10;
row[m_Columns.m_col_name] = "SYNCHRONOUS CONVERTERS: 250 V DIRECT CURRENT";
row[m_Columns.m_col_namef] = ".33";
row[m_Columns.m_col_namei] = "";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 11;
row[m_Columns.m_col_name] = "INDIVIDUAL INDUCTION MOTORS: ABOVE 600 V";
row[m_Columns.m_col_namef] = ".17";
row[m_Columns.m_col_namei] = "";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 12;
row[m_Columns.m_col_name] = "GROUPS OF MOTORS EACH LESS THAN 50 HP: 600 V AND
BELOW";
row[m_Columns.m_col_namef] = ".25";
row[m_Columns.m_col_namei] = "";
row[m_Columns.m_col_names] = " ";
//Add the TreeView's view columns:
m_TreeView.append_column("ID", m_Columns.m_col_id);
m_TreeView.append_column("EQUIPMENT", m_Columns.m_col_name);
m_TreeView.append_column("SUBTRANSIENT REACT.IN P.U. OF M/C KVA",
m_Columns.m_col_namef);
m_TreeView.append_column("TRANSIENT REACT", m_Columns.m_col_namei);
m_TreeView.append_column("Notes", m_Columns.m_col_names);
//Make all the columns reorderable:
//This is not necessary, but it's nice to show the feature.
//You can use TreeView::set_column_drag_function() to more
//finely control column drag and drop.
for(guint i = 0; i < 5; i++)
{
Gtk::TreeView::Column* pColumn = m_TreeView.get_column(i);
pColumn>set_reorderable();
pColumn>set_sort_column(i);
}
show_all_children();
}
ExampleWindow2::ExampleWindow2()
: m_Button_Quit("Quit")
{
set_title("EPDMIS, Constants of copper conductors");
set_border_width(5);
set_default_size(400, 200);
add(m_VBox);
//Add the TreeView, inside a ScrolledWindow, with the button underneath:
m_ScrolledWindow.add(m_TreeView);
//Only show the scrollbars when they are necessary:
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_VBox.pack_start(m_ScrolledWindow);
m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
m_ButtonBox.set_border_width(5);
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
m_Button_Quit.signal_clicked().connect( sigc::mem_fun(*this,
&ExampleWindow2::on_button_quit) );
//Create the Tree model:
m_refTreeModel = Gtk::ListStore::create(m_Columns);
m_TreeView.set_model(m_refTreeModel);
//Fill the TreeView's model
Gtk::TreeModel::Row row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "1000";
row[m_Columns.m_col_namef] = ".013";
row[m_Columns.m_col_namei] = ".0758";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 2;
row[m_Columns.m_col_name] = "900";
row[m_Columns.m_col_namef] = ".0142";
row[m_Columns.m_col_namei] = ".0769";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 3;
row[m_Columns.m_col_name] = "800";
row[m_Columns.m_col_namef] = ".0159";
row[m_Columns.m_col_namei] = ".0782";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 4;
row[m_Columns.m_col_name] = "750";
row[m_Columns.m_col_namef] = ".0168";
row[m_Columns.m_col_namei] = ".079";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 5;
row[m_Columns.m_col_name] = "700";
row[m_Columns.m_col_namef] = ".0179";
row[m_Columns.m_col_namei] = ".08";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 6;
row[m_Columns.m_col_name] = "600";
row[m_Columns.m_col_namef] = ".0206";
row[m_Columns.m_col_namei] = ".0818";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 7;
row[m_Columns.m_col_name] = "500";
row[m_Columns.m_col_namef] = ".0246";
row[m_Columns.m_col_namei] = ".0839";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 8;
row[m_Columns.m_col_name] = "450";
row[m_Columns.m_col_namef] = ".0273";
row[m_Columns.m_col_namei] = ".0854";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 9;
row[m_Columns.m_col_name] = "400";
row[m_Columns.m_col_namef] = ".0307";
row[m_Columns.m_col_namei] = ".0867";
row[m_Columns.m_col_names] = "";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 10;
row[m_Columns.m_col_name] = "350";
row[m_Columns.m_col_namef] = ".0348";
row[m_Columns.m_col_namei] = ".0883";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 11;
row[m_Columns.m_col_name] = "300";
row[m_Columns.m_col_namef] = ".0407";
row[m_Columns.m_col_namei] = ".0902";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 12;
row[m_Columns.m_col_name] = "250";
row[m_Columns.m_col_namef] = ".0487";
row[m_Columns.m_col_namei] = ".0922";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 13;
row[m_Columns.m_col_name] = "4/0";
row[m_Columns.m_col_namef] = ".0574";
row[m_Columns.m_col_namei] = ".0953";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 14;
row[m_Columns.m_col_name] = " 3/0";
row[m_Columns.m_col_namef] = ".0724";
row[m_Columns.m_col_namei] = ".0981";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 15;
row[m_Columns.m_col_name] = "2/0";
row[m_Columns.m_col_namef] = ".0911";
row[m_Columns.m_col_namei] = ".101";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 16;
row[m_Columns.m_col_name] = "1/0";
row[m_Columns.m_col_namef] = ".115";
row[m_Columns.m_col_namei] = ".103";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 17;
row[m_Columns.m_col_name] = "1";
row[m_Columns.m_col_namef] = ".145";
row[m_Columns.m_col_namei] = ".106";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 18;
row[m_Columns.m_col_name] = "2";
row[m_Columns.m_col_namef] = ".181";
row[m_Columns.m_col_namei] = ".108";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 19;
row[m_Columns.m_col_name] = "3";
row[m_Columns.m_col_namef] = ".227";
row[m_Columns.m_col_namei] = ".111";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 20;
row[m_Columns.m_col_name] = "R & XA ARE GIVEN IN OHMS/CONDUCTOR/1000 FT.";
row[m_Columns.m_col_namef] = "Z =R+j(XA+XB)";
row[m_Columns.m_col_namei] = "XA at 1 ft spacing";
row[m_Columns.m_col_names] = " ";
//Add the TreeView's view columns:
m_TreeView.append_column("ID", m_Columns.m_col_id);
m_TreeView.append_column("SIZE OF COPPER CONDUCTOR (MCM OR AWG)",
m_Columns.m_col_name);
m_TreeView.append_column("RESISTANCE R", m_Columns.m_col_namef);
m_TreeView.append_column("REACTANCE (XA)", m_Columns.m_col_namei);
m_TreeView.append_column("Notes", m_Columns.m_col_names);
//Make all the columns reorderable:
//This is not necessary, but it's nice to show the feature.
//You can use TreeView::set_column_drag_function() to more
//finely control column drag and drop.
for(guint i = 0; i < 4; i++)
{
Gtk::TreeView::Column* pColumn = m_TreeView.get_column(i);
pColumn>set_reorderable();
pColumn>set_sort_column(i);
}
show_all_children();
}
ExampleWindow3::ExampleWindow3()
: m_Button_Quit("Quit")
{
set_title("EPDMIS, Constants of aluminum conductors");
set_border_width(5);
set_default_size(400, 200);
add(m_VBox);
//Add the TreeView, inside a ScrolledWindow, with the button underneath:
m_ScrolledWindow.add(m_TreeView);
//Only show the scrollbars when they are necessary:
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_VBox.pack_start(m_ScrolledWindow);
m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
m_ButtonBox.set_border_width(5);
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
m_Button_Quit.signal_clicked().connect( sigc::mem_fun(*this,
&ExampleWindow3::on_button_quit) );
//Create the Tree model:
m_refTreeModel = Gtk::ListStore::create(m_Columns);
m_TreeView.set_model(m_refTreeModel);
//Fill the TreeView's model
Gtk::TreeModel::Row row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "1590";
row[m_Columns.m_col_namef] = ".0129";
row[m_Columns.m_col_namei] = ".0679";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 2;
row[m_Columns.m_col_name] = "1431";
row[m_Columns.m_col_namef] = ".0144";
row[m_Columns.m_col_namei] = ".0692";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 3;
row[m_Columns.m_col_name] = "1272";
row[m_Columns.m_col_namef] = ".0161";
row[m_Columns.m_col_namei] = ".0704";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 4;
row[m_Columns.m_col_name] = "1192.5";
row[m_Columns.m_col_namef] = ".0171";
row[m_Columns.m_col_namei] = ".0712";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 5;
row[m_Columns.m_col_name] = "1113";
row[m_Columns.m_col_namef] = ".0183";
row[m_Columns.m_col_namei] = ".0719";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 6;
row[m_Columns.m_col_name] = "954";
row[m_Columns.m_col_namef] = ".0213";
row[m_Columns.m_col_namei] = ".0738";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 7;
row[m_Columns.m_col_name] = "795";
row[m_Columns.m_col_namef] = ".0243";
row[m_Columns.m_col_namei] = ".0744";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 8;
row[m_Columns.m_col_name] = "715.5";
row[m_Columns.m_col_namef] = ".0273";
row[m_Columns.m_col_namei] = ".0756";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 9;
row[m_Columns.m_col_name] = " 636";
row[m_Columns.m_col_namef] = ".0307";
row[m_Columns.m_col_namei] = ".0768";
row[m_Columns.m_col_names] = "";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 10;
row[m_Columns.m_col_name] = "556.5";
row[m_Columns.m_col_namef] = ".0352";
row[m_Columns.m_col_namei] = ".0786";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 11;
row[m_Columns.m_col_name] = "477";
row[m_Columns.m_col_namef] = ".0371";
row[m_Columns.m_col_namei] = ".0802";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 12;
row[m_Columns.m_col_name] = "397.5";
row[m_Columns.m_col_namef] = ".0445";
row[m_Columns.m_col_namei] = ".0824";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 13;
row[m_Columns.m_col_name] = "336.4";
row[m_Columns.m_col_namef] = ".0526";
row[m_Columns.m_col_namei] = ".0843";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 14;
row[m_Columns.m_col_name] = "266.8";
row[m_Columns.m_col_namef] = ".0662";
row[m_Columns.m_col_namei] = ".1045";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 15;
row[m_Columns.m_col_name] = "4/0";
row[m_Columns.m_col_namef] = ".0835";
row[m_Columns.m_col_namei] = ".1099";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 16;
row[m_Columns.m_col_name] = "3/0";
row[m_Columns.m_col_namef] = ".1052";
row[m_Columns.m_col_namei] = ".1175";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 17;
row[m_Columns.m_col_name] = "2/0";
row[m_Columns.m_col_namef] = ".133";
row[m_Columns.m_col_namei] = ".1212";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 18;
row[m_Columns.m_col_name] = "1/0";
row[m_Columns.m_col_namef] = ".1674";
row[m_Columns.m_col_namei] = ".1242";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 19;
row[m_Columns.m_col_name] = "1";
row[m_Columns.m_col_namef] = ".212";
row[m_Columns.m_col_namei] = ".1259";
row[m_Columns.m_col_names] = " ";
row = *(m_refTreeModel>append());
row[m_Columns.m_col_id] = 20;
row[m_Columns.m_col_name] = "R & XA ARE GIVEN IN OHMS/CONDUCTOR/1000 FT.";
row[m_Columns.m_col_namef] = "Z =R+j(XA+XB)";
row[m_Columns.m_col_namei] = "XA at 1 ft spacing";
row[m_Columns.m_col_names] = " ";
//Add the TreeView's view columns:
m_TreeView.append_column("ID", m_Columns.m_col_id);
m_TreeView.append_column("SIZE OF ALUMINUM CONDUCTOR (MCM OR AWG)",
m_Columns.m_col_name);
m_TreeView.append_column("RESISTANCE R", m_Columns.m_col_namef);
m_TreeView.append_column("REACTANCE (XA)", m_Columns.m_col_namei);
m_TreeView.append_column("Notes", m_Columns.m_col_names);
//Make all the columns reorderable:
//This is not necessary, but it's nice to show the feature.
//You can use TreeView::set_column_drag_function() to more
//finely control column drag and drop.
for(guint i = 0; i < 4; i++)
{
Gtk::TreeView::Column* pColumn = m_TreeView.get_column(i);
pColumn>set_reorderable();
pColumn>set_sort_column(i);
}
show_all_children();
}
ExampleWindow4::ExampleWindow4()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow4::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow5::ExampleWindow5()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow5::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow6::ExampleWindow6()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow6::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow7::ExampleWindow7()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow7::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow8::ExampleWindow8()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow8::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow9::ExampleWindow9()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow9::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow10::ExampleWindow10()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow10::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow11::ExampleWindow11()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow11::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow12::ExampleWindow12()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow12::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow13::ExampleWindow13()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow13::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow14::ExampleWindow14()
: m_button("Not implemented yet")
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow14::on_button_close));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
ExampleWindow::~ExampleWindow()
{hide();
}
ExampleWindow1::~ExampleWindow1()
{hide();
}
ExampleWindow2::~ExampleWindow2()
{hide();
}
ExampleWindow3::~ExampleWindow3()
{hide();
}
ExampleWindow4::~ExampleWindow4()
{hide();
}
ExampleWindow5::~ExampleWindow5()
{hide();
}
ExampleWindow6::~ExampleWindow6()
{hide();
}
ExampleWindow7::~ExampleWindow7()
{hide();
}
ExampleWindow8::~ExampleWindow8()
{hide();
}
ExampleWindow9::~ExampleWindow9()
{hide();
}
ExampleWindow10::~ExampleWindow10()
{hide();
}
ExampleWindow11::~ExampleWindow11()
{hide();
}
ExampleWindow12::~ExampleWindow12()
{hide();
}
ExampleWindow13::~ExampleWindow13()
{hide();
}
ExampleWindow14::~ExampleWindow14()
{hide();
}
void ExampleWindow::on_button_quit()
{
hide();
}
void ExampleWindow1::on_button_quit()
{
hide();
}
void ExampleWindow2::on_button_quit()
{
hide();
}
void ExampleWindow3::on_button_quit()
{
hide();
}
void ExampleWindow4::on_button_close()
{
hide();
}
void ExampleWindow5::on_button_close()
{
hide();
}
void ExampleWindow6::on_button_close()
{
hide();
}
void ExampleWindow7::on_button_close()
{
hide();
}
void ExampleWindow8::on_button_close()
{
hide();
}
void ExampleWindow9::on_button_close()
{
hide();
}
void ExampleWindow10::on_button_close()
{
hide();
}
void ExampleWindow11::on_button_close()
{
hide();
}
void ExampleWindow12::on_button_close()
{
hide();
}
void ExampleWindow13::on_button_close()
{
hide();
}
void ExampleWindow14::on_button_close()
{
hide();
}
void SimEq::on_button_clicked()
{ExampleWindow lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked1()
{ExampleWindow1 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked2()
{ExampleWindow2 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked3()
{ExampleWindow3 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked4()
{ExampleWindow4 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked5()
{ExampleWindow5 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked6()
{ExampleWindow6 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked7()
{ExampleWindow7 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked8()
{ExampleWindow8 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked9()
{ExampleWindow9 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked10()
{ExampleWindow10 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked11()
{ExampleWindow11 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked12()
{ExampleWindow12 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked13()
{ExampleWindow13 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_button_clicked14()
{ExampleWindow14 lesson1;
Gtk::Main::run(lesson1);
}
void SimEq::on_menu_file_quit()
{
hide(); //Closes the main window to stop the Gtk::Main::run().
}
void SimEq::on_combo_changed()
{
Gtk::TreeModel::iterator iter = m_Combo.get_active();
if(iter)
{
Gtk::TreeModel::Row row = *iter;
if(row)
{
//Get the data for the selected row, using our knowledge of the tree
//model:
int id = row[m_Columns.m_col_id];
Glib::ustring name = row[m_Columns.m_col_name];
std::cout << " ID=" << id << ", name=" << name << std::endl;
if (id == 1){ExampleWindow lesson1;
Gtk::Main::run(lesson1);
}
if (id == 2){ExampleWindow1 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 3){ExampleWindow2 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 4){ExampleWindow3 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 5){ExampleWindow4 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 6){ExampleWindow5 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 7){ExampleWindow6 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 8){ExampleWindow7 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 9){ExampleWindow8 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 10){ExampleWindow9 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 11){ExampleWindow10 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 12){ExampleWindow11 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 13){ExampleWindow12 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 14){ExampleWindow13 lesson1;
Gtk::Main::run(lesson1);
}
if (id == 15){ExampleWindow14 lesson1;
Gtk::Main::run(lesson1);
}
}
}
else
std::cout << "invalid iter" << std::endl;
}
SimEq::~SimEq()
{
}
Active Perl:
Example, calculating the equivalent of a few parallel elements:
while ($q==0){
print "enter 1 for equivalent of parallel elements,\n2 for wye to delta,\n3 for delta to wye conversion and
4 to quit: \n\n";
$choice=<STDIN>;
print("\n");
if($choice == 1) {
print ("enter number of elements in parallel: \n");
$noe=<STDIN>;
if ($noe==2) {print ("element1 = ");
$el1=<STDIN>;
print ("element2 = ");
$el2=<STDIN>;
$req=($el1)*($el2)/($el1+$el2);
print ("the equivalent = $req\n");
}
elsif ($noe==3) {print ("element1 = ");
$el1=<STDIN>;
print ("element2 = ");
$el2=<STDIN>;
print ("element3 = ");
$el3=<STDIN>;
$req=1/((1/$el1)+(1/$el2)+(1/$el3));
format printtosc =
********************************************************************************
The Result
equivalent of @<<elements =@>>>>. element1=@>>>>,element2=@>>>>,element3=@>>>>
$noe,$req,$el1,$el2,$el3
********************************************************************************
.
$~="printtosc";
write(STDOUT);
print ("to save result to data file, enter 1: ");
$fchoice=<STDIN>;
if ($fchoice==1) {
print ("to append file enter 1 & to ovewrite/create, enter 2: ");
$appover=<STDIN>;
if ($appover==1){
format printtofile =
=========================================================================
=========
equivalent of @<<< elements =@>>>>. element1:@>>>>, element2:@>>>>, element3:@>>>>
$noe,$req,$el1,$el2,$el3
=========================================================================
=========
.
print ("enter file name: ");
$filenam=<STDIN>;
open(myfile,">>$filenam");
select(myfile);
$~="printtofile";
write(myfile);
close(myfile);
select(STDOUT);
}
elsif ($appover==2){
print ("enter file name: ");
$filenam=<STDIN>;
open(myfile,">$filenam");
select(myfile);
print ("the equivalent = $req\n");
print("the $noe elements are: $el1, $el2 & $ el3");
close(myfile);
select(STDOUT);
}
}
}
}
elsif($choice == 2) {print("wye to delta\n\n");}
elsif($choice == 3) {print("delta to wye\n\n");}
elsif($choice == 4) {last;}
}
Tcl:
Example, calculating the equivalent of a few parallel, elements wye to delta & vice versa:
proc parallel {} {
puts "Enter number of elements: "
set noe [gets stdin]
if {$noe == 2} {
puts "Enter value of first element with decimal eg 2.0: "
set el1 [gets stdin]
puts "Enter value of second element with decimal eg 1.0: "
set el2 [gets stdin]
set res [expr ($el1*$el2)/($el1+$el2)]
puts "the equivalent = $res"
puts "to save to data file: to overwrite enter 1; to append enter 2 (press enter key to skip)"
set overappe [gets stdin]
if {$overappe == 1} {
puts "overwrite, enter filename to create/overwrite"
set filenam [gets stdin]
set fileid [open $filenam w]
puts $fileid "the elements & result are: $el1, $el2 & $res"
close $fileid
}
if {$overappe == 2} {
puts "append, enter filename to append"
set filenam [gets stdin]
set fileid [open $filenam a]
puts $fileid "the elements & result are: $el1, $el2 & $res"
close $fileid
}
}
if {$noe == 3} {
puts "Enter value of first element with decimal eg 2.0: "
set el1 [gets stdin]
puts "Enter value of second element with decimal eg 1.0: "
set el2 [gets stdin]
puts "Enter value of second element with decimal eg 1.0: "
set el3 [gets stdin]
set res [expr 1/((1/$el1)+(1/$el2)+(1/$el3))]
puts "the equivalent = $res"
puts "to save to data file: to overwrite enter 1; to append enter 2 (press enter key to skip)"
set overappe [gets stdin]
if {$overappe == 1} {
puts "overwrite, enter filename to create/overwrite"
set filenam [gets stdin]
set fileid [open $filenam w]
puts $fileid "the elements & result are: $el1, $el2, el3 & $res"
close $fileid
}
if {$overappe == 2} {
puts "append, enter filename to append"
set filenam [gets stdin]
set fileid [open $filenam a]
puts $fileid "the elements & result are: $el1, $el2, el3 & $res"
close $fileid
}
}
}
proc wyedelta {} {
puts "Enter 1n element value with decimal eg. 2.0: "
set el1 [gets stdin]
puts "Enter 2n element value with decimal eg. 3.0: "
set el3 [gets stdin]
puts "Enter 3n element value with decimal eg. 4.5: "
set el2 [gets stdin]
set result0 [expr ($el1+$el3)+($el1*$el3/$el2)]
set result1 [expr ($el2+$el3)+($el2*$el3/$el1)]
set result2 [expr ($el1+$el2)+($el1*$el2/$el3)]
puts "Element 12 = $result0"
puts "Element 23 = $result1"
puts "Element 13 = $result2"
puts "to save to data file: to overwrite enter 1; to append enter 2 (press enter key to skip)"
set overappe [gets stdin]
if {$overappe == 1} {
puts "overwrite, enter filename to create/overwrite"
set filenam [gets stdin]
set fileid [open $filenam w]
puts $fileid "the elements & result are: $el1, $el2, el3, $result0, $result1 & $result2"
close $fileid
}
if {$overappe == 2} {
puts "append, enter filename to append"
set filenam [gets stdin]
set fileid [open $filenam a]
puts $fileid "the elements & result are: $el1, $el2, el3, $result0, $result1 & $result2"
close $fileid
}
}
proc deltawye {} {
puts "Enter the value of 12 element according to following format nn.nn eg. 3.0: "
set el2 [gets stdin]
puts "Enter 23 element per above indicated format: "
set el1 [gets stdin]
puts "Enter 31 element per indicated format: "
set el3 [gets stdin]
set result0 [expr ($el2*$el3)/($el1+$el3+$el2)]
set result1 [expr ($el1*$el2)/($el2+$el3+$el1)]
set result2 [expr ($el1*$el3)/($el1+$el2+$el3)]
puts "Element 1n = $result0"
puts "Element 2n = $result1"
puts "Element 3n = $result2"
puts "to save to data file: to overwrite enter 1; to append enter 2 (press enter key to skip)"
set overappe [gets stdin]
if {$overappe == 1} {
puts "overwrite, enter filename to create/overwrite"
set filenam [gets stdin]
set fileid [open $filenam w]
puts $fileid "the elements & result are: $el1, $el2, el3, $result0, $result1 & $result2"
close $fileid
}
if {$overappe == 2} {
puts "append, enter filename to append"
set filenam [gets stdin]
set fileid [open $filenam a]
puts $fileid "the elements & result are: $el1, $el2, el3, $result0, $result1 & result2"
close $fileid
}
}
set choice ""
while {$choice != "q"} {
puts nonewline "Enter a for equivalent of parallel elements, \nb for wyetodelta conversion, \nc for
deltato wye & q to exit: "
set choice [gets stdin]
if {$choice == "a"} {parallel}
if {$choice == "b"} {wyedelta}
if {$choice == "c"} {deltawye}
if {$choice == "q"} {
exit}
}
TK:
Example, calculating the equivalent of a few parallel elements, wye to delta conversion & vice versa
and short circuit calculations for a simple circuit:
set w .menu
catch {destroy $w}
toplevel $w
wm title $w "Fundamental calculations"
wm iconname $w "menu"
label $w.msg wraplength 4i justify left
if {$tcl_platform(platform) == "macintosh"} {
$w.msg configure text "This window contains a menubar with cascaded menus. You can invoke
entries with an accelerator by typing Command+x, where \"x\" is the character next to the command
key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and
releasing the mouse."
} else {
$w.msg configure text "This window contains the menubar for the electrical power systems Basic
calculations:\n 1)The equivalent of a few parallel elements.\n 2)Wyetodelta conversion.\n 3)Deltato
wye transformation.\nFor short circuit calculations of a simple system:\n1)Line to ground
fault.\n2)Three phase fault.\n3)Double line fault.\n4)Double line to ground fault.\n "
}
pack $w.msg side top
set menustatus " "
frame $w.statusBar
label $w.statusBar.label textvariable menustatus relief sunken bd 1 font "Helvetica 10" anchor w
pack $w.statusBar.label side left padx 2 expand yes fill both
pack $w.statusBar side bottom fill x pady 2
menu $w.menu tearoff 0
if {$tcl_platform(platform) == "macintosh"} {
set modifier Command
} elseif {$tcl_platform(platform) == "windows"} {
set modifier Control
} else {
set modifier Meta
}
set m $w.menu.basic
$w.menu add cascade label "Basic calculations" menu $m underline 0
menu $m tearoff 0
$m add command label "Equivalent of parallel elements" command {parallel} background yellow
accelerator $modifier+H underline 0
bind $w <$modifierh> {parallel}
$m add command label "Wyetodelta" command {wyedelta} background red accelerator
$modifier+G underline 0
bind $w <$modifierg> {wyedelta}
$m add cascade label "Deltatowye" command {deltawye} background green accelerator
$modifier+W underline 0
bind $w <$modifierw> {deltawye}
set m $w.menu.short
$w.menu add cascade label "Simple S.C. Calc." menu $m underline 0
menu $m tearoff 0
$m add command label "Line to ground" command {ltg} background yellow accelerator
$modifier+H underline 0
bind $w <$modifierh> {sptg}
$m add command label "Three phase fault" command {thf} background red accelerator
$modifier+G underline 0
bind $w <$modifierg> {thf}
$m add cascade label "Linetoline fault" command {ltlf} background green accelerator
$modifier+W underline 0
bind $w <$modifierw> {deltawye}
$m add cascade label "Linetolinetoground" command {ltltg} background green accelerator
$modifier+L underline 17
bind $w <$modifierl> {deltawye}
$w configure menu $w.menu
frame .t
set log [text .t.log width 80 height 10 borderwidth 2 relief sunken setgrid true yscrollcommand
{.t.scroll set}]
scrollbar .t.scroll command {.t.log yview}
pack .t.scroll side right fill y
pack .t.log side left fill both expand true
pack .t side top fill both expand true
bind Menu <<MenuSelect>> {
global $menustatus
if {[catch {%W entrycget active label} label]} {
set label " "
}
set menustatus $label
update idletasks
}
proc parallel {} {
destroy .top0 .top4 .top4a .top5 .top5a
destroy .top1 .top2 .top3 .hk
global log
# Set window title
wm title . Parallel
# Create a frame for buttons and entry.
frame .top borderwidth 10
frame .bottom borderwidth 10
pack .top side top fill x
pack .bottom side top fill x
# Create the command buttons.
button .top.quit text Quit command exit
set but [button .top.run text "Run it" command Run]
pack .top.quit .top.run side right
set but [button .bottom.save text "Save data to file" command saved]
pack .bottom.save side right
# Create a 8labels + 8 entries for the command
label .top.l text element1: padx 0
label .top.2 text element2: padx 0
label .top.3 text element3: padx 0
label .top.4 text element4: padx 0
label .bottom.5 text element5: padx 0
label .bottom.6 text element6: padx 0
label .bottom.7 text element7: padx 0
label .bottom.8 text element8: padx 0
entry .top.cmd width 10 relief sunken textvariable command
entry .top.cmd0 width 10 relief sunken textvariable command0
entry .top.cmd1 width 10 relief sunken textvariable command1
entry .top.cmd2 width 10 relief sunken textvariable command2
entry .bottom.cmd3 width 10 relief sunken textvariable command3
entry .bottom.cmd4 width 10 relief sunken textvariable command4
entry .bottom.cmd5 width 10 relief sunken textvariable command5
entry .bottom.cmd6 width 10 relief sunken textvariable command6
pack .top.l side left
pack .top.cmd side left fill x expand true
pack .top.2 side left
pack .top.cmd0 side left fill x expand true
pack .top.3 side left
pack .top.cmd1 side left fill x expand true
pack .top.4 side left
pack .top.cmd2 side left fill x expand true
pack .bottom.5 side left
pack .bottom.cmd3 side left fill x expand true
pack .bottom.6 side left
pack .bottom.cmd4 side left fill x expand true
pack .bottom.7 side left
pack .bottom.cmd5 side left fill x expand true
pack .bottom.8 side left
pack .bottom.cmd6 side left fill x expand true
proc Run {} {
global commandr log command command0 command1 command2 command3 command4 command5
command6
if {$command1 eq ""} {set commandr [expr 1/((1/$command)+(1/$command0))]
$log insert end $commandr
$log insert end "\n" } elseif {$command2 eq ""} {set commandr [expr
1/((1/$command)+(1/$command0)+(1/$command1))]
$log insert end $commandr
$log insert end "\n" } elseif {$command3 == ""} {set commandr [expr
1/((1/$command)+(1/$command0)+(1/$command1)+(1/$command2))]
$log insert end $commandr
$log insert end "\n" } elseif {$command4 == ""} {set commandr [expr
1/((1/$command)+(1/$command0)+(1/$command1)+(1/$command2)+(1/$command3))]
$log insert end $commandr
$log insert end "\n" } elseif {$command5 == ""} {set commandr [expr
1/((1/$command)+(1/$command0)+(1/$command1)+(1/$command2)+(1/$command3)+(1/$command4
))]
$log insert end $commandr
$log insert end "\n" } elseif {$command6 == ""} {set commandr [expr
1/((1/$command)+(1/$command0)+(1/$command1)+(1/$command2)+(1/$command3)+(1/$command4
)+(1/$command5))]
$log insert end $commandr
$log insert end "\n" } else {set commandr [expr
1/((1/$command)+(1/$command0)+(1/$command1)+(1/$command2)+(1/$command3)+(1/$command4
)+(1/$command5)+(1/$command6))]
$log insert end $commandr
$log insert end "\n"}
}
proc saved {} {
global commandr log command command0 command1 command2 command3 command4 command5
command6
destroy .top
destroy .bottom
# Set window title
wm title . SavingScreen
# Create a frame for buttons and entry.
frame .tops borderwidth 10
frame .bottoms borderwidth 10
pack .tops side top fill x
pack .bottoms side top fill x
# Create the command buttons.
button .tops.quit text "Quit without saving" command exit
set but [button .tops.run text "Save" command Save]
pack .tops.quit .tops.run side right
# Create a 1 labels + 1 entries for the command
label .tops.l text Filename: padx 0
entry .tops.cmd width 10 relief sunken textvariable filename
pack .tops.l side left
pack .tops.cmd side left fill x expand true
proc Save {} {
global filename commandr log command command0 command1 command2 command3 command4
command5 command6
set fileid [open $filename a]
puts $fileid "the elements & result
are:$command,$command0,$command1,$command2,$command3,$command4,$command5,$comman
d6 & $commandr"
close $fileid
destroy .tops
destroy .bottoms
}
}
}
proc wyedelta {} {
destroy .top .bottom .top4 .top4a .top5 .top5a
destroy .top1 .top2 .top3 .hk
global log
# Set window title
wm title . Wyetodetla
# Create a frame for buttons and entry.
frame .top0 borderwidth 10
pack .top0 side top fill x
# Create the command buttons.
button .top0.quit text Quit command exit
set but [button .top0.run text "Run it" command Run]
pack .top0.quit .top0.run side right
# Create a 3labels + 3 entries for the command
label .top0.l text "1n element: " padx 0
label .top0.2 text "2n element: " padx 0
label .top0.3 text "3n element: " padx 0
entry .top0.cmd width 10 relief sunken textvariable command
entry .top0.cmd0 width 10 relief sunken textvariable command0
entry .top0.cmd1 width 10 relief sunken textvariable command1
pack .top0.l side left
pack .top0.cmd side left fill x expand true
pack .top0.2 side left
pack .top0.cmd0 side left fill x expand true
pack .top0.3 side left
pack .top0.cmd1 side left fill x expand true
proc Run {} {
global commandr commandr0 commandr1 log command command0 command1
$log insert end "element 13:"
set commandr [expr (($command+$command1)+($command*$command1/$command0))]
$log insert end $commandr
$log insert end "\n"
$log insert end "element 23:"
set commandr0 [expr (($command0+$command1)+($command0*$command1/$command))]
$log insert end $commandr0
$log insert end "\n"
$log insert end "element 12:"
set commandr1 [expr ($command+$command0)+($command*$command0/$command1)]
$log insert end $commandr1
$log insert end "\n"
}
}
proc deltawye {} {
destroy .top .bottom .top4 .top4a .top5 .top5a
destroy .top0 .top2 .top3 .hk
global log
# Set window title
wm title . Deltatowye
# Create a frame for buttons and entry.
frame .top1 borderwidth 10
pack .top1 side top fill x
# Create the command buttons.
button .top1.quit text Quit command exit
set but [button .top1.run text "Run it" command Run]
pack .top1.quit .top1.run side right
# Create a 3labels + 3 entries for the command
label .top1.l text "12 element: " padx 0
label .top1.2 text "23 element: " padx 0
label .top1.3 text "31 element: " padx 0
entry .top1.cmd width 10 relief sunken textvariable command
entry .top1.cmd0 width 10 relief sunken textvariable command0
entry .top1.cmd1 width 10 relief sunken textvariable command1
pack .top1.l side left
pack .top1.cmd side left fill x expand true
pack .top1.2 side left
pack .top1.cmd0 side left fill x expand true
pack .top1.3 side left
pack .top1.cmd1 side left fill x expand true
proc Run {} {
global commandr commandr0 commandr1 log command command0 command1
$log insert end "element 2n:"
set commandr [expr ($command*$command0)/($command+$command1+$command0)]
$log insert end $commandr
$log insert end "\n"
$log insert end "element 1n:"
set commandr0 [expr ($command*$command1)/($command0+$command1+$command)]
$log insert end $commandr0
$log insert end "\n"
$log insert end "element 3n:"
set commandr1 [expr ($command1*$command0)/($command+$command0+$command1)]
$log insert end $commandr1
$log insert end "\n"
}
}
proc ltg {} {
destroy .top .bottom .top4 .top4a .top5 .top5a
destroy .top0 .top1 .top3
global log
# Set window title
wm title . "Single line to ground fault"
# Create a frame for buttons and entry.
frame .top2 borderwidth 10
pack .top2 side top fill x
frame .hk borderwidth 10
pack .hk side top fill x
# Create the command buttons.
button .top2.quit text Quit command exit
set but [button .top2.run text "Run it" command Run]
pack .top2.quit .top2.run side right
# Create a 6labels + 6 entries for the command
label .top2.l text "Fault react. in p.u.: " padx 0
label .top2.2 text "+ve seq. X in pu: " padx 0
label .top2.3 text "Neutral react., pu: " padx 0
label .hk.1 text "ve Seq. react. in p.u.: " padx 0
label .hk.2 text "Zero seq. X in pu: " padx 0
label .hk.3 text "Prefault V in pu: " padx 0
entry .top2.cmd width 10 relief sunken textvariable f
entry .top2.cmd0 width 10 relief sunken textvariable d
entry .top2.cmd1 width 10 relief sunken textvariable e
entry .hk.cmd width 10 relief sunken textvariable c
entry .hk.cmd0 width 10 relief sunken textvariable b
entry .hk.cmd1 width 10 relief sunken textvariable a
pack .top2.l side left
pack .top2.cmd side left fill x expand true
pack .top2.2 side left
pack .top2.cmd0 side left fill x expand true
pack .top2.3 side left
pack .top2.cmd1 side left fill x expand true
pack .hk.1 side left
pack .hk.cmd side left fill x expand true
pack .hk.2 side left
pack .hk.cmd0 side left fill x expand true
pack .hk.3 side left
pack .hk.cmd1 side left fill x expand true
proc Run {} {
global log a b c d e f
$log insert end "The short circuit current in pu:"
set x [expr 3*$f]
set y [expr 3*$e]
set commandr [expr 3*$a/($x+$y+$c+$b+$d)]
$log insert end $commandr
$log insert end "\n"
}
}
proc thf {} {
destroy .top .bottom .top4 .top4a .top5 .top5a
destroy .top0 .top1 .top2 .hk
global log
# Set window title
wm title . "Three phase fault"
# Create a frame for buttons and entry.
frame .top3 borderwidth 10
pack .top3 side top fill x
# Create the command buttons.
button .top3.quit text Quit command exit
set but [button .top3.run text "Run it" command Run]
pack .top3.quit .top3.run side right
# Create a 3labels + 3 entries for the command
label .top3.l text "Prefault V in pu: " padx 0
label .top3.2 text "+ve seq. X in pu: " padx 0
label .top3.3 text "Fault react., pu: " padx 0
entry .top3.cmd width 10 relief sunken textvariable h
entry .top3.cmd0 width 10 relief sunken textvariable j
entry .top3.cmd1 width 10 relief sunken textvariable k
pack .top3.l side left
pack .top3.cmd side left fill x expand true
pack .top3.2 side left
pack .top3.cmd0 side left fill x expand true
pack .top3.3 side left
pack .top3.cmd1 side left fill x expand true
proc Run {} {
global log h j k
$log insert end "The three phase short circuit current in pu:"
set commandr [expr ($h/$j+$k)]
$log insert end $commandr
$log insert end "\n"
}
}
proc ltlf {} {
destroy .top .bottom .top5 .top5a
destroy .top0 .top1 .top2 .hk .top3
global log
# Set window title
wm title . "Double line fault"
# Create a frame for buttons and entry.
frame .top4 borderwidth 10
pack .top4 side top fill x
frame .top4a borderwidth 10
pack .top4a side top fill x
# Create the command buttons.
button .top4.quit text Quit command exit
set but [button .top4.run text "Run it" command Run]
pack .top4.quit .top4.run side right
# Create a 4labels + 4 entries for the command
label .top4.l text "Prefault V in pu: " padx 0
label .top4.2 text "+ve seq. X in pu: " padx 0
label .top4.3 text "ve seq. react., pu: " padx 0
label .top4a.1 text "Fault react., pu: " padx 0
entry .top4.cmd width 10 relief sunken textvariable m
entry .top4.cmd0 width 10 relief sunken textvariable u
entry .top4.cmd1 width 10 relief sunken textvariable w
entry .top4a.cmd width 10 relief sunken textvariable uw
pack .top4.l side left
pack .top4.cmd side left fill x expand true
pack .top4.2 side left
pack .top4.cmd0 side left fill x expand true
pack .top4.3 side left
pack .top4.cmd1 side left fill x expand true
pack .top4a.1 side left
pack .top4a.cmd side left fill x expand true
proc Run {} {
global log m u w uw
$log insert end "The double line fault current in pu:"
set commandr0 [expr $m/($u+$w+$uw)]
set commandr [expr (.866*2*$commandr0)]
$log insert end $commandr
$log insert end "\n"
}
}
proc ltltg {} {
destroy .top .bottom .top4 .top4a
destroy .top0 .top1 .top2 .hk .top3
global log
# Set window title
wm title . "Double line fault"
# Create a frame for buttons and entry.
frame .top5 borderwidth 10
pack .top5 side top fill x
frame .top5a borderwidth 10
pack .top5a side top fill x
# Create the command buttons.
button .top5.quit text Quit command exit
set but [button .top5.run text "Run it" command Run]
pack .top5.quit .top5.run side right
# Create a 6 labels + 6 entries for the command
label .top5.l text "Prefault V in pu: " padx 0
label .top5.2 text "+ve seq. X in pu: " padx 0
label .top5.3 text "ve seq. react., pu: " padx 0
label .top5a.1 text "Fault react., pu: " padx 0
label .top5a.2 text "zero seq. react., pu: " padx 0
label .top5a.3 text "Neutral react., pu: " padx 0
entry .top5.cmd width 10 relief sunken textvariable v1
entry .top5.cmd0 width 10 relief sunken textvariable p1
entry .top5.cmd1 width 10 relief sunken textvariable n1
entry .top5a.cmd width 10 relief sunken textvariable l1
entry .top5a.cmd0 width 10 relief sunken textvariable z1
entry .top5a.cmd1 width 10 relief sunken textvariable g1
pack .top5.l side left
pack .top5.cmd side left fill x expand true
pack .top5.2 side left
pack .top5.cmd0 side left fill x expand true
pack .top5.3 side left
pack .top5.cmd1 side left fill x expand true
pack .top5a.1 side left
pack .top5a.cmd side left fill x expand true
pack .top5a.2 side left
pack .top5a.cmd0 side left fill x expand true
pack .top5a.3 side left
pack .top5a.cmd1 side left fill x expand true
proc Run {} {
global log v1 p1 n1 z1 g1 l1
$log insert end "The double line to ground fault current in pu:"
set commandr0 [expr (3*$g1 + 3*$l1 + $z1)*$n1/(3*$g1 + 3*$l1 + $z1 + $n1)]
set commandr1 [expr $v1/($p1 + $commandr0)]
set commandr2 [expr $v1 ($commandr1 * $p1)]
set commandr [expr (3*$commandr2/$z1)]
$log insert end $commandr
$log insert end "\n"
}
}
Python:
Example, calculating the equivalent of a few parallel branches:
def par2(el1, el2):
r1=1/el1
r2=1/el2
t=(r1+r2)
print 2,1/t
res=`(1/t)`
print "overwrite enter o, append enter a"
appover = raw_input()
if appover == "o":
print "enter file name"
fnam = raw_input()
f=open(fnam, 'w')
f.write ('\nthis is to overwrite or create\n')
f.write (res)
f.close()
if appover == "a":
print "enter file name"
fnam = raw_input()
f=open(fnam, 'a')
f.write ('\nthis is to append\n')
f.write (res)
f.close()
def par3(el1, el2,el3):
r1=1/el1
r2=1/el2
r3=1/el3
t=(r1+r2+r3)
print 3,1/t
def par4(el1, el2,el3,el4):
r1=1/el1
r2=1/el2
r3=1/el3
r4=1/el4
t=(r1+r2+r3+r4)
print 4,1/t
def par5(el1, el2,el3,el4,el5):
r1=1/el1
r2=1/el2
r3=1/el3
r4=1/el4
r5=1/el5
t=(r1+r2+r3+r4+r5)
print 5,1/t
JavaScript:
An example in JS to perform certain fundamental calculations:
<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*a33a32*a23))(a12*(a21*a33a23*a31))+(a13*(a21*a32a22*a31)) ;
b11 = (a22*a33a23*a32)/det ;
b12 = (a12*a33a13*a32)/det ;
b13 = (a12*a23a13*a22)/det ;
b21 = (a21*a33a31*a23)/det ;
b22 = (a11*a33a13*a31)/det ;
b23 = (a11*a23a13*a21)/det ;
b31 = (a21*a32a31*a22)/det ;
b32 = (a11*a32a12*a31)/det ;
b33 = (a11*a22a21*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>
VB.net:
An example to perform certain fundamental calculations:
fund00.vb file:
Imports System.Windows.Forms.MessageBox
Public Class fund00
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem8 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem9 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem10 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem11 As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
Me.MenuItem3 = New System.Windows.Forms.MenuItem
Me.MenuItem4 = New System.Windows.Forms.MenuItem
Me.MenuItem5 = New System.Windows.Forms.MenuItem
Me.MenuItem6 = New System.Windows.Forms.MenuItem
Me.MenuItem7 = New System.Windows.Forms.MenuItem
Me.MenuItem8 = New System.Windows.Forms.MenuItem
Me.MenuItem9 = New System.Windows.Forms.MenuItem
Me.MenuItem10 = New System.Windows.Forms.MenuItem
Me.MenuItem11 = New System.Windows.Forms.MenuItem
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(16, 24)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(312, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Equivalent of a few series resistance or reactance elements"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(16, 64)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(320, 23)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Equivalent of a few parallel resistance or reactance elements"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(16, 104)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(320, 23)
Me.Button3.TabIndex = 2
Me.Button3.Text = "Wye to delta conversion"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(16, 144)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(320, 23)
Me.Button4.TabIndex = 3
Me.Button4.Text = "Delta to wye conversion"
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem()
{Me.MenuItem1})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem()
{Me.MenuItem2, Me.MenuItem6, Me.MenuItem10, Me.MenuItem11})
Me.MenuItem1.Text = "Choice"
'
'MenuItem2
'
Me.MenuItem2.Index = 0
Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem()
{Me.MenuItem3, Me.MenuItem4, Me.MenuItem5})
Me.MenuItem2.Text = "Series elements"
'
'MenuItem3
'
Me.MenuItem3.Index = 0
Me.MenuItem3.Text = "2 elements"
'
'MenuItem4
'
Me.MenuItem4.Index = 1
Me.MenuItem4.Text = "3 elements"
'
'MenuItem5
'
Me.MenuItem5.Index = 2
Me.MenuItem5.Text = "4 elements"
'
'MenuItem6
'
Me.MenuItem6.Index = 1
Me.MenuItem6.MenuItems.AddRange(New System.Windows.Forms.MenuItem()
{Me.MenuItem7, Me.MenuItem8, Me.MenuItem9})
Me.MenuItem6.Text = "Parallel elements"
'
'MenuItem7
'
Me.MenuItem7.Index = 0
Me.MenuItem7.Text = "2 elements"
'
'MenuItem8
'
Me.MenuItem8.Index = 1
Me.MenuItem8.Text = "3 elements"
'
'MenuItem9
'
Me.MenuItem9.Index = 2
Me.MenuItem9.Text = "4 elements"
'
'MenuItem10
'
Me.MenuItem10.Index = 2
Me.MenuItem10.Text = "Wye to delta"
'
'MenuItem11
'
Me.MenuItem11.Index = 3
Me.MenuItem11.Text = "Delta to wye"
'
'fund00
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(424, 266)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Menu = Me.MainMenu1
Me.Name = "fund00"
Me.Text = "Fundamental Calculations"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim myform As New fund01
myform.Show()
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem3.Click
Dim myform As New fund01
myform.Show()
End Sub
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem4.Click
Dim myform As New fund01
myform.Show()
End Sub
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem5.Click
Dim myform As New fund01
myform.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Dim myform As New fund02
myform.Show()
End Sub
Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem7.Click
Dim myform As New parallel2
myform.Show()
End Sub
Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem8.Click
Dim myform As New parallel3
myform.Show()
End Sub
Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem9.Click
Dim myform As New parallel4
myform.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
MessageBox.Show("Not implemented yet.", "", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
MessageBox.Show("Not implemented yet.", "", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
End Sub
End Class
fund01.vb
Imports System
Imports System.IO
Public Class fund01
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Label5 = New System.Windows.Forms.Label
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.TextBox6 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "First element"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(104, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Second element"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(88, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "Third element"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 120)
Me.Label4.Name = "Label4"
Me.Label4.TabIndex = 3
Me.Label4.Text = "Fourth elemennt"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(144, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(88, 20)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = "0"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(144, 56)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(80, 20)
Me.TextBox2.TabIndex = 5
Me.TextBox2.Text = "0"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(144, 88)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(80, 20)
Me.TextBox3.TabIndex = 6
Me.TextBox3.Text = "0"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(144, 120)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(88, 20)
Me.TextBox4.TabIndex = 7
Me.TextBox4.Text = "0"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 160)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 24)
Me.Button1.TabIndex = 8
Me.Button1.Text = "Click to obtain result"
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(8, 192)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(40, 16)
Me.Label5.TabIndex = 9
Me.Label5.Text = "Result"
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(56, 192)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(104, 20)
Me.TextBox5.TabIndex = 10
Me.TextBox5.Text = "result appears here"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(16, 240)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(152, 32)
Me.Button2.TabIndex = 11
Me.Button2.Text = "Click to save to a c\testfile.text"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(248, 232)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(88, 56)
Me.Button3.TabIndex = 12
Me.Button3.Text = "click to save to a text file"
'
'TextBox6
'
Me.TextBox6.Location = New System.Drawing.Point(192, 208)
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.Size = New System.Drawing.Size(152, 20)
Me.TextBox6.TabIndex = 13
Me.TextBox6.Text = "Filename, including drive name"
'
'fund01
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(352, 302)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "fund01"
Me.Text = "fund01"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim n1 As Single
Dim n2 As Single
Dim n3 As Single
Dim n4 As Single
Dim nr As Single
n1 = Single.Parse(TextBox1.Text)
n2 = Single.Parse(TextBox2.Text)
n3 = Single.Parse(TextBox3.Text)
n4 = Single.Parse(TextBox4.Text)
nr = n1 + n2 + n3 + n4
TextBox5.Text = nr
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
' Create an instance of StreamWriter to write text to a file.
Dim sw As StreamWriter = New StreamWriter("c:\TestFile.txt")
' Add some text to the file.
sw.Write("The date is: ")
sw.WriteLine(DateTime.Now)
sw.WriteLine("")
sw.Write("first element: ")
sw.Write(TextBox1.Text)
sw.Write(" ")
sw.Write("second element: ")
sw.Write(TextBox2.Text)
sw.WriteLine(" ")
sw.Write("third element: ")
sw.Write(TextBox3.Text)
sw.Write(" ")
sw.Write("fourth element: ")
sw.Write(TextBox4.Text)
sw.WriteLine(" ")
sw.Write("the result: ")
sw.Write(TextBox5.Text)
sw.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
Dim myfilename As String
myfilename = TextBox6.Text.ToString
Dim sw As StreamWriter = New StreamWriter(myfilename)
' Add some text to the file.
sw.Write("The date is: ")
sw.WriteLine(DateTime.Now)
sw.WriteLine("")
sw.Write("first element: ")
sw.Write(TextBox1.Text)
sw.Write(" ")
sw.Write("second element: ")
sw.Write(TextBox2.Text)
sw.WriteLine(" ")
sw.Write("third element: ")
sw.Write(TextBox3.Text)
sw.Write(" ")
sw.Write("fourth element: ")
sw.Write(TextBox4.Text)
sw.WriteLine(" ")
sw.Write("the result: ")
sw.Write(TextBox5.Text)
sw.Close()
End Sub
End Class
fund02.vb:
Public Class fund02
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(16, 24)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(176, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Click for 2 elements in parallel"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(16, 56)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(176, 24)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Click for 3 elements in parallelel"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(16, 88)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(176, 24)
Me.Button3.TabIndex = 2
Me.Button3.Text = "Click for 4 elements in parallel"
'
'fund02
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 126)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "fund02"
Me.Text = "fund02"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim myform As New parallel2
myform.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Dim myform As New parallel3
myform.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
Dim myform As New parallel4
myform.Show()
End Sub
End Class
parallel2.vb:
Imports System
Imports System.IO
Public Class parallel2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(200, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "First element (resistance or reactance)"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(224, 16)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Second element (resistance or reactance)"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(232, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(80, 20)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = "1"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(232, 56)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(80, 20)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = "1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 88)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(128, 32)
Me.Button1.TabIndex = 4
Me.Button1.Text = "Click to calculate the equivalent"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(24, 136)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(48, 16)
Me.Label3.TabIndex = 5
Me.Label3.Text = "Result"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(80, 136)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.ReadOnly = True
Me.TextBox3.Size = New System.Drawing.Size(56, 20)
Me.TextBox3.TabIndex = 6
Me.TextBox3.Text = "result"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(184, 96)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(144, 20)
Me.TextBox4.TabIndex = 7
Me.TextBox4.Text = "Filename including full path"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(216, 128)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(104, 32)
Me.Button2.TabIndex = 8
Me.Button2.Text = "Click to save data to file"
'
'ErrorProvider1
'
Me.ErrorProvider1.ContainerControl = Me
'
'parallel2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(352, 182)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "parallel2"
Me.Text = "parallel2"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim m1 As Single
Dim m2 As Single
Dim mr As Single
m1 = Single.Parse(TextBox1.Text)
m2 = Single.Parse(TextBox2.Text)
mr = (1 / m1) + (1 / m2)
TextBox3.Text = 1 / mr
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsDigit(e.KeyChar) = False Then
ErrorProvider1.SetError(TextBox1, "enter a numeric value")
Else
ErrorProvider1.SetError(TextBox1, "")
End If
End Sub
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "enter a numeric value")
e.Cancel = True
ElseIf ErrorProvider1.GetError(TextBox1) <> "" Then
e.Cancel = True
Else
ErrorProvider1.SetError(TextBox1, "")
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If Char.IsDigit(e.KeyChar) = False Then
ErrorProvider1.SetError(TextBox2, "enter a numeric value")
Else
ErrorProvider1.SetError(TextBox2, "")
End If
End Sub
Private Sub TextBox2_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox2.Validating
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox2, "enter a numeric value")
e.Cancel = True
ElseIf ErrorProvider1.GetError(TextBox2) <> "" Then
e.Cancel = True
Else
ErrorProvider1.SetError(TextBox2, "")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Dim myfilename1 As String
myfilename1 = TextBox4.Text.ToString
Dim sw As StreamWriter
If File.Exists(myfilename1) = True Then
sw = File.AppendText(myfilename1)
sw.Write("The date is: ")
sw.WriteLine(DateTime.Now)
sw.Write("first element: ")
sw.WriteLine(TextBox1.Text)
sw.Write("second element: ")
sw.WriteLine(TextBox2.Text)
sw.Write("the result: ")
sw.WriteLine(TextBox3.Text)
sw.Flush()
sw.Close()
End If
If File.Exists(myfilename1) = False Then
' Create a file to write to.
sw = File.CreateText(myfilename1)
sw.Write("The date is: ")
sw.WriteLine(DateTime.Now)
sw.Write("first element: ")
sw.WriteLine(TextBox1.Text)
sw.Write("second element: ")
sw.WriteLine(TextBox2.Text)
sw.Write("the result: ")
sw.WriteLine(TextBox3.Text)
sw.Flush()
sw.Close()
End If
End Sub
End Class
parallel3.vb:
Public Class parallel3
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(88, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "First element"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(88, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Second element"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(96, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "Third element"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(144, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(80, 20)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = "1"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(144, 48)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(80, 20)
Me.TextBox2.TabIndex = 4
Me.TextBox2.Text = "1"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(144, 80)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(80, 20)
Me.TextBox3.TabIndex = 5
Me.TextBox3.Text = "1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 120)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(184, 24)
Me.Button1.TabIndex = 6
Me.Button1.Text = "Click to obtain result"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(72, 152)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.ReadOnly = True
Me.TextBox4.Size = New System.Drawing.Size(128, 20)
Me.TextBox4.TabIndex = 7
Me.TextBox4.Text = "result"
'
'parallel3
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "parallel3"
Me.Text = "parallel3"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim m1 As Single
Dim m2 As Single
Dim m3 As Single
Dim mr As Single
m1 = Single.Parse(TextBox1.Text)
m2 = Single.Parse(TextBox2.Text)
m3 = Single.Parse(TextBox3.Text)
mr = (1 / m1) + (1 / m2) + 1 / m3
TextBox4.Text = 1 / mr
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
While TextBox1.Text = ""
MessageBox.Show("Enter a nubmer", "Fatal error", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
TextBox1.Text = "1"
End While
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged
While TextBox2.Text = ""
MessageBox.Show("Enter a nubmer", "Fatal error", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
TextBox2.Text = "1"
End While
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox3.TextChanged
While TextBox3.Text = ""
MessageBox.Show("Enter a nubmer", "Fatal error", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
TextBox3.Text = "1"
End While
End Sub
End Class
parallel4.vb:
Public Class parallel4
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(104, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "first element"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(104, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "second element"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(80, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "third element"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 112)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(80, 24)
Me.Label4.TabIndex = 3
Me.Label4.Text = "fourth element"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(128, 8)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(72, 20)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = "1"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(128, 40)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(72, 20)
Me.TextBox2.TabIndex = 5
Me.TextBox2.Text = "1"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(128, 72)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(72, 20)
Me.TextBox3.TabIndex = 6
Me.TextBox3.Text = "1"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(128, 104)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(72, 20)
Me.TextBox4.TabIndex = 7
Me.TextBox4.Text = "1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 144)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(176, 24)
Me.Button1.TabIndex = 8
Me.Button1.Text = "click to obtain result"
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(64, 184)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.ReadOnly = True
Me.TextBox5.Size = New System.Drawing.Size(128, 20)
Me.TextBox5.TabIndex = 9
Me.TextBox5.Text = "RESULT"
'
'parallel4
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "parallel4"
Me.Text = "parallel4"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim m1 As Single
Dim m2 As Single
Dim m3 As Single
Dim m4 As Single
Dim mr As Single
m1 = Single.Parse(TextBox1.Text)
m2 = Single.Parse(TextBox2.Text)
m3 = Single.Parse(TextBox3.Text)
m4 = Single.Parse(TextBox4.Text)
mr = (1 / m1) + (1 / m2) + (1 / m3) + (1 / m4)
TextBox5.Text = 1 / mr
End Sub
End Class
VBA for applications (Excel):
An example, 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 = "Perunit 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 = "Perunit 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 = "Perunit 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 = "Perunit 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 = "Perunit 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 = "Perunit 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 = "Perunit 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 = "Perunit 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 = "&Ybus calculation"
Set ctrl711 = ctrl71.Controls.Add(Type:=msoControlButton, Id:=1)
ctrl711.Caption = "&Fourbus network Y calculation"
ctrl711.TooltipText = "Calculation of system admittancebus "
ctrl711.Style = msoButtonCaption
With ctrl711
.OnAction = "MySub711"
End With
Set ctrl72 = newMenu.Controls.Add(Type:=msoControlPopup, Id:=1)
ctrl72.Caption = "&Zbus calculation"
Set ctrl721 = ctrl72.Controls.Add(Type:=msoControlButton, Id:=1)
ctrl721.Caption = "F&ourbus network Z calculation"
ctrl721.TooltipText = "Calculation of system impedancebus "
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 focususer 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("YD & 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("Perunit 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("Perunit calc.").Select '"Perunit 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("Perunit 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 12 in p.u.= ") 'The user enters the data into the series if the
input boxes
r13 = InputBox("series resistance of line 13 in p.u.= ") 'will appear on the screen sequentialy.
r24 = InputBox("series resistance of line 24 in p.u.= ")
r34 = InputBox("series resistance of line 34 in p.u.= ")
x12 = InputBox("series reactance of line 12 in p.u.= ")
x13 = InputBox("series reactance of line 13 in p.u.= ")
x24 = InputBox("series reactance of line 24 in p.u.= ")
x34 = InputBox("series reactance of line 34 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 Zbus.
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
QuickBasic:
First example, calculation of the equivalent series resistance or reactance:
CLS
'a program to calculate the equivalent resistance for a set of series resistances
PRINT "The Series of Short Programs for Power Systems Analysts"
PRINT "a program to obtain the equivalent of a few series elements, rev.003/22/96"
INPUT "total number of series resistances or reactances "; n
t! = 0
FOR i = 1 TO n
INPUT " each resistance or reactance branch in ohms"; r!
t! = t! + r!
NEXT i
PRINT " the equivalent resistance or reactance ="; t!
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "Reference: ", refer$
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, "Reference: ", refer$
PRINT #1, "the equivalent resistance or reactance = ", t!
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, "Reference: ", refer$
PRINT #1, "the equivalent resistance or reactance = ", t!
CLOSE #1
END IF
END
Second example, the calculation of the equivalent resistance or reactance of a few parrallel branches:
CLS
'a short program to calculate the equivalent reactance or resistance of a few parallel branches
PRINT "The Series of Short Programs for Power Systems Analysts"
PRINT "a program to obtain the equivalent of a few parallel branches, rev.003/22/96"
INPUT "total number of parallel branches"; n
t! = 0
FOR i = 1 TO n
INPUT "value of each parallel branch in ohms"; r#
t# = t# + 1 / r#
NEXT i
PRINT " the equivalent resistance or reactance ="; 1 / t#
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "Reference: ", refer$
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, "Reference: ", refer$
PRINT #1, "the equivalent resistance or reactance = ", 1 / t#
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, "Reference: ", refer$
PRINT #1, "the equivalent resistance or reactance = ", 1 / t#
CLOSE #1
END IF
END
Third example, wye to delta & vice versa conversion:
DECLARE SUB w (l!, m!, n!)
DECLARE SUB d (x!, y!, z!)
CLS
PRINT "a program to transform from wye to delta and vice versa, rev.003/22/96"
PRINT "The Series of Short Programs for the Power systems analysts"
INPUT "The reactance or resistance in the first leg 1n or 23 "; x
INPUT "The reactance or resistance in the second leg 3n or 12"; y
INPUT "The reactance or resistance in the third leg 2n or 13"; z
PRINT x, y, z
PRINT " The conversion you want to do i.e. if you want to transfer to delta"
INPUT "enter delta if you want to convert to wye enter wye"; con$
IF con$ = "wye" THEN CALL w(x, y, z)
IF con$ = "delta" THEN CALL d(x, y, z)
END
SUB d (x, y, z)
PRINT "The Series of Short programs for Power Systems Analysts"
c = x + y + (x * y / z)
a = y + z + (y * z / x)
b = x + z + (x * z / y)
PRINT "branch 23 = "; a, "branch 12 = "; b, " branch 13 = "; c
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "reference:", refer$
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, "Reference: "; refer$
PRINT #1, "branch 23 = ", a
PRINT #1, "branch 12 = "; b
PRINT #1, "branch 13 = "; c
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, "Reference: "; refer$
PRINT #1, "branch 23 = ", a
PRINT #1, "branch 12 = "; b
PRINT #1, "branch 13 = "; c
CLOSE #1
END IF
END SUB
SUB w (l, m, n)
e = (l * m) / (l + m + n)
f = (l * n) / (l + m + n)
g = (m * n) / (l + m + n)
PRINT "branch 2n = "; e, "branch 3n = "; f, "branch 1n = "; g
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "reference: "; refer$
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, "Reference: "; refer$
PRINT #1, "branch 2n = "; e
PRINT #1, "branch 3n = "; f
PRINT #1, "branch 1n = "; g
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, "Reference: "; refer$
PRINT #1, "branch 2n = "; e
PRINT #1, "branch 3n = "; f
PRINT #1, "branch 1n = "; g
CLOSE #1
END IF
END SUB
Fourth example, matrix manipulation (matrix inversion to solve 2 & 3 simultaneous equations):
DECLARE SUB u ()
DECLARE SUB v ()
CLS
' a program to transpose and invert matrices.
PRINT "The Series of Short Programs for Power Systems Analysts"
PRINT "a program to invert 2 and 3 row square matrices"
INPUT "the square matrix has number of columns/rows n = ", n
IF n = 2 THEN CALL u
IF n = 3 THEN CALL v
END
SUB u
LOCATE 3, 1
PRINT STRING$(60, "")
LOCATE 25, 1
PRINT STRING$(60, "")
VIEW PRINT 4 TO 15
INPUT "a11 = ", a11!
INPUT "a12 = ", a12!
INPUT "a21 = ", a21!
INPUT "a22 = ", a22!
PRINT " transpose of matrix yield the following elements respectively a11,a12,a21,a22"
PRINT a11!, a21!, a12!, a22!
PRINT "inverse of matrix yield the following elements respectively a11,a12,a21,a22"
LET d1 = ((a11! * a22!) (a12! * a21!))
PRINT "determinant of matrix", d1
PRINT (a22 / d1), (a12 / d1), (a21 / d1), (a11 / d1)
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
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$
PRINT #1, " transpose of matrix yield the following elements respectively a11,a12,a21,a22"
PRINT #1, a11!, a21!, a12!, a22!
PRINT #1, "inverse of matrix yield the following elements respectively a11,a12,a21,a22"
PRINT #1, "determinant of matrix", d1
PRINT #1, (a22 / d1), (a12 / d1), (a21 / d1), (a11 / d1)
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, " transpose of matrix yield the following elements respectively a11,a12,a21,a22"
PRINT #1, a11!, a21!, a12!, a22!
PRINT #1, "inverse of matrix yield the following elements respectively a11,a12,a21,a22"
PRINT #1, "determinant of matrix", d1
PRINT #1, (a22 / d1), (a12 / d1), (a21 / d1), (a11 / d1)
CLOSE #1
END IF
END SUB
SUB v
INPUT "a11 = ", b11
INPUT "a12 = ", b12
INPUT "a13 = ", b13
INPUT "a21 = ", b21
INPUT "a22 = ", b22
INPUT "a23 = ", b23
INPUT "a31 = ", b31
INPUT "a32 = ", b32
INPUT "a33 = ", b33
PRINT "the transpose of matrix yields a11,a12,a13,a21,a22,a23,a31,a32,a33, respectively"
PRINT b11, b21, b31
PRINT b12, b22, b32
PRINT b13, b23, b33
d = (b11 * (b22 * b33 b32 * b23)) (b12 * (b21 * b33 b23 * b31)) + (b13 * (b21 * b32 b22 * b31))
PRINT "determinant = ", d
PRINT "inverse of matrix yields the elements a11,a12,a13,a21,a22,a23,a31,a32,a33, respectively"
PRINT (b22 * b33 b23 * b32) / d, (b12 * b33 b13 * b32) / d, (b12 * b23 b13 * b22) / d
PRINT (b21 * b33 b31 * b23) / d, (b11 * b33 b13 * b31) / d, (b11 * b23 b13 * b21) / d
PRINT (b21 * b32 b31 * b22) / d, (b11 * b32 b12 * b31) / d, (b11 * b22 b21 * b12) / d
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
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$
PRINT #1, "the transpose of matrix yields a11,a12,a13,a21,a22,a23,a31,a32,a33, respectively"
PRINT #1, b11, b21, b31
PRINT #1, b12, b22, b32
PRINT #1, b13, b23, b33
PRINT #1, "determinant = ", d
PRINT #1, "inverse of matrix yields the elements a11,a12,a13,a21,a22,a23,a31,a32,a33, respectively"
PRINT #1, (b22 * b33 b23 * b32) / d, (b12 * b33 b13 * b32) / d, (b12 * b23 b13 * b22) / d
PRINT #1, (b21 * b33 b31 * b23) / d, (b11 * b33 b13 * b31) / d, (b11 * b23 b13 * b21) / d
PRINT #1, (b21 * b32 b31 * b22) / d, (b11 * b32 b12 * b31) / d, (b11 * b22 b21 * b12) / d
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, "the transpose of matrix yields a11,a12,a13,a21,a22,a23,a31,a32,a33, respectively"
PRINT #1, b11, b21, b31
PRINT #1, b12, b22, b32
PRINT #1, b13, b23, b33
PRINT #1, "determinant = ", d
PRINT #1, "inverse of matrix yields the elements a11,a12,a13,a21,a22,a23,a31,a32,a33, respectively"
PRINT #1, (b22 * b33 b23 * b32) / d, (b12 * b33 b13 * b32) / d, (b12 * b23 b13 * b22) / d
PRINT #1, (b21 * b33 b31 * b23) / d, (b11 * b33 b13 * b31) / d, (b11 * b23 b13 * b21) / d
PRINT #1, (b21 * b32 b31 * b22) / d, (b11 * b32 b12 * b31) / d, (b11 * b22 b21 * b12) / d
CLOSE #1
END IF
END SUB
Fifth example, the solution of 6 simultaneous equations using gaussian elimination & triangular
factorization methods:
CLS
PRINT "The Series of Short Programs for Power Systems Analysts"
PRINT "gaussian elimination equation solving for 6x6 matrix with a chain to the 5x5 and 8x8
programs"
INPUT "matrix size: if 5x5 enter 1, if 6x6, enter 2; if 8x8, enter 3 = "; mxs1
IF mxs1 = 1 THEN CHAIN "gauss5x5"
IF mxs1 = 3 THEN CHAIN "gauss8x8"
PRINT "gaussian elimination process for a 6 by 6 matrix, rev.003/22/96"
INPUT "Y11 = ", y11
INPUT "Y12 = ", y12
INPUT "Y13 = ", y13
INPUT "Y14 = ", y14
INPUT "Y15 = ", y15
INPUT "Y16 = ", y16
INPUT "Y21 = ", y21
INPUT "Y22 = ", y22
INPUT "Y23 = ", y23
INPUT "Y24 = ", y24
INPUT "Y25 = ", y25
INPUT "Y26 = ", y26
INPUT "Y31 = ", y31
INPUT "Y32 = ", y32
INPUT "Y33 = ", y33
INPUT "Y34 = ", y34
INPUT "Y35 = ", y35
INPUT "Y36 = ", y36
INPUT "Y41 = ", y41
INPUT "Y42 = ", y42
INPUT "Y43 = ", y43
INPUT "Y44 = ", y44
INPUT "Y45 = ", y45
INPUT "Y46 = ", y46
INPUT "Y51 = ", y51
INPUT "Y52 = ", y52
INPUT "Y53 = ", y53
INPUT "Y54 = ", y54
INPUT "Y55 = ", y55
INPUT "Y56 = ", y56
INPUT "Y61 = ", y61
INPUT "Y62 = ", y62
INPUT "Y63 = ", y63
INPUT "Y64 = ", y64
INPUT "Y65 = ", y65
INPUT "Y66 = ", y66
y110 = y11 / y11
y120 = y12 / y11
y130 = y13 / y11
y140 = y14 / y11
y150 = y15 / y11
y160 = y16 / y11
y220 = y22 (y21) * (y12) / (y11)
y230 = y23 (y21) * (y13) / (y11)
y240 = y24 (y21) * (y14) / y11
y250 = y25 (y21) * (y15) / y11
y260 = y26 (y21) * (y16) / y11
y320 = y32 (y31) * (y12) / y11
y330 = y33 (y31) * (y13) / y11
y340 = y34 (y31) * (y14) / y11
y350 = y35 (y31) * (y15) / y11
y360 = y36 (y31) * (y16) / y11
y420 = y42 (y41) * (y12) / y11
y430 = y43 (y41) * (y13) / y11
y440 = y44 (y41) * (y14) / y11
y450 = y45 (y41) * (y15) / y11
y460 = y46 (y41) * (y16) / y11
y520 = y52 (y51) * (y12) / y11
y530 = y53 (y51) * (y13) / y11
y540 = y54 (y51) * (y14) / y11
y550 = y55 (y51) * (y15) / y11
y560 = y56 (y51) * (y16) / y11
y620 = y62 (y61) * (y12) / y11
y630 = y63 (y61) * (y13) / y11
y640 = y64 (y61) * (y14) / y11
y650 = y65 (y61) * (y15) / y11
y660 = y66 (y61) * (y16) / y11
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
PRINT "the L matrix of the triangular factorization ="
PRINT y11
PRINT y21, y220
PRINT y31, y320, y331
PRINT y41, y420, y431, y442
PRINT y51, y520, y531, y542, y553
PRINT y61, y620, y631, y642, y653, y664
PRINT "the U matrix of the triangular factorization ="
PRINT y110, y120, y130, y140, y150, y160
PRINT y211, y221, y231, y241, y251, y261
PRINT y312, y322, y332, y342, y352, y362
PRINT y413, y423, y433, y443, y453, y463
PRINT y514, y524, y534, y544, y554, y564
PRINT 0, 0, 0, 0, 1
INPUT "mismatch1 or right hand side of equation 1"; i1
INPUT "mismatch1 or right hand side of equation 2"; i2
INPUT "mismatch1 or right hand side of equation 3"; i3
INPUT "mismatch1 or right hand side of equation 4"; i4
INPUT "mismatch1 or right hand side of equation 5"; i5
INPUT "mismatch1 or right hand side of equation 6"; i6
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
v6 = (i6 (v1) * (y61) (y620) * (v2) (y631) * (v3) (y642) * (v4) (y653) * (v5)) / y664
f6 = v6
f5 = (v5 ((y564) * (f6)))
f4 = (v4 ((y453) * (f5)) ((y463) * (f6)))
f3 = (v3 ((y342) * (f4)) ((y352) * (f5)) ((y362) * (f6)))
f2 = (v2 ((y231) * (f3)) ((y241) * (f4)) ((y251) * (f5)) ((y261) * (f6)))
f1 = (v1 ((y120) * (f2)) ((y130) * (f3)) ((y140) * (f4)) ((y150) * (f5)) ((y160) * (f6)))
PRINT "f1, f2, f3, f4, f5, f6 = "; f1; f2; f3; f4; f5; f6
INPUT "project name"; projnam$
INPUT "prepared by"; pb$
INPUT "project number:"; projnum$
INPUT "date:"; da$
INPUT "enter 1 to overwrite or 2 to append file "; 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, "the 6 variables f1,f2,f3,f4,f5,f6 are equal respectively: "; f1, f2, f3, f4, f5, f6
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, "the 6 variables f1,f2,f3,f4,f5 are equal respectively: "; f1, f2, f3, f4, f5, f6
CLOSE #1
END IF
Sixth example, per unit calculation:
DECLARE SUB z (z1, z2, z3)
DECLARE SUB c (c1, c2, c3)
DECLARE SUB b (b1, b2, b3)
DECLARE SUB a (a1, a2, a3)
CLS
PRINT "The Series of Short Programs for Power Systems Ananlysts"
PRINT "a program to calculate the base currents and the per unit values of resistance/reactance in a
network"
INPUT "base voltage in KV = "; vb
INPUT "base apparent power (MVA) in mva = "; vab
ib = (vab * 1000) / (vb * 1.7320508#)
PRINT "base volt, MVA, current respectively = "; vb, vab, ib
impb = vb / ib
PRINT "number of base voltage in a system = number of transformers + 1"
INPUT "number of transformers is "; ntr
IF ntr = 2 THEN CALL a(vb, vab, ib)
IF ntr = 4 THEN CALL b(vb, vab, ib)
IF ntr = 6 THEN CALL c(vb, vab, ib)
IF ntr = 1 THEN CALL z(vb, vab, ib)
SUB a (a1, a2, a3)
PRINT "base voltage on the primary of the first transformer = base voltage entered previously"
INPUT " primary voltage of first transfo. = "; prim1
INPUT "secondary voltage of first transfo. = "; sec1
INPUT "primary of second transfo. = "; prim2
INPUT "secondary of second transfo. = "; sec2
vb1 = a1 * sec1 / (prim1)
vb2 = vb1 * sec2 / (prim2)
ib1 = (a2 * 1000) / (vb1 * 1.7320508#)
ib2 = (a2 * 1000) / (vb2 * 1.7320508#)
INPUT "the mva rating of transformer 1 = "; mva1
INPUT " the mva rating of transformer 2 = "; mva2
INPUT "the % reactance of transformer 1 based on its VA and V ratings"; react1
INPUT "the % reactance of transformer 2 based on its VA and V ratings"; react2
INPUT "the reactance of the line in ohms"; reactl1
INPUT "total number of motors ( or generators) "; load
reactlpu = (reactl1) * (a2) / ((vb1) ^ 2)
IF load = 1 THEN
INPUT "reactance of load1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
load1pu = lreact1 * (a2 / lmva1) * ((lkv1 / vb2) ^ 2)
END IF
IF load = 2 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
load1pu = lreact1 * (a2 / lmva1) * ((lkv1 / vb2) ^ 2)
load2pu = lreact2 * (a2 / lmva2) * ((lkv2 / vb2) ^ 2)
END IF
IF load = 3 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
INPUT "react. of load 3 = "; lreact3
INPUT "apparent power rating of load 3 in mva = "; lmva3
INPUT "voltage rating of load 3 in KV = "; lkv3
load1pu = lreact1 * (a2 / lmva1) * ((lkv1 / vb2) ^ 2)
load2pu = lreact2 * (a2 / lmva2) * ((lkv2 / vb2) ^ 2)
load3pu = lreact3 * (a2 / lmva3) * ((lkv3 / vb2) ^ 2)
END IF
reactpu1 = react1 * (a2 / mva1) * ((prim1 / a1) ^ 2)
reactpu2 = react2 * (a2 / mva2) * ((prim2 / vb1) ^ 2)
PRINT " the p.u. values on base mva and base KV for the tr.1, line 1, tr.2, loads (or generators
connected to the secondary of transfo. 2 = "; reactpu1, reactlpu, reactpu2, load1pu, load2pu, load3pu
PRINT "base current in second and third segments, respectively = "; ib1, ib2
INPUT "if loads include lighting or heaters or the like, enter 1"; heat
IF heat = 1 THEN
INPUT "load mw = "; mw
INPUT "p.f. = "; pf
INPUT "bus voltage = "; bv
PRINT " p.u. volt and current, espectively ="; bv / vb2; (mw * (1000) / (1.732 * bv * pf)) / ib2
END IF
END SUB
SUB b (b1, b2, b3)
PRINT "base voltage on the primary of the first transformer = base voltage entered previously"
INPUT " primary voltage of first transfo. = "; prim1
INPUT "secondary voltage of first transfo. = "; sec1
INPUT "primary of second transfo. = "; prim2
INPUT "secondary of second transfo. = "; sec2
INPUT "primary of third transfo. = "; prim3
INPUT "secondary of third transfo. = "; sec3
INPUT "primary of fourth transfo. = "; prim4
INPUT "secondary of fourth transfo. = "; sec4
vb1 = b1 * sec1 / (prim1)
vb2 = vb1 * sec2 / (prim2)
vb3 = vb2 * sec3 / (prim3)
vb4 = vb3 * sec4 / (prim4)
ib1 = (b2 * 1000) / (vb1 * 1.7320508#)
ib2 = (b2 * 1000) / (vb2 * 1.7320508#)
ib3 = (b2 * 1000) / (vb3 * 1.7320508#)
ib4 = (b2 * 1000) / (vb4 * 1.7320508#)
INPUT "the mva rating of transformer 1 = "; mva1
INPUT " the mva rating of transformer 2 = "; mva2
INPUT " the mva rating of transformer 3 = "; mva3
INPUT " the mva rating of transformer 4 = "; mva4
INPUT "the % reactance of transformer 1 based on its VA and V ratings"; react1
INPUT "the % reactance of transformer 2 based on its VA and V ratings"; react2
INPUT "the % reactance of transformer 3 based on its VA and V ratings"; react3
INPUT "the % reactance of transformer 4 based on its VA and V ratings"; react4
INPUT "the reactance of the line in ohms"; reactl1
INPUT "the reactance of the line between sec. of tr. 3 and prim. of tr. 4 in ohms"; reactl2
INPUT "total number of motors ( or generators) on sec. of transfo. 2 = "; load
reactlpu = (reactl1) * (b2) / ((vb1) ^ 2)
reaclpu2 = (reactl2) * (b2) / ((vb3) ^ 2)
IF load = 1 THEN
INPUT "reactance of load1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
load1pu = lreact1 * (b2 / lmva1) * ((lkv1 / vb2) ^ 2)
END IF
IF load = 2 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
load1pu = lreact1 * (b2 / lmva1) * ((lkv1 / vb2) ^ 2)
load2pu = lreact2 * (b2 / lmva2) * ((lkv2 / vb2) ^ 2)
END IF
IF load = 3 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
INPUT "react. of load 3 = "; lreact3
INPUT "apparent power rating of load 3 in mva = "; lmva3
INPUT "voltage rating of load 3 in KV = "; lkv3
load1pu = lreact1 * (b2 / lmva1) * ((lkv1 / vb2) ^ 2)
load2pu = lreact2 * (b2 / lmva2) * ((lkv2 / vb2) ^ 2)
load3pu = lreact3 * (b2 / lmva3) * ((lkv3 / vb2) ^ 2)
END IF
reacpu11 = react1 * (b2 / mva1) * ((prim1 / b1) ^ 2)
reacpu21 = react2 * (b2 / mva2) * ((prim2 / vb1) ^ 2)
reacpu31 = react3 * (b2 / mva3) * ((prim3 / vb2) ^ 2)
reacpu41 = react4 * (b2 / mva4) * ((prim4 / vb3) ^ 2)
INPUT "if loads include lighting or heaters or the like on sec. of tr. 2, enter 1"; heat
IF heat = 1 THEN
INPUT "load mw = "; mw
INPUT "p.f. = "; pf
INPUT "bus voltage = "; bv
END IF
INPUT "total number of motors ( or generators) on sec. of tr. 4 = "; load1
IF load1 = 1 THEN
INPUT "reactance of load1 = "; lreact11
INPUT "apparent power rating of load 1 in mva = "; lmva11
INPUT "voltage rating of load 1 in KV = "; lkv11
load1pu1 = lreact11 * (b2 / lmva11) * ((lkv11 / vb4) ^ 2)
END IF
IF load1 = 2 THEN
INPUT "reactance of load 1 = "; lreact11
INPUT "apparent power rating of load 1 in mva = "; lmva11
INPUT "voltage rating of load 1 in KV = "; lkv11
INPUT "react. of load 2 = "; lreact21
INPUT "apparent power rating of load 2 in mva = "; lmva21
INPUT "voltage rating of load 2 in KV = "; lkv21
load1pu1 = lreact11 * (b2 / lmva11) * ((lkv11 / vb4) ^ 2)
load2pu1 = lreact21 * (b2 / lmva21) * ((lkv21 / vb4) ^ 2)
END IF
IF load1 = 3 THEN
INPUT "reactance of load 1 = "; lreact11
INPUT "apparent power rating of load 1 in mva = "; lmva11
INPUT "voltage rating of load 1 in KV = "; lkv11
INPUT "react. of load 2 = "; lreact21
INPUT "apparent power rating of load 2 in mva = "; lmva21
INPUT "voltage rating of load 2 in KV = "; lkv21
INPUT "react. of load 3 = "; lreact31
INPUT "apparent power rating of load 3 in mva = "; lmva31
INPUT "voltage rating of load 3 in KV = "; lkv31
load1pu1 = lreact11 * (b2 / lmva11) * ((lkv11 / vb4) ^ 2)
load2pu1 = lreact21 * (b2 / lmva21) * ((lkv21 / vb4) ^ 2)
load3pu1 = lreact31 * (b2 / lmva31) * ((lkv31 / vb4) ^ 2)
END IF
PRINT " the p.u. values on base mva and base KV for the tr.1, line 1, tr.2, loads (or generators
connected to the secondary of transfo. 2, transfo. 3, loads on sec. of transfo. 2, line 2, transfo. 4 and
loads on sec. of transfo. 4 = "
PRINT reacpu11, reactlpu, reacpu21, load1pu, load2pu, load3pu, reacpu31, reaclpu2, reacpu41,
load1pu1, load2pu1, lod3pu1
PRINT "base current in second, third, fourth and fifth segments, respectively = "; ib1, ib2, ib3, ib4
INPUT "if loads include lighting or heaters or the like on sec. of tr. 6, enter 1"; heat
IF heat1 = 1 THEN
INPUT "load mw = "; mw1
INPUT "p.f. = "; pf1
INPUT "bus voltage = "; bv1
PRINT " p.u. volt and current on buses 2 and 4, respectively ="; bv / vb2; (mw * (1000) / (1.732 * bv *
pf)) / ib2; bv1 / vb4; (mw1 * (1000) / (1.732 * bv1 * pf1)) / ib4
END IF
END SUB
SUB c (c1, c2, c3)
PRINT "base voltage on the primary of the first transformer = base voltage entered previously"
INPUT " primary voltage of first transfo. = "; prim1
INPUT "secondary voltage of first transfo. = "; sec1
INPUT "primary of second transfo. = "; prim2
INPUT "secondary of second transfo. = "; sec2
INPUT "primary of third transfo. = "; prim3
INPUT "secondary of third transfo. = "; sec3
INPUT "primary of fourth transfo. = "; prim4
INPUT "secondary of fourth transfo. = "; sec4
INPUT "primary of fifth transfo. = "; prim5
INPUT "secondary of fifth transfo. = "; sec5
INPUT "primary of sixth transfo. = "; prim6
INPUT "secondary of sith transfo. = "; sec6
vb1 = c1 * sec1 / (prim1)
vb2 = vb1 * sec2 / (prim2)
vb3 = vb2 * sec3 / (prim3)
vb4 = vb3 * sec4 / (prim4)
vb5 = vb4 * sec3 / (prim5)
vb6 = vb5 * sec4 / (prim6)
ib1 = (c2 * 1000) / (vb1 * 1.7320508#)
ib2 = (c2 * 1000) / (vb2 * 1.7320508#)
ib3 = (c2 * 1000) / (vb3 * 1.7320508#)
ib4 = (c2 * 1000) / (vb4 * 1.7320508#)
ib5 = (c2 * 1000) / (vb3 * 1.7320508#)
ib6 = (c2 * 1000) / (vb4 * 1.7320508#)
INPUT "the mva rating of transformer 1 = "; mva1
INPUT " the mva rating of transformer 2 = "; mva2
INPUT " the mva rating of transformer 3 = "; mva3
INPUT " the mva rating of transformer 4 = "; mva4
INPUT " the mva rating of transformer 5 = "; mva5
INPUT " the mva rating of transformer 6 = "; mva6
INPUT "the % reactance of transformer 1 based on its VA and V ratings"; react1
INPUT "the % reactance of transformer 2 based on its VA and V ratings"; react2
INPUT "the % reactance of transformer 3 based on its VA and V ratings"; react3
INPUT "the % reactance of transformer 4 based on its VA and V ratings"; react4
INPUT "the % reactance of transformer 5 based on its VA and V ratings"; react5
INPUT "the % reactance of transformer 6 based on its VA and V ratings"; react6
INPUT "the reactance of the line in ohms"; reactl1
INPUT "the reactance of the line between sec. of tr. 3 and prim. of tr. 4 in ohms"; reactl2
INPUT "the reactance of the line between sec. of tr. 5 and prim. of tr. 6 in ohms"; reactl3
INPUT "total number of motors ( or generators) on sec. of transfo. 2 = "; load
reactlpu = (reactl1) * (c2) / ((vb1) ^ 2)
reaclpu2 = (reactl2) * (c2) / ((vb3) ^ 2)
reaclpu3 = (reactl3) * (c2) / ((vb3) ^ 2)
IF load = 1 THEN
INPUT "reactance of load1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
load1pu = lreact1 * (c2 / lmva1) * ((lkv1 / vb2) ^ 2)
END IF
IF load = 2 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
load1pu = lreact1 * (c2 / lmva1) * ((lkv1 / vb2) ^ 2)
load2pu = lreact2 * (c2 / lmva2) * ((lkv2 / vb2) ^ 2)
END IF
IF load = 3 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
INPUT "react. of load 3 = "; lreact3
INPUT "apparent power rating of load 3 in mva = "; lmva3
INPUT "voltage rating of load 3 in KV = "; lkv3
load1pu = lreact1 * (c2 / lmva1) * ((lkv1 / vb2) ^ 2)
load2pu = lreact2 * (c2 / lmva2) * ((lkv2 / vb2) ^ 2)
load3pu = lreact3 * (c2 / lmva3) * ((lkv3 / vb2) ^ 2)
END IF
reacpu11 = react1 * (c2 / mva1) * ((prim1 / c1) ^ 2)
reacpu21 = react2 * (c2 / mva2) * ((prim2 / vb1) ^ 2)
reacpu31 = react3 * (c2 / mva3) * ((prim3 / vb2) ^ 2)
reacpu41 = react4 * (c2 / mva4) * ((prim4 / vb3) ^ 2)
reacpu51 = react5 * (c2 / mva5) * ((prim5 / vb4) ^ 2)
reacpu61 = react6 * (c2 / mva6) * ((prim6 / vb5) ^ 2)
INPUT "if loads include lighting or heaters or the like on sec. of tr. 2, enter 1"; heat
IF heat = 1 THEN
INPUT "load mw = "; mw
INPUT "p.f. = "; pf
INPUT "bus voltage = "; bv
END IF
INPUT "total number of motors ( or generators) on sec. of tr. 4 = "; load1
IF load1 = 1 THEN
INPUT "reactance of load1 = "; lreact11
INPUT "apparent power rating of load 1 in mva = "; lmva11
INPUT "voltage rating of load 1 in KV = "; lkv11
load1pu1 = lreact11 * (c2 / lmva11) * ((lkv11 / vb4) ^ 2)
END IF
IF load1 = 2 THEN
INPUT "reactance of load 1 = "; lreact11
INPUT "apparent power rating of load 1 in mva = "; lmva11
INPUT "voltage rating of load 1 in KV = "; lkv11
INPUT "react. of load 2 = "; lreact21
INPUT "apparent power rating of load 2 in mva = "; lmva21
INPUT "voltage rating of load 2 in KV = "; lkv21
load1pu1 = lreact11 * (c2 / lmva11) * ((lkv11 / vb4) ^ 2)
load2pu1 = lreact21 * (c2 / lmva21) * ((lkv21 / vb4) ^ 2)
END IF
IF load1 = 3 THEN
INPUT "reactance of load 1 = "; lreact11
INPUT "apparent power rating of load 1 in mva = "; lmva11
INPUT "voltage rating of load 1 in KV = "; lkv11
INPUT "react. of load 2 = "; lreact21
INPUT "apparent power rating of load 2 in mva = "; lmva21
INPUT "voltage rating of load 2 in KV = "; lkv21
INPUT "react. of load 3 = "; lreact31
INPUT "apparent power rating of load 3 in mva = "; lmva31
INPUT "voltage rating of load 3 in KV = "; lkv31
load1pu1 = lreact11 * (c2 / lmva11) * ((lkv11 / vb4) ^ 2)
load2pu1 = lreact21 * (c2 / lmva21) * ((lkv21 / vb4) ^ 2)
load3pu1 = lreact31 * (c2 / lmva31) * ((lkv31 / vb4) ^ 2)
END IF
INPUT "if loads include lighting or heaters or the like on sec. of tr. 4, enter 1"; heat1
IF heat1 = 1 THEN
INPUT "load mw = "; mw1
INPUT "p.f. = "; pf1
INPUT "bus voltage = "; bv1
END IF
INPUT "total number of motors ( or generators) on sec. of tr. 6 = "; load2
IF load2 = 1 THEN
INPUT "reactance of load1 = "; lreact12
INPUT "apparent power rating of load 1 in mva = "; lmva12
INPUT "voltage rating of load 1 in KV = "; lkv12
load1pu2 = lreact12 * (c2 / lmva12) * ((lkv12 / vb6) ^ 2)
END IF
IF load2 = 2 THEN
INPUT "reactance of load 1 = "; lreact12
INPUT "apparent power rating of load 1 in mva = "; lmva12
INPUT "voltage rating of load 1 in KV = "; lkv12
INPUT "react. of load 2 = "; lreact22
INPUT "apparent power rating of load 2 in mva = "; lmva22
INPUT "voltage rating of load 2 in KV = "; lkv22
load1pu2 = lreact12 * (c2 / lmva12) * ((lkv12 / vb6) ^ 2)
load2pu2 = lreact22 * (c2 / lmva22) * ((lkv22 / vb6) ^ 2)
END IF
IF load2 = 3 THEN
INPUT "reactance of load 1 = "; lreact12
INPUT "apparent power rating of load 1 in mva = "; lmva12
INPUT "voltage rating of load 1 in KV = "; lkv12
INPUT "react. of load 2 = "; lreact22
INPUT "apparent power rating of load 2 in mva = "; lmva22
INPUT "voltage rating of load 2 in KV = "; lkv22
INPUT "react. of load 3 = "; lreact32
INPUT "apparent power rating of load 3 in mva = "; lmva32
INPUT "voltage rating of load 3 in KV = "; lkv32
load1pu2 = lreact12 * (c2 / lmva12) * ((lkv12 / vb6) ^ 2)
load2pu2 = lreact22 * (c2 / lmva22) * ((lkv22 / vb6) ^ 2)
load3pu2 = lreact32 * (c2 / lmva32) * ((lkv32 / vb6) ^ 2)
END IF
PRINT " the p.u. values on base mva and base KV for the tr.1, line 1, tr.2, loads (or generators
connected to the secondary of tr.2, tr.3, loads on sec. of tr.2, line 2, tr.4 and loads on sec. of tr.4, tr.5,
line 3, tr.6, and loads on tr.6 = "
PRINT reacpu11, reactlpu, reacpu21, load1pu, load2pu, load3pu, reacpu31, reaclpu2, reacpu41,
load1pu1, load2pu1, load3pu1, reacpu51, reaclpu3, reacpu61, load1pu2, load2pu, load3pu2
PRINT "base current in second, third, fourth, fifth, sixth and seventh segments, respectively = "; ib1,
ib2, ib3, ib4, ib5, ib6
INPUT "if loads include lighting or heaters or the like on sec. of tr. 6, enter 1"; heat2
IF heat2 = 1 THEN
INPUT "load mw = "; mw2
INPUT "p.f. = "; pf2
INPUT "bus voltage = "; bv2
PRINT " p.u. volt and current on buses 2, 4 and 6, respectively ="; bv / vb2; (mw * (1000) / (1.732 * bv
* pf)) / ib2; bv1 / vb4; (mw1 * (1000) / (1.732 * bv1 * pf1)) / ib4, bv2 / vb6; (mw2 * (1000) / (1.732 *
bv2 * pf2)) / ib6
END IF
END SUB
SUB z (z1, z2, z43)
PRINT "base voltage on the primary of the first transformer = base voltage entered previously"
INPUT " primary voltage of first transfo. = "; prim1
INPUT "secondary voltage of first transfo. = "; sec1
INPUT "number of buses on the sec. of transformer (including the sec. wdg. bus):", bn
INPUT "the mva rating of transformer 1 = "; mva1
vb1 = z1 * sec1 / (prim1)
ib1 = (z2 * 1000) / (vb1 * 1.7320508#)
IF bn = 2 OR 1 THEN
INPUT "the % reactance of transformer 1 based on its VA and V ratings"; react1
INPUT "the reactance of the line (between bus 1 and 2) in ohms"; reactl1
INPUT "total number of motors ( or generators) at bus 1 "; load
reactlpu = (reactl1) * (z2) / ((vb1) ^ 2)
IF load = 1 THEN
INPUT "reactance of load1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
END IF
IF load = 2 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
END IF
IF load = 3 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
INPUT "react. of load 3 = "; lreact3
INPUT "apparent power rating of load 3 in mva = "; lmva3
INPUT "voltage rating of load 3 in KV = "; lkv3
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
load3pu = lreact3 * (z2 / lmva3) * ((lkv3 / vb1) ^ 2)
END IF
reactpu1 = react1 * (z2 / mva1) * ((prim1 / z1) ^ 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,
INPUT "if loads include lighting or heaters or the like, enter 1"; heat
IF heat = 1 THEN
INPUT "load mw = "; mw
INPUT "p.f. = "; pf
INPUT "bus voltage = "; bv
PRINT " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1
END IF
END IF
IF bn = 3 THEN
INPUT "the % reactance of transformer 1 based on its VA and V ratings"; react1
INPUT "the reactance of the line (between bus 1 and 2) in ohms"; reactl1
INPUT "the reactance of the line (between bus 2 and 3) in ohms"; reactl2
INPUT "total number of motors ( or generators) at bus 1 "; load
reactlpu = (reactl1) * (z2) / ((vb1) ^ 2)
reaclpu1 = (reactl2) * (z2) / ((vb1) ^ 2)
IF load = 1 THEN
INPUT "reactance of load1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
END IF
IF load = 2 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
END IF
IF load = 3 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
INPUT "react. of load 3 = "; lreact3
INPUT "apparent power rating of load 3 in mva = "; lmva3
INPUT "voltage rating of load 3 in KV = "; lkv3
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
load3pu = lreact3 * (z2 / lmva3) * ((lkv3 / vb1) ^ 2)
END IF
reactpu1 = react1 * (z2 / mva1) * ((prim1 / z1) ^ 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
INPUT "if loads include lighting or heaters or the like, enter 1"; heat
IF heat = 1 THEN
INPUT "load mw = "; mw
INPUT "p.f. = "; pf
INPUT "bus voltage = "; bv
PRINT " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1
END IF
END IF
IF bn = 4 THEN
INPUT "the % reactance of transformer 1 based on its VA and V ratings"; react1
INPUT "the reactance of the line (between bus 1 and 2) in ohms"; reactl1
INPUT "the reactance of the line (between bus 2 and 3) in ohms"; reactl2
INPUT "the reactance of the line (between bus 3 and 4) in ohms"; reactl3
INPUT "total number of motors ( or generators) at bus 1 "; load
reactlpu = (reactl1) * (z2) / ((vb1) ^ 2)
reaclpu1 = (reactl2) * (z2) / ((vb1) ^ 2)
reaclpu2 = (reactl3) * (z2) / ((vb1) ^ 2)
IF load = 1 THEN
INPUT "reactance of load1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
END IF
IF load = 2 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
END IF
IF load = 3 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
INPUT "react. of load 3 = "; lreact3
INPUT "apparent power rating of load 3 in mva = "; lmva3
INPUT "voltage rating of load 3 in KV = "; lkv3
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
load3pu = lreact3 * (z2 / lmva3) * ((lkv3 / vb1) ^ 2)
END IF
reactpu1 = react1 * (z2 / mva1) * ((prim1 / z1) ^ 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
INPUT "if loads include lighting or heaters or the like, enter 1"; heat
IF heat = 1 THEN
INPUT "load mw = "; mw
INPUT "p.f. = "; pf
INPUT "bus voltage = "; bv
PRINT " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1
END IF
END IF
IF bn = 5 THEN
INPUT "the % reactance of transformer 1 based on its VA and V ratings"; react1
INPUT "the reactance of the line (between bus 1 and 2) in ohms"; reactl1
INPUT "the reactance of the line (between bus 2 and 3) in ohms"; reactl2
INPUT "the reactance of the line (between bus 3 and 4) in ohms"; reactl3
INPUT "the reactance of the line (between bus 4 and 5) in ohms"; reactl4
INPUT "total number of motors ( or generators) at bus 1 "; load
reactlpu = (reactl1) * (z2) / ((vb1) ^ 2)
reaclpu1 = (reactl2) * (z2) / ((vb1) ^ 2)
reaclpu2 = (reactl3) * (z2) / ((vb1) ^ 2)
reaclpu3 = (reactl4) * (z2) / ((vb1) ^ 2)
IF load = 1 THEN
INPUT "reactance of load1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
END IF
IF load = 2 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
END IF
IF load = 3 THEN
INPUT "reactance of load 1 = "; lreact1
INPUT "apparent power rating of load 1 in mva = "; lmva1
INPUT "voltage rating of load 1 in KV = "; lkv1
INPUT "react. of load 2 = "; lreact2
INPUT "apparent power rating of load 2 in mva = "; lmva2
INPUT "voltage rating of load 2 in KV = "; lkv2
INPUT "react. of load 3 = "; lreact3
INPUT "apparent power rating of load 3 in mva = "; lmva3
INPUT "voltage rating of load 3 in KV = "; lkv3
load1pu = lreact1 * (z2 / lmva1) * ((lkv1 / vb1) ^ 2)
load2pu = lreact2 * (z2 / lmva2) * ((lkv2 / vb1) ^ 2)
load3pu = lreact3 * (z2 / lmva3) * ((lkv3 / vb1) ^ 2)
END IF
reactpu1 = react1 * (z2 / mva1) * ((prim1 / z1) ^ 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
INPUT "if loads include lighting or heaters or the like, enter 1"; heat
IF heat = 1 THEN
INPUT "load mw = "; mw
INPUT "p.f. = "; pf
INPUT "bus voltage = "; bv
PRINT " p.u. volt and current, espectively ="; bv / vb1; (mw * (1000) / (1.732 * bv * pf)) / ib1
END IF
END IF
END SUB
Seventh example, Zbus modeling:
DECLARE SUB d (b1!, b2!, b3!, b4!, b5!, b6!, b7!, b8!, b9!, b10!, b11!, b12!, b13!, b14!, b15!, b16!,
b17!)
DECLARE SUB c (a1!, a2!, a3!, a4!, a5!, a6!, a7!, a8!, a9!, a10!, a11!, a12!, a13!, a14!, a15!, a16!,
a17!)
DECLARE SUB b (x11b, x12b, x13b, x21b, x22b, x23b, x31b, x32b, x33b, x03, x34)
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
COMMON SHARED x11f, x12f, x13f, x14f, x21f, x22f, x23f, x24f, x31f, x32f, x33f, x34f, x41f, x42f,
x43f, x44f
COMMON SHARED x11f1, x12f1, x13f1, x14f1, x21f1, x22f1, x23f1, x24f1, x31f1, x32f1, x33f1,
x34f1, x41f1, x42f1, x43f1, x44f1
CLS
PRINT "The Series of Short Programs for Power Systems Analysts"
PRINT "a program to calculate the impedance bus matrix for 4 buses, with 3 sources and x31=0"
INPUT "reactance between reference node and bus 1=", x01
INPUT "reactance between reference node and bus 2=", x02
INPUT "reactance between reference node and bus 3=", x03
INPUT "reactance between reference node and bus 4=", x04
INPUT "reactance between bus 1 and bus 2=", xx12
INPUT "reactance between bus 2 and bus 3=", xx23
INPUT "reactance between bus 3 and bus 4=", xx34
INPUT "reactance between bus 4 and bus 2=", xx42
INPUT "reactance between bus 4 and bus 1=", xx41
x11 = x01
x12 = x11
x21 = x12
x22 = x01 + xx12
PRINT "reactances after first step", x11, x12, x21, x22
IF x02 > 0 THEN
CALL a(x11, x12, x21, x22, x02, 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
CALL b(x11b, x12b, x13b, x21b, x22b, x23b, x31b, x32b, x33b, x03, 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 CALL c(x112, x122, x132, x142, x212, x222, x232, x242, x312, x322,
x332, x342, x412, x422, x432, x442, xx42)
IF xx42 > 0 AND x03 = 0 THEN CALL c(x11d, x12d, x13d, x14d, x21d, x22d, x23d, x24d, x31d,
x32d, x33d, x34d, x41d, x42d, x43d, x44d, xx42)
IF xx41 > 0 THEN CALL d(x11f, x12f, x13f, x14f, x21f, x22f, x23f, x24f, x31f, x32f, x33f, x34f, x41f,
x42f, x43f, x44f, xx41)
IF xx41 = 0 AND xx31 = 0 THEN
PRINT x11f, x12f, x13f, x14f
PRINT x21f, x22f, x23f, x24f
PRINT x31f, x32f, x33f, x34f
PRINT x41f, x42f, x43f, x44f
PRINT "for a 3=phase fault on bus 1 with prefault voltage = 1 p.u., the short circuit current =", 1 / x11f
PRINT "voltage at bus 1 for a fault on bus 2 =", 1 (x12f / x22f)
PRINT "voltage at bus 3 for a fault on bus 2 =", 1 (x42f / x22f)
ELSE
PRINT x11f1, x12f1, x13f1, x14f1
PRINT x21f1, x22f1, x23f1, x24f1
PRINT x31f1, x32f1, x33f1, x34f1
PRINT x41f1, x42f1, x43f1, x44f1
PRINT "for a 3=phase fault on bus 4 with prefault voltage = 1 p.u., the short circuit current =j"; 1 /
x44f1; "p.u."
PRINT "voltage at bus 2 for a fault on bus 4 =", 1 (x24f1 / x44f1); "pu"
PRINT "voltage at bus 1 for a fault on bus 4 =", 1 (x14f1 / x44f1); "pu"
END IF
SUB a (x11, x12, x21, x22, x02, xx23)
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
END SUB
SUB b (x11b, x12b, x13b, x21b, x22b, x23b, x31b, x32b, x33b, x03, xx34)
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
END SUB
SUB c (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)
x1p3 = a2 a4
x2p3 = a6 a8
x3p3 = a10 a12
x4p3 = a14 a16
xp13 = x1p3
xp23 = x2p3
xp33 = x3p3
xp43 = x4p3
xpp3 = a6 + a16 2 * (a8) + a17
x11f = a1 (x1p3) * (xp13) / (xpp3)
x12f = a2 (x1p3) * (xp23) / (xpp3)
x13f = a3 (x1p3) * (xp33) / (xpp3)
x14f = a4 (x1p3) * (xp43) / (xpp3)
x21f = a5 (x2p3) * (xp13) / (xpp3)
x22f = a6 (x2p3) * (xp23) / (xpp3)
x23f = a7 (x2p3) * (xp33) / (xpp3)
x24f = a8 (x2p3) * (xp43) / (xpp3)
x31f = a9 (x3p3) * (xp13) / (xpp3)
x32f = a10 (x3p3) * (xp23) / (xpp3)
x33f = a11 (x3p3) * (xp33) / (xpp3)
x34f = a12 (x3p3) * (xp43) / (xpp3)
x41f = a13 (x4p3) * (xp13) / (xpp3)
x42f = a14 (x4p3) * (xp23) / (xpp3)
x43f = a15 (x4p3) * (xp33) / (xpp3)
x44f = a16 (x4p3) * (xp43) / (xpp3)
END SUB
SUB d (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17)
x1p4 = b1 b4
x2p4 = b5 b8
x3p4 = b9 b12
x4p4 = b13 b16
xp14 = x1p4
xp24 = x2p4
xp34 = x3p4
xp44 = x4p4
xpp4 = b1 + b16 2 * (b4) + b17
x11f1 = b1 (x1p4) * (xp14) / (xpp4)
x12f1 = b2 (x1p4) * (xp24) / (xpp4)
x13f1 = b3 (x1p4) * (xp34) / (xpp4)
x14f1 = b4 (x1p4) * (xp44) / (xpp4)
x21f1 = b5 (x2p4) * (xp14) / (xpp4)
x22f1 = b6 (x2p4) * (xp24) / (xpp4)
x23f1 = b7 (x2p4) * (xp34) / (xpp4)
x24f1 = b8 (x2p4) * (xp44) / (xpp4)
x31f1 = b9 (x3p4) * (xp14) / (xpp4)
x32f1 = b10 (x3p4) * (xp24) / (xpp4)
x33f1 = b11 (x3p4) * (xp34) / (xpp4)
x34f1 = b12 (x3p4) * (xp44) / (xpp4)
x41f1 = b13 (x4p4) * (xp14) / (xpp4)
x42f1 = b14 (x4p4) * (xp24) / (xpp4)
x43f1 = b15 (x4p4) * (xp34) / (xpp4)
x44f1 = b16 (x4p4) * (xp44) / (xpp4)
END SUB
Eighth example, Ybus modeling:
CLS
PRINT "The Series of Short Programs for Power Systems Analysts"
PRINT "calculation of bus voltage for a 4bus network"
INPUT "Y11 = ", y11
INPUT "Y12 = ", y12
INPUT "Y13 = ", y13
INPUT "Y14 = ", y14
INPUT "Y21 = ", y21
INPUT "Y22 = ", y22
INPUT "Y23 = ", y23
INPUT "Y24 = ", y24
INPUT "Y31 = ", y31
INPUT "Y32 = ", y32
INPUT "Y33 = ", y33
INPUT "Y34 = ", y34
INPUT "Y41 = ", y41
INPUT "Y42 = ", y42
INPUT "Y43 = ", y43
INPUT "Y44 = ", y44
y110 = y11 / y11
y120 = y12 / y11
y130 = y13 / y11
y140 = y14 / y11
y220 = y22 (y21) * (y12) / (y11)
y230 = y23 (y21) * (y13) / (y11)
y240 = y24 (y21) * (y14) / y11
y320 = y32 (y31) * (y12) / y11
y330 = y33 (y31) * (y13) / y11
y340 = y34 (y31) * (y14) / y11
y420 = y42 (y41) * (y12) / y11
y430 = y43 (y41) * (y13) / y11
y440 = y44 (y41) * (y14) / y11
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
PRINT "the L matrix of the triangular factorization ="
PRINT y11
PRINT y21, y220
PRINT y31, y320, y331
PRINT y41, y420, y431, y442
PRINT "the U matrix of the triangular factorization ="
PRINT y110, y120, y130, y140
PRINT y211, y221, y231, y241
PRINT y312, y322, y332, y342
PRINT 0, 0, 0, 1
INPUT "current injected in node 1 I1 =", x1
INPUT "the angle O1 in deg. =", z1
INPUT "current injected in node 2 I2 =", x2
INPUT "the angle O2 =", z2
INPUT " current injected in node 3 I3 =", x3
INPUT "the angle O3 =", z3
INPUT "current injected in node 4 I4 =", x4
INPUT "the angle O4 =", z4
PRINT "V1' =", x1 / y11
IF z1 = 0 THEN z12d1 = 0
IF z1 > 0 THEN z12d1 = z1 90
IF z1 < 0 THEN z12d1 = z1 90
z12 = 3.141592654# * z1 / (180)
v1r = (x1 / y11) * (COS(z12 1.570796))
v1m = (x1 / y11) * (SIN(z12 1.570796))
z22 = 3.141592654# * z2 / (180)
v2r = (v1r) * (y21) / (y220) + ((x2 / y220) * (COS(z22 1.570796)))
v2m = (v1m) * (y21) / (y220) + ((x2 / y220) * (SIN(z22 1.570796)))
v2 = (v2r ^ 2 + v2m ^ 2) ^ .5
PRINT "V'2 =", v2
IF v2r = 0 THEN av2 = 0
IF v2r > 0 THEN av2 = ATN(v2m / v2r)
IF v2r < 0 THEN av2 = ATN(v2m / v2r)
av2d = av2 * 180 / (3.14159265#)
PRINT "the phase angle =", av2d
z31 = 3.141592654# * z3 / (180)
v3r = ((v1r * y31) / (y331)) + (x3 * (COS(z31 1.570796)) / (y331)) ((v2r * y320) / (y331))
v3m = ((v1m * y31) / (y331)) + (x3 * (SIN(z31 1.570796)) / (y331)) ((v2m * y320) / (y331))
V3 = (v3r ^ 2 + v3m ^ 2) ^ .5
IF v3r = 0 THEN av3 = 0
IF v3r > 0 THEN av3 = ATN(v3m / v3r)
IF v3r < 0 THEN av3 = ATN(v3m / v3r)
av3d = av3 * 180 / (3.14159265#)
PRINT "V'3 =", V3
PRINT "the phase angle of V'3=", av3d
z41 = 3.141592654# * z4 / (180)
v4r = ((v1r * y41) / (y442)) + (x4 * (COS(z41 1.570796)) / (y442)) ((v2r * y420) / (y442)) (v3r *
y431) / (y442)
v4m = ((v1m * y41) / (y442)) + (x4 * (SIN(z41 1.570796)) / (y442)) ((v2m * y420) / (y442))
((v3m * y431) / (y442))
v4 = (v4r ^ 2 + v4m ^ 2) ^ .5
IF v4r = 0 THEN av4 = 0
IF v4r > 0 THEN av4 = ATN(v4m / v4r)
IF v4r < 0 THEN av4 = ATN(v4m / v4r)
av4d = av4 * 180 / (3.14159265#)
PRINT "V'4 =", v4
PRINT "the phase angle of V'4=", av4d
PRINT "V'4 = V4 = bus 4 voltage", v4
PRINT "the angle of V4 =", av4d
v31r = v3r (y342) * (v4r)
v31m = v3m (y342) * (v4m)
v31 = (v31r ^ 2 + v31m ^ 2) ^ .5
IF v31r = 0 THEN av31 = 0
IF v31r > 0 THEN av31 = ATN(v31m / v31r)
IF v31r < 0 THEN av31 = ATN(v31m / v31r)
av31d = av31 * 180 / (3.14159265#)
PRINT "voltage at bus 3, V3 =", v31
PRINT "the angle of V3 = ", av31d
v21r = (v2r (y241 * v4r) (y231 * v31r))
v21m = (v2m (y241 * v4m) (y231 * v31m))
v21 = (v21r ^ 2 + v21m ^ 2) ^ .5
IF v21r = 0 THEN av21 = 0
IF v21r > 0 THEN av21 = ATN(v21m / v21r)
IF v21r < 0 THEN av21 = ATN(v21m / v21r)
av21d = av21 * 180 / (3.14159265#)
PRINT "voltage at bus 2, V2 =", v21
PRINT "the angle of V2 = ", av21d
v11r = (v1r (y140 * v4r) (y130 * v31r) (v21r * y120))
v11m = (v1m (y140 * v4m) (y130 * v31m) (v21m * y120))
v11 = (v11r ^ 2 + v11m ^ 2) ^ .5
IF v11r = 0 THEN av11 = 0
IF v11r > 0 THEN av11 = ATN(v11m / v11r)
IF v11r < 0 THEN av11 = ATN(v11m / v11r)
av11d = av11 * 180 / (3.14159265#)
PRINT "voltage at bus 1, V1 =", v11
PRINT "the angle of V1 = ", av11d
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
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$
PRINT #1, "voltage at bus 1, V1 =", v11
PRINT #1, "voltage at bus 2, V2 =", v21
PRINT #1, "voltage at bus 3, V3 =", v31
PRINT #1, "voltage at bus 4 voltage =", v4
PRINT #1, "the angle of V1 = ", av11d
PRINT #1, "the angle of V2 = ", av21d
PRINT #1, "the angle of V3 = ", av31d
PRINT #1, "the phase angle of V4 =", av4d
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, "voltage at bus 1, V1 =", v11
PRINT #1, "voltage at bus 2, V2 =", v21
PRINT #1, "voltage at bus 3, V3 =", v31
PRINT #1, "voltage at bus 4 voltage =", v4
PRINT #1, "the angle of V1 = ", av11d
PRINT #1, "the angle of V2 = ", av21d
PRINT #1, "the angle of V3 = ", av31d
PRINT #1, "the phase angle of V4 =", av4d
CLOSE #1
END IF
Ninth example, calculation of short circuit currents for different fault conditions for a simple circuit:
DECLARE SUB q (h!, j!, k!)
DECLARE SUB r (v1!, z1!, n1!, p1!, g1!, l1!)
DECLARE SUB s (m!, u!, w!, wu!)
DECLARE SUB o (a!, b!, c!, d!, e!, f!)
CLS
'a program to calculate the fault currents in electrical systems
PRINT "The Series of Short Programs for Power Systems Analysts"
PRINT "a program to calculate the fault currents"
INPUT "enter fault reactance in p.u., if any"; l
INPUT "enter +ve seq. react. in p.u."; p
INPUT "enter neutral reactance in p.u., if any"; g
INPUT "enter ve seq. react. in p.u."; n
INPUT "enter zero seq. react. in p.u."; z
INPUT "enter prefault voltage in p.u."; v
INPUT "type of fault, for single ph to ground enter 1, for ph to ph enter 2, for ph. to ph. to ground enter
3 & for 3 phase enter 4"; t
IF t = 1 THEN CALL o(v, z, n, p, g, l)
IF t = 2 THEN CALL s(v, p, n, l)
IF t = 3 THEN CALL r(v, z, n, p, g, l)
IF t = 4 THEN CALL q(v, p, l)
SUB o (a!, b!, c!, d!, e!, f!)
x = 3 * (f)
y = 3 * (e)
i = a / (x + y + c + b + d)
PRINT "+ve seq. current, Ia1="; i
PRINT "fault current in p.u."; 3 * i
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "reference:", refer$
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, "Reference: ", refer$
PRINT #1, "single phase to ground fault current in p.u.= "; 3 * i
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, "Reference: ", refer$
PRINT #1, "single phase to ground fault current in p.u. = "; 3 * i
CLOSE #1
END IF
END SUB
SUB q (h, j, k)
PRINT "the 3phase fault="; h / (j + k)
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "reference:", refer$
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, "Reference: ", refer$
PRINT #1, "3phase fault current in p.u.= "; h / (j + k)
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, "Reference: ", refer$
PRINT #1, "3phase fault current in p.u.= "; h / (j + k)
CLOSE #1
END IF
END SUB
SUB r (v1, z1, n1, p1, g1, l1)
j1 = (3 * g1 + 3 * l1 + z1) * n1 / (3 * g1 + 3 * l1 + z1 + n1)
j2 = v1 / (p1 + j1)
j3 = v1 (j2 * p1)
PRINT "the line to line to ground fault current="; (3 * j3) / z1
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "reference:", refer$
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, "Reference: ", refer$
PRINT #1, "line to line to ground fault current in p.u.= "; (3 * j3) / z1
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, "Reference: ", refer$
PRINT #1, "line to line to ground fault current in p.u. = "; (3 * j3) / z1
CLOSE #1
END IF
END SUB
SUB s (m, u, w, uw)
i1 = m / (u + w + uw)
PRINT "fault current in p.u.="; .866 * 2 * i1
INPUT "Project Name: ", projnam$
INPUT "Project Number: ", projnum$
INPUT "prepared by:", pb$
INPUT "date:", da$
INPUT "reference:", refer$
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, "Reference: ", refer$
PRINT #1, "line to line fault current in p.u.= "; .866 * 2 * i1
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, "Reference: ", refer$
PRINT #1, "line to line fault current in p.u.= "; .866 * 2 * i1
CLOSE #1
END IF
END SUB
C++:
First example, that converts from wye to delta & vice versa, that finds the equivalent of a few parallel
branches and to calculate the short circuit value for a simple circuit:
#include<iostream.h>
#include<fstream.h>
void main() {
char response,filename[80],mainsel;
float x,y,z,b1,b2,b3,fb1,fb2,fb3,fb4,fb5,fb6,eq,eq1,fr,psr,nr,nsr,zsr,pfv,i1,i2;
float i3,i;
int quit = 0;
while (quit==0) {
cout<<"enter:a for y to delta conversion, b for delta to Y conversion"<<endl
<<"c to find the equivalent of a few parallel branches, d to calculate"<<endl
<<"the short circuit current for a simple system & q to quit: "<<endl;
cin>>mainsel;
cout<<"file name:(enter q if you entered q to previous prompt) ";
cin>>filename;
ofstream fout(filename);
if (mainsel == 'b') {
cout<< "branch 23: " ;
cin >> x ;
cout<< "branch 12: " ;
cin >> y;
cout<< "branch 13: " ;
cin >> z;
b1 = (x*y)/(x+y+z);
cout << "branch 2n = "<< b1 << endl;
b2 = (x*z)/(x+y+z);
cout << "branch 3n = "<< b2 << endl;
b3= (z*y)/(x+y+z) ;
cout << "branch 1n = "<< b3 << endl;
fout<<"branches 1n,2n & 3n,respectively: "<<b3<<","<<b1<<","<<b2<<endl;
fout.close();
continue;
}
if (mainsel == 'a') {
cout<< "branch 1n: " ;
cin >> x ;
cout<< "branch 3n: " ;
cin >> y;
cout<< "branch 2n: " ;
cin >> z;
b1 = x + y + (x*y/z);
cout << "branch 13 = "<< b1 << endl;
b2 = y + z + (y*z/x);
cout << "branch 23 = "<< b2 << endl;
b3= x + z + (x*z/y);
cout << "branch 12 = "<< b3 << endl;
fout<<"branches 13,23 & 12,respectively: "<<b1<<","<<b2<<","<<b3<<endl;
fout.close();
continue;
}
if (mainsel == 'c'){
cout <<"enter a for 2 branches, b for 3, c for 4, d for 5, e for 6: "<<endl;
cin >>response;
switch (response) {
case 'a': cout <<"enter value of first branch ="<<endl;
cin >> fb1 ;
cout <<"enter value of second branch ="<<endl;
cin >> fb2 ;
eq1 = (1/fb1)+(1/fb2);
eq = 1/(eq1);
cout <<"the equivalent for the branches ="<<eq<<endl;
fout<<"equivalent branch: "<<eq<<endl;
fout.close();
continue;
case 'b': cout <<"enter value of first branch ="<<endl;
cin >> fb1 ;
cout <<"enter value of second branch ="<<endl;
cin >> fb2 ;
cout <<"enter value of third branch ="<<endl;
cin >> fb3 ;
eq1 = (1/fb1)+(1/fb2)+(1/fb3);
eq = 1/(eq1);
cout <<"the equivalent for the branches ="<<eq<<endl;
fout<<"equivalent branch: "<<eq<<endl;
fout.close();
continue;
case 'c': cout <<"enter value of first branch ="<<endl;
cin >> fb1 ;
cout <<"enter value of second branch ="<<endl;
cin >> fb2 ;
cout <<"enter value of third branch ="<<endl;
cin >> fb3 ;
cout <<"enter value of fourth branch ="<<endl;
cin >> fb4 ;
eq1 = (1/fb1)+(1/fb2)+(1/fb3)+(1/fb4);
eq = 1/(eq1);
cout <<"the equivalent for the branches ="<<eq<<endl;
fout<<"equivalent branch: "<<eq<<endl;
fout.close();
continue;
case 'd': cout <<"enter value of first branch ="<<endl;
cin >> fb1 ;
cout <<"enter value of second branch ="<<endl;
cin >> fb2 ;
cout <<"enter value of third branch ="<<endl;
cin >> fb3 ;
cout <<"enter value of fourth branch ="<<endl;
cin >> fb4 ;
cout <<"enter value of fifth branch ="<<endl;
cin >> fb5 ;
eq1 = (1/fb1)+(1/fb2)+(1/fb3)+(1/fb4)+(1/fb5);
eq = 1/(eq1);
cout <<"the equivalent for the branches ="<<eq<<endl;
fout<<"equivalent branch: "<<eq<<endl;
fout.close();
continue;
case 'e': cout <<"enter value of first branch ="<<endl;
cin >> fb1 ;
cout <<"enter value of second branch ="<<endl;
cin >> fb2 ;
cout <<"enter value of third branch ="<<endl;
cin >> fb3 ;
cout <<"enter value of fourth branch ="<<endl;
cin >> fb4 ;
cout <<"enter value of fifth branch ="<<endl;
cin >> fb5 ;
cout <<"enter value of sixth branch ="<<endl;
cin >> fb6 ;
eq1 = (1/fb1)+(1/fb2)+(1/fb3)+(1/fb4)+(1/fb5)+(1/fb6);
eq = 1/(eq1);
cout <<"the equivalent for the branches ="<<eq<<endl;
fout<<"equivalent branch: "<<eq<<endl;
fout.close();
continue;
}
}
if (mainsel == 'd') {
cout <<"enter a for line to ground fault" << endl;
cout <<"enter b for line to line fault" << endl;
cout <<"enter c for line to line to ground fault" << endl;
cout <<"enter d for 3 phase fault and q to quit" << endl;
cin >>response;
switch (response) {
case 'a': cout <<"the prefault voltage in p.u.=" << endl;
cin >>pfv ;
cout <<"the fault reactance in p.u. =" << endl;
cin >>fr ;
cout <<"the positive sequence reactance in p.u. =" << endl;
cin >>psr ;
cout <<"the negative sequence reactance in p.u.=" << endl;
cin >>nsr ;
cout <<"the zero sequence reactance in p.u.=" << endl;
cin >>zsr ;
cout <<"the neutral reactance in p.u.=" << endl;
cin >>nr ;
i1 = pfv/((3*fr)+psr+(3*nr)+nsr+zsr);
i = 3*(i1);
cout<<"the +ve sequence current & the fault current in p.u. ="<<i1<<" & "<<i<<endl;
fout<<"the +ve sequence current & the fault current in p.u. ="<<i1<<" & "<<i<<endl;
fout.close();
continue;
case 'b': cout <<"the prefault voltage in p.u.=" << endl;
cin >>pfv ;
cout <<"the fault reactance in p.u. =" << endl;
cin >>fr ;
cout <<"the positive sequence reactance in p.u. =" << endl;
cin >>psr ;
cout <<"the negative sequence reactance in p.u.=" << endl;
cin >>nsr ;
i1 = pfv/(fr+psr+nsr);
i = (.866*2*i1);
cout<<"the fault current in p.u. ="<< i << endl;
fout<<"the fault current in p.u. ="<< i << endl;
fout.close();
continue;
case 'c': cout <<"the prefault voltage in p.u.=" << endl;
cin >>pfv ;
cout <<"the fault reactance in p.u. =" << endl;
cin >>fr ;
cout <<"the positive sequence reactance in p.u. =" << endl;
cin >>psr ;
cout <<"the negative sequence reactance in p.u.=" << endl;
cin >>nsr ;
cout <<"the zero sequence reactance in p.u.=" << endl;
cin >>zsr ;
cout <<"the neutral reactance in p.u.=" << endl;
cin >>nr ;
i1 = ((3*fr)+(3*nr)+zsr)*(nsr)/((3*fr)+(3*nr)+zsr+nsr);
i2 = pfv/(i1+psr);
i3 = pfv(i2*psr);
i = (3*i3)/zsr;
cout<<"the fault current in p.u. =" << i << endl;
fout<<"the fault current in p.u. ="<< i << endl;
fout.close();
continue;
case 'd': cout <<"the prefault voltage in p.u.=" << endl;
cin >>pfv ;
cout <<"the fault reactance in p.u. =" << endl;
cin >>fr ;
cout <<"the positive sequence reactance in p.u. =" << endl;
cin >>psr ;
i = pfv/(psr+fr);
cout<<"the fault current in p.u. =" << i << endl;
fout<<"the fault current in p.u. ="<< i << endl;
fout.close();
continue;
}
}
if (mainsel == 'q') {
quit = 1;
break;
}
}
}
Second example, solving 2 & 3 simultaneous equations using matrix manipulation:
#include<iostream.h>
#include<fstream.h>
void main() {
char response ;
int quit = 0;
char filename[80];
float a11 ;
float a12 ;
float a13 ;
float a21 ;
float a22 ;
float a23 ;
float a31 ;
float a32 ;
float a33 ;
float det ;
float b11 ;
float b12 ;
float b13 ;
float b21 ;
float b22 ;
float b23 ;
float b31 ;
float b32 ;
float b33 ;
while (quit==0) {
cout<<"enter a for 2 by 2 matrix & b for 3X3 (or q to quit): "<<response <<endl;
cin >>response;
cout<<"file name:(enter q if you entered q to previous prompt) ";
cin>>filename;
ofstream fout(filename);
switch (response) {
case 'a': cout <<"enter element a11: "<<endl;
cin >>a11 ;
cout <<"enter element a12: "<<endl;
cin >>a12 ;
cout <<"enter element a21: "<<endl;
cin >>a21 ;
cout <<"enter element a22: "<<endl;
cin >>a22 ;
det = (a11*a22)(a12*a21) ;
cout <<"the determinant of the matrix = "<<det <<endl;
if (det == 0)
break;
else
b11 = a22/det ;
b12 = a12/det ;
b21 = a12/det ;
b22 = a11/det ;
cout <<"the inverted matrix has a11 = "<<b11 <<endl;
cout <<"the inverted matrix has a12 = "<<b12 <<endl;
cout <<"the inverted matrix has a21 = "<<b21 <<endl;
cout <<"the inverted matrix has a22 = "<<b22 <<endl;
fout<<"determinant, a11, a12, a21, a22= "<<det<<","<<b11<<","<<b12<<","<<b21<<","<<b22;
fout.close();
break;
case 'b': cout <<"enter element a11: "<<endl;
cin >>a11 ;
cout <<"enter element a12: "<<endl;
cin >>a12 ;
cout <<"enter element a13: "<<endl;
cin >>a13 ;
cout <<"enter element a21: "<<endl;
cin >>a21 ;
cout <<"enter element a22: "<<endl;
cin >>a22 ;
cout <<"enter element a23: "<<endl;
cin >>a23 ;
cout <<"enter element a31: "<<endl;
cin >>a31 ;
cout <<"enter element a32: "<<endl;
cin >>a32 ;
cout <<"enter element a33: "<<endl;
cin >>a33 ;
det = (a11*(a22*a33a32*a23))(a12*(a21*a33a23*a31))+(a13*(a21*a32a22*a31)) ;
cout <<"the determinant of the matrix = "<<det <<endl;
if (det == 0)
break;
else
b11 = (a22*a33a23*a32)/det ;
b12 = (a12*a33a13*a32)/det ;
b13 = (a12*a23a13*a22)/det ;
b21 = (a21*a33a31*a23)/det ;
b22 = (a11*a33a13*a31)/det ;
b23 = (a11*a23a13*a21)/det ;
b31 = (a21*a32a31*a22)/det ;
b32 = (a11*a32a12*a31)/det ;
b33 = (a11*a22a21*a12)/det ;
cout <<"the inverted matrix has a11 = "<<b11 <<endl;
cout <<"the inverted matrix has a12 = "<<b12 <<endl;
cout <<"the inverted matrix has a13 = "<<b13 <<endl;
cout <<"the inverted matrix has a21 = "<<b21 <<endl;
cout <<"the inverted matrix has a22 = "<<b22 <<endl;
cout <<"the inverted matrix has a23 = "<<b23 <<endl;
cout <<"the inverted matrix has a31 = "<<b31 <<endl;
cout <<"the inverted matrix has a32 = "<<b32 <<endl;
cout <<"the inverted matrix has a33 = "<<b33 <<endl;
fout<<"det.,a11,a12,a13,a21,a22,a23,a31,a32,a33=
"<<det<<","<<b11<<","<<b12<<","<<b13<<","<<b21<<","<<b22<<","<<b23<<","<<b31<<","<<b32
<<","<<b33;
fout.close();
break;
case 'q': quit = 1;
break ;
}
}
}
Third example, solving 4, 5 , & 7 simultaneous equations using gaussian elimination/triangular
manipulation method:
#include<iostream.h>
#include<fstream.h>
void main() {
char response, filename[80] ;
int quit = 0 ;
float a11,a12,a13,a14,a15,a16,a21,a22,a23,a24,a25,a26,a31,a32,a33,a34,a35,a36;
float a41,a42,a43,a44,a45,a46,a51,a52,a53,a54,a55,a56,a61,a62,a63,a64,a65,a66;
float y110,y120,y130,y140,y150,y160,y220,y230,y240,y250,y260,y320,y330,y340,y350,y360;
float y420,y430,y440,y450,y460,y520,y530,y540,y550,y560,y620,y630,y640,y650,y660;
float y221,y231,y241,y251,y261,y331,y341,y351,y361,y431,y441,y451,y461,y531,y541;
float y551,y561,y631,y641,y651,y661,y332,y342,y352,y362,y442,y452,y462,y542,y552;
float y562,y642,y652,y662,y443,y453,y463,y553,y563,y653,y663,y554,y564,y664 ;
float m1,m2,m3,m4,m5,m6,m7,v1,v2,v3,v4,v5,v6,v7,f1,f2,f3,f4,f5,f6,f7 ;
float a17,a27,a37,a47,a57,a67,a71,a72,a73,a74,a75,a76,a77,y170,y270,y370,y470;
float y570,y670,y720,y730,y740,y750,y760,y770,y271,y371,y471,y571,y671;
float y731,y741,y751,y761,y771,y372,y472,y572,y672,y742,y752,y762,y772,y473,y573;
float y673,y753,y763,y773,y574,y674,y764,y774,y665,y675,y775;
while (quit==0) {
cout<<"enter a for 4x4 matrix,b for 5X5,c for 6X6,d for 7x7 (or q to quit): "<<response <<endl;
cin >>response;
cout<<"file name:(enter q if you entered q to previous prompt) ";
cin>>filename;
ofstream fout(filename);
switch (response) {
case 'a': cout<<"enter element a11: "<<endl;
cin>>a11 ;
cout<<"enter element a12: "<<endl;
cin>>a12 ;
cout<<"enter element a13: "<<endl;
cin>>a13 ;
cout<<"enter element a14: "<<endl;
cin>>a14 ;
cout<<"enter element a21: "<<endl;
cin>>a21 ;
cout<<"enter element a22: "<<endl;
cin>>a22 ;
cout<<"enter element a23: "<<endl;
cin>>a23 ;
cout<<"enter element a24: "<<endl;
cin>>a24 ;
cout<<"enter element a31: "<<endl;
cin>>a31 ;
cout<<"enter element a32: "<<endl;
cin>>a32 ;
cout<<"enter element a33: "<<endl;
cin>>a33 ;
cout<<"enter element a34: "<<endl;
cin>>a34 ;
cout<<"enter element a41: "<<endl;
cin>>a41 ;
cout<<"enter element a42: "<<endl;
cin>>a42 ;
cout<<"enter element a43: "<<endl;
cin>>a43 ;
cout<<"enter element a44: "<<endl;
cin>>a44 ;
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 ;
cout<<"enter right hand side of equation or mismatch m1: "<<endl;
cin>>m1 ;
cout<<"enter element m2: "<<endl;
cin>>m2 ;
cout<<"enter element m3: "<<endl;
cin>>m3 ;
cout<<"enter element m4: "<<endl;
cin>>m4 ;
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)));
cout<<"the elements of the lower matrix:a11,a12,a13,a14,a21,a22,a23,a24,a31,a32,"<<endl
<<"a33,a34,a41,a42,a43,a44: "<<a11<<",0,0,0,"<<a21<<","<<y220<<",0,0,"<<a31<<","<<endl
<<y320<<","<<y331<<"0"<<a41<<","<<y420<<","<<y431<<","<<y442<<endl;
cout<<"the elements of the upper matrix:a11,a12,a13,a14,a21,a22,a23,a24,a31,a32,"<<endl
<<"a33,a34,a41,a42,a43,a44: "<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<"0,"<<endl
<<y221<<","<<y231<<","<<y241<<",0,0,"<<y332<<","<<y342<<",0,0,0,1"<<endl;
cout<<"the variables are: "<<f4<<","<<f3<<","<<f2<<","<<f1<<endl;
fout<<"the elements of the lower matrix:a11,a12,a13,a14,a21,a22,a23,a24,a31,a32,"<<endl
<<"a33,a34,a41,a42,a43,a44: "<<a11<<",0,0,0,"<<a21<<","<<y220<<",0,0,"<<a31<<","<<endl
<<y320<<","<<y331<<"0"<<a41<<","<<y420<<","<<y431<<","<<y442<<"."<<endl
<<"the elements of the upper matrix:a11,a12,a13,a14,a21,a22,a23,a24,a31,a32,"<<endl
<<"a33,a34,a41,a42,a43,a44: "<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<"0,"<<endl
<<y221<<","<<y231<<","<<y241<<",0,0,"<<y332<<","<<y342<<",0,0,0,1"<<"."<<endl
<<"the variables v4,v3,v2 & v1 are: "<<f4<<","<<f3<<","<<f2<<","<<f1;
fout.close();
break;
case 'b': cout<<"enter element a11: "<<endl;
cin>>a11 ;
cout<<"enter element a12: "<<endl;
cin>>a12 ;
cout<<"enter element a13: "<<endl;
cin>>a13 ;
cout<<"enter element a14: "<<endl;
cin>>a14 ;
cout<<"enter element a15: "<<endl;
cin>>a15 ;
cout<<"enter element a21: "<<endl;
cin>>a21 ;
cout<<"enter element a22: "<<endl;
cin>>a22 ;
cout<<"enter element a23: "<<endl;
cin>>a23 ;
cout<<"enter element a24: "<<endl;
cin>>a24 ;
cout<<"enter element a25: "<<endl;
cin>>a25 ;
cout<<"enter element a31: "<<endl;
cin>>a31 ;
cout<<"enter element a32: "<<endl;
cin>>a32 ;
cout<<"enter element a33: "<<endl;
cin>>a33 ;
cout<<"enter element a34: "<<endl;
cin>>a34 ;
cout<<"enter element a35: "<<endl;
cin>>a35 ;
cout<<"enter element a41: "<<endl;
cin>>a41 ;
cout<<"enter element a42: "<<endl;
cin>>a42 ;
cout<<"enter element a43: "<<endl;
cin>>a43 ;
cout<<"enter element a44: "<<endl;
cin>>a44 ;
cout<<"enter element a45: "<<endl;
cin>>a45 ;
cout<<"enter element a51: "<<endl;
cin>>a51 ;
cout<<"enter element a52: "<<endl;
cin>>a52 ;
cout<<"enter element a53: "<<endl;
cin>>a53 ;
cout<<"enter element a54: "<<endl;
cin>>a54 ;
cout<<"enter element a55: "<<endl;
cin>>a55 ;
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 ;
cout<<"enter right hand side of equation or mismatch m1: "<<endl;
cin>>m1 ;
cout<<"enter element m2: "<<endl;
cin>>m2 ;
cout<<"enter element m3: "<<endl;
cin>>m3 ;
cout<<"enter element m4: "<<endl;
cin>>m4 ;
cout<<"enter element m5: "<<endl;
cin>>m5 ;
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)));
cout<<"the elements of the lower matrix:a11,a12,a13,a14,a15,a21,a22,a23,a24,a25,"<<endl
<<"a31,a32,a33,a34,a35,a41,a42,a43,a44,a45,a51,a52,a53,a54,a55: "<<a11<<","<<endl
<<"0,0,0,0,"<<a21<<","<<y220<<",0,0,0,"<<a31<<","<<y320<<","<<y331<<"0,0,"<<endl
<<a41<<","<<y420<<","<<y431<<","<<y442<<","<<a51<<","<<y520<<","<<y531<<","<<endl
<<y542<<","<<y553<<endl;
cout<<"the elements of the upper matrix:a11,a12,a13,a14,a15,a21,a22,a23,a24,a25,"<<endl
<<"a31,a32,a33,a34,a35,a41,a42,a43,a44,a45,a51,a52,a53,a54,a55:"<<endl
<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<y150<<endl
<<"0,"<<y221<<","<<y231<<","<<y241<<","<<y251<<endl
<<",0,0,"<<y332<<","<<y342<<y352<<endl
<<"0,0,0,"<<y443<<","<<y453<<endl
<<",0,0,0,0,1"<<endl;
cout<<"the variables v5,v4,v3,v2 & v1 are: "<<f5<<","<<f4<<","<<f3<<","<<f2<<","<<f1<<endl;
fout<<"the elements of the lower matrix:a11,a12,a13,a14,a15,a21,a22,a23,a24,a25,"<<endl
<<"a31,a32,a33,a34,a35,a41,a42,a43,a44,a45,a51,a52,a53,a54,a55: "<<a11<<","<<endl
<<"0,0,0,0,"<<a21<<","<<y220<<",0,0,0,"<<a31<<","<<y320<<","<<y331<<"0,0,"<<endl
<<a41<<","<<y420<<","<<y431<<","<<y442<<","<<a51<<","<<y520<<","<<y531<<","<<endl
<<y542<<","<<y553<<endl
<<"the elements of the upper matrix:a11,a12,a13,a14,a15,a21,a22,a23,a24,a25,"<<endl
<<"a31,a32,a33,a34,a35,a41,a42,a43,a44,a45,a51,a52,a53,a54,a55:"<<endl
<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<y150<<endl
<<"0,"<<y221<<","<<y231<<","<<y241<<","<<y251<<endl
<<",0,0,"<<y332<<","<<y342<<","<<y352<<endl
<<"0,0,0,"<<y443<<","<<y453<<endl
<<",0,0,0,0,1"<<endl
<<"the variables v5,v4,v3,v2 & v1 are: "<<f5<<","<<f4<<","<<f3<<","<<f2<<","<<f1<<endl;
fout.close();
break;
case 'c': cout<<"enter element a11: "<<endl;
cin>>a11 ;
cout<<"enter element a12: "<<endl;
cin>>a12 ;
cout<<"enter element a13: "<<endl;
cin>>a13 ;
cout<<"enter element a14: "<<endl;
cin>>a14 ;
cout<<"enter element a15: "<<endl;
cin>>a15 ;
cout<<"enter element a16: "<<endl;
cin>>a16 ;
cout<<"enter element a21: "<<endl;
cin>>a21 ;
cout<<"enter element a22: "<<endl;
cin>>a22 ;
cout<<"enter element a23: "<<endl;
cin>>a23 ;
cout<<"enter element a24: "<<endl;
cin>>a24 ;
cout<<"enter element a25: "<<endl;
cin>>a25 ;
cout<<"enter element a26: "<<endl;
cin>>a26 ;
cout<<"enter element a31: "<<endl;
cin>>a31 ;
cout<<"enter element a32: "<<endl;
cin>>a32 ;
cout<<"enter element a33: "<<endl;
cin>>a33 ;
cout<<"enter element a34: "<<endl;
cin>>a34 ;
cout<<"enter element a35: "<<endl;
cin>>a35 ;
cout<<"enter element a36: "<<endl;
cin>>a36 ;
cout<<"enter element a41: "<<endl;
cin>>a41 ;
cout<<"enter element a42: "<<endl;
cin>>a42 ;
cout<<"enter element a43: "<<endl;
cin>>a43 ;
cout<<"enter element a44: "<<endl;
cin>>a44 ;
cout<<"enter element a45: "<<endl;
cin>>a45 ;
cout<<"enter element a46: "<<endl;
cin>>a46 ;
cout<<"enter element a51: "<<endl;
cin>>a51 ;
cout<<"enter element a52: "<<endl;
cin>>a52 ;
cout<<"enter element a53: "<<endl;
cin>>a53 ;
cout<<"enter element a54: "<<endl;
cin>>a54 ;
cout<<"enter element a55: "<<endl;
cin>>a55 ;
cout<<"enter element a56: "<<endl;
cin>>a56 ;
cout<<"enter element a61: "<<endl;
cin>>a61 ;
cout<<"enter element a62: "<<endl;
cin>>a62 ;
cout<<"enter element a63: "<<endl;
cin>>a63 ;
cout<<"enter element a64: "<<endl;
cin>>a64 ;
cout<<"enter element a65: "<<endl;
cin>>a65 ;
cout<<"enter element a66: "<<endl;
cin>>a66 ;
y110 = a11 / a11 ;
y120 = a12 / a11 ;
y130 = a13 / a11 ;
y140 = a14 / a11 ;
y150 = a15 / a11 ;
y160 = a16 / a11 ;
y220 = a22 (a21) * (a12) / (a11) ;
y230 = a23 (a21) * (a13) / (a11) ;
y240 = a24 (a21) * (a14) / a11 ;
y250 = a25 (a21) * (a15) / a11 ;
y260 = a26 (a21) * (a16) / a11 ;
y320 = a32 (a31) * (a12) / a11 ;
y330 = a33 (a31) * (a13) / a11 ;
y340 = a34 (a31) * (a14) / a11 ;
y350 = a35 (a31) * (a15) / a11 ;
y360 = a36 (a31) * (a16) / a11 ;
y420 = a42 (a41) * (a12) / a11 ;
y430 = a43 (a41) * (a13) / a11 ;
y440 = a44 (a41) * (a14) / a11 ;
y450 = a45 (a41) * (a15) / a11 ;
y460 = a46 (a41) * (a16) / a11 ;
y520 = a52 (a51) * (a12) / a11 ;
y530 = a53 (a51) * (a13) / a11 ;
y540 = a54 (a51) * (a14) / a11 ;
y550 = a55 (a51) * (a15) / a11 ;
y560 = a56 (a51) * (a16) / a11 ;
y620 = a62 (a61) * (a12) / a11 ;
y630 = a63 (a61) * (a13) / a11 ;
y640 = a64 (a61) * (a14) / a11 ;
y650 = a65 (a61) * (a15) / a11 ;
y660 = a66 (a61) * (a16) / a11 ;
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 ;
cout<<"enter right hand side of equation or mismatch m1: "<<endl;
cin>>m1 ;
cout<<"enter element m2: "<<endl;
cin>>m2 ;
cout<<"enter element m3: "<<endl;
cin>>m3 ;
cout<<"enter element m4: "<<endl;
cin>>m4 ;
cout<<"enter element m5: "<<endl;
cin>>m5 ;
cout<<"enter element m6: "<<endl;
cin>>m6 ;
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 ;
v6 = (m6 (v1) * (a61) (y620) * (v2) (y631) * (v3) (y642) * (v4) (y653) * (v5)) / y664 ;
f6 = v6 ;
f5 = (v5 ((y564) * (f6))) ;
f4 = (v4 ((y453) * (f5)) ((y463) * (f6))) ;
f3 = (v3 ((y342) * (f4)) ((y352) * (f5)) ((y362) * (f6))) ;
f2 = (v2 ((y231) * (f3)) ((y241) * (f4)) ((y251) * (f5)) ((y261) * (f6))) ;
f1 = (v1 ((y120) * (f2)) ((y130) * (f3)) ((y140) * (f4)) ((y150) * (f5)) ((y160) * (f6))) ;
cout<<"the elements of the lower matrix:a11,a12,a13,a14,a15,a16,a21,a22,a23,"<<endl
<<"a24,a25,a26,a31,a32,a33,a34,a35,a36,a41,a42,a43,a44,a45,a46,a51,a52,a53,"<<endl
<<"a54,a55,a56,a61,a62,a63,a64,a65,a66: "<<a11<<",0,0,0,0,0,"<<a21<<","<<y220<<endl
<<"0,0,0,0,"<<a31<<","<<y320<<","<<y331<<"0,0,0,"<<a41<<","<<y420<<","<<y431<<","<<endl
<<y442<<",0,0,"<<a51<<","<<y520<<","<<y531<<","<<y542<<","<<y553<<","<<"0,"<<endl
<<a61<<","<<y620<<","<<y631<<","<<y642<<","<<y653<<","<<y664<<"."<<endl;
cout<<"the elements of the upper matrix:a11,a12,a13,a14,a15,a16,a21,a22,a23,a24,"<<endl
<<"a25,a26,a31,a32,a33,a34,a35,a36,a41,a42,a43,a44,a45,a46,a51,a52,a53,a54,"<<endl
<<"a56,a61,a62,a63,a64,a65,a66: "<<endl
<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<y150<<","<<y160<<endl
<<"0,"<<y221<<","<<y231<<","<<y241<<","<<y251<<","<<y261<<endl
<<"0,0,"<<y332<<","<<y342<<","<<y352<<","<<y362<<","<<endl
<<"0,0,0,"<<y443<<","<<y453<<","<<y463<<endl
<<"0,0,0,0,"<<y554<<","<<y564<<endl
<<"0,0,0,0,0,1"<<"."<<endl;
cout<<"the variables v6,v5,v4,v3,v2 & v1 are: "<<f6<<","<<f5<<","<<f4<<","<<endl
<<f3<<","<<f2<<","<<f1<<"."<<endl;
fout<<"the elements of the lower matrix:a11,a12,a13,a14,a15,a16,a21,a22,a23,"<<endl
<<"a24,a25,a26,a31,a32,a33,a34,a35,a36,a41,a42,a43,a44,a45,a46,a51,a52,a53,"<<endl
<<"a54,a55,a56,a61,a62,a63,a64,a65,a66: "<<a11<<",0,0,0,0,0,"<<a21<<","<<y220<<endl
<<"0,0,0,0,"<<a31<<","<<y320<<","<<y331<<"0,0,0,"<<a41<<","<<y420<<","<<y431<<","<<endl
<<y442<<",0,0,"<<a51<<","<<y520<<","<<y531<<","<<y542<<","<<y553<<","<<"0,"<<endl
<<a61<<","<<y620<<","<<y631<<","<<y642<<","<<y653<<","<<y664<<"."<<endl
<<"the elements of the upper matrix:a11,a12,a13,a14,a15,a16,a21,a22,a23,a24,"<<endl
<<"a25,a26,a31,a32,a33,a34,a35,a36,a41,a42,a43,a44,a45,a46,a51,a52,a53,a54,"<<endl
<<"a56,a61,a62,a63,a64,a65,a66: "<<endl
<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<y150<<","<<y160<<endl
<<"0,"<<y221<<","<<y231<<","<<y241<<","<<y251<<","<<y261<<endl
<<"0,0,"<<y332<<","<<y342<<","<<y352<<","<<y362<<","<<endl
<<"0,0,0,"<<y443<<","<<y453<<","<<y463<<endl
<<"0,0,0,0,"<<y554<<","<<y564<<endl
<<"0,0,0,0,0,1"<<"."<<endl
<<"the variables v6,v5,v4,v3,v2 & v1 are: "<<f6<<","<<f5<<","<<f4<<","<<f3<<","<<endl
<<f2<<","<<f1<<endl;
fout.close();
break ;
case 'd': cout<<"enter element a11: "<<endl;
cin>>a11 ;
cout<<"enter element a12: "<<endl;
cin>>a12 ;
cout<<"enter element a13: "<<endl;
cin>>a13 ;
cout<<"enter element a14: "<<endl;
cin>>a14 ;
cout<<"enter element a15: "<<endl;
cin>>a15 ;
cout<<"enter element a16: "<<endl;
cin>>a16 ;
cout<<"enter element a17: "<<endl;
cin>>a17 ;
cout<<"enter element a21: "<<endl;
cin>>a21 ;
cout<<"enter element a22: "<<endl;
cin>>a22 ;
cout<<"enter element a23: "<<endl;
cin>>a23 ;
cout<<"enter element a24: "<<endl;
cin>>a24 ;
cout<<"enter element a25: "<<endl;
cin>>a25 ;
cout<<"enter element a26: "<<endl;
cin>>a26 ;
cout<<"enter element a27: "<<endl;
cin>>a27 ;
cout<<"enter element a31: "<<endl;
cin>>a31 ;
cout<<"enter element a32: "<<endl;
cin>>a32 ;
cout<<"enter element a33: "<<endl;
cin>>a33 ;
cout<<"enter element a34: "<<endl;
cin>>a34 ;
cout<<"enter element a35: "<<endl;
cin>>a35 ;
cout<<"enter element a36: "<<endl;
cin>>a36 ;
cout<<"enter element a37: "<<endl;
cin>>a37 ;
cout<<"enter element a41: "<<endl;
cin>>a41 ;
cout<<"enter element a42: "<<endl;
cin>>a42 ;
cout<<"enter element a43: "<<endl;
cin>>a43 ;
cout<<"enter element a44: "<<endl;
cin>>a44 ;
cout<<"enter element a45: "<<endl;
cin>>a45 ;
cout<<"enter element a46: "<<endl;
cin>>a46 ;
cout<<"enter element a47: "<<endl;
cin>>a47 ;
cout<<"enter element a51: "<<endl;
cin>>a51 ;
cout<<"enter element a52: "<<endl;
cin>>a52 ;
cout<<"enter element a53: "<<endl;
cin>>a53 ;
cout<<"enter element a54: "<<endl;
cin>>a54 ;
cout<<"enter element a55: "<<endl;
cin>>a55 ;
cout<<"enter element a56: "<<endl;
cin>>a56 ;
cout<<"enter element a57: "<<endl;
cin>>a57 ;
cout<<"enter element a61: "<<endl;
cin>>a61 ;
cout<<"enter element a62: "<<endl;
cin>>a62 ;
cout<<"enter element a63: "<<endl;
cin>>a63 ;
cout<<"enter element a64: "<<endl;
cin>>a64 ;
cout<<"enter element a65: "<<endl;
cin>>a65 ;
cout<<"enter element a66: "<<endl;
cin>>a66 ;
cout<<"enter element a67: "<<endl;
cin>>a67 ;
cout<<"enter element a71: "<<endl;
cin>>a71 ;
cout<<"enter element a72: "<<endl;
cin>>a72 ;
cout<<"enter element a73: "<<endl;
cin>>a73 ;
cout<<"enter element a74: "<<endl;
cin>>a74 ;
cout<<"enter element a75: "<<endl;
cin>>a75 ;
cout<<"enter element a76: "<<endl;
cin>>a76 ;
cout<<"enter element a77: "<<endl;
cin>>a77 ;
y110 = a11 / a11 ;
y120 = a12 / a11 ;
y130 = a13 / a11 ;
y140 = a14 / a11 ;
y150 = a15 / a11 ;
y160 = a16 / a11 ;
y170 = a17 / a11 ;
y220 = a22 (a21) * (a12) / (a11) ;
y230 = a23 (a21) * (a13) / (a11) ;
y240 = a24 (a21) * (a14) / a11 ;
y250 = a25 (a21) * (a15) / a11 ;
y260 = a26 (a21) * (a16) / a11 ;
y270 = a27 (a21) * (a17) / a11 ;
y320 = a32 (a31) * (a12) / a11 ;
y330 = a33 (a31) * (a13) / a11 ;
y340 = a34 (a31) * (a14) / a11 ;
y350 = a35 (a31) * (a15) / a11 ;
y360 = a36 (a31) * (a16) / a11 ;
y370 = a37 (a31) * (a17) / a11 ;
y420 = a42 (a41) * (a12) / a11 ;
y430 = a43 (a41) * (a13) / a11 ;
y440 = a44 (a41) * (a14) / a11 ;
y450 = a45 (a41) * (a15) / a11 ;
y460 = a46 (a41) * (a16) / a11 ;
y470 = a47 (a41) * (a17) / a11 ;
y520 = a52 (a51) * (a12) / a11 ;
y530 = a53 (a51) * (a13) / a11 ;
y540 = a54 (a51) * (a14) / a11 ;
y550 = a55 (a51) * (a15) / a11 ;
y560 = a56 (a51) * (a16) / a11 ;
y570 = a57 (a51) * (a17) / a11 ;
y620 = a62 (a61) * (a12) / a11 ;
y630 = a63 (a61) * (a13) / a11 ;
y640 = a64 (a61) * (a14) / a11 ;
y650 = a65 (a61) * (a15) / a11 ;
y660 = a66 (a61) * (a16) / a11 ;
y670 = a67 (a61) * (a17) / a11 ;
y720 = a72 (a71) * (a12) / a11 ;
y730 = a73 (a71) * (a13) / a11 ;
y740 = a74 (a71) * (a14) / a11 ;
y750 = a75 (a71) * (a15) / a11 ;
y760 = a76 (a71) * (a16) / a11 ;
y770 = a77 (a71) * (a17) / a11 ;
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 ;
cout<<"enter right hand side of equation or mismatch m1: "<<endl;
cin>>m1 ;
cout<<"enter element m2: "<<endl;
cin>>m2 ;
cout<<"enter element m3: "<<endl;
cin>>m3 ;
cout<<"enter element m4: "<<endl;
cin>>m4 ;
cout<<"enter element m5: "<<endl;
cin>>m5 ;
cout<<"enter element m6: "<<endl;
cin>>m6 ;
cout<<"enter element m7: "<<endl;
cin>>m7 ;
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 ;
v6 = (m6 (v1) * (a61) (y620) * (v2) (y631) * (v3) (y642) * (v4) (y653) * (v5)) / y664 ;
v7 = (m7 (v1) * (a71) (y720) * (v2) (y731) * (v3) (y742) * (v4) (y753) * (v5) (y764) * (v6)) /
y775 ;
f7 = v7 ;
f6 = (v6 ((y675) * (f7))) ;
f5 = (v5 ((y564) * (f6)) ((y574) * (f7))) ;
f4 = (v4 ((y453) * (f5)) ((y463) * (f6)) ((y473) * (f7))) ;
f3 = (v3 ((y342) * (f4)) ((y352) * (f5)) ((y362) * (f6)) ((y372) * (f7))) ;
f2 = (v2 ((y231) * (f3)) ((y241) * (f4)) ((y251) * (f5)) ((y261) * (f6)) ((y271) * (f7))) ;
f1 = (v1 ((y120) * (f2)) ((y130) * (f3)) ((y140) * (f4)) ((y150) * (f5)) ((y160) * (f6)) ((y170) *
(f7))) ;
cout<<"the elements of the lower matrix:a11,a12,a13,a14,a15,a16,a17,a21,a22,"<<endl
<<"a23,a24,a25,a26,a27,a31,a32,a33,a34,a35,a36,a37,a41,a42,a43,a44,a45,a46,a47,"<<endl
<<"a51,a52,a53,a54,a55,a56,a57,a61,a62,a63,a64,a65,a66,a67,a71,a72,a73,a74,a75,"<<endl
<<"a51,a52,a53,a76,a77: "<<a11<<",0,0,0,0,0,0,"<<a21<<","<<y220<<",0,0,0,0,0"<<endl
<<a31<<","<<y320<<","<<y331<<",0,0,0,0,"<<a41<<","<<y420<<","<<y431<<","<<y442<<endl
<<"0,0,0"<<a51<<","<<y520<<","<<y531<<","<<y542<<","<<y553<<",0,0,"<<endl
<<a61<<","<<y620<<","<<y631<<","<<y642<<","<<y653<<","<<y664<<","<<endl
<<a71<<","<<y720<<","<<y731<<","<<y742<<","<<y753<<","<<y764<<","<<y775<<endl;
cout<<"the elements of the upper matrix:a11,a12,a13,a14,a15,a16,a17,a21,a22"<<endl
<<"a23,a24,a25,a26,a27,a31,a32,a33,a34,a35,a36,a37,a41,a42,a43,a44,a45,a46"<<endl
<<"a47,a51,a52,a53,a54,a56,a57,a61,a62,a63,a64,a65,a66,a67,a71,a72,a73,a74,a75"<<endl
<<"a76,a77: "<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<y150<<","<<endl
<<y160<<","<<y170<<"0,"<<y221<<","<<y231<<","<<y241<<","<<y251<<","<<y261<<","<<endl
<<y271<<","<<"0,0,"<<y332<<","<<y342<<","<<y352<<","<<y362<<","<<y372<<endl
<<"0,0,0,"<<y443<<","<<y453<<","<<y463<<","<<y473<<endl
<<"0,0,0,0,"<<y554<<","<<y564<<","<<y574<<endl
<<"0,0,0,0,0"<<y665<<","<<y675<<endl
<<"0,0,0,0,0,0,1"<<endl;
cout<<"the variables v7,v6,v5,v4,v3,v2 & v1 are: "<<f7<<","<<f6<<","<<f5<<","<<endl
<<f4<<","<<f3<<","<<f2<<","<<f1<<"."<<endl;
fout<<"the elements of the lower matrix:a11,a12,a13,a14,a15,a16,a17,a21,a22,"<<endl
<<"a23,a24,a25,a26,a27,a31,a32,a33,a34,a35,a36,a37,a41,a42,a43,a44,a45,a46,a47,"<<endl
<<"a51,a52,a53,a54,a55,a56,a57,a61,a62,a63,a64,a65,a66,a67,a71,a72,a73,a74,a75,"<<endl
<<"a51,a52,a53,a76,a77: "<<a11<<",0,0,0,0,0,0,"<<a21<<","<<y220<<",0,0,0,0,0"<<endl
<<a31<<","<<y320<<","<<y331<<",0,0,0,0,"<<a41<<","<<y420<<","<<y431<<","<<y442<<endl
<<"0,0,0"<<a51<<","<<y520<<","<<y531<<","<<y542<<","<<y553<<",0,0,"<<endl
<<a61<<","<<y620<<","<<y631<<","<<y642<<","<<y653<<","<<y664<<","<<endl
<<a71<<","<<y720<<","<<y731<<","<<y742<<","<<y753<<","<<y764<<","<<y775<<endl
<<"the elements of the upper matrix:a11,a12,a13,a14,a15,a16,a17,a21,a22"<<endl
<<"a23,a24,a25,a26,a27,a31,a32,a33,a34,a35,a36,a37,a41,a42,a43,a44,a45,a46"<<endl
<<"a47,a51,a52,a53,a54,a56,a57,a61,a62,a63,a64,a65,a66,a67,a71,a72,a73,a74,a75"<<endl
<<"a76,a77: "<<y110<<","<<y120<<","<<y130<<","<<y140<<","<<y150<<","<<endl
<<y160<<","<<y170<<"0,"<<y221<<","<<y231<<","<<y241<<","<<y251<<","<<y261<<","<<endl
<<y271<<","<<"0,0,"<<y332<<","<<y342<<","<<y352<<","<<y362<<","<<y372<<endl
<<"0,0,0,"<<y443<<","<<y453<<","<<y463<<","<<y473<<endl
<<"0,0,0,0,"<<y554<<","<<y564<<","<<y574<<endl
<<"0,0,0,0,0"<<y665<<","<<y675<<endl
<<"0,0,0,0,0,0,1"<<endl
<<"the variables v7,v6,v5,v4,v3,v2 & v1 are: "<<f7<<","<<f6<<","<<f5<<","<<endl
<<f4<<","<<f3<<","<<f2<<","<<f1<<"."<<endl;
fout.close();
break;
case 'q': quit = 1;
break ;
}
}
}