Top Banner
,' AD-A130 694 USERS GUIDE: SIMULATION MODEL FOR 'AMMUNITION PLANTS: I/ PREDICTION OF WASTEW.I CONSTRUCTION ENGINEERING RESEARCH LAD (ARMY) CHAMPAIGN IL S RAIISBACK ET AL. UNCLASSIFIED JUN 83 CERL-TR-N- 152 IAO-81052 FIG 13/8 14L IAI flfl **D
70

IAI flfl **D - DTIC

Mar 16, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: IAI flfl **D - DTIC

,' AD-A130 694 USERS GUIDE: SIMULATION MODEL FOR 'AMMUNITION PLANTS: I/PREDICTION OF WASTEW.I CONSTRUCTION ENGINEERINGRESEARCH LAD (ARMY) CHAMPAIGN IL S RAIISBACK ET AL.

UNCLASSIFIED JUN 83 CERL-TR-N- 152 IAO-81052 FIG 13/8 14L

IAIflfl **D

Page 2: IAI flfl **D - DTIC

t 2.

L. 1 20li .0

1.25 11111 1.4 .

MICROCOPY RESOLUTION TEST CHART

NAT.0WAL BUREAU 01 51-NO-RDS -'963

Page 3: IAI flfl **D - DTIC

contrutio of Engineers TECHNICAL REPORT j5engineeringJue18researchlaboratory_____________

USERS GUIDE:SIMULATION MODEL FOR AMMUNITION PLANTS;

PREDICTION OF WASTEWATER CHARACTERISTICSAND IMPACT OF REUSE/RECYCLE

ADA13 11A -4

bySteven Railsback

Manette MessengerRonald D. Webster

John T. Bandy

DTICELECTEJUL 2 61

B

son son

lo CIL~ £ON Approved for public release, distribution unlimited.

83 07 26 117

Page 4: IAI flfl **D - DTIC

The contents of this report are not to be used for advertising, publication, oipromotional purposes. Citation of trade names does not constitute anofficial indorsement or approval of the use of such commercial products.The findings of this report are not to be construed as an official Departmentof the Army position, unless so designated by other authorized documents.

The Computer program described herein is furnished by theGovernment and is accepted and used by the recipient withthe express understanding that the United States Governmentmake no warranties, expressed or implied, concerning theaccuracy, completeness, reliability, useability, or suita-bility for any p ;ticular purpose of the information anddata contained in this program or furnished in connectiontherewith, and the United States shall be under no liabil-ity whatsoever to any person by reason of any use madethereof. The program belongs to the Government. There-fore, the recipient further agrees not to assert any pro-prietary rights therein or to represent this program toanyone as other than a Government program.

DESTROY THIS REPORT WHEN IT IS NO I ONGER NEEDED

DO NOT RETURN IT TO THE ORIGIN.4 TOR

Page 5: IAI flfl **D - DTIC

UNCLASS IFIEDSECURITY CLASSIFICATION OF THIS PAGE (When D)A Pngd)

REPORT DOCUMENTATION PAGE 'Fi'ORF COMIt.iING I- IRM

I. REPORT NUMBER 2. GOVT ACCESSION NO. 3. RECIPIENT'S CATALOG. NUMItI R

CERL-TR-N-152 -

4. TITLE (and Subtitle) 5. TYPE OF REPORT & PERIOD COVERED

Users Guide: Simulation Model for Ammunition FINALPlants; Prediction of Wastewater Characteristics S. PERFORMINGORG. REPORT NUMBER

and Impact of Reuse/Recycle

7. AUTHOR(*) S. CONTRACT OR GRANT NUMBER(&)

Steven Railsback John T. BandyManette Messenger IAO 81052Ronald D. Webster

9. PERFORMING ORGANIZATION NAME AND ADDRESS 10. PROGRAM ELEMENT. PROJECT. TASKAREA & WORK UNIT NUMBERSU.S. Army Construction Engr Research

Laboratory

P.O. Box 4005Champaign, IL 61820

11. CONTROLLING OFFICE NAME AND ADDRESS 12. REPORT DATE

June 198313. NUMBER OF PAGES

6514. MONITORING AGENCY NAME & ADDRESS(If different from Controlling Office) 15. SECURITY CLASS. (of this report)

UNCLASSIFIED

Ise. DECLASSI FICATION/ DOWNGRADINGSCHEDULE

16. DISTRIBUTION STATEMENT (of this Report)

Approved for public release; distribution unlimited.

17. DISTRIBUTION STATEMENT (of the abstrect entered In Block 20, It different from Report)

1,. SUPPLEMENTARY NOTES

Copies are obtainable from National Technical Information ServiceSpringfield, VA 22151

19. KEY WORDS (Continue on reveree side If necessary and Identify by block number)

ammunitionmanufacturingwater pollutionwaste watercomputerized simulation

240 ATRA42T (Ctc11. 00 .,win . N nese"M d tifr by block mi,,be)

\qhis report describes the algorithm and details the operating instructions required for

an ammunition plant process model developed for DARCOM environmental personnel.

The model was created to define the impact of increased ammunition production on the

quantity and quality of the effluents discharged from the plants. It also allows assessmentof the impact of recycle/reuse of wastewaters on final effluent quality. This model maybe accessed through the Environmental Technical Information Systenm..

DO I IWOvSS W T11 Ot NovasISOMSOLETE UNCLASSIFIED

SECURITY CLASSIFICATION OF THI4 PAGE (When Dlat EnFeed)

Page 6: IAI flfl **D - DTIC

FOREWORD

This work was performed for Headquarters, Army Materiel Development and Readi-ness Command (DARCOM) under IAO 81052 by the Environmental Division (EN) ofthe U.S. Army Construction Engineering Research Laboratory (CERL). The DARCOMTechnical Monitor was Mr. Harry Delong.

Dr. R. K. Jain is Chief of EN. COL Louis J. Circeo is the Commander and Directorof CERL, and Dr. L. R. Shaffer is Technical Director.

-

Avai2 i ...

jAvaii : I'i/orDlst 4Specil

3 |

Page 7: IAI flfl **D - DTIC

CONTENTS

DD FORM 1473 1FOREWORD 3

LIST OF FIGURES 5

INTRODUCTION .......................................... 7BackgroundObjectiveApproach

2 MODEL FORMULATION .................................... 7Defining Model CharacteristicsGeneral DescriptionRoutinesModel Verification and Field ApplicationPossible Model Modifications

3 USERS GUIDE.............................................. 14Accessing ETISThe Plant Model

4 SUMMARY AND RECOMMENDATIONS .......................... 19

APPENDIX A: Example Session 19APPENDIX B: Program Listing 32

DISTRIBUTION

4

Page 8: IAI flfl **D - DTIC

FIGURES

Number Page

I Simplified Flowchart of Hydraulic Model 8

2 Simplified Flowchart of Pollutant Model 9

3 Example Process Train 9

4 Connection Matrix Built by Routine Matrxin 10

5 Numbered Connection Matrix (Variable Numbers) in Routine Bildsys 10

6 Determinant (System of Equations) Built by Routine Bildsys 12

7 Example ETIS Instructions and Explanation 16

Al Example Process Train 19

-- ° me ,. i m i l I

Page 9: IAI flfl **D - DTIC

USERS GUIDE: SIMULATION MODEL FOR 1. Ability to model any type of water use that mayAMMUNITION PLANTS; PREDICTION OF occur in AAPs, including water for nine manufacturingWASTEWATER CHARACTERISTICS AND processes, washdown, cooling, and transporting tin-IMPACT OF REUSE/RECYCLE ished ammunition through pipes.

2. Ability to specify a water-using process as many

INTRODUCTION distinct steps or at a "black box."

3. Ability to change flow interconnections and re-

Background run the model to assess the impact of recycle/reuse.

Army Ammunition Plants (AAP) manufactureexplosives and propellants for use by all U.S. military 4. Creation of a user-friendly interactive environ-

services. The Army began to eliminate pollutant ment to prompt the users for necessary data inputs

discharge from ammunition plants in the early 1970s. and changes.As a result, most AAPs now meet National PollutantDischarge Elimination System (NPDES) discharge 5. Use of the C programming language and UNIX

requirements; however, production is not even close operating system for all software developed in order toto design capacity at any of the plants. Thus, it is not simplify eventual transport to DARCOM computers.

clear that wastewater treatment facilities could success-fully treat a five- to ten-fold increase in pollutant A model flexible enough to apply to the variety of

loadings caused by capacity production to the levels AAP water-using activities allows the user to becomerequired by NPDES permits. Therefore, the Army familiar with one tool which can solve many problems.

must identify the effects of increased levels of am- Designing such a "general-purpose" model means that

munition production on the ultimate amount of very few assumptions are made about the character-

toxic pollutants discharged from AAP wastewater istics of any particular process. Instead, the user must

treatment facilities, describe each process train fully.

Objective General DescriptionThe objective of this study was to develop a com- The model designed to incorporate these defined

puter modeling tool to help Headquarters, Army characteristics includes four basic steps:Materiel Development and Readiness Command(DARCOM) and AAP personnel predict: (1) the I. The user describes a process train.effluent quality of wastewater streams as a function ofammunition production level, and (2) the effect of 2. The user describes water use, pollutant gener-various water reuse/recycle options of effluent quality. ation, and treatment efficiencies for each process inThis report documents the model formulation, soft- the train as a function of production level.ware development, and user instructions.

3. The program calculates water flows or pollutantApproach loadings throughout the system, including the dis-

Needed model characteristics were defined, and a charge; this is displayed immediately and saved in amodel was designed to satisfy these requirements file called RESULTS.(Chapter 2). Software and supporting documentationwere then developed (Chapter 3). 4. The user may change the system characteristics

such as flow connections, treatment levels, etc., andre-run the program; this allows the analysis of various

SF Uwater reuse/recycling schemes.iMODEL FORMULATION

The program describes the flow network with a setof simultaneous linear equations whose solution is the

Defining Model Characteristics flow rates in each pipe. Each plant process. whetherThe first step in designing a model that would meet manufacturing or treatment, is referred to as a node.

Army requirements was defining its necessary qualities. Nodes can also be pipe junctions or other situationsResearch indicated that a model combining the follow- where water or pollutant flow rates are changed. Theing characteristics would best meet these needs: flows between connected nodes are the variables the

7

Page 10: IAI flfl **D - DTIC

program solves for. Figures 1 and 2 are simplified use of Kirchoff's laws to solve electrical networks. Theflowcharts that describe how the plant model handles first set of equations, which is extracted directly fromwater flows and pollutant loadings, the connection matrix, simply states that the sum ot

inflows to a node equals the sum of outflows. WhenThe program describes the system of flows by means there is a node with more than one outflow, such as

of the connection matrix -- the variable "array." The for a recycle, more equations are added to describe theconnection matrix is a two-dimensional array, with fraction of the outflow which goes to each downstreameach node represented by a row and a column. The node. At nodes where there are water inflows to thecolumns represent nodes which flow is "from," and system, an equation is added which states that thethe rows represent nodes which flow is "to"; a "1" in inflows to the node. including inflows from the waterthe matrix indicates connection between nodes. For source, equal the water demanded by the node. Atinstance, flow from node 3 to node 5 is represented by this point, a variable representing the source flow ata "I" in column 3, row 5. The connection matrix the node is added.allows the user to change flow pathways easily bysimply inserting or deleting "I"s in the matrix. Theroutine called Matrxin creates the connection matrix. After all these equations are generated, there is

one equation for each variable (pipeflow), and theOnce the connection matrix is made, it is used equations can be solved. This is done by the computer

by the routine Bildsys to generate the equations with a Gaussian Elimination routine in the functiondescribing the system. These equations are represented Solvsys.by their determinant (variable "determ")and the vectorof right-side values ("rhs"). (In matrix notation, thesystem of equations is defined by "determn[] [I * Following a more detailed description of eachvar] rha[] ".) routine of the program, roughly in the order in which

control normally flows. Figure 3 shows a simpleSeveral kinds of equations describe the inflows and process train which will be used to illustrate the results

outflows at each node, in a manner analogous to the of each routine.

ii If RELATIONSHIP BETWEENMATRIX OF WATER USE AND COMPLETED SYSTEMFLOW INTERCONNECTION SYSTEM OF SIMULTANEOUS PROOUCTION LEVEL AT OF EQUATIONSPLOWUITRONECTMS N MEQUATIONS BUILT FROM EACH NODE IS DERIVED IS SOLVED FORBUILT FROM USER HONCINMTI N RPEINPUT DATA C E N TANO GRAPHEO FROM WATER FLOWSUSER INPUTS (SOLVSYS)

(MATRXIN) (BILDSYS) I FINODMOL GRAPH)

IS SATISFED

USER CHANGESFLOW INTERCONNECTIONS

CHGMTX

......................RERUN. TO MODEL POLLUTANTS DR DIFFERENT FLOW REGIME........................ ... .... T....... ....... . .............. ...F.... .....e........................

Figure 1. Simplified flowchart of hydraulic model.

8

Page 11: IAI flfl **D - DTIC

FOR WASTEWATER TREAT- SYSTEM OFRELATIONSHIP BETWEEN MENT NODES, RELATIONSHIP EQUATIONSPOLLUTANT GENERATION BETWEEN HYDRAULIC SOLVED FOR

WATER FLOW RATES 8 PRODUCTION LEVEL LOADING B % REMOVAL IS CONCENTRATIONEXIST FROM PREVIOUS DERIVED AND GRAPHED DERIVED 8 GRAPHED . OF POLLUTANTRUN TO MODEL WATER FMSEIFROM USER INPUTS IN EFFLUENT

(FINDMDLGRAPH) (TRTMDLGRAPH) ( SOVSYS)

REPE.ATE.D. UNTIL USER... .. REPEATE UNTI USER.."

IS SATISFIED IS SATISFIED

RERUN TO MODEL ANOTHER POLLUTANT OR DIFFERENT FLOW REGIME

OUIT

Figure 2. Simplified flowchart of pollutant model.

SOURCE WATER

(REATOR) (SETTLER) (TREATMENT) OUTFALL

100 m3

/hw REQUIRED

Figure 3. Example process train.

9

Page 12: IAI flfl **D - DTIC

Routines ChgmtxMatrxin The routine Chgmtx allows the user to modify the

Matrxin builds the connection matrix from inter- connection matrix either to correct input mistakes or

active input. It was designed to minimize input effort to model different flow routes. The routine asks the

by allowing the user to describe nodes with alpha- user which node to change; this refers to changing the

numeric names of 20 or fewer characters. The user is outflows. The nodes to which flow is going Are printed

asked to put in the name of a node and the name of out, and the user is asked which nodes, if any, to delete.

the nodes(s) to which flow goes. This is done for all The user may then add flow to any existing node.

nodes; the program builds the matrix from this infor-mation. The information for each node (its name and This routine may be called immediately after the

the names of the nodes flow goes to) is stored in a input routine or before statting a subsequent run of the

structure called "node." "node.ndname" is a character program.string with the node's name, and "node.ndto[]" is an

array of character strings containing the names of the Bildsysnodes flow goes to. The program is presently dimen- Bildsys builds the system of simultaneous equations.

sioned for up to 29 nodes and up to five outflows for Because it is also the main function, it is known in the

