Citation
Modeling Biological Nitrogen Removal with Denitrification Enzyme Parameter Estimation

Material Information

Title:
Modeling Biological Nitrogen Removal with Denitrification Enzyme Parameter Estimation
Creator:
HAMILTON, RYAN K.
Copyright Date:
2008

Subjects

Subjects / Keywords:
Biomass ( jstor )
Bioreactors ( jstor )
Enzymes ( jstor )
Mathematical independent variables ( jstor )
Modeling ( jstor )
Nitrates ( jstor )
Nitrogen ( jstor )
Oxygen ( jstor )
Parametric models ( jstor )
Wastewater ( jstor )
City of Gainesville ( local )

Record Information

Source Institution:
University of Florida
Holding Location:
University of Florida
Rights Management:
Copyright Ryan K. Hamilton. Permission granted to University of Florida to digitize and display this item for non-profit research and educational purposes. Any reuse of this item in excess of fair use or other copyright exemptions requires permission of the copyright holder.
Embargo Date:
4/17/2006
Resource Identifier:
495636970 ( OCLC )

Downloads

This item has the following downloads:

hamilton_r ( .pdf )

hamilton_r_Page_115.txt

hamilton_r_Page_014.txt

hamilton_r_Page_123.txt

hamilton_r_Page_042.txt

hamilton_r_Page_131.txt

hamilton_r_Page_130.txt

hamilton_r_Page_007.txt

hamilton_r_Page_114.txt

hamilton_r_Page_145.txt

hamilton_r_Page_137.txt

hamilton_r_Page_116.txt

hamilton_r_Page_035.txt

hamilton_r_Page_055.txt

hamilton_r_Page_051.txt

hamilton_r_Page_005.txt

hamilton_r_Page_125.txt

hamilton_r_Page_087.txt

hamilton_r_Page_119.txt

hamilton_r_Page_053.txt

hamilton_r_Page_037.txt

hamilton_r_Page_111.txt

hamilton_r_Page_147.txt

hamilton_r_Page_106.txt

hamilton_r_Page_012.txt

hamilton_r_Page_096.txt

hamilton_r_Page_046.txt

hamilton_r_Page_117.txt

hamilton_r_Page_063.txt

hamilton_r_Page_080.txt

hamilton_r_Page_024.txt

hamilton_r_Page_057.txt

hamilton_r_Page_098.txt

hamilton_r_Page_049.txt

hamilton_r_Page_124.txt

hamilton_r_Page_076.txt

hamilton_r_Page_128.txt

hamilton_r_Page_044.txt

hamilton_r_Page_104.txt

hamilton_r_Page_033.txt

hamilton_r_Page_028.txt

hamilton_r_Page_146.txt

hamilton_r_Page_008.txt

hamilton_r_Page_097.txt

hamilton_r_Page_047.txt

hamilton_r_Page_062.txt

hamilton_r_Page_136.txt

hamilton_r_Page_015.txt

hamilton_r_Page_023.txt

hamilton_r_Page_019.txt

hamilton_r_Page_043.txt

hamilton_r_Page_027.txt

hamilton_r_Page_045.txt

hamilton_r_Page_026.txt

hamilton_r_Page_040.txt

hamilton_r_Page_072.txt

hamilton_r_Page_079.txt

hamilton_r_Page_031.txt

hamilton_r_Page_083.txt

hamilton_r_Page_118.txt

hamilton_r_Page_103.txt

hamilton_r_Page_100.txt

hamilton_r_Page_009.txt

hamilton_r_Page_048.txt

hamilton_r_Page_120.txt

hamilton_r_Page_065.txt

hamilton_r_Page_002.txt

hamilton_r_Page_090.txt

hamilton_r_Page_107.txt

hamilton_r_Page_108.txt

hamilton_r_Page_126.txt

hamilton_r_Page_017.txt

hamilton_r_Page_141.txt

hamilton_r_Page_059.txt

hamilton_r_Page_054.txt

hamilton_r_Page_148.txt

hamilton_r_Page_001.txt

hamilton_r_Page_021.txt

hamilton_r_Page_084.txt

hamilton_r_Page_064.txt

hamilton_r_Page_066.txt

hamilton_r_Page_071.txt

hamilton_r_Page_127.txt

hamilton_r_Page_070.txt

hamilton_r_Page_016.txt

hamilton_r_Page_006.txt

hamilton_r_Page_029.txt

hamilton_r_Page_041.txt

hamilton_r_pdf.txt

hamilton_r_Page_018.txt

hamilton_r_Page_056.txt

hamilton_r_Page_091.txt

hamilton_r_Page_112.txt

hamilton_r_Page_085.txt

hamilton_r_Page_143.txt

hamilton_r_Page_061.txt

hamilton_r_Page_038.txt

hamilton_r_Page_052.txt

hamilton_r_Page_073.txt

hamilton_r_Page_113.txt

hamilton_r_Page_099.txt

hamilton_r_Page_102.txt

hamilton_r_Page_139.txt

hamilton_r_Page_109.txt

hamilton_r_Page_138.txt

hamilton_r_Page_078.txt

hamilton_r_Page_075.txt

hamilton_r_Page_077.txt

hamilton_r_Page_133.txt

hamilton_r_Page_013.txt

hamilton_r_Page_121.txt

hamilton_r_Page_088.txt

hamilton_r_Page_135.txt

hamilton_r_Page_082.txt

hamilton_r_Page_122.txt

hamilton_r_Page_094.txt

hamilton_r_Page_093.txt

hamilton_r_Page_011.txt

hamilton_r_Page_050.txt

hamilton_r_Page_003.txt

hamilton_r_Page_081.txt

hamilton_r_Page_032.txt

hamilton_r_Page_086.txt

hamilton_r_Page_067.txt

hamilton_r_Page_068.txt

hamilton_r_Page_010.txt

hamilton_r_Page_089.txt

hamilton_r_Page_004.txt

hamilton_r_Page_095.txt

hamilton_r_Page_058.txt

hamilton_r_Page_144.txt

hamilton_r_Page_092.txt

hamilton_r_Page_105.txt

hamilton_r_Page_129.txt

hamilton_r_Page_074.txt

hamilton_r_Page_020.txt

hamilton_r_Page_101.txt

hamilton_r_Page_142.txt

hamilton_r_Page_110.txt

hamilton_r_Page_039.txt

hamilton_r_Page_060.txt

hamilton_r_Page_140.txt

hamilton_r_Page_134.txt

hamilton_r_Page_132.txt

hamilton_r_Page_034.txt

hamilton_r_Page_036.txt

hamilton_r_Page_025.txt

hamilton_r_Page_030.txt

hamilton_r_Page_069.txt

hamilton_r_Page_022.txt


Full Text













MODELING BIOLOGICAL NITROGEN REMOVAL
WITH DENITRIFICATION ENZYME PARAMETER ESTIMATION














By

RYAN K. HAMILTON


A DISSERTATION PRESENTED TO THE GRADUATE SCHOOL
OF THE UNIVERSITY OF FLORIDA IN PARTIAL FULFILLMENT
OF THE REQUIREMENTS FOR THE DEGREE OF
DOCTOR OF PHILOSOPHY

UNIVERSITY OF FLORIDA


2005



































Copyright 2005

by

Ryan K. Hamilton

















To my wife, without whose support my work would have been impossible.
















ACKNOWLEDGMENTS

I would like to thank my supervisory committee chair (Spi, A. Svoronos)

and cochair (Ben Koopman) for their advice and guidance. I thank my committee

members (Atul Narang and Madeline Rasche) for their generous help. I would like

to also thank my colleagues, Anna Casas6s and Don Lee. Without their support,

the long hours of experiment would have been fatal. Finally, I would like to thank

my wife for standing by me during these years of study.

















TABLE OF CONTENTS
page

ACKNOWLEDGMENTS ............................. iv

LIST OF TABLES ...................... .......... vii

LIST OF FIGURES ..................... ......... viii

ABSTRACT ....................... ............ ix

CHAPTER

1 CONTROL ISSUES AND CHALLENGES ......... ...... ... 1

1.1 Introduction . . . . . . . 1
1.2 Sewer System .. .. ... .. .. .. .. ... .. .. .. .. .. 2
1.3 Aerobic Reactor ........ ................... 5
1.4 Anoxic Reactor ............................ 6
1.5 Secondary Settling Tank ............ ........... 7
1.6 Filters . . . . . . . . 8
1.7 Disinfection Basin .................. ... 8
1.8 Modeling (C! .III. .ges ....... . . .10
1.9 Further Rem arks .................. ........ 12

2 AUTOMATION OF LAB-SCALE BIOREACTORS . . 14

2.1 Introduction .................. ........... 14
2.2 Materials, Methods and Results .................. .14
2.3 Conclusions .. .. ... .. .. .. .. .. .. .. .. .... 20

3 MODEL FOR DENITRIFIER DIAUXIC GROWTH . . 22

3.1 Introduction .................. ........... 22
3.2 Model ........ .. ... ...... ... ....... 23
3.3 Materials and Methods .................. .. .27
3.3.1 Bacterial Strain and Growth Conditions . .... 28
3.3.2 Nitrate Reductase A--., .................. .29
3.3.3 Parameter Estimation .................. .. 30
3.4 Results and Discussion .................. ... 31
3.5 Conclusions .................. ........... 36
3.6 Enzyme Synthesis Expression Derivation . . ...... 39











4 KALMAN FILTER FOR ENZYME PARAMETER ESTIMATION ... 41

4.1 Introduction .... ........ .... ....... 41
4.2 Kanapaha Water Reclamation Facility ...... ....... 42
4.2.1 Hydraulic Model ................... ... 45
4.2.2 Biological Model ........... ...... ..... 49
4.3 Kalm an Filter .................. ........ .. .. 49
4.4 Results and Discussion .................. ... .. 53
4.5 Acknowledgments .................. ........ .. 56

5 FUTURE WORK ...... ..................... .. 57

5.1 Distributed State Modeling. ............... . 57
5.2 Extended Kalman Filter ....... ........ .... 57
5.3 Enzyme Activity Based Dynamic Optimization . .... 59

APPENDIX

A KALMAN FILTER SUPPLEMENTAL MATERIAL . . ... 61

B AUTOMATION PROGRAM SOURCE CODE . . ..... 69

B.1 Code for DLECModule.bas .................. ..... 69
B.2 Code for DLECEmailModule.bas ................. .. 73
B.3 Code for DLECPhoneCallModule.bas .. . . ..... 76
B.4 Code for DLECLogFileModule.bas ................. .. 77

C DENITRIFIER DIAUXIC GROWTH MODEL SOURCE CODE . 81

C.1 Code for Run061703.m .................. ... .. 81
C.2 Code for RunModel.m .................. ...... 82
C.3 Code for model5c.m .................. ....... .. 85
C.4 Code for FitAllData.m .................. ... .. 87

D EXTENDED KALMAN FILTER SOURCE CODE . . 89

D.1 Code for TestKSim.m .............. ... ... .. 89
D.2 Code for RunKEKF.m ............... .. .. .. 91
D.3 Code for fKanapahaSim.m ................ ...... 95
D.4 Code for fKanapahaModelOpsSetup.m . . ..... 103
D.5 Code for fKanapahadxdt.m ................ 107
D.6 Code for fParseAllX.m .................. ... 111
D.7 Code for fExtendedKalmanFilter.m ................ .. 114
D.8 Code for PlotKEKFData.m ............... .. 128

REFERENCES ................... . . .. 133

BIOGRAPHICAL SKETCH .................. ......... 138

















LIST OF TABLES
Table page

2-1 Equipment list ............... ........... .. 21

3-1 Synthetic media composition ............... .... 28

3-2 Parameter values obtained by fitting ............. .. .. 32

3-3 Nomenclature used in denitrifier modeling . . ..... 38

4-1 Wastewater composition ............... ....... .. 44

4-2 eASMlm model ............... ........... .. 50

4-3 eASMlm parameter values .............. .. .. 50

A-1 Aerobic basin surface aerators ................ . 62

A-2 Hydraulic model parameters .................. .. 64

A-3 eASMlm Model .................. ........... .. 65

A-4 eASMlm parameter values .................. ... .. 66

















LIST OF FIGURES
Figure page

1-1 Example plant diagram .................. ... 2

1-2 Kanapaha Water Reclamation Facility ............... 3

2-1 Automation system Process and Instrumentation Drawing (PID) 15

2-2 Effect of rinsing sample path on biomass measurements . ... 17

2-3 Software interface .................. .......... .. 19

2-4 Experiment configuration screen .................. .. 20

3-1 Biochemical process model .................. .... .. 24

3-2 Model overview .................. ........... .. 25

3-3 Model fit to literature results .................. .. 33

3-4 Enzyme activity during diauxic growth ................ .. 34

3-5 Additional experiments with model fits ................ .. 35

4-1 Kanapaha physical process layout. ............... ... .. 45

4-2 Kanapaha operations -aeration strategy. ............ 46

4-3 Kanapaha operations -recycles and recirculations. . . ... 47

4-4 Hydraulic model process diagram ............. .. .. 48

4-5 EKF results, aN, nitrate and ammonia ................ .. 55

A-1 Hydraulic model PID .................. ........ .. 62

A-2 Diurnal flow patterns .................. ........ .. 67

















Abstract of Dissertation Presented to the Graduate School
of the University of Florida in Partial Fulfillment of the
Requirements for the Degree of Doctor of Philosophy

MODELING BIOLOGICAL NITROGEN REMOVAL
WITH DENITRIFICATION ENZYME PARAMETER ESTIMATION

By

Ryan K. Hamilton

December 2005

C'! iri: S]pvii- A. Svoronos
Cochair: Ben Koopman
Major Department: ('I, "i,, I. Engineering

As urban population density has increased it has been necessary to develop

ever more sophisticated wastewater treatment technology. Waters that accept

domestic wastewater receive pollutants in the form of nutrients (primarily

organic compounds and ammonia) that, if left untreated, could spur a bloom

of microorganism growth and cause disease in the higher organisms that consumed

the water. Most modern wastewater treatment facilities use some type of activated

sludge process in which naturally occurring microorganisms are cultivated in the

wastewater under conditions that attempt to optimize the consumption of influent

nutrients. This work presents models and techniques for predicting the performance

of biological nutrient removal systems, both bench-scale and plant-scale.

Presented is a model for diauxic growth of denitrifying bacteria in which

nitrate reductase synthesis kinetics dominate the overall growth kinetics. The

model is based on the assumption of the existence of a nitrate respiration operon,

thereby linking the rate of nitrate uptake to the activity of nitrate reductase. I have

shown that this approach can model diauxic growth of Pseudomonas denitrificans











by conducting experiments in which nitrate reductase activity was measured

during both lag and ensuing exponential growth phases. I consistently observed the

pattern of low nitrate reductase enzyme activity during the lag phase, increasing

before the onset of growth. By fitting model parameters I was able to successfully

match experimental data for growth, nitrate uptake and enzyme activity level.

In cooperation with Gainesville Regional Utilities, a process model was

developed for the Kanapaha Water Reclamation Facility (KWRF) predenitrification

process in Gainesville, Florida. The process model incorporates a biochemical

model for diauxic growth of pure cultures of denitrifying bacteria that is integrated

with the industry standard Activated Sludge Model 1. I demonstrate, using real

facility operating data, that by applying an extended Kalman filter to a single

bioreactor I obtain estimates for both reactor composition and denitrification

enzyme model parameters. This technique for parameter identification allows

a semi-mechanistic model developed for pure cultures to be applied to a mixed

culture population where isolation of enzyme kinetic parameters is not practical.

















CHAPTER 1
CONTROL ISSUES AND CHALLENGES IN WASTEWATER TREATMENT
PLANTS

1.1 Introduction

As urban population density has increased it has been necessary to develop

ever more sophisticated wastewater treatment technology. There was a significant

improvement in urban sanitation with the boom in popularity of indoor toilets in

the early 1900s however this increase occurred at the expense of the downstream

receiving waters. These waters received pollutants in the form of nutrients

(primarily organic compounds and ammonia) that, if left untreated, could spur

a bloom of microorganism growth and cause disease in the higher organisms that

consumed the water.

Modern cities operate treatment facilities of ever growing scale and sophistication

in order to treat wastewater to a level that natural systems can safely absorb

without negative impact. Most modern wastewater treatment facilities use some

type of activated sludge process in which naturally occurring microorganisms

are cultivated in the wastewater under conditions that attempt to optimize the

consumption of influent nutrients. The 1_i i ly of plants in the United States aim

to accomplish only carbon removal, and issues of control there pertain primarily

to aeration control for energy usage and satisfying process demands. There is

a significant control issue for these facilities in that adequate oxygen has to be

provided in spite of significant and continually changing influent conditions without

excessive aeration that would waste energy. Increasing pressure to also remove

nutrients such as nitrogen and phosphorus requires more complicated processes that

have several optimization and control issues. N1i ti ii ii; are transformed at different

1












Sewage Enters
--------.----i -t-I


.---------------------------------------------------
Mixed Liquor Recirculation
S- Effluent
Plant Influent Anoxic Aerobic Disinfection
Basin Basin Clarifier Filter Basin

Sludge Return
Waste
Biosolids
Treatment Fi Processin

Figure 1-1: Example plant diagram. Sewage is collected by local pumping stations
before passing to the treatment facility (here a Ludzack-Ettinger process). Influent
first passes through an anoxic bioreactor in which nitrate is reduced to nitrogen
and some organic carbon is consumed. In the aerobic bioreactor most organic
carbon consumption occurs and ammonia is converted to nitrate. The mixed liquor
recirculation returns the generated nitrate to the anoxic reactor for reduction
to nitrogen gas. The secondary settling tank returns a concentrated stream of
activated sludge to the anoxic reactor while passing clarified effluent to the filters,
and from there to the disinfection basin for inactivation of harmful microorganisms.


rates depending on reactor environment and other operating conditions. Either

cyclic operation or multi-reactor facilities have been effectively utilized for nutrient

removal. Control and optimization of wastewater treatment facilities has been an

area of interest for over a century. As an example of the size of the industry, in

1996 $16.7 billion was spent in the U.S. on wastewater treatment operations.

1.2 Sewer System

The first control issue that can seriously impact plant operation is regulation

of the influent flow rate to the wastewater treatment plant. The normal d-4 /night

cycle of human activity causes diurnal variation in sewage flow. There are also

surges in flow rate due to rainfall entering the sewer system via cracks in pipes












































Figure 1-2: Kanapaha Water Reclamation Facility. This facility uses two different
biological nutrient removal processes in parallel to treat 10 million gallons of
wastewater per div with a total bioreactor volume of 11.2 Mgal (Note that this is
an unusually large ratio of reactor volume to flow rate.) Pictured are the .,li i'ent
East and West aeration basins, totaling 4.8 million gallons.











(infiltration) and through manhole covers and other openings (inflow). One

method of smoothing flow variations is to build equalization basins upstream of

the wastewater treatment plant. This is common practice at facilities treating

industrial wastewaters but is usually too expensive for municipal wastewater

treatment plants. In a few cases, the inherent storage within the pipes and

pumping stations that make up a sewer system has been utilized to smooth

variations in plant feed rates.

The Quebec Urban Community has successfully implemented such a real time

control solution to this problem by implementing a global optimal predictive sewer

control system that has been operating since the summer of 1999 (Schutze et al.,

2004). This system routes flows and controls volumes in the sewer system to meet a

series of ranked control objectives.

1. Minimization of combined sewer overflows.

2. Maximization of the use of treatment facility capacity. Treatment facilities

are designed based on assumed feed rates, and a feed rate that is too low can

adversely impact plant performance.

3. Minimization of accumulated volumes. The control scheme tries to meet its

goals with minimal held volume in the sewer system.

4. Minimization of setpoint variation.

A still more sophisticated system would coordinate these goals with the

dynamically changing needs of the treatment facility, but to our knowledge such a

unification has never been implemented.

Other cities are moving in this direction. For example, Chicago recently

finished installing 109 miles of tunnels with a storage capacity of 15.6 billion gallons

to address the problem of system overflows and demand fluctuation.











1.3 Aerobic Reactor

Upon entering the treatment facility and being combined with any internal

recycle streams wastewater enters one or more bioreactors where most of the

nutrient removal takes place by a complex mixed population of microorganisms.

Some of these microbes grow only under aerobic conditions (dissolved oxygen

present), whereas others are capable of growth under both anoxic (utilizing nitrate

instead of oxygen as terminal electron acceptor) and aerobic conditions. Many

plant configurations with different combinations of reactors, recirculations and

recycles are commonly used; however all meet the same basic needs. The one

universal requirement is removal of biochechemical oxygen demand (BOD), which is

a measure of the amount of organic carbon available to support microbial growth.

Additionally, removal of nitrogen or phosphorus is a requirement at a growing

number of facilities.

Aerobic conditions are conducive to the growth of a wide variety of microbes,

including heterotrophic bacteria that remove BOD from the wastewater, as well

as nitrifying bacteria that oxidize ammonia to nitrate. Aeration is typically

accomplished using surface impellers or submerged diffusers and accounts for the

largest energy cost in these plants. The cost of energy for aeration throughout a

facility can be 50' of the total plant energy costs, although in some cases this

can be as high as 7.'. as it is at the Kanapaha Water Reclamation Facility in

Gainesville, Florida. In this facility switching from manual aerator control to

automatic resulted in a savings of 10 to 3il '. on an annual cost of i.1,111 l11111

The aeration energy cost combined with the very strong effect of aeration on

biomass growth makes dissolved oxygen (DO) control the most studied control

problem in wastewater treatment. The problem is made more complicated by

the fact that oxygen uptake rates change under different plant loadings and

temperatures. The most frequently used control strategy is to manipulate the











aeration rate to control dissolved oxygen (DO), usually at a fixed set point

regardless of load. High DO promotes bacterial growth, but also leads to higher

aeration costs. High DO can also be a problem for nitrogen removing plants if it

leads to recirculation of excessive DO to the anaerobic denitrification reactors.

Several more sophisticated control schemes have been developed that vary the

DO setpoints in order to minimize costs while meeting effluent requirements. One

scheme that has been attempted is feed forward aeration control based on influent

ammonia, in which a concentration spike of influent ammonium is measured, and

triggers a traveling wave of increased DO setpoints down the line corresponding to

the calculated hydraulics of the spike (Ingildsen et al., 2002).

In facilities that vary the DO setpoint, the most common approach is cascade

control in which the DO setpoint is manipulated by an outer control loop in

order to control effluent quality. This decouples the fast DO response from the

slower dynamics of final effluent quality. Many techniques, such as fuzzy control

and expert systems have been used for the outer control loop, however, it has

recently been argued that this problem would be more accurately addressed as a

multivariable control problem rather than multiloop (Steffens and Lant, 1999).

1.4 Anoxic Reactor

Anoxic reactors are used in cases where nitrogen removal is a process goal.

Through denitrification, which takes place in anoxic reactors, nitrogen is reduced

through several intermediates to nitrogen gas, which passes harmlessly into the

atmosphere. Facultative anaerobes in the anoxic reactor use nitrate recirculated

from the aerobic reactor as terminal electron acceptor for growth under oxygen-free

conditions. A control issue here is the recirculation rate. It must be fast enough to

supply adequate nitrate without introducing excessive dissolved oxygen. Additional

nitrogen removal is accomplished in some process schemes in an anoxic reactor

following the aerobic reactor. An alternative to having dedicated anoxic reactors is











to have cycling of air on and off in the same reactor, thus combining nitrification

and denitrification in the same reactor. Plants can achieve phosphorus removal by

providing process conditions (such as an anaerobic tank at the beginning of the

bioprocess train) that encourage the growth of phosphate accumulating bacteria

(which convert soluble phosphate to polyphosphate).

1.5 Secondary Settling Tank

After leaving the bioreactors, activated sludge enters a secondary settling tank,

where floes consisting of microbes and other particulate matter are allowed to settle

and form a sludge blanket at the bottom of the tank. Clarified effluent exits at

the top of the tank and flows to the filters while sludge is continuously removed

from the bottom of the tank. On-line depth of blanket sensors monitor the depth

of the sludge blanket, which the operators (or a control system) use to adjust the

sludge return rate. If the return rate is too low, the sludge blanket can approach

the water surface, where it could easily be swept into the effluent. If the return

rate is too high, turbulence in the clarifier will cause the sludge blanket to become

fluffy, diluting the underflow stream and reducing clarifier efficiency. Almost all

of the sludge collected from the bottom of the secondary settling tank is returned

to the bioreactors. A small fraction of the sludge is removed (wasted) from the

settling tank for further processing (e.g. digestion). The waste rate is a variable

that can be used to manipulate solids retention time (SRT), which in turn controls

the net growth rate of microbes in the process. Thus, SRT has a very large impact

on the overall plant dynamics. One control application here is timing the sludge

waste so that it occurs at the time of d, i when sludge concentrations are at a

maximum in order to reduce hydraulic loading and maximize SRT in the digesters

that receive the sludge. In the case of the Kanapha Water Reclamation Facilitiy

(KWRF) in Gainesville, Florida, This strategy, combined with on-line nutrient and











pH measurements in the digester eliminated the need for a 5 to 10 million dollar

expansion in order to meet EPA CFR-503 Class B biosolids regulations.

One motivation for controlling influent wastewater flow rates is to avoid

upsetting the sludge blanket in the secondary settling tank. A sudden flow spike

can cause the blanket to dislodge and enter the upper (clarified) effluent stream,

where it can clog the filters in the next stage of treatment. In the Kanapaha facility

a PID controller is used to set a flow ratio between the clarifier effluent flow and

the sludge return rate. This saves thousands of dollars annually in pumping costs,

but more importantly eliminates the possibility of a plant upset due to a dislodged

sludge blanket.

1.6 Filters

The purpose of filtration is to decrease the concentration of particulate solids

in the treated effluent by passing water through granular or cloth media. Filter

runs are continued until head loss increases to the maximum allowed level. At this

point flow is reversed to dislodge accumulated particulate materials backwashingg).

The filter is then returned to normal operation. The 1 ii' Pr control issue is the use

of scheduling versus head loss to initiate backwashing.

1.7 Disinfection Basin

The final treatment step is disinfection, commonly accomplished with chlorine

dosing or ultraviolet light exposure. In this process, many of the remaining

microorganisms are killed before the treated water is allowed to leave the plant.

In facilities that use a chlorination basin, the facility is required to have a

certain effluent concentration of chlorine in order to guarantee a minimum level

of disinfection. Chlorine is added at the beginning of a chlorine contact basin and

a large amount immediately reacts with ammonia nitrogen (ammonia nitrogen

chlorine demand) in the water, leaving some fraction for disinfection. The effluent

level must be sufficient for disinfection, however excessive chlorination favors











formation of toxic trichloromethanes, which are regulated in water discharged into

the aquifer. By using only the necessary amount of chlorine the facility reduces the

need to store large quantities of a dangerous and expensive chemical.

Controlling effluent chlorine is frequently based on a feedback loop that

sets the chlorine dose based on the effluent chlorine concentration. However,

the ammonia nitrogen chlorine demand varies with the loading of the plant, so

the requisite dose will fluctuate with the daily usage cycle. Large disturbances

combined with significant dead times pose a significant challenge to tight control of

effluent chlorine. The dead times fluctuate by a factor of 10 over a 24 hour period,

so a Smith Predictor proves inadequate. One solution that has been employ, .1

is a cascade scheme in which an inner control loop manipulates the dosing in

order to maintain a setpoint concentration measured near the beginning of the

basin. This short dead time loop allows for rapid control dynamics to compensate

for fluctuations in ammonia nitrogen chlorine demand. The outer control loop

maintains the basin effluent concentration by manipulating the setpoint for the

inner control loop. The outer loop is able to compensate for large daily fluctuations

as a result of slow disturbances.

A novel solution to this problem has recently been proposed (\. redith, 2003)

in which a dynamic weir at the end of the contact basin is raised or lowered in

order to change the reactor volume in response to changes in flowrate. By doing

so, the residence time, and hence the dead time, becomes constant and traditional

dead time compensation techniques may be employ, .1

In the case of UV disinfection, the manipulated variable is the number of

banks of lights active at any time, and optimization is simply energy cost vs.

acceptable disinfection level.











1.8 Modeling ('!i iii. iges

As is the case in most processes, the i1i ii iily of development is done with

so-called white-box models, meaning that the models are developed from first

engineering principles. The overall wastewater treatment plant (WWTP) model

consists of two main parts. The hydraulic model represents reactor behavior (plug

flow, CSTR etc), flowrates and recirculation. One unique unit operation is the

secondary settling tank. There are a few secondary settling tank models in use,

the most common of which is the ideal or point clarifier with no retention time, in

which the bottom stream is simply enriched with particulates by a ratio determined

by stream flowrates. If the impact of operating points on sludge settling is of

interest, a one-dimensional settler model may be used, or for exploration of the

effect of flowrate and turbulence, a 2 or 3-dimensional model may be appropriate.

The second primary component of a WWTP model is the activated sludge

model that portrays the microorganism growth, death and nutrient consumption.

These models are necessarily approximations to the vast number of biological

processes occurring in each bioreactor, but selection of the proper model will allow

adequate description of those processes most relevant to a particular WWTP.

The reference model of biochemical reactions in the bioreactors is Activated

Sludge Model No. 1 (ASM1) (Henze et al., 2000), which was developed by

the International Water Association. The success of this model prompted the

widespread adoption of biochemical modeling of wastewater in both academia and

industry. For those facilities where biological phosphorus removal is desirable, a

standard model is Activated Sludge Model No. 2d (Henze et al., 2000). This model

portrays the processes by which phosphate accumulating organisms store phosphate

as polyphosphate under aerobic conditions and hydrolyze it under anaerobic

conditions. More recently, the TUDP model (van Veldhuizen et al., 1999) has been











proposed. This model combines the known metabolic model for denitrification and

bio-P removal with the ASM1 sludge production model.

These models have limitations in several respects. In the most common,

ASM1, there is no temperature effect, even though temperature has a significant

impact on sludge behavior. Instead, model parameters are provided at 10 and 20

C. In ASM2 and TUDP the temperature effect is portli -i, .1 with Arrhenius-type

equations valid in the range from 10 to 25 C. Another limitation of the ASM

models is that they cannot portray a lag in growth when switching electron

acceptors. Work has been going on to add these capabilities. Work has also been

done to extend these models to portray the effect of a slug of toxic influent such

as ethanol (Nowak et al., 1997). In this event, the sludge metabolism, particularly

nitrification, is dramatically inhibited. This problem is normally addressed on a

case-by-case basis depending on the particular facility, but another possible solution

would be to use an on-line model parameter estimation technique.

The next frontier of white-box modeling is the merger of distributed state

models and computational fluid dynamics (CFD). In these models, some or all

state variables do not have a single value, but are represented by a distribution

curve. While the SRT of a facility provides information about the fraction of

active biomass, a distributed state approach would provide that curve directly.

Distributed state models are currently highly demanding computationally, but have

the potential to provide great new insights into biological wastewater treatment.

The benefit of the distributed state approach is particularly significant

for models with nonlinear behavior based on concentrations of intracellular

components. Consider the case of diauxic lag, in which aerobically cultured

facultative anaerobes are introduced into an anoxic environment. They will

experience a period of little or no growth during which they synthesize necessary

enzymes for growth under the new conditions. Now, consider an anoxic reactor











containing bacteria experiencing a long diauxic lag into which is introduced an

innoculum that has been growing exponentially under identical anoxic conditions.

Common sense dictates that the new innoculum will continue to grow exponentially

in the new reactor while the preexisting culture continues to experience lag, but a

distributed state model is required to capture this behavior. A traditional model

would take the anoxic growth enzyme levels of the innoculum and average it out

over the entire population, resulting in the incorrect prediction that the entire

population is still experiencing a diauxic lag. A similar argument could be made

for phosphorus metabolism, in which stored polysphosphate is used as an energy

storage compound by certain classes of bacteria, highlighting further the benefit of

distributed state modeling in wastewater treatment.

Development of accurate process models is a prerequisite for application

of model predictive control techniques for whole-process control and dynamic

optimization. (Gernaey et al., 2004) is recommended as a recent review of

wastewater treatment modeling.

1.9 Further Remarks

It should also be noted that wastewater bioreactors are a very harsh

environment for probes. For example, dissolved oxygen probes that do not require

frequent replacement have only recently become available. Part of the reason for

the relatively underdeveloped state of wastewater treatment control is the difficulty

in obtaining accurate process information. In addition, many key variables must

be measured offline. This has prompted recent work in wastewater treatment plant

state estimation (Tenno and Uronen, 1995; Jorgensen et al., 1992). With rapid

improvements being made in sensor technology, the information deficit problem

is disappearing. Furthermore, faster processing capabilities, which have been so

crucial to the application of control as a discipline, are now allowing nonlinear









13


process control and dynamic optimization techniques to be applied to problems as

large as a wastewater treatment facility.

The challenging operating environment coupled with response dynamics

ranging from minutes (DO) to weeks (SRT) has resulted in a great deal of advanced

control work having been done in simulation, but very little in wastewater plants

themselves.

















CHAPTER 2
AN INEXPENSIVE METHOD FOR THE AUTOMATION OF LAB-SCALE
BIOREACTORS

2.1 Introduction

Bacterial growth experiments may last several di-,v or even weeks. During

this time it may be necessary to adjust bioreactor operating parameters, which

requires either the attention of a researcher, or an automated control system. We

have developed an inexpensive system for continuous absorbance measurements

using flow-through spectrophotometers and solenoid valves under the control of a

Visual Basic program. This system periodically samples a bioreactor, measures the

biomass absorbance and then rinses the sample line between measurements.

2.2 Materials, Methods and Results

A layout sketch of the experimental apparatus is given in Figure 2-1.

Batch culture experiments were carried out in a stirred bioreactor (\ IIi :-gen

model F-2000, New Brunswick Scientific, New Brunswick, NJ). The bioreactor

was cycled between aerobic and anoxic conditions to explore diauxic growth of

Pseudomonas denitrificans (American Type Cultures Coi,!i lrt 13867, Manassas,

VA). The cycling was accomplished by alternately sparging the culture with air

and nitrogen from pressurized cylinders. The switching between these gases was

accomplished using two computer-linked solenoid valves, one on each feed line.

Gases were sterilized by filtration (0.22 micron Whatman HEPA-Vent filters) and

pre-humidified by sparging through sterile deionized water before introduction to

the bioreactor.

Biomass was sampled from the bottom of the bioreactor through 0.03 inch I.D.

Tygon tubing (\! i-terflex 06409-13, Cole Parmer, Chicago, IL). The reactor effluent

14











Legend
Fluid
Power .Control -- Gas
-Rei -Reay -- o Data

rnpamp
...... ..e.... ... .........





i te Spec with
Flow-Through
Cell
J- Wetting r


Bioreactor Rinsing Waste
Solution

Figure 2-1: Automation system Process and Instrumentation Drawing (PID)


flowed to a 4.5 L clarifier (25 mm ). The biomass passed through a flow-through

cell in a spectrophotometer (Thermo-Spectronic Genesys 10UV, Thermo Electron

Corporation, Waltham, MA). This spectrophotometer is relatively inexpensive

and supports communication with a personal computer. The tubing end in the

bioreactor was bent upwards to prevent gas bubbles from entering the sample

line. (Bubbles tended to become trapped in the spectrophotometer flow cell.) The

spectrophotometer was inclined at 3 degrees to help bubbles pass through the

flow cell. A computer-linked 3-way stainless steel solenoid valve (Parker/Skinner

3133BSN1ANOONOM1S1PO, Parker, New Britain, CT) controlled whether sample or

a rinsing solution reached the spectrophotometer.

A i i, Pr problem of the sampling system was accumulation of biomass on the

inner walls of the flow cell. This caused the measured absorbance to increase with

time, regardless of the true sample absorbance. Higher flows failed to shear biomass

from the wall and, in fact, exacerbated the problem. In response to this, a rinsing











system was added. In this system, a solenoid valve switches the sampling line feed

to a rinsing solution after a measurement is made by a spectrophotometer.

Initially, sodium dodecyl sulfate solution was used for rinsing, but it was found

that the SDS itself accumulated on the walls of the cuvette, compounding our

biomass accumulation problem with soap scum. We next tried deionized water,

but found that it yielded only a small improvement over no rinsing. We ultimately

found that a solution of 50 mg/L chlorine in water (1+1999 dilution of 10.5'.

sodium hypochlorite) substantially limited accretion of biofilm within the flow cell

without causing any other problems. Figure 2-2 shows two typical runs, one rinsed

with chlorine solution and one without rinsing. Both of these sets of data were

taken from the same bioreactor so that, in the absence of biofilm accretion, they

should be identical. The rinsed data alternated between measurements of biomass

and measurements of rinse solution. As seen in the figure, the measurements

taken of the rinsing solution remained very near the baseline (zero absorbance)

throughout the experiment. If there were accumulation of biofilm inside the

instrument, we would have observed an increase in absorbance of the rinse solution.

The measurements of biomass absorbance taken in this instrument can therefore

be considered to be free of systematic errors caused by accumulation of biofilm.

In contrast, the measurements taken without rinsing are substantially higher than

the measurements with rinsing. This -i.--i:. -1 an accumulation of biomass on

the walls of the flow cell of the unrinsed spectrophotometer and, in fact, biofilm

and particulate matter were observed in previous experiments that used unrinsed

sample paths.

When the system is switched from rinsing solution to reactor effluent it

takes approximately 8 minutes for the measured absorbance to match that of

the bioreactor. To be safe, the entire measurement cycle was set to 30 minutes:

15 minutes of rinsing, at which point a measurement is taken to check for flow










17

2.5

xx
2.0- x
X*
x

2.- unrinsed biomass x x
a 1.5- measurements x ,
o x
x *
o 1.0 biomass measurements in
U spectrophotometer with rinsing
0
S0.5
U x* measurement of
xxx x x x rinsing solution
0.0 -Xxg 6x jfjx6xgx ,X X a x 8 .. ..
2 4 6 8 10 12

-0.5
time (hr)

Figure 2-2: Effect of rinsing sample path on biomass measurements


cell accumulation, followed by 15 minutes of reactor biomass and a reading to

determine reactor biomass concentration.

There were a few cases in which biofilm accumulation in the flow cell was not

completely eliminated. By taking measurements during the rinsing phase we have

a way to track the accumulation of biomass on the wall of the quartz flow through

cell. This value can be subtracted from the sample measurement to give the

suspended biomass contribution. This system has been shown to work acceptably

at absorbances as high as 1.5 at 550nm (1035 mg dry wt./L), and for our typical

operating range of 34-270 mg dry wt./L (Abs 550nm 0.05-0.40) it works very well.

A personal computer running Microsoft Windows 98 coordinated the valve

positions and spectrophotometer measurements using a control program written

in Microsoft Visual Basic 6.0. Communication with the spectrophotometer was

through a serial port. The program controlled the solenoid valves through a USB

control relay (J-Works JSB210-16, Granada Hills, CA) that, in turn, operated a

power relay(24V AC). The program also collected and dip1 i'- 1 data and enabled

the user to set experiment parameters (e.g. duration, sampling period, rinsing











period, gas control logic). A flow sheet of the program and its source code are

posted at http://www.ees.ufl.edu/homepp/koopman/hamiltonetal/.

The program communicated with the spectrophotometer using the mscomm

Visual Basic control, which provides simple access to serial ports. The computer

sent a PRINT string to the spectrophotometer whenever a measurement was

required. The spectrophotometer then returned a string containing the date, time,

wavelength and absorbance.

A challenge in writing the code was the indeterminate delay between the

request for a measurement of absorbance and the receipt of the string containing

that measurement. This was overcome using the OnComm event of the mscomm

Visual Basic control. This event is tl ii-_-. Id on receipt of data and then signals

the program to process the received data by calling a user written method (named

OnComm) of the mscomm object. This method extracts the absorbance from the

received string and stores it in a variable. The program periodically checks whether

this variable contains a number (it is reset to null in between measurements).

The USB control relay unit is manipulated using a set of pre-defined functions

provided by the manufacturer. These functions are part of a pre-compiled dynamic

link library (.dll) file. The functions are called to execute hardware level commands

that send data across the USB cable to the control relay unit. The control

functions are accessed by including a provided module, JWorksR. 1 i- Module.bas, in

the Visual Basic project. An example of the use of the provided functions is given

in the following code fragment, which uses the IsModuleR. 1 ,i-Off function to check

whether the relay for nitrogen (valveNitrogen) is closed and, if so, opens the relay

using the ModuleR. 1 ,i-On function. The vbNullString argument of these functions

is null if the computer is communicating with a single control relay unit and is

replaced with a string containing a serial number to specify a particular relay unit

in the case of multiple units.















PIe Tools About
;r.-n r .irmrnI | Abo m Eprm1- It| Sgtgwe Enpsimwmel t Iv a4 r

E i. Slat Ah*amec&a* OS2 434 NJA
1rV1aAM 1a4 na 1M2 oP F2 ..
TVl4 FI- -! b b---ww*r OFF

Dt
Ep. End: RIse im 120 OFF
1I23MM4 Sangph tfT-; 15 1 OFIF




I* Iiil il I f 2I3 10 T B 101 100 0 -
a31.T1777d 7 3A 3 a U. f2 a971 100 100 0
391134*99l 0L34 311 97 0 a .
MI 3a -I If 1393 al31 094 0 a 0
1% 6(I6 033O 024 0 0 0 5. 100
55t5555u 0%353 O K2 Q24Z 0 0
6O IT111 137M 0329 f25 0 0 0 Z
t S(E38B CL385 0337 02S D 0 0 2
?'oS44"4I 94W07 a I 29 8 4 0
7.5~7 0.14 0371 oi 11 0 0 0 0.2 40
U11.4ti B L54 0 0 39 0 0 0 0
a lt il1l 0517 0411 3-39 D 0 0 0
0i li5)2 B 401_512 3_ 0 ( _



Figure 2-3: Software interface including current status and measurement history



If IsModuleRelayOff(vbNullString, valveNitrogen) Then

Call ModuleRelayOn(vbNullString, valveNitrogen)

End If

The interface of the program (Figure 2-3) gives the status of the gas/sampling

system absorbancee, type of gas in use, type of fluid in rinse/sample line, length

of rinse phase, length of sample phase, time until next absorbance measurement,

elapsed time of experiment) in up to 3 reactors. It also shows plots of absorbance

and aeration status versus time, as well as a log of data being written to a

file. Another function of the interface is to allow real-time changes to control

parameters. Figure 2-4 shows a different screen that allows parameters for up to

three reactors to be entered.

A noteworthy feature of the software is its capability to send email automatically.

Using the MAPIMessages and MAPISession controls in Visual Basic, a function

was written that would send the current spectrophotometer measurement to a list

of email addresses. When combined with wireless messaging, this provided a means

of alerting remote users by mobile telephone to key changes in system status.

































Figure 2-4: Experiment configuration screen


Another useful resource is the freely available software WinVNC that allows

the user to remotely monitor and administer the lab computer. This was very

useful during experiments that required manual intervention after a long and

variable bacterial growth phase.

The components of the gas and rinsing control system are listed in Table 2-1,

along with their prices. The total system cost for parts was approximately $4500.

The system is easily scaled to multiple bioreactors. For example, we are currently

using it with three bioreactors and three spectrophotometers. This required the

addition of a USB device (Keyspan USB 4-Port Serial Adapter) for additional serial

ports.

2.3 Conclusions

The automated, on-line sampling and measurement system has proven to

be very successful in our experimental work. We currently observe only 1-2 bad

measurements absorbancee spike due to bubble entrapment or trapped particulate

material) in a 14 hour experiment (28 biomass measurements). Thus, using


Setup Experiment
Reaclol 1 F '.. : F. i ... E... i F ,.
T.. Ial,1 ... F In [ 1 Communicalinn Sellings
i '.. ,,,lI -,, [ .. .., ...

S ': ,1" ,1- '_ :i 3 .- iP ,, .




F'"" "U i' 1 -i U 3 i'




17 IJse Reaclol 1 r IJse Reaclom 2 IJse Reaclom 3
-II,.., =,'l"':' 1-,,












Table 2-1: Equipment list


Name
J-Works Relay
Spectrophotometer
Windows computer
3-Way solenoid valve
Tubing pump
Power Relay


Manufacturer
J-Works
Thermo-Spectronic

Parker


Model #
JSB210-16
Genesys 10UV

3133BSN1AN00N .. !S1PO


made in shop


Price
'._' I ,
$3300
less than $500
$20
less than $500
$10


information provided in this paper, it is possible to assemble an effective continuous

sampling and measurement system that functions over extended time periods

and requires only a modest investment. In addition to providing a measurement

record, this system could also be part of an automatic process control system

with the addition of a statistical data filtering technique for discriminating bad

measurements.

















CHAPTER 3
A STRUCTURED MODEL FOR DENITRIFIER DIAUXIC GROWTH

3.1 Introduction

Removal of biological nitrogen is an important operation in wastewater

treatment. Biological nitrogen contributes to eutrophication of bodies of water and

has also been linked to disease in humans (Ramalho, 1983). Nitrogen removal is

commonly accomplished in a two step activated sludge process. First, aerobic

autotrophs oxidize ammonia to nitrate, then facultative anaerobes reduce

this nitrate to nitrogen gas. This process involves exposing a mixed culture

of microorganisms to an environment in which the terminal electron acceptor

alternates between oxygen and nitrate. This can result in the phenomenon of

diauxic growth.

Diauxic growth occurs when a preferred growth substrate is exhausted and

a period of little or no growth occurs. During this period necessary enzymes are

synthesized that allow growth on the less preferred substrate. Diauxic growth

was first characterized in detail by Monod (1942) in the case of changing electron

donors. Later Kodama et al. (1969) observed that diauxic growth also occurs when

switching terminal electron acceptors. More recently several investigators (Waki

et al., 1980; Liu, Zhan, Svoronos and Koopman, 1998; Liu, Svoronos and Koopman,

1998; Gouw et al., 2001; Lisbon et al., 2002) have studied the particular diauxie

occurring when bacteria switch from oxygen to nitrate, which is known to occur

with biomass from an activated sludge process used for denitrification (Liu, Zhan,

Svoronos and Koopman, 1998).











The quality of model used in process design for denitrification can have

profound economic implications. Various models for biological denitrification have

been proposed. The Activated Sludge Models 1, 2, 2d and 3 (Henze et al., 2000)

are widely used in industry but do not portray the phenomenon of diauxic lag. The

cybernetic modeling approach of Liu, Zhan, Svoronos and Koopman (1998) as well

as modifications of this approach (Liu, Svoronos and Koopman, 1998; Casasis,

2001) are able to portray diauxic lag. These models were developed, in part,

from an optimization approach that assumed that bacteria are optimal strategists

(Ramkrishna, 1983). A more mechanistic approach considers intracellular variables

as well as substrate concentrations in solution. In this paper we present a model

for diauxic growth in which the cybernetic kinetics are replaced with an approach

based on regulation of enzyme synthesis and active transport of nitrate into the

cell. There is evidence for the existence of a nitrate transport protein in several

species of nitrate respiring bacteria (Berks et al., 1994; Moreno-Vivi&n et al., 1999).

3.2 Model

Baumann et al. (1996) found that in an oxic / anoxic cycling system the

concentrations of intermediates (NO2-, NO, N20) were significant when the system

was first to subjected to cycling, but subsequently declined in magnitude. Thus

the conversion of nitrate to nitrite can be inferred to be the rate limiting step. In

practice, nitrite concentrations within periodic processes for nitrogen removal are

usually quite low (well below 1 mg/L). For this reason, the ASM models consider

only nitrate as electron acceptor in denitrification (Henze et al., 2000), and this is

also the case for the model developed here.

The presented model is based on the biochemical process shown in Figure 3-1,

which shows that nitrate (NO3) is actively transported into the cell by transport

protein T. Internal nitrate binds to repressor R, freeing operator 0 which then

allows transcription of the nitrate respiration operon resulting in synthesis of the











DNA

R

NO3 NO3
















is that nitrate (N3 ) is actively transported into the cell by transport protein T.

Internal nitrate binds to repressor R, freeing operator 0. Synthesis of the nitrate
reductase, nar, and transport protein proceeds at a rate proportional to the amount
of free operator. We assume the existence of a nitrate respiration operon, and that
the transport protein and nitrate reductase are therefore synthesized together.
nitrate reductase (na) and transport protein. The rate of synthesis of na and
nar ( ^ ^^^


Cell
membrane

Figure 3-1: Biochemical Process Model. The biochemical process being modeled
is that nitrate (NO,) is actively transported into the cell by transport protein T.
Internal nitrate binds to repressor R, freeing operator O. Synthesis of the nitrate



reductase, nar, and transport protein proceeds at a rate proportional to the amount of free operator. Since we assume
of free operator. We assume the existence of a nitrate respiration opero it n,llows that transport protein
the transport protein and nitrate reductase are therefore synthesized together.

nitrate reductase (nar) and transport protein. The rate of synthesis of nar and
transport protein is proportional to the amount of free operator. Since we assume
the existence of a nitrate respiration operon, it follows that transport protein
and nitrate reductase are synthesized together. In this case the concentration of

transport protein would be proportional to the concentration of nar provided that
their decay rates are similar. The regulation scheme that underlies the presented

model follows that described by Yagil and Yagil (1971), in which enzyme synthesis
is proportional to the concentration of unbound operator. A schematic model
diagram is shown in Figure 3-2.











Cell

SN S. S XB
+ +



Figure 3-2: Model overview. Uptake of nitrate, SN,results in an increased level of
internal nitrate, si. This promotes synthesis of nitrate reductase, e,, which in turn
promotes synthesis of new biomass, XB, and increases the rate of nitrate uptake.


Under anoxic conditions the cell takes up nitrate from the environment. The

rate of uptake is influenced by the concentration of nitrate reductase in the cell.

The internal nitrate stimulates the synthesis of nar, which allows anoxic growth and

promotes further nitrate uptake.

The variables for biomass, XB(gdw/L), organic substrate Ss (mg/L) and

extracellular nitrate SN(mg/L) are expressed as volumetric concentrations, whereas

the intracellular variables nitrate reductase activity, e(katals/gdw), and internal

nitrate concentration, si (mg/gdw), are expressed per dry weight of biomass.

The rate expressions of this model utilize multiple Monod type expressions in a

manner analogous to the IWA series of activated sludge models Henze et al. (2000).

The processes modeled are:

1. The rate of synthesis of nitrate reductase, denoted r,,, follows the kinetics

described below. These kinetics are derived from the synthesis model of Yagil

and Yagil (1971), as shown in Appendix A. The particular repression model

used is the case of a single effector molecule binding to a single repressor

molecule. According to this model, K1 is the equilibrium constant for the

binding of repressor to an inducer molecule (internal nitrate). K2 controls

the constitutive rate of enzyme synthesis and is a function of the equilibrium

constant for the binding of the repressor to the operator. An addition to the

approach of Yagil is a Monod term for organic substrate dependence. This











represents the dependence of the rate of active transport on the concentration

of organic substrate.

( 1 + Ksi Ss (3.
ren =aN K+in,,--- ^ --+S- ) (3.1)
nK2 + KSi/s Ks,an +Ss(

2. Oxic growth is described by the kinetic expression Henze et al. (2000)


tox = pmax,ox Ks.o + Ss KoH + S (3.2)

3. The specific rate of uptake of nitrate is proportional to the concentration

of nitrate reductase, e,. (This approach is analogous to that taken by

Shoemaker et al. (2003) for modeling diauxic lag when switching carbon

sources.) Uptake is inhibited by the presence of oxygen, So (Berks et al.,

1994; Moreno-Viviin et al., 1999). The energy dependence of active transport

is modeled by including a Monod term for organic substrate in the rate

expression.

v en S IKoi s
rsni = VSni +-NO ) ( So] e. Ss (3.3)
en,max SN + KNOi Koi + So Ks,a + Ss

4. Anoxic growth is proportional to internal nitrate, sTi, and nitrate reductase,

e,. An explicit switching function for oxygen inhibition is unnecessary

because the presence of oxygen decreases the rate of nitrate uptake and

ultimately the intracellular nitrate concentration.


ranox fmax,anox en 1 a J ( S s ) (3.4)
en,max / \sni,max / Ks,an + S /

5. The specific biomass decay rate (b) is assumed to be constant.

6. The specific rate of enzyme decay (bNo) is assumed to be constant.

Performing a mass balance on a batch reactor using these rates yields the following:


dXB
=(ro, + renow b)XB (3.5)













dSs 1 1 X
S- t-ro -ranox) XB (3.6)



dSN
dt Y 1 c,ox can /


N -rsnXB (3.7)
dt


de, 1 dXB
re, b + bNO + en (3.8)
dt XB dt T


ds, 1 dXB
dT- ,i N,ansanox- + ) Sni (3.9)
dt XB dt )
In Equations 3.8 and 3.9 above, the last term represents dilution due to growth

and cell decay. The yield constants Yc represent the amount of biomass that is

synthesized per unit organic substrate consumed. The constant VN,an represents the

nitrate required per unit biomass synthesized during anoxic growth. The nitrogen

source for biosynthesis is assumed to be ammonia.

The theoretical maximum values of s,, and eT can be found by setting the time

derivatives for these variables to zero and assuming non-limiting concentrations of

organic substrate and nitrate.


Vs i
Sni,max N,an (3.10)
P-max ,anox


SNv 1 + Kisni,max ( (t1)1
%nmax b + bNo K2 + Kisni,max (3.11)

In view of Equation 3.10 Vsni > VN,anP.max,anox.

3.3 Materials and Methods

The experiment consisted of growing Pseudomonas denitrificans (ATCC

13867) under conditions designed to induce diauxic growth. After growing under

aerobic conditions the oxygen was stripped from the reactor by bubbling nitrogen











Table 3-1: Synthetic media composition. pH is adjusted to 7. Trace metal solution
contains 0.5'. w/v CuSO4, FeCI3, MnCl2 and NaMo04 2H20.

Ci. ii, ,,, Conc. (g/L)
sodium chloride 1
ammonium chloride 1
magnesium sulfate li, 1l I,!:.drate 0.2
calcium chloride dihydrate 0.0264
L-glutamic acid 6.77
potassium phosphate (monobasic) 5
potassium phosphate (dibasic) 1.5
trace metals 1 drop


gas and nitrate was added as the alternative electron acceptor. This resulted in a

lag followed by a period of anoxic growth. The dissolved oxygen was assumed to be

near saturation under aerobic conditions and zero under anoxic conditions. During

the experiment the enzyme level was measured using a viologen dye colorimetric

I1" li-.

3.3.1 Bacterial Strain and Growth Conditions

Freeze dried P. denitrificans (American Type Cultures Company 13867,

Manassas, VA) was revived in nutrient broth (Difco #0002-17-8) for 2 d,'i in a

shaking incubator at 35C. The culture was stored at 4C on agar plates (Sigma

#T-4536) for up to 2 weeks. Prior to each experiment the plated bacteria were

cultured without nitrate in 125 mL of synthetic media (Table 3-1) in a 250 mL

Ei. i i- *, v, rflask. The culture was kept at 350C in a shaking incubator for 24

hours.

At the beginning of each experiment the culture was transferred to a

continuously stirred bioreactor (\!11i gen Model F-1000 or F-2000, New Brunswick

Scientific, New Brunswick, NJ) containing synthetic media. The initial absorbance

in the bioreactor was 0.1-0.12 (69-83 gdw/L). Air was sparged into the reactor

during the initial aerobic phase, and dissolved oxygen was assumed to be near

saturation based on previous studies (Liu, Svoronos and Koopman, 1998). In











runs in which the absorbance reached 0.6, the culture was diluted during the

aerobic phase in order to remain in the linear range of the absorbance-biomass

curve (0-1.0). Dilution was accomplished by rapidly pumping out a fraction of

the reactor contents and aseptically replacing it with fresh nutrient solution.

After approximately 3 hours of exponential growth the aeration was stopped and

dissolved oxygen was stripped by sparging with nitrogen gas. Nitrate solution (4000

mg/L NO3-N) was added to give a total concentration of 40 mg NO3-N/L.

The anoxic phase was monitored until substantial exponential growth was

observed. Reactor contents were continuously withdrawn and passed through a

spectrophotometer (Thermo-Spectronic Genesys 10UV) to monitor biomass density

absorbancee at 550 nm).

Nitrite accumulation can occur under some conditions (Kornaros et al., 1996)

and result in reduction of growth rate. However, nitrite measurements from our

previous studies under similar conditions showed that the concentrations were

below 1 mg/L, which is well below the threshold for toxic inhibition of bacteria

(Weon et al., 2002).

3.3.2 Nitrate Reductase A--.

Cells were harvested by centrifugation (10,000 g for 10 minutes at 4C) and

washed with 20 mM Tris buffer (pH 7) before being resuspended in 2 mL of the

same buffer. Cell suspensions were used within 10 minutes of preparation. The

volume of cells sampled was varied to obtain approximately 4 gdw.

The .-- li- method was modified from Jones et al. (1977). The reaction

was performed in a 1-cm optical path borosilicate cuvette with a Wheaton seal.

Reagents were added in an anaerobic chamber (Coy Laboratory Type 'A', Grass

Lake MI), leaving no head space. After adding reagents and bacteria the final

concentrations were 0.3 mM benzyl viologen and approximately 55 mg/L dry

weight of bacteria. Sufficient dithionite was included in the reaction mixture to












reduce the benzyl viologen to a final absorbance of 1.8 at 550 nm. Several 3 mm

glass beads were added to the cuvette to facilitate mixing. The absorbance was

monitored for 3 minutes, then the reaction was initiated by injecting nitrate into

the cuvette (through the seal) to a final concentration of 6 mM. The cuvette was

then inverted twice for mixing and the absorbance of the reaction mixture was

measured for 5 minutes. The initial rate of decolorization was determined from

these data.

We performed a study on reproducibility, and for 6 measurements the standard

deviation was 2E-10 katals.

3.3.3 Parameter Estimation

Values for the model parameters were obtained by fitting simulation results to

experimental data. The fitting was performed using the following weighted least

squares performance measure



1 N
J = 2 > (XB,nmeas,i XB,pred,i
JXb i=1
i M
+ 29 (Cen,mneas,i n,pred,i
en i=

The weighting factors are the variances of the experimental measurements

(cb = 5 x 10-3 and aJ = 4.3 x 10-19 ). The performance measure J was

minimized by adjusting aN, K1, K2, Vs4, Koi, KNOi and bNo. In fitting data from

a previous experimental study (Liu, Svoronos and Koopman, 1998), for which

enzyme measurements are unavailable, the initial value of enwas also fit. The

maximum growth rate parameters /max,ox and /max,anox were found from the slopes

of semilog plots of absorbance versus time.











3.4 Results and Discussion

We first tested our model's ability to fit previously published data from

a study by Liu, Svoronos and Koopman (1998), in which they evaluated the

effect of the aerobic period length on the subsequent diauxic lag. A pre-culture

of P. denitrificans was split between two reactors. In one, bacteria were grown

aerobically under batch conditions with 40 mg/L nitrate for 1.1 hours. Aeration

was then stopped, and nitrogen was sparged into the reactor to strip residual

oxygen from the media. The growth results for this experiment (Figure 3-3a)

show a diauxic lag of 3 hours. The parallel reactor was aerated for a longer time

(2.6 hours) and the subsequent diauxic lag was also longer (6 hours) as shown in

Figure 3-3b. The present model captures the exponential growth behavior during

the aerobic phase and anoxic phase and closely matches the diauxic lag between

these phases in each of the parallel reactors. According to the model, the effect of

aeration period length on lag is due to the dilution of nitrate respiration enzymes

by biomass growth and enzyme decay. The model parameters for these experiments

were found by simultaneously fitting both experiments and are shown in Table 3-2.

Although the quality of model fit with previous data was encouraging, a

more rigorous test of the model required simultaneous enzyme and biomass data.

Experimental results, model fits, and modelled intracellular nitrate concentrations

are shown in Figure 3-4 for one of our experiments. The initial enzyme activity in

this experiment was very low. Thus, despite a relatively short aeration period of 2

hours, a substantial diauxic lag of 11 hours was exhibited by the culture. The end

of the diauxic lag coincides with a rapid increase in enzyme activity. The modeled

values for intracellular nitrate (Figure 3-4b) show that the end of the diauxic

lag, as well as the rapid increase in enzyme activity, are coincident with a rapid

rise in intracellular nitrate concentration. The significance of intracellular nitrate

concentration to enzyme activity and, ultimately, biomass growth is explained in































L0


1o 10- 10 0
0 0 t^t^ 0


c03


Co
-- -- M







V
m mD
mb m


V
t-

000







to-

coo
000


2 6


0i -0 0






b aO bOb babac
a~ a a a a


00
cY3


0 0


-co




c I
b-
^~^
^^ --

^ *
r ^ ^
1 CJ


0
o^


00


a a

i _
0^ 0






bL Co bL >^
frr

00
>. >.c?
>< C >; u .
o a o ^ r


rbO
a" a
2 .2

Q k

t M
co
Sm,

u -



0
a Q


000
0,
go
ooe


,--

m









co
0




















u
Oc
































a0
r




cb0

























qP >


H ci
oe~O
oioiO~












33


a) 50
. . . . . . . . . .... .. .. .. ..... . . . t 4 5

2545
40
026
A "*- 35
30
o A 25


010
15

0 biomass (experimental) biomass (model)
A nitrate (experimental) ------nitrate (model) 5
007 0
0 2 4 6 8 10 12
Time (hr)
b) 015 50
0 14 A--.. -..... .--- .................. 45
""""---.. 40

35
o 012 30
S011 25
S010 20
o o 15
009
10
008 O biomass (expermental)- biomass (model)
r0 A nitrate (experimental) ------nitrate (model)
007 0
0 1 2 3 4 5 6 7 8
Time (hr)


Figure 3-3: Model fit to Liu, Svoronos and Koopman (1998). Data points show

experimental results; dashed and solid lines show model fits. Nitrate was present at

the beginning of the experiment at a concentration of 40 mg/L NO3-N.



terms of the model as follows. Enzyme activity is initially very low, consequently


the rate of nitrate transport into the cell (after the anoxic period begins) is also


low. As a result, there is only slight accumulation of intracellular nitrate for


several hours after the beginning of the anoxic period. Finally, when the nitrate


concentration begins to build up (and, hence, enzyme biosynthesis accelerates due


to derepression of the operon by nitrate), exponential biomass growth resumes. The


parameters for the fit in Figure 3-4 are shown in Table 3-2.


Data from a second experiment are shown in Figure 3 5a) along with model


fits using the same parameters. In this case, the model captured the aerobic


exponential growth, both before and after dilution, the anoxic exponential growth,


the diauxic lag, and the buildup in enzyme activity immediately preceding the end


of the diauxic lag. Good model fits were obtained for a third set of experimental


data (shown in Figure 3 5b) but required changing two parameters in order to














34

























a) 05 4 OE-09
--- bomass (model) o biomass (experimental)
enzyme (model) enzyme (experimental) ,3 35E-09

04 /FO 30E-09
/0



_1 5E-09
0 2 0E-09
2 03 4Jo 2 OE-09


o o
I I






0 10 15
Time (hr)
b) 1 8E-05E-09
01 0 OE+00
0 5 10 15
Time (hr)
b) 18E-011 ---^---
-- intracellular nitrate
1 6E-01
1 4E-01
1 2E-01
1 OE-01
8 OE-02
S6 0E-02

4 0E-02
2 0E-02
0 OE+00
0 5 10 15
Time (hr)



Figure 3-4: Enzyme activity during diauxic growth. Data points show experimental

results; dashed and solid lines show model fits. The biomass grew exponentially

during an initial 2.5 hour aerobic phase. Nitrate was added to a concentration of

40 mg/L N03-N at the start of the anoxic phase. This was followed by a lag of 11

hours. The enzyme level was increasing during the lag phase.







































a) 12 1 6E-09
---biomass (model) o biomass (experimental)
enzyme (model) enzyme (experimental) 1 4E-09
10
1 2E-09
08
0 t 1 0 OE-09
S06 8 OE-10

04 I
I 4 0E-10
02- ^ / /
02 20E-10

0o 0 0o OE+00
0 5 10 15 20 25 30
Time (hr)
08 4 OE-09
b) --- bomass (model) o biomass (experimental)
0 7 enzyme (model) enzyme (experimental) 3 5E-09

06 3OE-09

S05 2 5E-09

S04 I 2 OE-09
S/ E
3 / o o 5E-09

02 / I 1 OE-09

01 I 50E-10
1-1 T
00 0 OE+00
0 2 4 6 8 10 12 14 16 18
Time (hr)


Figure 3-5: Additional experiments with model fits. These experiments included

dilution during the aerobic growth phase to ensure that absorbance ,i,- Id within

the range of linear measurement. Nitrate was added to a concentration of 40 mg/L

NO3-N at the start of the anoxic phase. The sharpness of the enzyme activity curve

in figure b results from the lower magnitude of parameter K2.











obtain a good fit (Table 3-2). The original model parameters would have predicted

a longer lag and lower reductase activity at the end of the aerobic phase.

Before the use of the proposed model is considered to improve design and

operation of nitrogen removing wastewater treatment plants, the range of

conditions under which the diauxic lag phenomenon occurs needs to be more

fully studied. For example, Kornaros and Lyberatos (1998), continuing earlier work

on the kinetics of denitrification (Kornaros et al., 1996; Kornaros and Lyberatos,

1997), failed to observe diauxic lag of P. denitrificans growing on glutamic acid

when the bacteria were transitioned from oxic to anoxic conditions. Notably,

these experiments involved high (374 mg/L) nitrate nitrogen concentrations in

pre-culture, aerobic, and anoxic growth phases, whereas in the present work nitrate

was absent during the aerobic phase. Monod (1942) remarked that diauxic lag

does not occur in all substrate transitions, particularly when the less preferred

substrate is present in high concentrations. Previous studies (Liu, Zhan, Svoronos

and Koopman, 1998; Liu, Svoronos and Koopman, 1998; Gouw et al., 2001;

Lisbon et al., 2002) have not investigated high nitrate concentrations throughout

the growth cycle, because the nitrate concentrations that occur in municipal

wastewater treatment plants are much lower.

3.5 Conclusions

We have modeled diauxic lag as resulting primarily from nitrate transport

limitation. This was achieved by combining Yagil type enzyme synthesis kinetics

with a model structure that uses intracellular nitrate as the inducer for an operon

coding for nitrate reductase and nitrate transport enzyme. This approach was

successful in fitting data on biomass from the literature, as well as data on

biomass growth and enzyme data collected as part of the present study. The

nitrate reductase synthesis dependence and coupled nitrate transport limitation

explains the dependence of lag length on aeration time, the cessation of anoxic









37

growth in the presence of oxygen, as well as the observed nar enzyme activity

profile during diauxie. Thus it may be concluded that a model based on enzyme

biosynthesis regulation can be successfully applied to portraying diauxic growth due

to switching of terminal electron acceptors.



























-4-





0 -
oo










L00










0000







I I
0- m m U
"3 .3 ^ ^
.a .a g g


mm







b- C i i
5 z5oo

~~Ob ~bL


a m
m m


co o



c t S a m t S

b-C b- bjC s -b





b-C
m nm 20 m 0





bjO bjO bj bjL bO
r- c' E 3 c cc c ct
SbLA bC


0 0
-4) -4)

^ m m


m m m



co 3 o m.
r -C b- C



c~Ecbcbc
.9 bob
-o o .2o > "








b-C

bLc bL bLQ bL~ bLl bn
Sb- tb -


Se e oC 0
e^^~~~~~ a3ez a3 ^ ^ze>T ^oow^o^^>< >-


m
m
s 0
0
* -



0 1
0 0



I I
O O
o

m" e




km








bi o
^ 2 S m
^S^

bD b a a




0; 0 0 0 *-




0 0 0 0 bO
m m m m 0 o
?- n0 ?i^^ '' -
b0 ^bO g ^
m0 0c ^ "'
m m m n' Co ^-i
co ^co ^
m SmS O


O



rj

cb

0 0
o

k mm
Sc co




m
m m m

co ^i -
ca c c
!
0 ^0 -
' -
u u
trimrtr


S


-c4
m 4 0










0 0








0-4
SN0






o t c'
0" .2

.5^1l
^3 c ^


r^







oa
b0
m
m
mm0






0 g











04-1
II'1




*t t3 c


m
m
cI
a






41
A I.










3.6 Enzyme Synthesis Expression Derivation

In the following derivation, repressor is denoted R, inducer (e.g. nitrate) is
denoted I, and operator is denoted O.
According to the model, inducer binds to free repressor.


[R] + [I] [RI] (3.12)

This shifts equilibrium between bound repressor, RO, and free repressor.

[R] + [O] 4 [RO] (3.13)

Note that, even in the absence of inducer there will ahlv--, be some unbound
operator, according the above equilibrium. Consequently the constitutive rate of

enzyme biosynthesis will be non-zero.
The total amount of repressor and operator is the sum of free and bound

species

[R] [R] + [RO] + [RI] (3.14)

[,]= [0] + [RO] (3.15)

The rate of nitrate reductase synthesis, r, is proportional to the concentration of
free operator.

r k,[] (3.16)

Therefore we are interested in finding the equilibrium concentration of O. From
Equation 3.13
[0] 1 1
[RO] k2 [R]
By applying Equation 3.15 we obtain

1
[O] [O] ] (3.17)
1 + k21Rl










In a similar fashion, manipulating Equation 3.12 and assuming [RO] < [Rt] yields

[R] = [R (3.18)
1 + ki[l]

Substituting Equation 3.18 into Equation 3.17we obtain

1 + ki] (3.9)
[0] = [Ot] (3.19)
(1 + k2[Rt]) + ki[I]

which results in the rate
1 + ki [I]
r = aN
S 2 + k [I]

with
aN = k,[Ot]

K2 (1 + k2[Rt])

The constitutive enzyme synthesis rate is obtained by setting I =0:

r =kr[ t]
(1 + k2[Rt])

















CHAPTER 4
ESTIMATION OF NITRATE REDUCTASE ENZYME PARAMETERS IN
ACTIVATED SLUDGE USING AND EXTENDED KALMAN FILTER

4.1 Introduction

Efforts to control bioreactors are made more complicated by the fact that

intracellular variables that can dictate system behavior are frequently difficult or

impossible to measure on-line. For example, low levels of nitrate reductase when

switching from oxic to anoxic conditions can result in a diauxic lag (a period

of little or no growth). The need for improved models for denitrifier diauxic

growth is discussed in Wild et al. (1994) and Liu, Svoronos and Koopman (1998).

Established models for growth of denitrifiers (Henze et al., 2000) can be improved

upon, especially with respect to enzyme kinetics. Doing so, however, introduces

parameters that cannot be fit independently (Wild et al., 1994). Both bench and

plant scale experiments will typically have some measurements available, but

not enough to fix the enzyme related model parameters. This paper presents an

approach for estimating denitrification enzyme parameters using an extended

Kalman filter (EKF) on plant-scale operations.

A Kalman filter is a technique for determining optimal estimates of the values

of state variables (such as biomass density and pH), including unmeasured or

infrequently measured state variables (e.g. enzyme activity) and model parameters.

The estimation algorithm is based on a limited set of noisy measurements. This

technique has relevance in the area of wastewater treatment due to the impact

that unmeasured intracellular components, such as polyphosphate level and nitrate

reductase activity, have on facility performance.











Previous studies have used Kalman filters to estimate state variables and

biological model parameters. Stephanopoulos and San (1984) proposed the use

of an extended Kalman filter for estimating specific growth rates. Later work by

Ramirez (1987) and ('! il I ,Vay and Stephanopoulos (1989) used the Kalman filter

along with the sequential parameter updating strategy of Ljung and Soderstrom

(1983) for both state and model parameter estimation. This strategy has been

used by Park and Ramirez (1990) for control of nutrient levels in a bioreactor. The

approach used in the present work demonstrates the use of an extended Kalman

filter with real plant data, both operational and analytical (nitrate, ammonia), in

order to estimate bioreactor contents and enzyme related model parameters in a

wastewater treatment facility.

The pure culture model of Hamilton et al. (2005), which includes two enzyme

related components, has been integrated (Lee, 2005) into the industry standard

Activated Sludge Model 1 (ASM1) (Henze et al., 2000). A process model was

developed for the Kanapaha Water Reclamation Facility (KWRF) predenitrification

process in Gainesville, Florida, in cooperation with Gainesville Regional Utilities.

To test the model, real facility data of influent and process flows were obtained for

a 20 d-, period beginning January 15, 2005. We demonstrate that by applying

a Kalman filter to an aeration basin compartment that contains probes for

measuring ammonia and nitrate we obtain consistent estimates of denitrification

enzyme model parameters. This technique for parameter identification allows a

semi-mechanistic model developed for pure cultures to be used in a mixed culture

population where isolation of enzyme kinetic parameters is not practical.

4.2 Kanapaha Water Reclamation Facility

The Kanapaha Water Reclamation Facility (KWRF) receives an average

daily flow of 10 million gallons per d i' (I GD) of wastewater, of which a constant

5 MGD is diverted to a Carrousel process(EIMCO, Salt Lake City, UT). The











remaining 5 MGD, including diurnal flow variation, enters a Ludzack-Ettinger

process and it is this stream that is modeled herein.

By developing a good process model, capable of reasonable predictions of

nutrient levels that are linked to intracellular processes, it becomes possible to

estimate the unmeasured process variables, as well as unknown model parameters.

The discussion of the KWRF model is presented here in two parts. First the

hydraulic model, consisting of the process fluid flows, bioreactors, settlers, etc. is

detailed. Secondly the biological model, which describes the biochemical reactions

taking place in the reactors, is discussed.

Several processes in the facility generate a significant but unmeasured amount

of low nutrient wastewater that is combined with the influent stream. This has the

effect of diluting the influent stream before it enters the scope of the process model.

By examining operator logs it was possible to calculate the raw wastewater influent

entering the process, as well as the flowrate exiting the process. The difference was

attributed to the unmeasured dilution streams. This flow information was used

to determine the actual nutrient concentrations entering the process by diluting

the standard wastewater composition given in Table 4-1. The influent stream was

assumed to contain none of the enzyme related components. A diurnal study was

performed to verify that this composition was still representative.

After collection by the sewer system, influent enters the facility headworks

as shown in Figure 4-1. The sludge return stream contains thickened sludge

from the bottom of the clarifiers. After entering the headworks, the mixture of

influent wastewater and return sludge flows to a 440,000 gallon anoxic reactor

which nominally performs nitrogen removal for the process. The stream then enters

a 2.9 million gallon aerated reactor, where nitrification takes place. The mixed

liquor suspended solids (I S.HS) recirculation returns a fraction of effluent from the

aerated reactors to the anoxic reactors.











Table 4-1: Wastewater composition

Component Symbol Units
soluble intert substrate SI g COD/m3
particulate intert substrate Xi g COD/m3
readily degradable substrate Ss g COD/m3
slowly degradable particulate substrate Xs g COD/m3
nitrate plus nitrite nitrogen SNo g N/m3
ammonia nitrogen SNH g N/m3
soluble degradable organic nitrogen SND g N/m3
particulate degradable organic nitrogen XND g N/m3
active heterotrophic biomass XB,H g COD/m3
active autotrophic biomass XB,A g COD/m3
inert decay products Xp g COD/m3
alkalinity SALK g moles/m3
dissolved oxygen So g COD/m3
nitrate reductase EN ,. i'il /(L hr)
intracellular nitrate SNo,i g/L
Values taken from Potter et al. (1996)
* enzyme activity reported as moles substrate reduced per second


Value
62
62
99
247
0
24
4
6
0
0
0
6
0
0
0


Each of the two aerated reactors has 4 equally spaced vertical shaft surface

aerators that introduce oxygen into the activated sludge to facilitate aerobic

growth. The aerators vary in maximum power from 75 hp to 200 hp. Two of these

aerators are continuously variable in power output while the other two can only

be set to high, low, or off. The operators adjust the power of these 8 aerators

throughout the div according to both the current state of the facility and the

anticipated future loading. The aerators are almost alhv-, adjusted in matched

pairs, with the first aerator in the East aerated basin changed at the same time

and in the same way as the first aerator in the West basin. It is significant that

the third aerator in each of the aerated basins is frequently turned off (Figure

4-2) so that a significant amount of denitrification takes place in the aerated

basin. Aeration records were used to determine the aeration schedule for both

aeration basins. These handwritten records were a possible source of error in model

predictions as not all aeration changes are recorded.




























Figure 4-1: Kanapaha physical process layout.


The MLSS recirculation is not used continually as it would be in a normal

Ludzack-Ettinger process. It is usually used only between 3:00 AM and 5:00 AM to

provide flow balancing during the hours with the lowest influent rates. The flowrate

of this recirculation stream, when active, is 20 MGD.

The effluent from both bioreactors is merged and fed to four secondary

clarifiers. The sludge return stream from the clarifiers is returned to the anoxic

basin at a rate set by the operators in order to maintain a desired sludge blanket

height. The waste stream, which is set to control the solids retention time, goes on

to further biosolids processing.

The operators record instantaneous flowrates for both trains for return

activated sludge rate, mixed liquor recirculation rate and waste rate. The total

feed is evenly split between the two trains. The flows for a 20 di period are shown

in Figure 4-3. Supplemental information about facility operation is available at

http://www.ees.ufl.edu/homepp/koopman/hamilton.etal2/.

4.2.1 Hydraulic Model

The hydraulic model is shown in Figure 4-4. The two bioreactor trains are

labeled A (the east) and B (the west) with appropriate subscripts on the stream
























0 2 4 6 8 10 12 14 16 18 2


400

300

S200
01)
S100

0


400

S300
z&
cj
200

( 100

0


400

S300

200
ci)
( 100

0


400

a 300

200
o
c 100

n


0 2 4 6 8 10 12 14 16 18 20
days


Figure 4-2: Kanapaha operations -aeration strategy.


-


,n~rw~vn


0 2 4 6 8 10 12 14 16 18 2










0 2 4 6 8 10 12 14 16 18 2


FLA'


i


0





























S1.5



Sn

-LL nF(


- x106


3
LL

S2


0
0 1
C0
mI
_I)


0
0 2 4 6 8 10 12 14 16 18 2


x 105
"107


-J
8
LL
S6

i 4

2


0 2 4 6 8 10 12 14 16 18 20


S 10000
-J
8000
LL
6000

4000

2000

0 0
_3
CI


0 2 4 6 8 10 12 14 16 18 20
days



Figure 4-3: Kanapaha operations -recycles and recirculations.


I I I I I I I I


5


I I I













FMA

FA -
Aerated Aerated Aerated Aerated
Anoxic Basin Basin Basin Basin
BasinA 1A 2A 3A 4A

FRA Far Far2 Far3 Clarifier

\FWA+FWB
FRB FMB


Aerated Aerated Artd Aerated
noic Basin BaBsin Basin Basin
BasinB 1B 2B 3B 4B
t-- t I t I

Farl Far2 Far3

Figure 4-4: Hydraulic model process diagram. indicates location of nitrate and
ammonia probe pair used by the Kalman filter.


labels. In this figure, F represents the feed to the bioreactor process, including

dilution from unmodeled sources (such as filter backwashing). Each aerated reactor

is assumed to be well mixed and not interacting with .,.i ,i:ent reactors except via

listed process streams. Each aerated basin (with its four aerators) is modeled as

four sequential CSTRs. Each virtual aerated reactor is then oxygenated based on

the operation of the corresponding physical aerators. Some backmixing occurs in

the large aerated basin, and this is modeled by including internal recycles (F,,)

between each of the virtual aerated reactors. A simple ideal clarifier model is used

for the secondary clarifiers. The mixed liquor from both trains is combined before

entering the secondary clarifiers.

The nitrate and ammonia probes used in the EKF are located in the west

aerated basin near the third aerator as indicated in Figure 4-4. The probes report

measurements independently every few minutes. These data were synchronized

by assuming that any measurements within 5 minutes of each other took place

at the same time. This eliminated the necessity of using multi-rate measurement

techniques in the EKF. The raw data are available at the above mentioned website.










4.2.2 Biological Model

The biological model captures the substrate conversion and biomass growth in
the bioreactors. The model used is a modified ASM1 in which the model presented
in Hamilton et al. (2005) for diauxic growth of denitrifiers was incorporated
(Lee, 2005). This couples the enzyme kinetics of the Hamilton model with the
sludge production and wastewater components modeled by ASM1. This model
is described as extended ASM1 mechanistic (eASMlm). In this model nitrate
reduction and uptake are governed by a nitrate respiration operon. The model is an
improvement over ASM1 in that it is capable of predicting diauxic lag of denitrifiers

and correlates nitrate reductase enzyme level to anoxic growth. It adds 2 new
components, the nitrate reductase enzyme level, EN, and the total intracellular
nitrate, SNO,i. The expressions that differ from ASM1 are presented in Table 4-2.
The model parameter values used were taken from Hamilton et al. (1992) for ASM1

except for those values listed in Table 4-3. Two calculated variables used in Table
4-2 are shown below.


SNO,i,max 2-86 Yh XB,H
rI Sli-r) (2.86 y QY1) X

EN ( N \ XB,H +K1 SNO,i,max
EN,max bEN + lh "* Tg bh K2 XB,H + K1 SNO,i,mnax /X

The total process model is the sum of the advection (bulk flow) terms defined
by the hydraulic model and the reaction terms provided by the biological model.
Oxygen is introduced into the aerated basin through the mass transfer term, which
is given by KLA (So,sat So). The mass transfer coefficients are derived from
values provided by the aerator manufacturer.
4.3 Kalman Filter

Kalman (1960) created a solution to the discrete data linear filtering problem
which is now widely used in motion capture and navigation systems. The extended











50







Table 4-2: eASMlm model expressions that differ from ASM1


j Process


2 Anoxic growth
of heterotrophs
9 Uptake of
nitrate
10 Synthesis
of nitrate
reductase
11 Decay of
intracellular
nitrate
12 Decay of
nitrate
reductase


Component
8 14
SNO SNo,i
SYH
2.86 YH

-1 1


Process rate, pj
ML-3T-1
Ss
Ks+Ss) 'i7XB,H

V EN ,INO KO( ( HO) SS) XBH
SNriEN(,ma \KNO+SNO \Ko,H+So K+Ss

XB,H+KlSNO,i S
aN K2XB ,H+K1SNO,,) (HKs+S) BH


bSNo,i


BEEN


Table 4-3: eASMlm parameter
et al. (1992)


Parameter Sym
Maximum specific growth rates
heterotrophic biomass PH
autotrophic biomass PA
Yields on organic substrate
heterotrophic biomass YH
autotrophic biomass YA
Decay rates
autotrophic biomass bA
nitrate reductase bEN
Nitrate reductase synthesis constants
maximum specific synthesis rate aN
repressor / inducer ... I .. K1
constitutive expression level K2
Maximum nitrate uptake rate VSN
All masses given in COD units
* Values from Hamilton et al. (2005)


values that differ from values presented in Hamilton


ibol Units


mg biomass/mg substrate
mg biomass/mg substrate

h-1
h-1

moles benzyl viologen/(mg biomass-hr)
(mg nitrate/gdw)-1

mg nitrate/(mg biomass-hr)


Values


0.008
1E-6

IE-12
1.27E5'
1.86E4
0.122


,i











Kalman filter is used for nonlinear systems which are linearized around the current

process state. A significant benefit of the Kalman filter is that unmeasured process

states may be estimated based on limited, noisy process measurements. In order

to use an EKF to perform parameter estimation, parameters are treated as process

variables with a rate of change = 0.

Consider the following system of augmented process state vector and

measurement vector z:


( ) (f(, 0 ) + w(t) (4.1)




z = h (x, t) + v(t) (4.2)

The evolution of the process state, x, is a function of the state, x, time, t, and

system parameters, 0. The process rates and measurements are subject to zero

mean noise functions w and v, respectively.

The Kalman filter algorithm distinguishes between two estimates for the

system state. The a priori estimate, x-, is calculated based on model predictions

before any measurements are considered. The a posteriori estimate, x, is calculated

after including measurements for the current time step. These are distinct from

the true, unknown, system state, x. Finding the a posteriori estimate is the goal

of using an EKF. When an EKF is also used for parameter estimation, the a

posteriori estimate contains both the optimal estimate of the reactor state as well

as model parameters 0. Note that this superscript notation is also used for the

error covariance matrix Pk. It is worth mentioning that the matrix Pk can be stored

for each measurement and used to calculate error bars for the state estimates.

The diagonal elements of P are the variances of each of the corresponding state

variables.











The error covariance matrix is a key part of the Kalman filter and must be

integrated simultaneously with the process model. The rate of change of the error

covariance matrix P is shown in Equation 4.3.


P(t) = F(t) P(t) + P(t) FT(t) + R (4.3)

Here F is the Jacobian of f with respect to the augmented state vector and R

is the covariance of w. The a posteriori error covariance matrix P is calculated by

Equation 4.4.


Pk [I- Kk Hk()] P (4.4)

The heart of the Kalman filter is the gain matrix, K. The gain formula

is derived by minimizing the expected error between the a posteriori state

estimate and the actual state. The final form of the gain, derived for the

process/measurement system in Equations 4.1-4.2 is shown in Equation 4.5,

where Q is the covariance of v and H is the Jacobian of h with respect to the

augmented state vector.


Kk P HI (k-) [Hk (k-) Pk H (I ) + Q] (4.5)

The a posteriori state estimate is the weighted sum of the a priori estimate

and an error term that represents the difference between the actual measurement,

Zk, and the measurement that would be expected if the model was perfectly
accurate, hk(x~(). The weighting factor is the Kalman gain matrix, Kk.

k = f+ Kk [zk hk(k)] (4.6)


The filtering algorithm is shown below for each time step k.











1. Simultaneously integrate Equation 4.1 with the initial condition of Xk-1 and

w set to zero, and Equation 4.3 with initial condition of Pk-1. This yields the

a prior estimate of the system state, XJ, as well as the a priori estimate of

error covariance, P-.

2. Calculate the gain, Kk using X, and P1- in Equation 4.5.

3. Using Equation 4.6 calculate Xk the final estimate of the system state for

this time step.

4. Calculate Pk from Equation 4.4 for use in the next time step.

See Gelb (1974) for a more complete discussion and derivation of the Kalman

filter.

In order to estimate state variables and specific growth rates Stephanopoulos

and San (1984) proposed the use of an extended Kalman filter. Later work by

Ramirez (1987) and C'! ill i.way and Stephanopoulos (1989) used the Kalman filter

along with the sequential parameter updating strategy of Ljung and Soderstrom

(1983) for both state and model parameter estimation. This strategy has been used

by Park and Ramirez (1990) for control of nutrient levels in a bioreactor.

The values shown in Table 4-3 for the parameters controlling enzyme kinetics

(Ki, K2, aN and b,,) were the initial values. They were continually estimated by

the EKF as probe measurements are processed.

The Kalman filter algorithm was run on aerated basin 3B, a subset of the full

system model. The rest of the plant model was integrated without the Kalman

filter using the generated parameter estimates.

4.4 Results and Discussion

Estimates of nitrate reductase parameter aN from the on-line data are

presented in Figure 4-5. This is the first time that estimates of an intracellular

component in activated sludge have been made by processing of real plant data.

Nitrate and ammonia measurements are compared to EKF output for a 20 d,-'











period. The filter output is a good match for the probe data without appearing to

be over-tuned.

As the filter runs, it continually updates the estimates for the models

parameters K1, K2, aN and be,. Essentially no change was made to the parameters

with the exception of aN, shown in Figure 4-5. This result indicates that varying

only aN could account for the observed change in nitrate and ammonia. As

discussed in Hamilton et al. (2005), K1 and K2 are based on the Lac operon

regulation model, and most of their effect on behavior stems from their relative

magnitudes.

The filter parameters which require turning are the values for the covariance

matrices R and Q in Equations 4.3 and 4.5. These give the algorithm information

about the level of variation that can be expected in the process, which heavily

influences decisions about how to appropriately weight measurements versus model

predictions. The tuning was done by inspection, based on plots of filter output

combined with the error covariance matrix derived error bars. After running the

algorithm and observing a component that seemed to have error bars that were too

tight based on process knowledge, the corresponding component of R was increased.

The variation observed in aN is on the timescale of about 1 d4w. This

parameter is the maximum specific nitrate reductase synthesis rate, and has

been found to be very important for tuning the unfiltered model. One possible

explanation for the variation observed in this parameter is changes in reactor

temperature which would be expected to have a significant effect on biomass

growth. The operators' temperature logs are intermittent, making it difficult to

correlate this effect. An unmodelled change in operating conditions would be

reflected by the filter in the form of changes to the estimated parameters.























x10-11

0
c 1.

0 1 -
E

rd 0.5


CO 0- L L L
0 2 4 6 8 10 12 14 16 18
days



CO
I 1.5
z



0.5












m 4
0)

0 2 4 6 8 10 12 14 16 18



8 Probe
SSimulation
z 6

m4










(ay) as well as a comparison of nitrate and ammonia probe meaurements to filter
results. The other three estimated parameters (Ki, K2, and be,) did not vary by
CO

0 2 4 6 8 10 12 14 16 18
days


Figure 4 5: Estimates of the maximum specific nitrate reductase synthesis rate
(aN) as well as a comparison of nitrate and ammonia probe meaurements to filter
results. The other three estimated parameters (K1, K2, and b,,) did not vary by
more than 0.5'. over the period shown. Units of activity are moles benzyl viologen
consumed per second.









56

4.5 Acknowledgments

We would like to thank Gainesville Regional Utilities for their cooperation in

this study, and for providing access to the KWRF. We would also like to thank the

employees of the KWRF for their assistance with data collection and for sharing

their process insights.

















CHAPTER 5
FUTURE WORK

5.1 Distributed State Modeling

Distributed state modeling is a type of model structure in which model

components are tracked as evolving distributions rather than single values. The

benefit of this approach is particularly significant for models with nonlinear

behavior based on concentrations of intracellular components. In the case of diauxic

lag, microorganisms experience a period of little or no growth during which they

synthesize necessary enzymes for growth under new conditions. In the case where a

subset of the population is growing exponentially while the i I i il ity is experiencing

a lag phase, a traditional model will generate incorrect predictions of behavior. A

traditional model functions as a "single cell," in which all model components are

averaged out over the entire population. When a small fraction of the population

has the i I i ii ity of a key component, the model prediction will be lag for the entire

population. A similar argument could be made for phosphorus metabolism.

5.2 Extended Kalman Filter

The next step for the adaptive extended Kalman filter presented in ('! Ilpter

4 would be to incorporate enzyme activity estimates from the Kanapaha facility

into the algorithm. These ..-- li-, would not be available with the frequency of

ion probe data, which would necessitate the use of a multi-rate EKF technique.

This is a common situation with bioprocess measurement. It is frequently the case

that some measurements are available on-line and are frequently updated while

others are more sporadic / irregular and perhaps d. 1 -, .1 This is particularly

true in the case of bioprocesses, in which you may have constant measurement of











variables like optical density, pH, temperature and GC ,i: 1, i--i of effluent gases,

but measurement of some substrate concentrations may require lengthy chemical

tests, in addition to ..-- li-, for intracellular states of the components.

A multirate EKF is relevant to the present work in that the availability of

enzyme ..-- ,i-- is expected to greatly increase the effectiveness of the parameter

estimation algorithm. These ..-- li-, would only be available infrequently, and a

multirate approach would be required to integrate them into the probe data.

The approach of Gudi et al. (1995) was adapted from the multi-rate strategy of

Glasson (1980, 1983). Gudi et al. (1995) also retained past measurements in their

output equations in an attempt to increase system observability. In this approach,

the EKF is defined as in Equations 4.1-4.6 above.

This approach defines two sampling periods. The i1 i, i" sampling period

is those times at which both rapid and infrequent measurements overlap and

the minor period is the sampling period of the rapid measurement alone. The

measurement vector is of higher dimensionality at the in ii' ', sampling period so

redefinitions of the EKF measurement equations are required.



Major h- major(XV(tmajor)) + Umajor (5.1)



Zminor = minor (X(tminor)) + Uminor (5.2)

New measurement Jacobians must be defined for the linearized measurement

mode.


Hajor ahmajorx (t), t) (5.3)
axj (t)



Hminor (t), t) (5.4)
axj(t)











This begins the derivation of what is functionally two separate extended

Kalman filters, one of which is invoked at the i i ri" sampling period and one at

the minor.



Major major [ Hmajor o major jor + major] (5.5)



Kninor -minor H- inor Hminor minominor + Rminor (5.6)

5.3 Enzyme Activity Based Dynamic Optimization

An ultimate goal of the presented EKF and model is a dynamic optimization

scheme. As has been discussed, the industry standard models can not predict

diauxic lag, and an optimization scheme based on such a model will be suboptimal.

Conceptually, one would seek to optimize the nitrogen removal rate subject to the

constraint that the nitrate respiration enzyme levels should not fall low enough

that there is a significant diauxic lag. If aeration is cycled too slowly the enzyme

levels will drop while rapid cycling may not provide adequate biomass generation or

carbon removal.

One algorithm for dynamic plant optimization is to define a goal function

based on the desired output characteristics of the process which is a function of

all controllable process inputs. The goal function would be evaluated by using

the process model to predict the plant performance over a large (relative to

measurement frequency) time window. An optimization algorithm would be applied

to that goal function and the resulting optimal operating conditions would be

applied to the physical process. As measurements are made, the EKF continually

updates the estimated process state, which serves as the initial condition for the

goal function's prediction. The EKF is essential here because of the importance of









60


denitrification enzymes in process performance and the low frequency of enzyme

activity measurement.

















APPENDIX A
EXTENDED KALMAN FILTER FOR DENITRIFICATION ENZYME
PARAMETER ESTIMATION AT THE KANAPAHA WATER RECLAMATION
FACILITY
SUPPLEMENTAL MATERIAL

The advection (bulk flow) terms are described by a hydraulic model, the

reaction terms by the biochemical model, and the mass transfer term describes the

action of the aerators.


dX
= advection + reaction + mass transfer (A.1)
dt

The final hydraulic model is shown in Figure A-1. The two bioreactor trains

are labeled A and B with appropriate subscripts on the stream labels. In this

figure F represents the feed to the bioreactor process, including dilution from

unmodeled sources (such as filter washing). Each aerobic reactor is assumed to

be well mixed and not interacting with .i-i i:ent reactors except via listed process

streams. Each aerobic basin (with its four aerators) is modeled as four sequential

CSTRs. Each virtual aerobic reactor is then oxygenated based on the operation of

the corresponding physical aerators. Some backmixing occurs in the large aerobic

basin and this is modeled by including internal recycles (Fr,) between each of the

virtual aerobic reactors. A simple ideal clarifier model is used for the secondary

settling tank. This models the solids enrichment in the lower stream as perfect

separation. The sludge from both trains is combined before entering the clarifier.

The differential equations governing the hydraulic model advectionn terms) for

train A are shown in Equations A.2-A.6 below. In these expressions, Xy denotes

component X in reactor y. Each expression is then a vector, where X is replaced














Table A-1: Aerobic basin surface aerators. Aerators are numbered sequentally in
flow direction. The first aerator encountered in the East aeration basin is number
1, the last number 4. In the West aeration basin the numbering starts with 5. This
is the numbering scheme used by the Kanapaha operators. Control type refers to
the granularity of power output settings available. High/low aerators can be set to
10i' -, 5(0' or (0'. power. Continuously variable (C.V.) aerators can be set to any
percentage output.


aerator
number
1,5
2,6
3,7
4,8


control
type
high/low
C.V.
high/low
C.V.


maximum
horsepower
125
200
125
75


Figure A-1: Hydraulic model PID. The process is modeled as two trains in parallel.
Each aerobic basin (with its four aerators) is modeled as 4 sequential CSTRs.
Each virtual aerobic reactor then is then oxygenated based on the operation of the
corresponding physical aerators. To account for backmixing within the large aerobic
basin there are recycle streams between the virtual aerobic reactors. An ideal point
clarifier model is used for the secondary settling tank. The sludge return (FR) for
each train is mixed before being reintroduced into the anoxic basin.












by each model component. For example, Xab4a is component X in aerobic basin

4 of train A. The labels used for streams are consistent with Figure A 1, and the

reactor volumes are given by Table A-2.

Equation A.2 gives the anoxic basin advection expression for particulate

material. For soluble material the clarifier separation efficiency, A, equals 1 since

the clarifier does not segregate soluble material. The term Fsum,A is defined for

brevity as FA + FRA + FMA.


F FR FM Fsum,A
S* Xinfluent + A Xmixed + Xb4 Xan (A.2)
Van Van Van Van

The term Xmixed represents the secondary settling tank combined return from

both trains and is calculated by:

(FA + FRA) Xab4a + (FB + FRB) Xab4b
Xmixed
SA + FRA + FB + FRB


The advection terms for the 4 virtual aerobic reactors are defined in Equations

A.3 A.6.


Fsum,A FFar sumF ,
FsurnA Xana + F- Xab2a -
Vaerl Vaerl /



Fsum,A + Farl Far2 Farl
Xabla + --- Xab3a Xab2a
Vaer2 Vaer2 Vaer2




Fsum,A + Far2 Far,3 Far2
SXab2a, + Xab4a Xab3a
Vaer3 Vaer3 Vaer3



Fsum,A + Far3 Far3
Xab3a 4 Xab4a
Vaer4 Vaer4


(A.3)


4 + Farl
Xabla
aer 1


Fsum,A + Far2
Fam + F Xab2a (A.4)
Vaer2


Fsum,A + Far3
S Vae Xab3a




Fsum,A
Fa- Xab4a
Vaer4


(A.5)


(A.6)













Parameter
virtual aerobi
anoxic tank v
aerator efficie
aerator 1
aerator 2
aerator 3
aerator 4
dissolved oxy;
aerobic basin


Table A-2: Hydraulic model parameters

Symbol Units
c tank volume Vaer L
*olume Van L
ncy
KLA1 hr- /
KLA2 hr- /
KLA3 hr- /
KLA4 hr- /
gen at saturation So,sat mg 02
internal recycle ratio abr


hp
hp
hp
hp
/L


The mass transfer component of the overall balance equation describes the

rate at which the surface aerators are able to introduce dissolved oxygen into the

aerobic basin. The mass transfer for oxygen is given below, where i represents

each of the 4 aerobic basins. The value for KLA2 (a recent upgrade) is derived

from performance per horsepower specifications from the manufacturer and the

performance for the remaining aerators was found by fitting ASM1 to KWRF

nutrient data.


d, KLAi (So,sat Soi)
_7-i


(A.7)


The full biochemical model is presented in Table A-3 with corresponding

model parameters presented in Table A-4. The combination of the discussed

hydraulic model and the tabulated biochemical model is used to simulate overall

process performance.

Historical flow data was collected from this facility and used to generate a

set of representative diurnal flow patterns. One significant difficulty in modeling

the KWRF process is that the operator logs record flow rates every hour. This

sampling frequency can miss significant variation on a shorter timescale or

over-emphasize variation that occurs at the time that the flowrate is recorded.

Due to this unreliability the influent flowrate used in the model is calculated from


Value
5 : .'0
3330800

0.0136
0.0176
0.0136
0.0136
8.8
1.5



















j q
,?


____ __ n__ Li _


>1d
O



'0 0I


oro


- 0 0

0.2 C-C E C C CL4
r .v a--a a
C C-_ C-_ __ _ E'E- o3 -
t '0 0 0- 00 0 s'
7 : s I .o i1|a 0
SSf ~ ,la.- l acs ^; -^ O3.is-
O II
lmli lllUl l ^ ^l l
E~ -, _Q ~~, hjg ~
i- C' CO ^ ^O t l-~ G C~ ;^r U1 r F a


":










66













Table A-4: eASMlm parameter values


Parameter
Maximum specific growth rates
heterotrophic biomass
autotrophic biomass
Yields on organic substrate
heterotrophic biomass
autotrophic biomass
Half-saturation coefficients
carbon source
oxygen, heterotrophic biomass
oxygen, autotrophic biomass
nitrate
slowly degradable substrate
Decay rates
heterotrophic biomass
autotrophic biomass
nitrate reductase
Nitrate reductase synthesis constants
maximum specific synthesis rate
repressor / inducer binding
constitutive expression level
Maximum rates
nitrate uptake
hydrolysis
ammonification
Anoxic correction for PH
Anoxic correction for hydrolysis
Mass nitrogen per unit biomass
Mass nitrogen per unit biomass products
Fraction of biomass decaying to particulates
All masses given in COD units


Symbol Units

PH h-1
AA h-1


YH
YA

Ks
KO,H
KO,A
KNH
Kx


aN
K1
K,2

VsN,i
kh
k,
lg
'lh
iXB
ixp
fp


mg biomass/mg substrate
mg biomass/mg substrate

mg organic substrate/L
mg Oa/L
mg Oa/L
mg N/L
mg/mg biomass


katals/(mg biomass-hr)
(mg nitrate/gdw)-1


mg nitrate/(mg biomass-hr)
mg/(mg biomass -hr)
L/(mg biomass -hr)


Values taken from Koopman et al. (1989) except where marked
* Values from Hamilton et al. (2005)
** Values from present study


Values

0.39**
0.19"*

0.5**
0.24**

20
0.1
0.4
1.0
0.3

0.026
0.008**
1E-6**

1E-12**
1.27E5*
1.86E4*

0.122"*
0.125
0.0033
0.85
0.4
0.086
0.06
0.08










67

13 I--



10

1/



S'- Monday
LL Tuesday
\\ Wednesday
j Thursday
Friday
S Saturday
-- Sunday
4 I I
0 5 10 15 20 25
time (hr)


Figure A-2: Diurnal flow patterns. Figures are based on operator logs for the
period January through August 2004.


the total influent flow for each div-, which is accurately recorded. The hourly flow

rates are computed by scaling the total daily flow using a diurnal pattern shown in

Figure A-2. This pattern was calculated by averaging the flowrate patterns (based

on hourly operator logs) for each d-v of the week for the months January through

August 2004. The resulting curves are similar to results from a previous study

(Koopman et al., 1989) in which a single flow pattern was used. This accurately

captures the total flow and most of the diurnal variation, but misses flow spikes and

changes in flow due to hlidi-- Flow spikes can be significant during rain events

and this can negatively impact process model performance.

Nitrate and ammonia data were collected using the facility's nitrate and

ammonia probes located in the aerobic reactors. Measurements of both species were

not made simultaneously, but were separated in times by a variable amount (1-10

minutes). An EKF approach is made less reliable by incorporating multi-rate

techniques unless necessary, so these probe measurements were treated as

simultaneous for those times where nitrate and ammonia were measured within









68

5 minutes of each other. This is reasonable because the time scale of changes in

these species is a much larger fraction of an hour.




















APPENDIX B
AUTOMATION PROGRAM SOURCE CODE

B.1 Code for DLECModule.bas


Attribute VBName = "DLECModule"
Option Explicit
Public fMainForm As frmMain
Public exp As DLECExperiment
Global EmailAddress(7) As String
'the email addresses to be used
'whether to use the corresponding email address
Global UseEmail(7) As Boolean
Public AllReactorSame As Boolean

'constants used to make these functions more readable
Global Const water As Integer = 0
Global Const biomass As Integer = 1
Global Const nogas As Integer = 2
Global Const nitrogen As Integer = 1
Global Const oxygen As Integer = 0
'local variable(s) to hold property values)



'set this false to be able to actually take data
Global RKHFAKESAMPLE As Boolean
Global ChartlData( As Double
Global Chart2Data() As Double
Global Chart3Data() As Double
Global LastMeasurementWasRinsing As Boolean
'whether to save data to a file as we run the experiment
Public LogToFile As Boolean



Sub Main()
Dim i As Integer

EmailAddress(O) = "rkhamilt@ufl.edu"
EmailAddress(1) = "acasasus@ufl.edu"
EmailAddress(2) = ""
EmailAddress(3) = ""













UseEmail(O) = True

'Set the relays that identify the particular relays we use
Relay02(0) = 1
Relay02(1) = 3
Relay02(2) = 7
RelayInert(O) = 2
Relaylnert(1) = 4
RelayInert(2) = 6
RelayEffluent(O) = 8
RelayEffluent(1) = 9
RelayEffluent(2) = 10

'turn off all relays just so we are sure of its state
ModuleAllRelayOff vbNullString

'set up the experiment with basic info
Set exp = DLECExperimentConstructor(3)

Set fMainForm = New frmMain

LogToFile = True
AllReactorSame = True

'kludges
For i = 0 To exp.NumberReactors 1
With exp.Reactor(i)
'Set Communication parameters
Set .MSCommObj = frmMain.SpecCommDevice(i)
.MSCommObj.CommPort = 4 + i
.MSCommObj.Settings = "9600,N,8,1"
If .MSCommObj.PortOpen Then .MSCommObj.PortOpen = False
End With
Next i
'spec 1 has a slight change in settings
exp.Reactor(0).MSCommObj.Settings = "19200,N,8,1"

RKHFAKESAMPLE = False
frmMain.mnuSim.Checked = RKHFAKESAMPLE

fMainForm.Show

End Sub



Public Function DLECExperimentConstructor(ByVal NumReactors As Integer)
As DLECExperiment













'this is the constructor for the experiment object
'note that for each reactor, it must have it's comm device
'set to point to a form element
Dim Output As New DLECExperiment
Set Output = New DLECExperiment
Dim i As Integer

'set up this experiment
With Output
.NumberReactors = NumReactors 'Initialize Settings for each reactor
.CurrentRunTime = 0
.StartTime = Now
.EmailHome = False
.Running = False
.TotalDuration = 2880
.NewData = False
.EmailAbs = 0.2
.EmailHome = False


'set up each reactor
For i = 0 To .NumberReactors 1
With .Reactor(i)
.InUse = False
.MinutesPerCycle = 30
.BiomassFlushingTime = 10 'minutes
.AbsorbanceGasTrigger = 0.2
.Absorbance = 0
.BubbleScreen = True
.BubbleScreenType = 1
.gas = nogas
.fluid = biomass
.LastGoodSample = 0
.MostRecentSample = 0
.SwitchGases = True
.TimeOfLastSample = Now
.UseRinsing = True
.MinutesBetweenSamples = 15
.valveEffluent = RelayEffluent(i)
.valveNitrogen = RelayInert(i)
.valveOxygen = RelayO2(i)
End With
Next i
End With

Output.Reactor(0).InUse = True

Set DLECExperimentConstructor = Output










72



End Function



Public Function DLECChemostatConstructor(ByRef ParentObj As DLECExperiment)
As DLECChemostat
Dim newMSCommObj As MSComm
Dim Output As DLECChemostat
Set Output = New DLECChemostat
'Set Output.MSCommObj = frmMain.SpecCommDevice(O)
Output.Ready = False
Set Output.Parent = ParentObj
Set DLECChemostatConstructor = Output
End Function













B.2 Code for DLECEmailModule.bas


Attribute VBName = "EmailModule"
Option Explicit
SSends an email to the appropriate personss.
SSendTo = List of email addresses separated by a semicolon. Example:
sm@xyz.com; steve@work.com; jane@home.com
SSubject = Text that summarizes what the email is about
SEmailText = Body of text that is the email
SAttachmentPath = Directory in which the attachment resides
SAttachment = File to send with the email

Private Sub SendEmailMAPI(SendTo As String, Subject As String,
EmailText As String, Optional AttachmentPath As String,
Optional Attachment As String)
Const constRoutine As String = "SendEmailMAPI"

Dim intStart As Integer
Dim strSendTo As String
Dim intEnd As Integer
Dim i As Integer



If frmMain.MAPISession.SessionID = 0 Then
frmMain.MAPISession.SignOn
End If

If SendTo = "" Then Exit Sub

With frmMain.MAPIMessages
.SessionID = frmMain.MAPISession.SessionID
.Compose

'Make sure that the SendTo always has a trailing semi-colon (makes it
easier below)
'Strip out any spaces between names for consistency
For i = 1 To Len(SendTo)
If Mid$(SendTo, i, 1) <> Then
strSendTo = strSendTo & Mid$(SendTo, i, 1)
End If
Next i

SendTo = strSendTo
If Right$(SendTo, 1) <> ";" Then
SendTo = SendTo & ";"
End If















'Format each recipient, each are separated by a semi-colon, like this:
steve.miller@aol.com;sm@psc.com; sm@teletech.com;
intEnd = InStr(l, SendTo, ";")
.RecipAddress = Mid$(SendTo, 1, intEnd 1)
.ResolveName

intStart = intEnd + 1
Do
intEnd = InStr(intStart, SendTo, ";")
If intEnd = 0 Then
Exit Do
Else
.RecipIndex = .RecipIndex + 1
.RecipAddress = Mid$(SendTo, intStart, intEnd intStart)
.ResolveName
End If
intStart = intEnd + 1
Loop

.MsgSubject = Subject
.MsgNoteText = EmailText
If Left$(Attachment, 1) = "" Then
Attachment = Mid$(Attachment, 2, Len(Attachment))
End If

If Attachment <> "" Then
If Right$(AttachmentPath, 1) = "" Then
.AttachmentPathName = AttachmentPath & Attachment
Else
.AttachmentPathName = AttachmentPath & "" & Attachment
End If
.AttachmentName = Attachment
End If
.Send False
End With

End Sub



Public Sub Email_Report()
Dim SendTo As String
Dim Subject As String
Dim EmailText As String
Dim i As Integer


'put together list of addressees













SendTo = ""
For i = 0 To 6
If UseEmail(i) Then SendTo = EmailAddress(i) + ";
Next i

'put together subject line
Subject = Format(Now, "Medium Time")

'put together email body
EmailText = ""
For i = 0 To exp.NumberReactors 1
With exp.Reactor(0)
If .InUse Then
EmailText = EmailText + "rctr" + CStr(i + 1) + ": +
Format(.Absorbance, "0.000") + "
If .gas = oxygen Then EmailText = EmailText + "02" + vbCr
If .gas = nitrogen Then EmailText = EmailText + "N2" + vbCr
If .gas = nogas Then EmailText = EmailText + "NONE" + vbCr
End If
End With
Next i

'send
SendEmailMAPI SendTo, Subject, EmailText


End Sub













B.3 Code for DLECPhoneCallModule.bas


Attribute VBName = "PhoneCallModule"
Option Explicit
Public Function Callthis(num As String)
Dim Output, dummy, FromModem$
Modem.CommPort = 1
Modem.Settings = "9600,N,8,1"
Modem.PortOpen = True
Modem.Output = "ATDT + num + vbCr

Wait for "OK" to come back from the modem.
Do
dummy = DoEvents()
If there is data in the buffer, then read it.
If Modem.InBufferCount Then
FromModem$ = FromModem$ + Modem.Input
Check for "OK".
If InStr(FromModem$, "OK") Then
'the phone was answered
Exit Do
End If
End If

Did the user choose Cancel?
'If CancelFlag Then
'CancelFlag = False
'Exit Do
'End If
Loop

Disconnect the modem.
Modem.Output = "ATH" + vbCr

Close the port.
Modem.PortOpen = False


End Function













B.4 Code for DLECLogFileModule.bas


Attribute VB_Name = "LogFileModule"
Option Explicit
Dim hLogFile As Integer Handle of open log file.

Public Sub OpenLogSub()
Dim replace, temp As String, Ret As Integer
On Error Resume Next

Dim dlgOpenLog As CommonDialog
Set dlgOpenLog = frmMain.OpenLog

dlgOpenLog.Flags = cdlOFNHideReadOnly Or cdlOFNExplorer
dlgOpenLog.CancelError = True

Get the log filename from the user.
dlgOpenLog.DialogTitle = "Open Data Log File"
dlgOpenLog.Filter = "Log Files (*.TXT)I*.txtIAll Files (*.*)I*.*"

Do
dlgOpenLog.FileName = ""
dlgOpenLog.ShowOpen
If Err = cdlCancel Then Exit Sub
temp = dlgOpenLog.FileName

If the file already exists, ask if the user wants to
overwritee the file or add to it.
Ret = Len(Dir$(temp))
If Err Then
MsgBox Error$, 48
Exit Sub
End If
If Ret Then
replace = MsgBox("Replace existing file + temp + "?", 35)
Else
replace = 0
End If
Loop While replace = 2

User clicked the Yes button, so delete the file.
If replace = 6 Then
Kill temp
If Err Then
MsgBox Error$, 48
Exit Sub













End If
End If

Open the log file.
hLogFile = FreeFile
Open temp For Binary Access Write As hLogFile
If Err Then
MsgBox Error$, 48
Close hLogFile
hLogFile = 0
Exit Sub
Else
Go to the end of the file so that new data can be appended.
Seek hLogFile, LOF(hLogFile) + 1
End If



End Sub



Public Sub CloseLog()
Close the log file.
Close hLogFile
hLogFile = 0
End Sub

' This procedure adds data to the Term control's Text property.
SIt also filters control characters, such as BACKSPACE,
Carriage return, and line feeds, and writes data to
San open log file.
SBACKSPACE characters delete the character to the left,
Either in the Text property, or the passed string.
SLine feed characters are appended to all carriage
returns. The size of the Term control's Text
Property is also monitored so that it never
Exceeds MAXTERMSIZE characters.
Public Static Sub ShowData(Term As Control, ByRef Data As String)
Const MAXTERMSIZE = 16000
Dim TermSize As Long, i

Make sure the existing text doesn't get too large.
TermSize = Len(Term.Text)
If TermSize > MAXTERMSIZE Then
Term.Text = Mid$(Term.Text, 4097)
TermSize = Len(Term.Text)
End If













' Point to the end of Term's data.
Term.SelStart = TermSize

' Filter/handle BACKSPACE characters.
Do
i = InStr(Data, Chr$(8))
If i Then
If i = 1 Then
Term.SelStart = TermSize 1
Term.SelLength = 1
Data = Mid$(Data, i + 1)
Else
Data = Left$(Data, i 2) & Mid$(Data, i + 1)
End If
End If
Loop While i

' Eliminate line feeds.
Do
i = InStr(Data, Chr$(10))
If i Then
Data = Left$(Data, i 1) & Mid$(Data, i + 1)
End If
Loop While i

' Make sure all carriage returns have a line feed.
i = 1
Do
i = InStr(i, Data, Chr$(13))
If i Then
Data = Left$(Data, i) & Chr$(10) & Mid$(Data, i + 1)
i = i + 1
End If
Loop While i

' Add the filtered data to the SelText property.
Term.SelText = Data

' Log data to file if requested.
If hLogFile Then
i = 2
Do
Err = 0
Put hLogFile, Data
If Err Then
i = MsgBox(Error$, 21)
If i = 2 Then










80


CloseLog
End If
End If
Loop While i <> 2
End If
Term.SelStart = Len(Term.Text)
End Sub



















APPENDIX C
DENITRIFIER DIAUXIC GROWTH MODEL SOURCE CODE

C.1 Code for Run061703.m


Run the model with parameters from 06-17-03
load data061703b;
load exp061703;
load mfit061703;
load mfitR;
%e.EndPhaseAtAbs = [1 1];
%e.init_sni = xfinal(end)
e.PhaseSolutionSn = [50 4000];
e.PhaseDilutionRatio = [0 100/(4000-100)];

e = RunModel(mfit,e);

%CALCULATE ERROR
%by linear interpolation, find a table of values for times
%corresponding to the times at which we have measurements
InterpExpEnzyme = interpl(e.times,e.fen,data.e-n_times);
InterpExpBiomass = interpl(e.times,e.fXb,data.times);

%calculate the sum of squares error between the simulation and the data
ssqXb = sum( (data.fXb InterpExpBiomass).^2 );
sizeXb = size(data.fXb,1);
varevXb = 5E-5; %experimentally measured average variance

%sum of squares error for nitrate reductase level
ssqen = sum( (data.fen InterpExpEnzyme).^2 );
sizee_n = size(data.fen,1);
vareve_n = 4.3E-19; %experimentally measured average variance

%output a weighted sum of the two
biomasserror = ssqXb/(sizeXb*varevXb);
enzymeerror = ssqen/(sizeen*vareve_n);
out = biomasserror + enzymeerror;

figure;
PlotModel(e);
PlotData(data);













C.2 Code for RunModel.m


function expout = RunModel(m, e)
%RUNMODEL(model,experiment), returns an experiment with simulated data

%number of phases
numphases = size(e.PhaseLength,2);

%initial conditions
state = [e.init_Xb; e.init_Ss; e.init_Sn; e.init_e_n; e.init_sni;];

%An experiment phase consists of a period of exposure to the same terminal
%electron acceptor.

%initial values
accumY = state';
accumT = 0;

for phase = l:numphases

%make note in the experiment what phase we are integrating
e.phase = phase;
%set aeration
e.So = e.PhaseStartSo(phase);

%DILUTION
%dilute only Xb, Ss, Sn. The other state variables are biomass
%specific. Also not that for dilution ratio of zero, nothing happens.
%This should always be zero for phase 1.
%e.g. for a 1:19 dilution (20 fold), this number is 19
DilutionFactor = e.PhaseDilutionRatio(phase);
%conc. of nitrate in the solution used to dilute
FeedSn = e.PhaseSolutionSn(phase);
%conc. of carbon in the solution used to dilute
FeedSs = e.PhaseSolutionSs(phase);
%no biomass in feed
state(l) = state(1)/(l+DilutionFactor);
%Substrate is added
state(2) = (state(2)+FeedSs*DilutionFactor)/(l+DilutionFactor);
%Nitrate is added
state(3) = (state(3)+FeedSn*DilutionFactor)/(l+DilutionFactor);

%solve ODE for each time in e.times from initial conditions init(above)
%run each integration for up to 100 hours or until a termination event
%occurs. These events are either reaching the correct biomass or a
%preset time.













[T,Y,TE,YE,IE]=odel5s(m.model,0:0.052113154:100,state,e.ODEoptions,m,e);


state = Y(end,:); %copy the final state to use on the next integration

%this point was already present at the end of the previous phase,
%so I'll delete it to avoid duplication
Y(1,:) = [];
T(1) = [];

concatenatee the second segment with the first
accumT = [accumT;T+accumT(end)];
accumY = [accumY;Y];
clear T Y TE YE IE;
end

%In order to have model data extending over the entire range we need to
%curve fit I will make sure that the last time we've measured is >= the
%total experimental duration
if accumT(end) < sum(e.PhaseLength)
%integrate out to make up the difference
phaseduration = sum(e.PhaseLength) accumT(end);
storeoptions = e.ODEoptions;
e.ODEoptions.Events = [];
[T,Y] = odel5s(m.model, [0 phaseduration], state,e.ODEoptions,m,e);
e.ODEoptions = storeoptions;

state = Y(end,:); %copy the final state to use on the next integration

%this point was already present at the end of the previous phase,
%so I'll delete it to avoid duplication
Y(1,:) = [];
T(1) = [];

concatenatee the second segment with the first
accumT = [accumT;T+accumT(end)];
accumY = [accumY;Y];
clear T Y;
end

%remove the temporary phase variable from e
e = rmfield(e,'phase');

%Seperate the data columns for readability
e.times = accumT;
e.fXb = accumY(:,l);
e.fSs = accumY(:,2);










84


e.fSn = accumY(:,3);
e.fe_n = accumY(:,4);
e.fsni = accumY(:,5);

e.finalstate = [e.fXb(end) e.fSs(end) e.fSn(end) e.fe_n(end) e.fsni(end)];

expout=e;













C.3 Code for model5c.m


function dy = model5c(t,y,m,e)
%model5b(t,y,m), model ODEs. m is a struct of model parameters
%model parameters are in a struct defined by DefaultModelParam
%This is modified from model5 by adding monod switching terms for Ss on
%rsni and reno

%Variable Definitions
Xb = y(l);
Ss = y(2);
Sn = y(3);
en = y(4);
sni = y(5);

%Maximum values for e-n and sni
snimax = m.Vsni / m.mumax_an 1/m.Yn_an;
e-n-max = m.aNO / (m.bNO + m.mumax_an m.b) (1 + m.Kl*snimax) / .
(m.K2 + m.Kl*snimax);

%Process Rates
%I'll do some goofy stuff here to shortcircuit some possible errors
%e.g. if Ks_ox happens to be zero (which it shouldn't be, but it may be
%temporarily during optimization) then when Ss = 0 (which is reasonable)
%then rox is undefined, when it should be zero.
if Ss == 0
rox = 0;
ranox = 0;
rsni = 0;
reno = 0;
else
rox = m.mumax_ox Ss / (m.Ks_ox + Ss) e.So / (m.Koh + e.So);
if snimax == 0
ranox = 0;
else
ranox = m.mumax_an (e_n/e_n_max) (sni/snimax) Ss / ...
(m.Ks_an + Ss);
end
rsni = m.Vsni (en/e_n_max) Sn/(Sn+m.Knoi) m.Koi/(m.Koi+e.So) ...
Ss / (m.Ks_an + Ss);
reno = m.aNO (1 + m.K1*sni ) / (m.K2 + m.K1*sni) Ss / ..
(m.Ks_an + Ss);
end

%ODEs
dxbdt = (rox+ranox-m.b-e.D) Xb;













dssdt = (- rox / m.Yc_ox ranox / m.Yc_an )*Xb + e.D*(e.Ssf Ss);
dsndt = -rsni*Xb +e.D*(e.Snf Sn);

%the formula for specific enzyme and internal nitrate are undefined for
%washout conditions. If there is no biomass I will just set these rates to
%zero.
if Xb == 0
de_ndt = 0;
dsnidt =0;
else
de_ndt = reno (m.bNO + e.D + dxbdt/Xb)*en;
dsnidt = rsni -(ranox/m.Yn_an) (e.D + m.b + dxbdt/Xb)*sni;
end
%return outputs
dy = [dxbdt;...
dssdt;...
dsndt; ...
de_ndt; ...
dsnidt;];













C.4 Code for FitAllData.m


%Minimize the value of Fit_TargetFunction by changing the model parameters


%Initial guesses for
disp('FitAllData')
% xO.mumax_ox =
% xO.mumax_an =
% xO.Ks_an
% xO.Vsni
% xO.Knoi
% xO.Koi
% xO.aNO
% xO.K1
% xO.K2
% xO.bNO


parameters

0.5690;
0.1631;
0.3417;
0.0217;
5.6055e-004;
3.3068e-004;
2.4536e-008;
9.8580e+004;
1.9597e+004;
0.4;


%aerobic growth
anoxicc growth
%switch for lack of energy/carbon
%maximum NO3 uptake;
%g/L external nitrate promotes uptake
%02 inhibits nitrate uptake
%maximum enzyme production rate

%controls lag length
%nitrate reductase decay rate


%START OPTIMIZTING FROM
load mfitASA2;
disp('initial model')
mfit.mumax_ox = 0.56;
mfit.mumax_an = 0.17;
disp(mfit)
xO.array = [mfit.aNO


[fvalinit,


mfit.K2
%mfit.mumax_
%mfit.mumax_
mfit.Vsni
mfit.K1
mfit.Knoi
mfit.Koi
mfit.bNO];
cost_flag] =


THE LAST GOOD POINT









ox
an







fAllError(xO.array);


%Set up constraints
%All variables must be positive
lb = [1E-12
1E3
%0.1
%0.1
0.0001
1E3
1E-5
1E-5
0];


ub = [1E-7













1E10
%0.5
%0.5
2
1E10
1E-1
1E-1
10 ;

t = clock;
%Optimize

disp('Using Adaptive Simulated Annealing')
disp('ASA 25.5')
disp('http://www.ingber.com/#ASA')
%Usage
%[fstar,xstar,grad,hessian,state] =
% asamin ('minimize', func,xinit, xmin, xmax, xtype)
xtype = -1 ones(7,1);
[fval,xfinal,grad,hessian,state] =
asamin ('minimize', 'fAllError',xO.array, lb, ub, xtype)



t = etime(clock,t);

mfit.aNO=xfinal(1); %maximum enzyme production rate
mfit.K2=xfinal(2); %controls lag length
mfit.Vsni=xfinal(3); %maximum N03 uptake;
mfit.K1=xfinal(4);
mfit.Knoi=xfinal(5);
mfit.Koi=xfinal(6);
mfit.bNO = xfinal(7);

disp('Optimization Complete')
disp('Initial Function Value')
disp(num2str(fvalinit))
disp('Final Function Value')
disp(num2str(fval))
disp('Optimization Statistics')
%disp(output)
disp('Time Elapsed during optimization')
disp(t/60)
disp('Model Parameters')
disp(mfit)

save mfit mfit;
save final final;



















APPENDIX D
EXTENDED KALMAN FILTER SOURCE CODE

D.1 Code for TestKSim.m


disp(sprintf('\n*******************************\nFile:\t\tTestKSim'))
%test fKanapahaSim.m
%load testvalues;
load decjankops2;

%TEMP duplicate these conditions for the other train
%kops = [kops(:,l) kops(:,2:9)/2 kops(:,2:9)/2 kops(:,10:24)];

%load deckops;
%load decjanflatkops;



%cut down to 1 day
kops = kops(l:168,:);
runASM = false;
useode23s = true;
plotreactors = [4];



if runASM
load XssASM;
else
% load Xss;
load XssMonthEnd;

%double xinit for the second train
xinit = [xinit xinit];
end

disp(sprintf('Run:\t\tday %2.0f to day %2.0f',kops(1,1)/24,kops(end,l)/24))

et = clock;
[t, allX, rctr, SRT] = fKanapahaSim(xinit, kops, runASM,useode23s, [], []);
et = etime(clock,et);

disp(sprintf('Simulated Time:\t%O.lf hr',kops(end,1)))













disp(sprintf('Elapsed Time:\t%O.if s',et))
disp(sprintf('Sim rate:\t%0.1f hrs/s',kops(end,l)/et))

save testksimoutput t allX rctr SRT;

for i = plotreactors
figure(i);
fPlotTank(rctr(i));
end

% figure(6)
% fPlotKOp(kops);

figure(7)
fPlotComp(rctr,'So');
for i = 1:5
[m, o] = fKanapahaModelOpsSetup(runASM);
subplot(5,l,i);
line([0 7],[m.Koa m.Koa],'Linestyle','--','Color','k');
line([0 7],[m.Koh m.Koh],'Linestyle','--','Color','k');
end

% figure(11)
% fPlotComp(rctr,'Snh');
% figure(12)
% fPlotComp(rctr,'Sno');
if "runASM
figure(13)
fPlotComp(rctr,'En');
end

figure(9)
set(9,'Name','All Variables for Tank');
fPlotTankAllVars(rctr(4))

figure(208)
set(gcf, 'Name', 'Compare Probe Data');
fPlotCompareProbes(rctr(4),rctr(10));

%**************************************************************************
%Output
disp(sprintf('final SRT:\t%0.1f days',SRT(end)))




Full Text

PAGE 1

MODELINGBIOLOGICALNITROGENREMOVALWITHDENITRIFICATIONENZYMEPARAMETERESTIMATIONByRYANK.HAMILTONADISSERTATIONPRESENTEDTOTHEGRADUATESCHOOLOFTHEUNIVERSITYOFFLORIDAINPARTIALFULFILLMENTOFTHEREQUIREMENTSFORTHEDEGREEOFDOCTOROFPHILOSOPHYUNIVERSITYOFFLORIDA2005

PAGE 2

Copyright2005byRyanK.Hamilton

PAGE 3

Tomywife,withoutwhosesupportmyworkwouldhavebeenimpossible.

PAGE 4

ACKNOWLEDGMENTSIwouldliketothankmysupervisorycommitteechairSpyrosA.SvoronosandcochairBenKoopmanfortheiradviceandguidance.IthankmycommitteemembersAtulNarangandMadelineRaschefortheirgeneroushelp.Iwouldliketoalsothankmycolleagues,AnnaCasasusandDonLee.Withouttheirsupport,thelonghoursofexperimentwouldhavebeenfatal.Finally,Iwouldliketothankmywifeforstandingbymeduringtheseyearsofstudy. iv

PAGE 5

TABLEOFCONTENTS page ACKNOWLEDGMENTS ............................. iv LISTOFTABLES ................................. vii LISTOFFIGURES ................................ viii ABSTRACT .................................... ix CHAPTER 1CONTROLISSUESANDCHALLENGES ................. 1 1.1Introduction .............................. 1 1.2SewerSystem ............................. 2 1.3AerobicReactor ............................ 5 1.4AnoxicReactor ............................ 6 1.5SecondarySettlingTank ....................... 7 1.6Filters ................................. 8 1.7DisinfectionBasin ........................... 8 1.8ModelingChallenges ......................... 10 1.9FurtherRemarks ........................... 12 2AUTOMATIONOFLAB-SCALEBIOREACTORS ............ 14 2.1Introduction .............................. 14 2.2Materials,MethodsandResults ................... 14 2.3Conclusions .............................. 20 3MODELFORDENITRIFIERDIAUXICGROWTH ........... 22 3.1Introduction .............................. 22 3.2Model ................................. 23 3.3MaterialsandMethods ........................ 27 3.3.1BacterialStrainandGrowthConditions ........... 28 3.3.2NitrateReductaseAssay ................... 29 3.3.3ParameterEstimation ..................... 30 3.4ResultsandDiscussion ........................ 31 3.5Conclusions .............................. 36 3.6EnzymeSynthesisExpressionDerivation .............. 39 v

PAGE 6

4KALMANFILTERFORENZYMEPARAMETERESTIMATION ... 41 4.1Introduction .............................. 41 4.2KanapahaWaterReclamationFacility ............... 42 4.2.1HydraulicModel ........................ 45 4.2.2BiologicalModel ........................ 49 4.3KalmanFilter ............................. 49 4.4ResultsandDiscussion ........................ 53 4.5Acknowledgments ........................... 56 5FUTUREWORK ............................... 57 5.1DistributedStateModeling ...................... 57 5.2ExtendedKalmanFilter ....................... 57 5.3EnzymeActivityBasedDynamicOptimization ........... 59 APPENDIX AKALMANFILTER-SUPPLEMENTALMATERIAL ........... 61 BAUTOMATIONPROGRAMSOURCECODE .............. 69 B.1CodeforDLECModule.bas ...................... 69 B.2CodeforDLECEmailModule.bas .................. 73 B.3CodeforDLECPhoneCallModule.bas ................ 76 B.4CodeforDLECLogFileModule.bas .................. 77 CDENITRIFIERDIAUXICGROWTHMODELSOURCECODE .... 81 C.1CodeforRun061703.m ........................ 81 C.2CodeforRunModel.m ........................ 82 C.3Codeformodel5c.m .......................... 85 C.4CodeforFitAllData.m ........................ 87 DEXTENDEDKALMANFILTERSOURCECODE ............ 89 D.1CodeforTestKSim.m ......................... 89 D.2CodeforRunKEKF.m ........................ 91 D.3CodeforfKanapahaSim.m ...................... 95 D.4CodeforfKanapahaModelOpsSetup.m ............... 103 D.5CodeforfKanapahadxdt.m ...................... 107 D.6CodeforfParseAllX.m ........................ 111 D.7CodeforfExtendedKalmanFilter.m ................. 114 D.8CodeforPlotKEKFData.m ..................... 128 REFERENCES ................................... 133 BIOGRAPHICALSKETCH ............................ 138 vi

PAGE 7

LISTOFTABLES Table page 2{1Equipmentlist ............................... 21 3{1Syntheticmediacomposition ....................... 28 3{2Parametervaluesobtainedbytting .................. 32 3{3Nomenclatureusedindenitriermodeling ................ 38 4{1Wastewatercomposition .......................... 44 4{2eASM1mmodel .............................. 50 4{3eASM1mparametervalues ........................ 50 A{1Aerobicbasinsurfaceaerators ...................... 62 A{2Hydraulicmodelparameters ....................... 64 A{3eASM1mModel .............................. 65 A{4eASM1mparametervalues ........................ 66 vii

PAGE 8

LISTOFFIGURES Figure page 1{1Exampleplantdiagram .......................... 2 1{2KanapahaWaterReclamationFacility ................. 3 2{1AutomationsystemProcessandInstrumentationDrawingPID ... 15 2{2Eectofrinsingsamplepathonbiomassmeasurements ........ 17 2{3Softwareinterface ............................. 19 2{4Experimentcongurationscreen ..................... 20 3{1Biochemicalprocessmodel ........................ 24 3{2Modeloverview .............................. 25 3{3Modelttoliteratureresults ....................... 33 3{4Enzymeactivityduringdiauxicgrowth ................. 34 3{5Additionalexperimentswithmodelts ................. 35 4{1Kanapahaphysicalprocesslayout. .................... 45 4{2Kanapahaoperations{aerationstrategy. ................ 46 4{3Kanapahaoperations{recyclesandrecirculations. ........... 47 4{4Hydraulicmodelprocessdiagram .................... 48 4{5EKFresults,aN,nitrateandammonia ................. 55 A{1HydraulicmodelPID ........................... 62 A{2Diurnalowpatterns ........................... 67 viii

PAGE 9

AbstractofDissertationPresentedtotheGraduateSchooloftheUniversityofFloridainPartialFulllmentoftheRequirementsfortheDegreeofDoctorofPhilosophyMODELINGBIOLOGICALNITROGENREMOVALWITHDENITRIFICATIONENZYMEPARAMETERESTIMATIONByRyanK.HamiltonDecember2005Chair:SpyrosA.SvoronosCochair:BenKoopmanMajorDepartment:ChemicalEngineeringAsurbanpopulationdensityhasincreasedithasbeennecessarytodevelopevermoresophisticatedwastewatertreatmenttechnology.Watersthatacceptdomesticwastewaterreceivepollutantsintheformofnutrientsprimarilyorganiccompoundsandammoniathat,ifleftuntreated,couldspurabloomofmicroorganismgrowthandcausediseaseinthehigherorganismsthatconsumedthewater.Mostmodernwastewatertreatmentfacilitiesusesometypeofactivatedsludgeprocessinwhichnaturallyoccurringmicroorganismsarecultivatedinthewastewaterunderconditionsthatattempttooptimizetheconsumptionofinuentnutrients.Thisworkpresentsmodelsandtechniquesforpredictingtheperformanceofbiologicalnutrientremovalsystems,bothbench-scaleandplant-scale.Presentedisamodelfordiauxicgrowthofdenitrifyingbacteriainwhichnitratereductasesynthesiskineticsdominatetheoverallgrowthkinetics.Themodelisbasedontheassumptionoftheexistenceofanitraterespirationoperon,therebylinkingtherateofnitrateuptaketotheactivityofnitratereductase.IhaveshownthatthisapproachcanmodeldiauxicgrowthofPseudomonasdenitricans ix

PAGE 10

byconductingexperimentsinwhichnitratereductaseactivitywasmeasuredduringbothlagandensuingexponentialgrowthphases.Iconsistentlyobservedthepatternoflownitratereductaseenzymeactivityduringthelagphase,increasingbeforetheonsetofgrowth.ByttingmodelparametersIwasabletosuccessfullymatchexperimentaldataforgrowth,nitrateuptakeandenzymeactivitylevel.IncooperationwithGainesvilleRegionalUtilities,aprocessmodelwasdevelopedfortheKanapahaWaterReclamationFacilityKWRFpredenitricationprocessinGainesville,Florida.TheprocessmodelincorporatesabiochemicalmodelfordiauxicgrowthofpureculturesofdenitrifyingbacteriathatisintegratedwiththeindustrystandardActivatedSludgeModel1.Idemonstrate,usingrealfacilityoperatingdata,thatbyapplyinganextendedKalmanltertoasinglebioreactorIobtainestimatesforbothreactorcompositionanddenitricationenzymemodelparameters.Thistechniqueforparameteridenticationallowsasemi-mechanisticmodeldevelopedforpureculturestobeappliedtoamixedculturepopulationwhereisolationofenzymekineticparametersisnotpractical. x

PAGE 11

CHAPTER1CONTROLISSUESANDCHALLENGESINWASTEWATERTREATMENTPLANTS 1.1 IntroductionAsurbanpopulationdensityhasincreasedithasbeennecessarytodevelopevermoresophisticatedwastewatertreatmenttechnology.Therewasasignicantimprovementinurbansanitationwiththeboominpopularityofindoortoiletsintheearly1900showeverthisincreaseoccurredattheexpenseofthedownstreamreceivingwaters.Thesewatersreceivedpollutantsintheformofnutrientsprimarilyorganiccompoundsandammoniathat,ifleftuntreated,couldspurabloomofmicroorganismgrowthandcausediseaseinthehigherorganismsthatconsumedthewater.Moderncitiesoperatetreatmentfacilitiesofevergrowingscaleandsophisticationinordertotreatwastewatertoalevelthatnaturalsystemscansafelyabsorbwithoutnegativeimpact.Mostmodernwastewatertreatmentfacilitiesusesometypeofactivatedsludgeprocessinwhichnaturallyoccurringmicroorganismsarecultivatedinthewastewaterunderconditionsthatattempttooptimizetheconsumptionofinuentnutrients.ThemajorityofplantsintheUnitedStatesaimtoaccomplishonlycarbonremoval,andissuesofcontroltherepertainprimarilytoaerationcontrolforenergyusageandsatisfyingprocessdemands.Thereisasignicantcontrolissueforthesefacilitiesinthatadequateoxygenhastobeprovidedinspiteofsignicantandcontinuallychanginginuentconditionswithoutexcessiveaerationthatwouldwasteenergy.Increasingpressuretoalsoremovenutrientssuchasnitrogenandphosphorusrequiresmorecomplicatedprocessesthathaveseveraloptimizationandcontrolissues.Nutrientsaretransformedatdierent 1

PAGE 12

2 Figure1{1:Exampleplantdiagram.SewageiscollectedbylocalpumpingstationsbeforepassingtothetreatmentfacilityhereaLudzack-Ettingerprocess.Inuentrstpassesthroughananoxicbioreactorinwhichnitrateisreducedtonitrogenandsomeorganiccarbonisconsumed.Intheaerobicbioreactormostorganiccarbonconsumptionoccursandammoniaisconvertedtonitrate.Themixedliquorrecirculationreturnsthegeneratednitratetotheanoxicreactorforreductiontonitrogengas.Thesecondarysettlingtankreturnsaconcentratedstreamofactivatedsludgetotheanoxicreactorwhilepassingclariedeuenttothelters,andfromtheretothedisinfectionbasinforinactivationofharmfulmicroorganisms. ratesdependingonreactorenvironmentandotheroperatingconditions.Eithercyclicoperationormulti-reactorfacilitieshavebeeneectivelyutilizedfornutrientremoval.Controlandoptimizationofwastewatertreatmentfacilitieshasbeenanareaofinterestforoveracentury.Asanexampleofthesizeoftheindustry,in1996$16.7billionwasspentintheU.S.onwastewatertreatmentoperations. 1.2 SewerSystemTherstcontrolissuethatcanseriouslyimpactplantoperationisregulationoftheinuentowratetothewastewatertreatmentplant.Thenormalday/nightcycleofhumanactivitycausesdiurnalvariationinsewageow.Therearealsosurgesinowrateduetorainfallenteringthesewersystemviacracksinpipes

PAGE 13

3 Figure1{2:KanapahaWaterReclamationFacility.Thisfacilityusestwodierentbiologicalnutrientremovalprocessesinparalleltotreat10milliongallonsofwastewaterperdaywithatotalbioreactorvolumeof11.2MgalNotethatthisisanunusuallylargeratioofreactorvolumetoowrate.PicturedaretheadjacentEastandWestaerationbasins,totaling4.8milliongallons.

PAGE 14

4 inltrationandthroughmanholecoversandotheropeningsinow.Onemethodofsmoothingowvariationsistobuildequalizationbasinsupstreamofthewastewatertreatmentplant.Thisiscommonpracticeatfacilitiestreatingindustrialwastewatersbutisusuallytooexpensiveformunicipalwastewatertreatmentplants.Inafewcases,theinherentstoragewithinthepipesandpumpingstationsthatmakeupasewersystemhasbeenutilizedtosmoothvariationsinplantfeedrates.TheQuebecUrbanCommunityhassuccessfullyimplementedsucharealtimecontrolsolutiontothisproblembyimplementingaglobaloptimalpredictivesewercontrolsystemthathasbeenoperatingsincethesummerof1999 Schutzeetal. 2004 .Thissystemroutesowsandcontrolsvolumesinthesewersystemtomeetaseriesofrankedcontrolobjectives. 1. Minimizationofcombinedseweroverows. 2. Maximizationoftheuseoftreatmentfacilitycapacity.Treatmentfacilitiesaredesignedbasedonassumedfeedrates,andafeedratethatistoolowcanadverselyimpactplantperformance. 3. Minimizationofaccumulatedvolumes.Thecontrolschemetriestomeetitsgoalswithminimalheldvolumeinthesewersystem. 4. Minimizationofsetpointvariation.Astillmoresophisticatedsystemwouldcoordinatethesegoalswiththedynamicallychangingneedsofthetreatmentfacility,buttoourknowledgesuchaunicationhasneverbeenimplemented.Othercitiesaremovinginthisdirection.Forexample,Chicagorecentlynishedinstalling109milesoftunnelswithastoragecapacityof15.6billiongallonstoaddresstheproblemofsystemoverowsanddemanductuation.

PAGE 15

5 1.3 AerobicReactorUponenteringthetreatmentfacilityandbeingcombinedwithanyinternalrecyclestreamswastewaterentersoneormorebioreactorswheremostofthenutrientremovaltakesplacebyacomplexmixedpopulationofmicroorganisms.Someofthesemicrobesgrowonlyunderaerobicconditionsdissolvedoxygenpresent,whereasothersarecapableofgrowthunderbothanoxicutilizingnitrateinsteadofoxygenasterminalelectronacceptorandaerobicconditions.Manyplantcongurationswithdierentcombinationsofreactors,recirculationsandrecyclesarecommonlyused;howeverallmeetthesamebasicneeds.TheoneuniversalrequirementisremovalofbiochechemicaloxygendemandBOD,whichisameasureoftheamountoforganiccarbonavailabletosupportmicrobialgrowth.Additionally,removalofnitrogenorphosphorusisarequirementatagrowingnumberoffacilities.Aerobicconditionsareconducivetothegrowthofawidevarietyofmicrobes,includingheterotrophicbacteriathatremoveBODfromthewastewater,aswellasnitrifyingbacteriathatoxidizeammoniatonitrate.Aerationistypicallyaccomplishedusingsurfaceimpellersorsubmergeddiusersandaccountsforthelargestenergycostintheseplants.Thecostofenergyforaerationthroughoutafacilitycanbe50%ofthetotalplantenergycosts,althoughinsomecasesthiscanbeashighas75%,asitisattheKanapahaWaterReclamationFacilityinGainesville,Florida.Inthisfacilityswitchingfrommanualaeratorcontroltoautomaticresultedinasavingsof10to30%onanannualcostof$600,000.TheaerationenergycostcombinedwiththeverystrongeectofaerationonbiomassgrowthmakesdissolvedoxygenDOcontrolthemoststudiedcontrolprobleminwastewatertreatment.Theproblemismademorecomplicatedbythefactthatoxygenuptakerateschangeunderdierentplantloadingsandtemperatures.Themostfrequentlyusedcontrolstrategyistomanipulatethe

PAGE 16

6 aerationratetocontroldissolvedoxygenDO,usuallyataxedsetpointregardlessofload.HighDOpromotesbacterialgrowth,butalsoleadstohigheraerationcosts.HighDOcanalsobeaproblemfornitrogenremovingplantsifitleadstorecirculationofexcessiveDOtotheanaerobicdenitricationreactors.SeveralmoresophisticatedcontrolschemeshavebeendevelopedthatvarytheDOsetpointsinordertominimizecostswhilemeetingeuentrequirements.Oneschemethathasbeenattemptedisfeedforwardaerationcontrolbasedoninuentammonia,inwhichaconcentrationspikeofinuentammoniumismeasured,andtriggersatravelingwaveofincreasedDOsetpointsdownthelinecorrespondingtothecalculatedhydraulicsofthespike Ingildsenetal. 2002 .InfacilitiesthatvarytheDOsetpoint,themostcommonapproachiscascadecontrolinwhichtheDOsetpointismanipulatedbyanoutercontrolloopinordertocontroleuentquality.ThisdecouplesthefastDOresponsefromtheslowerdynamicsofnaleuentquality.Manytechniques,suchasfuzzycontrolandexpertsystemshavebeenusedfortheoutercontrolloop,however,ithasrecentlybeenarguedthatthisproblemwouldbemoreaccuratelyaddressedasamultivariablecontrolproblemratherthanmultiloop SteensandLant 1999 1.4 AnoxicReactorAnoxicreactorsareusedincaseswherenitrogenremovalisaprocessgoal.Throughdenitrication,whichtakesplaceinanoxicreactors,nitrogenisreducedthroughseveralintermediatestonitrogengas,whichpassesharmlesslyintotheatmosphere.Facultativeanaerobesintheanoxicreactorusenitraterecirculatedfromtheaerobicreactorasterminalelectronacceptorforgrowthunderoxygen-freeconditions.Acontrolissuehereistherecirculationrate.Itmustbefastenoughtosupplyadequatenitratewithoutintroducingexcessivedissolvedoxygen.Additionalnitrogenremovalisaccomplishedinsomeprocessschemesinananoxicreactorfollowingtheaerobicreactor.Analternativetohavingdedicatedanoxicreactorsis

PAGE 17

7 tohavecyclingofaironandointhesamereactor,thuscombiningnitricationanddenitricationinthesamereactor.Plantscanachievephosphorusremovalbyprovidingprocessconditionssuchasananaerobictankatthebeginningofthebioprocesstrainthatencouragethegrowthofphosphateaccumulatingbacteriawhichconvertsolublephosphatetopolyphosphate. 1.5 SecondarySettlingTankAfterleavingthebioreactors,activatedsludgeentersasecondarysettlingtank,whereocsconsistingofmicrobesandotherparticulatematterareallowedtosettleandformasludgeblanketatthebottomofthetank.Clariedeuentexitsatthetopofthetankandowstothelterswhilesludgeiscontinuouslyremovedfromthebottomofthetank.On-linedepthofblanketsensorsmonitorthedepthofthesludgeblanket,whichtheoperatorsoracontrolsystemusetoadjustthesludgereturnrate.Ifthereturnrateistoolow,thesludgeblanketcanapproachthewatersurface,whereitcouldeasilybesweptintotheeuent.Ifthereturnrateistoohigh,turbulenceintheclarierwillcausethesludgeblankettobecomeuy,dilutingtheunderowstreamandreducingclariereciency.Almostallofthesludgecollectedfromthebottomofthesecondarysettlingtankisreturnedtothebioreactors.Asmallfractionofthesludgeisremovedwastedfromthesettlingtankforfurtherprocessinge.g.digestion.ThewasterateisavariablethatcanbeusedtomanipulatesolidsretentiontimeSRT,whichinturncontrolsthenetgrowthrateofmicrobesintheprocess.Thus,SRThasaverylargeimpactontheoverallplantdynamics.OnecontrolapplicationhereistimingthesludgewastesothatitoccursatthetimeofdaywhensludgeconcentrationsareatamaximuminordertoreducehydraulicloadingandmaximizeSRTinthedigestersthatreceivethesludge.InthecaseoftheKanaphaWaterReclamationFacilitiyKWRFinGainesville,Florida,Thisstrategy,combinedwithon-linenutrientand

PAGE 18

8 pHmeasurementsinthedigestereliminatedtheneedfora5to10milliondollarexpansioninordertomeetEPACFR-503ClassBbiosolidsregulations.Onemotivationforcontrollinginuentwastewaterowratesistoavoidupsettingthesludgeblanketinthesecondarysettlingtank.Asuddenowspikecancausetheblankettodislodgeandentertheupperclariedeuentstream,whereitcanclogtheltersinthenextstageoftreatment.IntheKanapahafacilityaPIDcontrollerisusedtosetaowratiobetweentheclariereuentowandthesludgereturnrate.Thissavesthousandsofdollarsannuallyinpumpingcosts,butmoreimportantlyeliminatesthepossibilityofaplantupsetduetoadislodgedsludgeblanket. 1.6 FiltersThepurposeofltrationistodecreasetheconcentrationofparticulatesolidsinthetreatedeuentbypassingwaterthroughgranularorclothmedia.Filterrunsarecontinueduntilheadlossincreasestothemaximumallowedlevel.Atthispointowisreversedtodislodgeaccumulatedparticulatematerialsbackwashing.Thelteristhenreturnedtonormaloperation.Themajorcontrolissueistheuseofschedulingversusheadlosstoinitiatebackwashing. 1.7 DisinfectionBasinThenaltreatmentstepisdisinfection,commonlyaccomplishedwithchlorinedosingorultravioletlightexposure.Inthisprocess,manyoftheremainingmicroorganismsarekilledbeforethetreatedwaterisallowedtoleavetheplant.Infacilitiesthatuseachlorinationbasin,thefacilityisrequiredtohaveacertaineuentconcentrationofchlorineinordertoguaranteeaminimumlevelofdisinfection.Chlorineisaddedatthebeginningofachlorinecontactbasinandalargeamountimmediatelyreactswithammonianitrogenammonianitrogenchlorinedemandinthewater,leavingsomefractionfordisinfection.Theeuentlevelmustbesucientfordisinfection,howeverexcessivechlorinationfavors

PAGE 19

9 formationoftoxictrichloromethanes,whichareregulatedinwaterdischargedintotheaquifer.Byusingonlythenecessaryamountofchlorinethefacilityreducestheneedtostorelargequantitiesofadangerousandexpensivechemical.Controllingeuentchlorineisfrequentlybasedonafeedbackloopthatsetsthechlorinedosebasedontheeuentchlorineconcentration.However,theammonianitrogenchlorinedemandvarieswiththeloadingoftheplant,sotherequisitedosewilluctuatewiththedailyusagecycle.Largedisturbancescombinedwithsignicantdeadtimesposeasignicantchallengetotightcontrolofeuentchlorine.Thedeadtimesuctuatebyafactorof10overa24hourperiod,soaSmithPredictorprovesinadequate.Onesolutionthathasbeenemployedisacascadeschemeinwhichaninnercontrolloopmanipulatesthedosinginordertomaintainasetpointconcentrationmeasurednearthebeginningofthebasin.Thisshortdeadtimeloopallowsforrapidcontroldynamicstocompensatefoructuationsinammonianitrogenchlorinedemand.Theoutercontrolloopmaintainsthebasineuentconcentrationbymanipulatingthesetpointfortheinnercontrolloop.Theouterloopisabletocompensateforlargedailyuctuationsasaresultofslowdisturbances.Anovelsolutiontothisproblemhasrecentlybeenproposed Meredith 2003 inwhichadynamicweirattheendofthecontactbasinisraisedorloweredinordertochangethereactorvolumeinresponsetochangesinowrate.Bydoingso,theresidencetime,andhencethedeadtime,becomesconstantandtraditionaldeadtimecompensationtechniquesmaybeemployed.InthecaseofUVdisinfection,themanipulatedvariableisthenumberofbanksoflightsactiveatanytime,andoptimizationissimplyenergycostvs.acceptabledisinfectionlevel.

PAGE 20

10 1.8 ModelingChallengesAsisthecaseinmostprocesses,themajorityofdevelopmentisdonewithso-calledwhite-boxmodels,meaningthatthemodelsaredevelopedfromrstengineeringprinciples.TheoverallwastewatertreatmentplantWWTPmodelconsistsoftwomainparts.Thehydraulicmodelrepresentsreactorbehaviorplugow,CSTRetc,owratesandrecirculation.Oneuniqueunitoperationisthesecondarysettlingtank.Thereareafewsecondarysettlingtankmodelsinuse,themostcommonofwhichistheidealorpointclarierwithnoretentiontime,inwhichthebottomstreamissimplyenrichedwithparticulatesbyaratiodeterminedbystreamowrates.Iftheimpactofoperatingpointsonsludgesettlingisofinterest,aone-dimensionalsettlermodelmaybeused,orforexplorationoftheeectofowrateandturbulence,a2or3-dimensionalmodelmaybeappropriate.ThesecondprimarycomponentofaWWTPmodelistheactivatedsludgemodelthatportraysthemicroorganismgrowth,deathandnutrientconsumption.Thesemodelsarenecessarilyapproximationstothevastnumberofbiologicalprocessesoccurringineachbioreactor,butselectionofthepropermodelwillallowadequatedescriptionofthoseprocessesmostrelevanttoaparticularWWTP.ThereferencemodelofbiochemicalreactionsinthebioreactorsisActivatedSludgeModelNo.1ASM1 Henzeetal. 2000 ,whichwasdevelopedbytheInternationalWaterAssociation.Thesuccessofthismodelpromptedthewidespreadadoptionofbiochemicalmodelingofwastewaterinbothacademiaandindustry.Forthosefacilitieswherebiologicalphosphorusremovalisdesirable,astandardmodelisActivatedSludgeModelNo.2d Henzeetal. 2000 .Thismodelportraystheprocessesbywhichphosphateaccumulatingorganismsstorephosphateaspolyphosphateunderaerobicconditionsandhydrolyzeitunderanaerobicconditions.Morerecently,theTUDPmodel vanVeldhuizenetal. 1999 hasbeen

PAGE 21

11 proposed.Thismodelcombinestheknownmetabolicmodelfordenitricationandbio-PremovalwiththeASM1sludgeproductionmodel.Thesemodelshavelimitationsinseveralrespects.Inthemostcommon,ASM1,thereisnotemperatureeect,eventhoughtemperaturehasasignicantimpactonsludgebehavior.Instead,modelparametersareprovidedat10and20C.InASM2andTUDPthetemperatureeectisportrayedwithArrhenius-typeequationsvalidintherangefrom10to25C.AnotherlimitationoftheASMmodelsisthattheycannotportrayalagingrowthwhenswitchingelectronacceptors.Workhasbeengoingontoaddthesecapabilities.Workhasalsobeendonetoextendthesemodelstoportraytheeectofaslugoftoxicinuentsuchasethanol Nowaketal. 1997 .Inthisevent,thesludgemetabolism,particularlynitrication,isdramaticallyinhibited.Thisproblemisnormallyaddressedonacase-by-casebasisdependingontheparticularfacility,butanotherpossiblesolutionwouldbetouseanon-linemodelparameterestimationtechnique.Thenextfrontierofwhite-boxmodelingisthemergerofdistributedstatemodelsandcomputationaluiddynamicsCFD.Inthesemodels,someorallstatevariablesdonothaveasinglevalue,butarerepresentedbyadistributioncurve.WhiletheSRTofafacilityprovidesinformationaboutthefractionofactivebiomass,adistributedstateapproachwouldprovidethatcurvedirectly.Distributedstatemodelsarecurrentlyhighlydemandingcomputationally,buthavethepotentialtoprovidegreatnewinsightsintobiologicalwastewatertreatment.Thebenetofthedistributedstateapproachisparticularlysignicantformodelswithnonlinearbehaviorbasedonconcentrationsofintracellularcomponents.Considerthecaseofdiauxiclag,inwhichaerobicallyculturedfacultativeanaerobesareintroducedintoananoxicenvironment.Theywillexperienceaperiodoflittleornogrowthduringwhichtheysynthesizenecessaryenzymesforgrowthunderthenewconditions.Now,considerananoxicreactor

PAGE 22

12 containingbacteriaexperiencingalongdiauxiclagintowhichisintroducedaninnoculumthathasbeengrowingexponentiallyunderidenticalanoxicconditions.Commonsensedictatesthatthenewinnoculumwillcontinuetogrowexponentiallyinthenewreactorwhilethepreexistingculturecontinuestoexperiencelag,butadistributedstatemodelisrequiredtocapturethisbehavior.Atraditionalmodelwouldtaketheanoxicgrowthenzymelevelsoftheinnoculumandaverageitoutovertheentirepopulation,resultingintheincorrectpredictionthattheentirepopulationisstillexperiencingadiauxiclag.Asimilarargumentcouldbemadeforphosphorusmetabolism,inwhichstoredpolysphosphateisusedasanenergystoragecompoundbycertainclassesofbacteria,highlightingfurtherthebenetofdistributedstatemodelinginwastewatertreatment.Developmentofaccurateprocessmodelsisaprerequisiteforapplicationofmodelpredictivecontroltechniquesforwhole-processcontrolanddynamicoptimization. Gernaeyetal. 2004 isrecommendedasarecentreviewofwastewatertreatmentmodeling. 1.9 FurtherRemarksItshouldalsobenotedthatwastewaterbioreactorsareaveryharshenvironmentforprobes.Forexample,dissolvedoxygenprobesthatdonotrequirefrequentreplacementhaveonlyrecentlybecomeavailable.Partofthereasonfortherelativelyunderdevelopedstateofwastewatertreatmentcontrolisthedicultyinobtainingaccurateprocessinformation.Inaddition,manykeyvariablesmustbemeasuredoine.Thishaspromptedrecentworkinwastewatertreatmentplantstateestimation TennoandUronen 1995 ; Jorgensenetal. 1992 .Withrapidimprovementsbeingmadeinsensortechnology,theinformationdecitproblemisdisappearing.Furthermore,fasterprocessingcapabilities,whichhavebeensocrucialtotheapplicationofcontrolasadiscipline,arenowallowingnonlinear

PAGE 23

13 processcontrolanddynamicoptimizationtechniquestobeappliedtoproblemsaslargeasawastewatertreatmentfacility.ThechallengingoperatingenvironmentcoupledwithresponsedynamicsrangingfromminutesDOtoweeksSRThasresultedinagreatdealofadvancedcontrolworkhavingbeendoneinsimulation,butverylittleinwastewaterplantsthemselves.

PAGE 24

CHAPTER2ANINEXPENSIVEMETHODFORTHEAUTOMATIONOFLAB-SCALEBIOREACTORS 2.1 IntroductionBacterialgrowthexperimentsmaylastseveraldays,orevenweeks.Duringthistimeitmaybenecessarytoadjustbioreactoroperatingparameters,whichrequireseithertheattentionofaresearcher,oranautomatedcontrolsystem.Wehavedevelopedaninexpensivesystemforcontinuousabsorbancemeasurementsusingow-throughspectrophotometersandsolenoidvalvesunderthecontrolofaVisualBasicprogram.Thissystemperiodicallysamplesabioreactor,measuresthebiomassabsorbanceandthenrinsesthesamplelinebetweenmeasurements. 2.2 Materials,MethodsandResultsAlayoutsketchoftheexperimentalapparatusisgiveninFigure 2{1 .BatchcultureexperimentswerecarriedoutinastirredbioreactorMulti-genmodelF-2000,NewBrunswickScientic,NewBrunswick,NJ.ThebioreactorwascycledbetweenaerobicandanoxicconditionstoexplorediauxicgrowthofPseudomonasdenitricansAmericanTypeCulturesCompany13867,Manassas,VA.Thecyclingwasaccomplishedbyalternatelyspargingtheculturewithairandnitrogenfrompressurizedcylinders.Theswitchingbetweenthesegaseswasaccomplishedusingtwocomputer-linkedsolenoidvalves,oneoneachfeedline.Gasesweresterilizedbyltration.22micronWhatmanHEPA-Ventltersandpre-humidiedbyspargingthroughsteriledeionizedwaterbeforeintroductiontothebioreactor.Biomasswassampledfromthebottomofthebioreactorthrough0.03inchI.D.TygontubingMasterex06409-13,ColeParmer,Chicago,IL.Thereactoreuent 14

PAGE 25

15 Figure2{1:AutomationsystemProcessandInstrumentationDrawingPID owedtoa4.5Lclariermm.Thebiomasspassedthroughaow-throughcellinaspectrophotometerThermo-SpectronicGenesys10UV,ThermoElectronCorporation,Waltham,MA.Thisspectrophotometerisrelativelyinexpensiveandsupportscommunicationwithapersonalcomputer.Thetubingendinthebioreactorwasbentupwardstopreventgasbubblesfromenteringthesampleline.Bubblestendedtobecometrappedinthespectrophotometerowcell.Thespectrophotometerwasinclinedat3degreestohelpbubblespassthroughtheowcell.Acomputer-linked3-waystainlesssteelsolenoidvalveParker/Skinner3133BSN1AN00N0M1S1P0,Parker,NewBritain,CTcontrolledwhethersampleorarinsingsolutionreachedthespectrophotometer.Amajorproblemofthesamplingsystemwasaccumulationofbiomassontheinnerwallsoftheowcell.Thiscausedthemeasuredabsorbancetoincreasewithtime,regardlessofthetruesampleabsorbance.Higherowsfailedtoshearbiomassfromthewalland,infact,exacerbatedtheproblem.Inresponsetothis,arinsing

PAGE 26

16 systemwasadded.Inthissystem,asolenoidvalveswitchesthesamplinglinefeedtoarinsingsolutionafterameasurementismadebyaspectrophotometer.Initially,sodiumdodecylsulfatesolutionwasusedforrinsing,butitwasfoundthattheSDSitselfaccumulatedonthewallsofthecuvette,compoundingourbiomassaccumulationproblemwithsoapscum.Wenexttrieddeionizedwater,butfoundthatityieldedonlyasmallimprovementovernorinsing.Weultimatelyfoundthatasolutionof50mg/Lchlorineinwater+1999dilutionof10.5%sodiumhypochloritesubstantiallylimitedaccretionofbiolmwithintheowcellwithoutcausinganyotherproblems.Figure 2{2 showstwotypicalruns,onerinsedwithchlorinesolutionandonewithoutrinsing.Bothofthesesetsofdataweretakenfromthesamebioreactorsothat,intheabsenceofbiolmaccretion,theyshouldbeidentical.Therinseddataalternatedbetweenmeasurementsofbiomassandmeasurementsofrinsesolution.Asseeninthegure,themeasurementstakenoftherinsingsolutionremainedverynearthebaselinezeroabsorbancethroughouttheexperiment.Iftherewereaccumulationofbiolminsidetheinstrument,wewouldhaveobservedanincreaseinabsorbanceoftherinsesolution.Themeasurementsofbiomassabsorbancetakeninthisinstrumentcanthereforebeconsideredtobefreeofsystematicerrorscausedbyaccumulationofbiolm.Incontrast,themeasurementstakenwithoutrinsingaresubstantiallyhigherthanthemeasurementswithrinsing.Thissuggestsanaccumulationofbiomassonthewallsoftheowcelloftheunrinsedspectrophotometerand,infact,biolmandparticulatematterwereobservedinpreviousexperimentsthatusedunrinsedsamplepaths.Whenthesystemisswitchedfromrinsingsolutiontoreactoreuentittakesapproximately8minutesforthemeasuredabsorbancetomatchthatofthebioreactor.Tobesafe,theentiremeasurementcyclewassetto30minutes:15minutesofrinsing,atwhichpointameasurementistakentocheckforow

PAGE 27

17 Figure2{2:Eectofrinsingsamplepathonbiomassmeasurements cellaccumulation,followedby15minutesofreactorbiomassandareadingtodeterminereactorbiomassconcentration.Therewereafewcasesinwhichbiolmaccumulationintheowcellwasnotcompletelyeliminated.Bytakingmeasurementsduringtherinsingphasewehaveawaytotracktheaccumulationofbiomassonthewallofthequartzowthroughcell.Thisvaluecanbesubtractedfromthesamplemeasurementtogivethesuspendedbiomasscontribution.Thissystemhasbeenshowntoworkacceptablyatabsorbancesashighas1.5at550nm35mgdrywt./L,andforourtypicaloperatingrangeof34{270mgdrywt./LAbs550nm0.05{0.40itworksverywell.ApersonalcomputerrunningMicrosoftWindows98coordinatedthevalvepositionsandspectrophotometermeasurementsusingacontrolprogramwritteninMicrosoftVisualBasic6.0.Communicationwiththespectrophotometerwasthroughaserialport.TheprogramcontrolledthesolenoidvalvesthroughaUSBcontrolrelayJ-WorksJSB210-16,GranadaHills,CAthat,inturn,operatedapowerrelay4VAC.Theprogramalsocollectedanddisplayeddataandenabledtheusertosetexperimentparameterse.g.duration,samplingperiod,rinsing

PAGE 28

18 period,gascontrollogic.Aowsheetoftheprogramanditssourcecodearepostedat http://www.ees.u.edu/homepp/koopman/hamilton etal/ .TheprogramcommunicatedwiththespectrophotometerusingthemscommVisualBasiccontrol,whichprovidessimpleaccesstoserialports.ThecomputersentaPRINTstringtothespectrophotometerwheneverameasurementwasrequired.Thespectrophotometerthenreturnedastringcontainingthedate,time,wavelengthandabsorbance.Achallengeinwritingthecodewastheindeterminatedelaybetweentherequestforameasurementofabsorbanceandthereceiptofthestringcontainingthatmeasurement.ThiswasovercomeusingtheOnCommeventofthemscommVisualBasiccontrol.ThiseventistriggeredonreceiptofdataandthensignalstheprogramtoprocessthereceiveddatabycallingauserwrittenmethodnamedOnCommofthemscommobject.Thismethodextractstheabsorbancefromthereceivedstringandstoresitinavariable.Theprogramperiodicallycheckswhetherthisvariablecontainsanumberitisresettonullinbetweenmeasurements.TheUSBcontrolrelayunitismanipulatedusingasetofpre-denedfunctionsprovidedbythemanufacturer.Thesefunctionsarepartofapre-compileddynamiclinklibrary.dllle.ThefunctionsarecalledtoexecutehardwarelevelcommandsthatsenddataacrosstheUSBcabletothecontrolrelayunit.Thecontrolfunctionsareaccessedbyincludingaprovidedmodule,JWorksRelayModule.bas,intheVisualBasicproject.Anexampleoftheuseoftheprovidedfunctionsisgiveninthefollowingcodefragment,whichusestheIsModuleRelayOfunctiontocheckwhethertherelayfornitrogenvalveNitrogenisclosedand,ifso,openstherelayusingtheModuleRelayOnfunction.ThevbNullStringargumentofthesefunctionsisnullifthecomputeriscommunicatingwithasinglecontrolrelayunitandisreplacedwithastringcontainingaserialnumbertospecifyaparticularrelayunitinthecaseofmultipleunits.

PAGE 29

19 Figure2{3:Softwareinterfaceincludingcurrentstatusandmeasurementhistory IfIsModuleRelayOffvbNullString,valveNitrogenThenCallModuleRelayOnvbNullString,valveNitrogenEndIfTheinterfaceoftheprogramFigure 2{3 givesthestatusofthegas/samplingsystemabsorbance,typeofgasinuse,typeofuidinrinse/sampleline,lengthofrinsephase,lengthofsamplephase,timeuntilnextabsorbancemeasurement,elapsedtimeofexperimentinupto3reactors.Italsoshowsplotsofabsorbanceandaerationstatusversustime,aswellasalogofdatabeingwrittentoale.Anotherfunctionoftheinterfaceistoallowreal-timechangestocontrolparameters.Figure 2{4 showsadierentscreenthatallowsparametersforuptothreereactorstobeentered.Anoteworthyfeatureofthesoftwareisitscapabilitytosendemailautomatically.UsingtheMAPIMessagesandMAPISessioncontrolsinVisualBasic,afunctionwaswrittenthatwouldsendthecurrentspectrophotometermeasurementtoalistofemailaddresses.Whencombinedwithwirelessmessaging,thisprovidedameansofalertingremoteusersbymobiletelephonetokeychangesinsystemstatus.

PAGE 30

20 Figure2{4:Experimentcongurationscreen Anotherusefulresourceisthefreelyavailablesoftware WinVNC thatallowstheusertoremotelymonitorandadministerthelabcomputer.Thiswasveryusefulduringexperimentsthatrequiredmanualinterventionafteralongandvariablebacterialgrowthphase.ThecomponentsofthegasandrinsingcontrolsystemarelistedinTable 2{1 ,alongwiththeirprices.Thetotalsystemcostforpartswasapproximately$4500.Thesystemiseasilyscaledtomultiplebioreactors.Forexample,wearecurrentlyusingitwiththreebioreactorsandthreespectrophotometers.ThisrequiredtheadditionofaUSBdeviceKeyspanUSB4-PortSerialAdapterforadditionalserialports. 2.3 ConclusionsTheautomated,on-linesamplingandmeasurementsystemhasproventobeverysuccessfulinourexperimentalwork.Wecurrentlyobserveonly1{2badmeasurementsabsorbancespikeduetobubbleentrapmentortrappedparticulatematerialina14hourexperiment8biomassmeasurements.Thus,using

PAGE 31

21 Table2{1:Equipmentlist NameManufacturerModel#Price J-WorksRelayJ-WorksJSB210-16$205SpectrophotometerThermo-SpectronicGenesys10UV$3300Windowscomputerlessthan$5003-WaysolenoidvalveParker3133BSN1AN00N0M1S1P0$20Tubingpumplessthan$500PowerRelaymadeinshop$10 informationprovidedinthispaper,itispossibletoassembleaneectivecontinuoussamplingandmeasurementsystemthatfunctionsoverextendedtimeperiodsandrequiresonlyamodestinvestment.Inadditiontoprovidingameasurementrecord,thissystemcouldalsobepartofanautomaticprocesscontrolsystemwiththeadditionofastatisticaldatalteringtechniquefordiscriminatingbadmeasurements.

PAGE 32

CHAPTER3ASTRUCTUREDMODELFORDENITRIFIERDIAUXICGROWTH 3.1 IntroductionRemovalofbiologicalnitrogenisanimportantoperationinwastewatertreatment.Biologicalnitrogencontributestoeutrophicationofbodiesofwaterandhasalsobeenlinkedtodiseaseinhumans Ramalho 1983 .Nitrogenremovaliscommonlyaccomplishedinatwostepactivatedsludgeprocess.First,aerobicautotrophsoxidizeammoniatonitrate,thenfacultativeanaerobesreducethisnitratetonitrogengas.Thisprocessinvolvesexposingamixedcultureofmicroorganismstoanenvironmentinwhichtheterminalelectronacceptoralternatesbetweenoxygenandnitrate.Thiscanresultinthephenomenonofdiauxicgrowth.Diauxicgrowthoccurswhenapreferredgrowthsubstrateisexhaustedandaperiodoflittleornogrowthoccurs.Duringthisperiodnecessaryenzymesaresynthesizedthatallowgrowthonthelesspreferredsubstrate.Diauxicgrowthwasrstcharacterizedindetailby Monod 1942 inthecaseofchangingelectrondonors.Later Kodamaetal. 1969 observedthatdiauxicgrowthalsooccurswhenswitchingterminalelectronacceptors.Morerecentlyseveralinvestigators Wakietal. 1980 ; Liu,Zhan,SvoronosandKoopman 1998 ; Liu,SvoronosandKoopman 1998 ; Gouwetal. 2001 ; Lisbonetal. 2002 havestudiedtheparticulardiauxieoccurringwhenbacteriaswitchfromoxygentonitrate,whichisknowntooccurwithbiomassfromanactivatedsludgeprocessusedfordenitrication Liu,Zhan,SvoronosandKoopman 1998 22

PAGE 33

23 Thequalityofmodelusedinprocessdesignfordenitricationcanhaveprofoundeconomicimplications.Variousmodelsforbiologicaldenitricationhavebeenproposed.TheActivatedSludgeModels1,2,2dand3 Henzeetal. 2000 arewidelyusedinindustrybutdonotportraythephenomenonofdiauxiclag.Thecyberneticmodelingapproachof Liu,Zhan,SvoronosandKoopman 1998 aswellasmodicationsofthisapproach Liu,SvoronosandKoopman 1998 ; Casasus 2001 areabletoportraydiauxiclag.Thesemodelsweredeveloped,inpart,fromanoptimizationapproachthatassumedthatbacteriaareoptimalstrategists Ramkrishna 1983 .Amoremechanisticapproachconsidersintracellularvariablesaswellassubstrateconcentrationsinsolution.Inthispaperwepresentamodelfordiauxicgrowthinwhichthecybernetickineticsarereplacedwithanapproachbasedonregulationofenzymesynthesisandactivetransportofnitrateintothecell.Thereisevidencefortheexistenceofanitratetransportproteininseveralspeciesofnitraterespiringbacteria Berksetal. 1994 ; Moreno-Vivianetal. 1999 3.2 Model Baumannetal. 1996 foundthatinanoxic/anoxiccyclingsystemtheconcentrationsofintermediatesNO2-,NO,N2Oweresignicantwhenthesystemwasrsttosubjectedtocycling,butsubsequentlydeclinedinmagnitude.Thustheconversionofnitratetonitritecanbeinferredtobetheratelimitingstep.Inpractice,nitriteconcentrationswithinperiodicprocessesfornitrogenremovalareusuallyquitelowwellbelow1mg/L.Forthisreason,theASMmodelsconsideronlynitrateaselectronacceptorindenitrication Henzeetal. 2000 ,andthisisalsothecaseforthemodeldevelopedhere.ThepresentedmodelisbasedonthebiochemicalprocessshowninFigure 3{1 ,whichshowsthatnitrateNO)]TJ/F21 7.97 Tf 0 -7.879 Td[(3isactivelytransportedintothecellbytransportproteinT.InternalnitratebindstorepressorR,freeingoperatorOwhichthenallowstranscriptionofthenitraterespirationoperonresultinginsynthesisofthe

PAGE 34

24 Figure3{1:BiochemicalProcessModel.ThebiochemicalprocessbeingmodeledisthatnitrateNO)]TJ/F21 7.97 Tf 0 -7.879 Td[(3isactivelytransportedintothecellbytransportproteinT.InternalnitratebindstorepressorR,freeingoperatorO.Synthesisofthenitratereductase,nar,andtransportproteinproceedsatarateproportionaltotheamountoffreeoperator.Weassumetheexistenceofanitraterespirationoperon,andthatthetransportproteinandnitratereductasearethereforesynthesizedtogether. nitratereductasenarandtransportprotein.Therateofsynthesisofnarandtransportproteinisproportionaltotheamountoffreeoperator.Sinceweassumetheexistenceofanitraterespirationoperon,itfollowsthattransportproteinandnitratereductasearesynthesizedtogether.Inthiscasetheconcentrationoftransportproteinwouldbeproportionaltotheconcentrationofnarprovidedthattheirdecayratesaresimilar.Theregulationschemethatunderliesthepresentedmodelfollowsthatdescribedby YagilandYagil 1971 ,inwhichenzymesynthesisisproportionaltotheconcentrationofunboundoperator.AschematicmodeldiagramisshowninFigure 3{2

PAGE 35

25 Figure3{2:Modeloverview.Uptakeofnitrate,SN,resultsinanincreasedlevelofinternalnitrate,sni.Thispromotessynthesisofnitratereductase,en,whichinturnpromotessynthesisofnewbiomass,XB,andincreasestherateofnitrateuptake. Underanoxicconditionsthecelltakesupnitratefromtheenvironment.Therateofuptakeisinuencedbytheconcentrationofnitratereductaseinthecell.Theinternalnitratestimulatesthesynthesisofnar,whichallowsanoxicgrowthandpromotesfurthernitrateuptake.Thevariablesforbiomass,XBgdw/L,organicsubstrateSSmg/LandextracellularnitrateSNmg/Lareexpressedasvolumetricconcentrations,whereastheintracellularvariablesnitratereductaseactivity,enkatals/gdw,andinternalnitrateconcentration,snimg/gdw,areexpressedperdryweightofbiomass.TherateexpressionsofthismodelutilizemultipleMonodtypeexpressionsinamanneranalogoustotheIWAseriesofactivatedsludgemodels Henzeetal. 2000 .Theprocessesmodeledare: 1. Therateofsynthesisofnitratereductase,denotedren,followsthekineticsdescribedbelow.Thesekineticsarederivedfromthesynthesismodelof YagilandYagil 1971 ,asshowninAppendixA.Theparticularrepressionmodelusedisthecaseofasingleeectormoleculebindingtoasinglerepressormolecule.Accordingtothismodel,K1istheequilibriumconstantforthebindingofrepressortoaninducermoleculeinternalnitrate.K2controlstheconstitutiverateofenzymesynthesisandisafunctionoftheequilibriumconstantforthebindingoftherepressortotheoperator.AnadditiontotheapproachofYagilisaMonodtermfororganicsubstratedependence.This

PAGE 36

26 representsthedependenceoftherateofactivetransportontheconcentrationoforganicsubstrate.ren=aN1+K1sni K2+K1sniSS KS;an+SS.1 2. Oxicgrowthisdescribedbythekineticexpression Henzeetal. 2000 rox=max;oxSS KS:ox+SSSO KOH+SO.2 3. Thespecicrateofuptakeofnitrateisproportionaltotheconcentrationofnitratereductase,en.Thisapproachisanalogoustothattakenby Shoemakeretal. 2003 formodelingdiauxiclagwhenswitchingcarbonsources.Uptakeisinhibitedbythepresenceofoxygen,SO Berksetal. 1994 ; Moreno-Vivianetal. 1999 .TheenergydependenceofactivetransportismodeledbyincludingaMonodtermfororganicsubstrateintherateexpression.rsni=Vsnien en;maxSN SN+KNOiKOi KOi+SOSS KS;an+SS.3 4. Anoxicgrowthisproportionaltointernalnitrate,sni,andnitratereductase,en.Anexplicitswitchingfunctionforoxygeninhibitionisunnecessarybecausethepresenceofoxygendecreasestherateofnitrateuptakeandultimatelytheintracellularnitrateconcentration.ranox=max;anoxen en;maxsni sni;maxSS KS;an+SS.4 5. Thespecicbiomassdecayratebisassumedtobeconstant. 6. ThespecicrateofenzymedecaybNOisassumedtobeconstant.Performingamassbalanceonabatchreactorusingtheseratesyieldsthefollowing:dXB dt=rox+ranox)]TJ/F22 11.955 Tf 11.955 0 Td[(bXB.5

PAGE 37

27 dSS dt=)]TJ/F15 11.955 Tf 18.653 8.087 Td[(1 Yc;oxrox)]TJ/F15 11.955 Tf 21.697 8.087 Td[(1 Yc;anranoxXB.6dSN dt=)]TJ/F22 11.955 Tf 9.298 0 Td[(rsniXB.7den dt=ren)]TJ/F28 11.955 Tf 11.956 16.857 Td[(b+bNO+1 XBdXB dten.8dsni dt=rsni)]TJ/F22 11.955 Tf 11.955 0 Td[(N;anranox)]TJ/F28 11.955 Tf 11.955 16.857 Td[(b+1 XBdXB dtsni.9InEquations 3.8 and 3.9 above,thelasttermrepresentsdilutionduetogrowthandcelldecay.TheyieldconstantsYcrepresenttheamountofbiomassthatissynthesizedperunitorganicsubstrateconsumed.TheconstantN;anrepresentsthenitraterequiredperunitbiomasssynthesizedduringanoxicgrowth.Thenitrogensourceforbiosynthesisisassumedtobeammonia.Thetheoreticalmaximumvaluesofsniandencanbefoundbysettingthetimederivativesforthesevariablestozeroandassumingnon-limitingconcentrationsoforganicsubstrateandnitrate.sni;max=Vsni max;anox)]TJ/F22 11.955 Tf 11.955 0 Td[(N;an.10en;max=aN b+bNO1+K1sni;max K2+K1sni;max.11InviewofEquation 3.10 Vsni>N;anmax;anox. 3.3 MaterialsandMethodsTheexperimentconsistedofgrowingPseudomonasdenitricansATCC13867underconditionsdesignedtoinducediauxicgrowth.Aftergrowingunderaerobicconditionstheoxygenwasstrippedfromthereactorbybubblingnitrogen

PAGE 38

28 Table3{1:Syntheticmediacomposition.pHisadjustedto7.Tracemetalsolutioncontains0.5%w/vCuSO4,FeCl3,MnCl2andNaMoO42H2O. ChemicalsConc.g/L sodiumchloride1ammoniumchloride1magnesiumsulfateheptahydrate0.2calciumchloridedihydrate0.0264L-glutamicacid6.77potassiumphosphatemonobasic5potassiumphosphatedibasic1.5tracemetals1drop gasandnitratewasaddedasthealternativeelectronacceptor.Thisresultedinalagfollowedbyaperiodofanoxicgrowth.Thedissolvedoxygenwasassumedtobenearsaturationunderaerobicconditionsandzerounderanoxicconditions.Duringtheexperimenttheenzymelevelwasmeasuredusingaviologendyecolorimetricassay. 3.3.1 BacterialStrainandGrowthConditionsFreezedriedP.denitricansAmericanTypeCulturesCompany13867,Manassas,VAwasrevivedinnutrientbrothDifco#0002-17-8for2daysinashakingincubatorat35C.Theculturewasstoredat4ConagarplatesSigma#T-4536forupto2weeks.Priortoeachexperimenttheplatedbacteriawereculturedwithoutnitratein125mLofsyntheticmediaTable 3{1 ina250mLErlenmeyerask.Theculturewaskeptat35Cinashakingincubatorfor24hours.AtthebeginningofeachexperimenttheculturewastransferredtoacontinuouslystirredbioreactorMultigenModelF-1000orF-2000,NewBrunswickScientic,NewBrunswick,NJcontainingsyntheticmedia.Theinitialabsorbanceinthebioreactorwas0.1{0.1269{83gdw/L.Airwasspargedintothereactorduringtheinitialaerobicphase,anddissolvedoxygenwasassumedtobenearsaturationbasedonpreviousstudies Liu,SvoronosandKoopman 1998 .In

PAGE 39

29 runsinwhichtheabsorbancereached0.6,theculturewasdilutedduringtheaerobicphaseinordertoremaininthelinearrangeoftheabsorbance-biomasscurve{1.0.Dilutionwasaccomplishedbyrapidlypumpingoutafractionofthereactorcontentsandasepticallyreplacingitwithfreshnutrientsolution.Afterapproximately3hoursofexponentialgrowththeaerationwasstoppedanddissolvedoxygenwasstrippedbyspargingwithnitrogengas.Nitratesolution00mg/LNO)]TJ/F21 7.97 Tf 0 -7.88 Td[(3-Nwasaddedtogiveatotalconcentrationof40mgNO)]TJ/F21 7.97 Tf 0 -7.88 Td[(3-N/L.Theanoxicphasewasmonitoreduntilsubstantialexponentialgrowthwasobserved.ReactorcontentswerecontinuouslywithdrawnandpassedthroughaspectrophotometerThermo-SpectronicGenesys10UVtomonitorbiomassdensityabsorbanceat550nm.Nitriteaccumulationcanoccurundersomeconditions Kornarosetal. 1996 andresultinreductionofgrowthrate.However,nitritemeasurementsfromourpreviousstudiesundersimilarconditionsshowedthattheconcentrationswerebelow1mg/L,whichiswellbelowthethresholdfortoxicinhibitionofbacteria Weonetal. 2002 3.3.2 NitrateReductaseAssayCellswereharvestedbycentrifugation0,000gfor10minutesat4Candwashedwith20mMTrisbuerpH7beforebeingresuspendedin2mLofthesamebuer.Cellsuspensionswereusedwithin10minutesofpreparation.Thevolumeofcellssampledwasvariedtoobtainapproximately4gdw.Theassaymethodwasmodiedfrom Jonesetal. 1977 .Thereactionwasperformedina1-cmopticalpathborosilicatecuvettewithaWheatonseal.ReagentswereaddedinananaerobicchamberCoyLaboratoryType`A',GrassLakeMI,leavingnoheadspace.Afteraddingreagentsandbacteriathenalconcentrationswere0.3mMbenzylviologenandapproximately55mg/Ldryweightofbacteria.Sucientdithionitewasincludedinthereactionmixtureto

PAGE 40

30 reducethebenzylviologentoanalabsorbanceof1.8at550nm.Several3mmglassbeadswereaddedtothecuvettetofacilitatemixing.Theabsorbancewasmonitoredfor3minutes,thenthereactionwasinitiatedbyinjectingnitrateintothecuvettethroughthesealtoanalconcentrationof6mM.Thecuvettewastheninvertedtwiceformixingandtheabsorbanceofthereactionmixturewasmeasuredfor5minutes.Theinitialrateofdecolorizationwasdeterminedfromthesedata.Weperformedastudyonreproducibility,andfor6measurementsthestandarddeviationwas2E-10katals. 3.3.3 ParameterEstimationValuesforthemodelparameterswereobtainedbyttingsimulationresultstoexperimentaldata.ThettingwasperformedusingthefollowingweightedleastsquaresperformancemeasureJ=1 2XbNXi=1XB;meas;i)]TJ/F22 11.955 Tf 11.955 0 Td[(XB;pred;i2+1 2enMXi=1en;meas;i)]TJ/F22 11.955 Tf 11.955 0 Td[(en;pred;i2Theweightingfactorsarethevariancesoftheexperimentalmeasurements2Xb=510)]TJ/F21 7.97 Tf 6.587 0 Td[(3and2en=4:310)]TJ/F21 7.97 Tf 6.586 0 Td[(19.TheperformancemeasureJwasminimizedbyadjustingaN;K1,K2,Vsni,KOi,KNOiandbNO.Inttingdatafromapreviousexperimentalstudy Liu,SvoronosandKoopman 1998 ,forwhichenzymemeasurementsareunavailable,theinitialvalueofenwasalsot.Themaximumgrowthrateparametersmax;oxandmax;anoxwerefoundfromtheslopesofsemilogplotsofabsorbanceversustime.

PAGE 41

31 3.4 ResultsandDiscussionWersttestedourmodel'sabilitytotpreviouslypublisheddatafromastudyby Liu,SvoronosandKoopman 1998 ,inwhichtheyevaluatedtheeectoftheaerobicperiodlengthonthesubsequentdiauxiclag.Apre-cultureofP.denitricanswassplitbetweentworeactors.Inone,bacteriaweregrownaerobicallyunderbatchconditionswith40mg/Lnitratefor1.1hours.Aerationwasthenstopped,andnitrogenwasspargedintothereactortostripresidualoxygenfromthemedia.ThegrowthresultsforthisexperimentFigure 3{3 ashowadiauxiclagof3hours.Theparallelreactorwasaeratedforalongertime.6hoursandthesubsequentdiauxiclagwasalsolongerhoursasshowninFigure 3{3 b.Thepresentmodelcapturestheexponentialgrowthbehaviorduringtheaerobicphaseandanoxicphaseandcloselymatchesthediauxiclagbetweenthesephasesineachoftheparallelreactors.Accordingtothemodel,theeectofaerationperiodlengthonlagisduetothedilutionofnitraterespirationenzymesbybiomassgrowthandenzymedecay.ThemodelparametersfortheseexperimentswerefoundbysimultaneouslyttingbothexperimentsandareshowninTable 3{2 .Althoughthequalityofmodeltwithpreviousdatawasencouraging,amorerigoroustestofthemodelrequiredsimultaneousenzymeandbiomassdata.Experimentalresults,modelts,andmodelledintracellularnitrateconcentrationsareshowninFigure 3{4 foroneofourexperiments.Theinitialenzymeactivityinthisexperimentwasverylow.Thus,despitearelativelyshortaerationperiodof2hours,asubstantialdiauxiclagof11hourswasexhibitedbytheculture.Theendofthediauxiclagcoincideswitharapidincreaseinenzymeactivity.ThemodeledvaluesforintracellularnitrateFigure 3{4 bshowthattheendofthediauxiclag,aswellastherapidincreaseinenzymeactivity,arecoincidentwitharapidriseinintracellularnitrateconcentration.Thesignicanceofintracellularnitrateconcentrationtoenzymeactivityand,ultimately,biomassgrowthisexplainedin

PAGE 42

32 Table3{2:Parametervaluesobtainedbytting datafromLiudatafrompresentParameterSymbolUnitsetal.:Fig. 3{3 study:Figs. 3{4 & 3{5 Maximumspecicgrowthratesoxicconditionsmax;oxh)]TJ/F21 7.97 Tf 6.587 0 Td[(10.390.56anoxicconditionsmax;anoxh)]TJ/F21 7.97 Tf 6.587 0 Td[(10.190.19YieldsonorganicsubstrateoxicconditionsYC;oxmgbiomass/mgsubstrate7575anoxicconditionsYC;anmgbiomass/mgsubstrate7575NitrateutilizationcoecientN;anmgnitrate/mgbiomass0.120.11Half-saturationcoecientscarbonsource,oxicconditionsKS;oxmgorganicsubstrate/L0.0250.025carbonsource,anoxicconditionsKS;anmgorganicsubstrate/L0.70.7oxygenKOHmgO2/L0.10.1nitratefornitrateuptakeKNOimgnitrate/L0.0740.074oxygenfornitrateuptakeKOimgO2/L0.0820.082Decayratesbiomassbh)]TJ/F21 7.97 Tf 6.587 0 Td[(100nitratereductasebNOh)]TJ/F21 7.97 Tf 6.587 0 Td[(12.170.035NitratereductasesynthesisconstantsmaximumspecicsynthesisrateaNkatals/gdwbiomasss2.1E-87E-10repressor/inducerbindingK1mgnitrate/gdw)]TJ/F21 7.97 Tf 6.586 0 Td[(16.9E154.1E5constitutiveexpressionlevelK24.8E158000MaximumspecicnitrateuptakerateVsnimgnitrate/gdwbiomasss0.030.06 Theactivityofnitratereductaseisreportedinmolesbenzylviologenreducedpersecond.InFigure 3{5 bthevalueofoneparameterwaschangedcomparedtotheprevioustwoexperimentalts.InthisexperimentK2=100.

PAGE 43

33 Figure3{3:Modeltto Liu,SvoronosandKoopman 1998 .Datapointsshowexperimentalresults;dashedandsolidlinesshowmodelts.Nitratewaspresentatthebeginningoftheexperimentataconcentrationof40mg/LNO3-N. termsofthemodelasfollows.Enzymeactivityisinitiallyverylow,consequentlytherateofnitratetransportintothecellaftertheanoxicperiodbeginsisalsolow.Asaresult,thereisonlyslightaccumulationofintracellularnitrateforseveralhoursafterthebeginningoftheanoxicperiod.Finally,whenthenitrateconcentrationbeginstobuildupand,hence,enzymebiosynthesisacceleratesduetoderepressionoftheoperonbynitrate,exponentialbiomassgrowthresumes.TheparametersforthetinFigure 3{4 areshowninTable 3{2 .DatafromasecondexperimentareshowninFigure 3{5 aalongwithmodeltsusingthesameparameters.Inthiscase,themodelcapturedtheaerobicexponentialgrowth,bothbeforeandafterdilution,theanoxicexponentialgrowth,thediauxiclag,andthebuildupinenzymeactivityimmediatelyprecedingtheendofthediauxiclag.GoodmodeltswereobtainedforathirdsetofexperimentaldatashowninFigure 3{5 bbutrequiredchangingtwoparametersinorderto

PAGE 44

34 Figure3{4:Enzymeactivityduringdiauxicgrowth.Datapointsshowexperimentalresults;dashedandsolidlinesshowmodelts.Thebiomassgrewexponentiallyduringaninitial2.5houraerobicphase.Nitratewasaddedtoaconcentrationof40mg/LNO3-Natthestartoftheanoxicphase.Thiswasfollowedbyalagof11hours.Theenzymelevelwasincreasingduringthelagphase.

PAGE 45

35 Figure3{5:Additionalexperimentswithmodelts.Theseexperimentsincludeddilutionduringtheaerobicgrowthphasetoensurethatabsorbancestayedwithintherangeoflinearmeasurement.Nitratewasaddedtoaconcentrationof40mg/LNO3-Natthestartoftheanoxicphase.ThesharpnessoftheenzymeactivitycurveingurebresultsfromthelowermagnitudeofparameterK2.

PAGE 46

36 obtainagoodtTable 3{2 .Theoriginalmodelparameterswouldhavepredictedalongerlagandlowerreductaseactivityattheendoftheaerobicphase.Beforetheuseoftheproposedmodelisconsideredtoimprovedesignandoperationofnitrogenremovingwastewatertreatmentplants,therangeofconditionsunderwhichthediauxiclagphenomenonoccursneedstobemorefullystudied.Forexample, KornarosandLyberatos 1998 ,continuingearlierworkonthekineticsofdenitrication Kornarosetal. 1996 ; KornarosandLyberatos 1997 ,failedtoobservediauxiclagofP.denitricansgrowingonglutamicacidwhenthebacteriaweretransitionedfromoxictoanoxicconditions.Notably,theseexperimentsinvolvedhigh4mg/Lnitratenitrogenconcentrationsinpre-culture,aerobic,andanoxicgrowthphases,whereasinthepresentworknitratewasabsentduringtheaerobicphase. Monod 1942 remarkedthatdiauxiclagdoesnotoccurinallsubstratetransitions,particularlywhenthelesspreferredsubstrateispresentinhighconcentrations.Previousstudies Liu,Zhan,SvoronosandKoopman 1998 ; Liu,SvoronosandKoopman 1998 ; Gouwetal. 2001 ; Lisbonetal. 2002 havenotinvestigatedhighnitrateconcentrationsthroughoutthegrowthcycle,becausethenitrateconcentrationsthatoccurinmunicipalwastewatertreatmentplantsaremuchlower. 3.5 ConclusionsWehavemodeleddiauxiclagasresultingprimarilyfromnitratetransportlimitation.ThiswasachievedbycombiningYagiltypeenzymesynthesiskineticswithamodelstructurethatusesintracellularnitrateastheinducerforanoperoncodingfornitratereductaseandnitratetransportenzyme.Thisapproachwassuccessfulinttingdataonbiomassfromtheliterature,aswellasdataonbiomassgrowthandenzymedatacollectedaspartofthepresentstudy.Thenitratereductasesynthesisdependenceandcouplednitratetransportlimitationexplainsthedependenceoflaglengthonaerationtime,thecessationofanoxic

PAGE 47

37 growthinthepresenceofoxygen,aswellastheobservednarenzymeactivityproleduringdiauxie.Thusitmaybeconcludedthatamodelbasedonenzymebiosynthesisregulationcanbesuccessfullyappliedtoportrayingdiauxicgrowthduetoswitchingofterminalelectronacceptors.

PAGE 48

38 Table3{3:Nomenclatureusedindenitriermodeling parameterunitsdescription aNkat/gdwbiomasssmaximumspecicenzymesynthesisratebh)]TJ/F21 7.97 Tf 6.587 0 Td[(1specicbiomassdecayratebNOh)]TJ/F21 7.97 Tf 6.587 0 Td[(1specicnitratereductasedecayrateenkat/mgbiomassspecicnitratereductaseconcentrationen;maxkat/mgbiomassmaximumspecicnitratereductaseactivityK1mgnitrate/gdw)]TJ/F21 7.97 Tf 6.586 0 Td[(1equilibriumconstantforrepressor/inducerbindingK2relatedtoconstitutiveenzymeexpressionlevelKNOimgNO)]TJ/F21 7.97 Tf 0 -7.879 Td[(3/Lhalf-saturationcoecientforinternalnitrateKOHmgO2/Lhalf-saturationcoecientforoxygeninaerobicgrowthKOimgO2/Lhalf-saturationcoecientforoxygeninhibitionofnitrateuptakeKS;anmgorganicsubstrate/Lhalf-saturationcoecientforcarbonsourceinanoxicgrowthKS;oxmgorganicsubstrate/Lhalf-saturationcoecientforcarbonsourceinaerobicgrowthranoxgdwbiomass/gdwbiomasshrspecicbiomassgrowthrateunderanoxicconditionsrenkat/gdwbiomass2hrspecicnitratereductasesynthesisrateroxgdwbiomass/gdwbiomasshrspecicbiomassgrowthrateunderaerobicconditionsrsnimgnitrate/gdwbiomass2hrspecicnitrateuptakerateSSmgorganicsubstrate/LorganicsubstrateconcentrationSNmgnitrate/Lnitrateconcentrationsnimg/gdwbiomassinternalnitrateconcentrationSOmg/LdissolvedoxygenconcentrationVsnimgnitrate/gdwbiomass2hrmaximumspecicnitrateuptakerateXBgdwbiomass/LbiomassconcentrationYc;anmgbiomass/mgorganicsubstrateyieldunderanoxicconditionsYc;oxmgbiomass/mgorganicsubstrateyieldunderaerobicconditionsN;anmgnitrate/mgbiomassnitrateconsumedperunitbiomassgrowth2Xbgdwbiomass/L2varianceofbiomassmeasurements2enkat/mgbiomass2varianceofenzymemeasurements

PAGE 49

39 3.6 EnzymeSynthesisExpressionDerivationInthefollowingderivation,repressorisdenotedR,inducere.g.nitrateisdenotedI,andoperatorisdenotedO.Accordingtothemodel,inducerbindstofreerepressor.[R]+[I]k1)]TJ -5.848 -2.265 Td[()]TJ/F22 11.955 Tf 3.441 0 Td[(+[RI].12Thisshiftsequilibriumbetweenboundrepressor,RO,andfreerepressor.[R]+[O]k2)]TJ -5.848 -2.265 Td[()]TJ/F22 11.955 Tf 3.441 0 Td[(+[RO].13Notethat,evenintheabsenceofinducertherewillalwaysbesomeunboundoperator,accordingtheaboveequilibrium.Consequentlytheconstitutiverateofenzymebiosynthesiswillbenon-zero.Thetotalamountofrepressorandoperatoristhesumoffreeandboundspecies[Rt]=[R]+[RO]+[RI].14[Ot]=[O]+[RO].15Therateofnitratereductasesynthesis,r,isproportionaltotheconcentrationoffreeoperator.r=kr[O].16ThereforeweareinterestedinndingtheequilibriumconcentrationofO.FromEquation 3.13 [O] [RO]=1 k21 [R]ByapplyingEquation 3.15 weobtain[O]=[Ot]1 1+k2[R].17

PAGE 50

40 Inasimilarfashion,manipulatingEquation 3.12 andassuming[RO][Rt]yields[R]=[Rt]1 1+k1[I].18SubstitutingEquation 3.18 intoEquation 3.17 weobtain[O]=[Ot]1+k1[I] +k2[Rt]+k1[I].19whichresultsintherater=aN1+k1[I] K2+k1[I]withaN=kr[Ot]K2=+k2[Rt]TheconstitutiveenzymesynthesisrateisobtainedbysettingI=0:r=kr[Ot]1 +k2[Rt]

PAGE 51

CHAPTER4ESTIMATIONOFNITRATEREDUCTASEENZYMEPARAMETERSINACTIVATEDSLUDGEUSINGANDEXTENDEDKALMANFILTER 4.1 IntroductionEortstocontrolbioreactorsaremademorecomplicatedbythefactthatintracellularvariablesthatcandictatesystembehaviorarefrequentlydicultorimpossibletomeasureon-line.Forexample,lowlevelsofnitratereductasewhenswitchingfromoxictoanoxicconditionscanresultinadiauxiclagaperiodoflittleornogrowth.Theneedforimprovedmodelsfordenitrierdiauxicgrowthisdiscussedin Wildetal. 1994 and Liu,SvoronosandKoopman 1998 .Establishedmodelsforgrowthofdenitriers Henzeetal. 2000 canbeimprovedupon,especiallywithrespecttoenzymekinetics.Doingso,however,introducesparametersthatcannotbetindependently Wildetal. 1994 .Bothbenchandplantscaleexperimentswilltypicallyhavesomemeasurementsavailable,butnotenoughtoxtheenzymerelatedmodelparameters.ThispaperpresentsanapproachforestimatingdenitricationenzymeparametersusinganextendedKalmanlterEKFonplant-scaleoperations.AKalmanlterisatechniquefordeterminingoptimalestimatesofthevaluesofstatevariablessuchasbiomassdensityandpH,includingunmeasuredorinfrequentlymeasuredstatevariablese.g.enzymeactivityandmodelparameters.Theestimationalgorithmisbasedonalimitedsetofnoisymeasurements.Thistechniquehasrelevanceintheareaofwastewatertreatmentduetotheimpactthatunmeasuredintracellularcomponents,suchaspolyphosphatelevelandnitratereductaseactivity,haveonfacilityperformance. 41

PAGE 52

42 PreviousstudieshaveusedKalmanlterstoestimatestatevariablesandbiologicalmodelparameters. StephanopoulosandSan 1984 proposedtheuseofanextendedKalmanlterforestimatingspecicgrowthrates.Laterworkby Ramirez 1987 and ChattawayandStephanopoulos 1989 usedtheKalmanlteralongwiththesequentialparameterupdatingstrategyof LjungandSoderstrom 1983 forbothstateandmodelparameterestimation.Thisstrategyhasbeenusedby ParkandRamirez 1990 forcontrolofnutrientlevelsinabioreactor.TheapproachusedinthepresentworkdemonstratestheuseofanextendedKalmanlterwithrealplantdata,bothoperationalandanalyticalnitrate,ammonia,inordertoestimatebioreactorcontentsandenzymerelatedmodelparametersinawastewatertreatmentfacility.Thepureculturemodelof Hamiltonetal. 2005 ,whichincludestwoenzymerelatedcomponents,hasbeenintegrated Lee 2005 intotheindustrystandardActivatedSludgeModel1ASM1 Henzeetal. 2000 .AprocessmodelwasdevelopedfortheKanapahaWaterReclamationFacilityKWRFpredenitricationprocessinGainesville,Florida,incooperationwithGainesvilleRegionalUtilities.Totestthemodel,realfacilitydataofinuentandprocessowswereobtainedfora20dayperiodbeginningJanuary15,2005.WedemonstratethatbyapplyingaKalmanltertoanaerationbasincompartmentthatcontainsprobesformeasuringammoniaandnitrateweobtainconsistentestimatesofdenitricationenzymemodelparameters.Thistechniqueforparameteridenticationallowsasemi-mechanisticmodeldevelopedforpureculturestobeusedinamixedculturepopulationwhereisolationofenzymekineticparametersisnotpractical. 4.2 KanapahaWaterReclamationFacilityTheKanapahaWaterReclamationFacilityKWRFreceivesanaveragedailyowof10milliongallonsperdayMGDofwastewater,ofwhichaconstant5MGDisdivertedtoaCarrouselprocessEIMCO,SaltLakeCity,UT.The

PAGE 53

43 remaining5MGD,includingdiurnalowvariation,entersaLudzack-Ettingerprocessanditisthisstreamthatismodeledherein.Bydevelopingagoodprocessmodel,capableofreasonablepredictionsofnutrientlevelsthatarelinkedtointracellularprocesses,itbecomespossibletoestimatetheunmeasuredprocessvariables,aswellasunknownmodelparameters.ThediscussionoftheKWRFmodelispresentedhereintwoparts.Firstthehydraulicmodel,consistingoftheprocessuidows,bioreactors,settlers,etc.isdetailed.Secondlythebiologicalmodel,whichdescribesthebiochemicalreactionstakingplaceinthereactors,isdiscussed.Severalprocessesinthefacilitygenerateasignicantbutunmeasuredamountoflownutrientwastewaterthatiscombinedwiththeinuentstream.Thishastheeectofdilutingtheinuentstreambeforeitentersthescopeoftheprocessmodel.Byexaminingoperatorlogsitwaspossibletocalculatetherawwastewaterinuententeringtheprocess,aswellastheowrateexitingtheprocess.Thedierencewasattributedtotheunmeasureddilutionstreams.ThisowinformationwasusedtodeterminetheactualnutrientconcentrationsenteringtheprocessbydilutingthestandardwastewatercompositiongiveninTable 4{1 .Theinuentstreamwasassumedtocontainnoneoftheenzymerelatedcomponents.Adiurnalstudywasperformedtoverifythatthiscompositionwasstillrepresentative.Aftercollectionbythesewersystem,inuententersthefacilityheadworksasshowninFigure 4{1 .Thesludgereturnstreamcontainsthickenedsludgefromthebottomoftheclariers.Afterenteringtheheadworks,themixtureofinuentwastewaterandreturnsludgeowstoa440,000gallonanoxicreactorwhichnominallyperformsnitrogenremovalfortheprocess.Thestreamthenentersa2.9milliongallonaeratedreactor,wherenitricationtakesplace.ThemixedliquorsuspendedsolidsMLSSrecirculationreturnsafractionofeuentfromtheaeratedreactorstotheanoxicreactors.

PAGE 54

44 Table4{1:Wastewatercomposition ComponentSymbolUnitsValue solubleintertsubstrateSIgCOD/m362particulateintertsubstrateXIgCOD/m362readilydegradablesubstrateSSgCOD/m399slowlydegradableparticulatesubstrateXSgCOD/m3247nitrateplusnitritenitrogenSNOgN/m30ammonianitrogenSNHgN/m324solubledegradableorganicnitrogenSNDgN/m34particulatedegradableorganicnitrogenXNDgN/m36activeheterotrophicbiomassXB;HgCOD/m30activeautotrophicbiomassXB;AgCOD/m30inertdecayproductsXPgCOD/m30alkalinitySALKgmoles/m36dissolvedoxygenSOgCOD/m30nitratereductaseENactivity/Lhr0intracellularnitrateSNO;ig/L0 Valuestakenfrom Potteretal. 1996 enzymeactivityreportedasmolessubstratereducedpersecond Eachofthetwoaeratedreactorshas4equallyspacedverticalshaftsurfaceaeratorsthatintroduceoxygenintotheactivatedsludgetofacilitateaerobicgrowth.Theaeratorsvaryinmaximumpowerfrom75hpto200hp.Twooftheseaeratorsarecontinuouslyvariableinpoweroutputwhiletheothertwocanonlybesettohigh,low,oro.Theoperatorsadjustthepowerofthese8aeratorsthroughoutthedayaccordingtoboththecurrentstateofthefacilityandtheanticipatedfutureloading.Theaeratorsarealmostalwaysadjustedinmatchedpairs,withtherstaeratorintheEastaeratedbasinchangedatthesametimeandinthesamewayastherstaeratorintheWestbasin.ItissignicantthatthethirdaeratorineachoftheaeratedbasinsisfrequentlyturnedoFigure 4{2 sothatasignicantamountofdenitricationtakesplaceintheaeratedbasin.Aerationrecordswereusedtodeterminetheaerationscheduleforbothaerationbasins.Thesehandwrittenrecordswereapossiblesourceoferrorinmodelpredictionsasnotallaerationchangesarerecorded.

PAGE 55

45 Figure4{1:Kanapahaphysicalprocesslayout. TheMLSSrecirculationisnotusedcontinuallyasitwouldbeinanormalLudzack-Ettingerprocess.Itisusuallyusedonlybetween3:00AMand5:00AMtoprovideowbalancingduringthehourswiththelowestinuentrates.Theowrateofthisrecirculationstream,whenactive,is20MGD.Theeuentfrombothbioreactorsismergedandfedtofoursecondaryclariers.Thesludgereturnstreamfromtheclariersisreturnedtotheanoxicbasinataratesetbytheoperatorsinordertomaintainadesiredsludgeblanketheight.Thewastestream,whichissettocontrolthesolidsretentiontime,goesontofurtherbiosolidsprocessing.Theoperatorsrecordinstantaneousowratesforbothtrainsforreturnactivatedsludgerate,mixedliquorrecirculationrateandwasterate.Thetotalfeedisevenlysplitbetweenthetwotrains.Theowsfora20dayperiodareshowninFigure 4{3 .Supplementalinformationaboutfacilityoperationisavailableat http://www.ees.ufl.edu/homepp/koopman/hamilton.etal2/ 4.2.1 HydraulicModelThehydraulicmodelisshowninFigure 4{4 .ThetwobioreactortrainsarelabeledAtheeastandBthewestwithappropriatesubscriptsonthestream

PAGE 56

46 Figure4{2:Kanapahaoperations{aerationstrategy.

PAGE 57

47 Figure4{3:Kanapahaoperations{recyclesandrecirculations.

PAGE 58

48 Figure4{4:Hydraulicmodelprocessdiagram.*indicateslocationofnitrateandammoniaprobepairusedbytheKalmanlter. labels.Inthisgure,Frepresentsthefeedtothebioreactorprocess,includingdilutionfromunmodeledsourcessuchaslterbackwashing.Eachaeratedreactorisassumedtobewellmixedandnotinteractingwithadjacentreactorsexceptvialistedprocessstreams.EachaeratedbasinwithitsfouraeratorsismodeledasfoursequentialCSTRs.Eachvirtualaeratedreactoristhenoxygenatedbasedontheoperationofthecorrespondingphysicalaerators.Somebackmixingoccursinthelargeaeratedbasin,andthisismodeledbyincludinginternalrecyclesFarbetweeneachofthevirtualaeratedreactors.Asimpleidealclariermodelisusedforthesecondaryclariers.Themixedliquorfrombothtrainsiscombinedbeforeenteringthesecondaryclariers.ThenitrateandammoniaprobesusedintheEKFarelocatedinthewestaeratedbasinnearthethirdaeratorasindicatedinFigure 4{4 .Theprobesreportmeasurementsindependentlyeveryfewminutes.Thesedataweresynchronizedbyassumingthatanymeasurementswithin5minutesofeachothertookplaceatthesametime.Thiseliminatedthenecessityofusingmulti-ratemeasurementtechniquesintheEKF.Therawdataareavailableattheabovementionedwebsite.

PAGE 59

49 4.2.2 BiologicalModelThebiologicalmodelcapturesthesubstrateconversionandbiomassgrowthinthebioreactors.ThemodelusedisamodiedASM1inwhichthemodelpresentedin Hamiltonetal. 2005 fordiauxicgrowthofdenitrierswasincorporated Lee 2005 .ThiscouplestheenzymekineticsoftheHamiltonmodelwiththesludgeproductionandwastewatercomponentsmodeledbyASM1.ThismodelisdescribedasextendedASM1mechanisticeASM1m.Inthismodelnitratereductionanduptakearegovernedbyanitraterespirationoperon.ThemodelisanimprovementoverASM1inthatitiscapableofpredictingdiauxiclagofdenitriersandcorrelatesnitratereductaseenzymeleveltoanoxicgrowth.Itadds2newcomponents,thenitratereductaseenzymelevel,EN,andthetotalintracellularnitrate,SNO;i.TheexpressionsthatdierfromASM1arepresentedinTable 4{2 .Themodelparametervaluesusedweretakenfrom Hamiltonetal. 1992 forASM1exceptforthosevalueslistedinTable 4{3 .TwocalculatedvariablesusedinTable 4{2 areshownbelow.SNO;i;max=VSN;i hg)]TJ/F28 11.955 Tf 11.955 16.857 Td[(1)]TJ/F22 11.955 Tf 11.955 0 Td[(Yh 2:86YhXB;HEN;max=aN bEN+hg)]TJ/F22 11.955 Tf 11.955 0 Td[(bhXB;H+K1SNO;i;max K2XB;H+K1SNO;i;maxXB;HThetotalprocessmodelisthesumoftheadvectionbulkowtermsdenedbythehydraulicmodelandthereactiontermsprovidedbythebiologicalmodel.Oxygenisintroducedintotheaeratedbasinthroughthemasstransferterm,whichisgivenbyKLASO;sat)]TJ/F22 11.955 Tf 11.955 0 Td[(SO.Themasstransfercoecientsarederivedfromvaluesprovidedbytheaeratormanufacturer. 4.3 KalmanFilter Kalman 1960 createdasolutiontothediscretedatalinearlteringproblemwhichisnowwidelyusedinmotioncaptureandnavigationsystems.Theextended

PAGE 60

50 Table4{2:eASM1mmodelexpressionsthatdierfromASM1 jProcessComponent 81415Processrate,jSNOSNO;iENML)]TJ/F21 7.97 Tf 6.587 0 Td[(3T)]TJ/F21 7.97 Tf 6.587 0 Td[(1 2Anoxicgrowthofheterotrophs)]TJ/F21 7.97 Tf 13.787 5.045 Td[(1)]TJ/F23 7.97 Tf 6.587 0 Td[(YH 2:86YH^HEN EN;maxSNO;i SNO;i;maxSS KS+SSgXB;H9Uptakeofnitrate-11VSN;iEN EN;maxSNO KNO+SNOKO;H KO;H+SOSS KS+SSXB;H10Synthesisofnitratereductase1NXB;H+K1SNO;i K2XB;H+K1SNO;iSS KS+SSXB;H11Decayofintracellularnitrate-1bSNO;i12Decayofnitratereductase-1bENEN Table4{3:eASM1mparametervaluesthatdierfromvaluespresentedin Hamiltonetal. 1992 ParameterSymbolUnitsValues Maximumspecicgrowthratesheterotrophicbiomass^Hh)]TJ/F21 7.97 Tf 6.586 0 Td[(10.39autotrophicbiomass^Ah)]TJ/F21 7.97 Tf 6.586 0 Td[(10.19YieldsonorganicsubstrateheterotrophicbiomassYHmgbiomass/mgsubstrate0.5autotrophicbiomassYAmgbiomass/mgsubstrate0.24DecayratesautotrophicbiomassbAh)]TJ/F21 7.97 Tf 6.586 0 Td[(10.008nitratereductasebENh)]TJ/F21 7.97 Tf 6.586 0 Td[(11E-6NitratereductasesynthesisconstantsmaximumspecicsynthesisrateNmolesbenzylviologen/mgbiomasshr1E-12repressor/inducerbindingK1mgnitrate/gdw)]TJ/F21 7.97 Tf 6.586 0 Td[(11.27E5constitutiveexpressionlevelK21.86E4MaximumnitrateuptakerateVSN;imgnitrate/mgbiomasshr0.122 AllmassesgiveninCODunitsValuesfrom Hamiltonetal. 2005

PAGE 61

51 Kalmanlterisusedfornonlinearsystemswhicharelinearizedaroundthecurrentprocessstate.AsignicantbenetoftheKalmanlteristhatunmeasuredprocessstatesmaybeestimatedbasedonlimited,noisyprocessmeasurements.InordertouseanEKFtoperformparameterestimation,parametersaretreatedasprocessvariableswitharateofchange=0.Considerthefollowingsystemofaugmentedprocessstatevector0B@x1CAandmeasurementvectorz:0B@_x_1CA=0B@fx;;t01CA+wt.1z=hx;t+vt.2Theevolutionoftheprocessstate,_x,isafunctionofthestate,x,time,t,andsystemparameters,.Theprocessratesandmeasurementsaresubjecttozeromeannoisefunctionswandv,respectively.TheKalmanlteralgorithmdistinguishesbetweentwoestimatesforthesystemstate.Theaprioriestimate,^x)]TJ/F15 11.955 Tf 7.085 -4.339 Td[(,iscalculatedbasedonmodelpredictionsbeforeanymeasurementsareconsidered.Theaposterioriestimate,^x,iscalculatedafterincludingmeasurementsforthecurrenttimestep.Thesearedistinctfromthetrue,unknown,systemstate,x.FindingtheaposterioriestimateisthegoalofusinganEKF.WhenanEKFisalsousedforparameterestimation,theaposterioriestimatecontainsboththeoptimalestimateofthereactorstateaswellasmodelparameters.NotethatthissuperscriptnotationisalsousedfortheerrorcovariancematrixPk.ItisworthmentioningthatthematrixPkcanbestoredforeachmeasurementandusedtocalculateerrorbarsforthestateestimates.ThediagonalelementsofParethevariancesofeachofthecorrespondingstatevariables.

PAGE 62

52 TheerrorcovariancematrixisakeypartoftheKalmanlterandmustbeintegratedsimultaneouslywiththeprocessmodel.TherateofchangeoftheerrorcovariancematrixPisshowninEquation 4.3 ._Pt=FtPt+PtFTt+R.3HereFistheJacobianoffwithrespecttotheaugmentedstatevectorandRisthecovarianceofw.TheaposteriorierrorcovariancematrixPiscalculatedbyEquation 4.4 .Pk=I)]TJ/F22 11.955 Tf 11.955 0 Td[(KkHk)]TJ/F15 11.955 Tf 6.204 -9.684 Td[(^x)]TJ/F23 7.97 Tf 0 -8.277 Td[(kP)]TJ/F23 7.97 Tf -1.626 -8.277 Td[(k.4TheheartoftheKalmanlteristhegainmatrix,K.Thegainformulaisderivedbyminimizingtheexpectederrorbetweentheaposterioristateestimateandtheactualstate.Thenalformofthegain,derivedfortheprocess/measurementsysteminEquations 4.1 { 4.2 isshowninEquation 4.5 ,whereQisthecovarianceofvandHistheJacobianofhwithrespecttotheaugmentedstatevector.Kk=P)]TJ/F23 7.97 Tf -1.626 -8.278 Td[(kHTk)]TJ/F15 11.955 Tf 6.204 -9.684 Td[(^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(kHk)]TJ/F15 11.955 Tf 6.204 -9.684 Td[(^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(kP)]TJ/F23 7.97 Tf -1.626 -8.278 Td[(kHTk)]TJ/F15 11.955 Tf 6.204 -9.684 Td[(^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(k+Q)]TJ/F21 7.97 Tf 6.587 0 Td[(1.5Theaposterioristateestimateistheweightedsumoftheaprioriestimateandanerrortermthatrepresentsthedierencebetweentheactualmeasurement,zk,andthemeasurementthatwouldbeexpectedifthemodelwasperfectlyaccurate,hk^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(k.TheweightingfactoristheKalmangainmatrix,Kk.^xk=^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(k+Kkzk)]TJ/F22 11.955 Tf 11.955 0 Td[(hk^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(k.6Thelteringalgorithmisshownbelowforeachtimestepk.

PAGE 63

53 1. SimultaneouslyintegrateEquation 4.1 withtheinitialconditionof^xk)]TJ/F21 7.97 Tf 6.586 0 Td[(1andwsettozero,andEquation 4.3 withinitialconditionofPk)]TJ/F21 7.97 Tf 6.587 0 Td[(1.Thisyieldstheaprioriestimateofthesystemstate,^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(k,aswellastheaprioriestimateoferrorcovariance,P)]TJ/F23 7.97 Tf -1.626 -8.278 Td[(k. 2. Calculatethegain,Kk,using^x)]TJ/F23 7.97 Tf 0 -8.278 Td[(kandP)]TJ/F23 7.97 Tf -1.625 -8.278 Td[(kinEquation 4.5 3. UsingEquation 4.6 calculate^xk,thenalestimateofthesystemstateforthistimestep. 4. CalculatePkfromEquation 4.4 foruseinthenexttimestep.See Gelb 1974 foramorecompletediscussionandderivationoftheKalmanlter.Inordertoestimatestatevariablesandspecicgrowthrates StephanopoulosandSan 1984 proposedtheuseofanextendedKalmanlter.Laterworkby Ramirez 1987 and ChattawayandStephanopoulos 1989 usedtheKalmanlteralongwiththesequentialparameterupdatingstrategyof LjungandSoderstrom 1983 forbothstateandmodelparameterestimation.Thisstrategyhasbeenusedby ParkandRamirez 1990 forcontrolofnutrientlevelsinabioreactor.ThevaluesshowninTable 4{3 fortheparameterscontrollingenzymekineticsK1,K2,aNandbenweretheinitialvalues.TheywerecontinuallyestimatedbytheEKFasprobemeasurementsareprocessed.TheKalmanlteralgorithmwasrunonaeratedbasin3B,asubsetofthefullsystemmodel.TherestoftheplantmodelwasintegratedwithouttheKalmanlterusingthegeneratedparameterestimates. 4.4 ResultsandDiscussionEstimatesofnitratereductaseparameteraNfromtheon-linedataarepresentedinFigure 4{5 .Thisisthersttimethatestimatesofanintracellularcomponentinactivatedsludgehavebeenmadebyprocessingofrealplantdata.NitrateandammoniameasurementsarecomparedtoEKFoutputfora20day

PAGE 64

54 period.Thelteroutputisagoodmatchfortheprobedatawithoutappearingtobeover-tuned.Asthelterruns,itcontinuallyupdatestheestimatesforthemodelsparametersK1,K2,aNandben.EssentiallynochangewasmadetotheparameterswiththeexceptionofaN,showninFigure 4{5 .ThisresultindicatesthatvaryingonlyaNcouldaccountfortheobservedchangeinnitrateandammonia.Asdiscussedin Hamiltonetal. 2005 ,K1andK2arebasedontheLacoperonregulationmodel,andmostoftheireectonbehaviorstemsfromtheirrelativemagnitudes.ThelterparameterswhichrequireturningarethevaluesforthecovariancematricesRandQinEquations 4.3 and 4.5 .Thesegivethealgorithminformationaboutthelevelofvariationthatcanbeexpectedintheprocess,whichheavilyinuencesdecisionsabouthowtoappropriatelyweightmeasurementsversusmodelpredictions.Thetuningwasdonebyinspection,basedonplotsoflteroutputcombinedwiththeerrorcovariancematrixderivederrorbars.Afterrunningthealgorithmandobservingacomponentthatseemedtohaveerrorbarsthatweretootightbasedonprocessknowledge,thecorrespondingcomponentofRwasincreased.ThevariationobservedinaNisonthetimescaleofabout1day.Thisparameteristhemaximumspecicnitratereductasesynthesisrate,andhasbeenfoundtobeveryimportantfortuningtheunlteredmodel.Onepossibleexplanationforthevariationobservedinthisparameterischangesinreactortemperaturewhichwouldbeexpectedtohaveasignicanteectonbiomassgrowth.Theoperators'temperaturelogsareintermittent,makingitdiculttocorrelatethiseect.Anunmodelledchangeinoperatingconditionswouldbereectedbythelterintheformofchangestotheestimatedparameters.

PAGE 65

55 Figure4{5:EstimatesofthemaximumspecicnitratereductasesynthesisrateaNaswellasacomparisonofnitrateandammoniaprobemeaurementstolterresults.TheotherthreeestimatedparametersK1,K2,andbendidnotvarybymorethan0.5%overtheperiodshown.Unitsofactivityaremolesbenzylviologenconsumedpersecond.

PAGE 66

56 4.5 AcknowledgmentsWewouldliketothankGainesvilleRegionalUtilitiesfortheircooperationinthisstudy,andforprovidingaccesstotheKWRF.WewouldalsoliketothanktheemployeesoftheKWRFfortheirassistancewithdatacollectionandforsharingtheirprocessinsights.

PAGE 67

CHAPTER5FUTUREWORK 5.1 DistributedStateModelingDistributedstatemodelingisatypeofmodelstructureinwhichmodelcomponentsaretrackedasevolvingdistributionsratherthansinglevalues.Thebenetofthisapproachisparticularlysignicantformodelswithnonlinearbehaviorbasedonconcentrationsofintracellularcomponents.Inthecaseofdiauxiclag,microorganismsexperienceaperiodoflittleornogrowthduringwhichtheysynthesizenecessaryenzymesforgrowthundernewconditions.Inthecasewhereasubsetofthepopulationisgrowingexponentiallywhilethemajorityisexperiencingalagphase,atraditionalmodelwillgenerateincorrectpredictionsofbehavior.Atraditionalmodelfunctionsasa"singlecell,"inwhichallmodelcomponentsareaveragedoutovertheentirepopulation.Whenasmallfractionofthepopulationhasthemajorityofakeycomponent,themodelpredictionwillbelagfortheentirepopulation.Asimilarargumentcouldbemadeforphosphorusmetabolism. 5.2 ExtendedKalmanFilterThenextstepfortheadaptiveextendedKalmanlterpresentedinChapter 4 wouldbetoincorporateenzymeactivityestimatesfromtheKanapahafacilityintothealgorithm.Theseassayswouldnotbeavailablewiththefrequencyofionprobedata,whichwouldnecessitatetheuseofamulti-rateEKFtechnique.Thisisacommonsituationwithbioprocessmeasurement.Itisfrequentlythecasethatsomemeasurementsareavailableon-lineandarefrequentlyupdatedwhileothersaremoresporadic/irregularandperhapsdelayed.Thisisparticularlytrueinthecaseofbioprocesses,inwhichyoumayhaveconstantmeasurementof 57

PAGE 68

58 variableslikeopticaldensity,pH,temperatureandGCanalysisofeuentgases,butmeasurementofsomesubstrateconcentrationsmayrequirelengthychemicaltests,inadditiontoassaysforintracellularstatesofthecomponents.AmultirateEKFisrelevanttothepresentworkinthattheavailabilityofenzymeassaysisexpectedtogreatlyincreasetheeectivenessoftheparameterestimationalgorithm.Theseassayswouldonlybeavailableinfrequently,andamultirateapproachwouldberequiredtointegratethemintotheprobedata.Theapproachof Gudietal. 1995 wasadaptedfromthemulti-ratestrategyof Glasson 1980 1983 Gudietal. 1995 alsoretainedpastmeasurementsintheiroutputequationsinanattempttoincreasesystemobservability.Inthisapproach,theEKFisdenedasinEquations 4.1 { 4.6 above.Thisapproachdenestwosamplingperiods.Themajorsamplingperiodisthosetimesatwhichbothrapidandinfrequentmeasurementsoverlapandtheminorperiodisthesamplingperiodoftherapidmeasurementalone.ThemeasurementvectorisofhigherdimensionalityatthemajorsamplingperiodsoredenitionsoftheEKFmeasurementequationsarerequired.zmajor=hmajorxtmajor+vmajor.1zminor=hminorxtminor+vminor.2NewmeasurementJacobiansmustbedenedforthelinearizedmeasurementmode.Hmajor=@hmajor^xt;t @xjt.3Hminor=@hminor^xt;t @xjt.4

PAGE 69

59 ThisbeginsthederivationofwhatisfunctionallytwoseparateextendedKalmanlters,oneofwhichisinvokedatthemajorsamplingperiodandoneattheminor.Kmajor=P)]TJ/F23 7.97 Tf -1.626 -8.012 Td[(majorHTmajorHmajorP)]TJ/F23 7.97 Tf -1.626 -8.012 Td[(majorHTmajor+Rmajor)]TJ/F21 7.97 Tf 6.587 0 Td[(1.5Kminor=P)]TJ/F23 7.97 Tf -1.625 -8.012 Td[(minorHTminorHminorP)]TJ/F23 7.97 Tf -1.625 -8.012 Td[(minorHTminor+Rminor)]TJ/F21 7.97 Tf 6.586 0 Td[(1.6 5.3 EnzymeActivityBasedDynamicOptimizationAnultimategoalofthepresentedEKFandmodelisadynamicoptimizationscheme.Ashasbeendiscussed,theindustrystandardmodelscannotpredictdiauxiclag,andanoptimizationschemebasedonsuchamodelwillbesuboptimal.Conceptually,onewouldseektooptimizethenitrogenremovalratesubjecttotheconstraintthatthenitraterespirationenzymelevelsshouldnotfalllowenoughthatthereisasignicantdiauxiclag.Ifaerationiscycledtooslowlytheenzymelevelswilldropwhilerapidcyclingmaynotprovideadequatebiomassgenerationorcarbonremoval.Onealgorithmfordynamicplantoptimizationistodeneagoalfunctionbasedonthedesiredoutputcharacteristicsoftheprocesswhichisafunctionofallcontrollableprocessinputs.Thegoalfunctionwouldbeevaluatedbyusingtheprocessmodeltopredicttheplantperformanceoveralargerelativetomeasurementfrequencytimewindow.Anoptimizationalgorithmwouldbeappliedtothatgoalfunctionandtheresultingoptimaloperatingconditionswouldbeappliedtothephysicalprocess.Asmeasurementsaremade,theEKFcontinuallyupdatestheestimatedprocessstate,whichservesastheinitialconditionforthegoalfunction'sprediction.TheEKFisessentialherebecauseoftheimportanceof

PAGE 70

60 denitricationenzymesinprocessperformanceandthelowfrequencyofenzymeactivitymeasurement.

PAGE 71

APPENDIXAEXTENDEDKALMANFILTERFORDENITRIFICATIONENZYMEPARAMETERESTIMATIONATTHEKANAPAHAWATERRECLAMATIONFACILITYSUPPLEMENTALMATERIALTheadvectionbulkowtermsaredescribedbyahydraulicmodel,thereactiontermsbythebiochemicalmodel,andthemasstransfertermdescribestheactionoftheaerators.dX dt=advection+reaction+masstransferA.1ThenalhydraulicmodelisshowninFigure A{1 .ThetwobioreactortrainsarelabeledAandBwithappropriatesubscriptsonthestreamlabels.InthisgureFrepresentsthefeedtothebioreactorprocess,includingdilutionfromunmodeledsourcessuchaslterwashing.Eachaerobicreactorisassumedtobewellmixedandnotinteractingwithadjacentreactorsexceptvialistedprocessstreams.EachaerobicbasinwithitsfouraeratorsismodeledasfoursequentialCSTRs.Eachvirtualaerobicreactoristhenoxygenatedbasedontheoperationofthecorrespondingphysicalaerators.SomebackmixingoccursinthelargeaerobicbasinandthisismodeledbyincludinginternalrecyclesFarbetweeneachofthevirtualaerobicreactors.Asimpleidealclariermodelisusedforthesecondarysettlingtank.Thismodelsthesolidsenrichmentinthelowerstreamasperfectseparation.Thesludgefrombothtrainsiscombinedbeforeenteringtheclarier.ThedierentialequationsgoverningthehydraulicmodeladvectiontermsfortrainAareshowninEquations A.2 { A.6 below.Intheseexpressions,XydenotescomponentXinreactory.Eachexpressionisthenavector,whereXisreplaced 61

PAGE 72

62 TableA{1:Aerobicbasinsurfaceaerators.Aeratorsarenumberedsequentallyinowdirection.TherstaeratorencounteredintheEastaerationbasinisnumber1,thelastnumber4.IntheWestaerationbasinthenumberingstartswith5.ThisisthenumberingschemeusedbytheKanapahaoperators.Controltypereferstothegranularityofpoweroutputsettingsavailable.High/lowaeratorscanbesetto100%,50%or0%power.ContinuouslyvariableC.V.aeratorscanbesettoanypercentageoutput. aeratorcontrolmaximumnumbertypehorsepower 1,5high/low1252,6C.V.2003,7high/low1254,8C.V.75 FigureA{1:HydraulicmodelPID.Theprocessismodeledastwotrainsinparallel.Eachaerobicbasinwithitsfouraeratorsismodeledas4sequentialCSTRs.Eachvirtualaerobicreactorthenisthenoxygenatedbasedontheoperationofthecorrespondingphysicalaerators.Toaccountforbackmixingwithinthelargeaerobicbasintherearerecyclestreamsbetweenthevirtualaerobicreactors.Anidealpointclariermodelisusedforthesecondarysettlingtank.ThesludgereturnFRforeachtrainismixedbeforebeingreintroducedintotheanoxicbasin.

PAGE 73

63 byeachmodelcomponent.Forexample,Xab4aiscomponentXinaerobicbasin4oftrainA.ThelabelsusedforstreamsareconsistentwithFigure A{1 ,andthereactorvolumesaregivenbyTable A{2 .Equation A.2 givestheanoxicbasinadvectionexpressionforparticulatematerial.Forsolublematerialtheclarierseparationeciency,,equals1sincetheclarierdoesnotsegregatesolublematerial.ThetermFsum;AisdenedforbrevityasFA+FRA+FMA.F VanXinfluent+FR VanXmixed+FM VanXab4)]TJ/F22 11.955 Tf 13.15 8.088 Td[(Fsum;A VanXanA.2ThetermXmixedrepresentsthesecondarysettlingtankcombinedreturnfrombothtrainsandiscalculatedby:Xmixed=FA+FRAXab4a+FB+FRBXab4b FA+FRA+FB+FRBTheadvectiontermsforthe4virtualaerobicreactorsaredenedinEquations A.3 { A.6 .Fsum;A Vaer1Xana+Far1 Vaer1Xab2a)]TJ/F22 11.955 Tf 13.151 8.088 Td[(Fsum;A+Far1 Vaer1Xab1aA.3Fsum;A+Far1 Vaer2Xab1a+Far2 Vaer2Xab3a)]TJ/F22 11.955 Tf 14.738 8.088 Td[(Far1 Vaer2Xab2a)]TJ/F22 11.955 Tf 13.15 8.088 Td[(Fsum;A+Far2 Vaer2Xab2aA.4Fsum;A+Far2 Vaer3Xab2a+Far3 Vaer3Xab4a)]TJ/F22 11.955 Tf 14.738 8.088 Td[(Far2 Vaer3Xab3a)]TJ/F22 11.955 Tf 13.15 8.088 Td[(Fsum;A+Far3 Vaer3Xab3aA.5Fsum;A+Far3 Vaer4Xab3a)]TJ/F22 11.955 Tf 14.738 8.087 Td[(Far3 Vaer4Xab4a)]TJ/F22 11.955 Tf 13.151 8.087 Td[(Fsum;A Vaer4Xab4aA.6

PAGE 74

64 TableA{2:Hydraulicmodelparameters ParameterSymbolUnitsValue virtualaerobictankvolumeVaerL5488250anoxictankvolumeVanL3330800aeratoreciencyaerator1KLA1hr)]TJ/F21 7.97 Tf 6.587 0 Td[(1/hp0.0136aerator2KLA2hr)]TJ/F21 7.97 Tf 6.587 0 Td[(1/hp0.0176aerator3KLA3hr)]TJ/F21 7.97 Tf 6.587 0 Td[(1/hp0.0136aerator4KLA4hr)]TJ/F21 7.97 Tf 6.587 0 Td[(1/hp0.0136dissolvedoxygenatsaturationSO;satmgO2/L8.8aerobicbasininternalrecycleratioabr1.5 Themasstransfercomponentoftheoverallbalanceequationdescribestherateatwhichthesurfaceaeratorsareabletointroducedissolvedoxygenintotheaerobicbasin.Themasstransferforoxygenisgivenbelow,whereirepresentseachofthe4aerobicbasins.ThevalueforKLA2arecentupgradeisderivedfromperformanceperhorsepowerspecicationsfromthemanufacturerandtheperformancefortheremainingaeratorswasfoundbyttingASM1toKWRFnutrientdata.dSOi dt=KLAiSO;sat)]TJ/F22 11.955 Tf 11.955 0 Td[(SOiA.7ThefullbiochemicalmodelispresentedinTable A{3 withcorrespondingmodelparameterspresentedinTable A{4 .Thecombinationofthediscussedhydraulicmodelandthetabulatedbiochemicalmodelisusedtosimulateoverallprocessperformance.Historicalowdatawascollectedfromthisfacilityandusedtogenerateasetofrepresentativediurnalowpatterns.OnesignicantdicultyinmodelingtheKWRFprocessisthattheoperatorlogsrecordowrateseveryhour.Thissamplingfrequencycanmisssignicantvariationonashortertimescaleorover-emphasizevariationthatoccursatthetimethattheowrateisrecorded.Duetothisunreliabilitytheinuentowrateusedinthemodeliscalculatedfrom

PAGE 75

65 TableA{3:eASM1mModel Componenti! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ProcessRate,j,ML)]TJ/F21 7.97 Tf 6.587 0 Td[(3T)]TJ/F21 7.97 Tf 6.587 0 Td[(1 Processj# Si SS Xi XS XB;H XB;A XP SO SNO SNH SND XND SALK SNO;i EN 1 Aerobicgrowthofheterotrophs )]TJ/F21 7.97 Tf 14.293 4.707 Td[(1 YH 1 )]TJ/F21 7.97 Tf 10.494 5.045 Td[(1)]TJ/F23 7.97 Tf 6.587 0 Td[(YH YH )]TJ/F22 11.955 Tf 9.298 0 Td[(iXB )]TJ/F23 7.97 Tf 6.587 0 Td[(iXB 14 ^HSS KS+SSSO KO;H+SOXB;H 2 Anoxicgrowthofhetrotrophs )]TJ/F21 7.97 Tf 14.293 4.707 Td[(1 YH 1 )]TJ/F22 11.955 Tf 9.298 0 Td[(iXB 1)]TJ/F23 7.97 Tf 6.586 0 Td[(YH 142:86YH)]TJ/F23 7.97 Tf -41.256 -11.727 Td[(iXB 14 )]TJ/F21 7.97 Tf 13.787 5.046 Td[(1)]TJ/F23 7.97 Tf 6.587 0 Td[(YH 2:86YH ^HEN EN;maxSNO;i SNO;i;maxSS KS+SSgXB;H 3 Aerobicgrowthofautotrophs 1 )]TJ/F21 7.97 Tf 10.494 5.046 Td[(4:57)]TJ/F23 7.97 Tf 6.586 0 Td[(YA YA 1 YA )]TJ/F22 11.955 Tf 9.299 0 Td[(iXB)]TJ/F21 7.97 Tf 16.499 4.708 Td[(1 YA )]TJ/F23 7.97 Tf 10.494 5.046 Td[(iXB 14)]TJ/F21 7.97 Tf -30.865 -9.738 Td[(1 7YA ^ASNH KNH+SNHSO KO;A+SOXB;A 4 Decayofheterotrophs )]TJ/F22 11.955 Tf 9.299 0 Td[(fP )]TJ/F15 11.955 Tf 9.299 0 Td[(1 fP iXB)]TJ/F22 11.955 Tf 11.956 0 Td[(fPiXB bHXB;H 5 Decayofautotrophs )]TJ/F22 11.955 Tf 9.299 0 Td[(fP )]TJ/F15 11.955 Tf 9.299 0 Td[(1 fP iXB)]TJ/F22 11.955 Tf 11.956 0 Td[(fPiXB bAXB;A 6 Ammonicationofsolubleorganicnitrogen 1 )]TJ/F15 11.955 Tf 9.299 0 Td[(1 1 14 kaSNDXB;A 7 Hydrolysisofentrappedorganics 1 )]TJ/F15 11.955 Tf 9.299 0 Td[(1 khXS=XB;H KX+XS=XB;HhSO KO;H+SO+hKOH KO;H+SOSNO KNO+SNOiXB;H 8 Hydrolysisofentrappedorganicnitrogen 1 )]TJ/F15 11.955 Tf 9.298 0 Td[(1 7XND=XS 9 Uptakeofnitrate )]TJ/F15 11.955 Tf 9.299 0 Td[(1 1 VSN;iEN EN;maxSNO KNO+SNOKO;H KO;H+SOSS KS+SSXB;H 10 Synthesisofnitratereductase 1 NXB;H+K1SNO;i K2XB;H+K1SNO;iSS KS+SSXB;H 11 Decayofintracellularnitrate )]TJ/F15 11.955 Tf 9.299 0 Td[(1 bSNO;i 12 Decayofnitratereductase )]TJ/F15 11.955 Tf 9.298 0 Td[(1 bENEN Observedconversionrates,ML)]TJ/F21 7.97 Tf 6.586 0 Td[(3T)]TJ/F21 7.97 Tf 6.586 0 Td[(1ri=Pjijj

PAGE 76

66 TableA{4:eASM1mparametervalues ParameterSymbolUnitsValues Maximumspecicgrowthratesheterotrophicbiomass^Hh)]TJ/F21 7.97 Tf 6.587 0 Td[(10.39autotrophicbiomass^Ah)]TJ/F21 7.97 Tf 6.587 0 Td[(10.19YieldsonorganicsubstrateheterotrophicbiomassYHmgbiomass/mgsubstrate0.5autotrophicbiomassYAmgbiomass/mgsubstrate0.24Half-saturationcoecientscarbonsourceKSmgorganicsubstrate/L20oxygen,heterotrophicbiomassKO;HmgO2/L0.1oxygen,autotrophicbiomassKO;AmgO2/L0.4nitrateKNHmgN/L1.0slowlydegradablesubstrateKXmg/mgbiomass0.3DecayratesheterotrophicbiomassbHh)]TJ/F21 7.97 Tf 6.587 0 Td[(10.026autotrophicbiomassbAh)]TJ/F21 7.97 Tf 6.587 0 Td[(10.008nitratereductasebENh)]TJ/F21 7.97 Tf 6.587 0 Td[(11E-6NitratereductasesynthesisconstantsmaximumspecicsynthesisrateNkatals/mgbiomasshr1E-12repressor/inducerbindingK1mgnitrate/gdw)]TJ/F21 7.97 Tf 6.586 0 Td[(11.27E5constitutiveexpressionlevelK21.86E4MaximumratesnitrateuptakeVSN;imgnitrate/mgbiomasshr0.122hydrolysiskhmg/mgbiomasshr0.125ammonicationkaL/mgbiomasshr0.0033Anoxiccorrectionfor^Hg0.85Anoxiccorrectionforhydrolysish0.4MassnitrogenperunitbiomassiXB0.086MassnitrogenperunitbiomassproductsiXP0.06FractionofbiomassdecayingtoparticulatesfP0.08 AllmassesgiveninCODunitsValuestakenfrom Koopmanetal. 1989 exceptwheremarkedValuesfrom Hamiltonetal. 2005 Valuesfrompresentstudy

PAGE 77

67 FigureA{2:Diurnalowpatterns.FiguresarebasedonoperatorlogsfortheperiodJanuarythroughAugust2004. thetotalinuentowforeachday,whichisaccuratelyrecorded.ThehourlyowratesarecomputedbyscalingthetotaldailyowusingadiurnalpatternshowninFigure A{2 .ThispatternwascalculatedbyaveragingtheowratepatternsbasedonhourlyoperatorlogsforeachdayoftheweekforthemonthsJanuarythroughAugust2004.Theresultingcurvesaresimilartoresultsfromapreviousstudy Koopmanetal. 1989 inwhichasingleowpatternwasused.Thisaccuratelycapturesthetotalowandmostofthediurnalvariation,butmissesowspikesandchangesinowduetoholidays.Flowspikescanbesignicantduringraineventsandthiscannegativelyimpactprocessmodelperformance.Nitrateandammoniadatawerecollectedusingthefacility'snitrateandammoniaprobeslocatedintheaerobicreactors.Measurementsofbothspecieswerenotmadesimultaneously,butwereseparatedintimesbyavariableamount{10minutes.AnEKFapproachismadelessreliablebyincorporatingmulti-ratetechniquesunlessnecessary,sotheseprobemeasurementsweretreatedassimultaneousforthosetimeswherenitrateandammoniaweremeasuredwithin

PAGE 78

68 5minutesofeachother.Thisisreasonablebecausethetimescaleofchangesinthesespeciesisamuchlargerfractionofanhour.

PAGE 79

APPENDIXBAUTOMATIONPROGRAMSOURCECODE B.1 CodeforDLECModule.bas AttributeVB_Name="DLECModule"OptionExplicitPublicfMainFormAsfrmMainPublicexpAsDLECExperimentGlobalEmailAddressAsString'theemailaddressestobeused'whethertousethecorrespondingemailaddressGlobalUseEmailAsBooleanPublicAllReactorSameAsBoolean'constantsusedtomakethesefunctionsmorereadableGlobalConstwaterAsInteger=0GlobalConstbiomassAsInteger=1GlobalConstnogasAsInteger=2GlobalConstnitrogenAsInteger=1GlobalConstoxygenAsInteger=0'localvariablestoholdpropertyvalues'setthisfalsetobeabletoactuallytakedataGlobalRKHFAKESAMPLEAsBooleanGlobalChart1DataAsDoubleGlobalChart2DataAsDoubleGlobalChart3DataAsDoubleGlobalLastMeasurementWasRinsingAsBoolean'whethertosavedatatoafileasweruntheexperimentPublicLogToFileAsBoolean'***************************************************SubMainDimiAsIntegerEmailAddress="rkhamilt@ufl.edu"EmailAddress="acasasus@ufl.edu"EmailAddress=""EmailAddress="" 69

PAGE 80

70 UseEmail=True'SettherelaysthatidentifytheparticularrelaysweuseRelayO2=1RelayO2=3RelayO2=7RelayInert=2RelayInert=4RelayInert=6RelayEffluent=8RelayEffluent=9RelayEffluent=10'turnoffallrelaysjustsowearesureofitsstateModuleAllRelayOffvbNullString'setuptheexperimentwithbasicinfoSetexp=DLECExperimentConstructorSetfMainForm=NewfrmMainLogToFile=TrueAllReactorSame=True'kludgesFori=0Toexp.NumberReactors-1Withexp.Reactori'SetCommunicationparametersSet.MSCommObj=frmMain.SpecCommDevicei.MSCommObj.CommPort=4+i.MSCommObj.Settings="9600,N,8,1"If.MSCommObj.PortOpenThen.MSCommObj.PortOpen=FalseEndWithNexti'spec1hasaslightchangeinsettingsexp.Reactor.MSCommObj.Settings="19200,N,8,1"RKHFAKESAMPLE=FalsefrmMain.mnuSim.Checked=RKHFAKESAMPLEfMainForm.ShowEndSub'*******************************************PublicFunctionDLECExperimentConstructorByValNumReactorsAsIntegerAsDLECExperiment

PAGE 81

71 'thisistheconstructorfortheexperimentobject'notethatforeachreactor,itmusthaveit'scommdevice'settopointtoaformelementDimOutputAsNewDLECExperimentSetOutput=NewDLECExperimentDimiAsInteger'setupthisexperimentWithOutput.NumberReactors=NumReactors'InitializeSettingsforeachreactor.CurrentRunTime=0.StartTime=Now.EmailHome=False.Running=False.TotalDuration=2880.NewData=False.EmailAbs=0.2.EmailHome=False'setupeachreactorFori=0To.NumberReactors-1With.Reactori.InUse=False.MinutesPerCycle=30.BiomassFlushingTime=10'minutes.AbsorbanceGasTrigger=0.2.Absorbance=0.BubbleScreen=True.BubbleScreenType=1.gas=nogas.fluid=biomass.LastGoodSample=0.MostRecentSample=0.SwitchGases=True.TimeOfLastSample=Now.UseRinsing=True.MinutesBetweenSamples=15.valveEffluent=RelayEffluenti.valveNitrogen=RelayInerti.valveOxygen=RelayO2iEndWithNextiEndWithOutput.Reactor.InUse=TrueSetDLECExperimentConstructor=Output

PAGE 82

72 EndFunction'************************************************PublicFunctionDLECChemostatConstructorByRefParentObjAsDLECExperimentAsDLECChemostatDimnewMSCommObjAsMSCommDimOutputAsDLECChemostatSetOutput=NewDLECChemostat'SetOutput.MSCommObj=frmMain.SpecCommDeviceOutput.Ready=FalseSetOutput.Parent=ParentObjSetDLECChemostatConstructor=OutputEndFunction

PAGE 83

73 B.2 CodeforDLECEmailModule.bas AttributeVB_Name="EmailModule"OptionExplicit'Sendsanemailtotheappropriatepersons.'SendTo=Listofemailaddressesseparatedbyasemicolon.Example:'sm@xyz.com;steve@work.com;jane@home.com'Subject=Textthatsummarizeswhattheemailisabout'EmailText=Bodyoftextthatistheemail'AttachmentPath=Directoryinwhichtheattachmentresides'Attachment=FiletosendwiththeemailPrivateSubSendEmailMAPISendToAsString,SubjectAsString,_EmailTextAsString,OptionalAttachmentPathAsString,_OptionalAttachmentAsStringConstconstRoutineAsString="SendEmailMAPI"DimintStartAsIntegerDimstrSendToAsStringDimintEndAsIntegerDimiAsIntegerIffrmMain.MAPISession.SessionID=0ThenfrmMain.MAPISession.SignOnEndIfIfSendTo=""ThenExitSubWithfrmMain.MAPIMessages.SessionID=frmMain.MAPISession.SessionID.Compose'MakesurethattheSendToalwayshasatrailingsemi-colonmakesit'easierbelow'StripoutanyspacesbetweennamesforconsistencyFori=1ToLenSendToIfMid$SendTo,i,1<>""ThenstrSendTo=strSendTo&Mid$SendTo,i,1EndIfNextiSendTo=strSendToIfRight$SendTo,1<>";"ThenSendTo=SendTo&";"EndIf

PAGE 84

74 'Formateachrecipient,eachareseparatedbyasemi-colon,likethis:'steve.miller@aol.com;sm@psc.com;sm@teletech.com;intEnd=InStr,SendTo,";".RecipAddress=Mid$SendTo,1,intEnd-1.ResolveNameintStart=intEnd+1DointEnd=InStrintStart,SendTo,";"IfintEnd=0ThenExitDoElse.RecipIndex=.RecipIndex+1.RecipAddress=Mid$SendTo,intStart,intEnd-intStart.ResolveNameEndIfintStart=intEnd+1Loop.MsgSubject=Subject.MsgNoteText=EmailTextIfLeft$Attachment,1="ThenAttachment=Mid$Attachment,2,LenAttachmentEndIfIfAttachment<>""ThenIfRight$AttachmentPath,1="Then.AttachmentPathName=AttachmentPath&AttachmentElse.AttachmentPathName=AttachmentPath&"&AttachmentEndIf.AttachmentName=AttachmentEndIf.SendFalseEndWithEndSubPublicSubEmail_ReportDimSendToAsStringDimSubjectAsStringDimEmailTextAsStringDimiAsInteger'puttogetherlistofaddressees

PAGE 85

75 SendTo=""Fori=0To6IfUseEmailiThenSendTo=EmailAddressi+";"Nexti'puttogethersubjectlineSubject=FormatNow,"MediumTime"'puttogetheremailbodyEmailText=""Fori=0Toexp.NumberReactors-1Withexp.ReactorIf.InUseThenEmailText=EmailText+"rctr"+CStri+1+":"+_Format.Absorbance,"0.000"+""If.gas=oxygenThenEmailText=EmailText+"O2"+vbCrIf.gas=nitrogenThenEmailText=EmailText+"N2"+vbCrIf.gas=nogasThenEmailText=EmailText+"NONE"+vbCrEndIfEndWithNexti'sendSendEmailMAPISendTo,Subject,EmailTextEndSub

PAGE 86

76 B.3 CodeforDLECPhoneCallModule.bas AttributeVB_Name="PhoneCallModule"OptionExplicitPublicFunctionCallthisnumAsStringDimOutput,dummy,FromModem$Modem.CommPort=1Modem.Settings="9600,N,8,1"Modem.PortOpen=TrueModem.Output="ATDT"+num+vbCr'Waitfor"OK"tocomebackfromthemodem.Dodummy=DoEvents'Ifthereisdatainthebuffer,thenreadit.IfModem.InBufferCountThenFromModem$=FromModem$+Modem.Input'Checkfor"OK".IfInStrFromModem$,"OK"Then'thephonewasanseredExitDoEndIfEndIf'DidtheuserchooseCancel?'IfCancelFlagThen'CancelFlag=False'ExitDo'EndIfLoop'Disconnectthemodem.Modem.Output="ATH"+vbCr'Closetheport.Modem.PortOpen=FalseEndFunction

PAGE 87

77 B.4 CodeforDLECLogFileModule.bas AttributeVB_Name="LogFileModule"OptionExplicitDimhLogFileAsInteger'Handleofopenlogfile.PublicSubOpenLogSubDimreplace,tempAsString,RetAsIntegerOnErrorResumeNextDimdlgOpenLogAsCommonDialogSetdlgOpenLog=frmMain.OpenLogdlgOpenLog.Flags=cdlOFNHideReadOnlyOrcdlOFNExplorerdlgOpenLog.CancelError=True'Getthelogfilenamefromtheuser.dlgOpenLog.DialogTitle="OpenDataLogFile"dlgOpenLog.Filter="LogFiles*.TXT|*.txt|AllFiles*.*|*.*"DodlgOpenLog.FileName=""dlgOpenLog.ShowOpenIfErr=cdlCancelThenExitSubtemp=dlgOpenLog.FileName'Ifthefilealreadyexists,askiftheuserwantsto'overwritethefileoraddtoit.Ret=LenDir$tempIfErrThenMsgBoxError$,48ExitSubEndIfIfRetThenreplace=MsgBox"Replaceexistingfile-"+temp+"?",35Elsereplace=0EndIfLoopWhilereplace=2'UserclickedtheYesbutton,sodeletethefile.Ifreplace=6ThenKilltempIfErrThenMsgBoxError$,48ExitSub

PAGE 88

78 EndIfEndIf'Openthelogfile.hLogFile=FreeFileOpentempForBinaryAccessWriteAshLogFileIfErrThenMsgBoxError$,48ClosehLogFilehLogFile=0ExitSubElse'Gototheendofthefilesothatnewdatacanbeappended.SeekhLogFile,LOFhLogFile+1EndIfEndSub'*********************************PublicSubCloseLog'Closethelogfile.ClosehLogFilehLogFile=0EndSub'ThisprocedureaddsdatatotheTermcontrol'sTextproperty.'Italsofilterscontrolcharacters,suchasBACKSPACE,'carriagereturn,andlinefeeds,andwritesdatato'anopenlogfile.'BACKSPACEcharactersdeletethecharactertotheleft,'eitherintheTextproperty,orthepassedstring.'Linefeedcharactersareappendedtoallcarriage'returns.ThesizeoftheTermcontrol'sText'propertyisalsomonitoredsothatitnever'exceedsMAXTERMSIZEcharacters.PublicStaticSubShowDataTermAsControl,ByRefDataAsStringConstMAXTERMSIZE=16000DimTermSizeAsLong,i'Makesuretheexistingtextdoesn'tgettoolarge.TermSize=LenTerm.TextIfTermSize>MAXTERMSIZEThenTerm.Text=Mid$Term.Text,4097TermSize=LenTerm.TextEndIf

PAGE 89

79 'PointtotheendofTerm'sdata.Term.SelStart=TermSize'Filter/handleBACKSPACEcharacters.Doi=InStrData,Chr$IfiThenIfi=1ThenTerm.SelStart=TermSize-1Term.SelLength=1Data=Mid$Data,i+1ElseData=Left$Data,i-2&Mid$Data,i+1EndIfEndIfLoopWhilei'Eliminatelinefeeds.Doi=InStrData,Chr$IfiThenData=Left$Data,i-1&Mid$Data,i+1EndIfLoopWhilei'Makesureallcarriagereturnshavealinefeed.i=1Doi=InStri,Data,Chr$IfiThenData=Left$Data,i&Chr$&Mid$Data,i+1i=i+1EndIfLoopWhilei'AddthefiltereddatatotheSelTextproperty.Term.SelText=Data'Logdatatofileifrequested.IfhLogFileTheni=2DoErr=0PuthLogFile,,DataIfErrTheni=MsgBoxError$,21Ifi=2Then

PAGE 90

80 CloseLogEndIfEndIfLoopWhilei<>2EndIfTerm.SelStart=LenTerm.TextEndSub

PAGE 91

APPENDIXCDENITRIFIERDIAUXICGROWTHMODELSOURCECODE C.1 CodeforRun061703.m Runthemodelwithparametersfrom06-17-03loaddata061703b;loadexp061703;loadmfit061703;loadmfitR; %e.EndPhaseAtAbs=[11]; %e.init sni=xfinalend e.PhaseSolutionSn=[504000];e.PhaseDilutionRatio=[0100/-100];e=RunModelmfit,e; %CALCULATEERROR %bylinearinterpolation,findatableofvaluesfortimes %correspondingtothetimesatwhichwehavemeasurements InterpExpEnzyme=interp1e.times,e.fe n,data.e n times;InterpExpBiomass=interp1e.times,e.fXb,data.times; %calculatethesumofsquareserrorbetweenthesimulationandthedata ssqXb=sumdata.fXb-InterpExpBiomass.^2;sizeXb=sizedata.fXb,1;varevXb=5E-5; %experimentallymeasuredaveragevariance %sumofsquareserrorfornitratereductaselevel ssqe n=sumdata.fe n-InterpExpEnzyme.^2;sizee n=sizedata.fe n,1;vareve n=4.3E-19; %experimentallymeasuredaveragevariance %outputaweightedsumofthetwo biomasserror=ssqXb/sizeXb*varevXb;enzymeerror=ssqe n/sizee n*vareve n;out=biomasserror+enzymeerror;figure;PlotModele;PlotDatadata; 81

PAGE 92

82 C.2 CodeforRunModel.m function expout=RunModelm,e %RUNMODELmodel,experiment,returnsanexperimentwithsimulateddata %numberofphases numphases=sizee.PhaseLength,2; %initialconditions state=[e.init Xb;e.init Ss;e.init Sn;e.init e n;e.init sni;]; %Anexperimentphaseconsistsofaperiodofexposuretothesameterminal %electronacceptor. %initialvalues accumY=state';accumT=0; for phase=1:numphases %makenoteintheexperimentwhatphaseweareintegrating e.phase=phase; %setaeration e.So=e.PhaseStartSophase; %DILUTION %diluteonlyXb,Ss,Sn.Theotherstatevariablesarebiomass %specific.Alsonotthatfordilutionratioofzero,nothinghappens. %Thisshouldalwaysbezeroforphase1. %e.g.fora1:19dilutionfold,thisnumberis19 DilutionFactor=e.PhaseDilutionRatiophase; %conc.ofnitrateinthesolutionusedtodilute FeedSn=e.PhaseSolutionSnphase; %conc.ofcarboninthesolutionusedtodilute FeedSs=e.PhaseSolutionSsphase; %nobiomassinfeed state=state/+DilutionFactor; %Substrateisadded state=state+FeedSs*DilutionFactor/+DilutionFactor; %Nitrateisadded state=state+FeedSn*DilutionFactor/+DilutionFactor; %solveODEforeachtimeine.timesfrominitialconditionsinitabove %runeachintegrationforupto100hoursoruntilaterminationevent %occurs.Theseeventsareeitherreachingthecorrectbiomassora %presettime.

PAGE 93

83 [T,Y,TE,YE,IE]=ode15sm.model,0:0.052113154:100,state,e.ODEoptions,m,e;state=Y end ,:; %copythefinalstatetouseonthenextintegration %thispointwasalreadypresentattheendofthepreviousphase, %soI'lldeleteittoavoidduplication Y,:=[];T=[]; %concatenatethesecondsegmentwiththefirst accumT=[accumT;T+accumTend];accumY=[accumY;Y];clearTYTEYEIE; end %Inordertohavemodeldataextendingovertheentirerangeweneedto %curvefitIwillmakesurethatthelasttimewe'vemeasuredis>=the %totalexperimentalduration if accumTend
PAGE 94

84 e.fSn=accumY:,3;e.fe n=accumY:,4;e.fsni=accumY:,5;e.finalstate=[e.fXbende.fSsende.fSnende.fe nende.fsniend];expout=e;

PAGE 95

85 C.3 Codeformodel5c.m function dy=model5ct,y,m,e %model5bt,y,m,modelODEs.misastructofmodelparameters %modelparametersareinastructdefinedbyDefaultModelParam %Thisismodifiedfrommodel5byaddingmonodswitchingtermsforSson %rsniandreno %VariableDefinitions Xb=y;Ss=y;Sn=y;e n=y;sni=y; %Maximumvaluesfore nandsni sni max=m.Vsni/m.mumax an-1/m.Yn an;e n max=m.aNO/m.bNO+m.mumax an-m.b*+m.K1*sni max/ ... m.K2+m.K1*sni max; %ProcessRates %I'lldosomegoofystuffheretoshortcircuitsomepossibleerrors %e.g.ifKs oxhappenstobezerowhichitshouldn'tbe,butitmaybe %temporarilyduringoptimizationthenwhenSs=0whichisreasonable %thenroxisundefined,whenitshouldbezero. if Ss==0rox=0;ranox=0;rsni=0;reno=0; else rox=m.mumax ox*Ss/m.Ks ox+Ss*e.So/m.Koh+e.So; if sni max==0ranox=0; else ranox=m.mumax an*e n/e n max*sni/sni max*Ss/ ... m.Ks an+Ss; end rsni=m.Vsni*e n/e n max*Sn/Sn+m.Knoi*m.Koi/m.Koi+e.So ... *Ss/m.Ks an+Ss;reno=m.aNO*+m.K1*sni/m.K2+m.K1*sni*Ss/ ... m.Ks an+Ss; end %ODEs dxbdt=rox+ranox-m.b-e.D*Xb;

PAGE 96

86 dssdt=-rox/m.Yc ox-ranox/m.Yc an*Xb+e.D*e.Ssf-Ss;dsndt=-rsni*Xb+e.D*e.Snf-Sn; %theformulaforspecificenzymeandinternalnitrateareundefinedfor %washoutconditions.IfthereisnobiomassIwilljustsettheseratesto %zero. if Xb==0de ndt=0;dsnidt=0; else de ndt=reno-m.bNO+e.D+dxbdt/Xb*e n;dsnidt=rsni-ranox/m.Yn an-e.D+m.b+dxbdt/Xb*sni; end %returnoutputs dy=[dxbdt; ... dssdt; ... dsndt; ... de ndt; ... dsnidt;];

PAGE 97

87 C.4 CodeforFitAllData.m %MinimizethevalueofFit TargetFunctionbychangingthemodelparameters %Initialguessesforparameters disp 'FitAllData' %x0.mumax ox=0.5690;%aerobicgrowth %x0.mumax an=0.1631;%anoxicgrowth %x0.Ks an=0.3417;%switchforlackofenergy/carbon %x0.Vsni=0.0217;%maximumNO3uptake; %x0.Knoi=5.6055e-004;%g/Lexternalnitratepromotesuptake %x0.Koi=3.3068e-004;%O2inhibitsnitrateuptake %x0.aNO=2.4536e-008;%maximumenzymeproductionrate %x0.K1=9.8580e+004; %x0.K2=1.9597e+004;%controlslaglength %x0.bNO=0.4;%nitratereductasedecayrate %STARTOPTIMIZTINGFROMTHELASTGOODPOINT loadmfitASA2;disp 'initialmodel' mfit.mumax ox=0.56;mfit.mumax an=0.17;dispmfitx0.array=[mfit.aNOmfit.K2 %mfit.mumax ox %mfit.mumax an mfit.Vsnimfit.K1mfit.Knoimfit.Koimfit.bNO];[fvalinit,cost flag]=fAllErrorx0.array; %Setupconstraints %Allvariablesmustbepositive lb=[1E-121E3 %0.1 %0.1 0.00011E31E-51E-50];ub=[1E-7

PAGE 98

88 1E10 %0.5 %0.5 21E101E-11E-110];t=clock; %Optimize %************************************************************************** disp 'UsingAdaptiveSimulatedAnnealing' disp 'ASA25.5' disp 'http://www.ingber.com/#ASA' %Usage %[fstar,xstar,grad,hessian,state]=... %asamin'minimize',func,xinit,xmin,xmax,xtype xtype=-1*ones,1;[fval,xfinal,grad,hessian,state]= ... asamin 'minimize' 'fAllError' ,x0.array,lb,ub,xtype %************************************************************************** t=etimeclock,t;mfit.aNO=xfinal; %maximumenzymeproductionrate mfit.K2=xfinal; %controlslaglength mfit.Vsni=xfinal; %maximumNO3uptake; mfit.K1=xfinal;mfit.Knoi=xfinal;mfit.Koi=xfinal;mfit.bNO=xfinal;disp 'OptimizationComplete' disp 'InitialFunctionValue' dispnum2strfvalinitdisp 'FinalFunctionValue' dispnum2strfvaldisp 'OptimizationStatistics' %dispoutput disp 'TimeElapsedduringoptimization' dispt/60disp 'ModelParameters' dispmfitsavemfitmfit;savexfinalxfinal;

PAGE 99

APPENDIXDEXTENDEDKALMANFILTERSOURCECODE D.1 CodeforTestKSim.m dispsprintf 'nn********************************nnFile:ntntTestKSim' %testfKanapahaSim.m %loadtestvalues; loaddecjankops2; %TEMPduplicatetheseconditionsfortheothertrain %kops=[kops:,1kops:,2:9/2kops:,2:9/2kops:,10:24]; %loaddeckops; %loaddecjanflatkops; %************************************************************************** %cutdownto1day kops=kops:168,:;runASM=false;useode23s=true;plotreactors=[4]; %************************************************************************** if runASMloadXssASM; else %loadXss; loadXssMonthEnd; %doublexinitforthesecondtrain xinit=[xinitxinit]; end dispsprintf 'Run:ntntday%2.0ftoday%2.0f' ,kops,1/24,kops end ,1/24et=clock;[t,allX,rctr,SRT]=fKanapahaSimxinit,kops,runASM,useode23s,[],[];et=etimeclock,et;dispsprintf 'SimulatedTime:nt%0.1fhr' ,kops end ,1 89

PAGE 100

90 dispsprintf 'ElapsedTime:nt%0.1fs' ,etdispsprintf 'Simrate:nt%0.1fhrs/s' ,kops end ,1/etsavetestksimoutputtallXrctrSRT; for i=plotreactorsfigurei;fPlotTankrctri; end %figure %fPlotKOpkops; figurefPlotComprctr, 'So' ; for i=1:5[m,o]=fKanapahaModelOpsSetuprunASM;subplot,1,i;line[07],[m.Koam.Koa], 'Linestyle' '--' 'Color' 'k' ;line[07],[m.Kohm.Koh], 'Linestyle' '--' 'Color' 'k' ; end %figure %fPlotComprctr,'Snh'; %figure %fPlotComprctr,'Sno'; if ~runASMfigurefPlotComprctr, 'En' ; end figureset, 'Name' 'AllVariablesforTank' ;fPlotTankAllVarsrctrfiguresetgcf, 'Name' 'CompareProbeData' ;fPlotCompareProbesrctr,rctr; %************************************************************************** %Output dispsprintf 'finalSRT:nt%0.1fdays' ,SRTend

PAGE 101

91 D.2 CodeforRunKEKF.m %findthetimesforwhichthereareenzymemeasurements dispsprintf 'nn********************************nnFile:ntntRunKEKF' clear %************************************************************************** %simulationsettings simdata=false; %usesimulatedplantdata,ratherthanrealdata runASM1=false;estparams=true; %estimateparametersaswell hourstosim=500; %numbersofhoursofdatatoworkon plotreactors=[4]; %numberofreactorstoplotattheend %measurementvariance mvar=[20; %aerobic3nitrate 0.6;]; %aerobic3ammonia %************************************************************************** %nsvisnumberofstatevariablesplusnumberofestimatedparameters if estparamsnsv=19; else nsv=15; end reactorindexNW=46:60;reactorindexSE=136:150; %loadplantoperatingconditions loaddecjankops2 %TEMPduplicatetheseconditionsfortheothertrain %kops=[kops:,1kops:,2:9/2kops:,2:9/2kops:,10:24]; if runASM1loadXssASM; else %loadXss; loadXssMonthEnd; %xinit*15+10=0.2;%newinitialvalueforSnh %doublexinitsowe'llhaveinitialconditionsfortheothertrain xinit=[xinitxinit]; end if simdatadispsprintf 'Data:ntntSimulatingData' dispsprintf 'Run:ntntday%2.0ftoday%2.0f' ...

PAGE 102

92 kops,1/24,kopshourstosim,1/24[t,allX,rctr,SRT]=fKanapahaSimxinit, ... kops:hourstosim,:, ... runASM1, ... true, ... [], ... [];t=[];allX,:=[]; %allXisall75statevariablesoneachrow,onerowperhour %tistimevectorcorrespondingtoallX %rctriseachreactorbrokendownintostructs %SRTistheSRTforeachtime %filtersubset %onlyuseasdatapointsthatfallonanhourmarker subset=findmodt,1==0&t<=hourstosim;ts=tsubset;allXs=allXsubset,:;z=[tsallXs:,reactorindexNW:10]; %addinwhatwemeasure: noise=repmatmvar.',sizeallXs,1,1.*randnsizeallXs,1,2;z:,2:3=z:,2:3+noise; %eliminatezeros zfindz:,2<0,2=0;zfindz:,3<0,3=0; else dispsprintf 'Data:ntntDec15-Jan12' %loadProbeData; loadzekf; %filtersubset %onlyuseasdatapointsthatbeforethecutoff subset=findz:,1<=hourstosim;z=zsubset,:; %allX=zeroshourstosim,75; %t=1:hourstosim; end %nowtandallXshouldcorrespondtotheavailablemeasurements %ifwearedoingparameterestimationaswell,thenaugmentstatewith

PAGE 103

93 %initialguessesfortheparameters state=xinit; %setinitialstateestimate xhat0=state; %initializefilterparametersprocessvariances %ProcesscovariancedeterminedviaSWAGmethod P0=[5.1; %Si 1; %Ss 200; %Xi 400; %Xs 400; %Xbh 10; %Xba 145; %Xp 10; %So 10; %Sno 7; %Snh 0.8; %Snd 10; %Xnd 1; %Salk 1; %Snoi 1E-11; %En ]; %ifwe'redoingparameterestimation,augmenttheprocesscovarmatrix %ifestparams %ifrunASM1 %else %P0=[P0; %1E5;%K1 %1E4;%K2 %1E-29;%aN %1E-12];%ben %end %end if estparams if runASM1 else P0=[P0;1E6; %K1 1E5; %K2 1E-35; %aN 1E-13]; %ben end end P0=diagP0;

PAGE 104

94 %measurementstddevs mvar=diagmvar; %************************************************************************** %filterdata dispsprintf 'Filteringdays:nt%0.0fto%0.0f...' ... min[z,1,kops,1]/24, ... z end ,1/24et=clock;[toutxhatoutallXPout]=fEKFz, ... xhat0, ... P0, ... kops, ... mvar, ... runASM1, ... estparams;et=etimeclock,et;dispsprintf 'ModeledTime:nt%0.1fhr' ,toutenddispsprintf 'ElapsedTime:nt%0.1fs' ,etdispsprintf 'Simrate:nt%0.1fhrs/s' ,toutend/et %************************************************************************** if simdatasaveKEKFResult else saveKEKFResult end %ImovedalloftheplottingstufftoascriptsoIcouldeasilyplot %storeddatabyloadingitandrunningthisscript PlotKEKFData

PAGE 105

95 D.3 CodeforfKanapahaSim.m function [t,allX,rctr,SRT]= ... fKanapahaSimxinit,kops,runASM,useode23s,pop,peASM1m %simulateKanapahausingfixedparametersusingeithereASM1morASM1 %inputs: [m,o]=fKanapahaModelOpsSetuprunASM; %timesofoperatingpointchanges[hr] tinput=kops:,1; %aerobicpumppower,foreachpump hp=kops:,2:5; %wasteflowrate[L/hr] Fw=kops:,6; %returnsludgerate[L/hr] Fr=kops:,7; %MLrecyclerate[L/hr] Fm=kops:,8; %feedflowrate[L/hr] F=kops:,9;influent=kops:,10:24; %Ffeedflowrate %Fwwasterate %Frwasterecycle %FmMLrecycle %hphorsepowertopumpsinaerobicbasinthrough4 %influentstrength %xinitinitialconditionsforallstatevariables %alloftheseareinrowform.Ifpassedarrayvalueseachrowrepresents %adifferentsetofoperatingconditions. %tinputiseitheracolumnoftimesrepresentingoperatingcondition %changesorasinglevaluerepresentingadurationtosimulateatthe %operatingconditions. %xinitisthesingleinitialconditionfortinput %optionalparameters %popisoperatingparameters.popisabrm,popisabkm %peASM1areeASM1mmodelparameters %peASM1isK1,peASM1isK2,peASM1isaN,peASM1isben, %peASM1isVsnoi %notationforvariables %an?anoxicbasinintrain? %ab#?aerobicbasin#intrain?

PAGE 106

96 %e.g.anbbisanoxicbasinintrainb %ifwearechanginganyparametersfromdefaults if lengthpopo.abkm1=pop*0.007983036373; %klaslopeforpumppower o.abkm2=pop*0.007983036373; %klaslopeforpumppower o.abkm3=pop*0.007983036373; %klaslopeforpumppower o.abkm4=pop*0.007983036373; %klaslopeforpumppower o.abrzero=pop; end if lengthpeASM1mm.K1=peASM1m; %mgbiomassCOD/mgnitrateCOD==7E4gdw/mgNO3 m.K2=peASM1m; %katals/mgbiomass m.aN=peASM1m;m.ben=peASM1m;m.Vsnoi=peASM1m; %mgNO3CODasN/biomassCOD*hr dispm end %tdeltaisthetimestepstointegrateover. if lengthtinput==1 %useitasasingledurationatthesamesetpoint tdelta=tinput; else %tdelta=difftinput; %ASSUMEEACHTIMEPOINTIS1HOURAPART!BEAWARE! tdelta=oneslengthtinput,1; end options=odeset 'InitialStep' ,0.1; %initialconditionstochangebetweeniterationsmustbecolumnvector xinitloop=xinit.';t=0;allX=xinit; for count=1:lengthtdelta %first,extracttheinfluentcompositioncorrespondingtothistime %stepandformatitasacolumnvector o.influent=influentcount,:.'; %************************************************************************** %VirtualAerobicReactorRecycleratios r1a=o.abrzero+o.abrm*meanhpcount,1:2;

PAGE 107

97 r2a=o.abrzero+o.abrm*meanhpcount,2:3;r3a=o.abrzero+o.abrm*meanhpcount,3:4;o.ab1aKlaf=o.abkzero+o.abkm1*hpcount,1;o.ab2aKlaf=o.abkzero+o.abkm2*hpcount,2;o.ab3aKlaf=o.abkzero+o.abkm3*hpcount,3;o.ab4aKlaf=o.abkzero+o.abkm4*hpcount,4; %************************************************************************** o.F=Fcount;o.Fr=Frcount;o.Fm=Fmcount; %Clarifierperformance o.lambda=o.F+o.Fr/o.Fr+Fwcount; %VirtualAerobicReactorRecycleratios o.Far1a=r1a*o.F+o.Fr+o.Fm;o.Far2a=r2a*o.F+o.Fr+o.Fm+o.Far1a;o.Far3a=r3a*o.F+o.Fr+o.Fm+o.Far2a; if useode23s[ttemp,ytemp]=ode15s@fKanapahadxdt, ... [0tdeltacount], ... xinitloop, ... [], ... m, ... o; else %integrateusingrk4 [ttemp,ytemp]=rkhrk4A@fKanapahadxdt,[0:ssize:tdeltacount],xinitloop,m,o; end %grabnextinitialconditions xinitloop=ytemp end ,:.'; %finaloutputis[time,allX,rctr,SRT] t=[t;ttemp:end+tend];allX=[allX;ytemp: end ,:]; end rctr=fParseAllXt,allX; %setupindexvariables %ifXisyourstate,thenXab2bisthestatevariablesinAerobicBasin %2,trainB

PAGE 108

98 %NOTETHATTHISISDUPLICATEDFROMFUNCTIONACCUM anba=1:15;ab1a=16:30;ab2a=31:45;ab3a=46:60;ab4a=61:75; %indexofparticulatesXi Xndx=[3:7,12]; %CalculateSRThratallpointsintime %grabtheXndxsubsetofeacha??? SRT=sum[allX:,anbaXndx'*o.Vanba ... allX:,ab1aXndx'*o.AerobicTankSize/4 ... allX:,ab2aXndx'*o.AerobicTankSize/4 ... allX:,ab3aXndx'*o.AerobicTankSize/4 ... allX:,ab4aXndx'*o.AerobicTankSize/4],2./ ... sumFwcount*o.lambda*allX:,ab4aXndx',2; %converttodays SRT=SRT/24; %************************************************************************** %************************************************************************** %************************************************************************** function [times,yout]=rkhrk4FunFcn,times,y0,m,o %Initialization %ifgivenonlystart/stoptimes,fillinadefaultstepsize if lengthtimes==2times=[times:0.1*times-times:times]; end times=times'; %t=t0; y=y0:;yout=y.'; %Themainloop for i=1:lengthtimes-1t=timesi;h=timesi+1-timesi; %ift+h>tfinal,h=tfinal-t;end %Computetheslopes s1=fevalFunFcn,t,y,m,o;s1=s1:;s2=fevalFunFcn,t+h/2,y+h*s1/2,m,o;s2=s2:;s3=fevalFunFcn,t+h/2,y+h*s2/2,m,o;s3=s3:;s4=fevalFunFcn,t+h,y+h*s3,m,o;s4=s4:;t=t+h;

PAGE 109

99 y=y+h*s1+2*s2+2*s3+s4/6;yfindy<0=0;yout=[yout;y.']; end ; %************************************************************************** %************************************************************************** %************************************************************************** function [times,yout]=rkheulerFunFcn,times,y0,m,o %thisisSOMUCHslowerthatIcan'tuseit.Itguarenteesgoodnumerical %behavior.Buttheproblemisstiff,sothestepsizesgettoosmall.I %wouldneedamoresophisticaedadaptivestepsizemethodthanthis. %Initialization %ifgivenonlystart/stoptimes,fillinadefaultstepsize if lengthtimes==2times=[times:0.05*times-times:times]; end times=times';y=y0:;yout=y.'; %Themainloop %Themainloop for i=1:lengthtimes-1t=timesi;h=timesi+1-timesi; %Computetheslopes s1=fevalFunFcn,t,y,m,o;s1=s1:;t=t+h;y=y+h*s1;yout=[yout;y.']; end ; %************************************************************************** %************************************************************************** %************************************************************************** function [tout,yout]=rkheulerAFunFcn,times,y0,m,o %thisisSOMUCHslowerthatIcan'tuseit.Itguarenteesgoodnumerical %behavior.Buttheproblemisstiff,sothestepsizesgettoosmall.I %wouldneedamoresophisticaedadaptivestepsizemethodthanthis.

PAGE 110

100 %Initialization t=times;tfinal=timesend;h=0; %valuegetsreplacedbymaxstepsizebeforeuse y=y0:;tout=t;yout=y.'; %Themainloop while ttfinal,h=tfinal-t; end %Computetheslopes s1=fevalFunFcn,t,y,m,o;s1=s1:; %computethemaximumstepsizethatissafetotake %don'tdividebyzero notzero=finds1~=0; %don'tusezerocomponents notzero2=findynotzero>0;maxstepsize=minabsynotzeronotzero2./s1notzeronotzero2;h=0.1*maxstepsize;t=t+h;y=y+h*s1;tout=[tout;t];yout=[yout;y.']; end ; %************************************************************************** %************************************************************************** %************************************************************************** function [times,yout]=rkhrk4AFunFcn,times,y0,m,o %Initialization %ifgivenonlystart/stoptimes,fillinadefaultstepsize if lengthtimes==2times=[times:0.1*times-times:times]; end times=times';t=0;

PAGE 111

101 tfinal=timesend;hdefault=times-times;h=hdefault;y=y0:;yout=y.'; %Themainloop while ttfinal,h=tfinal-t; end h=hdefault;unsucessful=true; %loopuntilweintegratewithoutnegativestatevariables %reducestepsizeiftheyDOgonegativeandrepeat while unsucessful %Computetheslopes s1=fevalFunFcn,t,y,m,o;s1=s1:;s2=fevalFunFcn,t+h/2,y+h*s1/2,m,o;s2=s2:;s3=fevalFunFcn,t+h/2,y+h*s2/2,m,o;s3=s3:;s4=fevalFunFcn,t+h,y+h*s3,m,o;s4=s4:;t=t+h;ytest=y+h*s1+2*s2+2*s3+s4/6; %makesurethannoneofthestatevariables:75wentnegative if anyytest:75<0 %reducethestepsizeaccordingtoASM1 asm1only=y:75;asm1onlyrates=s1:75; %weneedonlythoseratesthatarepositive subset=findasm1onlyrates~=0; %wedon'tneedtoworryaboutthosestatesthatarezero,but %havepositiverates asm1only=asm1onlysubset;asm1onlyrates=asm1onlyratessubset;subset=findasm1only==0; %lookateachzerostateandseeifthecorrespondingrate<0 removeme=findasm1onlyratessubset>=0;asm1onlysubsetremoveme=[];asm1onlyratessubsetremoveme=[];h=minabsasm1only./asm1onlyrates; else %wehaveintegratedsucessfully,storethisdata y=ytest;unsucessful=false; end

PAGE 112

102 end t=t+h; %yfindy<0=0; yout=[yout;y.']; end ;

PAGE 113

103 D.4 CodeforfKanapahaModelOpsSetup.m function [m,o]=fKanapahaModelOpsSetuprunASM %returnmodelparametersandoperatingparameterstobeconstantamongall %simulations %************************************************************************** %TunableProcessParameters %************************************************************************** %************************************************************************** %VirtualAerobicReactorRecycleratios %reflectsback-mixingintherealaerationtank %alinearfunctionoftheaerationmotorpower %abrzeroistherecycleatzeropumppower o.abrzero=1.5;o.abrm=0.00; %recycleslopeforpumppowermax=200*abrm %************************************************************************** %MassTransportiszeroforallcomponentsbutoxygen %Thesevalueswillcomefromthepowertotheaeratormotors %assumelinearrelationshipbetweenpowertomotorandKla %abkzeroistheklaatzeropumppower %Thefirstnumber.5isthemanufacturermeasurelbO2/hp/hr,thena %conversionfactortogetklanoteconversionincludesrctrvolume o.abkzero=0;o.abkm1=1.7*0.007983036373*2; %klaslopeforpumppower o.abkm2=2.2*0.007983036373*2; %klaslopeforpumppower o.abkm3=1.7*0.007983036373*2; %klaslopeforpumppower o.abkm4=1.7*0.007983036373*2; %klaslopeforpumppower %o.abkm=2.0*0.007983036373;%valuebasedonBridgeReportnumbers o.Sosat=8.8; %mg/L %ModelParametersvariable %BridgeReportValues m.Koh=0.1; %mg/LasO2 m.ng=0.85; %dimensionless m.nh=0.4; %dimensionless m.kh=0.125; %mgCOD/mgbiomassCODh m.Knh=1; %mg/LasN m.Koa=0.4; %mg/LasO2 m.Kx=0.3; %.03%mgCOD/mgbiomassCOD m.bh=0.026;m.ba=0.00833;m.ka=0.0033; %L/mgbiomassCODh m.Kno=0.5; %mg/LasN m.Ks=20; %mg/LasCOD

PAGE 114

104 m.muh=0.25; %^-h m.mua=0.033; %^-h m.runASM=runASM; %ParametersforEstimationeventually m.K1=1.2740e+05; %mgbiomassCOD/mgnitrateCOD==7E4gdw/mgNO3; m.K2=1.86E4;m.aN=1.0035e-12; %katals/mgbiomass m.ben=0.06;m.Vsnoi=0.06; %mgNO3CODasN/biomassCOD*hr %************************************************************************** %parameterswithstrongTdependance %Changesfrombridgereport %m.mua=0.08;%^-h %m.ka=0.0033;%L/mgbiomassCODh %m.bh=0.026; m.muh=0.3; %^-h %************************************************************************** %MODIFIEDValues %m.Koh=0.075;%mg/LasO2 %%m.Koa=0.3;%mg/LasO2 m.mua=0.04; %^-h m.ba=0.004; %MODIFIEDparameters m.K1=1.2740e+05; %mgbiomassCOD/mgnitrateCOD==7E4gdw/mgNO3; m.K2=1.86E4;m.aN=1.0035e-12; %katals/mgbiomass m.ben=1E-6;m.Vsnoi=0.122; %mgNO3CODasN/biomassCOD*hr %reactionrateparameters %Yh=0.67;%mgbiomassCOD/mgsubstrateCOD %Ya=0.24;%mgbiomassCODformed/mgNoxidized iNxb=0.086; %mgN/mgCODinactivebiomass iNxd=0.06; %mgN/mgCODinbiomassdebris fp=0.08; %mgdebrisCOD/mgbiomassCOD %************************************************************************** %MODIFIEDparameters Yh=0.5; %mgbiomassCOD/mgsubstrateCOD Ya=0.24; %mgbiomassCODformed/mgNoxidized m.Yh=Yh; if runASM

PAGE 115

105 %ASM1****************************************************************** %STOICHIOMETRYMATRIXNU*********************************************** m.nu=[0,-1/Yh,0,0,1,0,0,--Yh/Yh,0,-iNxb,0,0,-iNxb/14;0,-1/Yh,0,0,1,0,0,0,--Yh/.86*Yh,-iNxb,0,0,-Yh/*2.86*Yh-iNxb/14;0,0,0,0,0,1,0,-.57-Ya/Ya,1/Ya,-iNxb-1/Ya,0,0,-iNxb/14-1/*Ya;0,0,0,1-fp,-1,0,fp,0,0,0,0,iNxb-fp*iNxd,0;0,0,0,1-fp,0,-1,fp,0,0,0,0,iNxb-fp*iNxd,0;0,0,0,0,0,0,0,0,0,1,-1,0,1/14;0,1,0,-1,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,1,-1,0;]; else %eASM1m**************************************************************** %STOICHIOMETRYMATRIX m.nu=[0,-1/Yh,0,0,1,0,0,--Yh/Yh,0,-iNxb,0,0,-iNxb/14,0,0;0,-1/Yh,0,0,1,0,0,0,0,-iNxb,0,0,-Yh/*2.86*Yh-iNxb/14,--Yh/.86*Yh,0;0,0,0,0,0,1,0,-.57-Ya/Ya,1/Ya,-iNxb-1/Ya,0,0,-iNxb/14-1/*Ya,0,0;0,0,0,1-fp,-1,0,fp,0,0,0,0,iNxb-fp*iNxd,0,0,0;0,0,0,1-fp,0,-1,fp,0,0,0,0,iNxb-fp*iNxd,0,0,0;0,0,0,0,0,0,0,0,0,1,-1,0,1/14,0,0;0,1,0,-1,0,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0;0,0,0,0,0,0,0,0,-1,0,0,0,0,1,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,1;0,0,0,0,0,0,0,0,0,0,

PAGE 116

106 0,0,0,-1,0;0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1]; end %Operatingconditionsglobalvariable %TankVolumes o.AerobicTankSize=21953000/2; %liters2.9MG*3785000L/MG o.Vanba=3330800/2; %liters.44MG*3785000L/MG o.Vae1a=o.AerobicTankSize/4;o.Vae2a=o.AerobicTankSize/4;o.Vae3a=o.AerobicTankSize/4;o.Vae4a=o.AerobicTankSize/4;o.Vanbb=o.Vanba;o.Vae1b=o.AerobicTankSize/4;o.Vae2b=o.AerobicTankSize/4;o.Vae3b=o.AerobicTankSize/4;o.Vae4b=o.AerobicTankSize/4;

PAGE 117

107 D.5 CodeforfKanapahadxdt.m function dxdt=fKanapahadxdtt,x,m,o %computestheinstantaneousaccumulationforeachtank %accumulation=reactionrates+advectionrates+masstransferrates %numberofstatevariablespertank ns=15; %setupindexvariables %ifXisyourstate,thenXab2bisthestatevariablesinaerobicbasin %2,trainb anba=1:15;ab1a=16:30;ab2a=31:45;ab3a=46:60;ab4a=61:75;anbb=76:90;ab1b=91:105;ab2b=106:120;ab3b=121:135;ab4b=136:150; %indexofparticulatesXi Xndx=[3:7,12]; %REACTIONRATES************************************************************ %reactionratesareeasy.transposenu*processrates anbarxn=fKanapahaReactionRatesxanba,m;ab1arxn=fKanapahaReactionRatesxab1a,m;ab2arxn=fKanapahaReactionRatesxab2a,m;ab3arxn=fKanapahaReactionRatesxab3a,m;ab4arxn=fKanapahaReactionRatesxab4a,m;anbbrxn=fKanapahaReactionRatesxanbb,m;ab1brxn=fKanapahaReactionRatesxab1b,m;ab2brxn=fKanapahaReactionRatesxab2b,m;ab3brxn=fKanapahaReactionRatesxab3b,m;ab4brxn=fKanapahaReactionRatesxab4b,m; %themixedoutputfrombothvirtualaerobicbasin4sides xmixed=o.Fa+o.Fra*xab4a+o.Fb+o.Frb*xab4b/ ... o.Fa+o.Fra+o.Fb+o.Frb;

PAGE 118

108 %************************************************************************** %EASTTRAINA************************************************************ %************************************************************************** %ANOXICBASINA************************************************************ %componentscomingfromtheclarifieraremixedfrombothtrains %advectiontermforparticulatessettledinclarifier anbaparticulates=o.Fa/o.Vanba*o.influent+ ... o.Fra/o.Vanba*o.lambda*xmixed+ ... o.Fma/o.Vanba*xab4a... o.Fa+o.Fra+o.Fma/o.Vanba*xanba; %advectionfordissolvedspeciesisthesame,butlambdais1 anbaadv=o.Fa/o.Vanba*o.influent+ ... o.Fra/o.Vanba*xab4a+ ... o.Fma/o.Vanba*xab4a... o.Fa+o.Fra+o.Fma/o.Vanba*xanba; %overallit'sacombinationofparticulatesandsolubles,socopythe %particulatesvaluesintotheadvectionterm anbaadvXndx=anbaparticulatesXndx; %AEROBICBASIN1A********************************************************** ab1aadv=o.Fa+o.Fra+o.Fma/o.Vae1a*xanba+ ... o.Far1a/o.Vae1a*xab2a... o.Fa+o.Fra+o.Fma+o.Far1a/o.Vae1a*xab1a; %AEROBICBASIN2A********************************************************** ab2aadv=o.Fa+o.Fra+o.Fma+o.Far1a/o.Vae2a*xab1a+ ... o.Far2a/o.Vae2a*xab3a... o.Far1a/o.Vae2a*xab2a... o.Fa+o.Fra+o.Fma+o.Far2a/o.Vae2a*xab2a; %AEROBICBASIN3A********************************************************** ab3aadv=o.Fa+o.Fra+o.Fma+o.Far2a/o.Vae3a*xab2a+ ... o.Far3a/o.Vae3a*xab4a... o.Far2a/o.Vae3a*xab3a... o.Fa+o.Fra+o.Fma+o.Far3a/o.Vae3a*xab3a; %AEROBICBASIN4A********************************************************** ab4aadv=o.Fa+o.Fra+o.Fma+o.Far3a/o.Vae4a*xab3a... o.Far3a/o.Vae4a*xab4a... o.Fa+o.Fra+o.Fma/o.Vae4a*xab4a;anbamt=zeros,1;ab1amt=anbamt;ab2amt=anbamt;ab3amt=anbamt;ab4amt=anbamt;

PAGE 119

109 %notehere:ab1aistherangeforaerobicbasin1,traina %ab1aistheindexforSointhatbasin %xab1aisthevalueofSointhatbasin ab1amt=o.ab1aKlaf*o.Sosat-xab1a;ab2amt=o.ab2aKlaf*o.Sosat-xab2a;ab3amt=o.ab3aKlaf*o.Sosat-xab3a;ab4amt=o.ab4aKlaf*o.Sosat-xab4a; %************************************************************************** %WESTTRAINB************************************************************ %************************************************************************** %ANOXICBASINB************************************************************ %componentscomingfromtheclarifieraremixedfrombothtrains %advectiontermforparticulatessettledinclarifier anbbparticulates=o.Fb/o.Vanbb*o.influent+ ... o.Frb/o.Vanbb*o.lambda*xmixed+ ... o.Fmb/o.Vanbb*xab4b... o.Fb+o.Frb+o.Fmb/o.Vanbb*xanbb; %advectionfordissolvedspeciesisthesame,butlambdais1 anbbadv=o.Fb/o.Vanbb*o.influent+ ... o.Frb/o.Vanbb*xab4b+ ... o.Fmb/o.Vanbb*xab4b... o.Fb+o.Frb+o.Fmb/o.Vanbb*xanbb; %overallit'sacombinationofparticulatesandsolubles,socopythe %particulatesvaluesintotheadvectionterm anbbadvXndx=anbbparticulatesXndx; %AEROBICBASIN1B********************************************************** ab1badv=o.Fb+o.Frb+o.Fmb/o.Vae1b*xanbb+ ... o.Far1b/o.Vae1b*xab2b... o.Fb+o.Frb+o.Fmb+o.Far1b/o.Vae1b*xab1b; %AEROBICBASIN2B********************************************************** ab2badv=o.Fb+o.Frb+o.Fmb+o.Far1b/o.Vae2b*xab1b+ ... o.Far2b/o.Vae2b*xab3b... o.Far1b/o.Vae2b*xab2b... o.Fb+o.Frb+o.Fmb+o.Far2b/o.Vae2b*xab2b; %AEROBICBASIN3B********************************************************** ab3badv=o.Fb+o.Frb+o.Fmb+o.Far2b/o.Vae3b*xab2b+ ... o.Far3b/o.Vae3b*xab4b... o.Far2b/o.Vae3b*xab3b... o.Fb+o.Frb+o.Fmb+o.Far3b/o.Vae3b*xab3b; %AEROBICBASIN4B********************************************************** ab4badv=o.Fb+o.Frb+o.Fmb+o.Far3b/o.Vae4b*xab3b...

PAGE 120

110 o.Far3b/o.Vae4b*xab4b... o.Fb+o.Frb+o.Fmb/o.Vae4b*xab4b;anbbmt=zeros,1;ab1bmt=anbbmt;ab2bmt=anbbmt;ab3bmt=anbbmt;ab4bmt=anbbmt; %notehere:ab1aistherangeforaerobicbasin1,traina %ab1aistheindexforSointhatbasin %xab1aisthevalueofSointhatbasin ab1bmt=o.ab1bKlaf*o.Sosat-xab1b;ab2bmt=o.ab2bKlaf*o.Sosat-xab2b;ab3bmt=o.ab3bKlaf*o.Sosat-xab3b;ab4bmt=o.ab4bKlaf*o.Sosat-xab4b;dxdt=[anbarxn+anbaadv+anbamt;ab1arxn+ab1aadv+ab1amt;ab2arxn+ab2aadv+ab2amt;ab3arxn+ab3aadv+ab3amt;ab4arxn+ab4aadv+ab4amt;anbbrxn+anbbadv+anbbmt;ab1brxn+ab1badv+ab1bmt;ab2brxn+ab2badv+ab2bmt;ab3brxn+ab3badv+ab3bmt;ab4brxn+ab4badv+ab4bmt;];

PAGE 121

111 D.6 CodeforfParseAllX.m %turnsanallXstatevariablebytimearrayintoreactorstructs function rctr=fParseAllXt,allX,prefix %tistime,allXisallstatevars,prefixistexttoprefixeachlabel if nargin<3prefix= '' ; end ns=15;anba=1:ns;ab1a=ns+1:2*ns;ab2a=2*ns+1:3*ns;ab3a=3*ns+1:4*ns;ab4a=4*ns+1:5*ns; %indexofparticulatesXi Xndx=[3:7,12];rctr.name=[prefix 'AnoxicBasin' ];rctr.t=t;rctr.Si=allX:,anba;rctr.Ss=allX:,anba;rctr.Xi=allX:,anba;rctr.Xs=allX:,anba;rctr.Xbh=allX:,anba;rctr.Xba=allX:,anba;rctr.Xp=allX:,anba;rctr.So=allX:,anba;rctr.Sno=allX:,anba;rctr.Snh=allX:,anba;rctr.Snd=allX:,anba;rctr.Xnd=allX:,anba;rctr.Salk=allX:,anba;rctr.Snoi=allX:,anba;rctr.En=allX:,anba;rctr.name=[prefix 'AerobicBasinVirtualReactor1' ];rctr.t=t;rctr.Si=allX:,ab1a;rctr.Ss=allX:,ab1a;rctr.Xi=allX:,ab1a;rctr.Xs=allX:,ab1a;rctr.Xbh=allX:,ab1a;rctr.Xba=allX:,ab1a;rctr.Xp=allX:,ab1a;rctr.So=allX:,ab1a;

PAGE 122

112 rctr.Sno=allX:,ab1a;rctr.Snh=allX:,ab1a;rctr.Snd=allX:,ab1a;rctr.Xnd=allX:,ab1a;rctr.Salk=allX:,ab1a;rctr.Snoi=allX:,ab1a;rctr.En=allX:,ab1a;rctr.name=[prefix 'AerobicBasinVirtualReactor2' ];rctr.t=t;rctr.Si=allX:,ab2a;rctr.Ss=allX:,ab2a;rctr.Xi=allX:,ab2a;rctr.Xs=allX:,ab2a;rctr.Xbh=allX:,ab2a;rctr.Xba=allX:,ab2a;rctr.Xp=allX:,ab2a;rctr.So=allX:,ab2a;rctr.Sno=allX:,ab2a;rctr.Snh=allX:,ab2a;rctr.Snd=allX:,ab2a;rctr.Xnd=allX:,ab2a;rctr.Salk=allX:,ab2a;rctr.Snoi=allX:,ab2a;rctr.En=allX:,ab2a;rctr.name=[prefix 'AerobicBasinVirtualReactor3' ];rctr.t=t;rctr.Si=allX:,ab3a;rctr.Ss=allX:,ab3a;rctr.Xi=allX:,ab3a;rctr.Xs=allX:,ab3a;rctr.Xbh=allX:,ab3a;rctr.Xba=allX:,ab3a;rctr.Xp=allX:,ab3a;rctr.So=allX:,ab3a;rctr.Sno=allX:,ab3a;rctr.Snh=allX:,ab3a;rctr.Snd=allX:,ab3a;rctr.Xnd=allX:,ab3a;rctr.Salk=allX:,ab3a;rctr.Snoi=allX:,ab3a;rctr.En=allX:,ab3a;rctr.name=[prefix 'AerobicBasinVirtualReactor4' ];rctr.t=t;rctr.Si=allX:,ab4a;rctr.Ss=allX:,ab4a;rctr.Xi=allX:,ab4a;rctr.Xs=allX:,ab4a;

PAGE 123

113 rctr.Xbh=allX:,ab4a;rctr.Xba=allX:,ab4a;rctr.Xp=allX:,ab4a;rctr.So=allX:,ab4a;rctr.Sno=allX:,ab4a;rctr.Snh=allX:,ab4a;rctr.Snd=allX:,ab4a;rctr.Xnd=allX:,ab4a;rctr.Salk=allX:,ab4a;rctr.Snoi=allX:,ab4a;rctr.En=allX:,ab4a;

PAGE 124

114 D.7 CodeforfExtendedKalmanFilter.m function [tout,xArray,allX,Pout]=fEKFzdata, ... kx, ... P, ... kops, ... mvar, ... runASM1, ... ADAPTIVE %appliesaKalmanfiltertodatasetunderconstantoperatingconditions %zdataisanx3matrix,eachrowistime,nitrate,ammonia %kxistheinitialstateoftheentireprocess %Pistheinitialcovariancematrix %kopsistheoperatingconditions,fromtheKWRFStrategySheet.xlsfile %mvarismeasurementvariance %runASM1isboolean,whethertouseASM1oreASM1m %ADAPTIVEisboolean,whethertouseparameterestimationornot %toggledebugchecks DEBUG=true; if ADAPTIVE %lengthofAEKFstatevector nsv=19; %lengthofKanapahaSimstatevector asv=154; %singleoutonereactortofilter.Thisistheindexofthatreactors %statevariablesinsideoftheKSimstate rpindex=[46:60151:asv]; else %lengthofEKFstatevector nsv=15; %lengthofKanapahaSimstatevector asv=150; %singleoutonereactortofilter.Thisistheindexofthatreactors %statevariablesinsideoftheKSimstate rpindex=46:60; end %parsekops kopsfindkops:,1>zdata end ,1,:=[]; %timesofoperatingpointchanges[hr] koptimes=kops:,1; %aerobicpumppower,foreachpump hpa=kops:,2:5; %divideby2becausekopshastotalhpforbothtrains hpb=kops:,6:9; %divideby2becausekopshastotalhpforbothtrains

PAGE 125

115 %wasteflowrate[L/hr] Fwa=kops:,10; %returnsludgerate[L/hr] Fra=kops:,11; %MLrecyclerate[L/hr] Fma=kops:,12; %wasteflowrate[L/hr] Fwb=kops:,13; %returnsludgerate[L/hr] Frb=kops:,14; %MLrecyclerate[L/hr] Fmb=kops:,15; %feedflowrate[L/hr] Fa=kops:,16/2; %feedflowrate[L/hr] Fb=kops:,16/2;influent=kops:,17:31; %inordertokeepsynchronizedbetweenmeasurementtimesandchangesin %operatingconditions,Iwillusethevariablekopindextorepresentwhere %weareinthekopsarray,andz?indexforthedataarrays kopindex=2;z1index=1;iout=2;H=zeros,nsv;H,9=1;H,10=1; %ifthereisadatapointattimezero,ditchit if zdata,1==0z1index=1; end %getthemodelparametersfromthesetupfile. [m,o]=fKanapahaModelOpsSetuprunASM1; %************************************************************************** %VirtualAerobicReactorRecycleratios r1a=o.abrzero+o.abrm*meanhpakopindex,1:2;r2a=o.abrzero+o.abrm*meanhpakopindex,2:3;r3a=o.abrzero+o.abrm*meanhpakopindex,3:4;r1b=o.abrzero+o.abrm*meanhpbkopindex,1:2;r2b=o.abrzero+o.abrm*meanhpbkopindex,2:3;r3b=o.abrzero+o.abrm*meanhpbkopindex,3:4;

PAGE 126

116 o.influent=influentkopindex,:.';o.ab1aKlaf=o.abkzero+o.abkm1*hpakopindex,1;o.ab2aKlaf=o.abkzero+o.abkm2*hpakopindex,2;o.ab3aKlaf=o.abkzero+o.abkm3*hpakopindex,3;o.ab4aKlaf=o.abkzero+o.abkm4*hpakopindex,4;o.ab1bKlaf=o.abkzero+o.abkm1*hpbkopindex,1;o.ab2bKlaf=o.abkzero+o.abkm2*hpbkopindex,2;o.ab3bKlaf=o.abkzero+o.abkm3*hpbkopindex,3;o.ab4bKlaf=o.abkzero+o.abkm4*hpbkopindex,4; %************************************************************************** o.Fa=Fakopindex;o.Fra=Frakopindex;o.Fma=Fmakopindex;o.Fb=Fbkopindex;o.Frb=Frbkopindex;o.Fmb=Fmbkopindex; %Clarifierseparation o.lambda=o.Fa+o.Fb+o.Fra+o.Frb/o.Fra+o.Frb+ ... Fwakopindex+Fwbkopindex; %VirtualAerobicReactorRecycleratios o.Far1a=r1a*o.Fa+o.Fra+o.Fma;o.Far2a=r2a*o.Fa+o.Fra+o.Fma+o.Far1a;o.Far3a=r3a*o.Fa+o.Fra+o.Fma+o.Far2a;o.Far1b=r1b*o.Fb+o.Frb+o.Fmb;o.Far2b=r2b*o.Fb+o.Frb+o.Fmb+o.Far1b;o.Far3b=r3b*o.Fb+o.Frb+o.Fmb+o.Far2b; if ADAPTIVE&&~runASM1 %statevectorsmustbecolumnvectorsforthisalgorithm %onlyformymodifiedmodelandwhenestimatingparameters kx=[kx.';m.K1;m.K2;m.aN;m.ben;]; else kx=kx.'; end

PAGE 127

117 %I'veseenthisdonefreqeuntly.Justsettheinitialerrorcovariance %equaltotheprocessvariance.Thiswouldbemoreclearas %Pinitial=pvar. pvar=P; %allocatememoryforoutputsforspeed numoutput=lengthzdata:,1;xArray=zerosnumoutput,nsv;Pout=zerosnsv,nsv,numoutput;allX=zerosnumoutput,asv;tout=zerosnumoutput,1; %Initializestoragearrays Pout:,:,1=P;xArray,:=kxrpindex';allX,:=kx.';tout=0; %timeoflastmeasurement tend=zdata end ,1;t=0; if ADAPTIVE&&~runASM1dispsprintf 'tntK1ntntK2ntntaNntntbenntntVsnoi' dispsprintf '%3.1fnt%0.4ent%0.4ent%0.4ent%0.4ent%0.4e' ... t,m.K1,m.K2,m.aN,m.ben,m.Vsnoi end %logprogresstofile flog=fopen 'fEKFlog.txt' 'w' ; %stringofvaluestosavetofile savestr=[];saveformat=[];saveheader=[]; for i=1:asvsaveformat=[saveformat '%0.4ent' ];savestr=[savestr 'kx' int2stri ',' ];saveheader=[saveheader 'kx' int2stri 'ntnt' ]; end savestr=savestr:end-2;saveformat=saveformat:end-2;xhat=kxrpindex;eval[ 'fprintfflog,''tntntnt' saveheader 'nn'';' ]eval[ 'fprintfflog,''%0.3fnt' saveformat 'nn'',t,' savestr ''';' ] %FilterData

PAGE 128

118 et=clock;waithandle=waitbar, 'Filteringinprogress' ; %Initializewaitbar while t<=tend %********************************************************************** %considerthatthedatapointsmaynotmatchuptotheoperating %conditions.Ifwe'vepassedachangeoverpointthenchangeallofthe %operatingconditionsappropriately nexttime=zdataz1index,1; %integratesuperODEforwarduntilwe'vecaughtupwithallofthekop %changes while kopindex<=lengthkoptimes&&koptimeskopindex<=nexttimetimestep=koptimeskopindex-t; %integrate [ttemp,ytemp]=ode15s@superODE, ... [0timestep/2timestep], ... [kx;reshapeP,nsv^2,1], ... [], ... m, ... o, ... pvar, ... ADAPTIVE; %we'venowintegratedforwardtobeevenwiththenewkop t=koptimeskopindex; %grabtheentirestateoftheprocess kx=ytemp end ,1:asv'; if DEBUG&&anyisnanytemp end ,:dispsprintf '**ERROR:**ntntytempisNaNinkoploop' end P=reshapeytemp end ,asv+1:nsv^2+asv,nsv,nsv; %changetheoperatingconditions %************************************************************************** %VirtualAerobicReactorRecycleratios r1a=o.abrzero+o.abrm*meanhpakopindex,1:2;r2a=o.abrzero+o.abrm*meanhpakopindex,2:3;r3a=o.abrzero+o.abrm*meanhpakopindex,3:4;r1b=o.abrzero+o.abrm*meanhpbkopindex,1:2;r2b=o.abrzero+o.abrm*meanhpbkopindex,2:3;r3b=o.abrzero+o.abrm*meanhpbkopindex,3:4;o.influent=influentkopindex,:.';

PAGE 129

119 o.ab1aKlaf=o.abkzero+o.abkm1*hpakopindex,1;o.ab2aKlaf=o.abkzero+o.abkm2*hpakopindex,2;o.ab3aKlaf=o.abkzero+o.abkm3*hpakopindex,3;o.ab4aKlaf=o.abkzero+o.abkm4*hpakopindex,4;o.ab1bKlaf=o.abkzero+o.abkm1*hpbkopindex,1;o.ab2bKlaf=o.abkzero+o.abkm2*hpbkopindex,2;o.ab3bKlaf=o.abkzero+o.abkm3*hpbkopindex,3;o.ab4bKlaf=o.abkzero+o.abkm4*hpbkopindex,4; %************************************************************************** o.Fa=Fakopindex;o.Fra=Frakopindex;o.Fma=Fmakopindex;o.Fb=Fbkopindex;o.Frb=Frbkopindex;o.Fmb=Fmbkopindex; %Clarifierperformance o.lambda=o.Fa+o.Fb+o.Fra+o.Frb/o.Fra+o.Frb+ ... Fwakopindex+Fwbkopindex; %VirtualAerobicReactorRecycleratios o.Far1a=r1a*o.Fa+o.Fra+o.Fma;o.Far2a=r2a*o.Fa+o.Fra+o.Fma+o.Far1a;o.Far3a=r3a*o.Fa+o.Fra+o.Fma+o.Far2a;o.Far1b=r1b*o.Fb+o.Frb+o.Fmb;o.Far2b=r2b*o.Fb+o.Frb+o.Fmb+o.Far1b;o.Far3b=r3b*o.Fb+o.Frb+o.Fmb+o.Far2b;kopindex=kopindex+1; end %nowwehaveameasurementtodealwith z=zdataz1index,2:3.';z1index=z1index+1; if z1index>lengthzdata:,1 break ; end timestep=nexttime-t;

PAGE 130

120 waitbarnexttime/tend, ... waithandle, ... sprintf 'Filteringinprogressnntime:%f/%0.1fhrnnElapsedTime:%0.1fmin~%0.0fminremain' ... nexttime, ... tend, ... etimeclock,et/60, ... etimeclock,et/60*tend/nexttime-1; %simultaneouslyintegratexhatandPforwardtotimestep %vectorstructureisbelow: %[allreactorstates; %allparameters; %unrolledPmatrix;] %thisisincasekopandmeasurementcoincide, %wewillhaveintegratedalready if timestep>0[ttemp,ytemp]=ode15s@superODE, ... [0timestep/2timestep], ... [kx;reshapeP,nsv^2,1], ... [], ... m, ... o, ... pvar, ... ADAPTIVE; end %OptionalIntegrators %[ttemp,ytemp]=rkheuler@superODE,... %[0timestep],[kx;reshapeP,nsv^2,1],m,o,pvar; %[ttemp,ytemp]=rkheulerA@superODE,... %[0timestep],[kx;reshapeP,nsv^2,1],m,o,pvar; %[ttemp,ytemp]=rkhrk4A@superODE,... %[0timestep],[kx;reshapeP,nsv^2,1],m,o,pvar; %[ttemp,ytemp]=rkhrk4@superODE,... %[0timestep],[kx;reshapeP,nsv^2,1],m,o,pvar; %wehavejustintegratedupthroughthecurrentmeasurement t=nexttime; %grabtheentirestateoftheprocess kx=ytemp end ,1:asv'; %grabthefilteredreactorstate xhat=kxrpindex;P=reshapeytemp end ,asv+1:nsv^2+asv,nsv,nsv; %correctfornumericalproblems

PAGE 131

121 tmp=finddiagP<0&diagP>-1e-15; for k=tmp,Pk,k=0; end ; %Nowcomputexhatplus,outaposterioristateestimate. Minv=invH*P*H.'+mvar;K=P*H.'*Minv; if DEBUG&&anyisnanxhatdispsprintf '**ERROR:**ntntxhatisNaN' end if DEBUG&&anyisnanxhat+K*z-H*xhatdispsprintf '**ERROR:**ntxhatwillbeNaN' end %KALMANFILTERMAGICHAPPENSHERE xhat=xhat+K*z-H*xhat; if DEBUG,xhatfindxhat<0=0; end ;eval[ 'fprintfflog,''%0.3fnt' saveformat 'nn'',t,' savestr ''';' ] %correctfornumericalproblems tmp=finddiagP<0&diagP>-1e-15; for k=tmp,Pk,k=0; end ; if DEBUG&&anyanydiagP<0dispsprintf '**ERROR:**ntntPminusNEGATIVE' end %Pplus P=eyensv-K*H*P; %correctfornumericalproblems tmp=finddiagP<0&diagP>-1e-15; for k=tmp,Pk,k=0; end ; if DEBUG&&anyanyP<0dispsprintf '**ERROR:**ntntPPlusNEGATIVE' end %reconstitutethetotalprocessstateusingthenewaposteriorixhat kxrpindex:15=xhat:15; if ADAPTIVE&&~runASM1,kxend-3:end=xhat:nsv; end ; if DEBUG&&ADAPTIVE&&anykxend-4:end==0 %can'tallowzeroparametersforenzymekinetics if kxend-1==0kxend-1=1e-15; end

PAGE 132

122 dispsprintf '**ERROR:**ntbadparametervalueafterxhatpluscalc' tzK end if ADAPTIVE&&~runASM1 %nowthatwe'vemodifiedtheparameters,writethemouttothemodel m.K1=kx;m.K2=kx;m.aN=kx;m.ben=kx; %m.Vsnoi=kx; end if ADAPTIVE&&~runASM1dispsprintf '%3.1fnt%0.4ent%0.4ent%0.4ent%0.4ent%0.4e' ... t,m.K1,m.K2,m.aN,m.ben,m.Vsnoi end %storeresults xArrayiout,:=xhat.';Pout:,:,iout=P;allXiout,:=kx.';toutiout=t;iout=iout+1; if DEBUG&&anyisnankx||anykx<0||anyisinfkxdispsprintf '**ERROR:**ntntkxcontainsnegativenumbers,NaN,orInf' end %saveprogresstofile.Incaseofacrash,loadthisfileandthenrun %thenormaldatadisplayfunction,PlotKEKFData %savefEKFallXallXtoutPout; end closewaithandle; %***************************************************** %***************************************************** %***************************************************** function out=superODEt,x,m,o,pvar,ADAPTIVE %thisfunctiontakesasinput %input=[xhat;So;reshapeP,nsv^2,1] %andoutputs[xhatdot;0;reshapePdot,nsv^2,1] if ADAPTIVE %lengthofEKFstatevector

PAGE 133

123 nsv=19; %lengthofKanapahaSimstatevector asv=154; %singleoutonereactortofilter.Thisistheindexofthatreactors %statevariablesinsideoftheKSimstate rpindex=[46:60151:asv]; %numberofparameters np=4; else %lengthofEKFstatevector nsv=15; %lengthofKanapahaSimstatevector asv=150; %singleoutonereactortofilter.Thisistheindexofthatreactors %statevariablesinsideoftheKSimstate rpindex=46:60; %numberofparameters np=0; end P=reshapexasv+1:nsv^2+asv,nsv,nsv; if ADAPTIVEF=[fModelJacobAEKFxrpindex,m,o;zerosnp,nsv;]; else F=[fModelJacobxrpindex,m,o;zerosnp,nsv;]; end xhatdot=[fKanapahadxdtt,x:asv,m,o;zerosnp,1;];Pdot=F*P+P*F.'+pvar; if anyanyisnanPdotdispsprintf '**ERROR:**ntPdotisNaN' end out=[xhatdot;reshapePdot,nsv^2,1;]; %turnPdotintoavector %************************************************************************** %************************************************************************** %************************************************************************** function [times,yout]=rkhrk4FunFcn,times,y0,m,o,pvar %Initialization %ifgivenonlystart/stoptimes,fillinadefaultstepsize if lengthtimes==2times=[times:0.1*times-times:times]; end

PAGE 134

124 times=times'; %t=t0; y=y0:;yout=y.'; %Themainloop for i=1:lengthtimes-1t=timesi;h=timesi+1-timesi; %ift+h>tfinal,h=tfinal-t;end %Computetheslopes s1=fevalFunFcn,t,y,m,o,pvar;s1=s1:;s2=fevalFunFcn,t+h/2,y+h*s1/2,m,o,pvar;s2=s2:;s3=fevalFunFcn,t+h/2,y+h*s2/2,m,o,pvar;s3=s3:;s4=fevalFunFcn,t+h,y+h*s3,m,o,pvar;s4=s4:;t=t+h;y=y+h*s1+2*s2+2*s3+s4/6;yfindy:75<0=0;yout=[yout;y.']; end ; %************************************************************************** %************************************************************************** %************************************************************************** function [times,yout]=rkhrk4AFunFcn,times,y0,m,o,pvar %Initialization %ifgivenonlystart/stoptimes,fillinadefaultstepsize if lengthtimes==2times=[times:0.1*times-times:times]; end times=times';t=0;tfinal=timesend;hdefault=times-times;h=hdefault;y=y0:;yout=y.'; %Themainloop while ttfinal,h=tfinal-t; end

PAGE 135

125 h=hdefault;unsucessful=true; %loopuntilweintegratewithoutnegativestatevariables %reducestepsizeiftheyDOgonegativeandrepeat while unsucessful %Computetheslopes s1=fevalFunFcn,t,y,m,o,pvar;s1=s1:;s2=fevalFunFcn,t+h/2,y+h*s1/2,m,o,pvar;s2=s2:;s3=fevalFunFcn,t+h/2,y+h*s2/2,m,o,pvar;s3=s3:;s4=fevalFunFcn,t+h,y+h*s3,m,o,pvar;s4=s4:;t=t+h;ytest=y+h*s1+2*s2+2*s3+s4/6; %makesurethannoneofthestatevariables:75wentnegative if anyytest:75<0 %reducethestepsizeaccordingtoASM1 asm1only=y:75;asm1onlyrates=s1:75; %weneedonlythoseratesthatarepositive subset=findasm1onlyrates~=0; %wedon'tneedtoworryaboutthosestatesthatarezero,but %havepositiverates asm1only=asm1onlysubset;asm1onlyrates=asm1onlyratessubset;subset=findasm1only==0; %lookateachzerostateandseeifthecorrespondingrate<0 removeme=findasm1onlyratessubset>=0;asm1onlysubsetremoveme=[];asm1onlyratessubsetremoveme=[];maxstepsize=minabsasm1only./asm1onlyrates;h=0.2*maxstepsize; else %wehaveintegratedsucessfully,storethisdata y=ytest;unsucessful=false; end end t=t+h; %yfindy<0=0; yout=[yout;y.']; end ; %************************************************************************** %**************************************************************************

PAGE 136

126 %************************************************************************** function [times,yout]=rkheulerFunFcn,times,y0,m,o,pvar %thisisSOMUCHslowerthatIcan'tuseit.Itguarenteesgoodnumerical %behavior.Buttheproblemisstiff,sothestepsizesgettoosmall.I %wouldneedamoresophisticaedadaptivestepsizemethodthanthis. %Initialization %ifgivenonlystart/stoptimes,fillinadefaultstepsize if lengthtimes==2times=[times:0.05*times-times:times]; end times=times';y=y0:;yout=y.'; %Themainloop for i=1:lengthtimes-1t=timesi;h=timesi+1-timesi; %Computetheslopes s1=fevalFunFcn,t,y,m,o,pvar;s1=s1:;t=t+h;y=y+h*s1;yout=[yout;y.']; end ; %************************************************************************** %************************************************************************** %************************************************************************** function [tout,yout]=rkheulerAFunFcn,times,y0,m,o %thisisSOMUCHslowerthatIcan'tuseit.Itguarenteesgoodnumerical %behavior.Buttheproblemisstiff,sothestepsizesgettoosmall.I %wouldneedamoresophisticaedadaptivestepsizemethodthanthis. %Initialization t=times;tfinal=timesend;h=0; %valuegetsreplacedbymaxstepsizebeforeuse y=y0:;tout=t;yout=y.';

PAGE 137

127 %idallofthecomponentswithnonzerorates %notzero=[1:1316:2831:4346:5861:73]; %Themainloop while ttfinal,h=tfinal-t; end %Computetheslopes s1=fevalFunFcn,t,y,influent,m,o;s1=s1:; %computethemaximumstepsizethatissafetotake notzero=finds1>0;maxstepsize=minabsynotzero./s1notzero;h=0.8*maxstepsize;t=t+h;y=y+h*s1;tout=[tout;t];yout=[yout;y.']; end ;

PAGE 138

128 D.8 CodeforPlotKEKFData.m %PlotKEKFData %RequiredtoutallXerrbars reactorindexNW=46:60;reactorindexSE=136:150; %parsefiltereddataintoreactors rctrhat=fParseAllXtout,allX, 'Filtered-' ; %ifweareusingsimulateddata,thenwehavetheactualstatevariable %values if simdatarctr=fParseAllXts,allXs, 'Simulation-' ; end %togetsomeinformationaboutthecovariancesI'llplotelementsofP %hereI'mcomputingtheindicesofthediagonalelementsfromeach:,:,i %matrixofP errbars=zerossizeallX;psize=sizePout,3; if estparamsreactorindexNW=[reactorindexNW151:154];reactorindexSE=[reactorindexSE151:154]; end for i=1:nsvpndx=i+nsv*i-1:nsv^2:psize*nsv^2;errbars:,reactorindexNWi=sqrtPoutpndx'; end %errbarsisnowthesamedimensionsasallX,andeachelementisthestd %deviationofthecorrespondingelementinallX.Breakitupintoreactors %forplotting. rctrlowererror=fParseAllXtout,allX-errbars, 'lowererror-' ;rctruppererror=fParseAllXtout,allX+errbars, 'uppererror-' ; %nowifIplotallthreereactorsonthesamegraphIgetxhatwithupper %andlowererrorbars. %WAKEUP!!!Look,selectoutthereactorsyouwanttoplot,combinethem %togetherintocellarrayswiththeirerrorbarsandpassthemtofplot %Becauseofthegoofinessofworkingwithcellarrays,andmylackof %creativityinsolvingthis,I'll'preallocate'rctrplotbyassigningitto %rctrhat,thenreplaceeachelementofrctrplotwithwhatIwantto %actuallyplotforthatreactor. rctrtemp=rctrhat;

PAGE 139

129 for i=plotreactorsrctrtemp=rctrhati;rctrtemp=rctruppererrori;rctrtemp=rctrlowererrori; if simdatarctrtemp=rctri; end figurei+20;clf;fPlotTankEKFrctrtemp,z;figurei+40;clf;fPlotEnEKFrctrtemp,z; end %figure %fPlotKOpkops; figurefPlotComprctrhat, 'So' ; for i=1:5[m,o]=fKanapahaModelOpsSetupfalse;subplot,1,i;line[07],[m.Koam.Koa], 'Linestyle' '--' 'Color' 'k' ;line[07],[m.Kohm.Koh], 'Linestyle' '--' 'Color' 'k' ; end figurefPlotComprctrhat, 'Snh' ;figureset, 'Name' 'AllVariablesforTank' ;fPlotTankAllVarsrctrhat %figure %fPlotComprctr,'Ss'; if ~simdatafiguresetgcf, 'Name' 'CompareProbeData' ;fPlotCompareProbesrctrhat,rctrhat; end %************************************************************************** %plottheestimatedparameters if ~runASM1&&estparamsfiguresetgcf, 'Name' 'EstimatedParameterswithErrorBars' ;

PAGE 140

130 h=subplot,1,1;plottout/24,allX:,151, '-k' ... tout/24,allX:,151+errbars:,151, '-m' ... tout/24,allX:,151-errbars:,151, '-m' ylabel 'K 1' ; %seth,'YLim',[01.2*maxallX:,151+errbars:,151]; subplot,1,2;plottout/24,allX:,152, '-k' ... tout/24,allX:,152+errbars:,152, '-m' ... tout/24,allX:,152-errbars:,152, '-m' ylabel 'K 2' ;h=subplot,1,3;plottout/24,allX:,153, '-k' ... tout/24,allX:,153+errbars:,153, '-m' ... tout/24,allX:,153-errbars:,153, '-m' ylabel 'aN' ;seth, 'YLim' ,[01.2*maxallX:,153+errbars:,153];h=subplot,1,4;plottout/24,allX:,154, '-k' ... tout/24,allX:,154+errbars:,154, '-m' ... tout/24,allX:,154-errbars:,154, '-m' ylabel 'b E N' ;seth, 'YLim' ,[01.2*maxallX:,154+errbars:,154];orienttall;wysiwyg; %********************************************************************** figuresetgcf, 'Name' 'ScaledEstimatedParameterswithErrorBars' ;h=subplot,1,1;stemp=allX,151;plottout/24,allX:,151/stemp, '-k' ... tout/24,allX:,151+errbars:,151/stemp, '-m' ... tout/24,allX:,151-errbars:,151/stemp, '-m' ylabel 'K 1' ; %seth,'YLim',[01.2*maxallX:,151+errbars:,151]; subplot,1,2;stemp=allX,152;plottout/24,allX:,152/stemp, '-k' ... tout/24,allX:,152+errbars:,152/stemp, '-m' ... tout/24,allX:,152-errbars:,152/stemp, '-m' ylabel 'K 2' ;

PAGE 141

131 h=subplot,1,3;stemp=allX,153;plottout/24,allX:,153/stemp, '-k' ... tout/24,allX:,153+errbars:,153/stemp, '-m' ... tout/24,allX:,153-errbars:,153/stemp, '-m' ylabel 'aN' ;seth, 'YLim' ,[01.2*maxallX:,153+errbars:,153]/stemp;h=subplot,1,4;stemp=allX,154;plottout/24,allX:,154/stemp, '-k' ... tout/24,allX:,154+errbars:,154/stemp, '-m' ... tout/24,allX:,154-errbars:,154/stemp, '-m' ylabel 'b E N' ;seth, 'YLim' ,[01.2*maxallX:,154+errbars:,154]/stemp;orienttall;wysiwyg; %********************************************************************** figuresetgcf, 'Name' 'EstimatedParameters' ;subplot,1,1;plottout/24,allX:,151, '-k' ylabel 'K 1' ;subplot,1,2;plottout/24,allX:,152, '-k' ylabel 'K 2' ;subplot,1,3;plottout/24,allX:,153, '-k' ylabel 'aN' ;subplot,1,4;plottout/24,allX:,154, '-k' ylabel 'b E N' ;orienttall;wysiwyg; %********************************************************************** figuresetgcf, 'Name' 'ScaledEstimatedParameters' ;subplot,1,1;plottout/24,allX:,151/allX,151, '-k'

PAGE 142

132 ylabel 'K 1' ;subplot,1,2;plottout/24,allX:,152/allX,152, '-k' ylabel 'K 2' ;subplot,1,3;plottout/24,allX:,153/allX,153, '-k' ylabel 'aN' ;subplot,1,4;plottout/24,allX:,154/allX,154, '-k' ylabel 'b E N' ;orienttall;wysiwyg; end

PAGE 143

REFERENCES Baumann,Barbara,MarioSnozzi,AlexanderJBZehnderandJanRoelofvanderMeer996,`DynamicsofdenitricationactivityofParacoccusdenitricansincontinuouscultureduringaerobic-anaerobicchanges',JournalofBacteriology1785,4367{4374. Berks,BenC,DavidJRichardson,CarolRobinson,AnnReilly,RobinTAplinandStuartJFergunson994,`PuricationandcharacterizationoftheperiplasmicnitratereductasefromThiosphaerapantatropha',Eur.J.Biochem.220,117{124. Casasus,Anna01,Eectofexposuretooxygenonthediauxiclag,Mastersthesis,UniversityofFlorida,Gainesville,Florida. Chattaway,ThomasandGregoryStephanopoulos989,`Adaptiveestimationofbioreactors:monitoringplasmidinstability',ChemicalEngineeringScience44,41{48. Gelb,A74,AppliedOptimalEstimation,MITPress,Cambridge. Gernaey,KristV,MarkCMvanLoosdrecht,MogensHenze,MortenLindandStenBJorgensen004,`Activatedsludgewastewatertreatmentplantmodellingandsimulation,stateoftheart',EnvironmentalModelling&Software19,763{783. Glasson,DouglasP980,ResearchinMultirateEstimationandControl,AnalyticSciencesCorp.,Reading,Mass. Glasson,DouglasP983,`Developmentandapplicationsofmultiratedigitalcontrol',IEEEControlSystemsMagazine3,2{8. Gouw,Myrna,RobertBozic,BenKoopmanandSpyrosASvoronos01,`Eectofnitrateexposurehistoryontheoxygen/nitratediauxicgrowthofPseudomonasdenitricans',WaterResearch351,2794{2798. Gudi,RavindraD,SirishLShahandMurrayRGray995,`Adaptivemultiratestateandparameterestimationstrategieswithapplicationtoabioreactor',AIChEJournal111,2451{2464. Hamilton,John,RJain,PAntoniou,SpyrosASvoronos,BenKoopmanandGaryLyberatos92,`Modelingandpilot-scaleexperimentalvericationforpredenitricationprocess',JournalofEnvironmentalEngineering118,38{55. 133

PAGE 144

134 Hamilton,Ryan,AnnaCasasus,MadelineRasche,AtulNarang,SpyrosASvoronosandBenKoopman05,`Structuredmodelfordenitrierdiauxicgrowth',BiotechnologyandBioengineering90,501{508. Henze,M,WGujer,TMinoandMVLoosdrecht000,ActivatedsludgemodelsASM1,ASM2,ASM2dandASM3,number9in`ScienticandTechnicalReport',InternationalWaterAssociation,London,England. Ingildsen,P,UJeppssonandGOlsson02,`Dissolvedoxygencontrollerbasedon-linemeasurementsofammoniumcombiningfeed-forwardandfeedback',WaterScienceandTechnology45{5,453{460. Jones,RobertW,TrevorAGrayandPeterBGarland977,`AstudyofthepermeabilityofthecytoplasmicmembraneofEscherichiacolitoreducedandoxidizedbenzylviologenandmethylviologencations:Complicationsintheuseofviologensasredoxmediatorsformembrane-boundenzymes',BiochimicaetBiophysicaActa.4,671{673. Jorgensen,PE,TEriksenandBKJensen1992,`Estimationofviablebiomassinwastewaterandactivatedsludgebydeterminationofatp,oxygenutilizationrateandfdahydrolysis',WaterResearch261,1495{1501. Kalman,RudolphEmil960,`Anewapproachtolinearlteringandpredictionproblems',TransactionsoftheASME{JournalofBasicEngineering82SeriesD,35{45. Kodama,T,KShimadaandTMori1969,`Studiesonanaerobicbiphasicgrowthofadenitrifyingbacterium,Pseudomonasstutzeri',PlantandCellPhysiology10,855{965. Koopman,Ben,GaryLyberatos,SpyrosASvoronos,PAntoniou,JohnHamiltonandRohitJain89,Mathematicalmodelingandexperimentalvericationforthepredenitricationprocess,Technicalreport,DepartmentsofEnvironmentalSciencesandChemicalEngineering,UniversityofFlorida,Gainesville,Florida,USA. Kornaros,M,CZariandGLyberatos96,`KineticsofdenitricationbyPseudomonasdenitricansundergrowthconditionslimitedbycarbonand/ornitrate',WaterEnvironmentResearch68,934{945. Kornaros,MandGLyberatos997,`Kineticsofaerobicgrowthofadenitrifyingbacterium,pseudomonasdenitricans,inthepresenceofnitratesand/ornitrites',WaterResearch31,479{488. Kornaros,MandGLyberatos998,`Kineticmodelingofpseudomonasdenitricansgrowthanddenitricationunderaerobic,anoxicandtransient

PAGE 145

135 operatingconditions',WaterResearch32,1912{1922. Lee,Dong-Uk05,Thediauxiclagofdenitrifyingbacteriainalternatingoxic/anoxiccyclingundercontinuousowconditions,PhDthesis,UniversityofFlorida,Gainesville,Florida. Lisbon,Keisha,MMcKean,SShekar,SpyrosASvoronosandBenKoopman002,`Eectofdoonoxic/anoxicdiauxiclagofPseudomonasdenitricans',JournalofEnvironmentalEngineering128,391{394. Liu,Pi-Hsin,GougenZhan,SpyrosASvoronosandBenKoopman998,`Diauxiclagfromchangingelectronacceptorsinactivatedsludgetreatment',WaterResearch321,3452{3460. Liu,Pi-Hsin,SpyrosASvoronosandBenKoopman1998,`ExperimentalandmodelingstudyofdiauxiclagofPseudomonasdenitricansswitchingfromoxictoanoxicconditions',BiotechnologyandBioengineering60,649{655. Ljung,LennartandTorstenSoderstrom83,TheoryandPracticeofRecursiveIdentication,TheMITPressSignalProcessing,Optimization,andControlSeries,MITPress,Cambridge,MA. Meredith,ChristopherEdward03,Processcontroldesignandanalysisforwastewaterdisinfection,streamneutralization,andrun-to-runstrategies,Doctoraldissertation,UniversityofFlorida,Gainesville,Florida. Monod,J42,`Thegrowthofbacterialcultures',AnnualReviewofMicrobiology3,371{394. Moreno-Vivian,Conrado,PuricacionCabello,ManuelMartnez-Luque,RafaelBlasco,andFranciscoCastillo99,`Prokaryoticnitratereduction:Molecularpropertiesandfunctionaldistinctionamongbacterialnitratereductases',JournalofBacteriology1811,6573{6584. Nowak,O,KSvardalandPSchweighofer1997,`Thedynamicbehaviorofnitrifyingactivatedsludgesystemsinuencedbyinhibitingwastewatercomounds',BiotechnologyandBioengineering54,434{450. Park,SeujeungandWFredRamirez990,`Optimalregulatorycontrolofbioreactornutrientconcentrationincorporatingsystemidentication',ChemicalEngineeringScience452,3467{3481. Potter,PG,BenKoopmanandSpyrosASvoronos996,`Optimizationofaperiodicbiologicalprocessfornitrogenremovalfromwastewater',WaterResearch30,142{152.

PAGE 146

136 Ramalho,RS983,IntroductiontoWastewaterTreatmentProcesses,AcademicPress,SanDiego,California. Ramirez,WFred987,`Optimalstateandparameteridentication:Anapplicationtobatchfermentation',ChemicalEngineeringScience421,2749{2756. Ramkrishna,D983,FoundationsofBiochemicalEngineering:KineticsandThermodynamicsinBiologicalSystems,number207in`ACSSymposiumSeries',AmericanChemicalSociety,Washington,DC,chapterAcyberneticperspectiveofmicrobialgrowth. Schutze,Manfred,AlbertoCampisano,HubertColas,WolfgangSchillingandPeterAVanrolleghem04,`Realtimecontrolofurbanwastewatersystems{wheredowestandtoday?',JournalofHydrology299,335{348. Shoemaker,Jason,GregoryTReeves,ShaktiGupta,SergeiSPilyugin,ThomasEgliandAtulNarang003,`Thedynamicsofsingle-substratecontinuouscultures:theroleoftransportenzymes',JournalofTheoreticalBiology222,307{322. Steens,MarcA.andP.A.Lant99,`Multivariablecontrolofnutrientremovingactivatedsludgesystems',WaterResearch331,2864{2878. Stephanopoulos,GregandKYSan84,`Studiesonon-linebioreactoridentication',BiotechnologyandBioengineering260,1176{1188. Tenno,RandPUronen95,`Stateandparameterestimationforwastewatertreatmentprocessesusingastochasticmodel',ControlEngineeringPractice3,793{804. vanVeldhuizen,HM,MCMvanLoosdrechtandJJHeijnen1999,`Modellingbiologicalphosphorusandnitrogenremovalinafullscaleactivatedsludgeprocess',WaterResearch33,3459{3468. Waki,T,KMurayama,YKawatoandKIchikawa980,`TransientcharacteristicsofParacoccusdenitricanswithchangesbetweenaerobicandanaerobicconditions',JournalofFermentationTechnology58,243{249. Weon,Seung-Yeon,Chan-WonLee,Sang-IllLeeandBenKoopman02,`NitriteinhibitionofaerobicgrowthofAcinetobactersp.',WaterResearch36,4471{4476. Wild,D,RvonSchulthessandWGujer994,`Synthesisofdenitricationenzymesinactivatedsludge:modellingwithstructuredbiomass',WaterScienceandTechnology30,113{122.

PAGE 147

137 Yagil,GadandEzraYagil71,`Ontherelationbetweeneectorconcentrationandtherateofinducedenzymesynthesis',BiophysicalJournal11,11{27.

PAGE 148

BIOGRAPHICALSKETCHRyanHamiltonreceivedhisB.S.degreeinchemicalengineeringfromGeorgiaTechinAtlanta,Georgiain2000.Since2001hehasbeenagraduatestudentintheChemicalEngineeringDepartmentattheUniversityofFloridainGainesville,Floridaandexpectstoreceivehisdoctoratedegreein2005.Hisresearchinterestsincludemodelingbacterialmetabolism,parameterestimation,andprocessoptimization. 138