INDISIM-Paracoccus

INDISIM-Paracoccus preview image

4 collaborators

Default-person Marta Ginovart (Advisor)
Anna Gras (Advisor)
Vincent Moulton (Author)

Tags

bacterial growth  

Tagged by Pablo Alejandro Araujo Granda almost 8 years ago

denitrification 

Tagged by Pablo Alejandro Araujo Granda almost 8 years ago

indisim 

Tagged by Pablo Alejandro Araujo Granda almost 8 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.3.1 • Viewed 365 times • Downloaded 18 times • Run 0 times
Download the 'INDISIM-Paracoccus' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

; INDISIM - PARACOCCUS SIMULATOR - Metabolic version
; Araujo Granda P.A., Gras A., Ginovart M. & Moulton V. - 2016
;______________________________ Global Variables __________________________________________________________________________________

globals
[
  world                                                                      ; culture medium continuos size [ litres ]
  steptime                                                                   ; step time [h]
  time_now                                                                   ; simulated time [hours]
  gbacteria gdioxide gbicarbonate gn2o gno2- gno gn2 gsuccinate gamonium gnitrate goxygen ; global variables for graphical and numerical outputs
  output_file                                                                ; global variable for output file
  DST DSTb DSTr                                                              ; Variables for General Standard Deviation
  succinatemedium amoniummedium oxygenmedium nitratemedium nitritemedium monoxidemedium dinitrogenmedium nitrogenmedium dioxidemedium bicarbonatemedium
  succinate-input amonium-input nitrate-input
  xsc xam xox xntr xnr xmn xdn xn2 xco2 xhco3 bacteriaout xbacteria
  d
  untri
  isuccinate iamonium ioxygen initrate initrite imonoxide idinitrogen initrogen idioxide ibicarbonate ibacteria icbacteria inbacteria
  fsuccinate famonium foxygen fnitrate fnitrite fmonoxide fdinitrogen fnitrogen fdioxide fbicarbonate fbacteria fcbacteria fnbacteria
  insuccinate inamonium innitrate
  outsuccinate outamonium outoxygen outnitrate outnitrite outmonoxide outdinitrogen outnitrogen outdioxide outbicarbonate outbacteria outcbacteria outnbacteria
  c-bacteria n-bacteria c-succinate n-amonium n-nitrate n-nitrite n-monoxide n-dinitrogen n-nitrogen c-co2 c-hco3
  n-obtained n-delivered c-obtained c-delivered
  %_e_c %_e_n yc/c
  scm oxm ntrm
  q
  sc-mant2 sc-mant3 sc-mant4
  ini_biomass rep_biomass
  Suc Amo Oxy Nrt Nit N2O
  Pablo Araujo
  ]

; ____________________________ Microorganism variables ____________________________________________________________________________

breed [bacteria bacterium]                                                   ; microorganism definition
bacteria-own
[
  biomass                                                                    ; microorganism biomass [ mmol ]
  biomass-reproduction                                                       ; reproduction treshold biomass [ mmol ]
  R                                                                          ; reproductions counter
  m_aero s_aero_1 s_aero_2                                                   ; aerobic phase counter
  m_anox_1 m_anox_2 m_anox_3 m_anox_4 s_anox_1 s_anox_2 s_anox_3 s_anox_4    ; anaerobic reactions counters
  sc-useful am-useful ox-useful ntr-useful nr-useful mn-useful dn-useful     ; usefuls nutrients variables
]

; ____________________________ Culture Medium variables ____________________________________________________________________________

patches-own [
  succinate-medium                     ; culture medium variable for the electron donor and C-Source in aerobic and anaerobic phases [ mmol ]
  amonium-medium                       ; culture medium variable for the N-Source in aerobic and anaerobic phases [ mmol ]
  oxygen-medium                        ; culture medium variable for the electron aceptor in aerobic phase [ mmol ]
  nitrate-medium                       ; culture medium variable for the electron aceptor in anoxic reaction 1 [ mmol ]
  nitrite-medium                       ; culture medium variable for the electron aceptor in anoxic reaction 2 [ mmol ]
  monoxide-medium                      ; culture medium variable for the electron aceptor in anoxic reaction 3 [ mmol ]
  dinitrogen-medium                    ; culture medium variable for the electron aceptor in anoxic reaction 4 [ mmol ]
  dioxide nitrogen bicarbonate         ; culture medium variables for the denitrification products [ mmol ]
    ]

; ____________________________ Virtual Bioreactor Setting ____________________________________________________________________________

to setup
  clear-all                      ; clear all variables, graphical and numerical outputs
  reset-timer                    ; reset the timer counter
  reset-ticks                    ; reset tick counter
  setup-model                    ; setup general model parameters to obtain the starting points accord to Felgate's (2012) experiment
  setup-time                     ; scaled time setting
  setup-medium                   ; formulation of the initial culture medium
  setup-bacteria                 ; formulation of initial bacterial inoculum
  setup-monitors                 ; monitors setting
  if Output_file? = true
  [
  setup-output                   ; setup output file
  write-outputfile               ; write initial values on output file
  ]
  setup-balance                  ; mass balance setup
end 

;_____________________________ Initial data according to Felgate's Experiments _____________________________________________________

to setup-model
  set world (world-width * world-height)              ; Differential adjustment of reactor volume
  set DSTb 0.15                                       ; Standard Deviation for initial biomass distribution
  set DSTr 0.15                                       ; Standard Deviation for biomass reproduction
  set DST 0.05                                        ; Standard Deviation for general model varaibles
  set ini_biomass abs random-normal (4.5) (DST * 4.5) ; [pmol] initial biomass per each bacterium
  set rep_biomass abs random-normal (4.5) (DST * 4.5) ; [pmol] reproduction treshold biomass
if Experiment = "Succ_High/Nitrate_Low"
[
  Set Succinate 20 Set Nitrate 4.99825                                ; Succiante and Nitrate setup accord to Felgate's (2012) experiment (Succinate High/Nitrate low)
  let initial_biomass abs random-normal (0.0033683) (DST * 0.0033683)
  set Microrganism round ((initial_biomass * 1000 * world) / (75 * ini_biomass)) ; this quantity fix the initial biomass concentration accord to Felgate's (2012) experiment.

]
if Experiment = "Succ_Low/Nitrate_High"
[
  Set Succinate 5 set Nitrate 21.60951                                ; Succiante and Nitrate setup accord to Felgate's (2012) experiment (Succinate Low/Nitrate high)
  let initial_biomass abs random-normal (0.0668478) (DST * 0.0668478)
  set Microrganism round ((initial_biomass * 1000 * world) / (75 * ini_biomass)) ; this quantity fix the initial biomass concentration accord to Felgate's (2012) experiment.
]
end 

; ____________________________ Proceeding to Scaled time ____________________________________________________________________________

to setup-time
  set steptime (Min/steptime / 60)       ; User define the number of minute for each step time using a slider labeled "Min_per_steptime"
end 

; ____________________________ Proceeding to Formulation of Initial culture medium __________________________________________________

to setup-medium
if Experiment = "Succ_High/Nitrate_Low"
       [
       set Suc random-normal (Succinate) (DST * Succinate)           ; Succinate initial concentration (user define using a slider labeled Succinate) [mM]
       set Amo random-normal (Amonium) (DST * Amonium)               ; Amonium initial concentration (user define using a slider labeled Amonium) [mM]
       set Oxy random-normal (0.2360) (DST * 0.2360)                 ; Oxygen initial concentration (simulated saturated conditions) accord to Felgate's (2012) experiment [mM]
       set Nrt random-normal (Nitrate) (DST * Nitrate)               ; Nitrate initial concentration (user define using a slider labeled Nitrate) [mM]
       set Nit random-normal (0.0255) (DST * 0.0255)                 ; Nitrite initial concentration accord to Felgate's (2012) experiment [mM]
       set N2O random-normal (0.003003178) (DST * 0.003003178)       ; Nitrous oxide initial concentration accord to Felgate's (2012) experiment [mM]
       ]
     if Experiment = "Succ_Low/Nitrate_High"
       [
       set Suc random-normal (Succinate) (DST * Succinate)           ; Succinate initial concentration (user define using a slider labeled Succinate) [mM]
       set Amo random-normal (Amonium) (DST * Amonium)               ; Amonium initial concentration (user define using a slider labeled Amonium) [mM]
       set Oxy random-normal (0.2360) (DST * 0.2360)                 ; Oxygen initial concentration (simulated saturated conditions) accord to Felgate's (2012) experiment [mM]
       set Nrt random-normal (Nitrate) (DST * Nitrate)               ; Nitrate initial concentration (user define using a slider labeled Nitrate) [mM]
       set Nit random-normal (0.011163522) (DST * 0.011163522)       ; Nitrite initial concentration accord to Felgate's (2012) experiment [mM]
       set N2O random-normal (0.000028413312) (DST * 0.000028413312) ; Nitrous oxide initial concentration accord to Felgate's (2012) experiment [mM]
       ]
   ask patches
   [
     set succinate-medium abs random-normal (Suc) (DST * Suc)            ; Assign the succinate concentration to each cell according to the model's standar deviation
     set amonium-medium abs random-normal (Amo) (DST * Amo)              ; Assign the amonium concentration to each cell according to the model's standar deviation
     set oxygen-medium  abs random-normal (Oxy) (DST * Oxy)              ; Assign the oxygen concentration to each cell according to the model's standar deviation
     set nitrate-medium abs random-normal (Nrt) (DST * Nrt)              ; Assign the nitrate concentration to each cell according to the model's standar deviation
     set nitrite-medium abs random-normal (Nit) (DST * Nit)              ; Assign the nitrite concentration to each cell according to the model's standar deviation
     set dinitrogen-medium abs random-normal (N2O) (DST * N2O)           ; Assign the nitrous oxide concentration to each cell according to the model's standar deviation
     set monoxide-medium 0                                                ; Nitric Oxide initial concentration accord to Felgate's (2012) experiment [mM]
     set nitrogen 0                                                       ; Nitrogen gas (N2) initial concentration accord to Felgate's (2012) experiment [mM]
     set dioxide 0                                                        ; Carbon Dioxide initial concentration accord to Felgate's (2012) experiment [mM]
     set bicarbonate 0                                                    ; Bicarbonate initial concentration [mM]
     set pcolor scale-color blue succinate-medium 0 Succinate
   ]
end 

; ____________________________ Proceeding to Formulation the Initial bacterial inoculum __________________________________________________

to setup-bacteria
 create-bacteria Microrganism                                    ; User define the amount of initial active bacteria using a slider labaled Microrganism
 [
   set shape "circle"                                            ; Paracoccus denitrificans is a spherical bacteria
   set size 0.5                                                  ; This size is for visual propouse only
   set color green                                               ; This color is for visual propouse only
   setxy random-xcor random-ycor                                 ; Random inicial position on culture medium
   set biomass abs random-normal (ini_biomass) (DSTb * ini_biomass)                  ; [ mmol] in order to P.denitrificans biomass elementary cell composition C3H5.4N0.75O1.45 (M = 75 mg/mmol)
   set biomass-reproduction abs random-normal (rep_biomass) (DSTr * rep_biomass) ; reproduction treshold biomass [ mmol ] accord to INDISIM general procedures.
 ]
end 

; ____________________________ Proceeding to monitors setting __________________________________________________________________________

to setup-monitors
  set time_now ticks * steptime                                                                          ; Simulated time [ h ]
  set gbacteria ((sum [biomass] of bacteria / world) / 1000) * 75                                        ; Biomass concentration [ mg/ml ]
  set gsuccinate (sum[succinate-medium]of patches / world)                                               ; Succinate concentration [ mM ]
  set gamonium (sum [amonium-medium] of patches / world)                                                 ; Amonium concentration [ mM ]
  set goxygen (sum [oxygen-medium] of patches / world)                                                   ; Oxygen concentration [ mM ]
  set gnitrate (sum [nitrate-medium] of patches / world)                                                 ; Nitrate concentration [ mM ]
  set gno2- (sum [nitrite-medium] of patches / world)                                                    ; Nitrite concentration [ mM ]
  set gno (sum [monoxide-medium] of patches / world)                                                     ; Nitric Oxide concentration [ mM ]
  if Experiment = "Succ_Low/Nitrate_High"[set gn2o (sum [dinitrogen-medium] of patches / world) * 1000]  ; Nitrous Oxide concentration [ uM ]
  if Experiment = "Succ_High/Nitrate_Low"[set gn2o (sum [dinitrogen-medium] of patches / world)]         ; Nitrous Oxide concentration [ mM ]
  set gdioxide (sum [dioxide] of patches / world)                                                        ; Carbon dioxide concentration [ mM ]
  set gn2 (sum [nitrogen] of patches / world)                                                            ; Nitrogen concentration [ mM ]
  set gbicarbonate (sum [bicarbonate] of patches / world)                                                ; Bicarbonate concentration [ mM ]

  reactor_balance
end 

; ____________________________ Proceeding to setup output file __________________________________________________________________________

to setup-output
  file-close
  if Experiment = "Succ_Low/Nitrate_High"
  [
  set output_file (word behaviorspace-run-number "_INDISIM_Paracoccus(V20_Metabolic)_Output_ScLw_NtHg_" ".txt") ; Outputfile name with .txt extension and Behaviorspace numering
  ]
  if Experiment = "Succ_High/Nitrate_Low"
  [
  set output_file (word behaviorspace-run-number "_INDISIM_Paracoccus(V20_Metabolic)_Output_ScHg_NtLw_" ".txt") ; Outputfile name with .txt extension and Behaviorspace numering
  ]
  carefully
  [file-delete output_file] [ ]
  file-open output_file
  file-type "Time_[h] "                                                  ; Simulation time labed in outputfile unit hours
  file-type "Succinate_[mM] "                                            ; Succinate concentration labed in outputfile unit milimolar
  file-type "NH4+_[mM] "                                                 ; Amonium concentration labed in outputfile unit milimolar
  file-type "O2_[mg/l] "                                                 ; Oxygen concentration labed in outputfile unit mg/ml
  file-type "NO3-_[mM] "                                                 ; Nitrate concentration labed in outputfile unit milimolar
  file-type "NO2-_[mM] "                                                 ; Nitrite concentration labed in outputfile unit milimolar
  file-type "NO_[mM] "                                                   ; Nitric Oxide concentration labed in outputfile unit milimolar
  if Experiment = "Succ_Low/Nitrate_High" [file-type "N2O_[uM] "]        ; Dinitrogen concentration labed in outputfile unit micromolar
  if Experiment = "Succ_High/Nitrate_Low" [file-type "N2O_[mM] "]        ; Dinitrogen concentration labed in outputfile unit milimolar
  file-type "N2_[mM] "                                                   ; Nitrogen concentration labed in outputfile unit milimolar
  file-type "CO2_[mM] "                                                  ; Carbon dioxide concentration labed in outputfile unit milimolar
  file-type "Biomass_[mg/ml] "                                           ; Biomass concentration labed in outputfile unit miligrams / mililiter
  file-type "Individuals "                                               ; Individuals into bioreactor labed in outputfile
  file-type "d "                                                         ; Reactor dilution ratio labed in outputfile units (h^-1)
  file-type "Sc_In_[mmol] "                                              ; Inflow Succinate labed in outputfile units milimoles
  file-type "NH4+_In_[mmol] "                                            ; Inflow Amonium labed in outputfile units milimoles
  file-type "NO3-_In_[mmol] "                                            ; Inflow Nitrate labed in outputfile units milimoles
  file-type "Sc_Out_[mmol] "                                             ; Outflow Succinate labed in outputfile units milimoles
  file-type "NH4+_Out_[mmol] "                                           ; Outflow amonium labed in outputfile units milimoles
  file-type "NO3-_Out_[mmol] "                                           ; Outflow  nitrate labed in outputfile units milimoles
  file-type "NO2-_Out_[mmol] "                                           ; Outflow nitrite labed in outputfile units milimoles
  file-type "NO_Out_[mmol] "                                             ; Outflow Nitric Oxide labed in outputfile units milimoles
  if Experiment = "Succ_Low/Nitrate_High" [file-type "N2O_Out_[umol] "]  ; Outflow Nitrous Oxide labed in outputfile units micromoles
  if Experiment = "Succ_High/Nitrate_Low" [file-type "N2O_Out_[mmol] "]  ; Outflow Nitrous oxide labed in outputfile units milimoles
  file-type "N2_Out_[mmol] "                                             ; Outflow Nitrogen gas labed in outputfile units milimoles
  file-type "Ind_Out "                                                   ; Outflow Microorganims labed in outputfile
  file-type "HCO3_[mM] "                                                 ; Bicarbonate concentration labed in outputfile units milimolar
  file-type "HCO3_Out_[mmol] "                                           ; Outflow Bicarbonate labed in outputfile units milimoles
  file-type "CO2_Out_[mmol] "                                            ; Outflow Carbon dioxide labed in outputfile units milimoles
  file-print " "
end 

; ____________________________ Proceeding to write values on output file __________________________________________________________________________

to write-outputfile
  setup-monitors
  file-type time_now                                            ; Outputfile Simulated time [h]
  file-type " "
  file-type gsuccinate                                          ; Outputfile Bioreactor Succinate concentration [mM]
  file-type " "
  file-type gamonium                                            ; Outputfile Bioreactor Amonium concentration [mM]
  file-type " "
  file-type goxygen * 32                                        ; Outputfile Bioreactor Oxygen concentration [mg/l]
  file-type " "
  file-type gnitrate                                            ; Outputfile Bioreactor Nitrate concentration [mM]
  file-type " "
  file-type gno2-                                               ; Outputfile Bioreactor Nitrite concentration [mM]
  file-type " "
  file-type gno                                                 ; Outputfile Bioreactor Nitric Oxide concentration [mM]
  file-type " "
  file-type gn2o                                                ; Outputfile Bioreactor Nitrous Oxide concentration [mM][uM]
  file-type " "
  file-type gn2                                                 ; Outputfile Bioreactor Nitrogen gas concentration [mM]
  file-type " "
  file-type gdioxide                                            ; Outputfile Bioreactor Carbon Dioxide concentration [mM]
  file-type " "
  file-type gbacteria                                           ; Outputfile Bioreactor Biomass concentration [mg/ml]
  file-type " "
  file-type count bacteria                                      ; Outputfile Bioreactor microorganism count [individuals]
  file-type " "
  file-type d                                                   ; Outputfile Bioreactor Dilution ratio [h^1]
  file-type " "
  file-type succinate-input                                     ; Outputfile Inflow Succinate quantity [mmol]
  file-type " "
  file-type amonium-input                                       ; Outputfile Inflow Amonioum quantity [mmol]
  file-type " "
  file-type nitrate-input                                       ; Outputfile Inflow Nitrate quantity [mmol]
  file-type " "
  file-type xsc                                                 ; Outputfile Outflow Succinate quantity [mmol]
  file-type " "
  file-type xam                                                 ; Outputfile Outflow Amonium quantity [mmol]
  file-type " "
  file-type xntr                                                ; Outputfile Outflow Nitrate quantity [mmol]
  file-type " "
  file-type xnr                                                 ; Outputfile Outflow Nitrite quantity [mmol]
  file-type " "
  file-type xmn                                                 ; Outputfile Outflow Nitric oxide quantity [mmol]
  file-type " "
  if Experiment = "Succ_Low/Nitrate_High"[file-type xdn * 1000] ; Outputfile Outflow Nitrous oxide quantity [umol]
  if Experiment = "Succ_High/Nitrate_Low"[file-type xdn]        ; Outputfile Outflow Nitrous oxide quantity [mmol]
  file-type " "
  file-type xn2                                                 ; Outputfile Outflow Nitrogen gas quantity [mmol]
  file-type " "
  file-type bacteriaout                                         ; Outputfile Outflow microrganism quantity [individuals]
  file-type " "
  file-type gbicarbonate                                        ; Outputfile Bioreactor Bicarbonate concentration [mM]
  file-type " "
  file-type xhco3                                               ; Outputfile Outflow bicarbonate quantity [mmol]
  file-type " "
  file-type xco2                                                ; Outputfile Outflow Carbon Dioxide quantity [mmol]
  file-type " "
  file-print " "
