Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BSM2-P Effluent Metrics w/o Flowsheet Constraints #1492

Merged
merged 38 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0ed0d42
Add effluent metrics to prop pack
MarcusHolly Sep 12, 2024
9541a6a
Add preliminary effluent violations to the BSM2-P flowsheet
MarcusHolly Sep 12, 2024
07ea01a
Revert TSS change
MarcusHolly Sep 12, 2024
56b5145
Make BOD5_factor a parameter
MarcusHolly Sep 13, 2024
e2ac3b0
Update BSM2 GUI images
MarcusHolly Sep 13, 2024
4d05c61
Define effluent metrics as expressions (as done in ASM1) rather than …
MarcusHolly Sep 13, 2024
a09c691
Initial attempt at adding optimization to BSM2-P
MarcusHolly Sep 13, 2024
a19f1c6
Disable phosphorus effluent violation
MarcusHolly Sep 13, 2024
26df31e
Solves to Acceptable Level
MarcusHolly Sep 13, 2024
ef4f5e6
Update unit model tests
MarcusHolly Sep 13, 2024
c2ee4ac
Touch effluent metrics before scaling
MarcusHolly Sep 18, 2024
ec483ba
minor updates
MarcusHolly Sep 18, 2024
dc28584
Modify tear guess
MarcusHolly Sep 18, 2024
520d01a
Remove optimization functions
MarcusHolly Sep 18, 2024
229bcc8
Revert changes to BSM2
MarcusHolly Sep 19, 2024
3b12b77
Clean up files
MarcusHolly Sep 19, 2024
b3fcf2e
Add scaling for metrics
MarcusHolly Sep 19, 2024
08473d6
Add scaling factors for effluent metrics
MarcusHolly Sep 19, 2024
63408ac
Merge branch 'main' into bsm2_P_metrics
MarcusHolly Sep 19, 2024
9d30168
Touch SNOX property
MarcusHolly Sep 19, 2024
0390d43
Add SNOX to custom properties
MarcusHolly Sep 20, 2024
e3b6f8b
Try reverting some changes
MarcusHolly Sep 20, 2024
6877407
Re-add scaling
MarcusHolly Sep 20, 2024
4354d5a
Re-add SNOX
MarcusHolly Sep 20, 2024
a2f512a
Effluent properties don't need to be touched anymore
MarcusHolly Sep 23, 2024
043a544
Add effluent metrics to BSM2-P documentation
MarcusHolly Oct 1, 2024
6c450b4
Tune effluent metric scaling factors for the bio_P=True case
MarcusHolly Oct 1, 2024
4282759
Try removing all scaling factors for effluent concentrations
MarcusHolly Oct 2, 2024
d61ffc9
Merge branch 'main' into myfork-watertap-bsm2_P_metrics
MarcusHolly Oct 2, 2024
845cead
Minor adjustments to AD scaling factors
MarcusHolly Oct 2, 2024
6e215d0
Try more AD scaling changes
MarcusHolly Oct 2, 2024
c957bb6
Revert AD scaling changes
MarcusHolly Oct 2, 2024
bb7db6e
Another attempt at modifying AD scaling
MarcusHolly Oct 2, 2024
fc505ad
Resolve remaining test failures
MarcusHolly Oct 2, 2024
daaefa9
Clean up modified asm2d thermo test
MarcusHolly Oct 2, 2024
f6a7cb6
Address pylint issue
MarcusHolly Oct 2, 2024
6505c0d
Temporarily remove constraints from documentation
MarcusHolly Oct 2, 2024
eb36779
Address Chenyu's comments
MarcusHolly Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading