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

ADM1/ASM2d Translator Update #1435

Merged
merged 87 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
af1dc9a
Finish implementation of adm1/asm2d translator
MarcusHolly Jun 13, 2024
8318db2
Resolve inconsistent unit errors
MarcusHolly Jun 13, 2024
c0b8329
Update test file
MarcusHolly Jun 13, 2024
b1273c4
Remove completed to-do item
MarcusHolly Jun 13, 2024
df81af7
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 17, 2024
6b6a448
Add Soraya's scaling improvements
MarcusHolly Jun 17, 2024
66a7c44
Address minor formatting issues
MarcusHolly Jun 17, 2024
07ff096
Add BSM2 flowsheet w/new translator
MarcusHolly Jun 18, 2024
8133b7a
New flowsheet solving with Bio_P=True
MarcusHolly Jun 18, 2024
906fb13
Minor improvements to BSM2
MarcusHolly Jun 19, 2024
4953299
BioP=True solves & BioP=False fails
MarcusHolly Jun 19, 2024
f5ee78f
Update translator documentation
MarcusHolly Jun 19, 2024
49ce16c
Correct imports in test file
MarcusHolly Jun 19, 2024
5731370
Try automating scaling
MarcusHolly Jun 20, 2024
22c3091
Test autoscaling function
MarcusHolly Jun 21, 2024
98978a0
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 24, 2024
4159a92
Update AD initialization
MarcusHolly Jun 24, 2024
22fd6a9
Delete new files and update old files
MarcusHolly Jun 24, 2024
321b16e
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 26, 2024
a205a7a
Add Chenyu's versions of solved flowsheets
MarcusHolly Jun 26, 2024
87ccc2f
Clean up flowsheets
MarcusHolly Jun 26, 2024
7150b66
Update test solutions
MarcusHolly Jun 27, 2024
b7b2c17
Minor cleanup
MarcusHolly Jun 27, 2024
d637ff4
Add scaling factor that was accidentally deleted
MarcusHolly Jun 27, 2024
33b52e3
Add bac 2nd conservation test
MarcusHolly Jun 27, 2024
9125cda
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 27, 2024
4617c92
Address some electroN-P issues
MarcusHolly Jun 27, 2024
c7b9d56
Add scaling function to BSM2 ui file
MarcusHolly Jun 27, 2024
a95b8e8
Update test files
MarcusHolly Jun 27, 2024
07ffba0
address Pylint issue
MarcusHolly Jun 27, 2024
9901f3d
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 27, 2024
0aaac45
Change from rel to abs
MarcusHolly Jun 27, 2024
b42f408
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 28, 2024
7d31abb
Change rel to abs for zero-values
MarcusHolly Jun 28, 2024
0e93eb2
Try updating UI file
MarcusHolly Jun 28, 2024
59dec65
Remove costing terms from extended BSM2 GUI
MarcusHolly Jun 28, 2024
047b8c8
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 28, 2024
e80d531
Remove bio_P config option
MarcusHolly Jun 28, 2024
dfc95ca
Address merge conflict
MarcusHolly Jun 28, 2024
9c9655e
Chane one more rel to abs
MarcusHolly Jun 29, 2024
814c527
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jun 29, 2024
4e3bc98
Comment out bio_P=False testing and use bio_P=True in UI
MarcusHolly Jul 1, 2024
7b7aba8
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jul 1, 2024
bf0bd1b
Add costing to ui
MarcusHolly Jul 1, 2024
d240381
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jul 1, 2024
b64fba3
Address merge conflict
MarcusHolly Jul 2, 2024
65794b6
Replace bio with X_{bio}
MarcusHolly Jul 2, 2024
0e157dd
Delete unnecessary outputs from electroNP flowsheet
MarcusHolly Jul 2, 2024
5674852
Correct mistake in ADM1-ASM2d translator
MarcusHolly Jul 2, 2024
05de86b
Merge branch 'main' into new_adm1_asm2d_interface
lbianchi-lbl Jul 3, 2024
fa128e1
Flowsheet solving for bio_P = False
MarcusHolly Jul 3, 2024
46872d3
Update both translator files based on Xavi feedback
MarcusHolly Jul 5, 2024
5214c59
Merge branch 'new_adm1_asm2d_interface' of https://github.com/MarcusH…
MarcusHolly Jul 5, 2024
81a0233
Undo unit changes in ASM2d/ADM1 translator
MarcusHolly Jul 5, 2024
f898cb6
Correct typo
MarcusHolly Jul 5, 2024
f8471ae
Update adm1_asm2d test
MarcusHolly Jul 5, 2024
c9eb9d2
Update documentation
MarcusHolly Jul 5, 2024
1e6e114
Revised version of BSM2 and electroNP
luohezhiming Jul 11, 2024
7ca83c3
Merge branch 'new_adm1_asm2d_interface' of https://github.com/MarcusH…
MarcusHolly Jul 11, 2024
656fb38
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jul 11, 2024
b469c9b
Clean up BSM2_P_extension flowsheet
MarcusHolly Jul 11, 2024
230a4d3
Update BSM2 w/ P extension tests
MarcusHolly Jul 11, 2024
ffed59c
Update electroN-P flowsheet tests
MarcusHolly Jul 11, 2024
3a1be89
Update BSM2-P GUI
MarcusHolly Jul 11, 2024
3ea1f3c
Address pylint issue
MarcusHolly Jul 11, 2024
c719fbe
Delete tests for bio_P=True
MarcusHolly Jul 11, 2024
46071a5
Have GUI use bio_P=False instead of bio_P=True
MarcusHolly Jul 11, 2024
c6700b5
Put common translator parameters inside of ADM1 reaction package
MarcusHolly Jul 12, 2024
9bc5840
Use watertap solver instead of IDAES
MarcusHolly Jul 16, 2024
b3cd2bf
Update tests for bio_P=True and bio_P=False
MarcusHolly Jul 16, 2024
95a6f9b
Add config option for bio_P into GUI
MarcusHolly Jul 16, 2024
f8476c2
Address pylint issues
MarcusHolly Jul 16, 2024
cbbfe6f
Try to resolve remaining test failures
MarcusHolly Jul 16, 2024
bb95f8d
Add watertap get_solver to test file
MarcusHolly Jul 16, 2024
cc3f243
Get rid of config option in BSM2-P GUI
MarcusHolly Jul 16, 2024
b63ce95
Try to resolve GUI issue
MarcusHolly Jul 16, 2024
4dc04b3
Minor change to flowsheet scaling
MarcusHolly Jul 17, 2024
4e8d9ed
Add require_idaes_solver to BSM2-P GUI
MarcusHolly Jul 17, 2024
0729d39
Resolve solving issue
luohezhiming Jul 17, 2024
cc61553
Merge branch 'new_adm1_asm2d_interface' of https://github.com/MarcusH…
luohezhiming Jul 17, 2024
a7bdd21
Comment out everything related to costing
MarcusHolly Jul 17, 2024
77bd768
Merge branch 'new_adm1_asm2d_interface' of https://github.com/MarcusH…
MarcusHolly Jul 17, 2024
c06fe0f
Address Pylint issues
MarcusHolly Jul 17, 2024
3313322
Address Pylint issues
MarcusHolly Jul 17, 2024
b18c7f2
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jul 17, 2024
53baefd
Delete BSM2_electroNP flowsheet
MarcusHolly Jul 18, 2024
88955db
Merge branch 'main' into new_adm1_asm2d_interface
MarcusHolly Jul 18, 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
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:`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}`"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to rename bio as X_{bio} for consistency