end 

; ____________________________ General mass balance proceedings _____________________________________________________________________________

to setup-balance
  set ibacteria (sum [biomass] of bacteria)                                                ; Initial Biomass [mmol]
  set isuccinate (sum[succinate-medium]of patches)                                         ; Initial Succinate [mmol]
  set iamonium (sum [amonium-medium] of patches)                                           ; Initial Amonium [mmol]
  set ioxygen (sum [oxygen-medium] of patches)                                             ; Initial Oxygen [mmol]
  set initrate (sum [nitrate-medium] of patches)                                           ; Initial Nitrate [mmol]
  set initrite (sum [nitrite-medium] of patches)                                           ; Initial Nitrite [mmol]
  set imonoxide (sum [monoxide-medium] of patches)                                         ; Initial Monoxide [mmol]
  set idinitrogen (sum [dinitrogen-medium] of patches)                                     ; Initial Dinitrogen [mmol]
  set idioxide (sum [dioxide] of patches)                                                  ; Initial Carbon dioxide [mmol]
  set initrogen (sum [nitrogen] of patches)                                                ; Initial Nitrogen [mmol]
  set ibicarbonate (sum [bicarbonate] of patches)                                          ; Initial Bicarbonate [mmol]
end 

to reactor_balance
  set fbacteria (gbacteria * 1000 * world / 75)                                            ; Final Biomass [mmol]
  set fsuccinate (gsuccinate * world)                                                      ; Final Succinate [mmol]
  set famonium (gamonium * world)                                                          ; Final Amonium [mmol]
  set foxygen (goxygen * world)                                                            ; Final Oxygen [mmol]
  set fnitrate (gnitrate * world)                                                          ; Final Nitrate [mmol]
  set fnitrite (gno2- * world)                                                             ; Final Nitrite [mmol]
  set fmonoxide (gno * world)                                                              ; Final Monoxide [mmol]
  if Experiment = "Succ_Low/Nitrate_High"[set fdinitrogen ((gn2o * world) / 1000)]         ; Final Dinitrogen [mmol]
  if Experiment = "Succ_High/Nitrate_Low"[set fdinitrogen (gn2o * world)]                  ; FInal Dinitrogen [mmol]
  set fdioxide (gdioxide * world)                                                          ; Final Carbon dioxide [mmol]
  set fnitrogen (gn2 * world)                                                              ; Final Nitrogen [mmol]
  set fbicarbonate (gbicarbonate * world)                                                  ; Final Bicarbonate [mmol]
end 

to inflow_balance
  set insuccinate (insuccinate + succinate-input)                                          ; Inflow Succinate [mmol]
  set inamonium (inamonium + amonium-input)                                                ; Inflow Amonium [mmol]
  set innitrate (innitrate + nitrate-input)                                                ; Inflow Nitrate [mmol]
end 

to outflow_balance
  set outsuccinate (outsuccinate + xsc)                                                    ; OutFlow Succinate [mmol]
  set outamonium (outamonium + xam)                                                        ; OutFlow Amonium [mmol]
  set outoxygen (outoxygen + xox)                                                          ; OutFlow Oxygen [mmol]
  set outnitrate (outnitrate + xntr)                                                       ; Outflow Nitrtate [mmol]
  set outnitrite (outnitrite + xnr)                                                        ; Outflow Nitrite [mmol]
  set outmonoxide (outmonoxide + xmn)                                                      ; Outflow Monoxide [mmol]
  set outdinitrogen (outdinitrogen + xdn)                                                  ; Outflow N2O [mmol]
  set outnitrogen (outnitrogen + xn2)                                                      ; Outflow N2 [mmol]
  set outdioxide (outdioxide + xco2)                                                       ; Outflow CO2 [mmol]
  set outbicarbonate (outbicarbonate + xhco3)                                              ; outflow HCO3 [mmol]
  set outbacteria (outbacteria + xbacteria)                                                ; OutFlow Baacteria [mmol]
end 

to general_mass_balance
  set icbacteria (ibacteria * 3 * 12)                                                      ; Initial C-Mic [mg]
  set inbacteria (ibacteria * 0.75 * 14)                                                   ; Initial N-Mic [mg]
  set fcbacteria (fbacteria * 3 * 12)                                                      ; Final C-Mic [mg]
  set fnbacteria (fbacteria * 0.75 * 14)                                                   ; Final N-Mic [mg]
  set outcbacteria (outbacteria * 3 * 12)                                                  ; OutFlow C-Mic [mg]
  set outnbacteria (outbacteria * 0.75 * 14)                                               ; OutFlow N-Mic [mg]

  set c-bacteria (fcbacteria - icbacteria) - (0 - outcbacteria)                            ; Microorganism Carbon balance
  set n-bacteria (fnbacteria - inbacteria) - (0 - outnbacteria)                            ; Microorganims Nitrogen balance
  set c-succinate ((fsuccinate - isuccinate) - (insuccinate - outsuccinate)) * 4 * 12      ; Succinate carbon balance
  set n-amonium ((famonium - iamonium) - (inamonium - outamonium)) * 1 * 14                ; Amonium nitrogen balance
  set n-nitrate ((fnitrate - initrate) - (innitrate - outnitrate)) * 1 * 14                ; Nitrate nitrogen balance
  set n-nitrite ((fnitrite - initrite) - (0 - outnitrite)) * 1 * 14                        ; Nitrite nitrogen balance
  set n-monoxide ((fmonoxide - imonoxide) - (0 - outmonoxide)) * 1 * 14                    ; Nitric oxide nitrogen balance
  set n-dinitrogen ((fdinitrogen - idinitrogen) - (0 - outdinitrogen)) * 2 * 14            ; Nitrous oxide nitrogen balance
  set n-nitrogen ((fnitrogen - initrogen) - (0 - outnitrogen)) * 2 * 14                    ; Nitrogen gas nitrogen balance
  set c-co2 ((fdioxide - idioxide) - (0 - outdioxide)) * 1 * 12                            ; Carbon dixoide carbon balance
  set c-hco3 ((fbicarbonate - ibicarbonate) - (0 - outbicarbonate)) * 1 * 12               ; Bicarbonate carbon balance

  set n-obtained abs (n-nitrite + n-monoxide + n-dinitrogen + n-nitrogen + n-bacteria)     ; Total nitrogen obtained
  set n-delivered abs (n-amonium + n-nitrate)                                              ; Total nitrogen delivered
  set c-obtained abs (c-co2 + c-hco3 + c-bacteria)                                         ; Total carbon obtained
  set c-delivered abs (c-succinate)                                                        ; Total carbon delivered

  set %_e_c abs ((c-delivered - c-obtained) / c-delivered ) * 100                          ; Carbon general mass balance porcentual error
  set %_e_n abs ((n-delivered - n-obtained) / n-delivered ) * 100                          ; Nitrogen general mass balance porcentual error
  set yc/c abs (c-bacteria / c-succinate)                                                  ; Population Yield growth
end 

; ____________________________ Run Proceeding to Virtual Bioreactor __________________________________________________________________________