each node. (The structure "node" is dimensioned to program as "main." After calling functions Matrxin

30, but the 0 element is not used;likewise, the charac- and Chgmtx, Bildsys uses the connection matrix to

ter arrays tonode and flofrac are dimensioned to 6 but write the first group of equations.

only 5 are used.)The variables are labeled by the program before the

Flows to the outfall (or "sink") should not be put equations are generated. Since each "1" in the con-

in as nodes. Matrxin asks the user which nodes go to nection matrix represents a flow, there will be one

the outfall and automatically includes these flows in variable for each "l ." To keep track of them, the

the flow network. Likewise, flows into the network program goes through the matrix from row 1, column

from the source, whether it is a river or water treat- 1, moving across each row and numbering the -'I "s

ment facility, are automatically included for any node encountered in ascending order. These numbers are

at which there is a water demand (this is done in then referred to as "variable numbers." Since the

routine Bildsys). "1" in the matrix is replaced by its variable t,umber.the variable number for a flow is expressed as

To avoid having to enter all the node information "matrix[row] [col ." There will be a row and column

every time the program is run, an option has been in the determinant for each variable number. Figure 5

added to allow the user to read all the input values for shows a numbered connection matrix.

Matrxin from a file. Matrxin returns a value to themain routine which is the size of the connection matrix The first group of equations (there will be one for

which is also the number of nodes in the system. each node), simply states that the sum o. inflows

Figure 4 shows an example connection matrix, equals the sum of outflows at each node. This is done

NODE I NODE 2 NODE 3 NODE I NODE 2 NODE 3

NODEI 0 0 1 NODEI 0 0 I

NOOE2 1o 0 NOOE2 2 0 0

NODE3 0 I 0 NODE3 0 3 0

OUTFALL 0 0 OUTFALL 0 0 4

Figure 5. Numbered connection matrix (variable

Figure 4. Connectiin matrix built by routine Matrxin. numbers) in routine Bildsys.

10

Page 13: IAI flfl **D - DTIC

by moving through the connection matrix and at each the system, since an extra outflow ineans anl extravariable (element in the matrix with a non-zero value), variable. The equations needed at each node includeputting a +1 in the determinant at row = row in one tor each extra outflow, or one less than thematrix, column = variable number, and a -1 at row = number of outflows. It is assumed that a constantcolumn in matrix, column = variable number. In other fraction of the total outflow will go -, each down-words, the program looks at a flow, finds the node at stream node.which the flow is an inflow, and puts a +1 in theequation for that node. It then finds the node for The program moves through the columns of thewhich it is an outflow and puts in a -1 in its equation, connection matrix. Any column with a non-zero valueFor the bottom row of the connection matrix, which is in more than one row has more than one outflow. Atfor the outfall, only -l's are added, since flow does this point, the user is asked for the fraction of the out-not go to anywhere from the outfall. The result is one flow going to one of the downstream nodes. Thisequation for each node. Within the determinant, the question is repeated so that all the equations neededrow number is equal to the number of the node the can be written. Each equation states that(1 flofrac[i] )equation is for; the column numbers correspond to times the outflow to node i plus (--1 * flofracli])variable numbers, with one additional column for times all the other outflows equals zero (tlofrac[i])flow to the outfall. equals the fraction of the outflow to node i0. This

equation divides the flow between node i and the otherBildsys then asks the user which nodes are processes outflow nodes. Figure 6 is an example of a determinant

at which there is a water demand. These are nodes at built by Bildsys.which the process being modeled requires a certainamount of water; this amount is determined from theproduction level by the function "findmdl" (explained Modeling consumptive use of water is not nowbelow). For such nodes, an additional variable must included in the program. but doing so would not bebe added to represent the amount of water coming difficult. Water consumption either as a constant rate.from the source to this node. An equation is added as a constant fraction of water use, or as a function ofwhich states that the sum of inflows to the node, production level can be modeled by altering theincluding the source flow, equals the water demand "inflow = outflow" equations. This process is similaras determined by Findmdl. The model assumes that to the way pollutant removal is handled, as describedif there is a water demand at a node and if there is on p 13.insufficient inflow from upstream nodes to meet thedemand, water from the source is added. At this point, the set of equations is complete and

Bildsys calls function Solvsys to solve them. The aboveThe equation is added by making a new row in the description of Bildsys has assumed that water flows arc

determinant which has a +1 in each column cor- being modeled and there are sorie differences whenresponding to a variable number in the node's row of pollutants are being modeled instead. Instead of askingthe connection matrix. The inflow is then added by if a water demard function exists, the program asks ifputting a +1 in a new column, which then represents there is pollutant generation at each node. If thethe inflow; the required flow rate is added to the right- answer is "yes," function Findnidl determines thehand side vector (rhs) for this new row. amount of pollutant added to the system instead of the

water demanded. Instead of adding a variable and anBecause another inflow has been added to the node, equation describing water inflow. Bildsys modifies the

each time this procedure is used to add source flow, existing "inflow equals outflow" equation to saNthe program must go back and add a +1 to the node's "inflow plus pollutant generated equals ot los"inflow = outflow" equation. This is done by first This is done by changing the right side of the eitiatlionlooking in the node's column in the connection matrix from zero to the amount o the pIllulant generated I1and finding the first variable number in the column. no pollutant is generated at a node. The plogram asksIn any row of the determinant in which there is a -1 the user if' the node is a waste treatment process wherein the column equal to that variable number, a +1 is the pollutant is removed It' it is. the program uses theadded to the column corresponding to the inflow, function Trtmdl to determine the percent iemoal o1

the pOIlulatit. Tile 'n0low equals OittlO A " CqUAtion isThe final group of equations added describes how then modified to "'inflow tines reniova equal." ou-

flow is divided at nodes with more than one 0u1l1ow. flow.'' This is done by niultiplying the 4I (inflo)This is necessary to provide enough equations to solve values in the eLuaion by the renoval tiaL n

II

Page 14: IAI flfl **D - DTIC

VARIABLE NUMBER

(FLOW Td\ [ INFLOW ATJOUTFALL) NOoIE IJ RHS MEANING

I 2 3 4 5

EQ. # 1 +1 -I 0 0 +1 a 0 INFLOW- OUTFLOW AT NODE I

# 2 0 + 1 -I 0 0 a 0 INFLOWaOUTFLOW AT NODE 2

*3 -I 0 +1 -I 0 0 INFLOW- OUTFLOW AT NODE 3

#4 0 +1 0 0 0 - 100 OUTFLOW AT NODE I -I100(FLOW REQUIRED)

* 5 0.9 0 0 -0.1 0 - 0 RECYCLE 10% OF NODE 3 OUTFLOW

SOLUTION: VAR # I a 10#2- 100* 3- 100#4a 90#5- 90

Figure 6. Determinant (system of equations) built by routine Bildsys.

The final section of Bildsys prints out the various If an existing model is found, it is graphed out byflows after the system of equations has been solved the function Graph, and the user may replace theand then allows another run of the program. model. If the user does not want to change the existing

model, it interpolates the desired water demand orFindmdl pollutant generated and returns it. In all other cases

The routine Findmdl returns the amount of water (a new file created, no existing model found, or ex-demanded o; poiltutant generated at a node when isting model to be replaced), a new model is gener-called from Bildsvs. This is done when the program ated and written into the file, overwriting the existingsearches a file of existing process models, which are model if there was one. The user is asked to put in thetwo-dimensional graphs of production level (as percent productlon level and corresponding water demand orol full production) versus water demanded or poilutant pollutant genecated for a, bitrary nunbc i of points.

generated. The name of each file is the name of the tip it) 20. When a production ievel ol 100 is enered.constituenl. the routine automatically stops, cails hiie graphiin. 5

routine, and asks i' the model should be changei.The pitogram frst checks whether such a file exists When the user is satisfied with tic model. t- ,nru

by using the UNIX library function "open." If "open" interpolates the water demand of pollutant generatiollreturns a negative value, the file does not exist and one from the production level specifieu by the user.is created with the library ftunction "creal." If lie filedoes exist, it is searched i lile lines Iincs which An ilpolital cIssuBIpron built Into Fitulidl taldbegin with the character -x.'' If lie title is the same as l1ltmldl) is that whenI a production level is munhekdthe node name in question, the model is read. If rio which is less Ihain tile first point III the model, tiemodel is found with the node's name, a new model water demand is the same as in the first point ot tlemust be put in. Thus, the user should use the same model. In other words, the program does not assumenode names to use existing process models. that water demand goes to zero as production goes to

12

Page 15: IAI flfl **D - DTIC

zero. This assumption could be changed with a minor diagonal's row to get a non-zero diagonal. When thisprogram modification in the interpolation routine, process is finished, all values below the diagonal ot

the determinant are zero; Solvsys then goes back.

Trtmdl starting with the last variable, and evaluates all tileTrtmdl is very similar to Findmdl; the difference is variables. A variable is evaluated by using the row with

