Skip to content
kai edited this page Oct 27, 2021 · 3 revisions

Example 1 - Setting Up a Steady State Simulation for a Complete Mixed Activated Sludge Treatment Plant:

Part 1 of 2 - Construction of the Process Flow Diagram

Let's say the user would like to model the steady state for the following process flow diagram (PFD):

Inlet --p1-> reactor(ra) --p2-> final.clar --p3-> outlet
             ^                       |
             |                       p4
             |                       |
             |                       |
             |                       V
             +<--RAS-----splt*<------+
                          |
                          +----------p5---------> waste (WAS)

where the definitions of each process unit, including the inlet, outlet, waste sludge, pipes, splitters, bioreactor, and final clarifier can be found in the sample code below. (splt* is a SRT controlling splitter).

1) Import all the process units that are needed for the PFD:

from PooPyLab.unit_procs.streams import splitter, pipe, WAS

from PooPyLab.unit_procs.streams import influent, effluent

from PooPyLab.unit_procs.bio import asm_reactor

from PooPyLab.unit_procs.physchem import final_clarifier

2) Create the process units needed for the PFD:

inlet = influent()

p1 = pipe()

ra = asm_reactor()

p2 = pipe()

fc = final_clarifier()

p3 = pipe() # to outlet

p4 = pipe() # to splt

outlet = effluent()

splt = splitter()

p5 = pipe() # to waste

RAS = pipe() # to ra

waste = WAS()

3) Place all the process units into a Python list container for the main loop (Part 2 of this Example):

wwtp = [inlet, p1, p2, p3, p4, p5, ra, fc, outlet, RAS, waste, splt]

4) Define a target sludge retention time (SRT, d) for the steady state simulation:

SRT = 10 # day

5) Define the PFD (see above) by connecting the process units and specifying flow rates (m3/d), active volumes (m3), bioreactor's dissolved oxygen concentration (mg/L) and temperature (degC):

def construct():

   # make an CMAS plant

   inlet.set_downstream_main(p1)
   p1.set_downstream_main(ra)
   ra.set_downstream_main(p2)
   p2.set_downstream_main(fc)
   fc.set_downstream_main(p3)
   fc.set_downstream_side(p4)
   p3.set_downstream_main(outlet)
   p4.set_downstream_main(splt)
   splt.set_downstream_main(RAS)
   splt.set_downstream_side(p5)
   splt.set_as_SRT_controller(True)
   RAS.set_downstream_main(ra)
   p5.set_downstream_main(waste)
   inlet.set_mainstream_flow(37800)
   splt.set_mainstream_flow(37800) # i.e. 1.0x influent flow
   ra.set_model_condition(10, 2.0)  # temperature and DO
   ra.set_active_vol(14000)
   print("CMAS PFD constructed.")
   return wwtp

Now the CMAS PFD is defined. Save it into CMAS.py and move onto the 2nd part of the example...

Part 2 of 2 - Running the Steady State Simulation for the PFD Defined in CMAS.py:

The majority of work is done once the PFD is defined. Create a file called CMAS_test.py (or whatever name you prefer), in which include the following:

from PooPyLab.utils import pfd, run

In the main, the CMAS PFD will need to be imported and constructed:

if __name__ == '__main__':

   import CMAS
   wwtp = CMAS.construct()
   pfd.check(wwtp)
   pfd.show(wwtp)
   run.get_steady_state(wwtp, target_SRT=CMAS.SRT, verbose=False, diagnose=False)

Save CMAS_test.py. And it can be run in Python3.