For this project I have worked with a program known as VENTSIM. [1][2] The VENTSIM program is a legacy public domain mine ventilation system simulator developed at Virginia Tech as part of a research project sponsored by the US Department of the Interior. It is primarily used to graph the airflow of the inner workings of mines and postulate a feasible, effective, and cost effective ventilation system for that mine, the program also takes potential growth and expansion of the mine into account. The program can be used to optimize airflow by redesigning existing ventilation or used to suggest ventilation options for new mines. VENTSIM's applications stretch far beyond the development of mine ventilation systems. In light of the fact that the VENSTIM program was originally developed by a mining engineer, it is mainly centered on the area of mine ventilation systems. However, the program can very easily be configured to be used in the aspects of the graphing and of the planning of ventilation systems for any situation such as large buildings or other instances that might require an extensive, complicated, or unique ventilation system.
The VENTSIM program is written in a programming language known as FORTRAN 77, the predecessor of today's FORTRAN 90. The FORTRAN language was developed for use in scientific computing by engineers, scientists and mathematicians. Its syntax is more concise and less descriptive than object-oriented languages such as C++ in common use today. [3] This makes for efficient processing speed when performing a series of mathematical calculations; however, FORTRAN is more widely used in legacy systems today than in developing new applications. The VENTSIM program contains over 3800 lines of code that with the exception of comment lines and internal routing directors are largely a series of formulas and algorithms. The program tests various mine ventilation design options that can be expressed as variables, performs an analysis of the variables for defined configurations and delivers the optimum configuration in the output report. Even with the modifications made by individual users with modern computing technology, entering data into the VENTSIM program is still considered cumbersome and difficult. Output from this program has been, and in the vast majority of cases still is, delivered in the form of printing out a physical paper printout instead of today's method of simply printing the data out to a screen. Because of this, the existing program has become all but obsolete.
Despite the extreme age of the application, it can hardly be considered out of date. Although the uses for the FORTRAN language have diminished, the need for a program such as VENTSIM is just as great now, if not greater, than when the program was first created. The foreseeable applications for this program are many. It will help to design ventilation for the increasingly larger buildings and complexes around in modern times. Today the old version of the VENTSIM program is still widely used around the globe. (A casual web search done last fall before I started this project revealed that this program is currently being used in Australia, Argentina, South Africa and several European countries as well as in America for both building and mine applications. VENTSIM was actually a presentation topic at an international mining simulation convention held in Poland in 2000.) It stands to reason that if mining companies are still using an ancient FORTRAN 77 relic program to map their mine's air flow patterns and increase their ventilation efficiency and the safety of their facility, that if a modern version of the program could be developed using a commonly used programming language, accessible and useable by the general public (i.e., open source code), it would be used extensively by all kinds of businesses and corporations for ventilation applications of varying types.
I have been working to re-write the VENTSIM program in the more widely used object-oriented language of C++. I have been renovating the program in gradual steps instead of simply converting one to the other at once. Because I only do a small part of the program or re-engineer only small portions of the program at any given time, quality control becomes a very big issue that can not be ignored. Because every part of the program undergoes several changes individually it is important that the different versions stay true to the original program so that the integrity of the output is protected.
The program is based on electric circuit theory. This enables to be adapted to much more than just mine ventilation. It is applicable for multi level building as well as mines. The calculations performed by the program are based on Kirchhoff's Voltage and Current Laws, which are used in DC circuit analysis. [2] These laws fundamentally state that the sum of the currents flowing into a junction (or node) equal the sum of the currents flowing away from the junction.[4][5][6] In 1928, Hardy Cross, a professor at the University of Illinois, determined that Kirchhoff's Laws could be applied to mine ventilation. [2] The surface shape and texture of the mine walls, the placement and spacing of roof supports, etc., create varying degrees of drag on airflow much as resisters do in an electric circuit. In a circuit, the junctions are where the wires meet. In a mine, the junctions (called splits) are where mineshafts split into multiple tunnels. Factors such as the number of fans and their placement in a mine, fan blade sizes and volume of air delivered serve to decrease resistance and increase airflow. The program also provides for tunnel dimensions, air pressure differences in different tunnels or elevations, leakage volumes and airflow stoppages and blockages where no intake air is available for specific fans, etc. The application user characterizes the existing system and then varies a number of parameters to determine optimal ventilation conditions. As many as 20 roof support plans, 50 splits with up to 99 openings off each split, 5 different fan types with multiple variables (17 blade positions for each fan, volume delivered, base speed, drive type, etc.), and up to 75 leakage path scenarios may be analyzed in one run in the existing program. The program solves for regulator dimensions, best combinations of fan speeds and blade positions, airway balance limits and leakage balance limits. The program includes options for combining follow on data to merge, run independently or considered as add on data for additional scenarios to be run. [2] (Note: I haven't tackled understanding the more sophisticated elements of the program that allow testing multiple data sets in one program run.)
The FORTRAN 77 version of VENTSIM program includes 3800 lines of code not including loops or comments. The program ran as a batch processed job on a mainframe computer and originally took input from punch cards. The program calls 7 types of data cards. Each card type contained up to a maximum 77 character data string that the program separated into the appropriate fields, data types and associated with program defined variables expected for data positions within the string.
The original code also contains many subroutines that were introduced to break the program up into sections that the systems it was being run on could handle. When the program was written, creating programs that could run within available memory was a major obstacle faced by programmers. By splitting the code into subroutines, the programmer was able to save memory.
Because of the iterative nature of my project, with continual revision of the code and translation into an object oriented language, it will be necessary to follow software quality engineering principles such as conferring with subject matter experts to understand what the program is doing and reviewing results with them as the project evolves, practicing good version control, continually assessing output to assure the program integrity is still good, testing multiple data sets for various applications, measuring performance and usability, considering risks and developing strategies to deal with the risks. Appendix A contains an Activity Diagram [7] that visually shows the initial planning steps of the process. After this stage, the new code is developed and tested.
My first task will be to create Windows input screens using C++ to collect the required variables for the FORTRAN version of VENTSIM. This data will be reformatted into strings for each card type and an interface written to feed the input to the FORTRAN version of the program. The program will be run on a FORTRAN compiler and a report generated.
I will then convert the program to C++ and rerun the program. If all goes well, the output data should approximate that of the original program.
Simplifications of the input screens, including prompts and field checks, will follow. Multiple reporting options will also be explored.
Refinements to reduce the complexity of the existing program structure will be incorporated to take advantage of the power of modern supercomputers. This will be done by eliminating some of the subroutines in the FORTRAN version of the program by combining them into the main body of the program to see if computation time is enhanced as a side study. I will track processing times to compare the efficiency of FORTRAN and C++. It will be interesting to see if the C++ version of the program is as fast as the FORTRAN version which is supposedly superior for this type of application.
Down the road, capabilities will be added to the program based on recommendations from the original code author. This modernization of the code could include more comprehensive airflow calculations based on increased knowledge in the field, further conversion to a Java based format and options not available at the time the program was originally written. Graphical output may also be added.
"The scope of work has two major tasks: that of creating a Window compatible
interface for data input and possibly adapting the output for screen display.
Data input is the big task. Data values for several categories must be defined.
Some of the values must be entered manually into fields on the screen, some
can be computer generated as others are defined, and some can be selected from
pull down menus. Before data values can be determined in most cases, a mine
ventilation map must be derived from the mining projections of an existing or
newly planned mine. Categories of data values are: mine airway characteristics,
fan characteristics, closed ventilation network loops (whereby the network flows
can be balanced), flow regulator characteristics, required flow volumes at specified
points, desired flow paths through the mine.
The operation of the interface should be typical for Windows applications in
general, with as much data as possible being entered from the click of a mouse,
others in fields identifying the type of value to be entered (with context sensitive
help available).
Output could be routed to a printer as it was in the batch program, or could
be redirected to the monitor screen." [8]
I started by learning the language FORTRAN 77. Originally, I had planned to convert the FORTRAN code to JavaScript and make the program web based. I then decided that I could go a lot farther with this program than simply a web page. I switched my focus from JavaScript to C++. With C++ I can eventually use VB script and create a Windows.exe program to collect the data, do the calculations, and print the data to the screen.
I learned how to develop Flow Charts. With this knowledge I was able to draw up a pseudo code because it maps out the details of the language in the program rather that just the functions of the program.
I obtained the FORTRAN simulation and reviewed the code. I worked with the program author to understand the syntax and how the program worked. The languages of FORTRAN and C++ are very different - C++ is object oriented and FORTRAN is not. Learning FORTRAN was very challenging because the entire syntax of the language is different from anything I had encountered before.
I will write a basic front end in C++ to serve as an input method to replace the punch cards used in past to feed data to the FORTRAN simulation. It will include a screen to collect input data from the user.
The next step will be to run the VENTSIM program through an F2C conversion program to get a basic outline of what I will be working with to translate the entire program. I will have to be careful about altering the newer versions to the point where they are not true to the original program so they do not alter the validity of the output.
The last step will be to create a windows based front end for the completed converted version of VENTSIM. This will enable users to interact with a user-friendly interface that will allow then to enter data, run the program, and receive output without the hassles of a complicated program. The eventual goal with this step will be that any user with a basic knowledge of ventilation and how to use a computer will be able to sit down and graph a ventilation system to meet his needs whatever they may be.
1. Obtain a copy of original VENTSIM code
2. Review mine ventilation theory with VENTSIM author
3. Obtain a copy of VENTSIM User's Manual, "Computer Applications in Underground
Mining Systems, Volumes I & II." (Borrowed from New Mexico Tech)
4. Learn FORTRAN code by completing an online FORTRAN tutorial
5. Learn to flow chart
6. Register for TVI course, CP278, C++ (Spring '03 semester)
7. Develop Project Plan and test plan
8. Determine Feasibility of translating FORTRAN to Java
9. Locate and use online reference material for Java programming. (Note: this
program could be done in Java; however, I decided C++ was a better fit.)
10. Write a very basic C++ front end to collect input data and to replace the
punch cards used in past to feed data to the FORTRAN simulation.
11. Write an interface to feed the screen-collected data to the FORTRAN simulation.
12. Locate a FORTRAN 77 compiler/ translator
13. Load, operate and understand FORTRAN version of VENTSIM (original program)
14. Enter test data set, compile FORTRAN version of VENTSIM and print results
15. Run FORTRAN version of VENTSIM thru F2C conversion program to convert it
into C++
16. Run "raw" C++ version of VENTSIM with original test data. Compare
results with FORTRAN run.
17. Develop Flow chart for FORTRAN version of VENTSIM using "Inspiration
6" flowcharting utility at SSLC Smart Lab and/or write C++ pseudo code
(See Appendix B)
18. Identify core functions of existing code and prioritize sections. Assign
sections of code to each team member based on flow chart sections. Develop C++
using flow chart as a guide.
19. Assemble and load C++ program on AiS site and begin testing code. Debug.
Expand code utility/capability after existing sections of code are demonstrated
to work.
20. Develop web interface including data input windows that test validity of
input variables and prompt the user with valid data ranges
21. Develop report capability for program output. (Evaluate feasibility of making
report function interactive, allowing user to select information they want reported
from a report menu.)
22. Conduct further study of mine ventilation theory to develop understanding
of math and related physics associated with mine ventilation. Develop an understanding
of the calculations performed by the program and how the program output would
be used.
23. Load program onto a website with adequate security
24. Perform a usability study to assure user interface is intuitive.
25. Refine program. Build better input and output screens, streamline program
by incorporating some of the subroutines into the main body of the program.
26. Write final report
27. Develop presentation
I learned how FORTRAN programs are structured at a basic level and was able
to draw comparisons between the way FORTRAN code is written and the conventions
used in object oriented languages like C++. Since all my programming language
experience has been with object oriented languages, I initially found FORTRAN
confusing.
I learned how to develop and read Flow Charts and how they might be used to simplify a process by providing a visual representation of a system.
I am enrolled in a C++ class at TVI and gaining proficiency in this language.
I understand the concept of simulation and how computer simulations can be used to optimize a solution for an engineering problem.
I understand the concept of using software quality engineering approaches to guide in the development and testing of code. For my VENTSIM project, this means that I will run the test data through the original FORTRAN version of the code. I will run the program at reasonable intervals to assure that the simulation continues to produce the same results (within reason) as the program evolves.
Originally I planned to write this program in JavaScript because of my familiarity with web scripting. I have been taking C++ at TVI and after studying the VENTSIM code, I decided that the program would lend itself better to C++.
The structure of object oriented languages like C++ has quite different syntax when compared to programs like FORTRAN. I understand that FORTRAN is actually a much more efficient language than C++. It will be interesting to see if I can make the C++ program run as fast as the FORTRAN version of VENTSIM.
Recommendations
Continue this project next year. Use the additional time to learn more about software quality engineering and apply the principles to my project. Add additional capabilities to the program and refine the user interface and reporting options.
I was over confident about the amount of time my AiS Challenge Project would take grossly underestimating the scope of the project. I delayed starting on this project until too late in the year. I understand the approach I will need to follow and have a better understanding of the process requirements and schedule constraints that must be observed to succeed.
Acknowledgements
Robert Paztor for sponsoring my participation in the AiS Supercomputing Challenge.
AiS Judges at Interim review for suggesting use of F2C converter for initial translation of the code from FORTRAN to C++ and approach to assure integrity of the simulation results is maintained. Tom Laub for his offer of support when I run the FORTRAN code and also interpreting sections of the FORTRAN code that prove troublesome for me.
Hans Petersen, LRRI, for his extensive efforts toward extracting an updated FORTRAN77 version of the code and test data sets from a 1987 IBM system generated 9-track tape.
Ellis P. Bucklen, for assistance in scoping the project, for providing a copy of the simulation code, several one on one mine ventilation tutorials, background information and rationale behind code structure, review of FORTRAN syntax, suggestions for streamlining the code taking advantage of the power of modern supercomputers, providing a test data set and other support as requested.
Carolyn D. Bucklen for relentlessly tormenting me about this project and becoming the real driving force behind it, for teaching me basic flow charting, for providing an overview of Software Quality Engineering/Software Quality Assurance principles as an approach to software requirements definition, development, verification and validation.
Sandra Lacata, NMT Librarian, for arranging for the loan of VENTSIM User's Manual from the NM Tech Library.
Bibliography
[1] Bucklen, Ellis P., et al, Computer Applications in Underground Mining Systems, Part I, Prepared for Office of Coal Research, Department of the Interior, V. 1. Summary Report, V. 5. VENTSIM Program, Virginia Polytechnic Institute, Blacksburg, Va., Dept. of Mining Engineering, 1968 - 1974, pages 1-2, 17-26.
[2] Bucklen, Ellis P., et al, Computer Applications in Underground Mining Systems, Part II, V. 8. Final report, Virginia Polytechnic Institute, Blacksburg, Va., Dept. of Mining Engineering, 1968 - 1974, pages 1-47, Exhibits 1-5.
[3] FORTRAN, http://www-it.hr.doe.gov/standards/stdsdesc.cfm?Id=97 , [Online tutorial]
[4] Collinson, Andy. Basic DC Theory. March 2003
http://www.mitedu.freeserve.co.uk/Theory/basicdc.htm [Online tutorial]
[5] DC Circuits, Kirchhoff's Current Law, [Online tutorial]
http://www.physics.uoguelph.ca/tutorials/ohm/Q.ohm.KCL.html ,
[6] Kiselev, Sergey and Yanovsky-Kiselev, Tanya. Interactive Physics and Math
with Java, Circuits and Kirchhoff's Rules (series). June 1997. [Online tutorial]
http://www.lightlink.com/sergey/java/index.html and http://webphysics.ph.msstate.edu/javamirror/ipmj/java/kirch4/index.html
[7] Seacord, Robert C., Modernizing Legacy Systems: Software Technologies,
Engineering Processes and Business Practices, Addison Wesley, 2003
[Online synopsis]: http://www.sei.cmu.edu/cbs/mls/mls.htm cites Activity Diagram
of Risk Managed Modernization (RMM) with descriptions of process steps: http://www.sei.cmu.edu/cbs/mls/rmm-diagram.html
[8] E-mail message received from program author and mentor, Ellis P. Bucklen 9/25/2002, describing requirements for Phase I of this project.
Appendix B - VENTSIM Program Flow
MINE VENTILATION SYSTEM ANALYSIS PROGRAM
-START-
SUM HEAD LOSSES ALONG PATHS AND GET EFFECTIVE MINE RESISTANCE FOR EACH FAN
CALCULATE INTERSECTION OF MINE AND FAN CURVES
CHECK TO SEE IF LAST ESTIMATE IS WITHIN FINAL LIMITS
CALCULATE FACTOR FOR BRINGING MINE VOLUME UP TO DESIRED VOLUME
DISTRIBUTE TOTAL MINE VOLUME DIFFERENCE EQUALLY TO EACH FAN
REBALANCE
CHECK TO SEE IF TOTAL VOLUME MATCHES TOTAL WANTED
REBALANCE SYSTEM WITH ARTIFICIAL RESISTANCES ON FAN
CHECK FAN VOLUME AGAINST ACTUAL VOLUME. IF ANY ARE OUTSIDE LIMIT
CALCULATE NEW ARTIFICIAL RESISTANCES AND REBALANCE
IF AN INTERSECTION PROBLEM, RETURN TO BEGINNING AND CALCULATE ANOTHER INTERSECTION
ZERO RESISTANCES
WRITE ERROR MESSAGES
FIND PATH TO ATMOSPHERE
DISTRIBUTE FLOW THROUGHOUT SYSTEM
FORM CLOSED LOOP BY ELIMINATING COMMON SEGMENTS FROM TWO PATHS
PROCESS ANALYSIS DESCRIPTION CARDS
PROCESS ROOF SUPPORT CLASSIFICATION DATA
PROCESS REGULATOR DATA CARDS
PROCESS AIRWAY DATA CARDS
PROCESS FAN DATA CARDS
READ CONTROL CARD FOR FAN J
READ FAN BLADE DATA CARDS
READ BUT DO NOT PROCESS CARDS FOR ELIMINATED FANS
PROCESS LEAKAGE PATH DATA CARDS
PROCESS OPTION DATA CARD
SET UP FLOW PATHS THRU THE SYSTEM
FLOW PATHS FROM FANS
REGULATOR FLOW PATHS
DISTRIBUTE REGULATOR FLOW
FLOW PATHS FROM INTAKES
FUNCTION TO CALCULATE RESISTANCE OF MINE AIRWAYS
CALCULATE AREA AND PERIMETER
CALCULATE EFFECT OF CONTINUOUS OBSTRUCTIONS
CALCULATE EFFECT OF ROOF SUPPORT
CALCULATE FRICTION FACTOR AND COMPOSITE RESISTANCE
WHEN N4 = 1 SOLVE FOR HEAD-QUANTITY COEFFICIENTS
WHEN N4 = 2 SOLVE FOR POWER-QUANTITY COEFFICIENTS
SUM NECESSARY VALUES FOR REGRESSION EQUATIONS
METHOD OF LEAST SQUARES FOR QUADRATIC EQUATION
ENTER VALUES IN EQUATION MATRIX
ELIMINATE FIRST UNKNOWN
ELIMINATE SECOND UNKNOWN
SOLVE FOR COEFFICIENTS
PUT H-Q EQUATION IN FORM H=A*N**2+B*N*Q+C*Q**2
DETERMINE SPEED AND BLADE POSITION WHICH WILL DELIVER REQUIRED VOLUME AND HEAD WITH LEAST HORSEPOWER
DETERMINE EFFECT OF FAN STOPPAGES
CANCEL LOOPS INCLUDING STOPPED FAN
PREPARE TO TREAT STOPPED FAN AS AN INTAKE
ELIMINATE SELECTED REGULATOR VOLUMES
ELIMINATE SELECTED LEAKAGE VOLUMES
RE-BALANCE SYSTEM
PRINT BASE FLOW DISTRIBUTION AND FAN STOPPAGE REDISTRIBUTION
RESTORE SYSTEM
CHECK ALL AIRWAYS INCLUDED IN AT LEAST ONE LOOP
BALANCE SYSTEM
READ THROUGH DATA ON 2 TO PROPER POSITION TO WRITE
READ FAN PATHS OFF 1 AND CALCULATE FAN HEAD
POSITION TAPE 1 FOR WRITING RESISTANCES,HEADS, AND VOLUMES
IF N7=3 TAPES ARE IN POSITION TO READ FROM FOR WRITING OUTPUT
SET INDICES FOR WRITING REGULATOR DATA
ROUTINE TO CALCULATE AND WRITE RESIS, Q, AND H ON TAPE UNIT
SET INDICES FOR AIRWAYS
CALCULATE AND WRITE LEAKAGES ON TAPE UNIT
PRINT INITIAL TABLE OF VALUES
DETERMINE MINIMUM HORSEPOWER TO DELIVER REQUIRED MINE VOLUME
FIND UNREGULATED FAN LOOPS WHICH INCLUDE CURRENT FAN
ESTABLISH TABLES FOR MINIMUM HORSEPOWER DETERMINATION
SELECT MINIMUM HORSEPOWER CONDITION
ELIMINATE HIGHEST HORSEPOWER TABLE OF VALUES
DETERMINE ADJUSTMENT FACTOR FOR VOLUME TO REPLACE ELIMINATED TABLE
DETERMINE ADJUSTMENT FACTOR FOR VOLUMES CONVERGING ON MIDDLE TABLE
STORE MINIMUM VALUES IN ALL TABLES
SET FAN VOLUME BACK TO VOLUME REQUIRED FOR MINIMUM HORSEPOWER
PRINT MINIMUM TABLE OF VALUES AFTER NTH ADJUSTMENT
CALCULATE REGULATOR DIMENSIONS
CALCULATE RESISTANCE OF REGULATOR IN THE NTH ENTRY
CALCULATE VOLUME TO PASS THROUGH REGULATOR
CALCULATE AREA OF REGULATOR
CALCULATE COEFFICIENT OF CONTRACTION
CALCULATE DIMENSIONS OF REGULATOR OPENING
SOLVE FOR SYMMETRICAL OPENING
SOLVE FOR SQUARE OPENING (APPROX)
WRITE COLUMN HEADINGS
SET INDICES ON OUTPUT DO LOOP FOR FANS
START OF OUTPUT DO LOOP
WRITE IF NO OPTIONS ARE SELECTED
WRITE IF ONE OPTION IS SELECTED
WRITE IF BOTH OPTIONS ARE SELECTED
END OF OUTPUT DO LOOP
SET INDICES ON OUTPUT DO LOOP FOR REGULATORS
SET INDICES ON OUTPUT DO LOOP FOR AIRWAYS
SET INDICES ON OUTPUT DO LOOP FOR LEAKAGE PATHS
DETERMINE TOTAL PROBLEMS AND TOTAL CARDS EACH TYPE FOR EACH PROB
DETERMINE WHETHER SYSTEM IS BALANCED
ADJUST REGULATOR RESISTANCES
CHECK FOR CHANGES IN LEAKAGE VOLUMES
BALANCE SYSTEM
CALCULATE UNBALANCED PRESSURE DROP AND FLOW CORRECTION
MAKE FLOW CORRECTIONS
ESTABLISH CLOSED LOOPS THROUGHOUT SYSTEM
FAN LOOPS
REGULATOR LOOPS
INTAKE LOOPS
AIRWAY LOOPS
SET UP LEAKAGE LOOPS AND PATHS
OUTPUT DATA
-END-