that Trtmdl is used to handle modeling of wastewater it on the diagonal (the row number equal to thetreatment processes, while Findmdl is used to handle variable's column number): its value is the right ,idepoliuitarit generation. Instead of modeling water of the row. minus the sum of all other variables to lhedemand or pollutant generated vs. production level, right of the variable times their coetficients in theit models removal efficiency vs. flow rate, a function determinant: this number is divided by the coetficientwhich is more traditionally used in wastewater of the variable in qucstion. The values of the variablesengineering and modeling. Once the proper model is are stored in the a-ray 'var[] ." At this point, controlfound or put in, exactly as in Findmdl, a value of returns to the main routine Bildsys. which printspercent removal is returned. To do this, a value of the out the results and writes them into a file calledflow rate must be obtained. This value is stored in "RESULTS."the structure "nodes" under the variable "watrin,"where its value was assigned the last time the program Helpwas run for water flows. This means it is important to Help is called whenever the user replies to a prompt

model water flows before modeling pollutant flows with the word "help." Help includes some generaland removal. instructions on using the program and specific in-

structions for each prompt. The instructions for eachGraph prompt are based on the information in the user's

The function Graph is a simple graphing routine guide (Chapter 3).which uses two one-dimensional arrays as input. Itgenerates 50 points between zero and the maximum Model Verification and Field Applicationvalue of the x=axis, then plots them out on 20 rows Enough data has not yet been obtained from anyof 50 columns each. single ammunition manufacturing process to do a

verification study of the model. There are manySolVsys publications from AAP water pollution studies, but

Solvsys solves the system of linear equations gen- there is no complete set of information on processerated by Bildsys, using Gaussian Elimination on the descriptions, water use, pollutant generation, waste-determinant "determ" and the vector "rhs" of right- water treatment capacities, and effluent characteristics.side constants. Gaussian Elimination requires that the all measured under the same production conditions:elements of the main diagonal of the determinant be such data is needed to make a realistic model run.non-zero to avoid division by zero. The problem is compounded because much waste-

water treatment modernization, including water reuse

Solvsys uses two separate methods to insure non- and recycling, has been done since plants stoppedzero values in the diagonal. First it moves down the large-scale production- in fact, the present lack ofrows and if it finds a row with a zero on the diagonal, activity at AAPs will hamper any meling effort.it looks below that row for another row with a non-zero value in the desired column. If it finds such a row, Conversations with Government engineers at AAPsthe rows 4re interchanged. After going through the have deternined that the input data needed to runentire determinant in this fashion, most (but not this model is available, though it may have to benecessarily all) of the diagonal elements are non-zero extracted from operating logs. Unfortunately, theseand the Gaussian Elimination routine starts. logs are not available to non-DARCOM personnel,

which indicates that the program should be used byThe routine starts at row 1, column 1, and looks plant operators or overseers, since they are most

down the rows until it finds a non-zero value in column familiar with plant operations and production levels.1. When this happens, row I is multiplied by theappropriate value and added to this row to make the One problem which will be encountered when thevalue go to zero. The program proceeds in this fashion model is used in the field is that some productiondown through all the columns for each row. If a non- lines do not really have gradations of productionzero element is found in a column whose aiagonal level; i.e., they are either on or off. The model canelement is still zero. the element's row is added to the handle this situation in several ways. If, for instance, a

13

Page 16: IAI flfl **D - DTIC

production line is either on or off during each of three 3. A checking routine for process trains involvingdaily shifts, the water use/pollutant generation graphs reuse/recycle to compare the recycled water qualitycan be drawn as three-stage step functions: for up to against the water quality needed for process influent.33 percent production, the pollution generated by 8hours (one shift) of continuous operation is used; for 4. Environmental fate of toxic pollutants in theup to 67 percent production, the pollution generated receiving stream. A number of adequate fate modelsby 16 hours (two shifts) is used; and for 100 percent exist, but they are not written in the C programmingproduction, the pollution generated by 24 hours (three language.shifts) is used. In such cases, water flows will beaveraged over the whole day, which is realistic if there 5. Costing algorithms and expected treatmentis much detention time in the wastewater treatment efficiencies for various treatment technologies usedsystem. to treat ammunition plant process wastes.

The program can also be used with flat water use/pollutant generation curves, meaning that pollutant USERS GUIDEgeneration is independent of production level, or thatproduction level is irrelevant. In these cases, where theproduction line is either on or off, the effluent is The plant model is available as Experimental Profilereadily predicted by using historical measurements of Number 30 of the Environmental Technical Infor-pollutant flow as the (flat) pollutant generation graph. mation System (ETIS).' ETIS can be accessed overWhen the line is on, these measured flows will be commercial telephone lines by almost any kind ofrouted into the treatment models to predict the computer terminal. ETIS is an interactive, answer-effluent; when the line is off, no effluent will be driven umbrella system which can be used by peoplepredicted. unfamiliar with computers.

Another problem in field use will be that in some Accessing ETIScases, data from only one production level will be If you decide to access the plant model after inter-available. In this case, the user will have to estimate the actively entering ETIS, you need only transfer into theshape of the curves; usually this will mean extrapo- program. The following paragraphs provide instructionslating toward higher production levels. An experienced for accessing ETIS information by remote terminal.ammunition plant operator should know to someextent how water use and pollution generation will Once you have acquired a log-in and a passwordchange as production increases; for instance, the from CERL's Environmental Division, you can accessoperator may feel that the amount of washwater will ETIS by remote terminal by following the directionsremain constant if washdown operations are not in CERL Technical Reports N-56 2 and N-23 (DAincreased with production, while the discharge of some Pamphlet 200-2w), and CERL Technical Reportpollutant from the actual production line may beestimated to be linearly related to production level.This requirement for user judgment is another reasonwhy plant operators should use the program. 'R. D. Webster, et al., Development of the Environmental

Technical Information System, Interim Report E-52/ADAPossible Model Modifications 009668 (U.S. Army Construction Engineering Research

The plant model could be further developed to Laboratory (CERLI, 1975).

include: 2J. van Weringh, J. Patzer, R. Welsh, and R. Webster,Computer.Aided Environmental Legislative Data System

i. Built-in models of the manufacture of explosives (CELDS/ User Manual. Technical Report N-56/ADA061126

and propellants other than TNT. Currently, such (CERL, 1978).

models must be input by the user. 3 R. D. Webster, R. A. Mitchell, R. L. Welsh, E. Shannon,and M. L. Anderson, The Economic Impact Forecast System-Description and User Instructions. Technical Report N-2/

2. A method to account for the consumptive use of ADA027139 (CERL, 1976).water and reaction kinetics of pollutants. A kinetic 4The Economic Impact Forecast System-Descriptionmodel would involve a major effort; however, a model and User Instructions, DA PAM 200-2 (Department of thefor consumptive use of water could be added easily. Army, December 1976).

14

Page 17: IAI flfl **D - DTIC

N-43.5 After acquiring a remote terminal and a tele- 3. Volume of each pollutant (constituent) gener-phone, dial the system's number (FTS 217/3334086, ated (kg/hour or kg/batch) in the water phase versusWATS 800/637-0958). If there is no answer, the entire the production level (percent of full production).system is down for maintenance. Upon hearing asteady tone, plug the phone into the terminal, making 4. Efficiency (percent removal) of all treatmentsure that the earpiece and the speaker are in the processes for each pollutant (constituent) with respectproper openings, and log into the system. After logging to flow rate through treatment process (cubic meters!in with the correct name and password, you will hour or cubic meters/batch).receive system messages. If the system indicated "NODIRECTORY" or a similar designation, access to ETIS 5. How the process train could be modified tois probably closed down and you should try again incorporate recycle/reuse.later. If the system is in operation, output similar tothat shown in Figure 7 will appear on the screen or The model returns values for the flow rate andterminal. (The text on the right-hand side of the figure pollutant loading for each interconnection in theis explanatory and is not part of the output,) process train, including the outfalls. Then modifica-

tion of the existing process train or specification of aKeep several things in mind when using the system. new one is allowed before the program is rerun.

The symbol <CR> used in some instructions means todepress the carriage return button. The instruction to Several general instructions should be followedtype CTRL-d means to simultaneously depress the throughout the program.button marked CTRL and the letter d. An input errorcan be corrected by typing CTRL-h (hitting the CTRL I. All process names are alphanumeric wordsand h buttons simultaneously) if the return button has which can contain any character, but should notnot yet been depressed. This procedure will back the include blanks and must be no more than 20 characterscarriage up one space each time it is repeated. This can long. It is important to maintain spelling and upper/be done as many times as necessary. Every symbol lower-case consistency. It is also important to makewhich has been backspaced over has been removed sure that a process' name is the same as the name offrom the terminal memory. Therefore, if the first the process model, if any, that is on file. At some, butdigit of a six-digit number has been mistyped, you not all prompts, the program will find a spelling errormust depress CTRL-h six times and then retype all six and let the user correct it.digits. The corrected symbols will be overprinted onthe paper. To stop a long listing depress the button 2. Yes or no questions can be answered by spellingmarked DEL (delete). out yes, no, or just by y or n. Upper/lower case is not

important.The Plant Model

Like ETIS, the plant model also contains an answer- 3. The first constituent that should be modeled indriven system to accept required input data from the any run is water because water flows are needed byuser. Five types of information are required to run the the treatment process models. Changes in flow routingmodel: or in production level change water flow rates, and the

program reminds you to model water again after1. A process train showing all flow interconnec- making these changes.

tions, source water inputs, and outfalls.4. At any point in the program where a list is

2. Volume of source water necessary (cubic meters/ typed in, the program will keep repeating the samehour or cubic meters/batch for batch processes) at a prompt. Typing a 0 (zero) tells the program that theminimum of two different production levels (percent user is through entering the list and wants to move onof full production). to the next prompt. In general, "0" acts as an escape.

5 T5. At any prompt which is followed by "h/a,"sS. E. Thomas. R, A. Mitchell, R. E. Ri*g&s, J. J. Fittipaldi, on-line help is available. Simply answer the questionand E. W. Novak, Computer-Aided Environmental ImpactAnalysis jor Industrial, Procurement, and Research, Develop- with the word "help" to obtain a help routine whichment, Test, and Evaluation Activities- User Manual, Technical provides information similar to that given in thisReport N.43/ADA056997 (CERL, 1978). report.

15

Page 18: IAI flfl **D - DTIC

ETIS (Trademark applied for)

United States Army Corps of EngineersEnvironmental Technical Information System

ETIS: What program? (Type <cr> to see list):Type:

1 or intro for an introduction to the Environmental TechnicalInformation System and people to call for help withproblems about using the programs.

2 or eics for the Environmental Impact Computer-aided System.3 or celds for the Computer-aided Environmental Legislative Data System.4 or etfs for the Economic Impact Forecasting System.5 or afeics for the Air Force Environmental Impact Computer-aided System.6 or iicep for the Interagency/Intergovernmental Coordination for

Environmental Planning (IICEP).7 or xper for the Experimental Subsystem Module of ETIS -

Pilot Systems under development.8 or help for HELP on using any of the ETIS systems or UNIX.9 or rubouts to ignore extraneous phone noise.

10 or end or bye to exit from ETIS.mail to see your mail.

Figure 7. Example ETIS instructions and explanation.

Step-by-step instructions for using the model are 3. What is the name of the next node? (h/a)given below, in the order in which the program general-ly flows. Because you can choose how the program The first step in the program is to describe the flowproceeds at several points, some prompts may be network. This is done by first typing the names of each

repeated during a session. node, in any order.

1. Do you want process configuration input to 4. What node does flow go to from <nodename>?

come from a file? (h/a) (h/a)

For the node just entered in response to question 3,This allows you the option of keeping the answers enter the name(s) of the node(s) to which flow goes.

to questions 3 through 5 (below) in a file. Be sure to When there are no more, type in "0."include all the zeroes in the file to terminate question-ing (see general instruction 4 above). Questions 3 and 4 will be repeated until all nodes

are entered; at this point, type in "0" in response to2. What is the name of the file? (h/a) prompt 3.

5. Enter node which goes to sink. (h/a)Question 2 asks the name of the input file if ques-

tion I was answered affirmatively. Type in the name of any process from which flow

goes to the outfall. This prompt will be repeated,If question 1 was answered negatively, questions 3 allowing multiple outfalls, so type "0" after the last

through 5 will be asked. one.

16

Page 19: IAI flfl **D - DTIC

At this point, the flow connections are printed out. production level, water should be modeled first. TIheprompts now given depend on whether waer or a

6. Do you want to change flow connections? (h/a) pollutant is being modeled. The prompts for modelingwater flows are explained in questions 13 through 15.

To change where flow goes for any of the nodes, The prompts for modeling pollutant generation areanswer yes. This question is repeated at the beginning explained in questions 19 through 28.of each rtn, so new flow routing schemes can be trieddurnp the same session. 12. Do ou want to use the existing <constituent>

models? lh a)

Prompts 7 through 9 occur if flow connections arechanged. If you want to use the models already on the file.

without any modifications and without seeing the7. Which node do you want to change? i h/a) models, answer -'yes.- This will bypass prompts

13 through 16, 20 through 23. and 25 through 28.Enter the name of the node whose outflow you

wish to re-route. This instruction will be repeated at 13. Is there a water demand at <nodename>?the end of the change routine, so you can change as (h/a)many nodes as desired.

If the process represented by the nodename is oneAt this point, the nodes which flow goes to from which requires a certain amount of water, answer

the node you want to change are printed out. "yes." This tells the program that you wish to model

the water demand at this node.8. Which node do you wish to eliminate flow to?

(h/a) If question 13 is answered "yes," the program looksfor a file of existing models which includes this node.

If you want to stop flow from going to a node, If the file is not found, or it no model with the node'senter the node's name. You can eliminate flow to the name is found in the file, the next prompt will beoutfall by entering "outfall." This question will be question 15. If a model is found, it will be graphed outrepeated so you can eliminate flow to more then one on the terminal.node, if necessary.

14. Do you want to change this model?9. Which node do you wish to add flow to? (h/a)

If the graph adequately represents the water demandIf you want to direct flow to a node, enter the vs. production level for this node, answer "no." Other-

node's name. If not, enter "0." You can add flow to wise. answer "yes," and you will be able to type in athe outfall by entering "outfall." This question is also new model by answering questions 15 and 16.repeated.

15. Production level?After all changes have been made, or if no changes

were requested, the following prompts are given. 16. Water?

10. What production level? (h/a) Each tin c these two prompts are given, put in a

point on the water demand vs. regular productionEnter the production level you want to model. level graph. You need nut enter a point for zero pro-

This should be expressed as a percent of full pro- duction. When a production level of 100 is entered,duction, so it should be between 0 and 100. the program automatically moves on.

11. What constituent do you want to model? (h/a) The model is now graphed ou.. and you will be

asked again if you want to change it. When you areAt this point, the program also prints out a list of satisfied with the model, answer "no- and the new

the constituents for which models exist, and you model will be written into the file.should choose from them. You may also add a newconstituent to the list by entering its name. For the Questions 13 through 16 will be repeated for allfirst run, and after any changes in flow routing or nodes.

17

Page 20: IAI flfl **D - DTIC

17. Enter fraction of flow from <nodename> to Put in the points for a graph for the amount of the<nodename>. (h/a) pollutant constituent generated vs. production level.

Production level should be expressed as a percent ofWherever there is a divided outflow from a node, full production, i.e., between 0 and 100. You need not

the program must know what fraction of the flow goes put in a point for zero production; the program stopsto each outflow. It will ask this question for all nodes asking for points after you have entered a productionwhich have divided outflows. The value entered should level of 100.be between zero and one.

23. Do you want to change this model?After question 17 has been answered, the program

has all the input it needs and will compute the flows If you are satisfied with the new model whicn hasbetween all nodes. The results will be typed out at just been graphed, answer "no," and it will be writtenthe terminal as well as appended to a file called into the file. Otherwise, you will go back to questionRESULTS, which can be accessed after the session is 20.over.

If the node was not one where the pollutant was18. Do you want another run? (h/a) generated, the following series of prompts will appear.

Answering "no" will terminate the session. "Yes" 24. Is <nodename> a treatment process wherewill take you back to question 6. <constituent> is removed? (h/a)

The prompts explained below are for modeling Answer "yes" if you want to model the removal ofpollutant flows. The following sequence will follow the pollutant at this node, and you will get promptsquestion I I if a pollutant constituent is chosen for 25 through 28. A "no" moves you on to the nextmodeling, node.

19. Is <constituent> generated at <nodename>? Modeling treatment processes is very similar to(h/a) modeling generation or water demand, except you

are modeling percent removal vs. flow rate for treat-If the node is one at which the constituent enters ment processes.

the wastewater stream, answer "yes," and pollutantgeneration will be modeled, as explained in questions At this point, when modeling a treatment process,20 through 23. A "no" reply will lead to further the program looks for a file containing a model for theprompts, as explained in questions 24 through 28. process. If no file is found or no model with the node'sReplying with an "x" tells the program that this node name is found in the file, questions 26 through 28 willis not a treatment process; this bypasses prompts 24 be used to build a model. If a model is found, it willthrough 28. be graphed out and question 25 asked.

After a "yes" reply to question 19, the program 25. Do you want to change this model?searches for a model of pollutant generation vs. pro-duction level in a file. If no file exists or if there is no If you are satisfied with the existing model ofmodel in the file, you will have to build one as in treatment efficiency (y-axis) vs. inflow rate (x-axis),questions 21 and 22. If a file does exist, it will be answer "no," and the program will use the model.graphed out and question 20 asked. Otherwise, answer "yes," and you will get questions

26 through 28 to build a new model. If your model20. Do you want to change this model? does not include flow rates as high as you are trying

to model, you will have to build a new model.If you are satisfied with the existing model, answer

"no." Otherwise, questions 21 and 22 will be used to 26. Flow rate?build a new model.

27. Removal?21. Production level?

For up to 20 points, put in flow rate vs. removal.22. <constituent>? Type in "0" for flow rate to end the input and move

18

Page 21: IAI flfl **D - DTIC

on. The new model will be graphed for you at the APPENDIX A:terminal. EXAMPLE SESSION

28. Do you want to change this model?This example run is for a simplified version of the

If you are satisfied with the model you just built. sellite wash process for TNT, the source of so-calledanswer "no," and the program will return to question "red water." For this example, a pond is the only19 until all nodes have been examined. A "yes" reply treatment process. In recent years, "red water" haswill return you to question 26. either been sold for paper processing or dried and

incinerated. In the example, a hypothetical recycleAppendix A provides an example session of the of the pond effluent is considered.

model, and Appendix B provides the program listing. The model's level of resolution can be chosen bythe user; nodes may be chosen for units as small as

Aindividual reactors, or whole process trains may be' SUMMARY AND RECOMMENDATIONS included in one "black box" node. A degree of

resolution should be chosen that is suitable for the

A pilot ammunition plant computer-aided simu- data available.

lation model was designed and programmed to predictwastewater effluent quality at various production levelsand to assess the impact of reuse/recycle on effluent sellite mfgrquality. Any type of process train can be used asinput to the model to describe water use in AAPs. Theplant model may be accessed through the Environ-mental Technical Information System. sellite sh

Detailed model input data on wastewater qualityand quantity for cooling, washing, and transportoperations is not available in the literature. Suchinformation is probably available in AAP operatinglogs, but would take some time to extract, and it maynot be available for more than one production level.Appropriate estimations and assumptions can be madeby the user when water use and pollutant generation treatment pond

are not well-defined functions of production rate. _outtall

It is recommended that the plant model describedhere be tested and used by AAP and other DARCOMpersonnel before being further developed or refined. Figure Al. Example process train.

19

Page 22: IAI flfl **D - DTIC

Plant Model Program

At all prompts which are followed by: (h/a) you can get on-linehelp by responding with the word 'help'.

Answer yes-no questions with yes, no, y, or n

Do you want process configuration input to come from a file? (h/a)

Do you want general help or help specific to the queszion you are on?Enter I or 2:

1= general2=specific

Ammunition Plant Process Model

This is a program to model the flow of water and water-borne pollutantsThe following general instructions apply:

1. All process (node) names should contain 20 or fewer characters ofany type, but without blanks. Be careful with spelling!

2. Yes or no questions can be answered with: yes, no, y, or n.

3. Whenever a prompt repeats itself you can tell it to move onby typing '0' (zero).

4. You must always model water flows before pollutant flows because treatmentmodels use flow rate as a parameter. Any time you change the productionlevel or re-route flows you should model water flows again.

5. At any prompt where '(h/a)' appears, you can answer 'help' ano ast it.

More details are available in the user manual and details are availablehere for specific prompts.

it '1' to continue

hoose one of the following:

1 Do you want input to come from a file?2 What is the name of the file'?3 What is the name of the next node?4 What node does flow go to?5 Enter node which goes to outfall6 Do you want to change flow connections?7 Which node do you want to change?8 Which node do you wish to eliminate flow to?9 Which node do you wish to add flow to?10 What production level?11 What constituent do you want to model?12 Do you want to use the existing models!13 Is there a water oemand at this node?15 for help with units.

20

Page 23: IAI flfl **D - DTIC

17 Enter fraction of flow from a to b13 Do you want another run?19 Is the constituent generated here?24 Is this a treatment process where constituent is removed?

98 for intrepretation of results99 to quit HELP and return to program

Which one do you want? (you entered 'help' from no. 1l)Help for question I:Do you want process configuration input to come from a file?

If you have a file with all the node names, where flowgoes to for each one, and the names of nodes which drainto the outfall, you can use it instead of answeringquestions 3 through 5. This is very useful when running amodel several times. If you answer yes, the next questionwill ask you the name of the input file.

More help? y or n(D

Do you want process configuration input to come from a file? (h/*)S

Process configuration entry routine: put in the name

and where flow goes to for each node.

What is the name of the next node? Hit zero for no more (h/a)sellitam~r

What node does flow go to from sellitemfr? (h/a)sellitewashWhat node does flow go to from sellitemfr? (h/a)oWhat is the name of the next node? Hit zero for no more (h/a)seillitewashWhat node does flow go to from sellitewash? (h/a)treatmentpondWhat node does flow go to from sellitewash? (h/a)0What is the name of the next node? Hit zero for no more (h/a)treatmentpondEWhat node does flow go to from treatmentpond? (h/a)

0What is the name of the next node? Hit zero for no more (h/a)

Enter node which goes to sink (h/a) (txuieri-ond

Enter node which goes to sink (h/a) @

Flow goes from sellitemfr to sellitewash

Flow goes from sellitewash to treatmentpond

Flow goes from treatmentpond to sink

Do you want to change flow connections? y or n (h/a)

What production level- 0 to 100? (h/a)

What constituent do you want to model?

The following are available: (h/a)

water

21

Page 24: IAI flfl **D - DTIC

TNT

DNT

Do gou want to use the existing water models' (h/&)S

Is there a water demand at sellitemfr? y or n (h/a)

Mooel Water Use at sellitemfr

No file of models found; file created

BUILD A NEW MODEL for sellitemfr

Input water used as a function of production level

Por a max of 20 points, put in prod. level, up to 100.not including zero, and water used/.cnerated

Use units of cubic meters/hour or cubic meters/batch for water(for help with units typo 'help')

Prod. level (h/)

water?

Prod level[2]? (h/a)a

water? 0

Prod. levelE3]' (h/a)

water' S

105 000: cooo

orl0e40: ooo~

0000

0000

84 00: oooo

0 0 0

63 00: 00000 o

00

42. 00: 000

onw 000a 21.00: 00t :00000e

r' - I - S

20 40 60 so 100PRODUCTION LEVEL

Do you want to chang@ this model? y or n

Is there a water demand at sellitewash? y or n (h/a)

Is there a water demand at treatmenvpond? y or n (h/a) 8

water from sellitemfr to selliteoash - 105.00

22

Page 25: IAI flfl **D - DTIC

water From sellitewash to treatmentpond - 105 00

water from treatmentpond to outfall - 105.00

Inflow to network at sellitemfr = 105.00

Do you want another run? y or n (h/a)G

Do you want to change flow connections? y or n (h/a)

What production level- 0 to,QO (h/a)P-evious level was 100)

what constituent do you want to model?

The following are available: (h/a)

water

TNT

DNT

Do you want to use the existing TNT models? (h/a)®

Is TNT generated at sellitmfr? or n (h/a) 9

Do you want general help or help specific to the question you are on'Fnter 1 or 2:

1 general2-speczfzc

Help for question 19, Is constituent generated hereIf this is a process at which the oollutant enters thewastewater stream, and at which there is a pollutantgeneration vs. production level model, answer yesAnswering with a 'x' tells the program that there isneither a pollucant generation nor a treatment modelfor this node.

More help? y or n

Is TNT generated at sellitemfr? y or n (h/a)

Is sollitemfr a treatment process where TNT is removed? (h/a) S

Is TNT generated at sellitewash? y or n (h/a)

No file of models found; file created

BUILD A NEW MODEL for sellitewash

Input TNT generated as a function of production level

For a max. of 20 pointe, put in prod. level, up to 10().

not including zero, and TNT used/generated

Use units of kg/hour or kg/batch for TNT(for help with units type 'help')

23

Page 26: IAI flfl **D - DTIC

Prod levaltl]? (hila

TNT' (

Prod. lev.1C2? (h/a) 0TNT' 200

PIDd. lvelC3I? (h/a) 1100

TNT" 8

Prod. level 43? (h/a)TNT7 @

250.00: 0

00000 0

Go 0200o00, 0o 0

0 0

0000

150 00: 00 0G0 0

00

100.00 00 0

* 00

00so: 00

50.00, 00

T 1ooooooNT

20 40 60 80 100PRODUCTION LEVEL

Do vou Want to change this model? y or

BUILD A NEW MODEL for sellitewash

Input TNT generated as a function of production level

For a max. of 20 points, put in prod. level, up to 100,not including zero, and TNT used/generated

Use units of kg/hour or kg/batch for TNT(for help with units tvp* 'help')

Prod. levelC12? (h/a)

TNT? @

Prod. levhlC23? (h/a) &

TNT'

Prod. level37? (h/a)

TNT')4

Prod. lovel[4.77 (h/a)<Z

24

Page 27: IAI flfl **D - DTIC

TNT

30000 o000

000000

240 0: oo000

000

00

0000

0001;! 00: 00

00000

0060 00: oo

T :Q00N Oo~ooT

20 40 60 80 100PRODUCTION LEVEL

Do gou want to chang* this model? 4 or n G

is TNT generated at treatmentpond? q or n (h/a) eIs treatmontptnd a treatment process where TNT is removed? (hl)@

Moqel Treatmeht Efficienct at teatmentpondNo model called tieatmentpond in file

BUILD A NEW MODEL for treatmentpond

Put in removal percent as a function of flowFor a max. of 20 points, put in flow rate and removal

QJe units of cubic meters/hour or cubic meters/batch for flowFor help with units tVpe 'help'

Flow rate3i? (h/a)

removal? 8

Flow ratel23? (h/a)

removal? 6

Flow ratoC33? (h/a)

removal? a

Flow rateC43' (h/a)O

T 98.O0:oooo

E 400000000CA 0oooooooooT 78.40: aoo4oooo

0000000ENT 5880:

Page 28: IAI flfl **D - DTIC

E

PP 39 20:

E 19 60:NC

100 200 300 400 500FLOW RATE

Do :you want to change this model? y or n @

TNT from sellitemfr to sellitewash 0.00Concentration - 0 mg/l

TNT from sellitewash to treatmentpond - 30000Concentration = 2e57. 14 mg/I

TNT from treatmentpond to outfall = IS 00Concentration - 171.429 mg/l

Do you want another run- y or n (h/a)®

Do you want to change flow connections? y or n (h/a)

Wh ch node do you want to change? (h/a) GDo you want general help or help soecific to the question 4nu are on'Enter 1 or 2:

I= general2=specific

Help for question 7: Which node do you want to change?

Yov dre now in the routine to change flow routingEnter the name of the node (process) whose outflow yojwish to redirect.

More help" y or nD

Which node do you want to change? (h/a) treatment

No such node as pond

Which node do you want to change? (h/a) tmentpond

FI.ow goes from treatmentpond to outfall

Which node do you wish to eliminate flow to' (h/a)©

Which node do you wish to add flow to? (h/a)

done

26

Page 29: IAI flfl **D - DTIC

Which node do you wish to add flow to? (h/a)O

Which node do you want to change' (h/a) @

Flows changed- model water first to get correct resultsWhat production level- 0 to 100? (h/a)(Previous level was 100) 10D

What constituent do you want to model?

The following are available: (h/a)

water

7NT

Do you want to use the existing water models? (h/a)G

Is there a water demand at selliterfr' i or n (h/a) n

Is there a water demand at sellitewash? y or n (h/a)

Is there a water demand at treatmenrpond? y or n (h/a)

Enter fraction of flow from treatmentpond to outfallQ

water from treatmentpond to sellitemfr = 22.00

water from sellitemfr to sellitewash = 1'. Ct0

water from sellitewash to treatmentpona &

water from treatmentpond to outfall = 88.00

InmIow to network at sellitemfr = 88.00

Do you want another run- y or n (h/a) G

Do you want to change flow connections? y or n (h/a)

What production level- 0 toU.L01 4h/a)(PreviouO level was 100) (EOO

What constituent do you want to model?

The following are available: (h/a)

water

TNT

DNT eDo you want to use the existing TNT models? (h/a)®

Is TNT generated at seilltemfr? y or n (h/a) GIs TNT generated at seilitewash? y or n (h/a) G

27

Page 30: IAI flfl **D - DTIC

7s -NT gc-erated at treatmentpond y or n (h/a) 0Is treatmentpond a treatment process where TNT is removed? (h/a)Q

Enter Fraction of Flow from treatmentpond to outfall 3

TNT from treatmentpond to sellitefr = 3.64Concentration = 165 624 mg/l

TNT from sellitemfr to sellitewash 3.64Concentration = 33. 124. mg/il

TNT from sellitewash to treatmentpond = 303 64Concentration = 2760 4 g/li

TNT from treptmentpond to outfall = 14 57Concantration = 165.624 mg/i

Do you want another run? y or n (h/a)®

Do .ou want to change fi i connections? y or n (h/a) G

.hat production level- 0 to 00? (h/a)(Previous level was 1001

Production level changed- model water first to get correct resultsWhat constituent do you want to model?

The following are available: (h/a)

water

TNT

DNT E

Do you want to use the existing water models? (h/a) n

Is there a water demand at sellitemfr? y or n (h/a) G

Is there a water demand at sellitewash? y or n (h/a)

Is there a water demand at treatmentpond' q or n (h/a, E

Enter fraction of flow from treatmentpond to outfall G

water from treatmentpond to seilitemfr = 13.00

water from sellitemfr to sellitewasn = 65.00

water from sellitewash to treatmentpond - 65.00

water from treatmentpond to outfall = 52.00

Inflow to network at seilitemfr = 52.00

Do you want another run? y or n (h/a)G

Do you want to change flow connections? y or n (h/a) S

28

Page 31: IAI flfl **D - DTIC

What oroduction level- 0 t 100) (h/a)

-Previous level was 50)

What constituent do you want to modal?

The $oilowing are available: (h/a)

wt er

TNT

DNT

Do 4ou want to use the existing TNT models' (h/a)G

is TNT generated at sellitemfr? y or n (h/a)

Is TNT generated at seilitewash? y or n (h/a)

Is TNT generated at treatmentpond' y or n (h/a)

Is treatmentpond a treatment process where TNT is removed? (h/a)G

Enter fraction of flow from treatmentpond to outfall G

TNT from treatmentpond to sellitemfr = 1.01Concentration = 78.0065 mg/l

TNT from sellitemfr to sellitewash = 1.01Concentration = 15.6013 mg/l

TNT from sellitewash to treatmentpond = 169.01Concentration = 2600 22 mg/l

TNT From treatmentpond to outfall = 4.06Concentration = 78.0065 mg/1

Do you want another run? y or n (h/a)®12

29

Page 32: IAI flfl **D - DTIC

NEXT RUN

Constituont water Production level. 100

water from sellitemfr to sellitewash = 105 O0

water Prom seilitewash to treatmentpond - 105 00

water From treatinentpond to outFall = 105 00

In4low to network at sellitemfr - 105.00.

NEXT RUN

Constituent TNT Production level: 100

TNT from sellitemfr to sellitewash = 0.00

Concentration - 0 mg/1I

TNT from sellitewash to treatmentpond - 300.00roncentration = 2857 14 mg/l

TNI from treatmentpond to outfall = 18.00

Concentrwtion = 171.429 mg/l.

NEXT RUN-

Constituent water Production level. 100

water from treatmentpond to sellitemfr = 22.00

rater from sellitemfr to sellitewash = 110.00

w ater from sellitewash to treatmentpond = 110.00

water Prom treatmentpond to outfall = B8 00

lniiow to network at sellitemfr = 88 00

NExT RUN

Constituent TNT Production level 100

TNT from trsatmentpond to sellitemr = 3 647-oncentr 4 tion - 165 624 mg/l

7NT from sellitemfr to Sellitewash - 3.64Con:ertration = 33 1248 mg/l

TNT from sllitewash to treatmentpond w 303.64

Concentration - 2760 4 mg/l

TNT from treatmentpond to outfall 1457Concentration a 165.624 mg/l.

NEXT RUN

Constituent water Production lavel: 50

30

Page 33: IAI flfl **D - DTIC

water from treatmentpond to eilltemfr = 13 00

water from sellitemfr to selitewas - 65 00

water from sellitewash to treatmentpond - 65 00

water from treatmontpond to outfall - 52.00

Inflow to network at sellitemfr 52.00

NEXT RUN.

Constituent: TNT Production level: 50

TNT from treatmentpond to eellitemfr - 1.01Concentration - 78 0065 mg/l

TNT from sellitomfr to sallitweesh = 1.01Concentration - 15. 6013 mg/l

TNT from sellitewash to treatmentpond - 169.01Concentration = 2600, 22 mg/I

TNT from treatmentpond to outfall 4.06Concentration = 7,0065 mg/l.

31

Page 34: IAI flfl **D - DTIC

APPENDIX B:PROGRAM LISTING

# incluae :stdio n.'-I

loub!e determ[lO0[lO0],double rhslO0,douole var100Lint detrmsz,int matrix[30[30], arysze;

struct a (char aaC20]i }

struct (char ndname[202struct a ndto[63;double watrin;node[30];

main({

Int nvar, i, j, varlbl[100],int ii, ix, temp, col, row, flagiint noden, ncnsts, fd;,nt tonodeC6]idouble flofrac[6], cancidouble qreq, rmval, qtrt;double flows[t00],;loat pl, ftemp,char tquery[4], query[5], ucnsttC2Ol, linebuf[81];char stemp[5]istruct (char a[203 > cnsts[2O];/* .

/4 Bildsys is the main routine. It calls routine MatTxinto build a connection matrix for the system.Routine chgmtrx allows the user to revise the connectior.matrix Routine findmdl uses a file of production levelvs water demand models to determine how much wateris needed at each node(plant process) which requires water.Bildsys uses the above informacion to build a systemof simultaneous linear equations describing flow throughthe system. Additional equatiz;,s are added for eachnode in the system with more than one outflow.

After the system is built, with the equations described bu thLdeterminant "determ" and right-side vector "rhs". it issolved in the routine "solvsys

32

Page 35: IAI flfl **D - DTIC

/* variablesnvar the number of simcitaneous equatonc */

1* originally equal to the number of *//* positive values in the connection matrix *//* arysze the length of the x("from') dimension in the */* connection matrix */I* matrix the connection matrix

determ the determinant of the system of simultaneous zuatiOisrhs the right side (constants) for the equationsvarlbl labels variables in the determinanc */

/. *************************************** ./

/* print out heading ./

prnt-f("\n\n\n Plant Model Program');printf("\n\n At all prompts which are followed by: (h/a) you can gev on-line").printf("\nhelp by responding with the word 'help'. \n\nAnswer yes no ").printf("questions with yes, no. y, or n \n\n\n\n");

/* initialize list of constituents

setbuf(stdout, NULL)istrcpy(cnsts[O3.a,"water");strcpy(cnsts 1].a."TNT");strcpy(cnsts[2].a,"DNT");ncnsts = 3.

/* (((C MM{{{{{{{ Initialize watrin >>)>}}}>}>>)'}>}

for (1 =0; i <-29; i++) nodeti3.watrin = 0.0;p1 = -1,

I* call input routine < Z'Z<( X<<

argsze = matrxin),

:7 ~~::>::'~x print and modify matrix 'Z(((.(<Z *

for (col l 1, col <= aryszej col++)

for (row - 1 row <- arysie; row++){ if(matrix[row]Ccol] !- 0)printf("\nFlow goes from %s to %s",nodelcoij.ndname,nodetrow].ndname);

33

Page 36: IAI flfl **D - DTIC

pr intf( "\n")

for (col =1, col C= arysze; col++)if tmatrix[aryszeal[colj != 0)printf("\nFlow goes from %s to sink",nodetcol].ndnamen

recycle printf("\n\nDo you want to change flow connections- u or n (h/a) ");

scanf("%s",query).

if (strcmp(query,"help") ==O : strcmp(query,"HELP") == 0{ help(6);

goto recycle;)

if (query[O] == 'y' !! ouery[O] -- 'Y) )< chgmtx();

printf("\nFlows changed- model water first to cot correct results");y

ten printf("\nWhat production level- 0 to 100? (h/a) ");if(pl > 0.0) printf("\n(Previous level was %-.Of) ", pl);scanf("%s", query);

if (strcmp(query,"help") -- 0 :: strcmp(query,"HELP") ==0C help(lO);

goto ten;

sscanfiquery"%f",&ftemp);

while (ftemp < 0.0 :: ftemp > 100.0){ printf("\nPlease keep production level between 0 and 100")printf("\n\nProduction level? ");

sc*rf("%f",&fterp);

/* if the production level is being changed, say so */

if (ftemp I- pl && pl !- -1.0)printf("\nProduction level changed- model water first to get correct results");p1 = ftemp;

= 99while (i '1 ncnsts) /* read in constituent wanted and

make sure it is available -*{

eleven printf("\nWhat constituent do you want to model-"),printf("\n\nThe following are available: (h/a) ";)

for (isO; i < ncnsts; i++)C printf("\n\ns ",cnststi2. a);

34

Page 37: IAI flfl **D - DTIC

scanWc'%s"-ucnstt);

If (strcmp(ucnstt.1'help") == 0 1:strcmp(ucnstt. 'HELP) =

{help(lI1)8goto eleven;

for (i0O; I < ncnsts; i4+){if (strcmp(cnstsliJ.a~ucnstt) == 0) break;

iP(i>= ncnsts) printf("\n~s not available" ucnstt';

Allow the user to uce the existing process models without

modi iication.

twelve. printf("\nDo you want to use the existing %s model-iT (h/a) ' ucnsttscanf("%s",tquerq);if (tquerytO2 -- 'V') tqueryC0) -y'

if (strcmp(tquery, "HELP") - 0 strcmp(tquery. "help") -- C1Chelp(12);goto twelve;

1* if modeling water, reset the stored values of war.r flows to zero *

if(strcmp(ucnstt, "water") ==0) {for (1=0; i <= 29; 1++).:detil.watrin = 00;t

All the input ard bookkeeping is done. N~w o~iildthe system of simultaneous equation.

for (i=l, iK (arysxe~l); I44)Cfor(j=1; jZsarysze; j++){

ifcmatrixCi3tjJ 1-0) matrixxi3tjJ - *-nvar;

4array now read into "matrix" 4

/4now generate determinant for system of equations 4

/* put "I" in dtterm f',r inflows */* and "-I" in for outflows cfor (i-0, 1 <:99; i+4-)

35

Page 38: IAI flfl **D - DTIC

Kfor ;j=O, j 99; j++) d atormC iI IjJI = 0, 0,rhs~i] = 0, 0;

;or i1, i-, arysici 1++) Cfor .jI., jK= arys~ei j++) <

if( matrix CilCj] 1 0)determrilc(matrixtijril)3 -10,

for jl, j<= aryszei j++

I f( matrix[ (aT yszo+l) 31j3 0determtj)E(matrixE (arysze+l) 1j]J) I =-10

Jecrmsz =arysze;

/* add equations for inflows to sitstain-= one equation for each node with a production-level vs demnr functier*<a for water. */

call routine "findmdl" to got information on these nodes ~pa qroq is the flow rate demanded at the node *

add a new row in tne determinant for each inflow *for~i=l, il"arysze, i+-)

if (strcmp(ucnstt."water") -- u)

q13 querujC0l - ''printf("%nIs there a water demand at %S? yj or n (h/a) ",nod*[i] ndname).scanf('%s".querj);

if (strcnmp(querup "help"l) -- 0 strcmp(querj, HELP")(help(l3),goto q13;

if(query[0) == 'Y' :!queryjC03 'y'

/~build new equation if there is inflow '

I f'tquery[f0)1 'yj'printf("\nModal Water Use at %s\n",nod@[i1.ndname),

I. call findmdl with a 1 to allow changeS,with a zero for no change;

if(tquaryCO03I 'y')qreq - findmdl(nodeli2.ndniame~ucnsttpl,l)ielse qreqa findidl(nodaCi2.ndname~ucnsttp.0),++d etrms z;++nvar;varlbllnvar3 - 1;

for ( j*1i j<-aruoze, J++4

36

Page 39: IAI flfl **D - DTIC

iP( matrx[i][j] != 0determ~detrmsz][(matrix[i][j]) = 1.,

determ[detrmsz][nvar] = I+rhs[detrmsz] = qreq,

,,' find the first var. in the --de's column */Iiil

while ( matrix~ii](il - 0 ) ii++;for < ix=l, ix<=detrmsz; ii+ )

{ iF( determCixx] (metrixjii]i) == -1.0 ) determlixl[nvar3 = l v; },)

I /* end of water inflow routine.Now modify equations for nodes at which pollutantsare generated. Change equations from"Sum of inflows = Sum of outflows" to"Sum of inflows + pollutant generated == sum of outfld*5

:

This is done by putting -1 * pollut. generated on rightside of equation. *'

else{

q19 query[0] = 'printf("\nls %s generated at %s? y or n (h/a) ,ucnsttnodeLi] ndname),scanf "%s",query);

if(strcmp(query,"help")==O :: strcmp(query,"HELP") - 0){ help(19);goto q19;

}

if~query[0 = Y': querytO) = y

if (tquery[O] != 'y')qreq - findmdl(nodeCi].ndnameucnsttpl,1);else qreq f findmdl(node~i3ndname,ucnstt,ol,0)irhss] -1. 0 * qreq;

Modify those equacions for nooes which are waste treatment orocesses.By multiplying the "-I" values in the equation by the fractionalremoval by the treatment process, the equation is changed f-em"inflow - outflow" to "inflow * removal -- outiiow"This is done only for pollutants, not for water. */

else

if the user replied to the previous ouestiznwith a 'x' assume this is not atreatment process */

if (query[O) ' 'x' && queru[0] '= 'X')

37

Page 40: IAI flfl **D - DTIC

q-4 printf("\nts %s a treatment process wheri %s is remvedi" (h/a)node[1. ndname. ucnstt)iscavP("%%" queru),

if (strcmp~query,"help")=-O ;I strcmpiquery,"HELP") =- 0{ helpk24);goto q24;

if quer [03 == 'Y' :: queryC0] ==' ' )(

I f tquery[O3 '= 'y,)printf("\nModel Treatment Erficiency at %s",nodeli5 ndnaelg),

/* make sure water has been modeled ,irst and thr~e

is a water inflow to this treatment noJ$ kno'[ */

if (nodeti],watiin - 0.0){ printf("\nWarning- Water flow to process %s is z*ro-nodeli].ndname);

printf("\nWere water flows modeled first?-");}

* f changes in model are allowed, call trtmdl with a 1if not , call it with a zero */

i;(tquery[O) != 'y')rmval = trtmdl(nodeCij.ndname,ucnstt,nodei].watrzn, l),else rmval trtmdl(nodelil ndname,ucnstt,nodeti].watrin,0O,-

rmval = 1.0 - (rmval / 100.0);for (col=l, col -= nvar, col++)

{

if (determtil]col3 -0.0 ) determti][col]determti][coll * rmval;

}

/*add equations for each node with divided outflows

telling how much flow goes out each path.noden is the node number which has divided Outflows"tonode" is a matrix of the nodes flow goes to"flofrac is a matrix of the fraction of the outflow to the node

/

for(col = 1, col - arVszeoi col4+)flag = 0,

for (row -Io row <- arijsie~l; row++){ if(matrix[row][coll 1- 0)

i if (flag - 0)( noden - col,

tonodetflag] - iow,

38

Page 41: IAI flfl **D - DTIC

q17 if(r ,w =- arwszel)printf('Th.Enter fraction of flow from to outfallnode (cal) ndname),

=I s@printf("\nEnter fraction of flow From -;.s to *Is (h/a)nodeC coil. ndname, nodeCr ow). nd name Iiscanf('7.s', stemp),

if(strcmp(stemp, 'help") == 3 : strcmpsteep, 'HELP" )==0)(help(li,,goto q0;

--hile (flofractflag] C 0,0 :;flofrac[rlaql 1" Ir){printf("\nPlease keep it between 0 Ind 1.");printf(" Tryg again. 'scanrf'%f", flofrac+fla.);

++lag,

/* go through equation-adding routine for each node with divideu outflow~4

if flag1)

for (i=l; i<=flag-1; i+4-,

thi iflo pat (from i noden 0o ) & C i = tnodC

de~mdetrmszdetmz] (1t0iitii)Cnoden )) =(1 forci

fooiL ~ rmsz~l ii+) sz.l; i+

{print ot( eerian\ordeu pross

for (j1l; j<-detrmszi j'.-)fprintf('%-7.3f". determ~iJCEj2);

printf('ViO.3f",rhsCi)

39

Page 42: IAI flfl **D - DTIC

send determinant to routine soiveys for solution

print out the results'do this both to the standard Iterminal) output a:to a file called RESULTS.

/4 open or create the results #ale a

;d=opsnC"RESULTS" lb,if 'fi * 0 ) fd = creat'2'RESULTS",0644),Iseek(fd,OL,2), /* write the new output at the end of thet file

If an overwrite is preferred, change thisstatzment to lseek(fd,OL,C,) -

strcpy(linebuf' " NEXT RUN.");iinebufEOj = '\n', linebuftl) = '\n', linebuftlll = \'write(fd,iinebuf,12);for(i0O; i,'=7

9. i++) linebufti) =1\;

sprintf(linebuf,"\nConstituent: %.s Production level. 72.Of', ucnStt Dl)'write(fd,linebuf'Sl);

/4 print out pipeflows, between nodes 4

nvar =0,for (rowl1, row K- arysie. row++){for (collI, col K= arysrei col*+){if (matrii~rowflcoll =0

{nvar = nvar *

printf("\n\n%s from %~s to %s = %.7 2f",ucnstt,nodeCcolI.ndname,nodefrowl.ndname,vrmtri~r -UjLCoIJJ),

for (i=0, i <=79; i++) linebuflij - \=sprintf(linebuf. "\n\n~s from %.s to %.s = %7 2f",ucnstt,nodetcoll ndname,node~row).ndname,var~matrix~revfL-0olJLwrite(fd, linebuf,Bl);

1* Save the water inflows to nodes -W/if (strrmp(ucnstt. "winter" )=- 0){nodetrowjwatrin = node~row).watrin + vartmatrixt'ae~colJJ'flowscmatrix~row]tcol I = var~matrirlrow)Ccoll)

Calculate and print out the concentration of the consti'uentThe array 'flows" stores the water flow rate in ca' h pipiOThe "else" routine below calculates concentration as fle'd(cubic meters/time) divided by pollutant flow (kg/cime( times

40

Page 43: IAI flfl **D - DTIC

a conversion factor of l0uju to make mg/I.

else

if (flo'smatrixtrow3tcol))==O) cone = 0;else cone ( vartmatrixtrowjlcoll) / flows~rmatrixtrow)EcolJ)

*1000. 0; /4 convert kg/cubic meter to rng/l 4

printf("\nConcentration = %g mg/l",co-.c);for (i0O; i <=79; i4-4) linebuf~i] =\'

sprintf(linebuf."\nr-oncentration X/g m~g/l\n",conc),write(fd. linebuf,8l);

I

I

/* print out flows to outfall 4

for (col = 1, col <- argsze; col4+)C f(matrixfarysze~l3tccll 0

Cnvar = nvar + 1,printf("\n\n~s from X.s to outfall % 7.2f",ucnstt, nodetcoil. ndname~varimatrixCargsze+llrcol)2);

for (i0O; iZ=79; i4+) linebufti) = \isprintf(linebuf. "\n\n%s from %s to outfall -*72"ucnstt,node~coil. ndnane.vartmatrixrarusze+Iltcoli);write(fd, Iinebuf,B1);

if (strcmp(ucnstt. 'water" 01=flowstmatrixtarysze+l)Eco123 varEmatrix~arysze+±3tco1 2);

Calculate and print out the concentration of the constitUent.

else

if (flowsrmatrixtarysze+3col)W=O) cone = 0;else cone - ( varfmatriztarysze+lltcoiJ/flowe~matrixtarsz'-I3EcolJ3)

* 1000.0; /4 convert kg/cubic muter to erg/1 *printfC"\nConcentration - %~g mg/l".conc).for (i=0; i (-79; i++) linebufti3 \'sprintf(linebuf.'\nConcentration =%9 mrg/i'. cone)write(Pd. linebuf,91);

41

Page 44: IAI flfl **D - DTIC

/* print ins~lows to sys~tem where there is a flow requirentpr intf ("\n".

foar 'i = nvar + 1, i <= detrmsz; i-'-)

printf("\nlnflow to netwGrk at %s = Tf-'nodetvarlblti)] ndnamle,varri));

Por(col -1. col(= 7 9; col++) lmnebuf~col) 'N'sprintf(linebuf. '\n\nlnflow to networkc at /.s % 77 .-f"nodeCvarlbl~i22ndname,,artiJ),write(fd, linebuf,81Vi

else

varliJ l var~iLprintf("\nExcess flow at %s - 7..2f\n".node~varlblCi3J.ndname,varCjJ);

for(col = 1; col<-79; coi++) linebufCcojj "%'sprintf(linebufr"\n\nExcess flow at %.s 72"node~varlblti)).ndna.@,var~i3);write(fl, linebuf,81)i

close( ed),

Use the "infinitelcy-abusable goto" to allow reroutingof flows and another run of the program.

.. .. ... . . .. .. . .. . . . . .... ...

q1S printf("\n\nDo yjou want another run? y or n (h/a) )

if (strcamp(query, "help") -0 strcmp(qurj, HELP") =0)(help(18)igoto q18;

10 %queryCO) -- '': outrcjE03 y=c') goto recclei

/ * end of bildsys e

42

Page 45: IAI flfl **D - DTIC

#include td.h>

extern struct a <char aa[2O3);extern struct (char ndnameC2O2;

struct a ndtoC63idouble watrin;Inode[3O2;

extern int matrmixC3O3r-.,), aryszsi

chqmtxO)

;unction chgmtx to make changes in the flow conoectionmatrix, allowing the correction of errors or triifalternate recycling schemes.

The important variables are external, as defined elsewhere

char chgnode[2O), elimnodeE2O2, addnodeEL.O)0;int i, chgno,

start printf("\n\nWhich node do you warit to change' (h/a) "

scanf('Ys".chgnode),iflchgnodetO) -= '0') return;

mf~strcmp~chgnode, help') =- 0 ::strcmp(chgnodo. NELP') 0)

help(7).goto start,

/* iind the number of the node to 'e changed *

;or (i1l, i ,=aryjsze, i++)i f(strcmp~chgnode~nodera2.ndnamr.) -- 0

(chgnobreak;

if (i ax-ysze) (printf('\nNo such node as %s".hgnooe).goto start;

print out where flow oovs from chgnode

eight for (xl, i '~arysze; i++)< ifimatrxxti3[chqno! 0)

printf("\nFlow got* from Xs t-- %s",chgnod*,nodvC13 ndname),

I f~matrix~arysze+lJCchqno) 1 0)

43

Page 46: IAI flfl **D - DTIC

printf."\nFlow goes from Vs to outfall". chgnade);

while(elmnodeCO) 1= '')

printf("\ri\nWhich node do unu wish to eliminate flow to-, (h/a) "

scanf;".S",elmnode)p

if~strcmp(elmnode, "help") -- 0 ::strcmp(elmnode, "HELP") -0)

help (S),goto eight;

f(strcmp'eimnode'"outfall") == 0) {matrix~arysze~liCc,gnal - 0.I = 0; /* break out of loopx'printf("\ndlne");

else

for (i=li i <= arqjszei i+4){if (strcmp(elmrnod*,nodvi. ndnamv) 0)

Cmatrixdi31chgnoj 0;printf(\ndone")ibreak;

i i aryjsze && eimnode[O] I '0')printf("\nFlow does not g0 to '.s'" cmnode)i

while(addnodeC03 1 '0')

nine printf("\n\nWhich node do yjou wish to add iiow to" (h/,' '*1

sc an f ( ' s ad d node);

if(strcmp(addnode. 'help") == 0 ::strcmp(addnode "HELP") =

goto nine;

I Pstrcmp(addnode."outfall") ==O) {matrixrartyszs~l3(chgno3I - 0,prxntf("*\ndsnv"),

else

for (i-1, 1 <- artjsze, i++)if (strcmp(addnodv~nodeCj2. ndnamv) 0)

< m,*trixi3)chanoi 1;printf("\ndone")ibreaki;

44

Page 47: IAI flfl **D - DTIC

ii(i *. arysie && addnodo[Ol I= '0'printf("\nNo such node ag %s",addnode),

J

elmnode[0] = 'x', addnode[03 = x',goto start;

*include <'stdio. h:>.;

/* ... 4++.+.+.4.+.+.4.+.-...+.+.+..+.. .-... 4+4++.+.4.*.4.*. + .. .. .. +4- 4

routine findmdl to look in a fiie of existing processmodels and read it if it exists. Also allows writingover existing models.

Each model in the file has 5 lines: the first is a title iin-with an x in the first %pacei and 4 lines of altornatingx and y points. % represents the production love), from0 to 100. Y represents the water demanded or mass of wastechemical produced.

Each line must have 80 char. not including the newli .)

tirdmdl(wlabel,wmdlpdlvl.chngs)char wlabelC203,wmdlC20];float prdlvl,int chngs;(

char linebuf[81]. numbufC93, fletest;char testC3], labeloC20, queryC O];int fd, i, j, nread, line, ihi, ilow;

float iC202, yE20).double qn,

I* initialize x and y *I

Por(i=O i <= 19i i+ ) {xti] 00 YE[] 0.0;>

Fletest 'n',

'* +ietest keeps track of what kioA.- writing is to be done at eno-f prog'r' - replace old model"n' a write new model in existir-9 File'o' = use existing model, no overwrite

c' - create new Piie, writ* in fi.dei

The variable "chngs" ij rqual to I Cchans in the model are to be aiaowed aniis 0 if no changes allowed

45

45

Page 48: IAI flfl **D - DTIC

{printf("\nNo file of models found; file creat.,d\n",,fd =creat(ugmdlI0444),fletest -''

I* f Pile of modols exists, print out the names of the models *

else i 1s~eexkd,OL,O),

while((nread - read(fd,.inebuF,81)) '-0)

if (linebvf[Ol==x)

for(i=Oi i <- 19. 1++)

labelti3 - linebufliil.if(strcmp(label~wlabel)- 0)

f~atest - o0/* desired modol is now found

read it *

f7T (line - 0, line <- 3, line-+)

r*&d(fd, liriebuf 91),

for (i = 0, i <-4, i+*)

(for(j - 0; j <= 7. j++)

(numbuftj) linebuftl16*i) ij

numbufLAi2 -=\'sscanf(numbuf,X*%f",x+(ltrpe*5 + xl)ifor~j-0; j <a 7, j-)

(numbuftj) = linebuft(16*i) + j + )

numbuf&Pil = \'sscerf(numbuf,"%Bf"ty+(lTne*5 + 0)C,

}T4k

/* teot if requested model not in file *if (flotest I-'G')

(printfiU\nNo model called %~20% in file', waabol);goto build;

*if no changes are to be made go to end of program *

46

Page 49: IAI flfl **D - DTIC

if tchngs ==0 S(& fletest -- 'o') goto qui..

/* plot out the model; if .u:er wants to change it,or if no model was on the file, build a new one *

graph( x, y.20,wmdl );printft2'\n PRODUCTION LEVEL"),printf."\nDo you want to change this model-, y or n")scanf( "%s", test);if(test[Ol 1 'Y' && testro) 1 'y') goto QuitoFletest = r

/* builo new model 4

build test[03 =Y'

while (testC0) = 'y')

for (i=O, i =19i i++) {ori] = 0.0; g~i) - 0 0; label[%]='

printf("\n\n BUILD A NEW MODEL for %s\n",wlabel);strcpylabel~wlabel)iif(strcmp(wmdl."water") -0)printf("\nlnput water used as a function of production level\n"),else printf('\nlnput %s generated as a function of production level\n",

wind 1)printf('\nFor a max. of 20 points, put in prod, level, 1printf("up to 100. \nnot including zero, and %s uszd/grnerated" windI)

xf(strcmp(wmdl. "water") - Ci)

printf("\n\nUse units of cubic meters/dayj or cubic meters/batch r'or water\n"),else printf("\n\nUse units of kq/day or kg/batch for %s\n".windl.printf("(for help with units tyoe 'help')\n")o

q15 for(i=0; i<=19; i++)< printf("\nP'od. leveit%d)? (h/a) ",i~)

scanf("YAs",query);

if(strcmp(queru. "help') =- 0 ::strcinp(query, 'HELP") ==0'

Chelp(15),goto ql5i

sscanf(qurj, "%f". iz),

if(SEf3 < 0.0) <printf('\nPlease, no ncgotive or zero values"),goto build;

printf("\n~s? ",windl);scanf("%f", y+i)iif (xi) 3 100) break; /* stop at 100% capacityj*

47

Page 50: IAI flfl **D - DTIC

qrapnh x,y , wimdl),printf("\n PRODUCTION LEVEL");printf("\nDo you want to change this model' y or n "),canf("%s",test),

iF(test[Ol == 'Y') test[O) = 'y',

quit: if fletest ': )/4 position file for writing 4//* if replacing old model, move back up 5 lines(405 char) */

{ if (fletest == 'r') Iseek<fd, -405L. 1);

/* if writing new model in file, move to end of file 5/if (Fletest == 'n jlseek(fd, OL, 2).

/* if creating new file, rewind j/if (fletest =. 'c') lseek(fd, OL, 0);

/* write out the model, title line and then 4 data lines. */

lineouf[O] f 'x';for (i = O; i 'C i9 i++1 linebufti+l] labelli];for ki = 21. i <- 79; i++) linebufi] = 'linebuft80) = '\n';

write(fd, linebui, 81);

for (2ine = 3; !ine <= 3; line++)for (%=O; i ',= 4i i +)

( sprintf(numbuf,"%8, Ie",x[(line*5) + i]);for (j=O; j <- 7; jAt)linebufti*l6 + j3 = numbuf[j);

sprintf(numouf;"%8le",yC(line*5) + i3);for (j-

0; j <= 7; j+ )

linebufE(i*16) +j +zJ = numbuf[j];

linebuft8O] = \n'write(fd, linebuf,81)i

p /* end of write routine */1 ose fd ),

/* *####*# ##### interpolate value of water demand ######**#'#*# /

ilow = 0, ihi = 1,

ifi prdlvl , x[O3) qn = y[O); /* Assume thlat if x less thanmin. in graph, y stiye at yinDon't a-sume water use g9es tozero ac zero produkcion . /

48

Page 51: IAI flfl **D - DTIC

whiie(prdivl a~ihi) && ich C20

if(xhi >- 20) /* D-r't go off the upper end or the graph ~ipr~ntf("n.f/ production level too high at %s; extend ,nodt- 1,prdlvl. wlabel)igoto build;

qn = yCilowl +(yijChil - ytilow)) * ((prdlvl - x~ilowl)

return qn),

/* &&& &&&&& &&4

Routine Graph to maxe a graph at- a twso-dimensionai array,such as a process model-

gT-aph(x, y, npts. yiabl)gloat x[201, y[2.OLint npts,char ylabl[203;

float ymax, graphyI:533, temp, xmax, qiint 1, iow, ihi, j,

/4 ~*** first find the max. x and y vilu1w ** *

xmax = 0. 0ymaA = 0 0,for (i=0, i C. npts-l, i++)

{if ( ytil " ymam) mjmax i3if kri X x max) %max = X2,

/* generate 50 points for the graph byj interpolation 4ilow - 0, ihi - 1;

49

Page 52: IAI flfl **D - DTIC

for (q- xmax/50.0, q <= xmax; q =q+ (xmax/50.0)

j= q * (50.0 / xmax);if q xCO3) graphijCj3 = LCOi /* Assume that ii x 1ls than,

min. in graph, u stis at y,.inDon't agsume water Use goes tozero ac zero production. *

else

while(q) xCihil)i ++ihj,

++j low.

graphyij3 m yCilow3 +(ylih13 - yfilowJ) *((q - iilowl)(xtihil - x~ilow3))i

/4 now print the graph 4

=h strlen(tjlabl);

for(i=20i i > 0; i--)

If(i <= ihi) printfC'\n~c,ilablihi-i3); /* write th.- y label 4else piintf("\n "');if( i %/ 4 =- 0) < temp = (ymax / 20) * e

else printfC' ")

forj=l; j<=50i j++)Cif (graphyEtj] < (i+l)*(yjmax/20. 0) && graphyCj3 ~= i *(umax/20. O'pl-intf('o"); /* print if it is a point */ -

else printfC ("); /4 print this if it isn't a point *-

/* print x axis and label 4

for (i-1; i<-5; i++)printf( -----------

printf('\nfor (i-1; i<-.5; i++) (j - xmx *(i/5.O);

raturni

50

Page 53: IAI flfl **D - DTIC

i include -stdzo h>,heip~n)

inc n.

/* help routine for the ammo plant model *

nt test l, oldn,char queryC33.

oldn n,

W IIIe )(

printf;"\nDo you want general help or"),przntf(" help specific to the question you are on- "),

printf("\nEnter 1 or 2: "),prlntf("'\n\n 1= 3eneral\n 2-specific\n"3,scanf("%d",&test),

if (test ==1)

{

printf'"\n\nAmmunitio" Plant Process Model\n");printf("\n This is a program to model the flow of water and water-borne"),printf(" pollutants \nThe following general instructions applu "),printf("\n\nl. All process (node) names should contain 20 o, fewer"),printf(" characters of\nany type. but without blanks. ")iprintf(" Be careful with spelling!")oprmntf("'\n\n2. Yes or no questions can be answered with yes, no, y. or n ").printf("\n\n3. Whenever a prompt repeats itself you can t*ll it to move on"),printf("\nby typing '0' (zero).");printf("\nNn4 You must always model water flows before pollutant -lows ")printfC'because treatment\nmodels use flow rate as a parameter Any time '

printf(,"you change the production\nlevel or re-route flows you should model"),printf(" water flows again.\n\n")iprintf("5. At any prompt wnere '(h/a)' appears, you c4n answer 'Ilp' and get"),printf(" it ")pprintf("\n\nMore details are available in the user manual ind detazils arc"Bprintf(" available\nhere for specific prompts. ");printf("\n\nHit '1' to continue\n");

scanfC"%s".query)i

printf("Choose one of the following: ");

printf("\n\n")iprintf("\n I to you want input to come from a file?");printf("\n 2 What is the name of the file?");printf("\n 3 What is the name of the next nnde"")iprintf("\n 4 4hat node does flow go to'?");printf("\n 5 Enter node wnich goes to outfall");printf("\n 6 Do you want to change flow connections ");printf("\n 7 Which node do you want to change");printfO"\n 8 Which node do you wish to eliminate flow to?"),

51

Page 54: IAI flfl **D - DTIC

printf('\n 9 Which node do you wish to add flow to'"),printf("\n 10 What production level?");printf("\n 11 What constituent do you want to model"),printf("\n 12 Do you want t. use the existing models-"),printf("\n 13 Is there a warer demand at this node?");printf"\n 15 for help with units. "),printf("\n 17 Enter fraction of flow from a to b"),printf("\n 18 Do you want a~rother run?");printf4"\n 19 Is the constituent generated hpre?"),printf("\n 24 Is this a treatment process where constitucnt is"),printfi" removed?"),printf("\n 98 for intrepretation of results"),printf'"\n 99 to quit HELP and return to program"),

prntf("\n\nWhich one do you want? ");printf("(you entered 'help' from no. %d) ",old.,,scanft"%d",n);

if tn== 99) return;

else if (n==l){ printf("\nHelp for questior. 1: \n")iprintf("Do you want process configuration input to come from a ile")printf("\n\nlf you have a file with all the node namxs, where flow")printf("\ngoes to for each one, and the names of nodes i --lch drain\n"),printf("to the outfall. yi can use it instead of answeringn':nprintf("questions 3 through 5. This is verg useful when running a"),printf("\nmodel several times. If you answer yes, the next question"),printf("\nwill ask you the name of the input file."),

else if (n==2)< printf("\nhelp for question 2: What is the name of the file",printf("\n\nlf you told the program that the process coxigiuration");printf("\nwas in a File, uc-u now have to teli it cne naqe of th*"),printf(" file. \nIf the file is not in uour directory. be sure to"),printf("\ninclude the path to the file."),

else if (n==3){ printf("\n help for question 3: What is the name of the next nnde?");printf("\n\nYou now have to enter the names of all the nodes"),printf("(processes)\nin your model, one at a time. Each name can"),printf("\nhave up to 19 cnaracters, with no blanks. The program"),printf("\nis presently dimensioned for up to 30 nodes "',printf("\nAfter all nodes are entered, answer this quescYfn with"),printf("\na '0' (zero).");

else if (n--4){ printf("\nHelp for question 4: What node does flow go to&")printf("\n\nFor the node that you just entered enter the names").printf("\nof the nodes which flow goes to. You can enter from ),

52

Page 55: IAI flfl **D - DTIC

printf(" to 5\nnodenames, be sure to spell them correctly When"),printf("\nthere are no more to enter, enter a '0' izero,- After jou").printf("\nhave entered all the nodes and where flow goes for e-ch"),printf("\n one, the program will tell you where flow goes from each").printf("one\nso you can chock it."),printf("\nIf it isn't right, you will be allowed to cha~rge flow"),printfC"\nconnections at a later prompt.");printf("\nDon't worry about flows to the outfall (or othorwise out").printf("\nof the the sustam); you will be allowed to tell the');printf("\nprogram which nodes go to the outfall later

else if (n-=5){ printf("\nHelp for question 5: Enter node which goes to sink",

printf("\n\nType in the name of any node (process) which dra,nE to").printf("\nthe outfall or otherwise leaves the system. -This promot")printf("\nre0eats, so you can have multiple outfalls. Enter '0'");printf(" (zero)\nwhen there are no more. ')i

else if (n-=6){ printf("\nHelp for question 6: Do you want to cnange Flo, ")

printf("connections?");printf("\n\nIf you want to change where flow goes to froir, any of'),printf("\nthe nodes, answer yes. You wili enter a routine which");printf("\nallows you to do this. ");

else if (n-7)

printf("\nHelp for question 7: Which node do you want to change'"),printf('\n\nYou are now in the routine to change flow fO.tino. "),printf('\nEnter the name of the node (process) whose o~ptfIow you").printf("\nwish to redirect.");

}

else if (n--B){

printf("\nHelp for quescion B. Which node oo you wish to elimtnate"),printf(" flow to?");printf("\n\nYou have just been told wnich nodes, It ar, flow gies").printf("\nto from the one you want to change. If you Want co stop").printf("\nflow from going to any of these, type in tho name of'),printf("\nthat node. Enter '0' (zero) wher, you don't want to"),printf("\nchange any more. ")iprintf("\nTo elimate flow to the outfall eter the worS 'outfa!l

else if (n-9)

printf("\nHelp for ouestbon 9: Which node do you wish to add"),printf(" flow to?\n\n")iprintf("If you want to add a flow path from this node to some"),printf("\nother, enter the name of that node To add Iow to"),printf("\n tne outfall, enter the word 'outfall'. Enter '0"'),printf("\n(zero) when you don't want to add any more

53

Page 56: IAI flfl **D - DTIC

else if (n-1O)( printf("\nHelp for question 10 What prod',ction ievel-,

printf('\n\nEnte- the production level you want to model This"),prxntf("\nsnould be expressed as a percent of full production,"),printf("\nso should be betweeii 0 and 100. "',

)

else if (n==Il){ printf("\nHelp for question 11. What constituenc do you want"),printf(" to model*?\n\n"),printf("The program will print out a list of the oollutart"),printf("\nconstituents ;or which models exist, ano-you should").printf("\V,choose one of them. For the first run, and after any").printf("\ncnange in flow routing or production level, jou must ),printf("\nmodel water flows first, because the creatmppt models"),printf("\nneed to know the water flow rats. ")i

}

else if (n- 12){ printf("\nHelp for Quescion 12 Do you want to use exiting "1,printfC(models?")printf("\n\nlf you answer yes. you will not be allowed to look").printf("\nat and modify any of the process modei . If this i:");printf("\nnot your first time through the program and OL, are sure")printf("\nthat you are satisfied with the models, this-wil save"),printf("\nsome time. Otherwise, answer no and look at. modiry,")iprintf("\nand build models as needed."),

else i; in==13){ printf("\nHelp ;or ouestion 13. Is there a water demand-printf("\n\nIf this node is one where water is used and where").printf("\na water demand vs. production lz'iel ',ode) exists (or");printf("\nshould exist), answer yes. ").

else if (n=l5){

printf("\nHelp for units \n\n"),printf("To get correct concentration calcuiations, ali plows must"),printf("\nbe in cubic meters/time and all pollutant ggheratiot\n".printf("rates must be in kilogram/time. The time value may be any"),printf("Nnconsistenc unit, such as day, or by batch for atch',n").printf("processes. The concentration will be averaged over th.").printf("\ntime period chvsero.\n\nSome conversion factors \n\n ;.

printf("Cubic feet x 0283 equal, cubic meters."),printf("\nLiters x .001 equal; cubic maters ");printf("\nallons x 00370 equals cubic meters "),printf("\nPounds x .454 equals kilograms.");print#("\nCubic feet/sec x 2447 equals cubic mterstdg.. ,,prmntP("\nMilIion gal/day x 3786 equals cuoic meoers/d ",printf("\ncubic lightyOars/millisecond x 1.02ex-40 e quIS m3/day",.

54

Page 57: IAI flfl **D - DTIC

else if (n--17)( printf("\nHelp for question 17, Enter fraction zi flow"),printf("\nYou must tell the program what fraction of thc' outflow"),printf("\nfrom the first node goes to the second. Enitr a m.moer'")printf("\nbetween zero and one. ")i

}

else if (n==8){ printf("\nHelp for question 18, Do you want another rvn"),

printf("\nlf you want to run the program again, type 'i' ")printf("\nYou will be allowed to change flow rouving, Model"),printf("\nanother constituent, change the production )=vel,");printf("\nand all kinds of fun stuff. "1,

}

else if (n==19){ printf("\nHelp for quescion 19, Is constituent generated here");printf("\nlf this is a process at which the pollutant enters the"),printf("\nwastewater stream, and at which there is a pollutant"),orintf("\ngeneration vs. production level model, answer yes");printf("\nAnswering with a 'x' tells the program that there is"),printf("\nneither a pollutant generation ncr a tieatmrnc model");printf("\nfor this node. ")i

else if (n--24)< printf("\nHelp for question 24, Is this a process where3),

printf("\n the the constituent is removed");printf("\nIf this is a process where the bollutant is f movzd");printf("\nfrom the wastewater stream, sucn--as a treatment process"),printf("\nand where treatment efficiency vs. flow rate-is to be"),printf("\nmodeled, answer yes.");

}

else if (n-98){

printf("\nHelp fot interpretation of resuivs. \n\n"),printf("There are four different kinds of outout lines! "),printf("\n\n'<constituent> from <node> to <node> - _-),printf("\n\nThis line tells you the flow of the const.cucnt"),printf("\n(or water) in the pipe between the two nodes Flow"),printf("\nrates are the same as used in the waver use/pollutant"),printf("\ngeneration graphs."),printf("\n\n'Concentration = "n_printf("\nThis line tells you the concentration of the constituent",printf("\nin the pipe wnen modeling pollutant flows ")

printf("\n\n'Inflow to network at <node> z_ ,printf("\nThis line appears when modeling water flows and tells ",printP('\nyou the rate at which water enters the syste from"),printf("\nwhatever the source is (well, intake from river.")iprintf("\ntreatment plant, etc. ).");printf("\n\n'Excess flow at <node> = .__ );printf("\nThis line appears when there is more water flowing iito"),printf("\nthe node from upstream nodes than is needed, as"),printf("\ndetermined by the water demand graph.ltprintf("\nThis excess water leaves the system at this point and");

55

Page 58: IAI flfl **D - DTIC

printf("\ncould be considered as flow to t;e outfall. "j,

printf("\nThe presence of excess flow mea:is that you ate routing ).printf("\ntoo much water into the node. ");

else< printf("\nSorry, you picked an option which isn't available "),

print9("\n\nMore help? q or nscanf("%s",query),if (query[O] !- 'Y' && queruCO] = 'y') return,

#include 'stdio. hZ'.

extern int matrix30][30i;

'* IIXxIEXXXXXXXXXZxXXXCXXXXZZ5XIX11,ZZZ~XXWx

subroutine matrxin to build the connection matrix Read innode labels, nodes being plant p'ocesses or treatmentprocesses. Nodes representing sources to the system (withdrawalsfrom the river etc.) are added automatically.

variables:

ndname- an array of the node names. The node number is assigned

as the position in the array.

ndto- an array of the node numbers vs. the node numbers FlOW goesto.

mtxsze- the number of columns in the matrix. There is one morerow than columns to accomodate the sink.

Modified to allow input from a file.

struct a ( char aar20; )

struct i char ndnameCO3;

struct a ndtoCb];double watrin;

) noder303;

56

Page 59: IAI flfl **D - DTIC

ratrxin() <

int z. i. iy, j, ndno, rtxszo;char tosinkC203, testE43;char filennC2Oj;FILE *fp, *fopenU;

one. printf("\nDo you want process configuration input )

printf("to corne from a file'7 (h/a) ")iscanf("%s'1test),

if itest[O) WH 1: testC03 <~ help(l)jgoto one;

if (test[03 IV' && testCO3 != 'y')

pi-intf("\nProcess confiouration entry routine: put in the name");printf("\naid where flow goes to for each node. \n\n");

for (z = 1; z <=30; z4'){three: printf("\n~hat is the name of the next node?");printf(" Hit zero for no more (h/a) )

scanf(%s",nodvz~j. ndname,;printf('Vs',nodCz3. ndnam*);if (nodoCz3.ndnam@EtO -- '0') break;if (strcmp~nod.Cz3.ndnameo "help") ==0strcmp([email protected]@,"HELP") --=0

(help(3);g~to three;

for (i - 1; i <- 5; i++)

(four: printf('\nWhat node does flow go to from %s? (h/aT.node[23. ndname)iscanf("%s".nodelz3.ndto~i5.aa);printf("%s",. od*Cz3. ndtal13. aa)iif (nodvCz3.vtdto~i3.aaCO3 -- '0') break;if (strcmp(node~z3. ndto~i). aa 'help") 0 01strcmp(nodeCz3.ndtoCi3.aa."HELP'l) --=0

-C halp(4)iqato four;

two: printf("\nwhat is the nme of the file? Wh/)';scanf( "%s',filvnm);

57

Page 60: IAI flfl **D - DTIC

if (strcmp(Pilemm,"help") -- 0 Hstrcmp(filvnm, "HELP") 0'heip(2)igoto two;

while ((fp = fopen(filenm, 'r")) -=0)(piintf('\nFxle %/s not found. Please try zoain the '1filenm),scanf("%s",filenm);if (strcmp(filenm, 'help") == 0 ::strcmptfilenm. "HELP-)= 0

'help(2)igoto two;

for (z=l; z <= 30; z++)'fscanf'(fp, 's"nodetz3. ndname)iif (node~zJ.ndnanwtuJ -- '0') break;

for (4-i i <- 5; i++)'fscani'~ Pp, "%s", nod.'CzJ ndtoli3 ae);

if (nod9Ez3.ndtoEI3.ae1O3 - '0') break;

mtxsze =(z'-l)i

/*The node names and where flow goes to have now been read in.Now construct the matrix. The column number rePTesentsthe node flow comes from and the row number represents thenode flow goes to.

for (1=1; i <mtxszo; i++)<C for (j-1; j <- 6; j++)

'if (nod&1i3.ndto~j2.aaCO) -= '0, break;

/* look up the node with a node no. equal to ndto(find the node no. flow goes to, give its name) *

for (iij - 1; iij <- mtxsze; iij++)'if (strcmp(nodeCi3. ndtoj3. aa~nodeij2. ndname) 0<C matrixCiyjEII - 1; break;

if (iy >mtxsze)

printfC"no node called %s" nodei3. ndto~j) aa);printf("\r*Xnput error occurred- program aborted~n\nYou lose\n\n"),exit( V

Page 61: IAI flfl **D - DTIC

/* add flows to sink or outfall 4if(testCO] I- 'Y' && testCOJ! ''

for (z1,i z <m mtxsze; z++)Cfive: printf("\nEnter node which goes to sink (h/a) ")iscan f( W, tosink );if (tosinkC03 a-~' break;

if(strcmp(tosink. h elp) ==0 1! strcmp(tosink,"HELP'l) 0)

goto five;

for (i-i i<-mtxsze; i++){if (strcmp(tosinknod*Ci3.ndnam*) a- )

(matrizxintxsze+l3Ci3 1;break;

if (i > mtxsze) printf("\nNo such node as %s", tavink);

else < for (z1;i 2 -. mtxsze; z++)Cfscanf(fp,"%s"tosintk);if (tosinkE03 -- '0') break;

for Ui-1; i <- mtxsze; i++)< if (strcmp(tosink~nod&Ei3.ndnam@) =-0

m atrixabtxsz*+13ri3 - 1;break;

fclose(fp);

/* print out labelled niatris

printf("\n %-20s",nod@Ll5 ndname);for (1.2; x <= mtxlze; i++) ( printf("%-15s",[email protected]); Ifor (i-I, i <a txszo; i++)

Cprintf("\n%-i~s", nodeli3. ndna.,e);for (j-1; j <- mtxszes j4.+)

{printf("%-15d. matrixrijCj3)i

printf('\nSink /outfall "1);

for (i1;i i <- mtxsze; i++)printf("%-15d'. matriilmtxsze+lJi3); 5

Page 62: IAI flfl **D - DTIC

return~mtxsze),"t/* end matrwxn */

#include <stdio. h>,extern double determClO0]ZlO,0]extern int detrmsz;extern double rhs[lO0), varl003;soivsys( )

int i, iswap, ii, row, col.double swapo, mltplr;double count;

make sure the diagonal of the determinant has no zeroes-this is necessaru to make the solution routine work.First go down 4rough the rows substituting them to

put values in the diagonal. if this does not fill inthe entire~diagonal, cor,ninue by adding rows.

count = 0.0;for (i=1; i <= detrmszx i++)

{ if (determli][i] - 0.0;< count = 1.0;

for (ii - 1+i; ii <- derrmszi ii++){ if (determ~ii][i] !- 0.0)

< for (iswap = 1; iswap <= detrmsz, iswap)C swapo determti]tiswap3;determ~i]Ciswap] = determCii!isuap],determ~iiJ~iswap3 = swapo;

swapo rhsi];rhsli] = rhsZi]-jrhsCii] = swapoi

cg,,nt - 0.0;break;

/'* for diagonal elements not changed from zero bq substitution,go back through and add an equation with a non-zero elementin the appropriate column.

if (count '- 0.0)for (i-Ii i <- detrmsz; i -)

< if (determ~i3Ci] == 0.0)for (ii - 1; ii (detrmsz; ii++)if (d t r nCii][i] = 0 0 )

60

Page 63: IAI flfl **D - DTIC

< for jiswap- 1; sewap 4-detrmszi iswap*+)determCi3Eiswap3 determCijCiswap3 + dootermCix)Ciswap3)rhsl%3 - rhsCi3 + rhstji];break;

