Skip to content

Commit

Permalink
BSM2-P Effluent Metrics w/o Flowsheet Constraints (#1492)
Browse files Browse the repository at this point in the history
* Add effluent metrics to prop pack

* Add preliminary effluent violations to the BSM2-P flowsheet

* Revert TSS change

* Make BOD5_factor a parameter

* Update BSM2 GUI images

* Define effluent metrics as expressions (as done in ASM1) rather than constraints

* Initial attempt at adding optimization to BSM2-P

* Disable phosphorus effluent violation

* Solves to Acceptable Level

* Update unit model tests

* Touch effluent metrics before scaling

* minor updates

* Modify tear guess

* Remove optimization functions

* Revert changes to BSM2

* Clean up files

* Add scaling for metrics

* Add scaling factors for effluent metrics

* Touch SNOX property

* Add SNOX to custom properties

* Try reverting some changes

* Re-add scaling

* Re-add SNOX

* Effluent properties don't need to be touched anymore

* Add effluent metrics to BSM2-P documentation

* Tune effluent metric scaling factors for the bio_P=True case

* Try removing all scaling factors for effluent concentrations

* Minor adjustments to AD scaling factors

* Try more AD scaling changes

* Revert AD scaling changes

* Another attempt at modifying AD scaling

* Resolve remaining test failures

* Clean up modified asm2d thermo test

* Address pylint issue

* Temporarily remove constraints from documentation
  • Loading branch information
MarcusHolly authored Oct 3, 2024
1 parent 7f85fc0 commit b27f929
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 98 deletions.
2 changes: 0 additions & 2 deletions docs/technical_reference/flowsheets/extended_BSM2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ Additional Variables
"Reactor 7 oxygen mass transfer coefficient",":math:`KLa_{R7}`", "240", ":math:`\text{hr}^{-1}`"
"Dissolved oxygen concentration at equilibrium",":math:`S_{O, eq}`", "8e-3", ":math:`\text{hr}^{-1}`"



Additional Constraints
----------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def main(bio_P=False):
m.fs.R6.outlet.conc_mass_comp[:, "S_O2"].unfix()
m.fs.R7.outlet.conc_mass_comp[:, "S_O2"].unfix()

# Resolve with controls in place
# Re-solve with controls in place
results = solve(m)

pyo.assert_optimal_termination(results)
Expand Down Expand Up @@ -548,6 +548,10 @@ def scale_variables(m):
)
iscale.set_scaling_factor(block.control_volume.material_balances, 1e3)

iscale.set_scaling_factor(m.fs.AD.KH_co2, 1e1)
iscale.set_scaling_factor(m.fs.AD.KH_ch4, 1e1)
iscale.set_scaling_factor(m.fs.AD.KH_h2, 1e1)

# Apply scaling
scale_variables(m)
iscale.calculate_scaling_factors(m)
Expand Down Expand Up @@ -612,7 +616,7 @@ def initialize_system(m, bio_P=False, solver=None):
(0, "X_AUT"): 0.25,
(0, "X_H"): 23.0,
(0, "X_I"): 11.3,
(0, "X_PAO"): 10.8,
(0, "X_PAO"): 10.9,
(0, "X_PHA"): 0.0058,
(0, "X_PP"): 2.9,
(0, "X_S"): 3.8,
Expand Down Expand Up @@ -872,9 +876,82 @@ def display_performance_metrics(m):
pyo.units.get_units(m.fs.AD.liquid_phase.properties_in[0].flow_vol),
)

print("---- Feed Metrics----")
print(
"Feed TSS concentration",
pyo.value(m.fs.FeedWater.properties[0].TSS),
pyo.units.get_units(m.fs.FeedWater.properties[0].TSS),
)
print(
"Feed COD concentration",
pyo.value(m.fs.FeedWater.properties[0].COD),
pyo.units.get_units(m.fs.FeedWater.properties[0].COD),
)
print(
"BOD5 concentration",
pyo.value(m.fs.FeedWater.properties[0].BOD5["raw"]),
pyo.units.get_units(m.fs.FeedWater.properties[0].BOD5["raw"]),
)
print(
"TKN concentration",
pyo.value(m.fs.FeedWater.properties[0].TKN),
pyo.units.get_units(m.fs.FeedWater.properties[0].TKN),
)
print(
"SNOX concentration",
pyo.value(m.fs.FeedWater.properties[0].SNOX),
pyo.units.get_units(m.fs.FeedWater.properties[0].SNOX),
)
print(
"Organic phosphorus concentration",
pyo.value(m.fs.FeedWater.properties[0].SP_organic),
pyo.units.get_units(m.fs.FeedWater.properties[0].SP_organic),
)
print(
"Inorganic phosphorus concentration",
pyo.value(m.fs.FeedWater.properties[0].SP_inorganic),
pyo.units.get_units(m.fs.FeedWater.properties[0].SP_inorganic),
)

print("---- Effluent Metrics----")
print(
"TSS concentration",
pyo.value(m.fs.Treated.properties[0].TSS),
pyo.units.get_units(m.fs.Treated.properties[0].TSS),
)
print(
"COD concentration",
pyo.value(m.fs.Treated.properties[0].COD),
pyo.units.get_units(m.fs.Treated.properties[0].COD),
)
print(
"BOD5 concentration",
pyo.value(m.fs.Treated.properties[0].BOD5["effluent"]),
pyo.units.get_units(m.fs.Treated.properties[0].BOD5["effluent"]),
)
print(
"TKN concentration",
pyo.value(m.fs.Treated.properties[0].TKN),
pyo.units.get_units(m.fs.Treated.properties[0].TKN),
)
print(
"SNOX concentration",
pyo.value(m.fs.Treated.properties[0].SNOX),
pyo.units.get_units(m.fs.Treated.properties[0].SNOX),
)
print(
"Organic phosphorus concentration",
pyo.value(m.fs.Treated.properties[0].SP_organic),
pyo.units.get_units(m.fs.Treated.properties[0].SP_organic),
)
print(
"Inorganic phosphorus concentration",
pyo.value(m.fs.Treated.properties[0].SP_inorganic),
pyo.units.get_units(m.fs.Treated.properties[0].SP_inorganic),
)


if __name__ == "__main__":
# This method builds and runs a steady state activated sludge flowsheet.
m, results = main(bio_P=False)

stream_table = create_stream_table_dataframe(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def build(self):
domain=pyo.PositiveReals,
doc="Conversion factor applied for TSS calculation",
)
self.BOD5_factor = pyo.Var(
self.BOD5_factor = pyo.Param(
["raw", "effluent"],
initialize={"raw": 0.65, "effluent": 0.25},
units=pyo.units.dimensionless,
Expand Down
Loading

0 comments on commit b27f929

Please sign in to comment.