A Object-Oriented Implementation of a Chemical Waste Consolidation Expert System
Return to front page 1. Background and Rationale 2. Interface Design
3. System Design
4. Evaluation and Results 5. Future Work 6. Conclusions Bibliography and References Appendix A. Example Drum Report Appendix B. Chemical Compatibility Testing Data |
3.4. The Bottle (Transporter) Library: Class BottleBook
Class BottleBook provides the functionality of the bottle library. It is similar to the ChemBookclass because it uses linked lists of structures, and that fact alone dictates very similar functions with slight code differences. This class only has two linked lists, one for the bottle information and one for the ingredients of the bottles. The original proposed structure design had three arrays per TransportData structure: the bottle ingredients, a waste type array, and an available container compatibility array. This limits the maximum number of ingredients the bottle can contain and wastes large amounts of memory unused by the average bottle. It was found that the waste type would be a single integer type descriptor and did not require an array. The available container compatibility array functionality was transferred to theDrumBook class. After a few cycles of software revision, the fundamental building block of the linked-list bottle library is the TransportData structure: struct TransportData { TransportData* next; // POINTER TO NEXT TRANS. STRUCT int bottleID; // TRANSPORT CONTAINER NUMBER int numIngredients; // NUMBER OF INGREDIENTS int destinationDrum; // CONSOLIDATION float volume; // TRANSPORTER VOLUME IN LITERS float pH; // CONTAINER pH float mass; // CONTAINER MASS float acidMoles; // MOLES OF ACID/BASE IN BOTTLE float oxidizerVolume; // VOLUME OF OXIDIZER IN BOTTLE int activeOxidizer; // OXIDIZER TEST(0=SPENT, 1=ACTIVE) float organicVolume; // VOLUME OF ORGANICS IN BOTTLE float corrosiveVolume; // VOLUME OF CORROSIVES IN BOTTLE float halogenatedVolume;// VOLUME OF HALOGENATED IN BOTTLE float bottleFlam; // BOTTLE NFPA FLAMMABILITY float bottleHealth; // BOTTLE NFPA HEALTH float bottleReact; // BOTTLE NFPA REACTIVITY float bottleContact; // BOTTLE NFPA CONTACT int day, month, year; // DATE RECEIVED String40 generatorName; // ORIGINAL GENERATOR int wasteType; // WASTE TYPE DESIGNATOR FOR BOTTLE }; The ingredient linked list is composed of nodes containing the ingredient name, bottle number and amount. The TransportData structure has gained several new members since the original design, including destinationDrum and acidMoles to track the concentration of acid and base in the bottle. The oxidizerVolume, organicVolume, corrosiveVolume and halogenatedVolume track various items to assist with the waste type determination. The bottleFlam, bottleHealth, bottleReact and bottleContact all represent volume weighted averages of the individual ingredient NFPA values. In particular, the weighted average of NFPA flammabilities generally follows the expected values of the flammability point of the mixture [NFPA 2007]. The weighted average of the reactivity is used to determine the addition order of the bottles to the storage drums. The functions BottleMenu, LoadBottleData, DisplayBottleInfo, BottleLookup and DeleteBottle all behave similarly to their ChemBook counterparts. The AddNewBottle function is the user interface to generate a new TransportData bottle and insert it into the linked list. It begins with interrogatory questions asking for volume of container, generator of the waste and the date of entry into the library. The items are recorded into aTransportData structure initialized by InitializeBottleDataStruct and are inserted into the linked list. At this point, the function passes control to theAddToBottle routine. The AddToBottle function is the user interface for the process for adding ingredients to an existing bottle. It begins by mirroring the ingredients from the linked list to a static array. The ChemLookup function generates the chemical name of the new ingredient, and the software asks for the volumetric amount of this addition. The new chemical is checked against the static array list for prior existence in the list; if not found, it is appended. At this point, the chemical is checked for compatibility against all the other chemicals in the bottle, and the results are displayed for the user. The software asks the user to commit to the addition. A negative response causes the addition to be aborted without the function writing the new ingredient to the linked list. An affirmative response updates the bottle; because the linked list is out of date, the function deletes all the bottle ingredients from the linked list and writes the static array ingredient information into the linked list for that bottle. A call to RecalculateBottleupdates all the derived bottle parameters. Finally, the function asks if the user wishes to continue adding to this bottle. If so, the process begins again, with the loading of the static array of ingredients. The RecalculateBottle routine performs the vital service of evaluating the bottles and adjusting the structure members in relation to the change of ingredients in the ingredient linked list. It begins by defaulting all the reference values to zero with the exception of destinationDrum, pH andactiveOxidizer, which are not re-evaluated by this function. It flags the bottle if formaldehyde is present to try to establish if this is a formalin solution. The ingredient list is scanned and cumulative totals of mass, volume, acidMoles, oxidizerVolume, organicVolume, corrosiveVolumeand halogenatedVolume are established. The bottleFlam, bottleHealth, bottleReact and bottleContact variables are multiplied by their volumetric amounts and divided by the total volume to generate the volume-weighted averages. Many of the more volatile chemical solvents in the waste stream can be vaporized or diffused [Bird 1960] from the mixture at relatively low temperatures, which poses additional health and flammability hazards. The NFPA volume-weighted number, bottleFlam, directly associates the flash point and volatility of the mixture. The bubble point of a mixture can be calculated using a series calculation [Henley 1981]. This method of determination of the beginning temperature of boiling requires information not easily obtainable for most of the chemicals in the library, and the information generated is too specific and excessive for the task at hand. The Antoine equation can yield accurate results for the flammability point of a mixture, but the lack of availability of published Antoine coefficients prohibited implementation of the method. The bottleFlam calculation is sufficient for these tasks because it gives an indication of the flammability point, which is relative to the mixture boiling point and vapor pressure [NFPA 2007]. This one number gives a good warning of the container’s flammability potential and danger. A TransportData container that has anNFPAflamm value of 1.2 would have a boiling point over 200 degrees Celsius while a container having an NFPAflamm value of 3.9 will boil below 100 degrees Celsius. It would also have a substantial amount of vapor generation at room temperature and pose a much greater risk of fire and explosion. The logic to determine the chemical waste type is based upon the flammability, corrosive, oxidizer and halogenated levels plus a few other parameters. During the initial ingredient scan, the wasteType of the bottle can be set if one of the chemical ingredients has a special wasteType.A wasteType of 1000 indicates chemicals that should be isolated from practically all others for reactivity reasons, while 1100 indicates chemicals like mercury which require isolation for toxicity reasons. The wasteType classification falls into distinct catagories, as shown in Figure 3.5. All bottles with a preset wasteType of 1100 or 1000 bypass the classification code. These values are directly transcribed from the ChemBook library when the chemical ingredient that requires special treatment was indexed. The next separation is based on flammability; the organicVolume divided by the total volume gives the volumetric percentage of flammables in the container. Another prime indicator is the weighted average bottleFlamm, which gives an estimated flammability bracket of the mixture. Since the organicVolume is slightly advantageous compared to the bottleFlamm, it is the criterion used for the flammability division. Bottles with more than 15% organics are considered flammable liquids; less than this amount is considered non-flammable by the currently used waste treatment company [EOG 2005]. The flammables are further divided by 6% halogenated and 5% corrosive criteria questions, again by stipulation from the currently used waste treatment company [EOG 2005]. Figure 3.5. Logic Flow of wasteType Classification
The non-flammable group is further divided into corrosive, poison, oxidizer or formaldehyde solution based on very similar thresholds. If a bottle is less than 15% flammable and has the boolean variable for formaldehyde set, the bottle wasteType is set to “formaldehyde solutions.” Next, the logic asks if the bottleHealth is greater than 0.5 and sets the wasteType to “Poison” if it is higher. Next the evaluation checks for a corrosive level over 5% and overwrites with a wasteType of “Corrosive” if it is true. Finally, if the bottle has an oxidizer level greater than 5%, the wasteType is overwritten to “Oxidizer.” By this logic, the bottle has been classified to a specific wasteType. The function finishes by calling the UpdateBottlefunction from the ChemBook class. |