/4 Gaussian Elimination Routine (since the iterative one did'intconverge)First eliminate variables below the diagonal a

for (col = 1. col <= detrmsz; col++)( for(row - col + 1; row <- actrmsz; row++)< if(daterm~row3Ccol] -- 0.0) continue;

if(dotermtcol3~coO - 0.0)f or(iswap a 1; Tswap <- detrmsz; iswap++)detvrmCcol3Liswap3 datermCcol3Ciswap) +determC row] li swap];1hsCcol3 - rhstcol) rhsrrow3;

mltplr -determtrow3Ecol3 / determ~coilCcol];for(i-l; i<- detrmsz; i++)

< determcrow3:i3 deter'mtrow3C13 - (ailtplr adetermC1t~3Cz).

rhs~row3 rhs~row) (mltplr * rhstcol3);

1* debug print routineprintf("\n\nDEBUQ PRINT\n");

for(row -Ii row <- detrmsy; row++)

print f( "'\n)ifor (iswap - 1; iswap <a devrmsz; iswap++)

< prcntf('%-7.3f",determ~row]Ciswap]);printf (" -7.3f".rhsCrow2);

/4 Now solve for the variables, working up the diagonalfrom the bottom right.

for(row a detrmsz; row >= 1. row--){varCrow] - 0.01

for(col arowal, col <- decrmsz; co+)< vartrow3 varCrowl - (dotorm~rowlCcoll * varicall);I.

varCrowl - (varCrow3 + rhsCrow3) / determCrosa]Crow]i