"S_ac concentration", ":math:`S_{ac, 1} = S_{ac, in} + X_{PHA, in}`"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the 1 and 2 subscripts meant to represent (e.g., S_{ac, 1} or S_{ac, 2})?

Copy link
Contributor Author

@MarcusHolly MarcusHolly Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - the 1 and 2 subscripts correspond to the concentration of the given component at steps 1 and 2 (named like Sac_AD1 in the code). This translator only has 2 steps (whereas the other translator has 5).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little bit confused here, e.g., I see you set X_{PP,1} = 0 and then there are some conversion equations like S_IP will add X_{PP,1}, but it is set as 0, so what is the purpose for this conversion? Add 0 does not seem to have any impacts of the outcome. and where does X_PP convert to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done that just to be explicit, and the c-code also leaves in such terms even when they are set equal to 0. I wanted to avoid somebody cross-checking our code with the c-code and wondering why a term is missing from an expression

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X_PP is converted into S_Mg, S_K, and S_IP

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct. It has no effect since it's zero. But is it possible that in the future we want to change X_PP from 0 to something else? If so, I think it's worth keeping this zero term here in the documentation and in the code itself. It's also just the most accurate representation of these equations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adam-a-a hope you could also join the talk, I am confused because I believe X_PP should be important components of the system, right now, it seems no matter the initial value of X_PP is, it will directly set to 0 and no actual conversion happens to the system. Same conditions to X_PHA and X_PAO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... yea there's a mistake here. S_{IP, 1} should be X_{PP, in) + ... and not S_{IP, in) + ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch @luohezhiming. This may or may not screw up the flowsheet again, but I'll test it out now...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do a line-by-line review of the new translator file after this, which I just haven't had the time to do yet