to go
  tick                                                                 ; Start tick counter
  set Araujo ticks
  ifelse Araujo = 1 [reset-timer] [ ]
  stir                                                                 ; Observer procedure to stablish quantities for outflow in batch and continuos culture.
  outflow                                                              ; Observer and patch procedure to make outflow from bioreactor in continuos culture with or without culture medium homogenization
  inflow                                                               ; Observer procedure to simulate input nutrients to bioreactor according to dilution ratio with or without culture medium homogenization
  maintenance-requirements                                             ; Observer procedure to calculate maintenance requirements for aerobic and anaerobic phases.

  ask bacteria
  [
    uptake                                                             ; Agent procedure, each time step the bacteria establish their uptake capacities of all nutrients
    ifelse oxygen-medium >= abs random-normal NOX (DST * NOX)          ; Agent procedure, according to oxygen local concentration runs different metabolic pathways
    [mant-aerobic][mant-anoxic1]
    metabolism_end                                                     ; Agent procedure, after cellular maintenance and biomass synthesis the uptaked nutrient quantities are updated
    bipartition                                                        ; Agent procedure, after execute metabolic pathways if the biomass reached the treshold valeu microorganism reproduce by bipartition
  ]

  ask bacteria [ move ]                                                ; Agent procedure, effect produced by the bioreactor agitation

  do-plotting                                                          ; Observer procedure, to setup graphical outputs
  if Output_file? = true
  [
;    if
;    ;time_now = 3 or
;    ;time_now = 4 or
;    time_now = 6 or
;    ;time_now = 7 or
;    time_now = 24 or
;    time_now = 24.5 or
;    time_now = 27 or
;    ;time_now = 28 or
;    ;time_now = 30 or
;    ;time_now = 47 or
;    ;time_now = 48 or
;    time_now = 49 or
;    ;time_now = 50 or
;    ;time_now = 51 or
;    time_now = 52 or
;    ;time_now = 53 or
;    time_now = 55 or
;    ;time_now = 71 or
;    time_now = 72 or
;    ;time_now = 74 or
;    time_now = 74.5 or
;    ;time_now = 75 or
;    ;time_now = 77 or
;    time_now = 78.5 or
;    ;time_now = 79 or
;    ;time_now = 95 or
;    ;time_now = 96 or
;    time_now = 96.5 or
;    ;time_now = 98 or
;    time_now = 99 or
;    time_now = 102 or
;    ;time_now = 119
;    time_now = 119.5
;    ;time_now = 120
;    [
      write-outputfile
      ; ]
  ]                            ; Observer procedure, write-out the all simulated data to output file.

  general_mass_balance

  if time_now >= Simulation_Time [file-close set pablo timer stop]                     ; Stop simulation if time is over and close output-file
  if (sum [succinate-medium] of patches / world) < 0 [file-close set pablo timer stop] ; Stop simulation if the succinate global concentration is lower to zero and close output-file
  if (sum [amonium-medium] of patches / world) < 0 [file-close set pablo timer stop]   ; Stop simulation if the amonium global concentration is lower to zero and close output-file
  if (sum [oxygen-medium] of patches / world) < 0 [file-close set pablo timer stop]    ; Stop simulation if the oxygen global concentration is lower to zero and close output-file
  if (sum [nitrate-medium] of patches / world) < 0 [file-close set pablo timer stop]   ; Stop simulation if the nitrate global concentration is lower to zero and close output-file
end 

; ____________________________ Proceeding to simulate bioreactor agitation over the culture medium ____________________________________________________

to stir
  set succinatemedium (sum [succinate-medium] of patches)   ; Total Succinate in culture medium [mmol]
  set amoniummedium (sum [amonium-medium] of patches)       ; Total Amonium in culture medium [mmol]
  set oxygenmedium (sum [oxygen-medium] of patches)         ; Total Oxygen in culture medium [mmol]
  set nitratemedium (sum [nitrate-medium] of patches)       ; Total Nitrate in culture medium [mmol]
  set nitritemedium (sum [nitrite-medium] of patches)       ; Total Nitrite in culture medium [mmol]
  set monoxidemedium (sum [monoxide-medium] of patches)     ; Total Nitric oxide in culture medium [mmol]
  set dinitrogenmedium (sum [dinitrogen-medium] of patches) ; Total Nitrous oxide in culture medium [mmol]
  set nitrogenmedium (sum [nitrogen] of patches)            ; Total nitrogen gas in culture medium [mmol]
  set dioxidemedium (sum [dioxide] of patches)              ; Total carbon dioxide in culture medium [mmol]
  set bicarbonatemedium (sum [bicarbonate] of patches)      ; Total bicarbonate in culture medium [mmol]

  ifelse time_now >= Time_Shutdown_O2                       ; if simulated time is lower than time_shutdown_O2
  [set d abs random-normal (di) (DST * di)]                 ; Bioreactor works in continuos culture according to dilution ratio
  [
    set d 0                                                 ; the bioreactor works in batch conditions
    if oxygenmedium > 0.2360 * world
    [set oxygenmedium 0.2360 * world]                       ; and the oxygen keep saturated conditions
  ]
  set xsc d * succinatemedium * steptime                    ; succinate outflow according to dilution ratio [mmol]
  set xam d * amoniummedium * steptime                      ; amonium outflow according to dilution ratio [mmol]
  set xox d * oxygenmedium * steptime                       ; oxygen outflow according to dilution ration [mmol]
  set xntr d * nitratemedium * steptime                     ; nitrate outflow according to dilution ration [mmol]
  set xnr d * nitritemedium * steptime                      ; nitrite outflow according to dilution ration [mmol]
  set xmn d * monoxidemedium * steptime                     ; nitric oxide outflow according to dilution ration [mmol]
  set xdn d * dinitrogenmedium * steptime                   ; nitrous oxide outflow according to dilution ration [mmol]
  set xn2 d * nitrogenmedium * steptime                     ; nitrogen gas outflow according to dilution ration [mmol]
  set xco2 d * dioxidemedium * steptime                     ; carbon dioxide outflow according to dilution ration [mmol]
  set xhco3 d * bicarbonatemedium * steptime                ; bicarbonate outflow according to dilution ration [mmol]
  if xmn >= (3.27 * world) [set xmn (3.27 * world)]         ; if nitric oxide quantity is higher than maximun saturated conditions outflow only the saturated conditions
  if xdn >= (58.27 * world) [set xdn (58.27 * world)]       ; if nitrous oxide quantity is higher than maximun saturated conditions outflow only the saturated conditions
  if xn2 >= (104.91 * world) [set xn2 (104.91 * world)]     ; if nitrogen gas quantity is higher than maximun saturated conditions outflow only the saturated conditions
  if xco2 >= (8009.05 * world) [set xco2 (8009.05 * world)] ; if carbon dioxide quantity is higher than maximun saturated conditions outflow only the saturated conditions

  let bactout (sum [biomass] of bacteria)                   ; Total biomass in culture medium [mmol]
  let xbact (d * bactout * steptime)                        ; biomass outflow according to dilution ratio [mmol]
  let prom (count bacteria / bactout)                       ; average individual per biomass in outflow [individual ml /mg]
  set bacteriaout round (xbact * prom)                      ; Microorganism quantity to outflow [individuals]
  let monp (bactout / count bacteria)                       ; average biomass per individual in outflow [mg / ml individual]
  set xbacteria (monp * bacteriaout)                        ; Microorganism biomass concentration to outflow [mmol]

  outflow_balance
end 

; ____________________________ Proceeding to simulate reactor OutFlow ________________________________________________________________________________________

to outflow
  set q random 2
  ifelse q = 0 [
   ask patches [
    set succinate-medium (succinatemedium - xsc) / world      ; The succinate outflow quantity is taken from global quantity and then homogenization occurs.
    set amonium-medium (amoniummedium - xam) / world          ; The amonium outflow quantity is taken from global quantity and then homogenization occurs.
    set oxygen-medium (oxygenmedium) / world                  ; Agitation and homogenization of oxygen
    set nitrate-medium (nitratemedium - xntr) / world         ; The nitrate outflow quantity is taken from global quantity and then homogenization occurs.
    set nitrite-medium (nitritemedium - xnr) / world          ; The nitrite outflow quantity is taken from global quantity and then homogenization occurs.
    set monoxide-medium (monoxidemedium - xmn) / world        ; The nitric oxide outflow quantity is taken from global quantity and then homogenization occurs.
    set dinitrogen-medium (dinitrogenmedium - xdn) / world    ; The nitrous oxide outflow quantity is taken from global quantity and then homogenization occurs.
    set nitrogen (nitrogenmedium - xn2) / world               ; The nitrogen gas outflow quantity is taken from global quantity and then homogenization occurs.
    set dioxide (dioxidemedium - xco2 ) / world               ; The carbon dioxide outflow quantity is taken from global quantity and then homogenization occurs.
    set bicarbonate (bicarbonatemedium - xhco3) / world       ; The bicarbonate outflow quantity is taken from global quantity and then homogenization occurs.
    set pcolor scale-color blue succinate-medium 0 Succinate
    ]
  ]
  [
    ask patches [
    set succinate-medium succinate-medium - (xsc / world)     ; The succinate outflow concentration is taken from local quantity without homogenization.
    set amonium-medium amonium-medium - (xam / world)         ; The amonium outflow concentration is taken from local quantity without homogenization.
    set oxygen-medium (oxygenmedium) / world                  ; Agitation and homogenization of oxygen
    set nitrate-medium nitrate-medium - (xntr / world)        ; The nitrate outflow concentration is taken from local quantity without homogenization.
    set nitrite-medium nitrite-medium - (xnr / world)         ; The nitrite outflow concentration is taken from local quantity without homogenization.
    set monoxide-medium monoxide-medium - (xmn / world)       ; The nitric oxide outflow concentration is taken from local quantity without homogenization.
    set dinitrogen-medium dinitrogen-medium - (xdn / world)   ; The nitrous oxide outflow concentration is taken from local quantity without homogenization.
    set nitrogen nitrogen - (xn2 / world)                     ; The nitrogen gas outflow concentration is taken from local quantity without homogenization.
    set dioxide dioxide - (xco2 / world)                      ; The carbon dioxide outflow concentration is taken from local quantity without homogenization.
    set bicarbonate bicarbonate - (xhco3 / world)             ; The bicarbonate outflow concentration is taken from local quantity without homogenization.
    set pcolor scale-color blue succinate-medium 0 Succinate
    ]
  ]
  ask n-of bacteriaout bacteria [ die ]                       ; Choose random bacteria and outflow accord to reactor dilution ratio