61

Page 64: IAI flfl **D - DTIC

;. print out variable values. (T-E SOLUTION!)for (i=l; i,'=detrmsz; i++)printf("\nvariable %d =%7 3f",i,vari])3)

* /

return,#include Kstdio.hK.

4j ... ...++ .. .+++.-4.-+++ 4' .+..+.+- . . . .+.. . . +.4.

routine findmdl to look in a 4

iie of existing processmodels and read it if it exists, Also allows writingover existing models.

Each model in the file has 5 lines: the first is a title linewith an x in the first space; aid 4 lines of alternatingx and y points. x represents the production level, from0 to 100. Y represents the water demanded or mass of wastechemical produced.

Each line must have 80 char. (not including the newline). -lllllllllll~lllll[llllllllllllll t 111111111 2 11111111 f11111*

trtmdl(wlabel,wmdl,qin, chgs)char wlabel[20], wmdlL203float qin,Int chgs;

char linebuf[81], numbuf[9], label'20], fletest;char test[33,char query[]9,int fd, i, j. nread, line, ihi, ilou;float x1203, yE20];double qn;

/* initialize x and y */

fletest = 'n'i/* flotest keeps tract of what kiod

-f writing is to be done at end n.* prog= replace old m.del= write new mod.l in existing fxl*

use existing model, no o0rtrwrite= create new file, write in--model

The variable chgs is passed as a I tIchanges to models are to be allowed; a 0 if not.

Fd = open(wmdl,2)iif (fd .' 0)

62

Page 65: IAI flfl **D - DTIC

<printf('\nNo file of models found; file creatid\n"),fd - creat(wmdl, 0644);fletest = ''

/* If file of models *xists, print out the names of the models *

else I seek~fd.0L,0);

while((nread =read(fd,linebuf,81)) 1= 0)

if (linebuftO) -''

foi'(i=; 1 (= i9; i++)label~il -linebuf~i+l);

if(strcmp(label~wlabel) -= 0)

f'0test = ''/* desired model is now found

read it a

for (line - 0; line <- 3; line+-'

read(fd, ljnabuf,81)ifor (1 - 0; i <(4; i+4.)

< for(j -0; ,j <- 7; j++)

<numbuflj3 - linebufl(16*i) +j7

numbuftB2 -= 'sscanf(numbuf,".Sf",x+(lv e*5 + i)),for(j-0; j <- 7; j++)

(numbuf~j) linebuft(l6*i) + j+ 133i

numbufC~i3 = \'sscanf(numbuf.'7.9f"j+(1Iime*5 + 0));

br eak;

/* test if requested model not in file aif (fletest !-'0')

(printf("\nNo model called %20S in filt",wiabel);goto build;

/* if no changes are to be allowed go to end of routine *

if (chgs -- 0 && fletest -- 'o') goto quit;

Is plot out the modeli if vtor wants to change it,

63

Page 66: IAI flfl **D - DTIC

or if no model was on the file, build a nww one. *

graph(xy ,20, "TREATMENT EFFICIENCY").printF("\n FLOW RATE"),printf("\nDo you want to change this model-, g or nscanf("%s" test),if(test[O] != 'Y' && test[0] 1= 'y') goto qult.fletest = 'r;

/* build new model */

build: test[0 y = 'y'while (testC03 'y')(

for (i=O; i ,'=19; i++) CxtiJ = 0. O; yCi = 0. 0;printf("\n\n BUILD A NEW MODEL for %s\n",wlabel);for(i=O; i (= 19; i++) labelL13 =/* printf("\nPut in process namscanf("%-20s", label); */printf("\nPut in removal percent as a function of flow");printf("\nFor a max. of 20 points, put in flow rate ").orintf("and % removal");printf("\n\nUse units of cubic maters/day or cubic meters/batch for flow\n"),printf("For help with units type 'help'\n");

q15 for(i=O; i<=19 i++){ printf("\nFlow rate[%d]? (h/a) ". i+I);scanf("%s",query);

if(strcmp(query, "help") == 0 ! stromp(query, "HELP") == O)C help(15)igoto q15;

}

sscanf(query. "%f",xi)iif (x[O] <= 0.0) < printf("\nPlease, no zero or negative values").

goto build;)

if (x~i ,= 0.0) break;

printf "\n% removal? ");scanf("%f",g+i);

graph(xy,20,"TREAThENT EFFICIENCY")i

printf("\n FLOW RATE");printf("\nDo uou wanv to change this model? y or n ");

scanf("7s", test);if(testO -= 'Y') test[O] - 'yo;

quit if (fletest ! 'o')/* position file for writing //* if replacing old model, move back up 5 lines(405 char) */

( if (fletest =- 'r') lseek(fd, -405L, 1);

64

Page 67: IAI flfl **D - DTIC

1* ;i writing new model in file, move to end of file /if kfletest == 'n) lseekfd, OL, 2);

/* if creating new file. rewind */if (fletest - 'c ) iseek(fd, OL, 0);

* write out the model, title line and then 4 data lines. *

linebuf[Ol = w,for (i = 0; 1 '- 19; i1-) lir*bufti+1J wlabeltjl;for (i = 21, i = 79i i++) linabufCi =linebuf[80] - '\n ,

write(fd, linebuf, 81),

for (line = 0; line <= 3; line++)- for (i=Oi i <= 4i i++)

{ sprintf(numbuf,"%8. le",x[(line*5) + i]);

for (j=; j 2< 7; j*+)linebufli*16 + j] = numbuf#j];

sprintf(numbuf.'/..le". %(Iine*51 + i3

for (j-i; j <= 7; j@+)linebufE(i*16) +j +83 = numbuf[j2i

}

iinebuf[80] = -An';write(fd, linebuf,81);

y

/* end of write routine *1closefd),

1/* *######***** interpolate value of water demand ###h*####'#.# */

ilow =0, ihi - 1,

if( qin < x1O) qn = y[O), /* Assume that if x less thanmin. in graph, y steVs at uminDon't assume water use goes to

zero at zero production.

else

while(qin > x[ihi] && ihi < 20){ ++ihi++ilow;

i f (ih i >- 20)<printf("\nFlow rate of %f too high at %s, extend model.qin,wlabel);goto build;

qn = gEilow] +

(y[ihi] - yilow ) * ((qin - xCilow) /(xtihi3 - xiilow]));

}

return(qn).

65

Page 68: IAI flfl **D - DTIC

CERL DISTRIBUTION

Chief of ingineers 8th USA. vrea MTKATTN Tech oni tor ATTN L EArt-i 96171 ATTN: MTHC- SA 20315ATTN OAEN-I-L A 2) ATTN: EAi--P 96259 ATTN, Facilities EngineerTTN: I.N-CCY ATTN: EAFE-T 96212 Oakland Army Base 9462b

ATTN: DAEN-CW Bayonne MOT 07002ATTN: DAIN-C W ROK/US oniOined FOrces Command 96301 Sunny Point 140T 28461ATTN: DAEN- WR-W ATTN: EUSA-HHC-CFC/EngrATTN: OALN-CWO NARADCOM, ATTN: DRDMA-F 071160ATTN: DALN-rWP USA Japan (USAAJ)

ATTN: OAEN-EC Ch, FE 31v, AJE-FE 96343 TARCOM, Fnc. Div. 48090ATTk: OAEN-ECC PFc Engr (Honshul 96343ATTN: IAEN-ECE FaC Engr (Okinanwa) 96331 TRADOCATC: DAEN-ZCF HQ, TRADOC. ATTN: ATEN-FEArrT: C-L-L Rocky Mt. Area 80903 ATTN: FaCilities EngineerATTN: OAEN-RO Fort gelvoir 22060ATTN: DAEN-ROC Area Engineer, AEDC-Area Office Fort Benning 31905ATTN: DAER-ROM Arnold Air Force Station. TN 37389 Fort Bliss 79916

ATTN: DAEN-R4 Carlisle Barracks 17013ATTN: OAEM-ZCZ Western Area Office. CE Fort Chaffee 72902ATN: OAEN-ZCE annderberg AFB, CA 93437 Fort DIA 08640ATTN: OAEN-ZCI Fort Eustis 23604ATTN: TAENZCM 416th Engineer Comand 60623 Fort Gordon 30405

ATTN: Facilities Engineer Fort Hamilton 1252FESA. ATfN. Library 22060 Fort Benjamin Harrison 46216

US Military Academy 10996 Fort Jackson 29207FESA. ATTN: OET I1 79906 ATTN: Facilities Engineer Fort Knox 40171

ATTN: Dept of Geography a Fort Leavenworth 660?7US Army Engineer Districts Computer Science Fort Lee 23601ATTN: Library ATTN: OSCPER/MAEN-A Fort McClellan 36205

Alaska 99501 Fort Monroe 23651Al Batin 09616 Engr. Studies Center 20315 Fort Rucker 36362Aibuquerque 87103 ATTN: Library Fort Sill 73503Baltimore 21203 Fort Leonard Wood 65473Buffalo 14207 AP4IRC, ATTN: ORXNt-WE 02172

Charieston 29402 TSARCOM, ATTN: STSAS-F 63120Chicago 60604 USA ARRCOM 61299Detroit 48231 ATTN: DRCIS-RI-I USACCFar East 6301 ATTN: D8SAR-IS ATTN: Facilities EngineerFort Yorth 76102 Fort Huachuca 85613 {/)Galveston 77550 OARCOM - Dir.. Inst.. A Svns. Fort Ritchie 21719Huntington 25721 ATTN: Facilities EngineerJacksonville 32232 ARRADCOM 0:801 WESTCOnJapan 96343 Aberdeen Proving Ground 21005 ATN: Facilities EngineerKansas City 64106 Arow Matis. and Mechanics Res. Ctr. Fort Shafter 96858Little Rock 72203 Corpus Christl Army Depot 78419 ATTN: APEN-INLos Angeles 90053 Harry Diamond Laboratories 20783Louisville 40201 Dugmay Proving Ground 84022 SHAPE 09055Memphis 38103 Jefferson Proving Ground 47250 ATTN: Survivability Section, CCB-OPSMobile 36628 Fort Monmouth 07703 Infrastructure Branch. LANMANashville 37202 Letterkenny Army Depot 17201New England 02154 Natick R&D Ctr. 01760 Ho USEUCOM 09128New Orleans 70160 New Cumierland Army Depot 17070 ATTN: ECJ 4/7-LOtMew York 10007 Pueblo Amy Depot 81001Norfolk 23510 Red River Army Depot 75501 Fort Belvoir. VA 22060Omaha 58102 Redstone Arsenal 35809 ATTN: ATZA-DTE-EMPhiladelphia 19106 Rock Island Arsenal 61299 ATTN: ATT.A-DTE-SWPittsburgh 15222 Savanna Army Depot 61074 ATTN: ATIA-FtPortland 97208 Sharpe Army Depot 95331 ATTN: Engr. LibraryAiyad 09038 Seneca Army Depot 14541 ATTN: Canadian Liaison Office (2)Rock Island 61201 Tobyhanna Ariy Depot 18466 ATTN: IMB LibrarySacramento 95814 Tooee Army Depot 84074

San Francisco 94105 Wateryliet Arsenal 12189 Cold Regions Research Engineering Lao 03i7SSavannlah 31402 Yasm Proving Ground 85364 ATTN: LibrarySeattle 98124 White Sands Missile Range 88002St. Louis 63101 EY., ATTN: Library 22060St. Paul 55101 DLA ATTN: OLA-W] 22314Tulsa 74102 Waterways Experiment Station 39180Yicsburg 39180 FORSCOM ATTN: Librarydalla Walla 99362 FORSCOM Engineer, ATTN: AFEm-FEWilmington 28401 ATTN: Facilities Engineer HO, XVIII Airborne Corps and 28307

Fort Buchanan 00934 Ft. BraggUS Army tngineer Divisions Fort Bragg 28307 ATTN: AFZA-FE-EEATTN: Library Fort Campbll 42223Europe 09757 Fort Carson 80913 Chanute AFB, IL. 61866Huntsville 35007 Fort Devens 01433 3345 CES/DE, Stop 27Lower Mississippi Valley 39180 Fort Drum 13601Middle East 09038 Fort ood 76544 Norton AFB 92409Middle East lRear) 22601 Fort Indiantown Gap 17003 ATTN: AFRCE-MX/DEEMissouri River 68101 Fort Irwin 92311

North Atlantic 10007 Fort Sam Houston 78234 Tyndall AFB. FL 32403North Central 60605 Fort Lewis 98433 AFESC/Engintering & Service LabNorth Pacific 97208 Fort McCoy S4656Ohio River 45201 Fort McPherson 30330 MAFECPacific ocean 968S8 Fort George P. Meade 2075S ATT: ROTIE Liaison OfficeSouth Atlantic 30303 Fort Ord 93941 Atlantic Division 23511South Pacific 94111 Fort Polk 71459 Chesapeake Division 20374Soutnwester 75202 Fort Richardson 9905 Southern Division 29411

Fort Riley 66442 Pacific Division 94860US Army Europe Presidio of San Francisco 94129 Northern Division 19112HQ, 7th Army Training Command 09114 Fort Sheridan 60037 Western Division 64066ATN: A1TTG-OEH 151 Fort Stewart 31313 ATT: Sr. Tech. FAC-03T 2332

HO, 7th Army ODCS/Enr. 09403 Fort Wainwright 99703 ATTN: Asst. COR R&D. FAC-03 22332ATTN: AEAEN-EM (4 Vancouver eks. 98660

Y. Corps 09079 NCEL 93041ATTN: AETVH (5) HSC ATTN: Library (Code L0BA)

Vii. Corps 09154 ATTN: HSLO-F 78234ATTN: AIT5H I51 ATTII: FacilitieOs ngineer Defense Technical info. Center 22314

ME4t Support Command 09325 Fitzsimons AMC 80240 ATTN: DCA (121ATTN: AEREW I5) Walter Reed AMC 20012

Berlin 09742 Engineering Societies Library 10017ATIN: MEA-EN 121 INSCO1 - Ch. Inst1. Div. Mew York, MY

Southern European Task Force 09188 ATTN: Facilities EngineerATTN: AMSE-ENG 131 Arlington Hall Station (2) 22212 National Guard Bureau 20310

Installation Support Activity 09403 gist Hill FAres Station 22186 Installation DivisionATTN: AUES-RP

mow US Goret Printing Office 223048th USA, Korea ATTN: Facilities Engineer Recteing SectlonIDepository Copies (21ATTN: (AFt 181 %301 Cmewron Station 22314ATTN: EAFE-I 96358 Fort Lesley J. McNair 20319 250ATT : EAFE-ID 96224 Fort Myer 22211 1-86attn. tact am asni

Page 69: IAI flfl **D - DTIC

Users guide : Simulation model for a~munition plants : prediction of wastaweatercharacteristics and impact reuse-recycle / by Steven Railsback ... (at aI.)

- Champaign, IL ; Construction engineering Research Laboratory ; availablefrom NTIS, 1983.65 page (Technical Report / Conatruction Engineering Research LaboratoryN-152)

1. Amunition-tanufacture-environmental aspects. 2. Water-pollu ion-co puter programs. I. Railsback, Steven I. LX. Messenger, Manetce. II.Webster, Ronald Dwight. IV. Bady, John T. V. Series Technical Report(Construction Engineering Research Laboratory) ;N-152.

Page 70: IAI flfl **D - DTIC