APPLICATION OF COMPUTER BASED SIMULATION IN GAS NETWORK SYSTEM USING GRAPH THEORY ALGORITHMS AND NUMERICAL METHODS POH HONG HWEE UNIVERSITI TEKNOLOGI MALAYSIA To my beloved father, mother, brothers and sister. ACKNOWLEDGEMENTS I would to take this opportunity to express my appreciation to my supervisors, Prof. Dr Zulkelfi Yaacob and Assoc. Prof. Dr. Rahmat Mohsin, who spent their precious time to guide, encourages, inspires and even helps me to solve my problems patiently during my research. I would like to thank my family for their unselfish support, patience and encouragement during the whole period of the research. I thank them all and dedicate this thesis to them with all my love. Last but not least, I would like to express my thanks to all other friends that support and help me in this research. Thank you. ABSTRACT The existing gas network software is highly depending on the Breadth First Search (BFS) and the Depth First Search (DFS) in performing gas network computation of any topology. This is causing the other graph theory algorithms remain least known to users. Apart from that, there are many numerical methods that can be used in performing the gas pipeline network analysis. Thus, the hypothesis of the method states that the Newton Gauss Elimination method is faster and more accurate than the Newton Gauss Seidel method. The objectives of this research are to determine the fastest graph theory algorithm , and to determine the fastest and the most accurate numerical method, in the development of gas network computer simulator. The developed computer simulator applies the Newton Nodal Method in performing the network analysis. Object oriented approach was used in designing the structure of the computer simulator. Two case studies and one extended case study were performed. Case study 1 and 2 involve 5 nodes low pressure gas pipeline network and 6 nodes medium pressure gas pipeline network respectively. The extended case study 1 involves 7 nodes high pressure gas pipeline network. The flow results from the computer simulator in the case study 1 and 2 were compared with GaPIS version 2.3. While in the extended case study, two flow equations for high pressure gas network system were compared for the accuracy. In conclusion, the BFS is the fastest graph theory with 5.37 milliseconds for case study 1, 5.48 milliseconds for case study 2 and 5. 62 milliseconds for extended case study 1. The Newton Gauss Elimination is the fastest numerical method with 34.86 milliseconds for case study 1, 46.35 milliseconds for case study 2 and 50.26 milliseconds for extended case study 1. The combination of BFS and Newton Gauss Elimination gives the fastest speed, with 40.23 milliseconds in case study 1, 51.83 milliseconds in case study 2 and 55.87 milliseconds in extended case study 1. The average accurac ies of both numerical methods for case study 1, case study 2 and extended case study 1 are 99.22%, 95.64% and 91.71% respectively. ABSTRAK Perisian komputer gas sekarang amat bergantung kepada Breadth First Search (BFS) dan Depth First Search (DFS) untuk mewakili sistem rangkaian gas dalam komputer. Ini menyebabkan teori graf yang lain kurang diketahui oleh pengguna. Di samping itu, terdapat pelbagai kaedah berangka boleh digunakan dalam menyelesaikan analisis rangkaian talian gas. Oleh itu, hipotesis tentang kaedah ini menyatakan bahawa Newton Gauss Elimination adalah lebih cepat dan lebih jitu daripada kaedah Newton Gauss Seidel. Objektif kajian ini adalah untuk menentukan teori graf yang paling pantas, dan menentukan kaedah berangka yang paling pantas dan paling jitu dalam membangunkan suatu perisian simulasi rangkaian gas. Perisian simulasi ini mengaplikasikan kaedah Newton Nodal dalam menyelesaikan analisis rangkaian. Pendekatan berorientasi objek telah digunakan dalam mereka struktur utama perisian simulasi. Dua kajian kes dan satu kajian kes tambahan telah dijalankan. Kajian kes 1 dan 2 masing-masing melibatkan 5 nod talian rangkaian gas bertekanan rendah dan 6 nod talian rangkaian gas bertekanan sederhana. Kajian kes tambahan 1 melibatkan 7 nod talian rangkaian gas bertekanan tinggi. Nilai aliran daripada perisian simulasi bagi kajian kes 1 dan 2 dibandingkan dengan keputusan daripada GaPIS versi 2.3. Manakala, untuk kajian kes tambahan, dua persamaan aliran bagi rangkaian gas bertekanan tinggi telah dibandingkan untuk menilai kejituannya. Pada kesimpulannya, BFS ialah teori graf yang terpantas, dengan 5.37 milisaat untuk kajian kes 1, 5.48 milisaat untuk kajian kes 2 dan 5.62 milisaat untuk kajian kes tambahan 1. Newton Gauss Elimination ialah kaedah berangka yang terpantas dengan 34.86 milisaat untuk kajian kes 1, 46.35 milisaat untuk kajian kes 2 and 50.26 milisaat untuk kajian kes tambahan 1. Penggabungan BFS dengan Netwon Gauss Elimination memberikan kelajuan terpantas, dengan 40.23 milisaat bagi kajian kes 1, 51.83 milisaat bagi kajian kes 2 and 55.87 milisaat bagi kajian kes tambahan 1. Kejituan purata bagi kedua-dua kaedah berangka untuk kajian kes 1, kajian kes 2 dan kajian kes tambahan 1 ialah 99.22%, 95.64 dan 91.71%. TABLE OF CONTENTS CHAPTER TITLE TITLE PAGE i DECLARATION ii DEDICATION iii ACKNOWLEDGEMENTS iv ABSTRACT v ABSTRAK TABLE OF CONTENTS 1 2 PAGE vii x LIST OF TABLES xiv LIST OF FIGURES xvi LIST OF ABBREVIATION xix INTRODUCTION 1.1 Introduction 1 1.2 Problem Statement 2 1.3 Objectives 3 1.4 Scope of Study 3 LITERATURE REVIEW 2.1 Introduction 5 2.2 Gas Network 5 2.3 Object Oriented 6 2.3.1 Object 8 2.3.2 Message 9 2.3.3 Class 9 2.3.4 Domain 9 2.3.5 Object Oriented Decomposition 9 2.3.6 Notation 10 2.3.7 Object Oriented Development 11 2.3.7.1 Encapsulation 11 2.3.7.2 Inheritance and Reuse 11 2.3.7.3 Polymorphism 11 2.4 Graph Theory 2.4.1 Depth First Search 11 12 2.4.2 Breadth First Search 13 2.4.3 13 Spanning Tree Algorithm 2.4.4 Dijkstra’s Minimum Path Algorithms 15 2.4.5 Strongly Connected Components 16 2.4.6 Application of Graph Theory Algorithms In 16 Gas Network System 2.4.7 Basic Analysis of Graph Theory Algorithms 19 2.5 Network Analysis 20 2.6 Common Flow Equations 21 2.6.1 Selection of Flow Equations 22 2.6.2 Kirchhoff’s First Law 25 2.6.3 Kirchhoff’s Second Law 27 2.6.4 Newton Nodal Method 28 2.6.5 Newton Loop Method 32 2.6.6 Newton Nodal Method Versus Newton Loop 36 Method 2.7 Numerical Solution Of Linear Algebraic Equation 2.7.1 Gauss Elimination Method 37 2.7.2 Gauss Seidel Method 39 2.8 Commercial Software 3 36 40 METHODOLOGY 3.1 Introduction 42 3.2 Structural Design Method 43 3.5 Object Oriented Approach for Computer simulator 44 Design 3.4 Procedure 45 3.5 Computer Program Selection 46 3.6 Formulae and Methods Selection 46 3.7 Computer Simulator Development 47 3.7.1 Graphical User Interface(GUI) 47 3.8 Results Testing 48 3.9 Modification 49 3.10 Results 49 3.11 Process Flow Diagram for Computer Simulator 49 3.11.1 Graph/Drawing Type Selection 51 3.11.2 Draw the Graph/Drawing 51 3.11.3 Algorithms Selection 51 3.11.4 Graph Results 51 3.11.5 Data Input For Network System and Network 52 System Calculation 3.11.6 Calculation Results 4 5 53 COMPUTER SIMULATOR FEATURES 4.1 Introduction 56 4.2 Properties Information 56 4.3 User Interface Features 58 4.4 Computer Simulator Tools 59 4.5 Dialog Boxes 62 4.6 Main Menu 65 4.7 Simple User Guide 67 4.8 Hardware and Software Requirements 70 RESULTS AND DISCUSSION 5.1 Introduction 71 5.2 Analysis on Case Studies 71 5.3 Speed Analysis For Gas Network System 78 5.3.1 Speed test without N etwork Analysis 79 5.3.2 Speed test With Network Analysis 84 5.3.3 Speed Test Analysis for Case Study 1 86 5.3.4 Speed Test Analysis for Case Study 2 92 5.3.5 Speed Test Analysis for Extended Case Study 97 1 5.3.6 Discussion on Speed test with Network 102 Analysis 5.4 Accuracy Analysis For Gas Network System 103 5.4.1 Accuracy Analysis For Case Study 1 103 5.4.2 Accuracy Analysis For Case Study 2 106 5.4.3 Accuracy Analysis For Extended Case Study 109 1 5.4.4 6 REFERENCE Discussion on the Accuracy Analysis 112 CONCLUSION AND RECOMMENDATION 6.1 Conclusion 113 6.2 Recommendation 115 116 LIST OF TABLES TABLES 2.1 TITLE Main kinds of programming styles and kinds of abstractions PAGE 6 used 2.2 Minimum Spanning Tree algorithm 18 2.3 Basic Analysis on Graph Theory Algorithms 20 2.4 Guidelines to Selection of a flow equation for Distribution 23 System Calculation 2.5 Flow Equations 24 2.6 Limitation and Assumption Made for the Six Flow Equations 25 2.7 The Summary of Commercial Software Studied 41 4.1 Hardware and Software Requirements for User and Developer 70 5.1 Case studies pr operties 72 5.2 Input Data for Study Case 1 73 5.3 Input Data for Study Case 2 75 5.4 Input Data for Study Case 3 77 5.5 Speed Analysis Results without Network Analysis in Three 80 Case Studies 5.6 One Iteration Time for the Case Study 1 with Gauss 84 Elimination and Gauss Seidel Method 5.6.1 Total Iteration Time for the Case Study 1 with Gauss 84 Elimination and Gauss Seidel Method 5.7 One Iteration Time for the Case Study 2 with Gauss 85 Elimination and Gauss Seidel Method 5.7.1 Total Iteration Time for the Case Study 2 with Gauss 85 Elimination and Gauss Seidel Method 5.8 One Iteration Time for the Case Study 3 with Gauss Elimination and Gauss Seidel Method 85 5.8.1 Total Iteration Time for the Case Study 3 with Gauss 86 Elimination and Gauss Seide l Method 5.9 Accuracy Analysis in Case Study 1 104 5.10 Accuracy Analysis in Case Study 2 107 5.11 Accuracy Analysis in Case Study 3 110 LIST OF FIGURES FIGURES TITLE PAGE 2.1 Example of a Graph 17 2.2 Example of a Weighted Graph 18 2.3 Graph of gas network system for Newton Nodal Method 30 2.4 Graph of gas network system for Newton Loop Method 34 3.1 Algorithms Decomposition For Computer simulator Design 43 3.2 Overview of the basic structure of the computer simulator 44 based on the object-oriented concept 3.3 Procedure of computer simulator development 45 3.4 Process Flow Diagram for Computer Simulator 50 3.5 Flow chart of Process Occurs inside Algorithms Selection 54 3.6 Flow chart of Processes Occur in Network System 55 Calculation 4.1 Main Screen of Computer Simulator with a Sample Graph 58 4.2 General Toolbars 59 4.3 Drawing and Algorithms Toolbars 60 4.4 Algorithms Buttons 61 4.5 Results Display Column 61 4.6 Information Dialog box 62 4.7 Input Data Dialog Box for Node 63 4.8 Input Data Dialog Box for Pipe 64 4.9 Results Dialog Box 65 4.10 Converter 67 5.1 Schematic diagram for case study 1 74 5.2 Schematic diagram for case study 2 76 5.3 Schematic diagram for Extended Case Study 1 78 5.4 Computation Time for Case Study 1 versus Graph Theory 81 Algorithms 5.5 Computation Time for Case Study 2 versus Graph Theory 82 Algorithms 5.6 Computation Time for Extended Case Study 1 versus Graph 83 Theory Algorithms 5.7 One Iteration Time for case study 1 versus the Newton Gauss 89 Elimination and Gauss Seidel Method 5.8 Total Iteration Time for case study 1 versus the Newton 90 Gauss Elimination and Gauss Seidel Method 5.9 Computation Time for case study 1 versus the Graph Theory 91 Algorithms and Numerical Methods 5.10 One Iteration Time for case study 2 versus the Newton Gauss 94 Elimination and Gauss Seidel Method 5.11 Total Iteration Time for case study 2 versus the Newton 95 Gauss Elimination and Gauss Seidel Method 5.12 Computation Time for case study 2 versus the Graph Theory 96 Algorithms and Numerical Methods 5.13 One Iteration Time for Extended Case Study 1 versus the 99 Newton Gauss Elimination and Gauss Seidel Method 5.14 Total Iteration Time for Extended Case Study 1 versus the 100 Newton Gauss Elimination and Gauss Seidel Method 5.15 Computation Time for Extended Case Study 1 versus the 101 Graph Theory Algorithms and Numerical Methods 5.16 Newton Nodal Method (flow comparison case study 1– 105 Newton Gauss Elimination) 5.17 Newton Nodal Method (flow comparison case study 1– 105 Newton Gauss Seidel Method) 5.18 Newton Nodal Method (flow comparison case study 2– 108 Newton Gauss Elimination) 5.19 Newton Nodal Method (flow comparison case study 2– 108 Newton Gauss Seidel Method) 5.20 Newton Nodal Method (flow comparison extended case study 1– Newton Gauss Elimination) 111 5.21 Newton Nodal Method (flow comparison extended case study 1– Newton Gauss Seidel Method) 111 LIST OF ABBREVIATION BFS - Breadth-First Search DFS - Depth-First Search MST - Minimum Spanning Tree path - Edge, branch, chord SCC - Strongly Connected Component vertex - Node, point E - Efficiency factor D - Internal pipe Diameter i - Initial vertex K - Constant flow equation L - Length m Q - Flow rate m3/hr S - Specific gravity of gas T - Temperature K p1 - Pressure at sending node bar/kPa p2 - Pressure at receiving node bar/kPa Pn - Pressure at standard Temperature kPa Tn - Standard Temperature ε a,i - Percentage approximation mm K CHAPTER 1 INTRODUCTION 1.1 Introduction Natural gas is one of the most important energy sources used in the world, besides oil and coal. Normally natural gas is supplied to users through natural gas pipeline system. Many pipeline systems are built throughout the world, from the gas reservoir to the end users, in order to support the highly increasing demand for natural gas. In America alone, from 1996 to 1998, at least 78 pipeline construction projects were completed adding approximately 11.7 billion cubic feet per day of capacity [1]. Meanwhile in Malaysia, as in January 2004, network of gas pipeline covering a total of 1,193.9 kilometres (831.7 kilometres completed) is constantly expanding to reach a larger population [2 ]. Natural gas pipeline systems become very complex as years pass by. The complexity of the gas pipeline systems makes people think ways to solve it. Program development is one of the solutions. With the help of computer program, people can gain information regarding the construction site and the pipeline chosen; design the gas pipeline systems and performing the network analysis before the construction of the actual pipeline systems. This research is to develop a program that can help the users to design the pipeline system and solve the network analysis. Besides that, users can also know the pressure of certain point along the pipeline systems and load or flow rate of the pipe leg. 1.2 Problem Statement Graph theory (graph theory algorithms) is a branch of mathematics concerned about how networks can be encoded and their properties measured [3]. This means in gas engineering term, graph theory is used to represent the gas network computation of any topology before the network analysis can be performed. Generally, graph theory algorithms are used in mathematic field. The existing software (user friendly software) nowadays are highly depending on one or two graph theory algorithms, especially the Breadth First Search (BFS) and Depth First Search (DFS) in order to represent gas network computation of any topology, before working on a network calculation. So, lacks of studies on other graph theory algorithms, led to these graph theory algorithms remain unknown to users. These studies like the way of graph theory algorithms affect on network configuration, way of graph theory algorithms work on gas network system and so on. T his research helps users to understand vividly about the graph theory algorithms, the way of graph theory algorithms work in the gas network system and compare all the graph theory algorithms in order to determine the fastest graph theory algorithms. There are many numerical methods that can be used in solving the network analysis. The commonly used numerical methods are Newton Gauss Elimination method and Newton Gauss Seidel method. Thus, hypothesis of Newton Gauss Elimination method is faster than and more accurate than Newton Gauss Seidel method exists. This research helps users to understand both numerical methods and to determine the fastest and more accurate numerical method on steady state gas network system. 1.3 Objectives The main objective of the research is to determine the fastest graph theory algorithms selected based on the computation time obtained in the development of gas network computer simulator. In addition, the other objective of this research is to determine the fastest and the most accurate numerical methods in the development of gas network computer simulator. The numerical methods will be tested for their speed of execution (computation time) and checked their accuracy based on the flow results obtained from the computer simulator. 1.4 Scope of Study In this research, a computer simulator for gas pipeline network system will be developed. This computer simulator can be used to simulate natural gas distribution network systems. In order to ensure the success of the research, a right path is needed to be carried out step by step. The most important step is to choose the right computer program, which will be used to develop the computer simulator , and the programming language . MS Visual C++ is chosen due to its speed of execution, simple to use for programmers and developers and it is suitable for the creation of scientific, mathematical and statistical applications. C++ programming language is chosen because it is simple to understand and to code, and it is the programming language for MS Visual C++. After choosing the right computer program and the programming language, studies of the existing software in the market will be done before the design of the structure of the gas network program. Object oriented approach will be used in the designing of the structure of the program. Next, studies on different graph theory algorithms and numerical methods will be done due to different graph theory algorithms and numerical methods will be implemented into the computer simulator. There are five graph theory algorithms that will be studied, which are Breadth First Search (BFS), Depth First Search (DFS), Minimum Spanning Tree (MST), Strongly Connected Components (SCC) and Dijkstra’s Minimum Path. Meanwhile, two numerical methods are studied, which are the Newton Gauss Elimination method and the Newton Gauss Seidel method. The final step is to study the way of performing the network analysis. In performing the network analysis, Newton Nodal method in steady state condition and several of flow equations will be used. A network is in a steady state when the values of the quantities characterizing the flow of gas in the system are independent of time and the system is described by a set of nonlinear algebraic equations [4]. In steady state analysis, the pressure of the nodes and the flow rate in the pipes must satisfy the flow equations and the value of load node and source node must fulfil the two Kirchhoff’s laws, which are the Kirchhoff’s first law and Kirchhoff’s second law (see Chapter 2). CHAPTER 2 LITERATURE REVIEW 2.1 Introduction Literature revie w is a very important part in this research. It works as the foundation of this research, which is to determine the most suitable way to develop the computer simulator. In order to develop the simulator, studies on the concepts of gas network, graph theory algorithms, object oriented and network analysis are needed. 2.2 Gas Network In general, gas network system is built with the purpose of transferring natural gas in high capacity, which normal storage tanks cannot supply this capacity of gas. So, a gas network system is able to supply the high capacity and high pressure of gas directly to the users of the gas. Gas distribution network can be classified in two different types namely tree or loop [5, 6]. The concept of the tree and loop as mathematical entities was firstly proposed by Kirchhoff in the connection with the definition of fundamental circuits used in the analysis of electrical circuit [7]. The tree type pipeline system happens where the pipeline system is not in the loop condition. While for the loop type system, the pipeline system contains loops. It is much easier to solve the calculations for the tree type system compare to the loop type pipeline system. This is due to the looped nature, gas flow and direction of each pipe cannot easily be calculated. By calculating the pressure drop of the pipeline based on appropriate formulations can easily solve the calculations of the tree type pipeline system. While for the loop type pipeline system, a trial and error method is needed to solve the network calculation, with the help of specified formulations and numerical methods. 2.3 Object Oriented There are about five main kinds of programming styles. Table 2.1 shows the kinds of programming styles, as well as kinds of abstractions used [8]. Table 2.1: Main kinds of programming styles and kinds of abstractions used Programming Styles Abstractions Procedure oriented Algorithms Object oriented Classes and Objects Logic oriented Goals, often expressed in a predicate calculus Rule oriented If-then rules Constraint oriented Invariant relationships Procedure oriented is the oldest programming style while object oriented is the latest programming style, often used by programmers nowadays. Object-oriented programming is intended to promote greater flexibility and maintainability in programming, and is widely popular in large -scale software engineering [9]. In this research, the computer simulator developed can be considered as a large -scale engineering project because it contains many equations, graph theory algorithms, numerical methods and formulations that needed to be code. Besides that, the computer simulator developed must be able to provide platform for future enhancement so that the computer simulator can become commercial software. The computer simulator developed must be user-friendly and contains Graphical User Interface (GUI) too. Object oriented is suitable in developing the Graphical User Interface (GUI). Due to these reasons, object oriented approach is chosen for design the basic structure of the simulator . B y using this approach, an architectural framework of the simulator can be formed. In order to use this approach, firstly, one has to understand the meaning of object oriented programming, object or iented analysis and object oriented design. The meanings of these three important phases of object oriented are as shown as below [8, 10, and 11]. “Object oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some classes, and whose classes are all members of a hierarchy of classes united via inheritance relationships.” “Object oriented analysis is a method of analysis that examines requirements from the perspective of the classes and object found in the vocabulary of the problem domain” “Object oriented design is a method of design encompassing the process of object oriented decomposition and a notation for depicting both logical and physical as well as static and dynamic models of the system under design” Secondly, one has to understand the meanings of object, message, class, domain, object oriented decomposition and notation. The object-oriented approach for the simulator design is show n in Chapter 3. 2.3.1 Object An object has state, behaviour, and identity; the structure and behaviour of similar object are defined in their common class; the terms instance and object are interchangeable. The state of an object encompasses all of the properties of the object and the current values of each of the properties. The behaviour is how an object acts and reacts, in term of its state changes and message passing. The identity is that property of an object which distinguishes it from all objects [8]. Most objects can be categorized into five categories [12] : i. Tangible objects. Abstractions of the actual existence of some thing in the physical world. For example, pipe, pump, valve and tank in a juice bottling plant. ii. Roles. Abstractions of the purpose or assignment of a person, piece of equipment, or organization. For example, piston, inlet valve and outlet valve in a car engine. iii. Incidents. Abstractions of some happening or occurrence. For example, accident in plant. iv. Interactions. Objects that result from associations between other objects. For example, connections of two pipes. v. Specification objects. Objects that used to represent rules, standards, or quality criteria (as opposed to the tangible object or role that meets these standards). For example, a compound represents the composition of a chemical, but not a particular sample of that compound. An object can only act as an actor, server or agent. An actor is object that can operate upon other objects and never operated upon by other objects. A server is object that can only operated upon by other objects. An agent is object that can both operate upon other objects and operated upon by other objects [8]. 2.3.2 Message Message passing only happens when an object relates with other objects [13, 14]. There are two types of messages, which are the unidirectional message and bidirectional message. Unidirectional message is only a one -way message while the bidirectional message is a two-way message. Examples of unidirectional message and bidirectional message are relationships between a general with a soldier and relationships between husband and wife respectively. 2.3.3 Class A class is a set of objects that share a common structure and common behaviour [8]. For example, a metal chair and a wooden chair can be grouped into the same class, called Chair. 2.3.4 Domain A domain is a separate real, hypothetical, or abstract world inhabited by a distinct set of objects that behave according to rules and policies characteristic of the domain [12]. For example, a gas distribution system domain consists of depressurize station, pipeline system, various type of gas users as objects. 2.3.5 Object Oriented Decomposition When designing a complex simulator system, it is essentia l to decompose it into smaller parts. There are two ways of decompositions, that are the algorithms decomposition and the object oriented decomposition [11] . The algorithms decomposition is a method of building top-down structured design, wherein each module in the system denotes a major step in some overall process. This method is based upon algorithms view that highlights the ordering of event. On the other hand, object oriented decomposition is a method which decomposes the system according to the key abstraction in the problem domain. In other word, object oriented decomposition is based upon objects. Both ways of decompositions are useful. However, only one of the ways can be used when designing a complex simulator system. In this research, s ince object oriented approach is used, so, object oriented decomposition is chosen in designing the structure of the gas network system. The reasons of choosing this way of decomposition is it can reduce the risk of building complex simulator system and it is able to evolve over time, because of its stable intermediate form. 2.3.6 Notation Notation is a very important method in the process of simulator development. The notation for object oriented development includes four basic diagrams and two supplementary diagrams [8]. The four basic diagrams are class diagrams, object diagrams and process diagrams while the two supplementary diagrams are state transition diagrams and interaction diagrams. A class diagram is used to show the existence of classes and their relationships in the logical design of a system. An object diagram is used to show the existence of objects and their relationships in the logical design of a system. A module diagram is used to show the allocation of classes and objects to module s in the physical design of a system. A process diagram is used to show the allocation of processes to processors in the physical design of a system. A state transition diagram is used to show the state space of an instance of give class, the events that cause a transition from one state to another, ant the actions that result from a state change. An interaction diagram is used to trace the execution of a scenario in the same context as an object diagram. 2.3.7 Object Oriented Development Object orie nted development includes encapsulation, inheritance and polymorphism. 2.3.7.1 Encapsulation The property of being a self -contained unit is called encapsulation [15]. With encapsulation, data hiding can be accomplished. Data hiding is the highly valued characteristic that an object can be used without the user knowing or caring how it works internally [15]. 2.3.7.2 Inheritance and Reuse Inheritance, also called specialization or derivation, which is supported by C++ [16, 17] , is a way to declare a new type which is an extension of an existing type [15]. The new subclass is said to derive from the existing type and is sometimes called a derived type. It inherits all qualities from the existing types but adds to them or modifies them as needed [15]. 2.3.7.3 Polymorphism Polymorphism is a function and a class which enables different objects to respond differently to the same function call [18]. 2.4 Graph Theory A graph G = (X, A) is a collection of points or vertices (node) x1 , x2 … xn (denoted by the set X) and a collection of lines (edge/branch) a 1 , a2 … an (denoted by the set A) joining all or some of these points [19, 20]. Graph can be divided into directed graph and undirected graph. If the lines in A have direction – which is usually shown by an arrow – they are called arcs and the resulting graph is called a directed graph [19]. Dendrite is a connected network graph Gn without loops [5]. Tree branch is the branches belong to a dendrite and those do not belong to a dendrite are called chords. 2.4.1 Depth First Search (DFS) The procedure of Depth First Search for both directed graph and undirected graph is shown below [21]. 1) Start the search at a vertex v and initialize the search path to v. 2) If there is an unexplored edge (branch) at the vertex at the head of the search path leading to an unexplored vertex w, extend the search path to w, which becomes its new head and repeat step (2). 3) If there is an unexplored edge at the head of the search path leading to an explored vertex w, mark that edge as explored and repeat (2) for the next edge incident at the head of the search path. 4) If there are no further unexplored edges at the head of the search path, retract the search path to the previous vertex by removing the current head of the path and repeat step (2). 5) Stop once the search path is empty. The Depth First Search method visits all the vertices. It always advances from its last explored vertex, making the path drive deeper into the graph before it explores closer region of the graph. 2.4.2 Breadth First Search (BFS) The Breadth First Search method is like the Depth First Search Method. Breadth First Search is a traversal through a graph that touches all the vertices reachable from a particular vertex. However, unlike DFS method, BFS explores all the neighbours of the particular vertex before proceeds to the neighbours of its neighbours. This method is liked a wave of emanating from the stone drop into the pool of water [22]. The algorithm for BFS is given as: At first no vertices of the graph are labelled. 1. Label vertex s with 0. 2. i ? 0 3. Find all unlabeled vertices adjacent to at least one vertex labelled i. If none are found, stop. 4. Label all the vertices found in (3) with i+1. 5. If vertex t is labelled, stop. Depth First Search is useful in identifying structural properties of graphs. On the other hand, for problems, such as maximum flow, where the structural characteristics of depth first search are not needed, breadth first search may lead to better performance [21]. 2.4.3 Spanning Tree Algorithms For a connected, undirected graph, a spanning tree of that graph is a sub- graph which is a tree and connects all the vertices together. A minimum spanning tree is a spanning tree with weight less than or equal to the weight of every other spanning tree. Initially all edges are uncoloured and all buckets are empty [23]. Step 1: Select any edge that is not a loop. Colour this edge blue and place both its endpoints into an empty bucket. Step 2: Select any uncoloured edge that is not a loop. (If no such edge exists, stop the algorithm; no spanning tree exits.) One of four different situations must occur: i. ii. Both endpoints of this edge are in the same bucket. One endpoint of this edge is in a bucket, the other endpoint is not in any bucket. iii. Neither endpoint is in any bucket. iv. Each endpoint is in a different bucket. If item (i) occurs, colour the edge orange (not in the tree) and return to Step 2. If (ii) occurs, colour the edge blue (in the tree) and assign the un-bucketed endpoint to the same bucket as the other endpoint. If (iii) occurs, colour the edge blue and assign both endpoints to an empty bucket. If (iv) occurs, colour the edge blue and combine the contents of both buckets into one bucket, leaving the other bucket empty. Go to Step 3. Step 3: If all the vertices of the graph are in one bucket, stop the algorithm since the blue edges form a spanning tree. Otherwise, return to Step 2. (Note that each time a step of the algorithm is performed an edge is indelibly coloured. If there are only a finite number of edges in the graph, then the algorithm must stop after a finite number of steps) If the algorithm does not terminate with a spanning tree, then no spanning tree exists for the graph for the following reason: The algorithms will terminate with two sets (buckets) of vertices that have no edge joining a member of one set to a member of the other set. Otherwise, such an edge would have been coloured blue by the algorithm and the tow buckets would have been merged together. Hence the algorithm does what it is supposed to do, construct a spanning tree. The minimum spanning tree algorithm examines the edges in order of ascending weight (smallest first, largest last). If two or more edges have the same weight, order them arbitrarily. This algorithm is used in to determine the total weight, which represents cost, length and others of the links used is a minimum; and all the points are connected together. 2.4.4 Dijkstra’s Minimum Path Algorithms Dijkstra’s algorithm solves the shortest path problem for a directed graph with nonnegative edge weights. For example, if the vertices of the graph represent gas wells and edge weights represent distances between pairs of wells connected by a pipeline, this algorithm can be used to find the shortest route between two gas wells. Step 1: Initially all arcs and vertices are uncoloured [23]. Assign a number d(x) to each vertex x to denote the length of the shortest path from s to x that uses only coloured vertices as intermediate vertices. Initially, set d(s) = 0 and d(x) = 8 for all x ? s. Let y denote the last vertex to be coloured. Colour vertex s and let y = s. Step 2: For each uncoloured vertex x, redefine d(x) as follow: d ( x ) = min{ d ( x ), d ( y ) + a ( y , x )} where a ( y, x) = length of the arc or edge from y to any neighbour x of w. If d(x) = 8 for all uncoloured x, then stop because no path exists from s to any uncoloured vertex. Otherwise, colour the uncoloured vertex x with the smallest value of d(x). Also colour the arc directed into vertex x from a colo ured vertex that determined the value of d(x) in the above minimization. Let y = x. Step 3: If vertex t has been coloured stop because a shortest path from s to t has been discovered. This path consists of the unique path of coloured arcs form s to t. If vertex t has not been colo ured yet, repeat Step 2. 2.4.5 Strongly Connected Components A graph is said to be strongly connected if for any two vertices xi and xj, there is at least one path going to vertices xi and xj [21]. For a strongly connected graph, vertex xj is reachable from vertex xi and vice versa for any xi and xj , the strong component containing a given vertex xi is unique and xi will appear in the set of vertices of one and only one strong component. For example: Considering a gas piping network. The network is strongly connected if the gas flows in one direction between every two positions. The network is weakly connected if the gas flows in both directions between every two positions. The network is disconnected if there is no possible way for the gas to flow from one point to another. Strongly connected components algorithms use DFS or BFS method in order to check whether the graph tested is strongly connected. 2.4.6 Application of Graph Theory Algorithms In Gas Network System As stated, graph theory is very useful in order to represent the gas network computation of any topology. Thus, graph theory can check the connectivity of the gas network system. 6 3 5 2 1Figure 2.1: Example of a Graph. 4 5 Based on Figure 2.1, using Breadth First Search method, to reach node 5 1 from node 1, firstly all the neighbouring nodes of node 1, which4are node 2 and node 3 3 will be checked. After that node 2 will go to node 4 while node 3 will go to node 4 2 and node 5. Lastly the method stops due to the desired node is reached. This means this graph is a connected graph. For the same figure, now using the Depth First Search method, to reach node 5 from node 1, firstly node 1 will go to node 2 through edge 1. This is followed respectively by the nodes, which are from node 2 to node 4 through edge 3, from node 4 to node 3 through edge 4 and from node 3 to node 5 through edge 6. After all the nodes are touched, the method stops. The graph now is also a connected graph. Now, saying the graph shown in Figure 2.1 is changed to a weighted graph like Figure 2.2 as shown in the following page. 3 7 5 3 9 1 4 2 6 Note: Weight 2 Figure 2.2: Example of a Weighted Graph. The summary of using the Minimum Spanning Tree algorithm is indicated in Table 2.2 as below. Table 2.2: Minimum Spanning Tree Algorithm. Edges Weight Bucket 1 Bucket 2 Colour? (1, 2) 2 1, 2 Empty v (1, 3) 3 1, 2, 3 Empty v (2, 4) 6 1, 2, 3, 4 Empty v (3, 5) 7 1, 2, 3, 4, 5 Empty v (4, 5) 9 1, 2, 3, 4, 5 Empty × Since all the vertices are in the bucket, the algorithm stops at edge (3, 5). Edge (4, 5) is uncoloured. Four edges (1, 2), (1, 3), (2, 4) and (3, 5) form a minimum spanning tree of the graph. Using strongly connected components algorithm, if DFS method is chosen, the graph is strongly connected. The strongly connected components number is 1. Using Dijkstra’s algorithm, the steps used in carrying out the analysis are given as (from vertex 1 to vertex 5, so s=1; t=5): i. Initially only vertex 1 is coloured, d(1) = 0, and d(x) = 8 for all x ? 1 ii. Set y = 1 d(2) = min {d(2),d(1) + a(1,2)} = min {8,0+2} = 2 d(3) = min {d(3),d(1) + a(1,3)} = min {8,0+3} = 3 d(4) = min {d(4),d(1) + a(1,4)} = min {8,0+8} = 8 d(5) = min {d(5),d(1) + a(1,5)} = min {8,0+8} = 8 As a result, d(2) = 2 iii. Colour vertex 2 and edge (1,2) iv. Proceed with y = 2, y = 3, y = 4, y = 5 until vertex 5 is coloured. v. Final shortest path arborescence consists of edge (1,2), (1,3), (3,5) and (2,4). vi. Shortest path consists of (1,3) and (3,5) with length 3+7 = 10 Understanding the effects of different graph theory algorithms on the gas network system is very important. By using graph theory algorithms, any graph in the gas network system drawn can be proved whether the graph drawn is connected or not. If the graph drawn is not connected, the algorithms will tell the defects to users. Different graph theory algorithms have different computation time. If the graph drawn is very large, it means the computation time become longer. The longer the computation time means users have to wait longer time. Besides that, the shortest path for the starting vertex to the ending vertex can be determined. This helps users to find out the total minimum length and cost. 2.4.7 Basic Analysis on Graph Theory Algorithms After studying all the five graph theory algorithms, a basic analysis on all the graph theory algorithms has been done. This basic analysis is done with the purpose of helping the user to have a clear picture on all the five graph theory algorithms that will be used in the development of gas network computer simulator. Table 2.3 is the summary of analysis on graph theory algorithms based on the difference in the methods used and their applications. Table 2.3 : Basic Analysis of Graph Theory Algorithms. Algorithms Analysis Method BFS Uses a queue Application Used to find the shortest path in unweighted graph DFS Uses a stack Used to find cycles, to produce topological ordering or to determine which nodes are reachable from a given node MST Dijkstra’s Examining the edge in the Used to obtain optimal solution and order of ascending weight a minimum total cost in a graph Used shortest path algorithm Used to find the shortest path from Shortest the given node to the destination Path node in weighted graph SCC Uses DFS method Used to find the strong connected components in directed graph 2.5 Network Analysis Natural gas network analysis is used to determine the amount of gas, flow rate of the gas and the pressure used in a pipeline system. Besides that, it also can used to determine the usage of gas by consumers especially during the peak times. By making the network analysis, time of maintenance and failure of pipeline can be measured. The effect of new load on the pipeline also can be predicted. Generally, network analysis can be divided into three type, that are Network tracing, Network routing and Network Allocation [24]. Network tracing is done in order to trace the location of the particular pipeline in the system. Network routing is done in order to find out the optimum path or the shortest path, which costs less for the system. Network allocation is done in order to relocate all the pipelines into the main support. 2.6 Common Flow Equations Common flow equation can be expressed in a general form [4]. For any pipe k, the pipe flow equation from node i to node j can be expressed as φ[(Q n ) k ] = K k (Q nm1 ) k where φ[(Qn ) k ] k = the flow function for pipe k Kk = the pipe constant for pipe k (Qn ) k = the flow in pipe k m1 = the flow exponent = 2 for low pressure networks = 1.848 for medium pressure networks = 1.854 for high pressure networks. For the low pressure version of the flow equation, φ[(Qn ) k ] = K k (Qn2 ) k = pi − p j = ∆pk where ∆ pk = the pressure drop for pipe k, pi = the absolute pressure at node i, (i = the sending node of pipe k) p j = the absolute pressure at node j. (j = the receiving node of pipe k) For the medium and high pressure version of the flow equation φ[(Qn ) k ] = K k (Qnm1 ) k = Pi − P j = ∆Pk where Pi = pi2 , Pj = p 2j The equations for low pressure and for medium and high pressures can be rearranged: 1 φ[ ∆pk ] = (Qn ) k = ( ∆pk / K k ) 2 (2. 1) 1 φ[ ∆Pk ] = (Qn ) k = (∆Pk / K k ) m 1 (2.2) Equations (2.1) and (2.2) can be rearranged to the form as below after taking account of the fact that a change of the flow direction of the gas stream may take place in the network. (Qn ) k = S ij ( (Qn ) k = S ij ( S ij ( p i − p j ) Kk S ij ( p i − p j ) Kk 1 )2 (2.3) 1 ) m1 (2.4) where S ij = 1 if Pi > Pj ( p i > p j ) , S ij = −1 if Pi < Pj ( p i < p j ) 2.6.1 Selection of Flow Equations Flow equations are required to calculate the pressure drop in the gas network system. There are many flow equations that can be used in gas industry. Majority of them are developed based on the results of gas flow experiments. Thus, they are only capable to a limited range of flow and pipe surface conditions Table 2.4 shows the guidelines to the selection of a flow equation for the distribution system calculation [25, 26]. . Six flow equations are mainly used in this research and applied into the computer simulator. They are Lacey’s equation, Pole’s equation, Cox’s equation, Polyflo equation, Panhandle ‘A’ equation and Weymouth equation [27, 28, 29, 30 and 31]. These equations are shown in Table 2.5. Lacey’s and Pole’s equation are flow equations for low pressure network. Cox’s and Polyflo equation are flow equations for medium pressure network. Panhandle ‘A’ and Weymouth equation are flow equations for high pressure network. For Weymouth, length L and D is in meter (m) and pressure P is in Pascal (Pa). Table 2.4: Guidelines to Selection of a flow equation for Distribution System Calculation Type of Predominant Equation Piping Type Used High pressure Partially Panhandle A utility supply turbulent Range of Capacity Relatively good, slightly optimistic appr oximation for mains Smooth pipe Flow Law at Reynolds numbers >30000 High pressure Fully utility supply turbulent Weymouth Good approximation to Fully Turbulent Flow Law for clears mains rough commercial pipe of 10 to 30 inch diameter Medium and Partially High pressure turbulent Panhandle A Relatively good, slightly optimistic approximation for distribution Smooth pipe Flow Law at Reynolds numbers >30000 Medium and Partially High pressure turbulent Weymouth Very conservative for pipe of less than 20 inch diameter distribution Medium and Partially High pressure turbulent Cox’s Pressure range >5 psi, Velocity <20m/s in all pipes distribution Low pressure Partially distribution turbulent Pole’s Good approximation to Smooth pipe Flow Law for pipe of 4 inch diameter or smaller Table 2.5: Flow Equations Flow Equation K value Calculation Equations Lacey’ s/Pole’s Cox’s Polyflo Panhandle ‘A’ Weymouth Q = 7.1 × 10 −3 K = 11 .7 × 10 3 ( p1 − p 2 ) D 5 SL K = 206 .22527 × 10 3 2 Q = 1 .69 × 10 −3 Q = 7.57 × 10 −4 Q = 7.57 × 10 −4 L D5 ( p1 − p 2 ) D 5 SL 2 Tn Pn ( p1 − p 2 ) D 5 fSLT K = 27.24 Tn Pn ( p1 − p 2 ) D 5 fSLTZ K = 18.43 2 2 2 2 T ( p1 − p 2 ) Q = 11854124 .6 n D 8 / 3 Pn SLT 2 2 L D5 L E D 4.848 2 L 2 E D 4 .854 K = 2590000 L D 16 / 3 Assumptions have been made for the six flow equations above. These assumptions have been made in order to avoid confus ion to the users of this computer simulator and to help users to understand the reasons of picking the six flow equations above. Table 2.6 shows the limitation and assumptions made for the six flow equations. The fraction factor, f can be calculated using the equations given in the Table 2.6. There is no fraction factor for Cox’s and Weymouth, because the value is already inserted into the flow equations. In this research, the specific of gas is assumed to be 0.589 and the compressibility factor, Z is assumed 0.95. These two values are subjected to change, depend on the type of natural gas (natural gas properties) and the type of pipe used. The temperature and pressure is assumed as standard temperature and standard pressure, normally used by international gas users in solving network analysis. The efficiency factor normally varies between 0.8 and 1 for most gas pipes [32]. The actual flow in a pipe will be 80% of the flow predicted [4]. So, the efficiency factor, E in this research is assumed to be 0.8. Table 2.6: Limitation and Assumption Made for the Six Flow Equations Flow Pressure Equations Range (bar gauge) Assumption Made Fraction factor, f Specific gravity of gas, S Temperature, T and Normal Temperature, T n Normal Pressure, P n Compressibility factor, Z Efficiency factor, E Lacey’ s/Pole’s 0– f = 0.0044 (1 + 0.075 12 0 .276 D S = 0.589 Cox’s 0.75 -7 Polyflo 0.75 - 7 S = 0.589 1  SQ  = 11.98 × E  f ï£ D 0 .076 S = 0.589 T = 288K Panhandle ‘A’ >7 1  SQ  = 14.94 × E   f ï£ D  0 .073 S = 0.589 Tn = T = 288K, Pn = 1.01325 bar Z = 0.95, E = 0.8 Weymouth >7 S = 0.589 Tn = T = 288K, Pn = 101.325 kPa 2.6.2 Kirchhoff’s First Law Kirchhoff’s first law states that the algebraic sum of the flows at any node is zero [4]. This means that any load at any node is equal to the sum of the branch flows into and out of the node. Q1 + Q2 + Q3 ... + Qn = Load Load − Q = 0 Load = Q (2.5) where Q1 + Q2 + Q3 ... + Qn = Q Q = total flow in the branches, depend on the flow direction Load = demand in the load nodes, The nodal equation, equation (2.5) can be expressed in matrix form: L = A1 Q where: L (2.6) = vector of loads at the nodes, Q = vector of flows in the branches , A1 = reduced branch-nodal incidence matrix. The pressure drop in the branches can be related to the nodal pressures. The nodal pressure drop equation can be expressed in matrix form: ∆P = - AT P where: ? P P T A (2.7) = vector of pressure drops in the branch, = vector of nodal pressures, = transpose of branch-nodal incidence matrix. From equation (2.2), Q = φ ' ( ∆P) where φ ’ (?P) = vector of pressure drop functions . Substituting for ? P from equation (2.7), equation (2.8) becomes (2.8) Q = φ ' (- AT P) (2.9) Substituting for Q from equation (2.9), equation (2.6) becomes L = A1 [φ ' ( − A T P )] 2.6.3 (2.10) Kirchhoff’s Second Law Kirchhoff’s second law states that the pressure drop around any closed loop is zero [4]. This means that there is no pressure drop around the loop since the closed loop starts and finishes at the same node. ∆P1 + ∆P2 + ∆P3 ... + ∆Pn = 0 ∆PT = 0 (2.11) where ∆P1 + ∆P2 + ∆P3 ... + ∆Pn = ∆PT ∆PT = pressure drop in the branches, depend on the loop direction The loop equation, equation (2.11) can be expressed in matrix form: B∆P = 0 where: ∆P B (2.12) = vector of pressure drops in the branches, = branch loop incidence matrix Rearrange equation (2.8) , give ∆P = φ (Q) . where φ ’ (Q) = vector of flow functions. (2.13) Substituting for ? P from equation (2.13) , equation (2.12) becomes B[φ (Q)] = 0 2.6.4 (2.14) Newton Nodal Method The set of nodal equations that describes a gas network is shown as below [4, 33] : L = A1 [φ ' ( − A T P )] (2. 10) where: L = vector of loads at the load nodes, of dimension n1, A1 = reduced branch-nodal incidence matrix, AT = transpose of branch nodal incidence matrix, P = vector of nodal pressure, of dimension n, φ ' ( ∆P) = vector of pressure drop functions, of dimension m = = φ ' ( − AT P) This equation can be rearranged as below : A1 [F ’ (-A TP)] – L = 0 (2. 15) Equation (2. 15) is a mathematical representation of Kirchhoff’s first Law. In the nodal method, an initial approximation is made to the nodal pressure. This approximation is then successively corrected until the final solution reached. At the iteration the left hand side of equation (2.15) is not equal to zero. The pressures are only approximations of their true values and the flows calculated from these pressures are not balanced at each node. The imbalance at a node is the nodal error, which is a function of all the nodal pressures and is denoted as f (P 1) where P1 is the vector of squared pressures for high and medium pressure ga s network at the load nodes of dimension n1. There is a nodal error for each node and this set of errors is represented by:  f1 ( P1 , P2 ,...Pn 1 )   f ( P , P ,...P )  n1  F (P1 ) =  2 1 2 ........................     f n 1 ( P1 , P2 ,...Pn1 ) where F denotes a vector of functions. The nodal errors are incorporated into equation (2.6): F (P1 ) = A1 [φ ' (− AT P )] − L (2. 16) The errors F(P1 ) will tend to zero as the pressure approach their true values. The Newton nodal method solves the set of equations (2.16) iteratively until the nodal errors are less than a specified tolerance. The iterative scheme for correcting the approximations to the nodal pressures is (see next page) P1k +1 = P1k + (∂P1 ) k (2. 17) where k = number of iterations. Term ∂P1 is computed from the following equation: J k (∂P1 ) k = −[ F (P1 )]k (2. 18) The matrix J is the nodal Jacobi matrix and is given by ∂ f1   ∂f 1 ∂f 1  ∂P ∂P L ∂P  n1  1 2   ∂f 2 ∂f 2 ∂f 2  L J =  ∂P1 ∂P2 ∂Pn1  M     ∂f n1 ∂f n1 L ∂f n1   ∂P1 ∂P2 ∂Pn1  where f i stands for fi(P1). (2. 19) L2 L3 4 L4 5 3 2 4 2 1 3 1 Figure 2.3: Graph of gas network system for Newton Nodal Method. Assuming the flow equation is as shown as equation (2.4) and based on the chart (2.1) (see above). Hence the nodal equations are: f 2 = S 12 [ S12 f 3 = S 13[ S 13 ( P1 − P2 ) 1 / m1 (P − P2 ) 1 / m1 ] + S 32 [S 32 3 ] − L2 K1 K4 ( P1 − P3 ) 1 / m1 ( P − P2 ) 1 / m1 ( P − P4 ) 1 / m1 ] − S 32 [ S 32 3 ] − S 34 [S 34 3 ] − L3 K2 K4 K5 f 4 = S 14 [ S14 ( P1 − P4 ) 1 / m1 (P − P4 ) 1 / m1 ] + S 34 [S 34 3 ] − L4 K3 K5 (2. 20) The nodal Jacobi matrix is  ∂f 2  ∂P  2  ∂f J= 3  ∂P2  ∂f 4   ∂P2 ∂f 2 ∂f 2  ∂ P3 ∂P4  ∂f 3 ∂ f 3   ∂ P3 ∂P4  ∂f 4 ∂f 4   ∂ P3 ∂P4  After differentiating equation (2. 20) with respect to P 2 and considering the answer gained with equation (2.4), one new equation which is equation (2.21) is formed as shown as the following.  Q1 Q Q  + 4 ) − 4 0 (  ∆P4  ∆P1 ∆P4   1  Q4 Q2 Q4 Q5 Q5 J=− ( + + ) − −  m1  ∆P4 ∆P2 ∆P4 ∆P5 ∆ P5   Q3 Q5  Q4 − ( + ) 0 ∆P4 ∆ P3 ∆P5   (2. 21) The corrections to the nodal pressures are computed from equation (2. 18). Since the Jacobi matrix J is negative due to the (-1/m1) term in equation (2. 21), the correction to the nodal pressure will be positive if the error at the node is positive, and will be negative if the nodal error is negative. 2.6.5 Newton Loop Method The set of loop equations that describes a gas network is shown as below [4]. B[φ (Q )] = 0 (2.14) Where: B = branch loop incidence matrix, 0 = zero vector, of dimension k, ∆P = vector of pressure drop in the branches, of dimension m, φ ' (Q) = vector of flow functions, of dimension m. = ∆P Equation (2.14) is a mathematical representation of Kirchhoff’s second Law which states that the sum of the pressure drops around any loop is zero. The loop method requires that a set of loops in the network be defined. An initial approximation is made to the branch flows ensuring that a flow balance exists at each node. Since the branch flows are approximations to their true values, a loop flow is introduced. This loop flow is the flow correction to be added to the branch flow approximations to yield the true values. In general, the branch flows are a function of the initial approximations and of all the loops flows, given like equation below. Q = Q 0 + BT q (2. 22) where q = vector of loop flows of dimension k, (k is the number of loops) Q = the branch flows, Q0 = initial branch flow approximations. In the loop method, the iteration the left hand side of equation (2.14) will not be zero. The branch flows are only approximations of their true values and the pressure drops calculated from these flows will not summate to zero around each loop. This introduces a loop error into each loop which is a function of all loop flows and is denoted as f (q). There is a loop error for each loop and this set of errors is represented by:  f 1 ( q1 , q 2 ,...q k )    f 2 ( q1 , q 2 ,...q k )   F (q ) = ........................    f k ( q1 , q 2 ,...q k )  where F denotes a vector of functions. The loop errors are incorporated into equation (2.13): F ( q ) = B[φ (Q)] (2. 23) After substituting from equation (2. 22) into equation (2. 23), equation (2. 24) is formed. F (q) = B[φ (Q 0 + B T q)] (2. 24) The errors F(q) will tend to zero as the loop flow s approach their true values. The Newton Loop method solves the set of equations (2.16) iteratively until the loop errors are less than a specified tolerance. The iterative scheme for correcting the approximations to the loop flow is q k +1 = q k + (∂q) k (2. 25) where k = number of iterations. The correction to the loop flows are computed from the following equation: J k (∂q) k = −[ F ( q)]k The matrix J is the loop Jacobi matrix and is given by (2. 26)  ∂f 1  ∂q  1  ∂f 2  J =  ∂q1 M   ∂f k  ∂q1 ∂ f1 ∂f  L 1 ∂q 2 ∂q k  ∂f 2 ∂f 2  L  ∂q 2 ∂q k    ∂f k ∂f k  L ∂q 2 ∂q k  (2. 27) where f i stands for fi(q). Q4 3 Q5 2 4 qA qB Q2 Q1 Q3 1 Figure 2.4: Graph of gas network system for Newton Loop Method. Based on equation ∆Pk = K k (Q nm1 ) k and chart (2.2) (see above), the loop equations (2.28) are: f A = − S1 K1 [ S1 (Q10 − q A )] m1 + S 2 K 2 [S 2 (Q20 + q A + qB )] m1 + S 4 K 4 [S 4 (Q40 − q A )] m1 (2. 28) f B = S 2 K 2 [S 2 (Q 20 + q A + q B )] m1 − S 3 K 3 [S 3 (Q30 − q B )]m1 + S 5 K 5 [S 5 (Q 50 + q B )] m1 (2.29) where Sk = +1, if Qk is positive, Sk = -1, if Qk is negative, The Jacobi matrix is  ∂f A  ∂q A J =  ∂f B  ∂q  A ∂f A  ∂q B   ∂f B  ∂q B  The differential equation for equation (2.28) with respect to qA is gained and as shown as the following. δf A = m1 K1 ( S1 Q1 ) m1 −1 + m1 K 2 (S 2 Q2 ) m1 −1 + m1 K 4 (S 4 Q4 ) m1 −1 δq A The differential equation for equation (2.29) with respect to qB is gained and as shown as the following. δf B = m1 K 2 (S 2 Q2 ) m1 −1 + m1 K 3 ( S 3 Q3 ) m1 −1 + m1 K 5 ( S 5 Q5 ) m1 −1 δq B The differential equation for equation (2.28) with respect to q B and the differential equation for equation (2.29) with respect to q B are gained and as shown in the following page. δf A δf B = = m1 K 2 (S 2 Q2 ) m1 −1 δq A δ q B Since S k and Qk have the same sign for any pipe k, the term m1 K k ( S k Qk ) m1 −1 is always positive and can be written as m1 K k Qk m1 −1 . Hence {K 1 Q1 m1 −1 + K 2 Q2 J = m1   K 2 Q2 m1 −1  m1 −1 + K 4 Q4 m1 −1 } K 2 Q2 {K 2 Q2 m1 −1 m1 −1 + K 3 Q3 m1 −1   m −1 + K 5 Q5 1 } (2. 30) The corrections to the loop pressures are computed from equation (2.26). Since the Jacobi matrix J is positive, the correction to a loop flow will be negative if the loop error is positive and will be positive if the loop error is negative. 2.6.6 Newton Nodal Method Versus Newton Loop Method Newton Nodal method and Newton Loop method have advantage and disadvantage. The advantage of the nodal method is this method is suitable in solving set of equations. Meanwhile the advantage of the loop method over the nodal method is its good convergence characteristic. The disadvantage of the nodal method is the poor convergence characteristic while the disadvantage of loop method is the difficulty to define the loop in gas network. Newtown Nodal Method will be implemented into the gas network simulator as the basic method to solve the network analysis. 2.7 Numerical Solution Of Linear Algebraic Equation Numerical methods for solving systems of linear equations fall into two general classes; they are the direct methods and the iterative methods. Direct methods lead to an exact solution in a finite number of steps if a round off error is not involved. Iterative method leads to an approximation that is acceptably close to the exact solution by performing an infinite number of arithmetic operations. 2.7.1 Gauss Elimination Method Most of the direct methods developed are based on Gaussian elimination, which yields a system of equations with a triangular coefficient matrix allowing their easy solution. Gauss elimination method is method that used to solve a pair of simultaneous equations, which consists of two steps. Assume a linear system of 3x3 equations as shown as the matrix form below. a11 a12 a a  21 22 a31 a32 a13   x1  b1  a23  × ï£¯ x2  = b2       a33   x3  b3  (2. 31) The first step is to eliminate one of the unknowns from the equations. This step is called Forward elimination. The result of this elimination step is the forming of one equation with one unknown. While the second step is solving the equation directly and the result back substituted into one of the original equations to solve the remaining unknown. The advantage of this method is it having a higher precision and disadvantage is possible division by zero [34]. Assuming equations (2. 31) has initial values as below.  3 − 0 .1 − 0 .2  x1  0.1 7 − 0.3 × ï£¯ï£¯ x2  =  0 .3 − 0.2 10   x3   7 .85  − 19 .3    71 .4  Separate the above equations into three equations. 3x1 − 0.1x2 − 0.2x3 = 7.85 (2. 32) 0.1x1 + 7x2 − 0.3x3 = −19.3 (2.33) 0 .3 x1 − 0 .2 x2 + 10 x3 = 71 .4 (2. 34) Use the Gauss elimination method to solve the equations (2.32) to (2.34) . 1) Forward elimination The procedure is multiply equation (2. 32) by 0.1/3 and subtracts the result from equation (2. 33) to get 7 .00333 x 2 − 0 .293333 x3 = − 19.5617 Then multiply equation (2.32) by 0.3/3 and subtracts the result form equation (2. 34) to eliminate x1. After these operations, the set of equations is 3 x1 − 0.1x 2 − 0.2 x 3 = 7.85 (2. 35) 7 .00333 x 2 − 0 .293333 x3 = − 19.5617 (2. 36) − 0 .190000 x2 + 10 .0200 x 3 = 70 .6150 (2.37) Remove x 2 from equation (2.37). To accomplish this, multiply equation (2. 36) by -0.190000/7.0033 and subtract the result from equation (2. 37). An upper triangular is formed after x2 from the equation (2.37). 3x1 − 0.1x2 − 0.2x3 = 7.85 2) (2.38) 7.00333 x2 − 0.293333 x3 = − 19.5617 (2.39) 10 .0200 x3 = 70 .0843 (2. 40) Back substitution Equation (2. 40) can be solved by solving the x3. x3 = 70 .0843 = 7 .00003 10 .0200 (2. 41) Use equation (2.41) to solve equation (2. 39) to get x2. x2 = − 19.5617 + 0.293333 (7.00003 ) = −2.50000 7.00333 (2. 42) Finally, solve x1 by subtract equation (2. 41) and equation (2. 42) into equation (2.38). x1 = 2.7.2 7.85 + 0.1(−2.50000 ) + 0.2(7.00003 ) = 3.00000 3 Gauss Seidel Method This method is the most generally used iterative methods. Assume the equation (2.31) is given. If the diagonal elements are all nonzero, the first equation can be solved for x1 , the second for x2 and the third for x3 to yield x1 = x2 = x3 = b1 − a12 x2 − a13 x3 a11 b2 − a 21x1 − a 23x3 a 22 b3 − a31x1 − a32 x2 a33 (2. 43) (2. 44) (2. 45) Now assume that x2 and x3 are zero. Subtract these zeros into equation (2.35) to calculate new value of x1=b 1/a 11. Then subtract this new value of x1 along with the previous guess of zero for x3 into equation (2. 44) to calculate new value of x2. This process is repeated for equation (2. 45) to calculate new estimate for x3. After these operations, return to equation (2. 43) and repeat the entire procedure until the solution converges closely enough to the true values. Convergence can be checked using the criterion ε a, i below [6, 35], ε a ,i = ε a, i = Current approximation − previous approximation × 100 % Current approximation xi j − xij −1 xi j × 100 % for all i, where j and j-1 are the present and previous iterations. 2.8 Commercial Software Studied There is a variety of commercial gas software in the market. Some of them can be used to perform the network analysis. While some of them can be used for pipe sizing. In this research, commercial software has been studied in the purpose to find the problems facing in the software. The problems are mentioned in Chapter 1. The summary of the commercial software studied is shown in table in next page [5, 36, 37, and 38]. Commercial software, GaPIS is selected as the comparing tool for the accuracy in this research. The latest version of the software is v2.3. The reason of choosing this software is it suits the requirement of the computer simulator developed. This software contains flow equations for low and medium pressure distribution network system. It is widely used by local researchers and users, in solving the network analysis. Table 2.7: The Summary of Commercial Software Studied. Commercial Type Usage Software Contains Graph Theory Numerical Algorithms Methods GaPIS User Gas network Friendly Yes BFS, DFS Yes GASNETT User Gas network Friendly Yes BFS, DFS Yes GASWorkS User Gas network Friendly Yes Yes PIPEFLO User Fluid and Gas Friendly network Yes Yes STANET User Fluid and Gas Friendly network Yes BFS, DFS Yes CHAPTER 3 METHODOLOGY 3.1 Introduction To set up the basic structure of the computer simulator, one approach called object oriented approach is used. After setting up the structure, the concept of graph theory is used to check the connectivity of the pipeline system drawn in the computer simulator. Network analysis is done after the pipeline system is drawn. Only one method is studied in order to solve the gas network problems - the Newton Nodal Method. This method for gas pipeline system is in steady state. As stated, there are two types of decomposition or methods used in the computer simulator design. The first one is called algorithms decomposition or structural design, and another one is called object oriented design. In this research, object oriented approach or decompos ition is chosen. The reasons are stated in Chapter 2. 3.2 Structural Design Method If structural design method or algorithm decomposition is chosen, the computer simulator design of this research will be shown as Figure 3.1. Gas Network Software Draw Graph User Input … Gauss Elimination BFS DFS SCC MST Dijkstra’s Check Input Matrix factorization Output Inverse Matrix . . . Jacobi Matrix Newton Nodal Figure 3.1: Algorithms Decomposition for Computer simulator Design. Based on Figure 3.1, the design for the computer simulator developed is too complicated and looks confusing. The structural design for this research is very large. So, the disadvanta ges of using the algorithms decomposition method for this research are the computer simulator design is too large and much unorganized. More time and efforts needed in order to develop the computer simulator, comparing if using the object oriented approac h. 3.3 Object Oriented Approach for Computer simulator Design Gas Network Simulator Drawing Graph Theory Algorithms Network Analysis Help Calculation (Formulation) User Manual Itera tion (Matrix) About Simulation Figure 3.2: Overview of the basic structure of the computer simulator based on the object-oriented concept. Unlike the algorithms decomposition method, using object oriented approach or decomposition, the computer simulator is divided into two main parts (object), which are the Drawing, and Network Analysis, and one additional part (object), which is Help. The Graph Theory Algorithms (Attribute) is inside the Drawing. While the Calculation, Iteration and Simulation (Attributes) are inside the Network Analysis. (In this research, Newton Nodal Method is used as the basic method of calculation, Jacobi Matrix is used as the basic matrix and Gauss Elimination Method is used to solve the simulation.) The User Manual and About (Attributes) are inside the Help. Inside the Graph Theory Algorithms, all the algorithms needed in the computer simulator, like the BFS and DFS methods are called Functions or Events. There exist c onnections between the objects. 3.4 Procedure COMPUTER PROGRAM SELECTION FORMULAE AND METHOD SELECTION COMPUTER SIMULATOR DEVELOPMENT USING OBJECT ORIENTED APPROACH (Graph Theory Algorithms, Network Analysis) RESULTS TESTING SUCCESS NO MODIFICATION RESULTS YES Figure 3.3: Procedure of computer simulator development. 3.5 Computer Program Selection There are many computer compilers in the market, such as Borland C++ Builder, Delphi and so on, which can be used in writing the C++ programming language. In this research, the computer compiler used in developing the computer simulator is Microsoft Visual C++ 6.0. 3.6 Formulae and Methods Selection In order to make the computer simulator become user-friendly to the end users, literature review is the most important procedure in this research. This procedure can be divided into three segments. The first segment is the study of object oriented concepts and graph theory algorithms. By doing this study, the structure of the computer simulator can be designed using object oriented approach, which has been discussed in the early of this chapter. The concepts of graph theory algorithms are studied and applied on the computer simulator, in the purpose to check the connectivity of the graph or pipelines drawn by the users. The second segment is the selection of the formulation for the gas network analysis. So, in this research, only one formulation is selected to do the network analysis - Newton Nodal Method. In future, the Newton Loop Method will be applied into the computer simulator. Thus, users can choose to use, either Newton Nodal Method or Newton Loop Method, for the network analysis calculation. The last segment is the selection of the numerical methods like Newton Gauss Elimination and Newton Gauss Seidel methods in solving the network analysis problems, especially the matrix equations. The root of equation will be determined by convergence numerical methods. 3.7 Computer Simulator Development After the formulas and methods selection, the next procedure is to implement the studies, which have been done by the developer, into the computer simulator. This procedure is called computer simulator development. Generally this computer simulator development can be divided into two parts; so called the graphic part and the logic part. Both parts have their own functions and they can interact with each others. The graphic part is normally called graphical user interface. Its main purpose is to reduce users’ complication in using the computer simulator. While the logic part is part which dealing with the engine of the computer simulator. 3.7.1 Graphical User Interface (GUI) It is built in order to simplify all the works needed in this simulation. In the computer simulator developed, there are eight things should be observed. 1. Dialog Boxes More than two dialog boxes are created for data inserting. 2. Drawing Sheet The graph or pipeline system is drawn in this sheet. Graph theory algorithms can be directly tested on the drawing sheet and coloured node or edge will be shown. 3. Menu Particular task can be executed by clicking specified menu. 4. Push Buttons There are about five push buttons for doing different task. When a button is clicked, it will carry out the logic coded by the developer or programmer. 5. Radio Buttons Like the push button, there are about ten radio buttons for doing different task. Most of these buttons are involved in the graph classification, construction and graph algorithms. When a button is clicked, it will carry out the logic coded by the developer or programmer. The difference between the push button and the radio button is normally there is one of the radio button is pre-selected. 6. Tool Boxes The tool boxes work as a tool in helping the user besides choosing the radio buttons. 7. Result Boxes The result boxes show the results of the graph theory algorithms and time of execution. 8. List Boxes Like the result boxes, the list boxes are used to display the results of network analysis calculation in list. They are put inside a specific result box. 3.8 Results Testing The purpose of doing this testing is to check for any error that may occur in the computer simulator. A test plan with a variety of test cases will be done and the test plan will be shown in the coming chapter. If there is no error in the computer simulator, the results obtained from the simulation of the computer simulator may be compared with the data s imulated from any commercial computer simulator available in the market. Thus, the computer simulator can be published in the market. 3.9 Modification Modification or trouble shooting is undergoing if there are mistakes in the computer simulator. The mistakes can be syntax errors, internal errors and others. All the mistakes in the computer simulator will be identify and corrected. 3.10 Results This is the final result for the computer simulator. When arriving in this stage, the computer simulator can be considered become perfect. 3.11 Process Flow Diagram for Computer Simulator The process flow diagram for the computer simulator is shown in Figure 3.4. This diagram is different than the diagram of developing the computer simulator. The diagram shows and explains all the processes involved in the computer simulator. Generally, the diagram can be separated into two segments. The first segment is the drawing of graph or network system without network analysis or simulation. The second segment is the drawing of graph with simulation. The first segment involves the procedure to run the tests on graph theory algorithms. It consists of drawing the graph or drawing, selecting of graph theory algorithms, input the data that are the start point (node) or end point only for BFS and Dijkstra’s Shortest Path algorithms, run the test on algorithms and obtain results. The first segment is only suitable for undirected graph and directed graph without performing the network analysis. The second segment mainly involves the procedure to run the network analysis on drawing or network system. It consists of drawing the graph or drawing, selecting of graph theory algorithms, input the data that are the start point (node) or end point only for BFS and Dijkstra’s Shortest Path algorithms, input data for the network system (for network system calculation), run the test on algorithms, obtain graph results, network system calculation and obtain the calculation results. The second segment is only suitable for directed graph which needs to perform the network analysis. START Undirected/ Directed GRAPH/DRAWING TYPE SELECTION Directed & Simulation DRAW THE GRAPH/DRAWING DRAW THE GRAPH/DRAWING ALGORITHMS SELECTION ALGORITHMS SELECTION RUN ALGORITHMS DATA INPUT FOR NETWORK SYSTEM & RUN ALGORITHMS GRAPH RESULTS END GRAPH RESULTS NETWORK SYSTEM CALCULATION CALCULATION RESULTS END Figure 3.4: Process Flow Diagram for Computer Simulator. 3.11.1 Graph/Drawing Type Selection User of this computer simulator needs to select the type of graph or drawing (network system) prefer. The type of graph can be whether directed, undirected or directed with simulation. If user choose graph without simulation, the computer simulator will only run the graph theory algorithms. 3.11.2 Draw the Graph/Drawing After choosing the type of graph, user can draw the graph on the drawing area in the computer simulator. 3.11.3 Algorithms Selection After the graph is done, the next stage is to select the graph theory algorithms. There are five graph theory algorithms to choose. Details about the graph theory algorithms are shown in Chapter 2. Figure 3.5 shows the process occurs inside the Algorithms Selection. User can only select one of the graph theory algorithms each time to obtain the graph results. If user selects BFS and Dijkstra’s Minimum path (Yes path in Figure 3.5), user needs to select the start and end point (start node and end node) at the graph drawn, before the results of the algorithm can display. An error message will display if user doesn’t do so. If user chooses algorithms rather than the both algorithms stated above, whether is DFS, MST and SCC, the results of the graph theory algorithms will directly display on the graph results in the computer simulator 3.11.4 Graph Results The graph results consist of all the results of the desired graph theory algorithms and the computation time taken in calculating the algorithms. For graph without simulation (uncheck or unclick the “Simulation” button, see Chapter 4, section 4.4), the computer simulator will stop after all the calculation and all the results have been displayed on the computer simulator. While for graph with simulation, it will display all the results on the computer simulator and later proceeds to the next stage, that is the network system calculation, or in other word, network analysis. 3.11.5 Data Input For Network System and Network System Calculation This stage is to perform the network analysis on the graph drawn. The results will display after the calculation. However before that, all the data needed for the calculation must be entered into the computer simulator. User needs to enter the total node, the total branch, the total chord, tolerance, properties, and methods and flow equation into the computer simulator. Otherwise, errors will occur in the computer simulator and user needs to restart the computer simulator. If user fulfils all the required above, the process will go into the calculation of K value process and the Initial Chord Flow Calculation process. To calc ulate the K value, the formulas for the low, medium and high pressure gas network are as follow (see Chapter 2 for details), Pole formula (low pressure), K = 11 .7 × 10 3 L D5 Cox’s formula (medium pressure), K = 206 .2253 × 10 3 L D5 Weymouth formula (high pressure), K = 25900 × L D16 / 3 To calculate the chord flow rate, equations (2.2) and (2.4) are needed. After that, the data calculated will go to Formation of Jacobi Matrix process. The Jacobi matrix formed depends on the size of the nodes. The matrix can be formed using equation (2.12). The next process is Numerical Methods Calculation process. In this process, there are two numerical methods in the computer simulator and only one of them can be selected. Details about the two numerical methods are as shown in Chapter 2. Next, the calculation will proceed to New Branch Flow Calculation process and New Chord Flow Calculation process. New flow rate for the branch and chord will be calculated using equations (2.2) and (2.4). They are to calculate the new branch flow rate and chord flow rate. The calculation will stop if the specified tolerance (user input) is achieved. Otherwise, it will go back to the K value Calculation process to recalculate the new K value using the formulas above and continue all the processes above until the specified tolerance is achieved. The final results of network system calculation will display after the specified tolerance is achieved. Figure 3.6 show all the processes mentioned here. 3.11.6 Calculation Results The results of network system calculation are display here. They include time of one iteration and total iteration, number of iteration, branch flow rate, and chord flow rate and so on. Choose Yes Start/End Point Selection BFS No No Yes Yes DFS No Yes MST No Yes SCC No Start/End Point Selection Dijkstra Yes No No Calculation Graph Results Figure 3.5: Flow chart of Process Occurs inside Algorithms Selection. Start Data Input & Check Yes Error No K value Calculation Initial Chord flow Calculation Formation of Jacobi Matrix Numerical Methods Calculation New Branch flow Calculation New Chord flow Calculation No Achieve Tolerance? Yes Calculation Results Figure 3.6: Flow chart of Processes Occur in Network System Calculation. CHAPTER 4 COMPUTER SIMULATOR FEATURES 4.1 Introduction The computer simulator developed can be used for network simulation for steady state gas flow. The computer simulator uses the Newton Nodal Method in order to do the network analysis. The computer simulator can be used to solve piping problem and to check the connectivity of a graph drawn. To solve the piping problem, firstly user is required to draw the piping system on the drawing sheet, subsequently check the “Simulate” button and click at the system to enter the necessary data. User can view the results obtained and the data entered in a special results box. To check the connectivity of the piping system or the graph drawn, user is required to choose the necessary information given on the main frame and click on the “Run” button to simulate the graph theory algorithms. The results will be shown on the same main frame with the time execution. 4.2 Properties Information In order for the system to work properly, the following are the essential information required: (i) General Information a) Fluid Type (Gas) b) Friction Factor Equation (ii) Node Information a) Demands b) Elevations c) Pressures (iii) Gas Properties a) Compressible factor b) Specific gravity c) Temperature (iv) Pipe Information a) Diameter b) Length (v) Flow Equations a) Lacey b) Pole c) Polyflo d) Cox’s e) Pandhandle f) Weymouth 4.3 User Interface Features The developed application is a user friendly application. It consists of a Drawing Area at the center, one menu and three toolbars on the top, one toolbar on the left, four buttons and a results display column on the right. The main screen of computer simulator with a sample graph is shown in Figure 4.1. Figure 4.1: Main Screen of Computer Simulator with a Sample Graph. 4.4 Computer Simulator Tools These tools are very useful to the user because it can help user easily to draw the pipeline system. (i) Graph Toolbar The Graph toolbar consists of tool buttons “Node” (Vertices) and “Edge” (Branch). (a) Node (Vertices) By clicking this tool button, user can draw the node of the pipeline system. The node drawn in the drawing sheet is a small black dot. (b) Edge (Branch) This tool button will not work if there is no node on the drawing sheet. At least a node is needed (self-looping). User can draw edges which can connect many nodes. Figure 4.2: General Toolbars. (ii) Drawing and Algorithms Toolbars These toolbars consists of nine radio buttons and one check button. The radio buttons are “Directed”, “Undirected”, “Vertices”, “Edges”, “Breadth-First Shortest Path Search”, “Depth-First Search”, “Strongly Connected Components”, “Minimum Spanning Tree” and “Dijkstra’s Minimum Path” buttons (see Chapter 2 for details). Meanwhile, the check button is “Simulation” button. Each of them has their own functions. Figure 4.3 shows the display of the Drawing and Algorithms Toolbars. (iii) Algorithms Buttons Only four buttons needed to do the graph theory algorithms. They are the “Clear Drawing” button, the “Clear All Edges” button, the “Run Algorithms” button and the “Reset All” button. The “Clear Drawing” button is used to clear all the drawing drawn. The “Clear All Edges” button is used to clear all the edges drawn, including the data input of the edge. By clicking the “Run Algorithms” button, the computer simulator will run on the selected algorithm and the results will be shown in the Results Display Column. The “Reset All” button is to reset all the results calculated and displayed. Figure 4.3: Drawing and Algorithms Toolbars. Figure 4.4: Algorithms Buttons. (iv) Results Display Column The Results Display Column is used to display the algorithms summary and the computation time. Figure 4.5: Results Display Column 4.5 Dialog Boxes Dialog boxes are very useful in this software. There are three types of dialog boxes involved in this software. One is the Information dialog box, second is the Input dialog box and the third is the Results dialog box. Information dialog box gives the required information to user. Input dialog box allow user to input the necessary data into the simulation of the software. There are two types of input dialog boxes. They are Input Data for Node and Input Data for Pipe. Results dialog box shows the results of the calculation of the network problem. (i) Information Dia log Boxes After checking the Dijkstra’s Shortest Path algorithm or Breadth First Search algorithms, if user forgets to specify the start and end (finish) vertices of the graph drawn, this type of dialog boxes will display. The purpose of showing the dia log box is to remind user to specify the start and end vertices. One of these dialog boxes is shown in Figure 4.6. The sentences on the dialog box in Figure 4.6 say “Dijkstra’s Shortest Path Algorithm requires a Start Vertex and a Finish Vertex”. Figure 4.6: Information Dialog box. (ii) Input Data for Node In this dialog box, user has to insert the data of the node number, pressure and the flow rate of the specified node. Besides that, user has to specify whether the node is a source node or a load node by clicking the radio button on the left hand side of the dialog box. Figure 4.7 below shows the Input data for node dialog box. Figure 4.7: Input Data Dialog Box for Node . (iii) Input Data for Pipe For this dialog box, it contains data like the branch number, length, equivalent length and diameter of the pipe drawn by user. User need to enter all the data of the pipe. The graphical dialog box for data input on pipe for this software is illustration in Figure 4.8 below. Figure 4.8: Input Data Dialog Box for Pipe . (iv) Results Dialog Box The Results Dialog box is used to show the calculation of the network problem. Before viewing the results, user has to enter all the input data for the nodes and branches involved. This also means user has to draw the network system on the drawing sheet. By clicking the push button “Simulation” and selecting the radio button “Directed”, user can enter to the Results Dialog box. Before running the simulation, user need to enter some information required, such as the total of nodes, branch, type of method, tolerance and so on. To run the simulation, user just need to click the “Calculate” button. All the results will be displayed with the time of execution. The Results Dialog box is shown in Figure 4.9. Figure 4.9: Results Dialog Box. 4.6 Main Menu (i) File (a) New Through this button, user can open a new file to draw a network system and do the calculation of the network system. (b) Open Through this button, any saved file in Data File type can be opened. (c) Save/Save As It can help user to save the modified file in Graph File type. (c) Print It can help user to print the file. (d) Exit Through this button, user can exit the file. (ii) View (a) Converter Through this button, user can convert the temperature, mass, pressure and length. The Converter is shown in the following page. Figure 4.10: Converter. (b) Show Results Through this button, user can display the Results Dialog box. However, to make the button works, user need to click the Push button “Simulation” and select the Radio button “Directed”. Details about the Results Dialog box are displayed in the above section. 4.7 Simple User Guide User needs to know the simplest way of using the computer simulator. In order to reduce the time consuming in using this computer simulator and avoid any unwanted error occurs, user have to follow these steps in next page: (i) For Network Simulation (a) Choose the classification of the piping system; select the “Directed” and “Simulation” button for solving the network simulation. (b) Draw the network piping system using the tools provided in the computer simulator. While drawing, user can enter the data of the nodes and the pipelines just by double -click at the node when user is drawing the node and the edge (pipeline) when user is drawing the edge. If any error occurred in the drawing, user can simply delete the drawing by clicking the “Clear All” button or the “Clear All Edges” button. Besides that, user can delete the edge by right-click the edge and choose “Delete Edges”. (c) User can even move the node or edge drawn by just drag the node or edge. (d) Select the graph theory algorithms needed for the network system. User needs to set the start and end point (choose “Vertices” radio button, then right-click at the specified node) only for Breadth-First Shortest Path Search and Dijkstra’s Minimum Path algorithm. (e) Click the “Run Algorithms” button to see the algorithm results and the computation time. (f) Click the “Show Results” button to display the data of nodes and the pipelines. (g) Enter all the initial condition needed, the properties and the methods chosen in the Results Dialog Box. To display the network simulation results, just click the “Calculate” Button. (ii) For Non-Network Simulation (a) Choose the classification of the graph (drawing), select the “Directed” or “Undirected” button. Leave the “Simulation” button unchecked or blank. (b) Draw the graph using the tools provided in the computer simulator. User can delete the node or edge by just double click at the node or edge. “Clear Drawing” and “Clear All Edges” buttons also can be used. (c) User can even move the node or edge drawn by just drag the node or edge. (d) Select the graph theory algorithms needed. User needs to set the start and end point (choose “Vertices” radio button, then right -click at the specified node) only for Breadth-First Shortest Path Search and Dijkstra’s Minimum Path algorithm. (e) User can enter the weight of the graph by right-click the edge after choosing the “Edges” radio button. (f) Click the “Run Algorithms” button to see the algorithm results and the computation time. 4.8 Hardware & Software Requirements In order for the computer simulator to operate smoothly and efficiently, it needs the following hardware and software requirements. Table 4.1: Hardware and Software Requirements for User and Developer. Requirements User Developer Operating System Windows 98/2000/XP Windows 98/2000/XP Software None Microsoft Visual C++ 6.0, MS Word CPU Pentium 3 (650 MHz) or Pentium 3 (650 MHz) higher RAM 196 MB RAM 196 MB RAM (16 bit recommended) (16 bit recommended) Hard Disc 30 MB Hard Disc 40 GB Hard Disc Screen Display 256-colour SVGA 256-colour SVGA (16 bit recommended) (16 bit High Colour) CD-ROM 40x or higher CD-ROM 40x or higher CD-ROM Video GeForce2 MX/MX400 display NVIDIA GeForce2 card MX/MX400 display card Direct-8x or higher Direct-9x Mouse, keyboard Mouse, keyboard Other CHAPTER 5 RESULTS AND DISCUSSIONS 5.1 Introduction The developed gas network computer simulator is able to run five graph theory algorithms and examine the effects of graph theory algorithms on gas network system. Besides that, this computer simulator is able to run the Newton Nodal Method for the network analysis. In this chapter, comparison on its accuracy and speed can be done based on various different network configurations. The accuracy test is compared with the simulated results obtained by using the commercially software, GAPIS. The speed analysis is done on the various graph theory algorithms, number of iteration and various numerical methods such as the Newton Gauss Elimination and Newton Gauss Seidel method. 5.2 Analysis on Case Studies Two case studies and one extended case study have been performed in this research. For each case study, different conditions have been used. The set conditions are different pressure, length, diameter, flow rate and the arrangement of the network system. Different flow equations are applied into these case studies. In case study 1, the network is in low pressure, Pole’s (Lacey’s) equation is used. In case study 2, Cox’s equation is used since the network is in medium pressure. In extended case study 1, the network is in high pressure and the Weymouth and Panhandle ‘A’ equation is used. The reason of using different conditions is to check the capacity of the computer simulator developed. The computer simulator developed must be able to perform network analysis in low, medium and high pressure. Table 5.1 below shows these case studies properties. Table 5.1: Case studies properties Case Study Network Condition Initial Number Number Pressure of Node (bar Number Pressure Equation of Loop Range Used 3 Pressure Pole of Branch gauge ) 1 0.03 5 7 (low) 0-75 mbar gauge 2 1 6 9 4 (medium) Pressure Cox 29.4 kPa and above Extended 8 case (high) study 1 7 11 5 Pressure Weymouth more than and 7 bars Panhandle ‘A’ i) Case Study 1 The network is a simple low pressure network. The initial pressure of this network is 30 mbar and the specific gravity of gas is 0.589. The input data and the network schematic diagram are shown in Table 5.2 and Figure 5.1 respectively. Table 5.2: Input Data for Study Case 1 Node Status Pressure Load (m3h -1 ) (mbar gauge) 1 Source 30 - 2 Load - 250 3 Load - 100 4 Load - 180 5 Load - 120 Diameter (mm) Length (mm) Branch Sending Receiving Node Node 1 1 2 150 680 2 1 3 100 500 3 1 4 150 420 4 1 5 100 600 5 3 2 100 600 6 3 4 100 340 7 5 4 100 420 Figure 5.1: Schematic diagram for case study 1. ii) Case Study 2 The network is a medium pressure network with the initial pressure of 1 bar and the specific gravity of gas is 0.589. Cox’s equation is used. The efficiency factor , E is set to be 0.8. The input data and the network schematic diagram are shown in Table 5.3 and Figure 5.2 respectively. Table 5.3: Input Data for Study Case 2 Node Status Pressure Load (m3h-1 ) (bar gauge) 1 Source 1 - 2 Load - 250 3 Load - 100 4 Load - 180 5 Load - 120 6 Load - 150 Diameter (mm) Length (mm) Branch Sending Receiving Node Node 1 1 2 150 680 2 1 3 100 500 3 1 4 150 420 4 1 5 100 600 5 1 6 150 600 6 3 2 100 600 7 3 4 100 340 8 5 4 100 420 9 6 5 100 600 Figure 5.2: Schematic diagram for case study 2 . iii) Extended Case Study 1 This is the extended study of high pressure. The network is a high pressure network. The initial pressure of 8 bars and the specific gravity of ga s are 0.589. The efficiency factor is 0.8. The input data and the network schematic diagram are shown in Table 5.4 and Figure 5.3 respectively. The flow results obtained from Weymouth equation in the computer simulator are compared with the flow results of Panhandle ‘A’ equation in the computer simulator, during the accuracy test. Table 5.4 : Input Data for Extended Case Study 1 Node Status Pressure Load (m3h-1 ) (bar gauge) 1 Source 8 - 2 Load - 250 3 Load - 100 4 Load - 180 5 Load - 120 6 Load - 150 7 Load - 200 Diameter (mm) Length (mm) Branch Sending Receiving Node Node 1 1 2 150 420 2 1 3 100 500 3 1 4 200 680 4 1 5 200 700 5 1 6 150 450 6 1 7 100 500 7 3 2 150 500 8 3 4 100 420 9 5 4 100 340 10 6 5 150 650 11 7 6 100 250 Figure 5.3: Schematic diagram for extended case study 1. 5.3 Speed Analysis for Gas Network System The speed analysis is done on the all the case studies in order to determine the fastest graph theory algorithms for gas network system and the fastest numerical method for gas network system using the Newton Nodal Method. This analysis is carried out using the five graph theory algorithms, on three different case studies. There are two type of speed analysis carried out in this research. The first one is speed analysis without the network analysis and the second one is speed analysis with the network analysis. 5.3.1 Speed Test without Network Analysis The speed analysis is done for gas networks system without performing the network analysis. The purpose of undergoing this analysis is to determine the fastest graph theory algorithm, before performing the network analysis and determine the effect of graph theory algorithms on different gas network configuration. All the results are recorded and tabled as shown in Table 5.5. For BFS and Dijkstra’s Shortest Path Algorithms, the start and end nodes (points) must be defined before running the algorithms. For case study 1, the start node is 1 and end node is 5. For case study 2, the start node is 1 and the end node is 6 while for extended study case study 1, the start node is 1 and the end node is 7. Three bar graphs are plotted as shown in Figure 5.4 to Figure 5.6. From these graphs, the fastest graph theory algorithm is Breadth First Search. The slowest graph theory algorithm is Strongly Connected Component. BFS is the fastest because of the method used. As stated in Chapter 2, BFS explores all the neighbouring nodes before proceeds to their respective neighbouring nodes. For these three case studies, using BFS, starting from node 1, it will go to node 2, node 3, node 4, node 5(case study 1), node 6(case study 2) and node 7(extended study case study 1). Since all the nodes are “visited” by node 1, it stops. The time taken is becoming shorter as the ending node is directly connected to the starting node, node 1. Strongly Connected Component uses DFS method to find the strongly connect components. For case study 1, starting from node 1, it goes to nodes 2 using branch 1:2 and 3:2, node 3 using branch 1:3, node 4 using branch 1:4, 5:4 and branch 3:4, and node 5 using branch 1:5. Similar case also happens in case study 2 and extended study case study 1. Since there are re-“visited” incident happens and calculation needed to be done to obtain the strongly connected component, the time taken is longer, even longer than DFS. After comparing with three case studies, the effect of graph theory algorithms on different network configuration is the computation time. The larger the network, the time taken is longer. The reason is the number of nodes and branches increase. Table 5.5: Speed Analysis Results without Network Analysis in Three Case Studies. Algorithms Case Time (msec) Study 1 2 Average 3 4 5 (msec) Breadth 1 5.37 5.47 5.35 5.34 5.33 5.37 First 2 5.5 5.46 5.46 5.47 5.51 5.48 3 5.59 5.62 5.59 5.63 5.65 5.61 Depth First 1 6.74 6.78 6.74 6.76 6.72 6.75 Search 2 7.5 7.56 7.52 7.48 7.48 7.51 (DFS) 3 7.63 7.56 7.55 7.57 7.53 7.57 Strongly 1 10.49 10.39 10.53 10.37 10.40 10.44 Connected 2 12.05 11.82 11.89 11.88 11.90 11.91 3 12.76 12.76 12.84 12.77 12.86 12.80 Minimum 1 5.46 5.44 5.43 5.43 5.43 5.44 Spanning 2 5.7 6.97 5.60 5.58 5.67 5.90 3 5.77 5.79 5.78 5.78 5.76 5.78 Dijkstra’s 1 5.36 5.37 5.45 5.49 5.36 5.41 Shortest 2 5.56 5.59 5.51 5.51 5.49 5.53 Path 3 5.72 5.64 5.62 5.68 5.68 5.67 Search (BFS) Component (SCC) Tree (MST) 12 The number of: Node 5 Branch 7 5.44 5.41 MST Dijiktra's 10.44 10 Computation Time(ms) 8 6.75 6 5.37 4 2 0 BFS DFS SCC Graph Theory Algorithms Without Network Analysis Figure 5.4: Computation Time for Case Study 1 versus Graph Theory Algorithms. 14 The number of: 11.91 12 Node 6 Branch 9 Computation Time(ms) 10 8 6 7.51 5.90 5.53 5.48 4 2 0 BFS DFS SCC MST Dijiktra's Graph Theory Algorithms Without Network Analysis Figure 5.5: Computation Time for Case Study 2 versus Graph Theory Algorithms. 14 The number of: 12.80 12 Node 7 Branch 11 5.78 5.67 MST Dijiktra's Computation Time(ms) 10 8 6 7.57 5.62 4 2 0 BFS DFS SCC Graph Theory Algorithms Without Network Analysis Figure 5.6: Computation Time for Extended case study 1 versus Graph Theory Algorithms. 5.3.2 Speed Analysis with Network Analysis The speed analysis is also done for gas network system with network analysis. The network analysis is using the Newton Nodal Method. Newton Gauss Elimination Method and Newton Gauss Seidel Method are using numerical solutions to solve Linear Algebraic Equation in the network analysis [5]. The purpose of undergoing this speed analysis is to determine the fastest numerical method and the fastest method in performing the network analysis. This speed analysis can be divided into two sections. The first section is analysis on One Iteration T ime for the three case studies with different numerical methods that are the Newton Gauss Elimination and Gauss Seidel Method. The second analysis is analysis on Total Iteration T ime for the three case studies with the Newton Gauss Elimination and Gauss Seidel Method. All the results of the speed analysis for gas network system with network analysis is tabled and shown in tables below. Table 5.6: One Iteration Time for the Case Study 1 with Gauss Elimination and Gauss Seidel Method Numerical Method Gauss Elimination Gauss Seidel Tolerance 0.1 0.01 0.001 0.1 0.01 0.001 1 4.90 4.66 4.89 6.57 7.14 8.59 Time (msec) 2 4.64 4.88 4.72 6.64 7.10 8.22 3 4.64 4.89 4.88 6.42 7.04 8.09 Average Time (msec) 4.73 4.81 4.83 6.54 7.09 8.30 Table 5.6.1: Total Iteration Time for the Case Study 1 with Gauss Elimination and Gauss Seidel Method Numerical Method Tolerance Gauss Elimination 0.1 0.01 0.001 0.1 0.01 0.001 Gauss Seidel 1 29.16 32.48 35.21 40.37 51.09 57.34 Time (msec) 2 31.84 32.48 34.42 39.90 57.74 57.92 3 27.76 34.93 34.95 39.89 55.26 55.17 Average Time (msec) 29.59 33.30 34.86 40.05 54.69 56.81 Table 5.7: One Iteration Time for the Case Study 2 with Gauss Elimination and Gauss Seidel Method Numerical Method Tolerance Gauss Elimination 0.1 0.01 0.001 0.1 0.01 0.001 Gauss Seidel 1 6.62 6.46 6.51 8.12 8.39 9.45 Time (msec) 2 6.08 6.42 6.50 7.94 8.73 9.40 3 6.26 6.34 6.58 8.78 8.77 9.09 Average Time (msec) 6.32 6.41 6.53 8.28 8.63 9.31 Table 5.7.1: Total Iteration Time for the Case Study 2 with Gauss Elimination and Gauss Seidel Method Numerical Method Tolerance Gauss Elimination 0.1 0.01 0.001 0.1 0.01 0.001 Gauss Seidel 1 26.73 40.32 45.21 30.74 48.99 66.88 Time (msec) 2 25.85 38.31 49.61 39.74 49.47 64.11 3 25.65 39.92 44.23 35.13 50.25 65.55 Average Time (msec) 26.08 39.52 46.35 35.20 49.57 65.52 Table 5.8: One Iteration Time for the extended study case study 1 with Gauss Elimination and Gauss Seidel Method Numerical Method Tolerance Gauss Elimination 0.1 0.01 0.001 0.1 0.01 0.001 Gauss Seidel 1 7.77 8.01 7.76 9.04 11.25 10.99 Time (msec) 2 7.57 7.74 7.80 8.81 11.01 11.21 3 7.56 7.79 7.74 9.02 10.88 10.69 Average Time (msec) 7.63 7.85 7.77 8.96 11.05 10.96 Table 5.8.1: Total Iteration Time for the extended study case study 1 with Gauss Elimination and Gauss Seidel Method Numerical Method Tolerance Gauss Elimination 0.1 0.01 0.001 0.1 0.01 0.001 Gauss Seidel 5.3.3 1 23.60 46.04 52.31 34.37 51.85 73.90 Time (msec) 2 29.20 42.30 48.52 35.27 50.23 71.34 3 23.55 44.34 49.94 34.82 50.01 71.83 Average Time (msec) 25.45 44.23 50.26 34.82 50.70 72.35 Speed Test Analysis for Case Study 1 Based on the results obtained, three bar graphs have been plotted in order to provide a clear picture of the analysis. Figure 5.7 shows the one iteration computation time for case study 1 versus the Newton Gauss Elimination and Gauss Seidel Method. Figure 5.8 shows t he total iteration computation time for case study 1 versus the Newton Gauss Elimination and Gauss Seidel Method. Figure 5.9 shows the computation time for case study 1 versus the five graph theory algorithms and two numerical methods. Based on Figure 5.7 and Figure 5.8, Newton Gauss Elimination can provide faster results than Newton Gauss Seidel Method in case study 1. For tolerance 0.1, Newton Gauss Elimination is 1.81 milliseconds faster than Newton Gauss Seidel Method in one iteration and 10.47 milliseconds in total iteration. For tolerance 0.01, Newton Gauss Elimination is 2.28 milliseconds faster than Newton Gauss Seidel Method in one iteration and 21.40 milliseconds in total iteration. While for tolerance 0.001, Newton Gauss Elimination is 3.45 milliseconds faster than Newton Gauss Seidel Method in one iteration and 21.95 milliseconds in total iteration. Newton Gauss Elimination is a direct method while Newton Gauss Seidel Method is an iterative method. This means Newton Gauss Elimination pr ovides a straightforward solution while Newton Gauss Seidel Method generates a sequence of successive approximations to the exact solution. The main reason of Newton Gauss Elimination is faster than Newton Gauss Seidel for both graphs is its short sequence of calculation. Newton Gauss Elimination consists of two phases, which are the Forward Elimination and the Back substitution. The Forward Elimination is to eliminate one of the unknowns from the equations in the Jacobi Matrix and the Back substitution is to solve the equations directly. T hen the results obtained, after the Forward Elimination are back substituted into the original equations in the Jacobi Matrix, to solve the remaining unknown. The calculation stops until the final results are closely to the true values. Meanwhile, Newton Gauss Seidel Method has a similarity with the technique of simple fixed point iteration. Newton Gauss Seidel Method solves the unknowns from the equations in the Jacobi Matrix, using initial guesses that assume one or more the unknowns (n-1) are zero. For this case study, the number of unknowns, n is 4 because of 4 load nodes. So, 3 unknowns are initially assumed zero. The result of the last unknown obtained is substituted into the equations in Jacobi Matrix, in order to solving other unknowns. These calculation steps are repeated until the final results are closely to the true values (depend on the tolerance inserted by user of the computer simulator) and may sometimes rises up to 100. Due to the “trial and error” method and these steps, the time taken to obtain a good result becomes longer. The reuses of Jacobi matrix for Newton Gauss Seidel Method increases when all the old equations in the Jacobi Matrix are frequently replaced by the new equations each time the calculation steps are repeated, more than the reuses of Jacobi matrix for Newton Gauss Elimination method. The reason is the total number of iteration for Newton Gauss Elimination method is 7 times, comparing to the total number of iteration for Newton Gauss Seidel method is 414 (see Figure 5.9). So, Newton Gauss Seidel Method is slower than Newton Gauss Elimination at one iteration and total iteration. In order to obtain more accurate results, the tolerance must be smaller. Thus, the time taken to obtain the result is longer. Because of this reason, the total iteration time for tolerance 0.001 has been chosen to plot the graph in Figure 5.9. Figure 5.9 is plotted in order to determine the fastest method in performing the analysis on graph theory algorithms and numerical methods for case study 1. It can be considered as the combination of Figure 5.4 and Figure 5.8 because the same values for graph theory algorithms and numerical methods for tolerance 0.001 are obtained, after many tests on the computation time have been carried out. As stated, BFS is the fastest graph theory algorithms while Newton Gauss Elimination is the fastest numerical method from previous results. For Figure 5.9, still BFS is the fastest graph theory algorithms while Newton Gauss Elimination is the fastest numerical method. The fastest method in performing the analysis on graph theory algorithms and numerical methods for case study 1 is the combination of BFS and Newton Gauss Elimination with the total time 40.2328 milliseconds. However, the combination of MST and Newton Gauss Elimination, and the combination of Dijkstra’s Shortest Path Method and Newton Gauss Elimination also are two good ways to obtain fast results for case study 1, with the time difference of only 0.07 milliseconds and 0.03 milliseconds respectively, comparing with the time of the combination of BFS and Newton Gauss Elimination. Both the combination of MST with Newton Gauss Elimination and the combination of Dijkstra’s Shortest Path with Newton Gauss Elimination can provide fast results because the case study 1 is an un-weighted graph/drawing. These two graph theory algorithms are suitable for weighted graph. One Iteration, 5 nodes 9 8.30 8 7.09 7 6.54 Computation Times (ms) 6 Tolerance 5 4.73 4.81 4.83 0.1 0.01 0.001 4 3 2 1 0 Gauss Elimination Gauss Seidel Numerical Methods Figure 5.7: One Iteration Time for case study 1 v ersus the Newton Gauss Elimination and Gauss Seidel Method. Total Iteration, 5 nodes 60 56.81 54.69 50 40.05 Computation Times (ms) 40 Tolerance 34.86 33.30 30 0.1 0.01 29.59 0.001 20 10 0 Gauss Elimination Gauss Seidel Numerical Methods Figure 5.8: Total Iteration Time for case study 1 versus the Newton Gauss Elimination and Gauss Seidel Method. 80 Computation Time for Case Study 1 versus Graph Theory Algorithms and Numerical Methods Lege nd Netwon Gauss Seidel (0.001) 70 Newton Gauss Elimination (0.001) Dijkstra's Shortest Path 60 MST Computation Time (msec) 50 SCC 40 56.81 DFS 56.81 56.81 56.81 56.81 30 BFS 34.86 34.86 34.86 34.86 34.86 Total Iteration: 20 Newton Gauss Elimination Method (0.001) 7 10 10.44 10.44 5.37 5.37 6.75 6.75 5.44 5.44 5.41 5.41 Newton Gauss Seidel Method (0.001) 414 0 Graph Theory Algorithms and Numerical Methods Figure 5.9: Computation Time for case study 1 versus the Graph Theory Algorithms and Numerical Methods. 5.3.4 Speed Test Analysis for Case Study 2 Based on the results obtained, like in case study 1, three bar graphs have been plotted in order to provide a clear picture of t he analysis. Figure 5.10 shows the one iteration computation time for case study 2 versus the Newton Gauss Elimination and Gauss Seidel Method. Figure 5.11 shows the total iteration computation time for case study 2 versus the Newton Gauss Elimination and Gauss Seidel Method. Figure 5.12 shows the computation time for case study 2 versus the five graph theory algorithms and two numerical methods. Based on the both graphs, still Newton Gauss Elimination can provide faster results than Newton Gauss Seide l Method in case study 2, although different flow equation is used. For tolerance 0.1, Newton Gauss Elimination is 1.96 milliseconds faster than Newton Gauss Seidel Method in one iteration and 9.13 milliseconds for total iteration. For tolerance 0.01, Newton Gauss Elimination is 2.22 milliseconds faster than Newton Gauss Seidel Method in one iteration and 10.05 milliseconds in total iteration. While for tolerance 0.001, Newton Gauss Elimination is 2.78 milliseconds faster than Newton Gauss Seidel Method in one iteration and 19.17 milliseconds in total iteration. Like in case study 1, the main reason of Newton Gauss Elimination is faster than Newton Gauss Seidel for both graphs is its short sequence of calculation. Newton Gauss Elimination eliminates one of the unknowns from the equations in the Jacobi Matrix and solves the equation directly. The result obtained is substituted into the original equations in the Jacobi Matrix to solve the remaining unknown. The calculation stops until the final results are closely to the true values. Meanwhile, Newton Gauss Seidel Method solves the unknowns from the equations in the Jacobi Matrix, using initial guesses that assume all the unknowns are zero. For this case study, the number of unknowns, n is 5 because there are 5 load nodes. So, the number of unknowns is 4. They are initially assumed zero. The last unknown obtained is substituted into the equations in the Jacobi Matrix, in order to solve other unknowns. These “trial and error” calculation steps a re repeated until the final results are closely to the true values. The reuses of Jacobi matrix for Newton Gauss Seidel Method increases when all the old equations in the Jacobi Matrix are frequently replaced by the new equations each time the calculation steps are repeated, more than the reuses of Jacobi matrix for Newton Gauss Elimination method. The reason is the total number of iteration for Newton Gauss Elimination method is 7 times, comparing to the total number of iteration for Newton Gauss Seidel method is 377 (see Figure 5.9). So, the time taken to obtain a result becomes longer. From the graphs, the smaller the tolerance, the longer the time taken. To obtain a more accurate result, the tolerance must be smaller. Consequently, the time taken to obtain the result is longer. Like case study 1, Figure 5.12 is the combination of Figure 5.5 and Figure 5.11 because the computation time results obtained for case study 2 are still the same although many tests on the computation time have been carried out. The fastest method in performing the analysis on graph theory algorithms and numerical methods for case study 2 is the combination of BFS and Newton Gauss Elimination with the total time 51.83 milliseconds, slightly slower than in case study 1. The reason is the graph becomes larger. The combination of MST with Newton Gauss Elimination and the combination of Dijkstra’s Shortest Path with Newton Gauss Elimination also can provide fast results because the case study 2 is also an un-weighted graph like case study 1. Different computation time will be shown if the graph is a weighted graph. One Iteration, 6 nodes 10 9.31 9 8.63 8.28 8 Tolerance 7 Computation Times (ms) 6.32 6.41 6.53 6 0.1 0.01 5 0.001 4 3 2 1 0 Gauss Elimination Gauss Seidel Numerical Methods Figure 5.10: One Iteration Time for case study 2 versus the Newton Gauss Elimination and Gauss Seidel Method. Total Iteration, 6 nodes 70 65.52 60 49.57 50 46.35 Computation Times (ms) Tolerance 39.52 40 0.1 35.20 0.01 0.001 30 26.08 20 10 0 Gauss Elimination Gauss Seidel Numerical Methods Figure 5.11: Total Iteration Time for case study 2 versus the Newton Gauss Elimination and Gauss Seidel Method Computation Time for Case Study 2 versus Graph Theory Algorithms and Numerical Methods 90 Legend 80 Newton Gauss Seidel Method (0.001) Newton Gauss Elimination (0.001) 70 Computation Time (msec) Dijkstra's Shortest Path 60 MST 50 SCC 65.52 DFS 65.52 40 65.52 65.52 65.52 46.35 30 BFS 46.35 46.35 46.35 46.35 Total Iteration: 20 Newton Gauss Elimination Method (0.001) 7 10 11.91 11.91 5.48 5.48 7.51 7.51 5.90 5.90 5.53 5.53 0 Newton Gauss Seidel Method (0.001) 377 Graph Theory Algorithms and Numerical Methods Figure 5.12: Computation Time for case study 2 versus the Graph Theory Algorithms and Numerical Methods. 5.3.5 Speed Test Analysis for Extended Case Study 1 Based on the results obtained, like in case study 1 and 2, three bar graphs have been plotted in order to provide a clear picture of the analysis. Figure 5.13 shows the one iteration computation time for extended case study 1 versus the Newton Gauss Elimination and Gauss Seidel Method. Figure 5.14 shows the total iteration computation time for extended case study 1 versus the Newton Gauss Elimination and Gauss Seidel Method. Figure 5.15 shows the computation time for extended case study 1 versus the five graph theory algorithms and two numerical methods. Based on the both graphs, still Newton Gauss Elimination can provide faster results than Newton Gauss Seidel Method in extended case study 1. For tolerance 0.1, Newton Gauss Elimination is 1.32 milliseconds faster than Newton Gauss Seidel Method in one iteration and 9.37 milliseconds for total iteration. However, for tolerance 0.01, Newton Gauss Elimination is 3.20 milliseconds faster than Newton Gauss Seidel Method in one iteration and 6.4711 milliseconds in total iteration. While for tolerance 0.001, Newton Gauss Elimination is 3.19 milliseconds faster than Newton Gauss Seidel Method in one iteration and 22.09 milliseconds in total iteration. Like case study 1 and 2, the reason Newton Gauss Elimination is faster than Newton Gauss Seidel Method is short sequence of calculation for Newton Gauss Elimination. For this case, there is a bit different of time between the tolerance 0.01 and the tolerance 0.001 comparing with the other two case studies. For tolerance 0.001, the time taken for both numerical methods in one iteration is faster than time taken for tolerance 0.01 in one iteration. The reason for this incident happens is the internal diameter and the length of network system inserted during the data input is too small, causing the pressure drop becomes small. Thus, the results and time are easily obtained since the tolerance is small. Like case study 1 and 2, Fig ure 5.15 is the combination of Figure 5.6 and Figure 5.14 because the computation time results obtained for extended case study 1 are still the same although many tests on the computation time have been carried out. The fastest method in performing the analysis on graph theory algorithms and numerical methods for extended case study 1 is the combination of BFS and Newton Gauss Elimination with the total time 55.87 milliseconds, 4.04 milliseconds slower than case study 2 and 15.64 milliseconds slower than case study 1. The reason is the graph becomes larger than the graphs in case study 1 and case study 2. The graph of extended case study 1 is an un-weighted graph. Thus, the computation times obtained from the combination of MST and Newton Gauss Elimination and the combination of Dijkstra’s Shortest Path and Newton Gauss Elimination is almost as fast as the computation time obtained from the combination of BFS and Newton Gauss Elimination. One Iteration, 7 nodes 12 11.05 10.96 10 8.96 Computation Times (ms) 8 7.63 7.85 7.77 Tolerance 0.1 0.01 6 0.001 4 2 0 Gauss Elimination Gauss Seidel Numerical Methods Figure 5.13: One Iteration Time for extended study case study 1 versus the Newton Gauss Elimination and Gauss Seidel Method Total Iteration,7 nodes 80 72.35 70 60 50.70 50.26 Tolerance Computation Times (ms) 50 44.23 0.1 0.01 40 0.001 34.82 30 25.45 20 10 0 Gauss Elimination Gauss Seidel Numerical Methods Figure 5.14: Total Iteration Time for extended study case study 1 versus the Newton Gauss Elimination and Gauss Seidel Method. Computation Time for Case Study 2 versus Graph Theory Algorithms and Numerical Methods 90 Legend 80 Newton Gauss Seidel Method (0.001) Newton Gauss Elimination (0.001) 70 Dijkstra's Shortest Path Computation Time (msec) 60 MST SCC 50 72.35 72.35 72.35 72.35 72.35 DFS 40 50.26 BFS 50.26 30 50.26 50.26 50.26 20 10 12.80 12.80 5.62 5.62 7.57 7.57 5.78 5.78 5.67 5.67 0 Graph Theory Algorithms and Numerical Methods Figure 5.15: Computation Time for Extended Case Study 1 versus the Graph Theory Algorithms and Numerical Methods. 5.3.6 Discussion on Speed Test with Network Analysis Generally, there are many factors that can influence in the calculation of computation time for the speed test analysis with network analysis. These factors are the flow equations used, the network arrangement (how the network is connected, like one node to many nodes and so on) and network configuration (number of nodes, branch and loop), graph theory algorithms used, numerical methods used, the size of Jacobi Matrix and so on. However, for these three case studies, the factors that have been focused and analysed in this research are the network configuration, the size of Jacobi Matrix, graph theory algorithms used and the numerical methods used. The computation time for the flow equations used in the computer simulator and the network arrangement are not studied in this research, due to the objective of this research. For all the case studies, to obtain the fastest computation time in the computer simulator, smaller network, smaller size of Jacobi Matrix, Breadth First Search and Newton Gauss Elimination must be used. Smaller network means the number of nodes, branch and the number of loop involved are small, like in case study 1. When smaller network is used, the size of Jacobi Matrix formed is smaller because the size of the matrix only depends on the number of node, especially the load nodes (if Newton Nodal Method is used). Thus, the total computation times for the graph theory algorithms and the numerical methods are faster. This is the situation happens in case study 1, Figure 5.9, where the computation for case study 1 is fas ter than case study 2, Figure 5.12.and extended case study 1, Figure 5.15. Breadth First Search and Newton Gauss Elimination method are the fastest graph theory algorithms and numerical methods in this research. The reason of Breadth First Search is the fastest because of the start node (source node) are directly connected to the end node (last load node). Different graph theory algorithms have different computation time on different network configuration. This means that Breadth First Search is fastest in case study 1 (network with 5 nodes), faster in case study 2 (network with 6 nodes) and fast in extended case study 1(network with 7 nodes). Newton Gauss Elimination method is faster than Newton Gauss Seidel method because of its short sequence of calculation 5.4 Accuracy Analysis for Gas Network System The accuracy analysis is done on the two case studies in order to determine how accuracy the flow rate results is, obtained from the computer simulator developed, comparing with other commercial software, GaPIS in the market and to determine the most accurate numerical methods. For extended case study 1, the flow results obtained from the Weymouth equation is compared with the flow results obtained from the Panhandle ‘A’ equation, in the computer simulator. 5.4.1 Accuracy Analysis for Case Study 1 In case study 1, using the tolerance of 0.001 for both Newton Gauss Elimination and Newton Gauss Seidel Method, accuracy analysis on the flow is done. From the results obtained in Table 5.9, the average accuracy results on the flow rate for both numerical methods are 99.22%. Thus, the flow results obtained from the computer simulator developed is very close to the flow results from the commercial software, GaPIS. The reason is the same flow equation, w hich is the Pole’s equation and the same numerical methods are used. Graph of flow comparison for Newton Gauss Elimination is plotted based on the accuracy analysis results obtained. The graph is shown in Figure 5.16. From the graph, line s are plotted for the flow results obtained from GaPIS and the computer simulator. The flow results obtained from computer simulator are in the same shape like the flow results obtained from GAPIS. T his means the flow results obtained from the computer simulator is as accurate as the flow results obtained from GaPIS . However, all the flow results are not perfectly accurate, comparing with GaPIS. This is due to different specific gravity of gas is used. Same things happen for Newton Gauss Seidel Method. The flow results obtained from the computer simulator is as accurate as the flow results obtained from GaPIS. The graph of flow comparison for Newton Gauss Seidel Method is shown in Figure 5.17. Based on the tables and graphs, both numerical methods provide flow results with same accuracy. For this case study, the computer simulator developed can provide accurate flow results. So, the Pole’s equation and the numerical methods in this computer simulator can be used to perform the network analysis. The computer simulator developed is suitable to be used in small gas network system with low pressure. Table 5.9 : Accuracy Analysis in Case Study 1 Newton Gauss Elimination Tolerance=0.001 GASNETWORK Result SYTEMV1 No GaPIS Percentage Flowrate Branch Send Receive Flowrate (m3/h) (m3/h) 100% 1 1 2 223.218 223.771 99.75 2 1 3 89.7936 89.125 99.26 3 1 4 253.9282 254.525 99.77 4 1 5 83.06012 82.5798 99.42 5 3 2 26.7819 26.2295 97.94 6 3 4 36.9884 37.1045 99.69 7 5 4 36.9399 37.4202 98.72 Average: 99.22 Newton Gauss Seidel Method Tolerance=0.001 GASNETWORK Result SYTEMV1 No GaPIS Percentage Flowrate Branch Send Receive Flowrate(m3/h) (m3/h) 100% 1 1 2 223.218 223.771 99.75 2 1 3 89.7936 89.125 99.26 3 1 4 253.9282 254.525 99.77 4 1 5 83.06012 82.5798 99.42 5 3 2 26.7819 26.2295 97.94 6 3 4 36.9883 37.1045 99.69 7 5 4 36.9398 37.4202 98.72 Average: 99.22 Gas Network System Versus GaPIS Flowrate(m3/hr) 300 250 200 150 100 50 0 1 2 3 4 5 6 7 Branch GASNETWORKSYTEMV1 GaPIS Figure 5.16: Newton Nodal Method (flow comparison case study 1– Newton Gauss Elimination). Gas Network System Versus GaPIS Flowrate(m3/hr) 300 250 200 150 100 50 0 1 2 3 4 5 6 7 Branch GASNETWORKSYTEMV1 GaPIS Figure 5.17: Newton Nodal Method (flow comparison case study 1– Newton Gauss Seidel Method). 5.4.2 Accuracy Analysis for Case Study 2 In case study 2, the average accuracy results on the flow rate for both numerical methods are 95.64%. Thus, the flow results obtained from the computer simulator developed is close to the flow results from the commercial software , GaPIS. The reason is the same flow equation, which is the Cox’s equation, and the same numerical methods are used. Table 5.10 shows the accuracy test for case study 2. Figure 5.18 shows the graph of flow comparison for Newton Gauss Elimination. From the graph, like in case study 1, lines are plotted for the flow results obtained from GaPIS and the computer simulator. The flow results obtained from computer simulator are stil l in the same shape like the flow results from GAPIS, but compare with case study 1; the shape is not that alike starting from branch 6. This means the flow results obtained from the computer simulator is just as good as the flow results obtained from GaP IS, but not more accurate than in case study 1. This is due to different specific gravity of gas is used and different Cox’s coefficient is used in the computer simulator, comparing with GaPIS. The flow result of branch 6 has significant different from the other flow results and the accuracy of flow results from branch 6 to 9 (chords) are between 84 to 97%. The cause of these phenomena is the flow results starting from branch 6, are affected by the flow results starting from branch 1 to 5 (branches), when the chord flow calculation process takes place (see Chapter 3, section 3.11.5). Slightly changes in the flow results (comparing with GaPIS) starting from branch 1 to 5, will cause different in the pressure drop (pressure drop become bigger). Thus, it will cause major changes in the flow results from branch 6 to 9. Same things happen for Newton Gauss Seidel Method. The flow results obtained from the computer simulator is as good as the flow results obtained from GaPIS . The graph of flow comparison for Newton Gauss Seidel Method is shown in Figure 5.19. Based on the tables and graphs, both numerical methods provide flow results with same accuracy. For this case study, the Cox’s equation used in the computer simulator can provide accurate flow results and suitable to be used in gas network system with medium pressure. Table 5.10: Accuracy Analysis in Case Study 2 Newton Gauss Elimination Tolerance=0.001 GASNETWORK Result SYTEMV1 No GaPIS Percentage Flowrate Branch Send Receive Flowrate(m3/h) (m3/h) 100% 1 1 2 219.7473 214.086 97.42 2 1 3 86.8908 88.4701 98.21 3 1 4 238.1071 241.271 98.69 4 1 5 73.3305 73.3538 99.97 5 1 6 181.9232 182.891 99.47 6 3 2 30.2526 35.914 84.24 7 3 4 43.3617 47.449 91.39 8 5 4 14.6949 13.8272 94.10 9 6 5 31.9223 32.819 97.27 Average: 95.64 Newton Gauss Seidel Method Tolerance=0.001 GASNETWORK Result SYTEMV1 No GaPIS Percentage Flowrate Branch Send Receive Flowrate(m3/h) (m3/h) 100% 1 1 2 219.7473 214.086 97.42 2 1 3 86.8908 88.4701 98.21 3 1 4 238.1071 241.271 98.69 4 1 5 73.3305 73.3538 99.97 5 1 6 181.9232 182.891 99.47 6 3 2 30.2526 35.914 84.24 7 3 4 43.3617 47.449 91.39 8 5 4 14.6949 13.8272 94.10 9 6 5 31.9223 32.819 97.27 Average: 95.64 Gas Network System Versus GaPIS Flowrate(m3/hr) 300 250 200 150 100 50 0 1 2 3 4 5 6 7 8 9 Branch GASNETWORKSYTEMV1 GaPIS Figure 5.18: Newton No dal Method (flow comparison case study 2– Newton Gauss Elimination). Gas Network System Versus GaPIS Flowrate(m3/hr) 300 250 200 150 100 50 0 1 2 3 4 5 6 7 8 9 Branch GASNETWORKSYTEMV1 GaPIS Figure 5.19: Newton Nodal Method (flow comparison case study 2– Newton Gauss Seidel Method). 5.4.3 Accuracy Analysis for Extended Case Study 1 In extended study case study 1, the flow results obtained from the Weymouth equation in the computer simulator are compared with the flow results obtained from the Panhandle ‘A’ equation in the computer simulator. The test is performed under the tolerance of 0.001 for numerical methods, Newton Gauss Elimination and Newton Gauss Seidel method. T he average accuracy results on the flow rate for both numerical methods are 91.71%. Table 5.11 shows the accuracy test for extended case study 1. Figure 5.20 shows the graph of flow comparison for Newton Gauss Elimination. From the graph, like in case study 1 and 2, two lines are plotted for the flow results obtained from both flow equations in the computation simulator. If the Panhandle ‘A’ works as the control system, the Weymouth equation is in same shape with Panhandle ‘A’ equation. However, the flow results obtained from Weymouth equation become far different, starting from branch 3. This difference in the result is caused by the length input and the diameter input for that particular pipe is too small for Weymouth equation to calculate. Same things also happen for Newton Gauss Seidel Method. The graph of flow comparison for Newton Gauss Seidel Method is shown in Figure 5. 21. Based on the tables and graphs, both numerical methods provide flow results with same accuracy. For this case study, the Weymouth equation can provide the flow results almost as same as the flow results obtained from the Panhandle equation. Thus, the computer simulator can provide good results for gas network system w ith high pressure. Table 5.11 : Accuracy Analysis in Extended Case Study 1 Result (Tolerance=0.001) Weymouth Panhandle ‘A’ Newton Gauss Elimination No Percentage Flowrate Flowrate Branch Send Receive (m3/h) (m3/h) 100% 1 1 2 218.5398 218. 7038 99.93 2 1 3 69.8479 70.8589 98.57 3 1 4 229.5347 224.4258 97.77 4 1 5 221.2319 219.8126 99.36 5 1 6 167.4098 171.2337 97.77 6 1 7 92.9194 94.2278 98.61 7 3 2 47.9851 41.4026 86.28 8 3 4 60.7721 59.1699 97.36 9 5 4 10.6862 4.3045 40.28 10 6 5 89.6693 84.3084 94.02 11 7 6 107.0805 105.767 98.77 Average: 91.70 Newton Gauss Seidel Method No Flowrate Flowrate Branch Send Receive (m3/h) (m3/h) 100% 1 1 2 218.5398 218.7038 99.93 2 1 3 69.8478 70.8589 98.57 3 1 4 229.5346 224.4267 97.77 4 1 5 221.2318 219.811 99.36 5 1 6 167.4098 171.2333 97.77 6 1 7 92.9194 94.2277 98.61 7 3 2 47.9844 41.4029 86.28 8 2 4 60.772 59.1698 97.36 9 3 4 10.6862 4.3095 40.33 10 4 6 89.6693 84.3088 94.02 11 4 5 107.0805 105.767 98.77 Average: 91.71 Flowrate(m3/hr) GASNETWORKSYSTEM V1 Weymouth equation versus Panhandle 'A' equation 250 200 150 100 50 0 1 2 3 4 5 6 7 8 9 10 11 Branch Weymouth Panhandle 'A' Figure 5.20: Newton Nodal Method (flow comparison extended case study 1– Newton Gauss Elimination) Flowrate(m3/hr) GASNETWORKSYSTEM V1 Weymouth equation versus Panhandle 'A' equation 250 200 150 100 50 0 1 2 3 4 5 6 7 8 9 10 11 Branch Weymouth Panhandle 'A' Figure 5.21: Newton Nodal Method (flow comparison extended case study 1– Newton Gauss Seidel Method). 5.4.4 Discussion on the Accuracy Analysis For the three case studies, based on the flow results, both numerical methods provide flow results with same accuracy. This means Newton Gauss Elimination method is as accurate as Newton Gauss Seidel method. Both numerical methods have the same accuracy because of the same flow equation used and the most importantly, the same mathematical concept used that is to find the solutions in these case studies based on the same tolerance used, although the mathematical steps to find the solutions are different. However, Newton Gauss Elimination method is faster than Newton Gauss Seidel method in performing network analysis (already explained in the previous sections). That is why users of this method prefer using it than other numerical methods due to its speed and accuracy. Newton Elimination method is one of the earliest methods for solving simultaneous equations; it remains among the most important algorithms in use today and is the basic for linear equation solving a many popular software packages [5]. In this research, the bigger initial pressure and the larger the network, the accuracy of the flow results decreases. The reasons are different flow equations, and different fraction factor used in the computer simulator. As the initial pressure used become bigger, different flow equations are applied like Pole is only suitable for low pressure distribution. The flow equations have different fraction factors. It is hard to determine the fraction factors especially for high pressure network with high flow rate. Thus the accuracy of the flow results decreases. CHAPTER 6 CONCLUSION AND RECOMMENDATION 6.1 Conclusion A computer simulator has been successfully developed. This computer simulator is called GASNETWORKSYSTEMV1. The objectives of this research have been achieved. Object oriented approach has been used in the development of the structure of this computer simulator. Object oriented is suitable to develop Graphical User Interface (GUI). The user interface is needed to develop a user friendly program. This computer simulator has GUI, which will easily help users to navigate in this computer simulator. The computer simulator uses Newton Nodal Method in order to perform the network analysis. The reason of choosing this method is it is a simple method that suitable in solving set of equations, when comparing with Newton Loop method. The method is used as the basic method to solve the network analysis. In future, other methods such as the Newton Loop Method, Newton Loop-Nodal Method and so on can be implemented into this computer simulator. The flow equations used in this computer simulator are Pole’s (Lacey), Polyflo, Cox’s, Panhandle ‘A’ and Weymouth. These flow equations selected have their limitation like the pressure range. Assumptions have been made on these flow equations so that they are suitable to be used in this computer simulator. Graph theory algorithms are used to represent the gas network computation of any topology, before performing the network analysis. The graph theory algorithms have effect on gas network system, especially the network configuration. The effect is the computation time. The larger the gas network system, this means more nodes and branches involve, and the computation time taken is longer. From the results obtained (speed test analysis), BFS is the fastest graph theory algorithms that are 5.37ms for case 1, 5.48 ms for case 2 and 5.62 ms for extended case study 1. In this research, Newton Gauss Elimination is the fastest numerical method giving us 34.86 ms for case study 1 (tolerance 0.001), 46.35 ms for case study 2 (tolerance 0.001) and 50.26 ms for extended case study 1 (tolerance 0.001), that can be used to solve the network analysis with good speed. The combination of BFS and Newton Gauss Elimination is the fastest way to obtain the network analysis results, with the total time of 40.23 milliseconds in case study 1, 51.83 milliseconds in case study 2 and 55.87 milliseconds in extended case study 1. Both numerical methods used in computer simulator developed have the same accuracy, when the flow results of low pressure network and medium pressure network are compared with the commercial software, GaPIS and when Panhandle ‘A’ and Weymouth equation are compared with each other for high pressure network. For low pressure network, accuracy of 99.22% is obtained when Pole’s equation used. For medium pressure network, accuracy of 95.64% is obtained when Cox’s equation used. For high pressure network, accuracy of 91.71% is obtained. However, the accuracy is decreasing as the network system become larger and the initial pressure become bigger. This is due to different flow equations are used in the network calculation. Lastly, this computer simulator is able to perform the network analysis for low, medium and high pressure distribution network system. This computer simulator can be used as a teaching aid in the gas reticulation course. Future enhancement is needed in order to commercialize this computer simulator. 6.2 Reco mmendations After referring to the result and conclusion obtained from the three case studies, the following recommendations are given for future work. 1. To further develop the computer simulator into a real gas engineering application, which able user to perform calculation involving pump, elbow and others. 2. To incorporate Graphical Information System (GIS) in the computer simulator. It enables the computer simulator to consider the landscape factor for specific area. 3. To further develop the computer simulator into a computer application that can link with other useful program such as AUTOCAD, Matlab and so on. 4. To further develop the computer simulator with addition of some new flow equations like Institute of Gas Technology (IGT) equation, Spitzglass equation, and other methods such as the Newton Loop Method, Newton Loop-Nodal Method and so on. REFERENCE 1. Energy Information Administration (EIA) Natural Gas (1998). 109-127. 2. Gas Malaysia’s Business (2004). (www.gasmalaysia.com) 3. Rodrigue, J. P. (2005). Graph Theory: Definition and Properties. (http://people.hofstra.edu/geotrans/eng/ch2en/meth2en/ch2m1e n.html) 4. Osiadacz, A.J. Simulation and Analysis of Gas Network . First Edition. London: D and F.N. Spon Ltd. 1 – 176; 1987. 5. Yang, K.W. Convergence Characteristics of Steady State Gas Network System Using Numerical Loop -Node Method. Master Thesis. Universiti Teknologi Malaysia; 2001 6. Steven, C. C. and Raymond, P. C. Numerical Methods for Engineers. Third Edition. Singapore: McGraw-Hill. 118-328; 1998 7. Kirchhoff, G. Annalen der Physik and Chemie. 72: 497. 1847. 8. Booch, G. Object Oriented Analysis and Design – With Applications. Second Edition, California: The Benjamin/Cummings Publishing Company, Inc. 1994 9. Object Oriented Programming (2006). (www.www.en.wikipedia.org/wiki/Object-oriented_programming) 10. Kim, W., Lochovsky, Frederick, H. Object Oriented Concepts, Databases and Applications. USA: Addison Wesley Publishing, Company, Inc. 1989 11. Whitmire, S.A. Object Oriented Design Measurement. USA: John Wiley & Son Inc . 1997 12. Shlaer, S. and Mellor, S.J. Object Lifecycles Modeling the World in States. New Jersey: Prentice Hall, Inc. 1992 13. Taylor, D.A. Object Oriented Technology: A Manager Guide. USA: Addison Wesley Publishing, Company, Inc. 1990 14. Lewandowski, A. Object Oriented Modelling of The Natural Gas Pipeline Network. Journal of Pipeline Simulation Interest Group, 1994. 94(2): 1-30. 15. Liberty, J. SAMS Teach Yourself C++ in 21 Days. Fourth Edition. United States: Sams Publishing. 2001 16. Svenk, G. Object Oriented Programming – Using C++ Engineering and Technology. New York: Delmar Learning. 2003 17. Muller, P. Introduction to Object-Oriented Programming Using C++. Berlin, Germany: Globewide Network Academy (GNA). 1996 18. Hubbard, J.R. Programming with C++. Second Edition. Singapore: McGraw -Hill Book Co. 2000 19. Christofides, N. Graph Theory. New York: Academic Press. 1975 20. Wilf, H.S. Algorithms and Complexity. Internet Edition. University of Pennsylvania, Philadelphia. 1994 21. McHugh, J.A. Algorithmic Graph Theory. New Jersey, USA: Prentice Hall. 1990 22. Siek, J.G., Lee, L.Q., Lumsdaine, A. The Boost Graph Library: User Guide and Reference Manual. USA: Addison Wesley Publishing, Company, Inc. 2001 23. Minieka, E. Optimization Algorithms for Networks and Gra ph. New York, USA: Marcel Dekker. 1978 24. Puah, H. Implementasi Sistem Maklumat Geografi Untuk Pemetaan Sistem Utiliti Bawah Tanah Dengan Mengaplikasikan Sistem Maklumat (GIS). Undergraduate Thesis. Universiti Teknologi Malaysia; 2002 25. Wilson, G.G. Gas Distribution . First Edition. Chicago: IGT. 59-84. 1982. 26. Ohashi, T. Natural Gas Utilization for Industrial Users. Tokyo: Tokyo Gas Co. Ltd. 1-390. 1990. 27. Abdel-Alim Hashem. Part Two: Steady State Flow of Gas through Pipes. Oil and Gas Pipeline Design, Maintenance and Repair, 2000. PE 607: 1-71. 28. Dahl, H.J., Romo, F., Tomasgard, A. Optimisation Model for Rationing Efficient Allocation of Capacity in a Natural Gas Transportation Network. SINTEF Report, 2003. IAEE: 4-5. 29. Schroeder, D.W., Jr. A Tutorial on Pipe Flow Equations. Journal of Pipeline Simulation Interest Group, 2001. 01(1): 1-18. . 30. Piggott, J., Kurschat, T., Revell, N. Taking the Rough with the Smooth – a new look at transmission factor formulae. Journal of Pipeline Simulation Interest Group, 2002. 02(2): 2-21. 31. Menon, E. S., P.E. Gas Pipeline Hydraulic. Online Course. 2006 32. Aylmer, S. Interactive Gas Flow Analysis. PhD. Thesis. University of Manchester: Institute of Science and Technology. 1980. 33. Hoeven, T.V.D. Some Mathematical Aspects of Gas Network Simulation. Journal of Pipeline Simulation Interest Group, 1992. 92(6): 1-15. 34. Ferziger, J.H. Numerical Methods for Engineering Application . New York: Wiley. 1981 35. Hartman-Baker, R.J. Introduction to Iterative Methods. 2002 36. Fisher-Uhrig Engineering. STANET: Network Analysis of Gas and Water Networks with Net Database. Berlin: User Guide – Version 7.3. 2003 37. Bean, B.B. GASWorkS 9.0 Demonstration Guide. Colorado: User Guide – Version 9.0. 1997. 38. Hardee, R. Fluid Flow Software vs. Spreadsheets for Piping System Design & Analysis. Engineered Software, Inc . PIPEFLO: White Paper. 2000. 39. The American Society of Mechanical Engineers. Gas Transmission and Distribution Piping Syste m. U.S.A.: American National Standard ASME B31.8. 1990 40. Greg, V. Object Oriented Programming. Berkeley, California: McGraw Hill. 1991 41. Andrus, S. J. Steady State Simulation of Pipeline Network Using a Spreadsheet Model. Journal of Pipeline Simulation Interest Group, 1994. 94(1): 1-13. 42. Vetterling, W.T., Teukolsky, S.A., Press , W.H., Flannery, B.P. Numerical Recipes Example Book (C++). Second Edition. USA: Cambridge University Press. 2002 43. Perry, G. and Spencer, I. Visual C++ in 12 Easy Lessons. Indianapolis: Sams Publishing. 1995 44. Deitel, H. M. and Deitel, P. J. C++ How to Program. New Jersey, USA: Prentice Hall. 1997 45. Gottfried, B.S. Schaum’s Outline of Theory and Problems of Programming with C. Second Edition. Singapore: McGraw -Hill. 1996 46. Jones, R. M. Introduction to MFC Programming With Visual C++. New Jersey, USA: Prentice Hall. 2000 47. Zulkefli Yaacob. Modelling and Simulation of Transient Gas Flow. PhD. Thesis. University of Salford; 1996