end 

; __________________________________ Proceeding to simulate reactor Inflow ____________________________________________________________________________________

to inflow
  set succinate-input d * world * Succinate * steptime                        ; Succinate inflow to continuos culture according to the slider labed succinate [mmol]
  set amonium-input d * world * Amonium * steptime                            ; Amonium inflow to continuos culture according to the slider labed amonium [mmol]
  set nitrate-input d * world * Nitrate * steptime                            ; Nitrate inflow to continuos culture according to the slider labed nitrate [mmol]

  set succinatemedium (sum [succinate-medium] of patches) + (succinate-input) ; Total Succinate in culture medium after inflow [mmol]
  set amoniummedium (sum [amonium-medium] of patches) + (amonium-input)       ; Total Amonium in culture medium after inflow [mmol]
  set nitratemedium (sum [nitrate-medium] of patches) + (nitrate-input)       ; Total Nitrate in culture medium after inflow [mmol]
  if time_now <= Time_Shutdown_O2 [set oxygenmedium 0.2360 * world]

  inflow_balance

  ifelse q = 0
  [ ask patches
   [ set succinate-medium succinatemedium / world                                ; The succinate inflow quantity is added to global quantity and then homogenization occurs.
     set amonium-medium amoniummedium / world                                    ; The amonium inflow quantity is added to global quantity and then homogenization occurs.
     set oxygen-medium oxygenmedium / world                                      ; The oxygen inflow quantity is added to global quantity and then homogenization occurs.
     set nitrate-medium nitratemedium / world                                    ; The nitrate inflow quantity is added to global quantity and then homogenization occurs.
     set pcolor scale-color blue succinate-medium 0 Succinate
   ]
  ]
  [ ask patches
   [ set succinate-medium succinate-medium + (succinate-input / world)           ; The succinate inflow concentration is added to local quantity without homogenization.
     set amonium-medium amonium-medium + (amonium-input / world)                 ; The amonium inflow concentration is added to local quantity without homogenization.
     set oxygen-medium oxygenmedium / world
     set nitrate-medium nitrate-medium + (nitrate-input / world)                 ; The nitrate inflow concentration is added to local quantity without homogenization.
     set pcolor scale-color blue succinate-medium 0 Succinate
    ]
  ]
end 

; ____________________________ Maintenance Requirements for aerobic and anaerobic phases __________________________________________________________________________

to maintenance-requirements

ifelse time_now <= Time_Shutdown_O2
  [                                                               ; 1/14 (C4H4O4)2- + 1/4 O2 -> 1/7 CO2 + 1/7 HCO3- + 1/14 H2O
    set scm (energy_maintenance_a * steptime  * 36.033 / 48.044)  ; [mol succinate / molBiomass]
    set oxm (scm * 0.25 / 0.0714)                                 ; [mol oxygen / molBiomass ]
  ]
  [                                                               ; 1/14 (C4H4O4)2- + 1/2 NO3- -> 1/7 CO2 + 1/7 HCO3- + 1/2 NO2- + 1/14 H2O
    set scm (energy_maintenance_x * steptime * 36.033 / 48.044)   ; [mol succinate / molBiomass ]
    set ntrm (scm * 0.50 / 0.0714)                                ; [mol nitrate / molBiomass ]
  ]
end 

; ____________________________ Uptake proceeding according the core model INDISM __________________________________________________________________________

to uptake
  let uptsc (abs (random-normal (uSc) (DST * uSc)) * biomass * steptime)                ; [mmo] succinate by biomass uptake accord to INDISIM
  let uptam (abs (random-normal (uam) (DST * uam)) * biomass * steptime)                ; [mmol] amonium by biomass uptake accord to INDISIM
  let uptox (abs (random-normal (uox) (DST * uox)) * biomass * steptime)                ; [mmol] oxygen by biomass uptake accord to INDISIM
  ifelse time_now <= Time_Shutdown_O2 [set untri uNO3-a][set untri uNO3-x]              ; The microorganism takes different uptake coefficient for aerobic and anaerobic phase.
  let uptntr (abs (random-normal (untri) (DST * untri)) * biomass * steptime)           ; [mmol] nitrate by biomass uptake accord to INDISIM
  let uptnr (abs (random-normal (uNO2-) (DST * uNO2-)) * biomass * steptime)            ; [mmol] nitrite by biomass uptake accord to INDISIM
  let uptmn (abs (random-normal (uNO) (DST * uNO)) * biomass * steptime)                ; [mmol] nitric oxide by biomass uptake accord to INDISIM
  let uptdn (abs (random-normal (uN2O) (DST * uN2O)) * biomass * steptime)              ; [mmol] nitrous oxide by biomass uptake accord to INDISIM

  let sc-available (nsc * succinate-medium * k_avail)                                   ; INDISIM lineal model to determine succinate availability in culture medium [mmol]
  let am-available (nam * amonium-medium * k_avail )                                    ; INDISIM lineal model to determine amonium availability in culture medium [mmol]
  let ox-available (nx * oxygen-medium * k_avail )                                      ; INDISIM lineal model to determine oxygen availability in culture medium [mmol]
  let ntr-available (nntr * nitrate-medium * k_avail )                                  ; INDISIM lineal model to determine nitrate availability in culture medium [mmol]
  let nr-available (nnr * nitrite-medium * k_avail )                                    ; INDISIM lineal model to determine nitrite availability in culture medium [mmol]
  let mn-available (nmn * monoxide-medium * k_avail )                                   ; INDISIM lineal model to determine nitric oxide availability in culture medium [mmol]
  let dn-available (ndn * dinitrogen-medium * k_avail )                                 ; INDISIM lineal model to determine nitrous oxide availability in culture medium [mmol]

  ifelse sc-available <= uptsc [set sc-useful sc-available] [set sc-useful uptsc]       ; For succinate comparation between uptake by biomass and availability and takes the lowest value.
  ifelse am-available <= uptam [set am-useful am-available] [set am-useful uptam]       ; For amonium comparation between uptake by biomass and availability and takes the lowest value.
  ifelse ox-available <= uptox [set ox-useful ox-available] [set ox-useful uptox]       ; For oxygen comparation between uptake by biomass and availability and takes the lowest value.
  ifelse ntr-available <= uptntr [set ntr-useful ntr-available] [set ntr-useful uptntr] ; For nitrate comparation between uptake by biomass and availability and takes the lowest value.
  ifelse nr-available <= uptnr [set nr-useful nr-available] [set nr-useful uptnr]       ; For nitrite comparation between uptake by biomass and availability and takes the lowest value.
  ifelse mn-available <= uptmn [set mn-useful mn-available] [set mn-useful uptmn]       ; For nitric oxide comparation between uptake by biomass and availability and takes the lowest value.
  ifelse dn-available <= uptdn [set dn-useful dn-available] [set dn-useful uptdn]       ; For nitrous oxide comparation between uptake by biomass and availability and takes the lowest value.

  set succinate-medium (succinate-medium - sc-useful)                                   ; Update local quantity of succinate
  set amonium-medium (amonium-medium - am-useful)                                       ; Update local quantity of amonium
  set oxygen-medium (oxygen-medium - ox-useful)                                         ; Update local quantity of oxygen
  set nitrate-medium (nitrate-medium - ntr-useful)                                      ; Update local quantity of nitrate
  set nitrite-medium (nitrite-medium - nr-useful)                                       ; Update local quantity of nitrite
  set monoxide-medium (monoxide-medium - mn-useful)                                     ; Update local quantity of nitric oxide
  set dinitrogen-medium (dinitrogen-medium - dn-useful)                                 ; Update local quantity of nitrous oxide
end 

; ____________________________ Aerobic phase proceeding according to TEEM2 __________________________________________________________________________
; ____________________________ Aerobic Maintenance __________________________________________________________________________________________________

to mant-aerobic                                                          ; 1/14 (C4H4O4)2- + 1/4 O2 -> 1/7 CO2 + 1/7 HCO3- + 1/14 H2O
  let sc-mant (scm * biomass)                                            ; Succinate celullar maintenance requirements by biomass [mmol]
  let ox-mant (oxm * biomass)                                            ; Oxygen cellular maintenance requirements by biomass [mmol]

  let y min (list sc-mant sc-useful)                                     ; takes the minimum value between maintenance requirements and uptake quantity for Succinate [mmol]
  let z min (list ox-mant ox-useful)                                     ; takes the minimum value between maintenance requirements and uptake quantity for Oxygen [mmol]

  let y1 (y / 0.0714)                                                    ; succinate quantity by stoichometric coefficient
  let z1 (z / 0.25)                                                      ; oxygen quantity by stoichiometric coefficient

  let w1 min (list y1 z1)                                                ; limiting nutrient for aerobic maintenance

  let ndioxide (0.1428 * w1)                                             ; Carbon dioxide generation by cellular maintenance [mmol]
  let nbicarbonate (0.1428 * w1)                                         ; Bicarbonate generation by cellular maintenance [mmol]
  set dioxide (dioxide + ndioxide)                                       ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)                           ; Bicarbonate local quantity update

  set sc-useful (sc-useful - 0.0714 * w1)                                ; Update of Succinate uptaked  [mmol]
  set ox-useful (ox-useful - 0.25 * w1)                                  ; Update of Oxygen uptaked [mmol]
  set m_aero m_aero + 1                                                  ; counter to maintenance reaction on aerobic phase

  if (sc-useful > 0) and (am-useful > 0) and (ox-useful > 0) [aerobic1]  ; if uptaken updated quantities are higher than zero the microorganism could execute first aerobic parthway
  if (sc-useful > 0) and (am-useful > 0) and (ntr-useful > 0) [aerobic2] ; if uptaken updated quantities are higher than zero the microorganism could execute second aerobic parthway
