Modeling biological nitrogen removal with denitrification enzyme...
Transcript of Modeling biological nitrogen removal with denitrification enzyme...
MODELING BIOLOGICAL NITROGEN REMOVALWITH DENITRIFICATION ENZYME PARAMETER ESTIMATION
By
RYAN K. HAMILTON
A DISSERTATION PRESENTED TO THE GRADUATE SCHOOLOF THE UNIVERSITY OF FLORIDA IN PARTIAL FULFILLMENT
OF THE REQUIREMENTS FOR THE DEGREE OFDOCTOR 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 (Spyros 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 Casasus 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.
iv
TABLE OF CONTENTSpage
ACKNOWLEDGMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
LIST OF TABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
LIST OF FIGURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
ABSTRACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
CHAPTER
1 CONTROL ISSUES AND CHALLENGES . . . . . . . . . . . . . . . . . 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Sewer System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Aerobic Reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.4 Anoxic Reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.5 Secondary Settling Tank . . . . . . . . . . . . . . . . . . . . . . . 71.6 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.7 Disinfection Basin . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.8 Modeling Challenges . . . . . . . . . . . . . . . . . . . . . . . . . 101.9 Further Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 AUTOMATION OF LAB-SCALE BIOREACTORS . . . . . . . . . . . . 14
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.2 Materials, Methods and Results . . . . . . . . . . . . . . . . . . . 142.3 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3 MODEL FOR DENITRIFIER DIAUXIC GROWTH . . . . . . . . . . . 22
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.2 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.3 Materials and Methods . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3.1 Bacterial Strain and Growth Conditions . . . . . . . . . . . 283.3.2 Nitrate Reductase Assay . . . . . . . . . . . . . . . . . . . 293.3.3 Parameter Estimation . . . . . . . . . . . . . . . . . . . . . 30
3.4 Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . 313.5 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363.6 Enzyme Synthesis Expression Derivation . . . . . . . . . . . . . . 39
v
4 KALMAN FILTER FOR ENZYME PARAMETER ESTIMATION . . . 41
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414.2 Kanapaha Water Reclamation Facility . . . . . . . . . . . . . . . 42
4.2.1 Hydraulic Model . . . . . . . . . . . . . . . . . . . . . . . . 454.2.2 Biological Model . . . . . . . . . . . . . . . . . . . . . . . . 49
4.3 Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494.4 Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . 534.5 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5 FUTURE WORK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.1 Distributed State Modeling . . . . . . . . . . . . . . . . . . . . . . 575.2 Extended Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . 575.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 . . . . . . . . . . . . . . . . . . . . . . 69B.2 Code for DLECEmailModule.bas . . . . . . . . . . . . . . . . . . 73B.3 Code for DLECPhoneCallModule.bas . . . . . . . . . . . . . . . . 76B.4 Code for DLECLogFileModule.bas . . . . . . . . . . . . . . . . . . 77
C DENITRIFIER DIAUXIC GROWTH MODEL SOURCE CODE . . . . 81
C.1 Code for Run061703.m . . . . . . . . . . . . . . . . . . . . . . . . 81C.2 Code for RunModel.m . . . . . . . . . . . . . . . . . . . . . . . . 82C.3 Code for model5c.m . . . . . . . . . . . . . . . . . . . . . . . . . . 85C.4 Code for FitAllData.m . . . . . . . . . . . . . . . . . . . . . . . . 87
D EXTENDED KALMAN FILTER SOURCE CODE . . . . . . . . . . . . 89
D.1 Code for TestKSim.m . . . . . . . . . . . . . . . . . . . . . . . . . 89D.2 Code for RunKEKF.m . . . . . . . . . . . . . . . . . . . . . . . . 91D.3 Code for fKanapahaSim.m . . . . . . . . . . . . . . . . . . . . . . 95D.4 Code for fKanapahaModelOpsSetup.m . . . . . . . . . . . . . . . 103D.5 Code for fKanapahadxdt.m . . . . . . . . . . . . . . . . . . . . . . 107D.6 Code for fParseAllX.m . . . . . . . . . . . . . . . . . . . . . . . . 111D.7 Code for fExtendedKalmanFilter.m . . . . . . . . . . . . . . . . . 114D.8 Code for PlotKEKFData.m . . . . . . . . . . . . . . . . . . . . . 128
REFERENCES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
BIOGRAPHICAL SKETCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
vi
LIST OF TABLESTable 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 eASM1m model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4–3 eASM1m parameter values . . . . . . . . . . . . . . . . . . . . . . . . 50
A–1 Aerobic basin surface aerators . . . . . . . . . . . . . . . . . . . . . . 62
A–2 Hydraulic model parameters . . . . . . . . . . . . . . . . . . . . . . . 64
A–3 eASM1m Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
A–4 eASM1m parameter values . . . . . . . . . . . . . . . . . . . . . . . . 66
vii
LIST OF FIGURESFigure 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
viii
Abstract of Dissertation Presented to the Graduate Schoolof the University of Florida in Partial Fulfillment of theRequirements for the Degree of Doctor of Philosophy
MODELING BIOLOGICAL NITROGEN REMOVALWITH DENITRIFICATION ENZYME PARAMETER ESTIMATION
By
Ryan K. Hamilton
December 2005
Chair: Spyros A. SvoronosCochair: Ben KoopmanMajor Department: Chemical 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
ix
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.
x
CHAPTER 1CONTROL 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 majority 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. Nutrients are transformed at different
1
2
AnoxicBasin
AerobicBasin Clarifier
Plant Influent
Mixed Liquor Recirculation
WasteSludge Return
FilterDisinfection
Basin
Effluent
Pumping Station Tank
Sewage Enters
Pumping Station Tank
Pumping Station Tank
Sewage Enters Sewage Enters
Biosolids ProcessingTreatment Facility
Sewer System
Figure 1–1: Example plant diagram. Sewage is collected by local pumping stationsbefore passing to the treatment facility (here a Ludzack-Ettinger process). Influentfirst passes through an anoxic bioreactor in which nitrate is reduced to nitrogenand some organic carbon is consumed. In the aerobic bioreactor most organiccarbon consumption occurs and ammonia is converted to nitrate. The mixed liquorrecirculation returns the generated nitrate to the anoxic reactor for reductionto nitrogen gas. The secondary settling tank returns a concentrated stream ofactivated 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 day/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
3
Figure 1–2: Kanapaha Water Reclamation Facility. This facility uses two differentbiological nutrient removal processes in parallel to treat 10 million gallons ofwastewater per day with a total bioreactor volume of 11.2 Mgal (Note that this isan unusually large ratio of reactor volume to flow rate.) Pictured are the adjacentEast and West aeration basins, totaling 4.8 million gallons.
4
(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.
5
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 75%, 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 30% on an annual cost of $600,000.
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
6
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
7
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 flocs 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 day 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
8
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 (backwashing).
The filter is then returned to normal operation. The major 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
9
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 employed
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 (Meredith, 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 employed.
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.
10
1.8 Modeling Challenges
As is the case in most processes, the majority 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
11
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 portrayed 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
12
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 2AN INEXPENSIVE METHOD FOR THE AUTOMATION OF LAB-SCALE
BIOREACTORS
2.1 Introduction
Bacterial growth experiments may last several days, 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 (Multi-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 Company 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 (Masterflex 06409-13, Cole Parmer, Chicago, IL). The reactor effluent
14
15
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
3133BSN1AN00N0M1S1P0, Parker, New Britain, CT) controlled whether sample or
a rinsing solution reached the spectrophotometer.
A major 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
16
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 suggests 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
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
0 2 4 6 8 10 12
time (hr)
abso
rban
ce (
550n
m) unrinsed biomass
measurements
biomass measurements in spectrophotometer with rinsing
measurement ofrinsing solution
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 displayed data and enabled
the user to set experiment parameters (e.g. duration, sampling period, rinsing
18
period, gas control logic). A flow sheet of the program and its source code are
posted at http://www.ees.ufl.edu/homepp/koopman/hamilton etal/.
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 triggered 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, JWorksRelayModule.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 IsModuleRelayOff function to check
whether the relay for nitrogen (valveNitrogen) is closed and, if so, opens the relay
using the ModuleRelayOn 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.
19
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 (absorbance, 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.
20
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 (absorbance spike due to bubble entrapment or trapped particulate
material) in a 14 hour experiment (28 biomass measurements). Thus, using
21
Table 2–1: Equipment list
Name Manufacturer Model # PriceJ-Works Relay J-Works JSB210-16 $205
Spectrophotometer Thermo-Spectronic Genesys 10UV $3300Windows computer less than $500
3-Way solenoid valve Parker 3133BSN1AN00N0M1S1P0 $20Tubing pump less than $500Power Relay made in shop $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 3A 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).
22
23
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; Casasus,
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-Vivian et al., 1999).
3.2 Model
Baumann et al. (1996) found that in an oxic / anoxic cycling system the
concentrations of intermediates (NO2-, NO, N2O) 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 (NO−3 ) is actively transported into the cell by transport
protein T. Internal nitrate binds to repressor R, freeing operator O which then
allows transcription of the nitrate respiration operon resulting in synthesis of the
24
O
T
NO3
-
NO3
-R
RNO3
-
O
nar
Synthesis
DNA
Cell
membrane
Figure 3–1: Biochemical Process Model. The biochemical process being modeledis that nitrate (NO−
3 ) is actively transported into the cell by transport protein T.Internal nitrate binds to repressor R, freeing operator O. Synthesis of the nitratereductase, nar, and transport protein proceeds at a rate proportional to the amountof free operator. We assume the existence of a nitrate respiration operon, and thatthe 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.
25
Cell
+ +
SN sni
en
XB
Figure 3–2: Model overview. Uptake of nitrate, SN ,results in an increased level ofinternal nitrate, sni. This promotes synthesis of nitrate reductase, en, which in turnpromotes 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, en(katals/gdw), and internal
nitrate concentration, sni (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 ren, 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
26
represents the dependence of the rate of active transport on the concentration
of organic substrate.
ren = aN
(1 + K1sni
K2 + K1sni
) (SS
KS,an + SS
)(3.1)
2. Oxic growth is described by the kinetic expression Henze et al. (2000)
rox = µmax,ox
(SS
KS.ox + SS
) (SO
KOH + SO
)(3.2)
3. The specific rate of uptake of nitrate is proportional to the concentration
of nitrate reductase, en. (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-Vivian et al., 1999). The energy dependence of active transport
is modeled by including a Monod term for organic substrate in the rate
expression.
rsni = Vsnien
en,max
(SN
SN + KNOi
) (KOi
KOi + SO
) (SS
KS,an + SS
)(3.3)
4. Anoxic growth is proportional to internal nitrate, sni, and nitrate reductase,
en. 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 = µmax,anox
(en
en,max
) (sni
sni,max
) (SS
KS,an + SS
)(3.4)
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
dt= (rox + ranox − b)XB (3.5)
27
dSS
dt=
(− 1
Yc,ox
rox −1
Yc,an
ranox
)XB (3.6)
dSN
dt= −rsniXB (3.7)
den
dt= ren −
(b + bNO +
1
XB
dXB
dt
)en (3.8)
dsni
dt= rsni − νN,anranox −
(b +
1
XB
dXB
dt
)sni (3.9)
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 νN,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 sni and en can be found by setting the time
derivatives for these variables to zero and assuming non-limiting concentrations of
organic substrate and nitrate.
sni,max =Vsni
µmax,anox
− νN,an (3.10)
en,max =aN
b + bNO
(1 + K1sni,max
K2 + K1sni,max
)(3.11)
In view of Equation 3.10 Vsni > νN,anµ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
28
Table 3–1: Synthetic media composition. pH is adjusted to 7. Trace metal solutioncontains 0.5% w/v CuSO4, FeCl3, MnCl2 and NaMoO4 · 2H2O.
Chemicals Conc. (g/L)sodium chloride 1
ammonium chloride 1magnesium sulfate heptahydrate 0.2
calcium chloride dihydrate 0.0264L-glutamic acid 6.77
potassium phosphate (monobasic) 5potassium 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
assay.
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 days in a
shaking incubator at 35◦C. The culture was stored at 4◦C 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
Erlenmeyer flask. The culture was kept at 35◦C in a shaking incubator for 24
hours.
At the beginning of each experiment the culture was transferred to a
continuously stirred bioreactor (Multigen 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
29
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 NO−3 -N) was added to give a total concentration of 40 mg NO−
3 -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
(absorbance 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 Assay
Cells were harvested by centrifugation (10,000 g for 10 minutes at 4◦C) 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 assay 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
30
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
J =1
σ2Xb
N∑i=1
(XB,meas,i −XB,pred,i)2
+1
σ2en
M∑i=1
(en,meas,i − en,pred,i)2
The weighting factors are the variances of the experimental measurements
(σ2Xb = 5 × 10−3 and σ2
en = 4.3 × 10−19 ). The performance measure J was
minimized by adjusting aN , K1, K2, Vsni, 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.
31
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
32
Tab
le3–
2:Par
amet
erva
lues
obta
ined
by
fitt
ing da
tafr
omLiu
data
from
pres
ent
Par
amet
erSym
bol
Units
etal
.:Fig
.3–
3st
udy:
Fig
s.3–
4&
3–5
Max
imum
spec
ific
grow
thra
tes
oxic
condit
ions
µm
ax,o
xh−
10.
390.
56an
oxic
condit
ions
µm
ax,a
nox
h−
10.
190.
19Y
ield
son
orga
nic
subst
rate
oxic
condit
ions
YC
,ox
mg
bio
mas
s/m
gsu
bst
rate
7575
anox
icco
ndit
ions
YC
,an
mg
bio
mas
s/m
gsu
bst
rate
7575
Nit
rate
utiliza
tion
coeffi
cien
tν N
,an
mg
nit
rate
/mg
bio
mas
s0.
120.
11H
alf-sa
tura
tion
coeffi
cien
tsca
rbon
sourc
e,ox
icco
nditio
ns
KS,o
xm
gor
ganic
subst
rate
/L0.
025
0.02
5ca
rbon
sourc
e,an
oxic
condit
ions
KS,a
nm
gor
ganic
subst
rate
/L0.
70.
7ox
yge
nK
OH
mg
O2/L
0.1
0.1
nit
rate
for
nit
rate
upta
keK
NO
im
gnit
rate
/L0.
074
0.07
4ox
yge
nfo
rnit
rate
upta
keK
Oi
mg
O2/L
0.08
20.
082
Dec
ayra
tes
bio
mas
sb
h−
10
0nit
rate
reduct
ase
b NO
h−
12.
170.
035
Nit
rate
reduct
ase
synth
esis
const
ants
max
imum
spec
ific
synth
esis
rate
aN
kata
ls∗ /
(gdw
bio
mas
s·s)
2.1E
-87E
-10
repre
ssor
/in
duce
rbin
din
gK
1(m
gnit
rate
/gdw
)−1
6.9E
154.
1E5
const
itutive
expre
ssio
nle
vel
K2
4.8E
1580
00∗∗
Max
imum
spec
ific
nit
rate
upta
kera
teV
sni
mg
nit
rate
/(gd
wbio
mas
s·s)
0.03
0.06
∗T
he
acti
vity
ofnit
rate
reduct
ase
isre
por
ted
inm
oles
ben
zylvio
loge
nre
duce
dper
seco
nd.
∗∗In
Fig
ure
3–5b
the
valu
eof
one
par
amet
erw
asch
ange
dco
mpar
edto
the
pre
vio
us
two
exper
imen
talfits
.In
this
exper
imen
tK
2=
100.
33
0.07
0.16
0.26
0 2 4 6 8 10 12
Time (hr)
Ab
sorb
ance
0
5
10
15
20
25
30
35
40
45
50
mg
nit
rate
/ L
biomass (experimental) biomass (model)
nitrate (experimental) nitrate (model)
a)
0.07
0.08
0.09
0.10
0.11
0.12
0.13
0.14
0.15
0 1 2 3 4 5 6 7 8
Time (hr)
Ab
sorb
ance
0
5
10
15
20
25
30
35
40
45
50
mg
nit
rate
/ L
biomass (experimental) biomass (model)
nitrate (experimental) nitrate (model)
b)
Figure 3–3: Model fit to Liu, Svoronos and Koopman (1998). Data points showexperimental results; dashed and solid lines show model fits. Nitrate was present atthe 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
0.1
0.2
0.3
0.4
0.5
0 5 10 15
Time (hr)
Ab
sorb
ance
0.0E+00
5.0E-10
1.0E-09
1.5E-09
2.0E-09
2.5E-09
3.0E-09
3.5E-09
4.0E-09
enzy
me
acti
vity
biomass (model) biomass (experimental)enzyme (model) enzyme (experimental)
a)
0.0E+00
2.0E-02
4.0E-02
6.0E-02
8.0E-02
1.0E-01
1.2E-01
1.4E-01
1.6E-01
1.8E-01
0 5 10 15
Time (hr)
mg
nit
rate
/ L
intracellular nitrateb)
Figure 3–4: Enzyme activity during diauxic growth. Data points show experimentalresults; dashed and solid lines show model fits. The biomass grew exponentiallyduring an initial 2.5 hour aerobic phase. Nitrate was added to a concentration of40 mg/L NO3-N at the start of the anoxic phase. This was followed by a lag of 11hours. The enzyme level was increasing during the lag phase.
35
0.0
0.2
0.4
0.6
0.8
1.0
1.2
0 5 10 15 20 25 30
Time (hr)
Ab
sorb
ance
0.0E+00
2.0E-10
4.0E-10
6.0E-10
8.0E-10
1.0E-09
1.2E-09
1.4E-09
1.6E-09
enzy
me
acti
vity
biomass (model) biomass (experimental)
enzyme (model) enzyme (experimental)
a)
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0 2 4 6 8 10 12 14 16 18
Time (hr)
Ab
sorb
ance
0.0E+00
5.0E-10
1.0E-09
1.5E-09
2.0E-09
2.5E-09
3.0E-09
3.5E-09
4.0E-09
enzy
me
acti
vity
)
biomass (model) biomass (experimental)
enzyme (model) enzyme (experimental)b)
Figure 3–5: Additional experiments with model fits. These experiments includeddilution during the aerobic growth phase to ensure that absorbance stayed withinthe range of linear measurement. Nitrate was added to a concentration of 40 mg/LNO3-N at the start of the anoxic phase. The sharpness of the enzyme activity curvein figure b results from the lower magnitude of parameter K2.
36
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.
38
Tab
le3–
3:N
omen
clat
ure
use
din
den
itri
fier
model
ing
par
amet
erunit
sdes
crip
tion
aN
kat/
(gdw
bio
mas
s·s)
max
imum
spec
ific
enzy
me
synth
esis
rate
bh−
1sp
ecifi
cbio
mas
sdec
ayra
teb N
Oh−
1sp
ecifi
cnit
rate
reduct
ase
dec
ayra
tee n
kat/
mg
bio
mas
ssp
ecifi
cnit
rate
reduct
ase
conce
ntr
atio
ne n
,max
kat/
mg
bio
mas
sm
axim
um
spec
ific
nit
rate
reduct
ase
acti
vity
K1
(mg
nitra
te/g
dw
)−1
equilib
rium
const
ant
for
repre
ssor
/in
duce
rbin
din
gK
2re
late
dto
const
ituti
veen
zym
eex
pre
ssio
nle
vel
KN
Oi
mg
NO
− 3/L
hal
f-sa
tura
tion
coeffi
cien
tfo
rin
tern
alnit
rate
KO
Hm
gO
2/L
hal
f-sa
tura
tion
coeffi
cien
tfo
rox
yge
nin
aero
bic
grow
thK
Oi
mg
O2/L
hal
f-sa
tura
tion
coeffi
cien
tfo
rox
yge
nin
hib
itio
nof
nitra
teupta
keK
S,a
nm
gor
ganic
subst
rate
/Lhal
f-sa
tura
tion
coeffi
cien
tfo
rca
rbon
sourc
ein
anox
icgr
owth
KS,o
xm
gor
ganic
subst
rate
/Lhal
f-sa
tura
tion
coeffi
cien
tfo
rca
rbon
sourc
ein
aero
bic
grow
thr a
nox
gdw
bio
mas
s/(g
dw
bio
mas
s·hr)
spec
ific
bio
mas
sgr
owth
rate
under
anox
icco
nditio
ns
r en
kat/
(gdw
bio
mas
s2·h
r)sp
ecifi
cnitra
tere
duct
ase
synth
esis
rate
r ox
gdw
bio
mas
s/(g
dw
bio
mas
s·hr)
spec
ific
bio
mas
sgr
owth
rate
under
aero
bic
condit
ions
r sni
mg
nit
rate
/(gd
wbio
mas
s2·h
r)sp
ecifi
cnit
rate
upta
kera
teS
Sm
gor
ganic
subst
rate
/Lor
ganic
subst
rate
conce
ntr
atio
nS
Nm
gnit
rate
/Lnitra
teco
nce
ntr
atio
ns n
im
g/gd
wbio
mas
sin
tern
alnit
rate
conce
ntr
atio
nS
Om
g/L
dis
solv
edox
yge
nco
nce
ntr
atio
nV
sni
mg
nit
rate
/(gd
wbio
mas
s2·h
r)m
axim
um
spec
ific
nit
rate
upta
kera
teX
Bgd
wbio
mas
s/L
bio
mas
sco
nce
ntr
atio
nY
c,an
mg
bio
mas
s/m
gor
ganic
subst
rate
yie
ldunder
anox
icco
ndit
ions
Yc,
ox
mg
bio
mas
s/m
gor
ganic
subst
rate
yie
ldunder
aero
bic
condit
ions
ν N,a
nm
gnit
rate
/mg
bio
mas
snitra
teco
nsu
med
per
unit
bio
mas
sgr
owth
σ2 X
b(g
dw
bio
mas
s/L)2
vari
ance
ofbio
mas
sm
easu
rem
ents
σ2 en
(kat
/mg
bio
mas
s)2
vari
ance
ofen
zym
em
easu
rem
ents
39
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]k1↼−−⇁ [RI] (3.12)
This shifts equilibrium between bound repressor, RO, and free repressor.
[R] + [O]k2↼−−⇁ [RO] (3.13)
Note that, even in the absence of inducer there will always 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
[Rt] = [R] + [RO] + [RI] (3.14)
[Ot] = [O] + [RO] (3.15)
The rate of nitrate reductase synthesis, r, is proportional to the concentration of
free operator.
r = kr[O] (3.16)
Therefore we are interested in finding the equilibrium concentration of O. From
Equation 3.13
[O]
[RO]=
1
k2
1
[R]
By applying Equation 3.15 we obtain
[O] = [Ot]1
1 + k2[R](3.17)
40
In a similar fashion, manipulating Equation 3.12 and assuming [RO] � [Rt] yields
[R] = [Rt]1
1 + k1[I](3.18)
Substituting Equation 3.18 into Equation 3.17we obtain
[O] = [Ot]1 + k1[I]
(1 + k2[Rt]) + k1[I](3.19)
which results in the rate
r = aN1 + k1[I]
K2 + k1[I]
with
aN = kr[Ot]
K2 = (1 + k2[Rt])
The constitutive enzyme synthesis rate is obtained by setting I = 0:
r = kr[Ot]1
(1 + k2[Rt])
CHAPTER 4ESTIMATION 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.
41
42
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 Chattaway 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 day 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 day (MGD) of wastewater, of which a constant
5 MGD is diverted to a Carrousel process(EIMCO, Salt Lake City, UT). The
43
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 (MLSS) recirculation returns a fraction of effluent from the
aerated reactors to the anoxic reactors.
44
Table 4–1: Wastewater composition
Component Symbol Units Valuesoluble intert substrate SI g COD/m3 62particulate intert substrate XI g COD/m3 62readily degradable substrate SS g COD/m3 99slowly degradable particulate substrate XS g COD/m3 247nitrate plus nitrite nitrogen SNO g N/m3 0ammonia nitrogen SNH g N/m3 24soluble degradable organic nitrogen SND g N/m3 4particulate degradable organic nitrogen XND g N/m3 6active heterotrophic biomass XB,H g COD/m3 0active autotrophic biomass XB,A g COD/m3 0inert decay products XP g COD/m3 0alkalinity SALK g moles/m3 6dissolved oxygen SO g COD/m3 0nitrate reductase EN activity∗/(L hr) 0intracellular nitrate SNO,i g/L 0
Values taken from Potter et al. (1996)∗ enzyme activity reported as moles substrate reduced per second
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 day according to both the current state of the facility and the
anticipated future loading. The aerators are almost always 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.
45
Waste
FeedClarifier
AnoxicBasin(East)
AeratedBasin(West)
AnoxicBasin(West)
Sludge Return
Mixed Liquor Recirculation
AeratedBasin(East)
Headworks
Mixed Liquor Recirculation
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 day 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
46
0 2 4 6 8 10 12 14 16 18 200
100
200
300
400
aera
tor
1 (
hp
)
0 2 4 6 8 10 12 14 16 18 200
100
200
300
400
ae
rato
r 2 (
hp
)
0 2 4 6 8 10 12 14 16 18 200
100
200
300
400
ae
rato
r 3
(hp
)
0 2 4 6 8 10 12 14 16 18 200
100
200
300
400
ae
rato
r 4
(h
p)
days
Figure 4–2: Kanapaha operations – aeration strategy.
47
0 2 4 6 8 10 12 14 16 18 200
0.5
1
1.5
2x 10
6F
eed (
F)
(L/h
r)
0 2 4 6 8 10 12 14 16 18 200
1
2
3
x 106
MLS
S R
ecircula
tion (
FM
) (L
/hr)
0 2 4 6 8 10 12 14 16 18 200
2
4
6
8
10x 10
5
Slu
dge R
ecycle
(F
R)
(L/h
r)
0 2 4 6 8 10 12 14 16 18 200
2000
4000
6000
8000
10000
Slu
dge W
asting (
FW
) (L
/hr)
days
Figure 4–3: Kanapaha operations – recycles and recirculations.
48
FRA
FWA+FWB
Far3Far2Far1
FA
Clarifier
AeratedBasin4 A
AeratedBasin3 A
AeratedBasin2 A
AeratedBasin1 A
AnoxicBasin A
FRB
Far3Far2Far1
FBAeratedBasin4 B
AeratedBasin3 B
AeratedBasin2 B
AeratedBasin1 B
AnoxicBasin B
FMB
FMA
*
Figure 4–4: Hydraulic model process diagram. * indicates location of nitrate andammonia 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 adjacent 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 (Far)
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.
49
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 (eASM1m). 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 =
[(VSN,i
µh · ηg
)−
(1− Yh
2.86 · Yh
)]·XB,H
EN,max =
(aN
bEN + µh · ηg − bh
)·(
XB,H + K1 · SNO,i,max
K2 ·XB,H + K1 · SNO,i,max
)·XB,H
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: eASM1m model expressions that differ from ASM1
j ProcessComponent
8 14 15 Process rate, ρj
SNO SNO,i EN ML−3T−1
2 Anoxic growthof heterotrophs
− 1−YH
2.86·YHµH
EN
EN,max
SNO,i
SNO,i,max
(SS
KS+SS
)ηgXB,H
9 Uptake ofnitrate
-1 1 VSN,iEN
EN,max
(SNO
KNO+SNO
) (KO,H
KO,H+SO
) (SS
KS+SS
)XB,H
10 Synthesisof nitratereductase
1 αN
(XB,H+K1SNO,i
K2XB,H+K1SNO,i
) (SS
KS+SS
)XB,H
11 Decay ofintracellularnitrate
-1 bSNO,i
12 Decay ofnitratereductase
-1 bENEN
Table 4–3: eASM1m parameter values that differ from values presented in Hamiltonet al. (1992)
Parameter Symbol Units ValuesMaximum specific growth rates
heterotrophic biomass µH h−1 0.39autotrophic biomass µA h−1 0.19
Yields on organic substrateheterotrophic biomass YH mg biomass/mg substrate 0.5autotrophic biomass YA mg biomass/mg substrate 0.24
Decay ratesautotrophic biomass bA h−1 0.008nitrate reductase bEN h−1 1E-6
Nitrate reductase synthesis constantsmaximum specific synthesis rate αN moles benzyl viologen/(mg biomass·hr) 1E-12repressor / inducer binding K1 (mg nitrate/gdw)−1 1.27E5∗
constitutive expression level K2 1.86E4∗
Maximum nitrate uptake rate VSN,i mg nitrate/(mg biomass·hr) 0.122
All masses given in COD units∗ Values from Hamilton et al. (2005)
51
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
x
θ
and
measurement vector z: x
θ
=
f (x, θ, t)
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, θ. 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 θ. 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.
52
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) · F T (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
(x−
k
)]P−
k (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−k HT
k
(x−
k
) [Hk
(x−
k
)P−
k HTk
(x−
k
)+ Q
]−1(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−k ). The weighting factor is the Kalman gain matrix, Kk.
xk = x−k + Kk ·
[zk − hk(x
−k )
](4.6)
The filtering algorithm is shown below for each time step k.
53
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 priori estimate of the system state, x−k , as well as the a priori estimate of
error covariance, P−k .
2. Calculate the gain, Kk , using x−k and P−
k 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 Chattaway 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
(K1, K2, aN and ben) 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 day
54
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 ben. 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 day. 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.
55
0 2 4 6 8 10 12 14 16 180
0.5
1
1.5x 10
!11
aN
(m
ol B
.V)/
(mg
bio
ma
ss h
r)
days
0 2 4 6 8 10 12 14 16 180
0.5
1
1.5
2
Re
acto
r 3
B (
mg
NH
3 /
L)
0 2 4 6 8 10 12 14 16 180
2
4
6
8
days
Re
acto
r 3
B (
mg
NO
3 /
L)
Probe
Simulation
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 filterresults. The other three estimated parameters (K1, K2, and ben) did not vary bymore than 0.5% over the period shown. Units of activity are moles benzyl viologenconsumed 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 5FUTURE 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 majority 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 majority 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 Chapter
4 would be to incorporate enzyme activity estimates from the Kanapaha facility
into the algorithm. These assays 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 delayed. This is particularly
true in the case of bioprocesses, in which you may have constant measurement of
57
58
variables like optical density, pH, temperature and GC analysis of effluent gases,
but measurement of some substrate concentrations may require lengthy chemical
tests, in addition to assays for intracellular states of the components.
A multirate EKF is relevant to the present work in that the availability of
enzyme assays is expected to greatly increase the effectiveness of the parameter
estimation algorithm. These assays 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 major 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 major sampling period so
redefinitions of the EKF measurement equations are required.
zmajor = hmajor(x(tmajor)) + vmajor (5.1)
zminor = hminor(x(tminor)) + vminor (5.2)
New measurement Jacobians must be defined for the linearized measurement
mode.
Hmajor =∂hmajor(x(t), t)
∂xj(t)(5.3)
Hminor =∂hminor(x(t), t)
∂xj(t)(5.4)
59
This begins the derivation of what is functionally two separate extended
Kalman filters, one of which is invoked at the major sampling period and one at
the minor.
Kmajor = P−majorH
Tmajor
[HmajorP
−majorH
Tmajor + Rmajor
]−1(5.5)
Kminor = P−minorH
Tminor
[HminorP
−minorH
Tminor + Rminor
]−1(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 AEXTENDED KALMAN FILTER FOR DENITRIFICATION ENZYME
PARAMETER ESTIMATION AT THE KANAPAHA WATER RECLAMATIONFACILITY
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
dt= advection + reaction + mass transfer (A.1)
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 adjacent 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 (Far) 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 (advection 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
61
62
Table A–1: Aerobic basin surface aerators. Aerators are numbered sequentally inflow direction. The first aerator encountered in the East aeration basin is number1, the last number 4. In the West aeration basin the numbering starts with 5. Thisis the numbering scheme used by the Kanapaha operators. Control type refers tothe granularity of power output settings available. High/low aerators can be set to100%, 50% or 0% power. Continuously variable (C.V.) aerators can be set to anypercentage output.
aerator control maximumnumber type horsepower
1,5 high/low 1252,6 C.V. 2003,7 high/low 1254,8 C.V. 75
FRA
FWA+FWB
Far3Far2Far1
FA
Clarifier
AerobicBasin4 A
AerobicBasin3 A
AerobicBasin2 A
AerobicBasin1 A
AnoxicBasin A
FRB
Far3Far2Far1
FBAerobicBasin4 B
AerobicBasin3 B
AerobicBasin2 B
AerobicBasin1 B
AnoxicBasin B
FMB
FMA
*
*
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 thecorresponding physical aerators. To account for backmixing within the large aerobicbasin there are recycle streams between the virtual aerobic reactors. An ideal pointclarifier model is used for the secondary settling tank. The sludge return (FR) foreach train is mixed before being reintroduced into the anoxic basin.
63
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, λ, equals 1 since
the clarifier does not segregate soluble material. The term Fsum,A is defined for
brevity as FA + FRA + FMA.
F
Van
·Xinfluent +FR
Van
· λ ·Xmixed +FM
Van
·Xab4 −Fsum,A
Van
·Xan (A.2)
The term Xmixed represents the secondary settling tank combined return from
both trains and is calculated by:
Xmixed =(FA + FRA) ·Xab4a + (FB + FRB) ·Xab4b
FA + FRA + FB + FRB
The advection terms for the 4 virtual aerobic reactors are defined in Equations
A.3 – A.6.
Fsum,A
Vaer1
·Xana +Far1
Vaer1
·Xab2a −Fsum,A + Far1
Vaer1
·Xab1a (A.3)
Fsum,A + Far1
Vaer2
·Xab1a +Far2
Vaer2
·Xab3a −Far1
Vaer2
·Xab2a −Fsum,A + Far2
Vaer2
·Xab2a (A.4)
Fsum,A + Far2
Vaer3
·Xab2a +Far3
Vaer3
·Xab4a −Far2
Vaer3
·Xab3a −Fsum,A + Far3
Vaer3
·Xab3a (A.5)
Fsum,A + Far3
Vaer4
·Xab3a −Far3
Vaer4
·Xab4a −Fsum,A
Vaer4
·Xab4a (A.6)
64
Table A–2: Hydraulic model parameters
Parameter Symbol Units Valuevirtual aerobic tank volume Vaer L 5488250anoxic tank volume Van L 3330800aerator efficiency
aerator 1 KLA1 hr−1 / hp 0.0136aerator 2 KLA2 hr−1 / hp 0.0176aerator 3 KLA3 hr−1 / hp 0.0136aerator 4 KLA4 hr−1 / hp 0.0136
dissolved oxygen at saturation SO,sat mg O2 / L 8.8aerobic basin internal recycle ratio abr 1.5
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.
dSOi
dt= KLAi · (SO,sat − SOi) (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
65
Tab
leA
–3:
eASM
1mM
odel
Com
ponent
i→
12
34
56
78
910
1112
1314
15P
roce
ssR
ate,
ρj,M
L−
3T−
1
Pro
cess
j↓
Si
SS
Xi
XS
XB
,HX
B,A
XP
SO
SN
OS
NH
SN
DX
ND
SA
LK
SN
O,i
EN
1A
erob
icgr
owth
ofhet
erot
rophs
−1 YH
1−
1−
YH
YH
−i X
B−
i XB
14
µH
( SS
KS+
SS
)(S
O
KO
,H+
SO
) XB
,H
2A
nox
icgr
owth
ofhet
rotr
ophs
−1 YH
1−
i XB
1−
YH
14·2
.86·Y
H−
i XB
14
−1−
YH
2.8
6·Y
Hµ
HE
N
EN
,ma
x
SN
O,i
SN
O,i
,ma
x
( SS
KS+
SS
) η gX
B,H
3A
erob
icgr
owth
ofau
totr
ophs
1−
4.5
7−
YA
YA
1 YA
−i X
B−
1 YA
−i X
B
14
−1
7Y
A
µA
( SN
H
KN
H+
SN
H
)(S
O
KO
,A+
SO
) XB
,A
4D
ecay
ofhet
erot
rophs
−f P
−1
f Pi X
B−
f Pi X
Bb H
XB
,H
5D
ecay
ofau
totr
ophs
−f P
−1
f Pi X
B−
f Pi X
Bb A
XB
,A
6A
mm
onifi
cati
onof
solu
ble
orga
nic
nit
roge
n
1−
11 14
kaS
NDX
B,A
7H
ydro
lysi
sof
entr
apped
orga
nic
s1
−1
kh
XS
/X
B,H
KX
+(X
S/X
B,H
)
[(S
O
KO
,H+
SO
) +η h
( KO
H
KO
,H+
SO
)(S
NO
KN
O+
SN
O
)] XB
,H
8H
ydro
lysi
sof
entr
apped
orga
nic
nit
roge
n
1−
1ρ
7(X
ND/X
S)
9U
pta
keof
nit
rate
−1
1V
SN
,iE
N
EN
,ma
x
( SN
O
KN
O+
SN
O
)(K
O,H
KO
,H+
SO
)(S
S
KS+
SS
) XB
,H
10Synth
esis
ofnit
rate
reduct
ase
1α
N
( XB
,H+
K1S
NO
,i
K2X
B,H
+K
1S
NO
,i
)(S
S
KS+
SS
) XB
,H
11D
ecay
ofin
trac
ellu
lar
nit
rate
−1
bSN
O,i
12D
ecay
ofnit
rate
reduct
ase
−1
b EN
EN
Obse
rved
conve
rsio
nra
tes,
ML−
3T−
1r i
=∑ j
ν ijρ
j
66
Table A–4: eASM1m parameter values
Parameter Symbol Units ValuesMaximum specific growth rates
heterotrophic biomass µH h−1 0.39∗∗
autotrophic biomass µA h−1 0.19∗∗
Yields on organic substrateheterotrophic biomass YH mg biomass/mg substrate 0.5∗∗
autotrophic biomass YA mg biomass/mg substrate 0.24∗∗
Half-saturation coefficientscarbon source KS mg organic substrate/L 20oxygen, heterotrophic biomass KO,H mg O2/L 0.1oxygen, autotrophic biomass KO,A mg O2/L 0.4nitrate KNH mg N/L 1.0slowly degradable substrate KX mg/mg biomass 0.3
Decay ratesheterotrophic biomass bH h−1 0.026autotrophic biomass bA h−1 0.008∗∗
nitrate reductase bEN h−1 1E-6∗∗
Nitrate reductase synthesis constantsmaximum specific synthesis rate αN katals/(mg biomass·hr) 1E-12∗∗
repressor / inducer binding K1 (mg nitrate/gdw)−1 1.27E5∗
constitutive expression level K2 1.86E4∗
Maximum ratesnitrate uptake VSN,i mg nitrate/(mg biomass·hr) 0.122∗∗
hydrolysis kh mg/(mg biomass ·hr) 0.125ammonification ka L/(mg biomass ·hr) 0.0033
Anoxic correction for µH ηg 0.85Anoxic correction for hydrolysis ηh 0.4Mass nitrogen per unit biomass iXB 0.086Mass nitrogen per unit biomass products iXP 0.06Fraction of biomass decaying to particulates fP 0.08
All masses given in COD unitsValues taken from Koopman et al. (1989) except where marked∗ Values from Hamilton et al. (2005)∗∗ Values from present study
67
0 5 10 15 20 254
5
6
7
8
9
10
11
12
13
time (hr)
Flo
w R
ate
(M
GD
)
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Figure A–2: Diurnal flow patterns. Figures are based on operator logs for theperiod January through August 2004.
the total influent flow for each day, 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 day 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 holidays. 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 BAUTOMATION PROGRAM SOURCE CODE
B.1 Code for DLECModule.bas
Attribute VB_Name = "DLECModule"Option ExplicitPublic fMainForm As frmMainPublic exp As DLECExperimentGlobal EmailAddress(7) As String’the email addresses to be used’whether to use the corresponding email addressGlobal UseEmail(7) As BooleanPublic AllReactorSame As Boolean
’constants used to make these functions more readableGlobal Const water As Integer = 0Global Const biomass As Integer = 1Global Const nogas As Integer = 2Global Const nitrogen As Integer = 1Global Const oxygen As Integer = 0’local variable(s) to hold property value(s)
’set this false to be able to actually take dataGlobal RKHFAKESAMPLE As BooleanGlobal Chart1Data() As DoubleGlobal Chart2Data() As DoubleGlobal Chart3Data() As DoubleGlobal LastMeasurementWasRinsing As Boolean’whether to save data to a file as we run the experimentPublic LogToFile As Boolean
’***************************************************Sub Main()
Dim i As Integer
EmailAddress(0) = "[email protected]"EmailAddress(1) = "[email protected]"EmailAddress(2) = ""EmailAddress(3) = ""
69
70
UseEmail(0) = True
’Set the relays that identify the particular relays we useRelayO2(0) = 1RelayO2(1) = 3RelayO2(2) = 7RelayInert(0) = 2RelayInert(1) = 4RelayInert(2) = 6RelayEffluent(0) = 8RelayEffluent(1) = 9RelayEffluent(2) = 10
’turn off all relays just so we are sure of its stateModuleAllRelayOff vbNullString
’set up the experiment with basic infoSet exp = DLECExperimentConstructor(3)
Set fMainForm = New frmMain
LogToFile = TrueAllReactorSame = True
’kludgesFor i = 0 To exp.NumberReactors - 1
With exp.Reactor(i)’Set Communication parametersSet .MSCommObj = frmMain.SpecCommDevice(i).MSCommObj.CommPort = 4 + i.MSCommObj.Settings = "9600,N,8,1"If .MSCommObj.PortOpen Then .MSCommObj.PortOpen = False
End WithNext i’spec 1 has a slight change in settingsexp.Reactor(0).MSCommObj.Settings = "19200,N,8,1"
RKHFAKESAMPLE = FalsefrmMain.mnuSim.Checked = RKHFAKESAMPLE
fMainForm.Show
End Sub
’*******************************************Public Function DLECExperimentConstructor(ByVal NumReactors As Integer)
As DLECExperiment
71
’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 elementDim Output As New DLECExperimentSet Output = New DLECExperimentDim i As Integer
’set up this experimentWith 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 reactorFor 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 WithNext i
End With
Output.Reactor(0).InUse = True
Set DLECExperimentConstructor = Output
72
End Function
’************************************************Public Function DLECChemostatConstructor(ByRef ParentObj As DLECExperiment)
As DLECChemostatDim newMSCommObj As MSCommDim Output As DLECChemostatSet Output = New DLECChemostat’Set Output.MSCommObj = frmMain.SpecCommDevice(0)Output.Ready = FalseSet Output.Parent = ParentObjSet DLECChemostatConstructor = OutputEnd Function
73
B.2 Code for DLECEmailModule.bas
Attribute VB_Name = "EmailModule"Option Explicit’ Sends an email to the appropriate person(s).’ SendTo = List of email addresses separated by a semicolon. Example:’ [email protected]; [email protected]; [email protected]’ Subject = Text that summarizes what the email is about’ EmailText = Body of text that is the email’ AttachmentPath = Directory in which the attachment resides’ Attachment = 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 IntegerDim strSendTo As StringDim intEnd As IntegerDim i As Integer
If frmMain.MAPISession.SessionID = 0 ThenfrmMain.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 consistencyFor i = 1 To Len(SendTo)
If Mid$(SendTo, i, 1) <> " " ThenstrSendTo = strSendTo & Mid$(SendTo, i, 1)
End IfNext i
SendTo = strSendToIf Right$(SendTo, 1) <> ";" Then
SendTo = SendTo & ";"End If
74
’Format each recipient, each are separated by a semi-colon, like this:’ [email protected];[email protected]; [email protected];intEnd = InStr(1, SendTo, ";").RecipAddress = Mid$(SendTo, 1, intEnd - 1).ResolveName
intStart = intEnd + 1Do
intEnd = InStr(intStart, SendTo, ";")If intEnd = 0 Then
Exit DoElse
.RecipIndex = .RecipIndex + 1
.RecipAddress = Mid$(SendTo, intStart, intEnd - intStart)
.ResolveNameEnd IfintStart = intEnd + 1
Loop
.MsgSubject = Subject
.MsgNoteText = EmailTextIf Left$(Attachment, 1) = "¨ Then
Attachment = Mid$(Attachment, 2, Len(Attachment))End If
If Attachment <> "" ThenIf Right$(AttachmentPath, 1) = "¨ Then
.AttachmentPathName = AttachmentPath & AttachmentElse
.AttachmentPathName = AttachmentPath & "¨ & AttachmentEnd If.AttachmentName = Attachment
End If.Send False
End With
End Sub
Public Sub Email_Report()Dim SendTo As StringDim Subject As StringDim EmailText As StringDim i As Integer
’put together list of addressees
75
SendTo = ""For i = 0 To 6
If UseEmail(i) Then SendTo = EmailAddress(i) + "; "Next i
’put together subject lineSubject = Format(Now, "Medium Time")
’put together email bodyEmailText = ""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 + "O2" + vbCrIf .gas = nitrogen Then EmailText = EmailText + "N2" + vbCrIf .gas = nogas Then EmailText = EmailText + "NONE" + vbCr
End IfEnd With
Next i
’sendSendEmailMAPI SendTo, Subject, EmailText
End Sub
76
B.3 Code for DLECPhoneCallModule.bas
Attribute VB_Name = "PhoneCallModule"Option ExplicitPublic Function Callthis(num As String)
Dim Output, dummy, FromModem$Modem.CommPort = 1Modem.Settings = "9600,N,8,1"Modem.PortOpen = TrueModem.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 anseredExit Do
End IfEnd 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
77
B.4 Code for DLECLogFileModule.bas
Attribute VB_Name = "LogFileModule"Option ExplicitDim hLogFile As Integer ’ Handle of open log file.
Public Sub OpenLogSub()Dim replace, temp As String, Ret As IntegerOn Error Resume Next
Dim dlgOpenLog As CommonDialogSet dlgOpenLog = frmMain.OpenLog
dlgOpenLog.Flags = cdlOFNHideReadOnly Or cdlOFNExplorerdlgOpenLog.CancelError = True
’ Get the log filename from the user.dlgOpenLog.DialogTitle = "Open Data Log File"dlgOpenLog.Filter = "Log Files (*.TXT)|*.txt|All Files (*.*)|*.*"
DodlgOpenLog.FileName = ""dlgOpenLog.ShowOpenIf Err = cdlCancel Then Exit Subtemp = dlgOpenLog.FileName
’ If the file already exists, ask if the user wants to’overwrite the file or add to it.Ret = Len(Dir$(temp))If Err Then
MsgBox Error$, 48Exit Sub
End IfIf Ret Then
replace = MsgBox("Replace existing file - " + temp + "?", 35)Else
replace = 0End If
Loop While replace = 2
’ User clicked the Yes button, so delete the file.If replace = 6 Then
Kill tempIf Err Then
MsgBox Error$, 48Exit Sub
78
End IfEnd If
’ Open the log file.hLogFile = FreeFileOpen temp For Binary Access Write As hLogFileIf Err Then
MsgBox Error$, 48Close hLogFilehLogFile = 0Exit 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 hLogFilehLogFile = 0
End Sub
’ This procedure adds data to the Term control’s Text property.’ It also filters control characters, such as BACKSPACE,’ carriage return, and line feeds, and writes data to’ an open log file.’ BACKSPACE characters delete the character to the left,’ either in the Text property, or the passed string.’ Line 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 = 16000Dim 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
79
’ 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 ThenTerm.SelStart = TermSize - 1Term.SelLength = 1Data = Mid$(Data, i + 1)
ElseData = Left$(Data, i - 2) & Mid$(Data, i + 1)
End IfEnd 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 = 1Do
i = InStr(i, Data, Chr$(13))If i Then
Data = Left$(Data, i) & Chr$(10) & Mid$(Data, i + 1)i = i + 1
End IfLoop While i
’ Add the filtered data to the SelText property.Term.SelText = Data
’ Log data to file if requested.If hLogFile Then
i = 2Do
Err = 0Put hLogFile, , DataIf Err Then
i = MsgBox(Error$, 21)If i = 2 Then
80
CloseLogEnd If
End IfLoop While i <> 2
End IfTerm.SelStart = Len(Term.Text)
End Sub
APPENDIX CDENITRIFIER DIAUXIC GROWTH MODEL SOURCE CODE
C.1 Code for Run061703.m
Run the model with parameters from 06-17-03load 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 measurementsInterpExpEnzyme = interp1(e.times,e.fe n,data.e n times);InterpExpBiomass = interp1(e.times,e.fXb,data.times);
%calculate the sum of squares error between the simulation and the datassqXb = sum( (data.fXb - InterpExpBiomass).^2 );sizeXb = size(data.fXb,1);varevXb = 5E-5; %experimentally measured average variance
%sum of squares error for nitrate reductase levelssqe n = sum( (data.fe n - InterpExpEnzyme).^2 );sizee n = size(data.fe n,1);vareve n = 4.3E-19; %experimentally measured average variance
%output a weighted sum of the twobiomasserror = ssqXb/(sizeXb*varevXb);enzymeerror = ssqe n/(sizee n*vareve n);out = biomasserror + enzymeerror;
figure;PlotModel(e);PlotData(data);
81
82
C.2 Code for RunModel.m
function expout = RunModel(m, e)%RUNMODEL(model,experiment), returns an experiment with simulated data
%number of phasesnumphases = size(e.PhaseLength,2);
%initial conditionsstate = [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 valuesaccumY = state’;accumT = 0;
for phase = 1:numphases
%make note in the experiment what phase we are integratinge.phase = phase;%set aeratione.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 19DilutionFactor = e.PhaseDilutionRatio(phase);%conc. of nitrate in the solution used to diluteFeedSn = e.PhaseSolutionSn(phase);%conc. of carbon in the solution used to diluteFeedSs = e.PhaseSolutionSs(phase);%no biomass in feedstate(1) = state(1)/(1+DilutionFactor);%Substrate is addedstate(2) = (state(2)+FeedSs*DilutionFactor)/(1+DilutionFactor);%Nitrate is addedstate(3) = (state(3)+FeedSn*DilutionFactor)/(1+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.
83
[T,Y,TE,YE,IE]=ode15s(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 duplicationY(1,:) = [];T(1) = [];
%concatenate the second segment with the firstaccumT = [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 durationif accumT(end) < sum(e.PhaseLength)
%integrate out to make up the differencephaseduration = sum(e.PhaseLength) - accumT(end);storeoptions = e.ODEoptions;e.ODEoptions.Events = [];[T,Y] = ode15s(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 duplicationY(1,:) = [];T(1) = [];
%concatenate the second segment with the firstaccumT = [accumT;T+accumT(end)];accumY = [accumY;Y];clear T Y;
end
%remove the temporary phase variable from ee = rmfield(e,’phase’);
%Seperate the data columns for readabilitye.times = accumT;e.fXb = accumY(:,1);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;
85
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 DefinitionsXb = y(1);Ss = y(2);Sn = y(3);e n = y(4);sni = y(5);
%Maximum values for e n and snisni max = m.Vsni / m.mumax an - 1/m.Yn an;e n max = m.aNO / (m.bNO + m.mumax an - m.b) * (1 + m.K1*sni max) / ...
(m.K2 + m.K1*sni max);
%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;
elserox = m.mumax ox * Ss / (m.Ks ox + Ss) * e.So / (m.Koh + e.So);if sni max == 0
ranox = 0;else
ranox = m.mumax an * (e n/e n max) * (sni/sni max) * Ss / ...(m.Ks an + Ss);
endrsni = 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 * (1 + m.K1*sni ) / (m.K2 + m.K1*sni) * Ss / ...
(m.Ks an + Ss);end
%ODEsdxbdt = (rox+ranox-m.b-e.D) * Xb;
86
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;
elsede ndt = reno - (m.bNO + e.D + dxbdt/Xb)*e n;dsnidt = rsni -(ranox/m.Yn an) - (e.D + m.b + dxbdt/Xb)*sni;
end%return outputsdy = [dxbdt;...
dssdt;...dsndt;...de ndt;...dsnidt;];
87
C.4 Code for FitAllData.m
%Minimize the value of Fit TargetFunction by changing the model parameters%Initial guesses for parametersdisp(’FitAllData’)% x0.mumax ox = 0.5690; %aerobic growth% x0.mumax an = 0.1631; %anoxic growth% x0.Ks an = 0.3417; %switch for lack of energy/carbon% x0.Vsni = 0.0217; %maximum NO3 uptake;% x0.Knoi = 5.6055e-004; %g/L external nitrate promotes uptake% x0.Koi = 3.3068e-004; %O2 inhibits nitrate uptake% x0.aNO = 2.4536e-008; %maximum enzyme production rate% x0.K1 = 9.8580e+004;% x0.K2 = 1.9597e+004; %controls lag length% x0.bNO = 0.4; %nitrate reductase decay rate
%START OPTIMIZTING FROM THE LAST GOOD POINTload mfitASA2;disp(’initial model’)mfit.mumax ox = 0.56;mfit.mumax an = 0.17;disp(mfit)x0.array = [mfit.aNO
mfit.K2%mfit.mumax ox%mfit.mumax anmfit.Vsnimfit.K1mfit.Knoimfit.Koimfit.bNO];
[fvalinit, cost flag] = fAllError(x0.array);
%Set up constraints%All variables must be positivelb = [1E-12
1E3%0.1%0.10.00011E31E-51E-50];
ub = [1E-7
88
1E10%0.5%0.521E101E-11E-110];
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’,x0.array, lb, ub, xtype)%**************************************************************************
t = etime(clock,t);
mfit.aNO=xfinal(1); %maximum enzyme production ratemfit.K2=xfinal(2); %controls lag lengthmfit.Vsni=xfinal(3); %maximum NO3 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 xfinal xfinal;
APPENDIX DEXTENDED 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(:,1) kops(:,2:9)/2 kops(:,2:9)/2 kops(:,10:24)];
%load deckops;%load decjanflatkops;
%**************************************************************************%cut down to 1 daykops = kops(1:168,:);runASM = false;useode23s = true;plotreactors = [4];%**************************************************************************
if runASMload XssASM;
else% load Xss;
load XssMonthEnd;
%double xinit for the second trainxinit = [xinit xinit];
end
disp(sprintf(’Run:\t\tday %2.0f to day %2.0f’,kops(1,1)/24,kops(end,1)/24))
et = clock;[t, allX, rctr, SRT] = fKanapahaSim(xinit, kops, runASM,useode23s, [], []);et = etime(clock,et);
disp(sprintf(’Simulated Time:\t%0.1f hr’,kops(end,1)))
89
90
disp(sprintf(’Elapsed Time:\t%0.1f s’,et))disp(sprintf(’Sim rate:\t%0.1f hrs/s’,kops(end,1)/et))
save testksimoutput t allX rctr SRT;
for i = plotreactorsfigure(i);fPlotTank(rctr(i));
end
% figure(6)% fPlotKOp(kops);
figure(7)fPlotComp(rctr,’So’);for i = 1:5
[m, o] = fKanapahaModelOpsSetup(runASM);subplot(5,1,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));
%**************************************************************************%Outputdisp(sprintf(’final SRT:\t%0.1f days’,SRT(end)))
91
D.2 Code for RunKEKF.m
%find the times for which there are enzyme measurementsdisp(sprintf(’\n********************************\nFile:\t\tRunKEKF’))clear%**************************************************************************%simulation settingssimdata = false; %use simulated plant data, rather than real datarunASM1 = false;estparams = true; %estimate parameters as wellhourstosim = 500; %numbers of hours of data to work onplotreactors= [4]; %number of reactors to plot at the end%measurement variancemvar = [
20; %aerobic 3 nitrate0.6;]; %aerobic 3 ammonia
%**************************************************************************
%nsv is number of state variables plus number of estimated parametersif estparams
nsv = 19;else
nsv = 15;endreactorindexNW = 46:60;reactorindexSE = 136:150;
%load plant operating conditionsload decjankops2
%TEMP duplicate these conditions for the other train%kops = [kops(:,1) kops(:,2:9)/2 kops(:,2:9)/2 kops(:,10:24)];
if runASM1load XssASM;
else% load Xss;
load XssMonthEnd;%xinit(4*15+10) = 0.2; %new initial value for Snh%double xinit so we’ll have initial conditions for the other trainxinit = [xinit xinit];
end
if simdatadisp(sprintf(’Data:\t\tSimulating Data’))disp(sprintf(’Run:\t\tday %2.0f to day %2.0f’, ...
92
kops(1,1)/24,kops(hourstosim,1)/24))[t, allX, rctr, SRT] = fKanapahaSim(xinit, ...
kops(1:hourstosim,:), ...runASM1, ...true, ...[], ...[]);
t(1) = [];allX(1,:) = [];%allX is all 75 state variables on each row, one row per hour%t is time vector corresponding to allX%rctr is each reactor broken down into structs%SRT is the SRT for each time
%filter subset%only use as data points that fall on an hour markersubset = find((mod(t,1)==0)&(t<=hourstosim));ts = t(subset);allXs = allX(subset,:);
z = [ts allXs(:,reactorindexNW(9:10))];
%add in what we measure:noise = repmat(mvar.’,size(allXs,1),1) .* randn(size(allXs,1),2);z(:,2:3) = z(:,2:3) + noise;
%eliminate zerosz(find(z(:,2)<0),2)=0;z(find(z(:,3)<0),3)=0;
elsedisp(sprintf(’Data:\t\tDec 15 - Jan 12’))
% load ProbeData;
load zekf;
%filter subset%only use as data points that before the cutoffsubset = find(z(:,1)<=hourstosim);z=z(subset,:);
% allX = zeros(hourstosim,75);% t = 1:hourstosim;end
%now t and allX should correspond to the available measurements
%if we are doing parameter estimation as well, then augment state with
93
%initial guesses for the parametersstate = xinit;
%set initial state estimatexhat0 = state;%initialize filter parameters (process variances)%Process covariance determined via SWAG methodP0 = [
5.1; %Si1; %Ss200; %Xi400; %Xs400; %Xbh10; %Xba145; %Xp10; %So10; %Sno7; %Snh0.8; %Snd10; %Xnd1; %Salk1; %Snoi1E-11; %En
];%if we’re doing parameter estimation, augment the process covar matrix% if estparams% if runASM1% else% P0 = [P0;% 1E5; %K1% 1E4; %K2% 1E-29; %aN% 1E-12]; %ben% end% endif estparams
if runASM1else
P0 = [P0;1E6; %K11E5; %K21E-35; %aN1E-13]; %ben
endendP0 = diag(P0);
94
%measurement std devsmvar = diag(mvar);
%**************************************************************************%filter datadisp(sprintf(’Filtering days:\t%0.0f to %0.0f ...’, ...
min([z(1,1),kops(1,1)])/24,...z(end,1)/24))
et = clock;
[tout xhatout allX Pout] = fEKF(z, ...xhat0, ...P0, ...kops, ...mvar, ...runASM1, ...estparams);
et = etime(clock,et);
disp(sprintf(’Modeled Time:\t%0.1f hr’,tout(end)))disp(sprintf(’Elapsed Time:\t%0.1f s’,et))disp(sprintf(’Sim rate:\t%0.1f hrs/s’,tout(end)/et))%**************************************************************************
if simdatasave KEKFResult
elsesave KEKFResult
end
%I moved all of the plotting stuff to a script so I could easily plot%stored data by loading it and running this scriptPlotKEKFData
95
D.3 Code for fKanapahaSim.m
function [t, allX, rctr, SRT] = ...fKanapahaSim(xinit, kops, runASM, useode23s, pop, peASM1m)
%simulate Kanapaha using fixed parameters using either eASM1m or ASM1%inputs:
[m, o] = fKanapahaModelOpsSetup(runASM);
%times of operating point changes [hr]tinput = kops(:,1);%aerobic pump power, for each pumphp = kops(:,2:5);%waste flowrate [L/hr]Fw = kops(:,6);%return sludge rate [L/hr]Fr = kops(:,7);%ML recycle rate [L/hr]Fm = kops(:,8);%feed flowrate [L/hr]F = kops(:,9);influent = kops(:,10:24);
%F feed flowrate%Fw waste rate%Fr waste recycle%Fm ML recycle%hp horsepower to pumps in aerobic basin (1 through 4)%influent strength%xinit initial conditions for all state variables%all of these are in row form. If passed array values each row represents%a different set of operating conditions.%tinput is either a column of times representing operating condition%changes or a single value representing a duration to simulate at the%operating conditions.%xinit is the single initial condition for tinput(1)
%optional parameters%pop is operating parameters. pop(1) is abrm, pop(2) is abkm%peASM1 are eASM1m model parameters%peASM1(1) is K1, peASM1(2) is K2, peASM1(3) is aN, peASM1(4) is ben,%peASM1(5) is Vsnoi
%notation for variables%an? anoxic basin in train ?%ab#? aerobic basin # in train ?
96
%e.g. anbb is anoxic basin in train b
%if we are changing any parameters from defaultsif length(pop)
o.abkm1 = pop(1) * 0.007983036373; %kla slope for pump powero.abkm2 = pop(2) * 0.007983036373; %kla slope for pump powero.abkm3 = pop(1) * 0.007983036373; %kla slope for pump powero.abkm4 = pop(3) * 0.007983036373; %kla slope for pump powero.abrzero = pop(4);
endif length(peASM1m)
m.K1 = peASM1m(1); %mg biomass COD/mg nitrate COD == 7E4 gdw/mgNO3m.K2 = peASM1m(2);%katals/(mg biomassm.aN = peASM1m(3);m.ben = peASM1m(4);m.Vsnoi = peASM1m(5); %mg NO3 COD as N / (biomass COD * hr)disp(m)
end
%tdelta is the time steps to integrate over.if length(tinput) == 1
%use it as a single duration at the same setpointtdelta = tinput;
else%tdelta = diff(tinput);%ASSUME EACH TIME POINT IS 1 HOUR APART! BE AWARE!tdelta = ones(length(tinput),1);
end
options = odeset(’InitialStep’,0.1);
%initial conditions to change between iterations (must be column vector)xinitloop = xinit.’;
t = 0;allX = xinit;
for count=1:length(tdelta)%first, extract the influent composition corresponding to this time%step and format it as a column vectoro.influent = influent(count,:).’;
%**************************************************************************%Virtual Aerobic Reactor Recycle ratiosr1a = o.abrzero + o.abrm*mean(hp(count,1:2));
97
r2a = o.abrzero + o.abrm*mean(hp(count,2:3));r3a = o.abrzero + o.abrm*mean(hp(count,3:4));
o.ab1aKlaf = o.abkzero+o.abkm1*hp(count,1);o.ab2aKlaf = o.abkzero+o.abkm2*hp(count,2);o.ab3aKlaf = o.abkzero+o.abkm3*hp(count,3);o.ab4aKlaf = o.abkzero+o.abkm4*hp(count,4);
%**************************************************************************
o.F = F(count);o.Fr = Fr(count);o.Fm = Fm(count);
%Clarifier performanceo.lambda = (o.F + o.Fr)/(o.Fr + Fw(count));
%Virtual Aerobic Reactor Recycle ratioso.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, ...
[0 tdelta(count)], ...xinitloop, ...[], ...m, ...o);
else%integrate using rk4[ttemp,ytemp]=rkhrk4A(@fKanapahadxdt,[0:ssize:tdelta(count)],xinitloop,m,o);
end
%grab next initial conditionsxinitloop = ytemp(end,:).’;
%final output is [time, allX, rctr, SRT]t = [t; ttemp(2:end)+t(end)];allX = [allX; ytemp(2:end,:)];
end
rctr = fParseAllX(t,allX);
%set up index variables%if X is your state, then X(ab2b) is the state variables in Aerobic Basin%2, train B
98
%NOTE THAT THIS IS DUPLICATED FROM FUNCTION ACCUManba = 1:15;ab1a = 16:30;ab2a = 31:45;ab3a = 46:60;ab4a = 61:75;%index of particulates (Xi)Xndx = [3:7,12];
%Calculate SRT (hr) at all points in time%grab the Xndx subset of each a???SRT=sum([allX(:,anba(Xndx)’)*o.Vanba ...
allX(:,ab1a(Xndx)’)*o.AerobicTankSize/4 ...allX(:,ab2a(Xndx)’)*o.AerobicTankSize/4 ...allX(:,ab3a(Xndx)’)*o.AerobicTankSize/4 ...allX(:,ab4a(Xndx)’)*o.AerobicTankSize/4],2) ./ ...sum(Fw(count)*o.lambda*allX(:,ab4a(Xndx)’),2);
%convert to daysSRT = SRT / 24;
%**************************************************************************%**************************************************************************%**************************************************************************function [times, yout] = rkhrk4(FunFcn, times, y0,m,o)% Initialization%if given only start/stop times, fill in a default stepsizeif length(times) == 2
times = [times(1):0.1*(times(2)-times(1)):times(2)];end
times = times’;
%t = t0;y = y0(:);yout = y.’;
% The main loopfor i = 1:(length(times)-1)
t = times(i);h = times(i+1)-times(i);%if t + h > tfinal, h = tfinal - t; end% Compute the slopess1 = feval(FunFcn, t, y,m,o); s1 = s1(:);s2 = feval(FunFcn, t + h/2, y + h*s1/2,m,o); s2=s2(:);s3 = feval(FunFcn, t + h/2, y + h*s2/2,m,o); s3=s3(:);s4 = feval(FunFcn, t + h, y + h*s3,m,o); s4=s4(:);t = t + h;
99
y = y + h*(s1 + 2*s2 + 2*s3 +s4)/6;y(find(y<0))=0;yout = [yout; y.’];
end;
%**************************************************************************%**************************************************************************%**************************************************************************function [times, yout] = rkheuler(FunFcn, times, y0,m,o)%this is SO MUCH slower that I can’t use it. It guarentees good numerical%behavior. But the problem is stiff, so the step sizes get too small. I%would need a more sophisticaed adaptive stepsize method than this.
% Initialization%if given only start/stop times, fill in a default stepsizeif length(times) == 2
times = [times(1):0.05*(times(2)-times(1)):times(2)];end
times = times’;
y = y0(:);yout = y.’;
% The main loop% The main loopfor i = 1:(length(times)-1)
t = times(i);h = times(i+1)-times(i);
% Compute the slopess1 = feval(FunFcn, t, y,m,o); s1 = s1(:);
t = t + h;y = y + h*s1;yout = [yout; y.’];
end;
%**************************************************************************%**************************************************************************%**************************************************************************function [tout, yout] = rkheulerA(FunFcn, times, y0, m,o)%this is SO MUCH slower that I can’t use it. It guarentees good numerical%behavior. But the problem is stiff, so the step sizes get too small. I%would need a more sophisticaed adaptive stepsize method than this.
100
% Initializationt = times(1);tfinal = times(end);h = 0; %value gets replaced by maxstepsize before use
y = y0(:);tout = t;yout = y.’;
% The main loopwhile (t < tfinal)
if t + h > tfinal, h = tfinal - t; end
% Compute the slopess1 = feval(FunFcn, t, y,m,o); s1 = s1(:);
%compute the maximum stepsize that is safe to take%don’t divide by zeronotzero = find(s1~=0);%don’t use zero componentsnotzero2 = find(y(notzero)>0);
maxstepsize = min(abs(y(notzero(notzero2))./s1(notzero(notzero2))));
h = 0.1*maxstepsize;
t = t + h;y = y + h*s1;
tout = [tout; t];yout = [yout; y.’];
end;
%**************************************************************************%**************************************************************************%**************************************************************************function [times, yout] = rkhrk4A(FunFcn, times, y0,m,o)% Initialization%if given only start/stop times, fill in a default stepsizeif length(times) == 2
times = [times(1):0.1*(times(2)-times(1)):times(2)];end
times = times’;
t = 0;
101
tfinal = times(end);hdefault = times(2)-times(1);h = hdefault;y = y0(:);yout = y.’;
% The main loopwhile t < tfinal
%make sure we don’t step past the endif t + h > tfinal, h = tfinal - t; end
h = hdefault;unsucessful = true;
%loop until we integrate without negative state variables%reduce stepsize if they DO go negative and repeatwhile unsucessful
% Compute the slopess1 = feval(FunFcn, t, y,m,o); s1 = s1(:);s2 = feval(FunFcn, t + h/2, y + h*s1/2,m,o); s2=s2(:);s3 = feval(FunFcn, t + h/2, y + h*s2/2,m,o); s3=s3(:);s4 = feval(FunFcn, t + h, y + h*s3,m,o); s4=s4(:);t = t + h;ytest = y + h*(s1 + 2*s2 + 2*s3 +s4)/6;%make sure than none of the state variables (1:75) went negativeif any(ytest(1:75) < 0)
%reduce the stepsize according to ASM1asm1only = y(1:75);asm1onlyrates = s1(1:75);%we need only those rates that are positivesubset = find(asm1onlyrates~=0);%we don’t need to worry about those states that are zero, but%have positive ratesasm1only = asm1only(subset);asm1onlyrates = asm1onlyrates(subset);subset = find(asm1only==0);%look at each zero state and see if the corresponding rate<0removeme = find(asm1onlyrates(subset)>=0);asm1only(subset(removeme)) = [];asm1onlyrates(subset(removeme)) = [];
h = min(abs(asm1only./asm1onlyrates));else
%we have integrated sucessfully, store this datay = ytest;unsucessful = false;
end
102
end
t = t + h;%y(find(y<0))=0;yout = [yout; y.’];
end;
103
D.4 Code for fKanapahaModelOpsSetup.m
function [m, o] = fKanapahaModelOpsSetup(runASM)%return model parameters and operating parameters to be constant among all%simulations
%**************************************************************************%Tunable Process Parameters%**************************************************************************%**************************************************************************%Virtual Aerobic Reactor Recycle ratios%reflects back-mixing in the real aeration tank%a linear function of the aeration motor power%abrzero is the recycle at zero pump powero.abrzero = 1.5;o.abrm = 0.00; %recycle slope for pump power (max = 200*abrm)%**************************************************************************%Mass Transport is zero for all components but oxygen%These values will come from the power to the aerator motors%assume linear relationship between power to motor and Kla%abkzero is the kla at zero pump power%The first number (3.5) is the manufacturer measure lb O2 /hp/hr, then a%conversion factor to get kla (note conversion includes rctr volume)o.abkzero = 0;o.abkm1 = 1.7 * 0.007983036373*2; %kla slope for pump powero.abkm2 = 2.2 * 0.007983036373*2; %kla slope for pump powero.abkm3 = 1.7 * 0.007983036373*2; %kla slope for pump powero.abkm4 = 1.7 * 0.007983036373*2; %kla slope for pump power% o.abkm = 2.0 * 0.007983036373; %value based on Bridge Report numbers
o.Sosat = 8.8; %mg/L
%Model Parameters variable%Bridge Report Valuesm.Koh = 0.1; %mg/L as O2m.ng = 0.85; %dimensionlessm.nh = 0.4; %dimensionlessm.kh = 0.125; %mg COD/(mg biomass COD h)m.Knh = 1; %mg/L as Nm.Koa = 0.4; %mg/L as O2m.Kx = 0.3; %.03%mg COD/mg biomass CODm.bh = 0.026;m.ba = 0.00833;m.ka = 0.0033; %L/(mg biomass COD h)m.Kno = 0.5; %mg/L as Nm.Ks = 20; %mg/L as COD
104
m.muh = 0.25; %^-hm.mua = 0.033; %^-hm.runASM = runASM;%Parameters for Estimation (eventually)m.K1 = 1.2740e+05; %mg biomass COD / mg nitrate COD == 7E4 gdw/mgNO3;m.K2 = 1.86E4;m.aN = 1.0035e-12; %katals/(mg biomassm.ben = 0.06;m.Vsnoi = 0.06; %mg NO3 COD as N / (biomass COD * hr)%**************************************************************************%parameters with strong T dependance%Changes from bridge report%m.mua = 0.08; %^-h% m.ka = 0.0033; %L/(mg biomass COD h)% m.bh = 0.026;m.muh = 0.3; %^-h
%**************************************************************************%MODIFIED Values% m.Koh = 0.075; %mg/L as O2% % m.Koa = 0.3; %mg/L as O2m.mua = 0.04; %^-hm.ba = 0.004;
%MODIFIED parametersm.K1 = 1.2740e+05; %mg biomass COD / mg nitrate COD == 7E4 gdw/mgNO3;m.K2 = 1.86E4;m.aN = 1.0035e-12; %katals/(mg biomassm.ben = 1E-6;m.Vsnoi = 0.122; %mg NO3 COD as N / (biomass COD * hr)
% reaction rate parameters% Yh = 0.67; %mg biomass COD/mg substrate COD% Ya = 0.24; %mg biomass COD formed/mg N oxidizediNxb = 0.086;%mg N/mg COD in active biomassiNxd = 0.06; %mg N/mg COD in biomass debrisfp = 0.08; %mg debris COD/mg biomass COD
%**************************************************************************%MODIFIED parametersYh = 0.5; %mg biomass COD/mg substrate CODYa = 0.24; %mg biomass COD formed/mg N oxidized
m.Yh = Yh;if runASM
105
%ASM1******************************************************************%STOICHIOMETRY MATRIX NU***********************************************m.nu = [
0, -1/Yh, 0, 0, 1, 0, 0, -(1-Yh)/Yh, 0,-iNxb, 0, 0, -iNxb/14;
0, -1/Yh, 0, 0, 1, 0, 0, 0,-(1-Yh)/(2.86*Yh), -iNxb, 0, 0,(1-Yh)/(14*2.86*Yh)-iNxb/14;
0, 0, 0, 0, 0, 1, 0, -(4.57-Ya)/Ya, 1/Ya,-iNxb-1/Ya, 0, 0, -iNxb/14-1/(7*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****************************************************************%STOICHIOMETRY MATRIXm.nu = [
0, -1/Yh, 0, 0, 1, 0, 0, -(1-Yh)/Yh, 0,-iNxb, 0, 0, -iNxb/14, 0, 0;
0, -1/Yh, 0, 0, 1, 0, 0, 0, 0, -iNxb,0, 0, (1-Yh)/(14*2.86*Yh)-iNxb/14,-(1-Yh)/(2.86*Yh), 0;
0, 0, 0, 0, 0, 1, 0, -(4.57-Ya)/Ya, 1/Ya,-iNxb-1/Ya, 0, 0, -iNxb/14-1/(7*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,
106
0, 0, 0, -1, 0;0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, -1];end
%Operating conditions global variable%Tank Volumeso.AerobicTankSize = 21953000/2; %liters 2.9MG*3785000L/MGo.Vanba = 3330800/2; %liters (0.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;
107
D.5 Code for fKanapahadxdt.m
function dxdt = fKanapahadxdt(t,x,m,o)%computes the instantaneous accumulation for each tank
%accumulation = reaction rates + advection rates + mass transfer rates
%number of state variables per tankns=15;
%set up index variables%if X is your state, then X(ab2b) is the state variables in aerobic basin%2, train banba = 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;
%index of particulates (Xi)Xndx = [3:7,12];
%REACTION RATES************************************************************%reaction rates are easy. transpose(nu)*process ratesanbarxn = fKanapahaReactionRates(x(anba),m);ab1arxn = fKanapahaReactionRates(x(ab1a),m);ab2arxn = fKanapahaReactionRates(x(ab2a),m);ab3arxn = fKanapahaReactionRates(x(ab3a),m);ab4arxn = fKanapahaReactionRates(x(ab4a),m);
anbbrxn = fKanapahaReactionRates(x(anbb),m);ab1brxn = fKanapahaReactionRates(x(ab1b),m);ab2brxn = fKanapahaReactionRates(x(ab2b),m);ab3brxn = fKanapahaReactionRates(x(ab3b),m);ab4brxn = fKanapahaReactionRates(x(ab4b),m);
%the mixed output from both virtual aerobic basin 4 sidesxmixed =((o.Fa+o.Fra)*x(ab4a) + (o.Fb+o.Frb)*x(ab4b)) / ...
(o.Fa+o.Fra+o.Fb+o.Frb);
108
%**************************************************************************%EAST TRAIN (A)************************************************************%**************************************************************************%ANOXIC BASIN A************************************************************%components coming from the clarifier are mixed from both trains%advection term for particulates (settled in clarifier)anbaparticulates = o.Fa/o.Vanba*o.influent + ...
o.Fra/o.Vanba*o.lambda*xmixed + ...o.Fma/o.Vanba*x(ab4a) - ...(o.Fa+o.Fra+o.Fma)/o.Vanba*x(anba);
%advection for dissolved species is the same, but lambda is 1anbaadv = o.Fa/o.Vanba*o.influent + ...
o.Fra/o.Vanba*x(ab4a) + ...o.Fma/o.Vanba*x(ab4a) - ...(o.Fa+o.Fra+o.Fma)/o.Vanba*x(anba);
%overall it’s a combination of particulates and solubles, so copy the%particulates values into the advection termanbaadv(Xndx) = anbaparticulates(Xndx);
%AEROBIC BASIN 1A**********************************************************ab1aadv = (o.Fa+o.Fra+o.Fma)/o.Vae1a*x(anba) + ...
o.Far1a/o.Vae1a*x(ab2a) - ...(o.Fa+o.Fra+o.Fma+o.Far1a)/o.Vae1a*x(ab1a);
%AEROBIC BASIN 2A**********************************************************ab2aadv = (o.Fa+o.Fra+o.Fma+o.Far1a)/o.Vae2a*x(ab1a) + ...
o.Far2a/o.Vae2a*x(ab3a) - ...o.Far1a/o.Vae2a*x(ab2a) - ...(o.Fa+o.Fra+o.Fma+o.Far2a)/o.Vae2a*x(ab2a);
%AEROBIC BASIN 3A**********************************************************ab3aadv = (o.Fa+o.Fra+o.Fma+o.Far2a)/o.Vae3a*x(ab2a) + ...
o.Far3a/o.Vae3a*x(ab4a) - ...o.Far2a/o.Vae3a*x(ab3a) - ...(o.Fa+o.Fra+o.Fma+o.Far3a)/o.Vae3a*x(ab3a);
%AEROBIC BASIN 4A**********************************************************ab4aadv = (o.Fa+o.Fra+o.Fma+o.Far3a)/o.Vae4a*x(ab3a) - ...
o.Far3a/o.Vae4a*x(ab4a) - ...(o.Fa+o.Fra+o.Fma)/o.Vae4a*x(ab4a);
anbamt = zeros(15,1);ab1amt = anbamt;ab2amt = anbamt;ab3amt = anbamt;ab4amt = anbamt;
109
%note here: ab1a is the range for aerobic basin 1, train a%ab1a(8) is the index for So in that basin%x(ab1a(8)) is the value of So in that basinab1amt(8) = o.ab1aKlaf*(o.Sosat-x(ab1a(8)));ab2amt(8) = o.ab2aKlaf*(o.Sosat-x(ab2a(8)));ab3amt(8) = o.ab3aKlaf*(o.Sosat-x(ab3a(8)));ab4amt(8) = o.ab4aKlaf*(o.Sosat-x(ab4a(8)));
%**************************************************************************%WEST TRAIN (B)************************************************************%**************************************************************************%ANOXIC BASIN B************************************************************%components coming from the clarifier are mixed from both trains%advection term for particulates (settled in clarifier)anbbparticulates = o.Fb/o.Vanbb*o.influent + ...
o.Frb/o.Vanbb*o.lambda*xmixed + ...o.Fmb/o.Vanbb*x(ab4b) - ...(o.Fb+o.Frb+o.Fmb)/o.Vanbb*x(anbb);
%advection for dissolved species is the same, but lambda is 1anbbadv = o.Fb/o.Vanbb*o.influent + ...
o.Frb/o.Vanbb*x(ab4b) + ...o.Fmb/o.Vanbb*x(ab4b) - ...(o.Fb+o.Frb+o.Fmb)/o.Vanbb*x(anbb);
%overall it’s a combination of particulates and solubles, so copy the%particulates values into the advection termanbbadv(Xndx) = anbbparticulates(Xndx);
%AEROBIC BASIN 1B**********************************************************ab1badv = (o.Fb+o.Frb+o.Fmb)/o.Vae1b*x(anbb) + ...
o.Far1b/o.Vae1b*x(ab2b) - ...(o.Fb+o.Frb+o.Fmb+o.Far1b)/o.Vae1b*x(ab1b);
%AEROBIC BASIN 2B**********************************************************ab2badv = (o.Fb+o.Frb+o.Fmb+o.Far1b)/o.Vae2b*x(ab1b) + ...
o.Far2b/o.Vae2b*x(ab3b) - ...o.Far1b/o.Vae2b*x(ab2b) - ...(o.Fb+o.Frb+o.Fmb+o.Far2b)/o.Vae2b*x(ab2b);
%AEROBIC BASIN 3B**********************************************************ab3badv = (o.Fb+o.Frb+o.Fmb+o.Far2b)/o.Vae3b*x(ab2b) + ...
o.Far3b/o.Vae3b*x(ab4b) - ...o.Far2b/o.Vae3b*x(ab3b) - ...(o.Fb+o.Frb+o.Fmb+o.Far3b)/o.Vae3b*x(ab3b);
%AEROBIC BASIN 4B**********************************************************ab4badv = (o.Fb+o.Frb+o.Fmb+o.Far3b)/o.Vae4b*x(ab3b) - ...
110
o.Far3b/o.Vae4b*x(ab4b) - ...(o.Fb+o.Frb+o.Fmb)/o.Vae4b*x(ab4b);
anbbmt = zeros(15,1);ab1bmt = anbbmt;ab2bmt = anbbmt;ab3bmt = anbbmt;ab4bmt = anbbmt;
%note here: ab1a is the range for aerobic basin 1, train a%ab1a(8) is the index for So in that basin%x(ab1a(8)) is the value of So in that basinab1bmt(8) = o.ab1bKlaf*(o.Sosat-x(ab1b(8)));ab2bmt(8) = o.ab2bKlaf*(o.Sosat-x(ab2b(8)));ab3bmt(8) = o.ab3bKlaf*(o.Sosat-x(ab3b(8)));ab4bmt(8) = o.ab4bKlaf*(o.Sosat-x(ab4b(8)));
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;];
111
D.6 Code for fParseAllX.m
%turns an allX state variable by time array into reactor structsfunction rctr = fParseAllX(t,allX,prefix)%t is time, allX is all state vars, prefix is text to prefix each label
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;%index of particulates (Xi)Xndx = [3:7,12];
rctr(1).name = [prefix ’Anoxic Basin’];rctr(1).t = t;rctr(1).Si = allX(:,anba(1));rctr(1).Ss = allX(:,anba(2));rctr(1).Xi = allX(:,anba(3));rctr(1).Xs = allX(:,anba(4));rctr(1).Xbh = allX(:,anba(5));rctr(1).Xba = allX(:,anba(6));rctr(1).Xp = allX(:,anba(7));rctr(1).So = allX(:,anba(8));rctr(1).Sno = allX(:,anba(9));rctr(1).Snh = allX(:,anba(10));rctr(1).Snd = allX(:,anba(11));rctr(1).Xnd = allX(:,anba(12));rctr(1).Salk = allX(:,anba(13));rctr(1).Snoi = allX(:,anba(14));rctr(1).En = allX(:,anba(15));rctr(2).name = [prefix ’Aerobic Basin Virtual Reactor 1’];rctr(2).t = t;rctr(2).Si = allX(:,ab1a(1));rctr(2).Ss = allX(:,ab1a(2));rctr(2).Xi = allX(:,ab1a(3));rctr(2).Xs = allX(:,ab1a(4));rctr(2).Xbh = allX(:,ab1a(5));rctr(2).Xba = allX(:,ab1a(6));rctr(2).Xp = allX(:,ab1a(7));rctr(2).So = allX(:,ab1a(8));
112
rctr(2).Sno = allX(:,ab1a(9));rctr(2).Snh = allX(:,ab1a(10));rctr(2).Snd = allX(:,ab1a(11));rctr(2).Xnd = allX(:,ab1a(12));rctr(2).Salk = allX(:,ab1a(13));rctr(2).Snoi = allX(:,ab1a(14));rctr(2).En = allX(:,ab1a(15));rctr(3).name = [prefix ’Aerobic Basin Virtual Reactor 2’];rctr(3).t = t;rctr(3).Si = allX(:,ab2a(1));rctr(3).Ss = allX(:,ab2a(2));rctr(3).Xi = allX(:,ab2a(3));rctr(3).Xs = allX(:,ab2a(4));rctr(3).Xbh = allX(:,ab2a(5));rctr(3).Xba = allX(:,ab2a(6));rctr(3).Xp = allX(:,ab2a(7));rctr(3).So = allX(:,ab2a(8));rctr(3).Sno = allX(:,ab2a(9));rctr(3).Snh = allX(:,ab2a(10));rctr(3).Snd = allX(:,ab2a(11));rctr(3).Xnd = allX(:,ab2a(12));rctr(3).Salk = allX(:,ab2a(13));rctr(3).Snoi = allX(:,ab2a(14));rctr(3).En = allX(:,ab2a(15));rctr(4).name = [prefix ’Aerobic Basin Virtual Reactor 3’];rctr(4).t = t;rctr(4).Si = allX(:,ab3a(1));rctr(4).Ss = allX(:,ab3a(2));rctr(4).Xi = allX(:,ab3a(3));rctr(4).Xs = allX(:,ab3a(4));rctr(4).Xbh = allX(:,ab3a(5));rctr(4).Xba = allX(:,ab3a(6));rctr(4).Xp = allX(:,ab3a(7));rctr(4).So = allX(:,ab3a(8));rctr(4).Sno = allX(:,ab3a(9));rctr(4).Snh = allX(:,ab3a(10));rctr(4).Snd = allX(:,ab3a(11));rctr(4).Xnd = allX(:,ab3a(12));rctr(4).Salk = allX(:,ab3a(13));rctr(4).Snoi = allX(:,ab3a(14));rctr(4).En = allX(:,ab3a(15));rctr(5).name = [prefix ’Aerobic Basin Virtual Reactor 4’];rctr(5).t = t;rctr(5).Si = allX(:,ab4a(1));rctr(5).Ss = allX(:,ab4a(2));rctr(5).Xi = allX(:,ab4a(3));rctr(5).Xs = allX(:,ab4a(4));
113
rctr(5).Xbh = allX(:,ab4a(5));rctr(5).Xba = allX(:,ab4a(6));rctr(5).Xp = allX(:,ab4a(7));rctr(5).So = allX(:,ab4a(8));rctr(5).Sno = allX(:,ab4a(9));rctr(5).Snh = allX(:,ab4a(10));rctr(5).Snd = allX(:,ab4a(11));rctr(5).Xnd = allX(:,ab4a(12));rctr(5).Salk = allX(:,ab4a(13));rctr(5).Snoi = allX(:,ab4a(14));rctr(5).En = allX(:,ab4a(15));
114
D.7 Code for fExtendedKalmanFilter.m
function [tout, xArray, allX, Pout] = fEKF(zdata, ...kx, ...P, ...kops, ...mvar, ...runASM1, ...ADAPTIVE)
%applies a Kalman filter to dataset under constant operating conditions%zdata is a nx3 matrix, each row is time, nitrate, ammonia%kx is the initial state of the entire process%P is the initial covariance matrix%kops is the operating conditions, from the KWRF Strategy Sheet.xls file%mvar is measurement variance%runASM1 is boolean, whether to use ASM1 or eASM1m%ADAPTIVE is boolean, whether to use parameter estimation or not
%toggle debug checksDEBUG = true;
if ADAPTIVE%length of AEKF state vectornsv = 19;%length of KanapahaSim state vectorasv = 154;%single out one reactor to filter. This is the index of that reactors%state variables inside of the KSim staterpindex = [46:60 151:asv];
else%length of EKF state vectornsv = 15;%length of KanapahaSim state vectorasv = 150;%single out one reactor to filter. This is the index of that reactors%state variables inside of the KSim staterpindex = 46:60;
end
%parse kopskops(find(kops(:,1)>zdata(end,1)),:)=[];%times of operating point changes [hr]koptimes = kops(:,1);%aerobic pump power, for each pumphpa = kops(:,2:5); %divide by 2 because kops has total hp for both trainshpb = kops(:,6:9); %divide by 2 because kops has total hp for both trains
115
%waste flowrate [L/hr]Fwa = kops(:,10);%return sludge rate [L/hr]Fra = kops(:,11);%ML recycle rate [L/hr]Fma = kops(:,12);%waste flowrate [L/hr]Fwb = kops(:,13);%return sludge rate [L/hr]Frb = kops(:,14);%ML recycle rate [L/hr]Fmb = kops(:,15);%feed flowrate [L/hr]Fa = kops(:,16)/2;%feed flowrate [L/hr]Fb = kops(:,16)/2;
influent = kops(:,17:31);
%in order to keep synchronized between measurement times and changes in%operating conditions, I will use the variable kopindex to represent where%we are in the kops array, and z?index for the data arrayskopindex = 2;z1index = 1;iout = 2;
H=zeros(2,nsv);H(1,9)=1;H(2,10)=1;
%if there is a data point at time zero, ditch itif(zdata(1,1)==0)
z1index=1;end
%get the model parameters from the setup file.[m, o] = fKanapahaModelOpsSetup(runASM1);%**************************************************************************%Virtual Aerobic Reactor Recycle ratiosr1a = o.abrzero + o.abrm*mean(hpa(kopindex,1:2));r2a = o.abrzero + o.abrm*mean(hpa(kopindex,2:3));r3a = o.abrzero + o.abrm*mean(hpa(kopindex,3:4));
r1b = o.abrzero + o.abrm*mean(hpb(kopindex,1:2));r2b = o.abrzero + o.abrm*mean(hpb(kopindex,2:3));r3b = o.abrzero + o.abrm*mean(hpb(kopindex,3:4));
116
o.influent = influent(kopindex,:).’;
o.ab1aKlaf = o.abkzero+o.abkm1*hpa(kopindex,1);o.ab2aKlaf = o.abkzero+o.abkm2*hpa(kopindex,2);o.ab3aKlaf = o.abkzero+o.abkm3*hpa(kopindex,3);o.ab4aKlaf = o.abkzero+o.abkm4*hpa(kopindex,4);
o.ab1bKlaf = o.abkzero+o.abkm1*hpb(kopindex,1);o.ab2bKlaf = o.abkzero+o.abkm2*hpb(kopindex,2);o.ab3bKlaf = o.abkzero+o.abkm3*hpb(kopindex,3);o.ab4bKlaf = o.abkzero+o.abkm4*hpb(kopindex,4);
%**************************************************************************
o.Fa = Fa(kopindex);o.Fra = Fra(kopindex);o.Fma = Fma(kopindex);
o.Fb = Fb(kopindex);o.Frb = Frb(kopindex);o.Fmb = Fmb(kopindex);
%Clarifier separationo.lambda = ((o.Fa+o.Fb) + (o.Fra+o.Frb))/((o.Fra+o.Frb) + ...
(Fwa(kopindex)+Fwb(kopindex)));
%Virtual Aerobic Reactor Recycle ratioso.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%state vectors must be column vectors for this algorithm%only for my modified model and when estimating parameterskx = [kx.’;
m.K1;m.K2;m.aN;m.ben;];
elsekx = kx.’;
end
117
%I’ve seen this done freqeuntly. Just set the initial error covariance%equal to the process variance. This would be more clear as%Pinitial = pvar.pvar = P;
%allocate memory for outputs for speednumoutput = length(zdata(:,1));xArray = zeros(numoutput,nsv);Pout = zeros(nsv,nsv,numoutput);allX = zeros(numoutput,asv);tout = zeros(numoutput,1);
%Initialize storage arraysPout(:,:,1) = P;xArray(1,:) = kx(rpindex)’;allX(1,:) = kx.’;tout(1) = 0;
%time of last measurementtend = zdata(end,1);t = 0;
if ADAPTIVE && ~runASM1disp(sprintf(’t\tK1\t\tK2\t\taN\t\tben\t\tVsnoi’))disp(sprintf(’%3.1f\t%0.4e\t%0.4e\t%0.4e\t%0.4e\t%0.4e’, ...
t,m.K1,m.K2,m.aN,m.ben,m.Vsnoi))end
%log progress to fileflog = fopen(’fEKFlog.txt’,’w’);%string of values to save to filesavestr = [];saveformat = [];saveheader = [];for i=1:asv
saveformat = [saveformat ’%0.4e\t’];savestr = [savestr ’kx(’ int2str(i) ’), ’];saveheader = [saveheader ’kx(’ int2str(i) ’)\t\t’];
endsavestr = savestr(1:end-2);saveformat = saveformat(1:end-2);
xhat = kx(rpindex);eval([’fprintf(flog,’’t\t\t\t’ saveheader ’\n’’);’])eval([’fprintf(flog,’’%0.3f\t’ saveformat ’\n’’,t,’ savestr ’’’);’])
%Filter Data
118
et = clock;waithandle=waitbar(0,’Filtering in progress’); % Initialize waitbarwhile t <= tend
%**********************************************************************%consider that the data points may not match up to the operating%conditions. If we’ve passed a changeover point then change all of the%operating conditions appropriatelynexttime = zdata(z1index,1);
%integrate superODE forward until we’ve caught up with all of the kop%changeswhile kopindex <= length(koptimes) && koptimes(kopindex) <= nexttime
timestep = koptimes(kopindex) - t;%integrate[ttemp,ytemp] = ode15s(@superODE, ...
[0 timestep/2 timestep], ...[kx;reshape(P,nsv^2,1)], ...[], ...m, ...o, ...pvar, ...ADAPTIVE);
%we’ve now integrated forward to be even with the new kopt = koptimes(kopindex);
%grab the entire state of the processkx = ytemp(end,1:asv)’;
if DEBUG && any(isnan((ytemp(end,:))))disp(sprintf(’**ERROR:**\t\tytemp is NaN in kop loop’))
end
P = reshape(ytemp(end,asv+1:nsv^2+asv),nsv,nsv);
%change the operating conditions%**************************************************************************%Virtual Aerobic Reactor Recycle ratiosr1a = o.abrzero + o.abrm*mean(hpa(kopindex,1:2));r2a = o.abrzero + o.abrm*mean(hpa(kopindex,2:3));r3a = o.abrzero + o.abrm*mean(hpa(kopindex,3:4));
r1b = o.abrzero + o.abrm*mean(hpb(kopindex,1:2));r2b = o.abrzero + o.abrm*mean(hpb(kopindex,2:3));r3b = o.abrzero + o.abrm*mean(hpb(kopindex,3:4));
o.influent = influent(kopindex,:).’;
119
o.ab1aKlaf = o.abkzero+o.abkm1*hpa(kopindex,1);o.ab2aKlaf = o.abkzero+o.abkm2*hpa(kopindex,2);o.ab3aKlaf = o.abkzero+o.abkm3*hpa(kopindex,3);o.ab4aKlaf = o.abkzero+o.abkm4*hpa(kopindex,4);
o.ab1bKlaf = o.abkzero+o.abkm1*hpb(kopindex,1);o.ab2bKlaf = o.abkzero+o.abkm2*hpb(kopindex,2);o.ab3bKlaf = o.abkzero+o.abkm3*hpb(kopindex,3);o.ab4bKlaf = o.abkzero+o.abkm4*hpb(kopindex,4);
%**************************************************************************
o.Fa = Fa(kopindex);o.Fra = Fra(kopindex);o.Fma = Fma(kopindex);
o.Fb = Fb(kopindex);o.Frb = Frb(kopindex);o.Fmb = Fmb(kopindex);
%Clarifier performanceo.lambda = ((o.Fa+o.Fb) + (o.Fra+o.Frb))/((o.Fra+o.Frb) + ...
(Fwa(kopindex)+Fwb(kopindex)));
%Virtual Aerobic Reactor Recycle ratioso.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
%now we have a measurement to deal withz = zdata(z1index,2:3).’;z1index = z1index + 1;if z1index > length(zdata(:,1))
break;end
timestep = nexttime - t;
120
waitbar(nexttime/tend, ...waithandle, ...sprintf(’Filtering in progress\ntime: %f / %0.1f hr\nElapsed Time: %0.1f min (~%0.0f min remain)’,...nexttime, ...tend, ...etime(clock,et)/60, ...etime(clock,et)/60*(tend/nexttime-1)));
%simultaneously integrate xhat and P forward to timestep%vector structure is below:% [all reactor states;% all parameters;% unrolled P matrix;]%this is in case kop and measurement coincide,%we will have integrated alreadyif timestep > 0
[ttemp,ytemp] = ode15s(@superODE, ...[0 timestep/2 timestep], ...[kx;reshape(P,nsv^2,1)], ...[], ...m, ...o, ...pvar, ...ADAPTIVE);
end%Optional Integrators% [ttemp,ytemp] = rkheuler(@superODE, ...% [0 timestep],[kx;reshape(P,nsv^2,1)],m,o,pvar);% [ttemp,ytemp] = rkheulerA(@superODE, ...% [0 timestep],[kx;reshape(P,nsv^2,1)],m,o,pvar);% [ttemp,ytemp] = rkhrk4A(@superODE, ...% [0 timestep],[kx;reshape(P,nsv^2,1)],m,o,pvar);% [ttemp,ytemp] = rkhrk4(@superODE, ...% [0 timestep],[kx;reshape(P,nsv^2,1)],m,o,pvar);
%we have just integrated up through the current measurementt = nexttime;%grab the entire state of the processkx = ytemp(end,1:asv)’;%grab the filtered reactor statexhat = kx(rpindex);
P = reshape(ytemp(end,asv+1:nsv^2+asv),nsv,nsv);
%correct for numerical problems
121
tmp=find(diag(P)<0 & diag(P)>(-1e-15));for k = tmp, P(k,k) = 0; end;
%Now compute xhatplus, out a posteriori state estimate.Minv = inv(H*P*H.’+mvar);K = P*H.’*Minv;
if DEBUG && any(isnan(xhat))disp(sprintf(’**ERROR:**\t\txhat is NaN’))
endif DEBUG && any(isnan(xhat + K*(z - H*xhat)))
disp(sprintf(’**ERROR:**\txhat will be NaN’))end
%KALMAN FILTER MAGIC HAPPENS HERExhat = xhat + K*(z - H*xhat);
if DEBUG, xhat(find(xhat<0))=0; end;
eval([’fprintf(flog,’’%0.3f\t’ saveformat ’\n’’,t,’ savestr ’’’);’])
%correct for numerical problemstmp=find(diag(P)<0 & diag(P)>(-1e-15));for k = tmp, P(k,k) = 0; end;
if DEBUG && any(any(diag(P)<0))disp(sprintf(’**ERROR:**\t\tPminus NEGATIVE’))
end
%PplusP = ( eye(nsv) - K*H )*P;
%correct for numerical problemstmp=find(diag(P)<0 & diag(P)>(-1e-15));for k = tmp, P(k,k) = 0; end;
if DEBUG && any(any(P)<0)disp(sprintf(’**ERROR:**\t\tPPlus NEGATIVE’))
end
%reconstitute the total process state using the new a posteriori xhatkx(rpindex(1:15)) = xhat(1:15);if ADAPTIVE && ~runASM1, kx(end-3:end) = xhat(16:nsv); end;
if DEBUG && ADAPTIVE && any(kx(end-4:end)==0)%can’t allow zero parameters for enzyme kineticsif kx(end-1) == 0 kx(end-1) = 1e-15; end
122
disp(sprintf(’**ERROR:**\tbad parameter value after xhatplus calc’))tzK
end
if ADAPTIVE && ~runASM1%now that we’ve modified the parameters, write them out to the modelm.K1 = kx(151);m.K2 = kx(152);m.aN = kx(153);m.ben = kx(154);%m.Vsnoi = kx(80);
end
if ADAPTIVE && ~runASM1disp(sprintf(’%3.1f\t%0.4e\t%0.4e\t%0.4e\t%0.4e\t%0.4e’, ...
t,m.K1,m.K2,m.aN,m.ben,m.Vsnoi))end
%store resultsxArray(iout,:) = xhat.’;Pout(:,:,iout) = P;allX(iout,:) = kx.’;tout(iout) = t;iout = iout+1;
if DEBUG && ( any(isnan(kx)) || any(kx<0) || any(isinf(kx)) )disp(sprintf(’**ERROR:**\t\tkx contains negative numbers, NaN, or Inf’))
end
%save progress to file. In case of a crash, load this file and then run%the normal data display function, PlotKEKFData%save fEKFallX allX tout Pout;
endclose(waithandle);
%*****************************************************%*****************************************************%*****************************************************function out = superODE(t,x,m,o,pvar,ADAPTIVE)%this function takes as input%input = [xhat;So;reshape(P,nsv^2,1)]%and outputs [xhatdot;0;reshape(Pdot,nsv^2,1)]
if ADAPTIVE%length of EKF state vector
123
nsv = 19;%length of KanapahaSim state vectorasv = 154;%single out one reactor to filter. This is the index of that reactors%state variables inside of the KSim staterpindex = [46:60 151:asv];%number of parametersnp = 4;
else%length of EKF state vectornsv = 15;%length of KanapahaSim state vectorasv = 150;%single out one reactor to filter. This is the index of that reactors%state variables inside of the KSim staterpindex = 46:60;%number of parametersnp = 0;
end
P = reshape(x(asv+1:nsv^2+asv),nsv,nsv);
if ADAPTIVEF = [fModelJacobAEKF(x(rpindex),m,o); zeros(np,nsv);];
elseF = [fModelJacob(x(rpindex),m,o); zeros(np,nsv);];
end
xhatdot = [fKanapahadxdt(t,x(1:asv),m,o); zeros(np,1);];
Pdot = F * P + P * F.’ + pvar;if any(any(isnan(Pdot)))
disp(sprintf(’**ERROR:**\tPdot is NaN’))endout = [xhatdot;
reshape(Pdot,nsv^2,1);]; %turn Pdot into a vector
%**************************************************************************%**************************************************************************%**************************************************************************function [times, yout] = rkhrk4(FunFcn, times, y0,m,o,pvar)% Initialization%if given only start/stop times, fill in a default stepsizeif length(times) == 2
times = [times(1):0.1*(times(2)-times(1)):times(2)];end
124
times = times’;
%t = t0;y = y0(:);yout = y.’;
% The main loopfor i = 1:(length(times)-1)
t = times(i);h = times(i+1)-times(i);%if t + h > tfinal, h = tfinal - t; end% Compute the slopess1 = feval(FunFcn, t, y,m,o,pvar); s1 = s1(:);s2 = feval(FunFcn, t + h/2, y + h*s1/2,m,o,pvar); s2=s2(:);s3 = feval(FunFcn, t + h/2, y + h*s2/2,m,o,pvar); s3=s3(:);s4 = feval(FunFcn, t + h, y + h*s3,m,o,pvar); s4=s4(:);t = t + h;y = y + h*(s1 + 2*s2 + 2*s3 +s4)/6;y(find(y(1:75)<0))=0;yout = [yout; y.’];
end;
%**************************************************************************%**************************************************************************%**************************************************************************function [times, yout] = rkhrk4A(FunFcn, times, y0,m,o,pvar)% Initialization%if given only start/stop times, fill in a default stepsizeif length(times) == 2
times = [times(1):0.1*(times(2)-times(1)):times(2)];end
times = times’;
t = 0;tfinal = times(end);hdefault = times(2)-times(1);h = hdefault;y = y0(:);yout = y.’;
% The main loopwhile t < tfinal
%make sure we don’t step past the endif t + h > tfinal, h = tfinal - t; end
125
h = hdefault;unsucessful = true;
%loop until we integrate without negative state variables%reduce stepsize if they DO go negative and repeatwhile unsucessful
% Compute the slopess1 = feval(FunFcn, t, y,m,o,pvar); s1 = s1(:);s2 = feval(FunFcn, t + h/2, y + h*s1/2,m,o,pvar); s2=s2(:);s3 = feval(FunFcn, t + h/2, y + h*s2/2,m,o,pvar); s3=s3(:);s4 = feval(FunFcn, t + h, y + h*s3,m,o,pvar); s4=s4(:);t = t + h;ytest = y + h*(s1 + 2*s2 + 2*s3 +s4)/6;%make sure than none of the state variables (1:75) went negativeif any(ytest(1:75) < 0)
%reduce the stepsize according to ASM1asm1only = y(1:75);asm1onlyrates = s1(1:75);%we need only those rates that are positivesubset = find(asm1onlyrates~=0);%we don’t need to worry about those states that are zero, but%have positive ratesasm1only = asm1only(subset);asm1onlyrates = asm1onlyrates(subset);subset = find(asm1only==0);%look at each zero state and see if the corresponding rate<0removeme = find(asm1onlyrates(subset)>=0);asm1only(subset(removeme)) = [];asm1onlyrates(subset(removeme)) = [];
maxstepsize = min(abs(asm1only./asm1onlyrates));h = 0.2*maxstepsize;
else%we have integrated sucessfully, store this datay = ytest;unsucessful = false;
endend
t = t + h;%y(find(y<0))=0;yout = [yout; y.’];
end;
%**************************************************************************%**************************************************************************
126
%**************************************************************************function [times, yout] = rkheuler(FunFcn, times, y0, m,o,pvar)%this is SO MUCH slower that I can’t use it. It guarentees good numerical%behavior. But the problem is stiff, so the step sizes get too small. I%would need a more sophisticaed adaptive stepsize method than this.
% Initialization%if given only start/stop times, fill in a default stepsizeif length(times) == 2
times = [times(1):0.05*(times(2)-times(1)):times(2)];end
times = times’;
y = y0(:);yout = y.’;
% The main loopfor i = 1:(length(times)-1)
t = times(i);h = times(i+1)-times(i);
% Compute the slopess1 = feval(FunFcn, t, y,m,o,pvar); s1 = s1(:);
t = t + h;y = y + h*s1;yout = [yout; y.’];
end;
%**************************************************************************%**************************************************************************%**************************************************************************function [tout, yout] = rkheulerA(FunFcn, times, y0, m,o)%this is SO MUCH slower that I can’t use it. It guarentees good numerical%behavior. But the problem is stiff, so the step sizes get too small. I%would need a more sophisticaed adaptive stepsize method than this.
% Initializationt = times(1);tfinal = times(end);h = 0; %value gets replaced by maxstepsize before use
y = y0(:);tout = t;yout = y.’;
127
%id all of the components with nonzero rates%notzero = [1:13 16:28 31:43 46:58 61:73];
% The main loopwhile (t < tfinal)
if t + h > tfinal, h = tfinal - t; end
% Compute the slopess1 = feval(FunFcn, t, y,influent,m,o); s1 = s1(:);
%compute the maximum stepsize that is safe to takenotzero = find(s1>0);maxstepsize = min(abs(y(notzero)./s1(notzero)));
h = 0.8*maxstepsize;
t = t + h;y = y + h*s1;tout = [tout; t];yout = [yout; y.’];
end;
128
D.8 Code for PlotKEKFData.m
%Plot KEKF Data%Required tout allX errbars
reactorindexNW = 46:60;reactorindexSE = 136:150;
%parse filtered data into reactorsrctrhat = fParseAllX(tout,allX,’Filtered - ’);
%if we are using simulated data, then we have the actual state variable%valuesif simdata
rctr = fParseAllX(ts,allXs,’Simulation - ’);end
%to get some information about the covariances I’ll plot elements of P%here I’m computing the indices of the diagonal elements from each :,:,i%matrix of Perrbars = zeros(size(allX));psize = size(Pout,3);if estparams
reactorindexNW = [reactorindexNW 151:154];reactorindexSE = [reactorindexSE 151:154];
endfor i = 1:nsv
pndx = (i+nsv*(i-1)):nsv^2:psize*nsv^2;errbars(:,reactorindexNW(i)) = sqrt(Pout(pndx)’);
end%errbars is now the same dimensions as allX, and each element is the std%deviation of the corresponding element in allX. Break it up into reactors%for plotting.rctrlowererror = fParseAllX(tout,allX-errbars,’lowererror - ’);rctruppererror = fParseAllX(tout,allX+errbars,’uppererror - ’);%now if I plot all three reactors on the same graph I get xhat with upper%and lower error bars.
%WAKE UP!!! Look, select out the reactors you want to plot, combine them%together into cell arrays with their error bars and pass them to fplot%Because of the goofiness of working with cell arrays, and my lack of%creativity in solving this, I’ll ’preallocate’ rctrplot by assigning it to%rctrhat, then replace each element of rctrplot with what I want to%actually plot for that reactor.rctrtemp = rctrhat;
129
for i = plotreactorsrctrtemp(1) = rctrhat(i);rctrtemp(2) = rctruppererror(i);rctrtemp(3) = rctrlowererror(i);if simdata rctrtemp(4) = rctr(i); endfigure(i+20);clf;fPlotTankEKF(rctrtemp,z);figure(i+40);clf;fPlotEnEKF(rctrtemp,z);
end
% figure(6)% fPlotKOp(kops);
figure(7)fPlotComp(rctrhat,’So’);for i = 1:5
[m, o] = fKanapahaModelOpsSetup(false);subplot(5,1,i);line([0 7],[m.Koa m.Koa],’Linestyle’,’--’,’Color’,’k’);line([0 7],[m.Koh m.Koh],’Linestyle’,’--’,’Color’,’k’);
end
figure(8)fPlotComp(rctrhat,’Snh’);
figure(9)set(9,’Name’,’All Variables for Tank’);fPlotTankAllVars(rctrhat(4))
% figure(10)% fPlotComp(rctr,’Ss’);
if ~simdatafigure(28)set(gcf, ’Name’, ’Compare Probe Data’);fPlotCompareProbes(rctrhat(4),rctrhat(10));
end
%**************************************************************************%plot the estimated parametersif ~runASM1 && estparams
figure(100)set(gcf, ’Name’, ’Estimated Parameters with Error Bars’);
130
h=subplot(4,1,1);plot(tout/24,allX(:,151),’-k’, ...
tout/24,allX(:,151)+errbars(:,151),’-m’, ...tout/24,allX(:,151)-errbars(:,151),’-m’)
ylabel(’K 1’);%set(h,’YLim’, [0 1.2*max(allX(:,151)+errbars(:,151))]);
subplot(4,1,2);plot(tout/24,allX(:,152),’-k’, ...
tout/24,allX(:,152)+errbars(:,152),’-m’, ...tout/24,allX(:,152)-errbars(:,152),’-m’)
ylabel(’K 2’);
h=subplot(4,1,3);plot(tout/24,allX(:,153),’-k’, ...
tout/24,allX(:,153)+errbars(:,153),’-m’, ...tout/24,allX(:,153)-errbars(:,153),’-m’)
ylabel(’aN’);set(h,’YLim’, [0 1.2*max(allX(:,153)+errbars(:,153))]);
h=subplot(4,1,4);plot(tout/24,allX(:,154),’-k’, ...
tout/24,allX(:,154)+errbars(:,154),’-m’, ...tout/24,allX(:,154)-errbars(:,154),’-m’)
ylabel(’b E N’);set(h,’YLim’, [0 1.2*max(allX(:,154)+errbars(:,154))]);
orient tall;wysiwyg;
%**********************************************************************figure(101)set(gcf, ’Name’, ’Scaled Estimated Parameters with Error Bars’);h=subplot(4,1,1);stemp = allX(1,151);plot(tout/24,allX(:,151)/stemp,’-k’, ...
tout/24,(allX(:,151)+errbars(:,151))/stemp,’-m’, ...tout/24,(allX(:,151)-errbars(:,151))/stemp,’-m’)
ylabel(’K 1’);%set(h,’YLim’, [0 1.2*max(allX(:,151)+errbars(:,151))]);
subplot(4,1,2);stemp = allX(1,152);plot(tout/24,allX(:,152)/stemp,’-k’, ...
tout/24,(allX(:,152)+errbars(:,152))/stemp,’-m’, ...tout/24,(allX(:,152)-errbars(:,152))/stemp,’-m’)
ylabel(’K 2’);
131
h=subplot(4,1,3);stemp = allX(1,153);plot(tout/24,allX(:,153)/stemp,’-k’, ...
tout/24,(allX(:,153)+errbars(:,153))/stemp,’-m’, ...tout/24,(allX(:,153)-errbars(:,153))/stemp,’-m’)
ylabel(’aN’);set(h,’YLim’, [0 1.2*max(allX(:,153)+errbars(:,153))]/stemp);
h=subplot(4,1,4);stemp = allX(1,154);plot(tout/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’);set(h,’YLim’, [0 1.2*max(allX(:,154)+errbars(:,154))]/stemp);
orient tall;wysiwyg;
%**********************************************************************figure(102)set(gcf, ’Name’, ’Estimated Parameters’);subplot(4,1,1);plot(tout/24,allX(:,151),’-k’)ylabel(’K 1’);
subplot(4,1,2);plot(tout/24,allX(:,152),’-k’)ylabel(’K 2’);
subplot(4,1,3);plot(tout/24,allX(:,153),’-k’)ylabel(’aN’);
subplot(4,1,4);plot(tout/24,allX(:,154),’-k’)ylabel(’b E N’);
orient tall;wysiwyg;
%**********************************************************************figure(103)set(gcf, ’Name’, ’Scaled Estimated Parameters’);subplot(4,1,1);plot(tout/24,allX(:,151)/allX(1,151),’-k’)
132
ylabel(’K 1’);
subplot(4,1,2);plot(tout/24,allX(:,152)/allX(1,152),’-k’)ylabel(’K 2’);
subplot(4,1,3);plot(tout/24,allX(:,153)/allX(1,153),’-k’)ylabel(’aN’);
subplot(4,1,4);plot(tout/24,allX(:,154)/allX(1,154),’-k’)ylabel(’b E N’);
orient tall;wysiwyg;
end
REFERENCESBaumann, Barbara, Mario Snozzi, Alexander J B Zehnder and Jan Roelof van der
Meer (1996), ‘Dynamics of denitrification activity of Paracoccus denitrificans incontinuous culture during aerobic-anaerobic changes’, Journal of Bacteriology178(15), 4367–4374.
Berks, Ben C, David J Richardson, Carol Robinson, Ann Reilly, Robin T Aplin andStuart J Fergunson (1994), ‘Purification and characterization of the periplasmicnitrate reductase from Thiosphaera pantatropha’, Eur. J. Biochem. 220, 117–124.
Casasus, Anna (2001), Effect of exposure to oxygen on the diauxic lag, Mastersthesis, University of Florida, Gainesville, Florida.
Chattaway, Thomas and Gregory Stephanopoulos (1989), ‘Adaptive estimationof bioreactors: monitoring plasmid instability’, Chemical Engineering Science44(1), 41–48.
Gelb, A (1974), Applied Optimal Estimation, MIT Press, Cambridge.
Gernaey, Krist V, Mark C M van Loosdrecht, Mogens Henze, Morten Lindand Sten B Jorgensen (2004), ‘Activated sludge wastewater treatment plantmodelling and simulation, state of the art’, Environmental Modelling & Software19, 763–783.
Glasson, Douglas P (1980), Research in Multirate Estimation and Control, AnalyticSciences Corp., Reading, Mass.
Glasson, Douglas P (1983), ‘Development and applications of multirate digitalcontrol’, IEEE Control Systems Magazine 3(4), 2–8.
Gouw, Myrna, Robert Bozic, Ben Koopman and Spyros A Svoronos (2001), ‘Effectof nitrate exposure history on the oxygen/nitrate diauxic growth of Pseudomonasdenitrificans ’, Water Research 35(11), 2794–2798.
Gudi, Ravindra D, Sirish L Shah and Murray R Gray (1995), ‘Adaptive multiratestate and parameter estimation strategies with application to a bioreactor’,AIChE Journal 11(11), 2451–2464.
Hamilton, John, R Jain, P Antoniou, Spyros A Svoronos, Ben Koopman andGary Lyberatos (1992), ‘Modeling and pilot-scale experimental verification forpredenitrification process’, Journal of Environmental Engineering 118(1), 38–55.
133
134
Hamilton, Ryan, Anna Casasus, Madeline Rasche, Atul Narang, Spyros A Svoronosand Ben Koopman (2005), ‘Structured model for denitrifier diauxic growth’,Biotechnology and Bioengineering 90(4), 501–508.
Henze, M, W Gujer, T Mino and M V Loosdrecht (2000), Activated sludge modelsASM1, ASM2, ASM2d and ASM3, number 9 in ‘Scientific and Technical Report’,International Water Association, London, England.
Ingildsen, P, U Jeppsson and G Olsson (2002), ‘Dissolved oxygen controller basedon-line measurements of ammonium combining feed-forward and feedback’,Water Science and Technology 45(4–5), 453–460.
Jones, Robert W, Trevor A Gray and Peter B Garland (1977), ‘A study of thepermeability of the cytoplasmic membrane of Escherichia coli to reduced andoxidized benzyl viologen and methyl viologen cations: Complications in the useof viologens as redox mediators for membrane-bound enzymes’, Biochimica etBiophysica Acta. 4, 671–673.
Jorgensen, P E, T Eriksen and B K Jensen (1992), ‘Estimation of viable biomass inwastewater and activated sludge by determination of atp, oxygen utilization rateand fda hydrolysis’, Water Research 26(11), 1495–1501.
Kalman, Rudolph Emil (1960), ‘A new approach to linear filtering and predictionproblems’, Transactions of the ASME–Journal of Basic Engineering 82(SeriesD), 35–45.
Kodama, T, K Shimada and T Mori (1969), ‘Studies on anaerobic biphasic growthof a denitrifying bacterium, Pseudomonas stutzeri ’, Plant and Cell Physiology10, 855–965.
Koopman, Ben, Gary Lyberatos, Spyros A Svoronos, P Antoniou, John Hamiltonand Rohit Jain (1989), Mathematical modeling and experimental verification forthe predenitrification process, Technical report, Departments of EnvironmentalSciences and Chemical Engineering, University of Florida, Gainesville, Florida,USA.
Kornaros, M, C Zafiri and G Lyberatos (1996), ‘Kinetics of denitrification byPseudomonas denitrificans under growth conditions limited by carbon and/ornitrate’, Water Environment Research 68, 934–945.
Kornaros, M and G Lyberatos (1997), ‘Kinetics of aerobic growth of a denitrifyingbacterium, pseudomonas denitrificans, in the presence of nitrates and/or nitrites’,Water Research 31(3), 479–488.
Kornaros, M and G Lyberatos (1998), ‘Kinetic modeling of pseudomonasdenitrificans growth and denitrification under aerobic, anoxic and transient
135
operating conditions’, Water Research 32(6), 1912–1922.
Lee, Dong-Uk (2005), The diauxic lag of denitrifying bacteria in alternating oxic/ anoxic cycling under continuous flow conditions, PhD thesis, University ofFlorida, Gainesville, Florida.
Lisbon, Keisha, M McKean, S Shekar, Spyros A Svoronos and Ben Koopman(2002), ‘Effect of do on oxic/anoxic diauxic lag of Pseudomonas denitrificans ’,Journal of Environmental Engineering 128(4), 391–394.
Liu, Pi-Hsin, Gougen Zhan, Spyros A Svoronos and Ben Koopman (1998), ‘Diauxiclag from changing electron acceptors in activated sludge treatment’, WaterResearch 32(11), 3452–3460.
Liu, Pi-Hsin, Spyros A Svoronos and Ben Koopman (1998), ‘Experimental andmodeling study of diauxic lag of Pseudomonas denitrificans switching from oxicto anoxic conditions’, Biotechnology and Bioengineering 60(6), 649–655.
Ljung, Lennart and Torsten Soderstrom (1983), Theory and Practice of RecursiveIdentification, The MIT Press Signal Processing, Optimization, and ControlSeries, MIT Press, Cambridge, MA.
Meredith, Christopher Edward (2003), Process control design and analysis forwastewater disinfection, stream neutralization, and run-to-run strategies,Doctoral dissertation, University of Florida, Gainesville, Florida.
Monod, J (1942), ‘The growth of bacterial cultures’, Annual Review of Microbiology3, 371–394.
Moreno-Vivian, Conrado, Purificacion Cabello, Manuel Martınez-Luque, RafaelBlasco, and Francisco Castillo (1999), ‘Prokaryotic nitrate reduction: Molecularproperties and functional distinction among bacterial nitrate reductases’, Journalof Bacteriology 181(21), 6573–6584.
Nowak, O, K Svardal and P Schweighofer (1997), ‘The dynamic behaviorof nitrifying activated sludge systems influenced by inhibiting wastewatercomounds’, Biotechnology and Bioengineering 54, 434–450.
Park, Seujeung and W Fred Ramirez (1990), ‘Optimal regulatory control ofbioreactor nutrient concentration incorporating system identification’, ChemicalEngineering Science 45(12), 3467–3481.
Potter, P G, Ben Koopman and Spyros A Svoronos (1996), ‘Optimization ofa periodic biological process for nitrogen removal from wastewater’, WaterResearch 30(1), 142–152.
136
Ramalho, R S (1983), Introduction to Wastewater Treatment Processes, AcademicPress, San Diego, California.
Ramirez, W Fred (1987), ‘Optimal state and parameter identification:An application to batch fermentation’, Chemical Engineering Science42(11), 2749–2756.
Ramkrishna, D (1983), Foundations of Biochemical Engineering: Kinetics andThermodynamics in Biological Systems, number 207 in ‘ACS Symposium Series’,American Chemical Society, Washington, DC, chapter A cybernetic perspectiveof microbial growth.
Schutze, Manfred, Alberto Campisano, Hubert Colas, Wolfgang Schillingand Peter A Vanrolleghem (2004), ‘Real time control of urban wastewatersystems–where do we stand today?’, Journal of Hydrology 299(4), 335–348.
Shoemaker, Jason, Gregory T Reeves, Shakti Gupta, Sergei S Pilyugin, ThomasEgli and Atul Narang (2003), ‘The dynamics of single-substrate continuouscultures: the role of transport enzymes’, Journal of Theoretical Biology222(3), 307–322.
Steffens, Marc A. and P. A. Lant (1999), ‘Multivariable control of nutrientremoving activated sludge systems’, Water Research 33(11), 2864–2878.
Stephanopoulos, Greg and K Y San (1984), ‘Studies on on-line bioreactoridentification’, Biotechnology and Bioengineering 26(10), 1176–1188.
Tenno, R and P Uronen (1995), ‘State and parameter estimation for wastewatertreatment processes using a stochastic model’, Control Engineering Practice3(6), 793–804.
van Veldhuizen, H M, M C M van Loosdrecht and J J Heijnen (1999), ‘Modellingbiological phosphorus and nitrogen removal in a full scale activated sludgeprocess’, Water Research 33, 3459–3468.
Waki, T, K Murayama, Y Kawato and K Ichikawa (1980), ‘Transient characteristicsof Paracoccus denitrificans with changes between aerobic and anaerobicconditions’, Journal of Fermentation Technology 58, 243–249.
Weon, Seung-Yeon, Chan-Won Lee, Sang-Ill Lee and Ben Koopman (2002), ‘Nitriteinhibition of aerobic growth of Acinetobacter sp.’, Water Research 36, 4471–4476.
Wild, D, R von Schulthess and W Gujer (1994), ‘Synthesis of denitrificationenzymes in activated sludge: modelling with structured biomass’, Water Scienceand Technology 30(6), 113–122.
137
Yagil, Gad and Ezra Yagil (1971), ‘On the relation between effector concentrationand the rate of induced enzyme synthesis’, Biophysical Journal 11(1), 11–27.
BIOGRAPHICAL SKETCH
Ryan Hamilton received his B.S. degree in chemical engineering from Georgia
Tech in Atlanta, Georgia in 2000. Since 2001 he has been a graduate student in
the Chemical Engineering Department at the University of Florida in Gainesville,
Florida and expects to receive his doctorate degree in 2005. His research interests
include modeling bacterial metabolism, parameter estimation, and process
optimization.
138