"S_IC concentration", ":math:`S_{IC, 1} = (bio * Ci[X_{su}] * 12) - (bio * f_{sI, xc} * Ci[S_{I}] * 12) - (bio * f_{ch, xc} * Ci[X_{ch}] * 12) - (bio * f_{pr, xc} * Ci[X_{pr}] * 12) - (bio * f_{li, xc} * Ci[X_{li}] * 12) - (bio * f_{xI, xc} * Ci[X_{I}] * 12) + (X_{PHA, in} * Ci[X_{PHA}] * 12) - (X_{PHA, in} * Ci[S_{ac}] * 12)`"
"S_IN concentration", ":math:`S_{IN, 1} = (bio * Ci[X_{su}] * 14) - (bio * f_{sI, xc} * Ni[S_{I}] * 14) - (bio * f_{pr, xc} * Ni[X_{pr}] * 14) - (bio * f_{xI, xc} * Ci[X_{I}] * 14)`"
"S_I concentration", ":math:`S_{I, 1} = S_{I, in} + (f_{sI, xc} * bio)`"
"X_ch concentration", ":math:`X_{ch, 1} = X_{ch, in} + (f_{ch, xc} * bio)`"
"X_pr concentration", ":math:`X_{pr, 1} = X_{pr, in} + (f_{pr, xc} * bio)`"
"X_li concentration", ":math:`X_{li, 1} = X_{li, in} + (f_{li, xc} * bio)`"
"X_I concentration", ":math:`S_{I, 1} = X_{I, in} + (f_{xI, xc} * bio)`"
"S_IP concentration", ":math:`S_{IP, 1} = S_{IP, in} + (bio * Pi[X_{su}] * 31) - (bio * f_{sI, xc} * Pi[S_{I}] * 31) - (bio * f_{ch, xc} * P_ch) - (bio * f_{li, xc} * Pi[X_{li}] * 31) - (bio * f_{xI, xc} * Pi[X_{I}] * 31)`"
"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}] * 12) + (X_{pr, 1} * Ci[X_{pr}] * 12) + (X_{li, 1} * Ci[X_{li}] * 12) - i_{CXS} * (X_{ch, 1} + X_{pr, 1} + X_{li, 1}) + (S_{su, in} * Ci[S_{su}] * 12) + (S_{aa, in} * Ci[S_{aa}] * 12) + (S_{fa, in} * Ci[S_{fa}] * 12) - i_{CSF} * (S_{su, in} + S_{aa, in} + S_{fa, in}) + (S_{va, in} * Ci[S_{va}] * 12) + (S_{bu, in} * Ci[S_{bu}] * 12) + (S_{pro, in} * Ci[S_{pro}] * 12) + (S_{AC, 1} * Ci[S_{ac}] * 12) - 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}] * 14) - i_{NXS} * (X_{ch, 1} + X_{pr, 1} + X_{li, 1}) + (S_{aa, in} * Ni[S_{aa}] * 14) - 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}] * 14) - 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} = S_{IN, in} + S_{IN, 1} + S_{IN, 2}`"
"S_PO4 concentration", ":math:`S_{PO4, out} = S_{IP, in} + S_{IP, 1} + S_{IP, 2}`"
"S_IC concentration", ":math:`S_{IC, out} = S_{IC, in} + 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}`"
"S_Mg concentration", ":math:`S_{Mg, out} = S_{Mg, 2}`"

Classes
-------
Expand Down
Loading
Loading