end 

; ______________________________ Aerobic Sinthesis ______________________________________________________________________________________________________

to aerobic1 ; 0.0714 (C4H4O4)2- + 0.0431 NH4+ + 0.0740 O2 ->  0.0575 C3H5.4N0.75O1.45 + 0.0136 CO2 + 0.0998 HCO3- + 0.0240 H2O adjusted by TEEM2 (McCarty, 2007)
  let a (sc-useful / 0.0714)                                             ; uptaken succinate updated divided by its stoichiometric coefficient
  let b (am-useful / 0.0431)                                             ; uptaken amonium updated divided by its stoichiometric coefficient
  let c (ox-useful / 0.0740)                                             ; uptaken oxygen updated divided by its stoichiometric coefficient

  let x1 min (list a b c)                                                ; limiting nutrient for pathway 1 in aerobic phase

  let nbiomass 0.0575 * x1                                               ; Biomass generation by aerobic pathway 1 [mmol]
  let ndioxide 0.0136 * x1                                               ; Carbon dioxide generation by aerobic pathway 1 [mmol]
  let nbicarbonate 0.0998 * x1                                           ; Bicarbonate generation by aerobic pathway 1 [mmol]
  set biomass (biomass + nbiomass)                                       ; Individual biomass update
  set dioxide (dioxide + ndioxide)                                       ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)                           ; Bicarbonate local quantity update

  set sc-useful (sc-useful - 0.0714 * x1)                                ; update electron donor bacterium quantity
  set am-useful (am-useful - 0.0431 * x1)                                ; update N-source bacterium quantity
  set ox-useful (ox-useful - 0.0740 * x1)                                ; update electron aceptor bacterium quantity
  set s_aero_1 s_aero_1 + 1                                              ; counter to pathway 1 on aerobic phase

  if (sc-useful > 0) and (am-useful > 0) and (ntr-useful > 0) [aerobic2] ; if uptaken updated quantities are higher than zero the microorganism could execute second aerobic parthway
end 

to aerobic2 ; 0.0714 (C4H4O4)2- + 0.0429 NH4+ + 0.0374 NO3- + 0.0748 H+ + 0.0132 H2O ->  0.0572 C3H5.4N0.75O1.45 + 0.0141 CO2 + 0.0999 HCO3- + 0.0374 NH4+ adjusted by TEEM2 (McCarty, 2007)
  let a (sc-useful / 0.0714)                     ; uptaken succinate updated divided by its stoichiometric coefficient
  let b (am-useful / 0.0429)                     ; uptaken amonium updated divided by its stoichiometric coefficient
  let c (ntr-useful / 0.0374)                    ; uptaken nitrate updated divided by its stoichiometric coefficient

  let x2 min (list a b c)                        ; limiting nutrient for pathway 2 in aerobic phase

  let nbiomass 0.0572 * x2                       ; Biomass generation by aerobic pathway 2 [mmol]
  let ndioxide 0.0141 * x2                       ; Carbon dioxide generation by aerobic pathway 2 [mmol]
  let namonium 0.0374 * x2                       ; Amonium generation by aerobic pathway 2 [mmol]
  let nbicarbonate 0.0999 * x2                   ; Bicarbonate generation by aerobic pathway 1 [mmol]
  set biomass (biomass + nbiomass)               ; Individual biomass update
  set dioxide (dioxide + ndioxide)               ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)   ; Bicarbonate local quantity update
  set amonium-medium (amonium-medium + namonium) ; Amonium uptake quantity update

  set sc-useful (sc-useful - 0.0714 * x2)        ; update electron donor bacterium quantity
  set am-useful (am-useful - 0.0429 * x2)        ; update N-source bacterium quantity
  set ntr-useful (ntr-useful - 0.0374 * x2)      ; update electron aceptor bacterium quantity
  set s_aero_2 s_aero_2 + 1                      ; counter to pathway 2 on aerobic phase
end 

; ____________________________ Anaerobic phase proceeding ________________________________________________________________________________________________________
; _____________________ Anoxics reactions are execute according to Reduction Order _______________________________________________________________________________
; _____________________________Cellular maintenance to anoxic reaction 1 _________________________________________________________________________________________

to mant-anoxic1                                  ; 1/14 (C4H4O4)2- + 1/2 NO3- -> 1/7 CO2 + 1/7 HCO3- + 1/2 NO2- + 1/14 H2O

  let sc-mant (scm * biomass)                    ; Succinate celullar maintenance requirements by biomass [mmol]
  let ntr-mant (ntrm * biomass)                  ; Nitrate celullar maintenance requirements by biomass [mmol]

  let y min (list sc-mant sc-useful)             ; takes the minimum value between maintenance requirements and uptake quantity for Succinate [mmol]
  let z min (list ntr-mant ntr-useful)           ; takes the minimum value between maintenance requirements and uptake quantity for Nitrate [mmol]

  let y1 (y / 0.0714)                            ; Succinate quantity by stoichometric coefficient
  let z1 (z / 0.50)                              ; Nitrate quantity by stoichometric coefficient
  let w1 min (list y1 z1)                        ; limiting nutrient for first anaerobic maintenance

  let ndioxide 0.1428 * w1                       ; Carbon dioxide generation by cellular maintenance [mmol]
  let nbicarbonate 0.1428 * w1                   ; Bicarbonate generation by cellular maintenance [mmol]
  let nnitrite 0.50 * w1                         ; Nitrite generation by cellular maintenance [mmol]
  set dioxide (dioxide + ndioxide)               ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)   ; Bicarbonate local quantity update

  if ntr-mant > ntr-useful [set sc-mant2 sc-mant - 0.0714 * w1 ] ; Maintenance control

  set nr-useful (nr-useful + nnitrite)          ; Uptaken nitrite updated
  set sc-useful (sc-useful - 0.0714 * w1)       ; Update of Succinate uptaked  [mmol]
  set ntr-useful (ntr-useful - 0.50 * w1)       ; Update of Nitrate uptaked  [mmol]

  set m_anox_1 m_anox_1 + 1                     ; counter to first maintenance reaction on anaerobic phase

  if sc-useful <= 0 [stop]                      ; if the succinate uptaken is lower than zero stop the microorganism metabolism until the next step time
  ifelse sc-mant2 > 0 [mant-anoxic2] [anoxic1]  ; if maintenance is fullfiled go to biomass synthesis procedures
end 

; _____________________________Cellular maintenance to anoxic reaction 2 _________________________________________________________________________________________

to mant-anoxic2                                     ; 1/14 (C4H4O4)2- + NO2- -> 1/7 CO2 + 1/7 HCO3- + NO + 4/7 H2O

  let nr-mant2 (sc-mant2 * 1.0 / 0.0714)            ; nitrite maintenance requirements from succinate maintenance requirements

  let y min (list sc-mant2 sc-useful)               ; takes the minimum value between maintenance requirements and remaining uptaken quantity for Succinate [mmol]
  let z min (list nr-mant2 nr-useful)               ; takes the minimum value between maintenance requirements and uptake quantity for nitrite [mmol]

  let y1 (y / 0.0714)                               ; Succinate quantity by stoichometric coefficient
  let z1 (z / 1.0)                                  ; Nitrite quantity by stoichometric coefficient
  let w2 min (list y1 z1)                           ; limiting nutrient for second anaerobic maintenance

  let ndioxide 0.1428 * w2                          ; Carbon dioxide generation by cellular maintenance [mmol]
  let nbicarbonate 0.1428 * w2                      ; Bicarbonate generation by cellular maintenance [mmol]
  let nmonoxide 1.0 * w2                            ; Nitric oxide generation by cellular maintenance [mmol]
  set dioxide (dioxide + ndioxide)                  ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)      ; Bicarbonate local quantity update
  set monoxide-medium (monoxide-medium + nmonoxide) ; Nitric oxide generation release to culture medium

  if  nr-mant2 > nr-useful [set sc-mant3 sc-mant2 - 0.0714 * w2 ] ; Maintenance control

  set sc-useful (sc-useful - w2 * 0.0714)           ; Update of Succinate uptaken  [mmol]
  set nr-useful (nr-useful - w2 * 1)                ; Update of Nitrite uptaken  [mmol]

  set m_anox_2 m_anox_2 + 1                         ; counter to second maintenance reaction on anaerobic phase

  if sc-useful <= 0 [stop]                          ; if the succinate uptaken is lower than zero stop the microorganism metabolism until the next step time
  ifelse sc-mant3 > 0 [mant-anoxic3] [anoxic2]      ; if maintenance is fullfiled go to biomass synthesis procedures
end 

; _____________________________Cellular maintenance to anoxic reaction 3 _________________________________________________________________________________________

to mant-anoxic3                                           ; 1/14 (C4H4O4)2- + NO -> 1/7 CO2 + 1/7 HCO3- + 1/2 N2O + 1/14 H2O

  let mn-mant3 (sc-mant3 * 1.0 / 0.0714)                  ; nitric oxide maintenance requirements from succinate maintenance requirements

  let y min (list sc-mant3 sc-useful)                     ; takes the minimum value between maintenance requirements and remaining uptaken quantity for Succinate [mmol]
  let z min (list mn-mant3 mn-useful)                     ; takes the minimum value between maintenance requirements and uptake quantity for nitric oxide [mmol]

  let y1 (y / 0.0714)                                     ; Succinate quantity by stoichometric coefficient
  let z1 (z / 1.0)                                        ; Nitric oxide quantity by stoichometric coefficient
  let w3 min (list y1 z1)                                 ; limiting nutrient for third anaerobic maintenance

  let ndioxide 0.1428 * w3                                ; Carbon dioxide generation by cellular maintenance [mmol]
  let nbicarbonate 0.1428 * w3                            ; Bicarbonate generation by cellular maintenance [mmol]
  let ndinitrogen 0.5 * w3                                ; Nitrous oxide generation by cellular maintenance [mmol]
  set dioxide (dioxide + ndioxide)                        ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)            ; Bicarbonate local quantity update
  set dinitrogen-medium (dinitrogen-medium + ndinitrogen) ; Nitrous oxide generation release to culture medium

  if mn-mant3 >= mn-useful [set sc-mant4 sc-mant3 - 0.0714 * w3 ] ; Maintenance control

  set sc-useful (sc-useful - w3 * 0.0714)                 ; Update of Succinate uptaken  [mmol]
  set mn-useful (mn-useful - w3 * 1)                      ; Update of Nitric oxide uptaken  [mmol]

  set m_anox_3 m_anox_3 + 1                               ; counter to third maintenance reaction on anaerobic phase

  if sc-useful <= 0 [stop]                                ; if the succinate uptaken is lower than zero stop the microorganism metabolism until the next step time
  ifelse sc-mant4 > 0 [mant-anoxic4] [anoxic3]            ; if maintenance is fullfiled go to biomass synthesis procedures
end 

; _____________________________Cellular maintenance to anoxic reaction 4 _________________________________________________________________________________________

to mant-anoxic4                                ; 1/14 (C4H4O4)2- + 1/2 N2O -> 1/7 CO2 + 1/7 HCO3- + 1/2 N2 + 1/14 H2O

  let dn-mant (sc-mant4 * 0.5 / 0.0714)        ; nitrous oxide maintenance requirements from succinate maintenance requirements

  let y min (list sc-mant4 sc-useful)          ; takes the minimum value between maintenance requirements and remaining uptaken quantity for Succinate [mmol]
  let z min (list dn-mant dn-useful)           ; takes the minimum value between maintenance requirements and uptake quantity for nitrous oxide [mmol]

  let y1 (y / 0.0714)                          ; Succinate quantity by stoichometric coefficient
  let z1 (z / 0.50)                            ; Nitrous oxide quantity by stoichometric coefficient
  let w4 min (list y1 z1)                      ; limiting nutrient for fourth anaerobic maintenance

  let ndioxide 0.1428 * w4                     ; Carbon dioxide generation by cellular maintenance [mmol]
  let nbicarbonate 0.1428 * w4                 ; Bicarbonate generation by cellular maintenance [mmol]
  let nnitrogen 0.5 * w4                       ; Nitrogen gas generation by cellular maintenance [mmol]
  set dioxide (dioxide + ndioxide)             ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate) ; Bicarbonate local quantity update
  set nitrogen nitrogen + nnitrogen            ; Nitrogen gas local quantity update

  set sc-useful (sc-useful - w4 * 0.0714)      ; Update of Succinate uptaken  [mmol]
  set dn-useful (dn-useful - w4 * 0.5)         ; Update of Nitrous oxide uptaken  [mmol]

  set m_anox_4 m_anox_4 + 1                    ; counter to fourth maintenance reaction on anaerobic phase

  ifelse (sc-useful > 0) and (am-useful > 0) and (dn-useful > 0) [anoxic4][stop] ; if maintenance is fullfiled go to biomass synthesis procedures
end 

; _____________________ Anoxics reactions are execute according to Reduction Order _______________________________________________________________________________
; _____________________________ Biomass Synthesis to anoxic reaction 1 ___________________________________________________________________________________________

to anoxic1 ; 0.0714 (C4H4O4)2- + 0.0214 NH4+ + 0.3250 NO3- ->  0.0286 C3H5.4N0.75O1.45 + 0.3250 NO2- + 0.0786 CO2 + 0.1214 HCO3- + 0.0479 H2O adjusted by TEEM2 (McCarty, 2007)

  let a (sc-useful / 0.0714)                                           ; uptaken succinate updated divided by its stoichiometric coefficient
  let b (am-useful / 0.0214)                                           ; uptaken amonium updated divided by its stoichiometric coefficient
  let c (ntr-useful / 0.3250)                                          ; uptaken nitrate updated divided by its stoichiometric coefficient

  let x1 min (list a b c)                                              ; limiting nutrient for enzimatic reaction 1 on pathway 3 in anaerobic phase

  let nbiomass 0.0286 * x1                                             ; Biomass generation for enzimatic reaction 1 on pathway 3 [mmol]
  let ndioxide 0.0786 * x1                                             ; Carbon dioxide generation for enzimatic reaction 1 on pathway 3 [mmol]
  let nnitrite 0.3250 * x1                                             ; Nitrite generation for enzimatic reaction 1 on pathway 3 [mmol]
  let nbicarbonate 0.1214 * x1                                         ; Bicarbonate generation for enzimatic reaction 1 on pathway 3 [mmol]
  set biomass (biomass + nbiomass)                                     ; Individual biomass update
  set dioxide (dioxide + ndioxide)                                     ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)                         ; Bicarbonate local quantity update
  set nr-useful (nr-useful + nnitrite)                                 ; Update of nitrite uptaken

  set sc-useful (sc-useful - 0.0714 * x1)                              ; update electron donor bacterium quantity
  set am-useful (am-useful - 0.0214 * x1)                              ; update N-source bacterium quantity
  set ntr-useful (ntr-useful - 0.3250 * x1)                            ; update electron aceptor bacterium quantity
  set s_anox_1 s_anox_1 + 1                                            ; counter to first biomass synthesis reaction on anaerobic phase

  if (sc-useful > 0) and (am-useful > 0) and (nr-useful > 0) [anoxic2] ; if the succinate, amonium and nitrite quatities are enough go to enzimatic reaction 2
  if (sc-useful > 0) and (am-useful > 0) and (mn-useful > 0) [anoxic3] ; if the succinate, amonium and nitric oxide quatities are enough go to enzimatic reaction 3
  if (sc-useful > 0) and (am-useful > 0) and (dn-useful > 0) [anoxic4] ; if the succinate, amonium and nitrous oxide quatities are enough go to enzimatic reaction 4
end 

; _____________________________ Biomass Synthesis to anoxic reaction 2 ___________________________________________________________________________________________

to anoxic2 ; 0.0714 (C4H4O4)2- + 0.0413 NH4+ + 0.3250 NO2- + 0.3250 H+ ->  0.0551 C3H5.4N0.75O1.45 + 0.3250 NO + 0.0189 CO2 + 0.1015 HCO3- + 0.1885 H2O adjusted by TEEM2 (McCarty, 2007)

  let a (sc-useful / 0.0714)                                           ; uptaken succinate updated divided by its stoichiometric coefficient
  let b (am-useful / 0.0413)                                           ; uptaken amonium updated divided by its stoichiometric coefficient
  let c (nr-useful / 0.3250)                                           ; uptaken nitrite updated divided by its stoichiometric coefficient

  let x2 min (list a b c)                                              ; limiting nutrient for enzimatic reaction 2 on pathway 3 in anaerobic phase

  let nbiomass 0.0551 * x2                                             ; Biomass generation for enzimatic reaction 2 on pathway 3 [mmol]
  let ndioxide 0.0189 * x2                                             ; Carbon dioxide generation for enzimatic reaction 2 on pathway 3 [mmol]
  let nmonoxide 0.3250 * x2                                            ; Nitric oxide generation for enzimatic reaction 2 on pathway 3 [mmol]
  let nbicarbonate 0.1015 * x2                                         ; Bicarbonate generation for enzimatic reaction 2 on pathway 3 [mmol]
  set biomass (biomass + nbiomass)                                     ; Individual biomass update
  set dioxide (dioxide + ndioxide)                                     ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)                         ; Bicarbonate local quantity update
  set mn-useful (mn-useful + nmonoxide)                                ; Update of nitric oxide uptaken

  set sc-useful (sc-useful - 0.0714 * x2)                              ; update electron donor bacterium quantity
  set am-useful (am-useful - 0.0413 * x2)                              ; update N-source bacterium quantity
  set nr-useful (nr-useful - 0.3250 * x2)                              ; update electron aceptor bacterium quantity
  set s_anox_2 s_anox_2 + 1                                            ; counter to second biomass synthesis reaction on anaerobic phase

  if (sc-useful > 0) and (am-useful > 0) and (mn-useful > 0)[anoxic3]  ; if the succinate, amonium and nitric oxide quatities are enough go to enzimatic reaction 3
  if (sc-useful > 0) and (am-useful > 0) and (dn-useful > 0)[anoxic4]  ; if the succinate, amonium and nitrous oxide quatities are enough go to enzimatic reaction 4
end 

; _____________________________ Biomass Synthesis to anoxic reaction 3 ___________________________________________________________________________________________

to anoxic3 ; 0.0714 (C4H4O4)2- + 0.0413 NH4+ + 0.3250 NO ->  0.0551 C3H5.4N0.75O1.45 + 0.1625 N2O + 0.0189 CO2 + 0.1015 HCO3- + 0.0260 H2O adjusted by TEEM2 (McCarty, 2007)

  let a (sc-useful / 0.0714)                                           ; uptaken succinate updated divided by its stoichiometric coefficient
  let b (am-useful / 0.0413)                                           ; uptaken amonium updated divided by its stoichiometric coefficient
  let c (mn-useful / 0.3250)                                           ; uptaken nitric oxide updated divided by its stoichiometric coefficient

  let x3 min (list a b c)                                              ; limiting nutrient for enzimatic reaction 3 on pathway 3 in anaerobic phase

  let nbiomass 0.0551 * x3                                             ; Biomass generation for enzimatic reaction 3 on pathway 3 [mmol]
  let ndioxide 0.0189 * x3                                             ; Carbon dioxide generation for enzimatic reaction 3 on pathway 3 [mmol]
  let ndinitrogen 0.1625 * x3                                          ; Nitrous oxide generation for enzimatic reaction 3 on pathway 3 [mmol]
  let nbicarbonate 0.1015 * x3                                         ; Bicarbonate generation for enzimatic reaction 3 on pathway 3 [mmol]
  set biomass (biomass + nbiomass)                                     ; Individual biomass update
  set dioxide (dioxide + ndioxide)                                     ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)                         ; Bicarbonate local quantity update
  set dn-useful (dn-useful + ndinitrogen)                              ; Update of nitrous oxide uptaken

  set sc-useful (sc-useful - 0.0714 * x3)                              ; update electron donor bacterium quantity
  set am-useful (am-useful - 0.0413 * x3)                              ; update N-source bacterium quantity
  set mn-useful (mn-useful - 0.3250 * x3)                              ; update electron aceptor bacterium quantity
  set s_anox_3 s_anox_3 + 1                                            ; counter to third biomass synthesis reaction on anaerobic phase

  if (sc-useful > 0) and (am-useful > 0) and (dn-useful > 0)[anoxic4]  ; if the succinate, amonium and nitrous oxide quatities are enough go to enzimatic reaction 4
end 

; _____________________________ Biomass Synthesis to anoxic reaction 4 ___________________________________________________________________________________________

to anoxic4 ; 0.0714 (C4H4O4)2- + 0.0413 NH4+ + 0.1625 N2O ->  0.0551 C3H5.4N0.75O1.45 + 0.1625 N2 + 0.0189 CO2 + 0.1015 HCO3- + 0.0260 H2O adjusted by TEEM2 (McCarty, 2007)

  let a (sc-useful / 0.0714)                                         ; uptaken succinate updated divided by its stoichiometric coefficient
  let b (am-useful / 0.0413)                                         ; uptaken amonium updated divided by its stoichiometric coefficient
  let c (dn-useful / 0.1625)                                         ; uptaken nitrous oxide updated divided by its stoichiometric coefficient

  let x4 min (list a b c)                                            ; limiting nutrient for enzimatic reaction 4 on pathway 3 in anaerobic phase

  let nbiomass 0.0551 * x4                                           ; Biomass generation for enzimatic reaction 4 on pathway 3 [mmol]
  let ndioxide 0.0189 * x4                                           ; Carbon dioxide generation for enzimatic reaction 4 on pathway 3 [mmol]
  let nnitrogen 0.1625 * x4                                          ; Nitrogen gas generation for enzimatic reaction 4 on pathway 3 [mmol]
  let nbicarbonate 0.1015 * x4                                       ; Bicarbonate generation for enzimatic reaction 4 on pathway 3 [mmol]
  set biomass (biomass + nbiomass)                                   ; Individual biomass update
  set dioxide (dioxide + ndioxide)                                   ; Carbon dioxide local quantity update
  set bicarbonate (bicarbonate + nbicarbonate)                       ; Bicarbonate local quantity update
  set nitrogen (nitrogen + nnitrogen)                                ; Nitrogen gas local quantity update

  set sc-useful (sc-useful - 0.0714 * x4)                            ; update electron donor bacterium quantity
  set am-useful (am-useful - 0.0413 * x4)                            ; update N-source bacterium quantity
  set dn-useful (dn-useful - 0.1625 * x4)                            ; update electron aceptor bacterium quantity
  set s_anox_4 s_anox_4 + 1                                          ; counter to fourth biomass synthesis reaction on anaerobic phase
end 

; ____________________________ Procedure before bipartition _______________________________________________________________________________________________

to metabolism_end
  ifelse sc-useful > 0 [set succinate-medium (succinate-medium + sc-useful) set sc-useful 0][set sc-useful 0]   ; Release to culture medium the quantity not used
  ifelse am-useful > 0 [set amonium-medium (amonium-medium + am-useful) set am-useful 0][set am-useful 0]       ; Release to culture medium the quantity not used
  ifelse ox-useful > 0 [set oxygen-medium (oxygen-medium + ox-useful) set ox-useful 0][set ox-useful 0]         ; Release to culture medium the quantity not used
  ifelse ntr-useful > 0 [set nitrate-medium (nitrate-medium + ntr-useful) set ntr-useful 0][set ntr-useful 0]   ; Release to culture medium the quantity not used
  ifelse nr-useful > 0 [set nitrite-medium (nitrite-medium + nr-useful) set nr-useful 0][set nr-useful 0]       ; Release to culture medium the quantity not used
  ifelse mn-useful > 0 [set monoxide-medium (monoxide-medium + mn-useful) set mn-useful 0][set mn-useful 0]     ; Release to culture medium the quantity not used
  ifelse dn-useful > 0 [set dinitrogen-medium (dinitrogen-medium + dn-useful) set dn-useful 0][set dn-useful 0] ; Release to culture medium the quantity not used
  set sc-mant2 0 set sc-mant3 0 set sc-mant4 0                                                                  ; Update to zero succinate internal maintenance requirements
end 

; ____________________________ Bipartition Procedure _______________________________________________________________________________________________

to bipartition
  if biomass >= biomass-reproduction                                ; cell division happens when a treshold value is reached
  [
    let division-proportioning random-normal 0.50 (DSTr * 0.50)     ; new bacteria differ randomly in their cell-biomass
    let cell-biomass-1 biomass * division-proportioning             ; original biomass is not splitted equally into two halfs
    let cell-biomass-2 biomass - cell-biomass-1
    set biomass cell-biomass-1                                      ; biomass for original microorganims
    set biomass-reproduction abs random-normal (rep_biomass) (DSTr * rep_biomass)   ; setup new reproduction treshold for the original microorganism
    hatch 1                                                         ; born new microorganism
    [
      set biomass cell-biomass-2                                    ; biomass for newest microorganims
      set color green
      set R 0 set m_aero 0 set s_aero_1 0 set s_aero_2 0            ; Reset all counters for new microorganism
      set m_anox_1 0 set m_anox_2 0 set m_anox_3 0 set m_anox_4 0   ; Reset all counters for new microorganism
      set s_anox_1 0 set s_anox_2 0 set s_anox_3 0 set s_anox_4 0   ; Reset all counters for new microorganism
      set biomass-reproduction abs random-normal (rep_biomass) (DSTr * rep_biomass) ; setup the reproduction treshold for the newest microorganism
    ]
    set R R + 1                                                     ; Counter for bipartitions
  ]
end 

; ____________________________ Proceeding to simulate bioreactor agitation over the microorganism ____________________________________________________

to move
  if q = 0
  [ setxy random-xcor random-ycor ] ; Randomly change position because bioreactor agitation
end 

; ____________________________ Proceeding to setup and write bioreactor graphical outputs ____________________________________________________

to do-plotting
  setup-monitors

  set-current-plot "Biomass"
  set-current-plot-pen "Biomass"
  plotxy time_now gbacteria

  set-current-plot "Products-CO2"
  set-current-plot-pen "CO2"
  plotxy time_now gdioxide

  set-current-plot "Products-N2O"
  set-current-plot-pen "N2O"
  plotxy time_now gn2o

  set-current-plot "Products - NO2-"
  set-current-plot-pen "NO2-"
  plotxy time_now gno2-

  set-current-plot "Products - NO"
  set-current-plot-pen "NO"
  plotxy time_now gno

  set-current-plot "Products - N2"
  set-current-plot-pen "N2"
  plotxy time_now gn2

  set-current-plot "Culture Medium Nutrients"
  set-current-plot-pen "Succinate"
  plotxy time_now gsuccinate
  set-current-plot-pen "Amonium"
  plotxy time_now gamonium

  set-current-plot "Nitrate"
  set-current-plot-pen "nitrate"
  plotxy time_now gnitrate

  set-current-plot "Oxygen"
  set-current-plot-pen "oxygen"
  plotxy time_now goxygen * 32

  set-current-plot "Bicarbonate"
  set-current-plot-pen "bicarbonate"
  plotxy time_now gbicarbonate

  set-current-plot "Bacterial-biomass-distribution"
  set-current-plot-pen "biomass-histogram"
  histogram [biomass] of bacteria
  set-plot-pen-interval 0.1
end 

There is only one version of this model, created almost 8 years ago by Pablo Alejandro Araujo Granda.

Attached files

File Type Description Last updated
INDISIM-Paracoccus.png preview Preview for 'INDISIM-Paracoccus' almost 8 years ago, by Pablo Alejandro Araujo Granda Download

This model does not have any ancestors.

This model does not have any descendants.