Skip to content

Commit

Permalink
ADM1/ASM2d Translator Update (watertap-org#1435)
Browse files Browse the repository at this point in the history
* Finish implementation of adm1/asm2d translator

* Resolve inconsistent unit errors

* Update test file

* Remove completed to-do item

* Add Soraya's scaling improvements

* Address minor formatting issues

* Add BSM2 flowsheet w/new translator

* New flowsheet solving with Bio_P=True

* Minor improvements to BSM2

* BioP=True solves & BioP=False fails

* Update translator documentation

* Correct imports in test file

* Try automating scaling

* Test autoscaling function

* Update AD initialization

* Delete new files and update old files

* Add Chenyu's versions of solved flowsheets

* Clean up flowsheets

* Update test solutions

* Minor cleanup

* Add scaling factor that was accidentally deleted

* Add bac 2nd conservation test

* Address some electroN-P issues

* Add scaling function to BSM2 ui file

* Update test files

* address Pylint issue

* Change from rel to abs

* Change rel to abs for zero-values

* Try updating UI file

* Remove costing terms from extended BSM2 GUI

* Remove bio_P config option

* Chane one more rel to abs

* Comment out bio_P=False testing and use bio_P=True in UI

* Add costing to ui

* Replace bio with X_{bio}

* Delete unnecessary outputs from electroNP flowsheet

* Correct mistake in ADM1-ASM2d translator

* Flowsheet solving for bio_P = False

* Update both translator files based on Xavi feedback

* Undo unit changes in ASM2d/ADM1 translator

* Correct typo

* Update adm1_asm2d test

* Update documentation

* Revised version of BSM2 and electroNP

* Clean up BSM2_P_extension flowsheet

* Update BSM2 w/ P extension tests

* Update electroN-P flowsheet tests

* Update BSM2-P GUI

* Address pylint issue

* Delete tests for bio_P=True

* Have GUI use bio_P=False instead of bio_P=True

* Put common translator parameters inside of ADM1 reaction package

* Use watertap solver instead of IDAES

* Update tests for bio_P=True and bio_P=False

* Add config option for bio_P into GUI

* Address pylint issues

* Try to resolve remaining test failures

* Add watertap get_solver to test file

* Get rid of config option in BSM2-P GUI

* Try to resolve GUI issue

* Minor change to flowsheet scaling

* Add require_idaes_solver to BSM2-P GUI

* Resolve solving issue

* Comment out everything related to costing

* Address Pylint issues

* Address Pylint issues

* Delete BSM2_electroNP flowsheet

---------

Co-authored-by: Ludovico Bianchi <[email protected]>
Co-authored-by: luohezhiming <[email protected]>
  • Loading branch information
3 people authored Jul 18, 2024
1 parent 080c644 commit f94f21d
Show file tree
Hide file tree
Showing 14 changed files with 1,576 additions and 965 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ The translator degrees of freedom are the inlet feed state variables:
* pressure
* volumetric flowrate
* solute compositions
* cations
* anions

Ports
-----
Expand All @@ -47,17 +45,26 @@ Sets
"Inlet/outlet", ":math:`x`", "['in', 'out']"
"Phases", ":math:`p`", "['Liq']"
"Inlet Components", ":math:`j_{in}`", "['H2O', 'S_su', 'S_aa', 'S_fa', 'S_va', 'S_bu', 'S_pro', 'S_ac', 'S_h2', 'S_ch4', 'S_IC', 'S_IN', 'S_IP', 'S_I', 'X_ch', 'X_pr', 'X_li', 'X_su', 'X_aa', 'X_fa', 'X_c4', 'X_pro', 'X_ac', 'X_h2', 'X_I', 'X_PHA', 'X_PP', 'X_PAO', 'S_K', 'S_Mg']"
"Ion", ":math:`j_{in}`", "['S_cat', 'S_an'] \ :sup:`1`"
"Outlet Components", ":math:`j_{out}`", "['H2O', 'S_A', 'S_F', 'S_I', 'S_N2', 'S_NH4', 'S_NO3', 'S_O2', 'S_PO4', 'S_K', 'S_Mg', 'S_IC', 'X_AUT', 'X_H', 'X_I', 'X_PAO', 'X_PHA', 'X_PP', 'X_S']"
"Readily Biodegradable COD", ":math:`r1`", "['S_su', 'S_aa', 'S_fa']"
"Readily Biodegradable COD", ":math:`r2`", "['S_va', 'S_bu', 'S_pro', 'S_ac']"
"Slowly Biodegradable COD", ":math:`s`", "['X_ch', 'X_pr', 'X_li']"
"Unchanged Components", ":math:`u`", "['S_I', 'X_I', 'X_PP', 'X_PHA', 'S_K', 'S_Mg', 'S_IC']"
"Zero Flow Components", ":math:`z`", "['S_N2', 'S_NO3', 'S_O2', 'X_AUT', 'X_H', 'X_PAO']"
"Ion", ":math:`j_{in}`", "['S_cat', 'S_an'] \ :sup:`1`"
"Zero Flow Components", ":math:`z`", "['S_O2', 'S_N2', 'S_NO3', 'X_H', 'X_PAO', 'X_PP', 'X_PHA', 'X_AUT']"

**Notes**
:sup:`1` "Ion" is a subset of "Inlet Components" and uses the same symbol j_in.

Parameters
----------

.. csv-table::
:header: "Description", "Symbol", "Parameter Name", "Value", "Units"

"Soluble inerts from composites", ":math:`f_{sI, xc}`", "f_sI_xc", 0, ":math:`\text{dimensionless}`"
"Particulate inerts from composites", ":math:`f_{xI, xc}`", "f_xI_xc", 0.1, ":math:`\text{dimensionless}`"
"Carbohydrates from composites", ":math:`f_{ch, xc}`", "f_ch_xc", 0.275, ":math:`\text{dimensionless}`"
"Proteins from composites", ":math:`f_{pr, xc}`", "f_pr_xc", 0.275, ":math:`\text{dimensionless}`"
"Lipids from composites", ":math:`f_{li, xc}`", "f_li_xc", 0.35, ":math:`\text{dimensionless}`"
"Phosphorus content of X_ch", ":math:`P_{ch}`", "P_ch", 0, ":math:`\text{dimensionless}`"

.. _Translator_ADM1_ASM2d_equations:

Equations and Relationships
Expand All @@ -69,15 +76,35 @@ Equations and Relationships
"Volumetric flow equality", ":math:`F_{out} = F_{in}`"
"Temperature balance", ":math:`T_{out} = T_{in}`"
"Pressure balance", ":math:`P_{out} = P_{in}`"
"Fermentable substrate conversion", ":math:`S_{F, out} = Σ_{r1} C_{r1, in}`"
"Acetic acid conversion", ":math:`S_{A, out} = Σ_{r2} C_{r2, in}`"
"Unchanged component conversions", ":math:`C_{u, out} = C_{u, in}`"
"Ammonium conversion", ":math:`S_{NH4, out} = S_{IN, in}`"
"Phosphate conversion", ":math:`S_{PO4, out} = S_{IP, in}`"
"Biodegradable particulate organics conversion", ":math:`X_{S, out} = Σ_{s} C_{s, in}`"
"Zero-flow component conversions", ":math:`C_{z, out} = 0`"


"Biomass concentration", ":math:`X_{bio} = X_{su, in} + X_{aa, in} + X_{fa, in} + X_{c4, in} + X_{pro, in} + X_{ac, in} + X_{h2, in} + X_{PAO, in}`"
"S_ac concentration", ":math:`S_{ac, 1} = S_{ac, in} + X_{PHA, in}`"
"S_IC concentration", ":math:`S_{IC, 1} = (X_{bio} * Ci[X_{su}]) - (X_{bio} * f_{sI, xc} * Ci[S_{I}]) - (X_{bio} * f_{ch, xc} * Ci[X_{ch}]) - (X_{bio} * f_{pr, xc} * Ci[X_{pr}]) - (X_{bio} * f_{li, xc} * Ci[X_{li}]) - (X_{bio} * f_{xI, xc} * Ci[X_{I}]) + (X_{PHA, in} * Ci[X_{PHA}]) - (X_{PHA, in} * Ci[S_{ac}])`"
"S_IN concentration", ":math:`S_{IN, 1} = (X_{bio} * Ci[X_{su}]) - (X_{bio} * f_{sI, xc} * Ni[S_{I}]) - (X_{bio} * f_{pr, xc} * Ni[X_{pr}]) - (X_{bio} * f_{xI, xc} * Ci[X_{I}])`"
"S_I concentration", ":math:`S_{I, 1} = S_{I, in} + (f_{sI, xc} * X_{bio})`"
"X_ch concentration", ":math:`X_{ch, 1} = X_{ch, in} + (f_{ch, xc} * X_{bio})`"
"X_pr concentration", ":math:`X_{pr, 1} = X_{pr, in} + (f_{pr, xc} * X_{bio})`"
"X_li concentration", ":math:`X_{li, 1} = X_{li, in} + (f_{li, xc} * X_{bio})`"
"X_I concentration", ":math:`S_{I, 1} = X_{I, in} + (f_{xI, xc} * X_{bio})`"
"S_IP concentration", ":math:`S_{IP, 1} = X_{PP, in} + (X_{bio} * Pi[X_{su}]) - (X_{bio} * f_{sI, xc} * Pi[S_{I}]) - (X_{bio} * f_{ch, xc} * P_ch) - (X_{bio} * f_{li, xc} * Pi[X_{li}]) - (X_{bio} * f_{xI, xc} * Pi[X_{I}])`"
"X_PHA concentration", ":math:`X_{PHA, 1} = 0`"
"X_PP concentration", ":math:`X_{PP, 1} = 0`"
"X_PAO concentration", ":math:`X_{PAO, 1} = 0`"
"S_IC concentration", ":math:`S_{IC, 2} = (X_{ch, 1} * Ci[X_{ch}]) + (X_{pr, 1} * Ci[X_{pr}]) + (X_{li, 1} * Ci[X_{li}]) - i_{CXS} * (X_{ch, 1} + X_{pr, 1} + X_{li, 1}) + (S_{su, in} * Ci[S_{su}]) + (S_{aa, in} * Ci[S_{aa}]) + (S_{fa, in} * Ci[S_{fa}]) - i_{CSF} * (S_{su, in} + S_{aa, in} + S_{fa, in}) + (S_{va, in} * Ci[S_{va}]) + (S_{bu, in} * Ci[S_{bu}]) + (S_{pro, in} * Ci[S_{pro}]) + (S_{AC, 1} * Ci[S_{ac}]) - i_{CSA} * (S_{va, in} + S_{bu, in} + S_{pro, in} + S_{ac, 1})`"
"S_IN concentration", ":math:`S_{IN, 2} = (X_{pr, 1} * Ni[X_{pr}]) - i_{NXS} * (X_{ch, 1} + X_{pr, 1} + X_{li, 1}) + (S_{aa, in} * Ni[S_{aa}]) - i_{NSF} * (S_{su, in} + S_{fa, in} + S_{va, in})`"
"S_IP concentration", ":math:`S_{IP, 2} = X_{PP, 1} + (X_{ch, 1} * P_ch) + (X_{li, 1} * Ni[X_{li}]) - i_{PXS} * (X_{ch, 1} + X_{pr, 1} + X_{li, 1}) - i_{PSF} * (S_{su, in} + S_{fa, in} + S_{va, in})`"
"S_K concentration", ":math:`S_{K, 2} = S_{K, in} + X_{PP, 1}`"
"S_Mg concentration", ":math:`S_{Mg, 2} = S_{Mg, in} + X_{PP, 1}`"
"S_F concentration", ":math:`S_{F, out} = S_{su, in} + S_{aa, in} + S_{fa, in}`"
"S_A concentration", ":math:`S_{A, out} = S_{va, in} + S_{bu, in} + S_{pro, in} + S_{ac, 1}`"
"S_I concentration", ":math:`S_{I, out} = S_{I, 1}`"
"S_NH4 concentration", ":math:`S_{NH4, out} = 31(S_{IN, in}/31 + S_{IN, 1} + S_{IN, 2})`"
"S_PO4 concentration", ":math:`S_{PO4, out} = 14(S_{IP, in}/14 + S_{IP, 1} + S_{IP, 2})`"
"S_IC concentration", ":math:`S_{IC, out} = 12(S_{IC, in}/12 + S_{IC, 1} + S_{IC, 2})`"
"X_I concentration", ":math:`X_{I, out} = X_{I, 1}`"
"X_S concentration", ":math:`X_{S, out} = X_{ch, 1} + X_{pr, 1} + X_{li, 1}`"
"S_K concentration", ":math:`S_{K, out} = S_{K, 2} * 39.1`"
"S_Mg concentration", ":math:`S_{Mg, out} = S_{Mg, 2} * 24.3`"

Classes
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ Equations and Relationships (with biological phosphorus removal)
.. csv-table::
:header: "Description", "Equation"

"Biomass concentration", ":math:`bio = X_{H, 2} + X_{PAO, in} + X_{AUT, in}`"
"S_I concentration", ":math:`S_{I, 4} = S_{I, in} + (bio * f_{sI, xc})`"
"S_NH4 concentration", ":math:`S_{NH4, 4} = S_{NH4, 3} + (bio * i_{NBM}) - (bio * f_{sI, xc} * i_{NSI}) - (bio * f_{xI, xc} * i_{NSI}) - (bio * f_{pr, xc} * Ni[X_{pr}] * 14)`"
"S_PO4 concentration", ":math:`S_{PO4, 4} = S_{PO4, 3} + (bio * i_{PBM}) - (bio * f_{sI, xc} * i_{PSI}) - (bio * f_{xI, xc} * i_{PXI}) - (bio * f_{ch, xc} * Pi[X_{ch}] * 31) - (bio * f_{li, xc} * Pi[X_{li}] * 31)`"
"S_IC concentration", ":math:`S_{IC, 4} = S_{IC, 3} + (bio * i_{CXB}) - (bio * f_{sI, xc} * i_{CSI}) - (bio * f_{xI, xc} * i_{CXI}) - (bio * f_{pr, xc} * Ci[X_{pr}] * 12) - (bio * f_{ch, xc} * Ci[X_{ch}] * 12) - (bio * f_{li, xc} * Ci[X_{li}] * 12)`"
"X_I concentration", ":math:`X_{I, 4} = X_{I, in} + (bio * f_{xI, xc})`"
"Biomass concentration", ":math:`X_{bio} = X_{H, 2} + X_{PAO, in} + X_{AUT, in}`"
"S_I concentration", ":math:`S_{I, 4} = S_{I, in} + (X_{bio} * f_{sI, xc})`"
"S_NH4 concentration", ":math:`S_{NH4, 4} = S_{NH4, 3} + (X_{bio} * i_{NBM}) - (X_{bio} * f_{sI, xc} * i_{NSI}) - (X_{bio} * f_{xI, xc} * i_{NSI}) - (X_{bio} * f_{pr, xc} * Ni[X_{pr}] * 14)`"
"S_PO4 concentration", ":math:`S_{PO4, 4} = S_{PO4, 3} + (X_{bio} * i_{PBM}) - (X_{bio} * f_{sI, xc} * i_{PSI}) - (X_{bio} * f_{xI, xc} * i_{PXI}) - (X_{bio} * f_{ch, xc} * Pi[X_{ch}] * 31) - (X_{bio} * f_{li, xc} * Pi[X_{li}] * 31)`"
"S_IC concentration", ":math:`S_{IC, 4} = S_{IC, 3} + (X_{bio} * i_{CXB}) - (X_{bio} * f_{sI, xc} * i_{CSI}) - (X_{bio} * f_{xI, xc} * i_{CXI}) - (X_{bio} * f_{pr, xc} * Ci[X_{pr}] * 12) - (X_{bio} * f_{ch, xc} * Ci[X_{ch}] * 12) - (X_{bio} * f_{li, xc} * Ci[X_{li}] * 12)`"
"X_I concentration", ":math:`X_{I, 4} = X_{I, in} + (X_{bio} * f_{xI, xc})`"
"X_H concentration", ":math:`X_{H, 4} = 0`"
"X_PAO concentration", ":math:`X_{PAO, 4} = 0`"
"X_AUT concentration", ":math:`X_{AUT, 4} = 0`"
Expand Down Expand Up @@ -156,12 +156,12 @@ Equations and Relationships (without biological phosphorus removal)
.. csv-table::
:header: "Description", "Equation"

"Biomass concentration", ":math:`bio = X_{H, 2} + X_{AUT, in}`"
"S_I concentration", ":math:`S_{I, 4} = S_{I, in} + (bio * f_{sI, xc})`"
"S_NH4 concentration", ":math:`S_{NH4, 4} = S_{NH4, 3} + (bio * i_{NBM}) - (bio * f_{sI, xc} * i_{NSI}) - (bio * f_{xI, xc} * i_{NSI}) - (bio * f_{pr, xc} * Ni[X_{pr}] * 14)`"
"S_PO4 concentration", ":math:`S_{PO4, 4} = S_{PO4, 3} + (bio * i_{PBM}) - (bio * f_{sI, xc} * i_{PSI}) - (bio * f_{xI, xc} * i_{PXI}) - (bio * f_{ch, xc} * Pi[X_{ch}] * 31) - (bio * f_{li, xc} * Pi[X_{li}] * 31)`"
"S_IC concentration", ":math:`S_{IC, 4} = S_{IC, 3} + (bio * i_{CXB}) - (bio * f_{sI, xc} * i_{CSI}) - (bio * f_{xI, xc} * i_{CXI}) - (bio * f_{pr, xc} * Ci[X_{pr}] * 12) - (bio * f_{ch, xc} * Ci[X_{ch}] * 12) - (bio * f_{li, xc} * Ci[X_{li}] * 12)`"
"X_I concentration", ":math:`X_{I, 4} = X_{I, in} + (bio * f_{xI, xc})`"
"Biomass concentration", ":math:`X_{bio} = X_{H, 2} + X_{AUT, in}`"
"S_I concentration", ":math:`S_{I, 4} = S_{I, in} + (X_{bio} * f_{sI, xc})`"
"S_NH4 concentration", ":math:`S_{NH4, 4} = S_{NH4, 3} + (X_{bio} * i_{NBM}) - (X_{bio} * f_{sI, xc} * i_{NSI}) - (X_{bio} * f_{xI, xc} * i_{NSI}) - (X_{bio} * f_{pr, xc} * Ni[X_{pr}] * 14)`"
"S_PO4 concentration", ":math:`S_{PO4, 4} = S_{PO4, 3} + (X_{bio} * i_{PBM}) - (X_{bio} * f_{sI, xc} * i_{PSI}) - (X_{bio} * f_{xI, xc} * i_{PXI}) - (X_{bio} * f_{ch, xc} * Pi[X_{ch}] * 31) - (X_{bio} * f_{li, xc} * Pi[X_{li}] * 31)`"
"S_IC concentration", ":math:`S_{IC, 4} = S_{IC, 3} + (X_{bio} * i_{CXB}) - (X_{bio} * f_{sI, xc} * i_{CSI}) - (X_{bio} * f_{xI, xc} * i_{CXI}) - (X_{bio} * f_{pr, xc} * Ci[X_{pr}] * 12) - (X_{bio} * f_{ch, xc} * Ci[X_{ch}] * 12) - (X_{bio} * f_{li, xc} * Ci[X_{li}] * 12)`"
"X_I concentration", ":math:`X_{I, 4} = X_{I, in} + (X_{bio} * f_{xI, xc})`"
"X_H concentration", ":math:`X_{H, 4} = 0`"
"X_PAO concentration", ":math:`X_{PAO, 4} = X_{PAO, in}`"
"X_PP concentration", ":math:`X_{PP, 4} = X_{PP, in}`"
Expand Down
Loading

0 comments on commit f94f21d

Please sign in to comment.