-
Notifications
You must be signed in to change notification settings - Fork 59
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 full flowsheet #1038
BSM2 full flowsheet #1038
Conversation
Co-authored-by: Adam Atia <[email protected]>
Co-authored-by: Adam Atia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just capturing some initial thoughts / questions I have on the code
watertap/examples/flowsheets/case_studies/BSM2/ASM1_ADM1_flowsheet.py
Outdated
Show resolved
Hide resolved
@adam-a-a @agarciadiego There are two potential issues with
|
** 2 | ||
), | ||
return ( | ||
-3 | ||
* ( | ||
smooth_max(0, self.params.pH_UL_ac - self.pH, eps=1e-8) | ||
/ (self.params.pH_UL_ac - self.params.pH_LL_ac) | ||
) | ||
** 2 | ||
) | ||
|
||
self.I_pH_ac = pyo.Expression( | ||
rule=rule_I_pH_ac, doc="pH inhibition of acetate-utilizing microorganisms" | ||
) | ||
|
||
def rule_I_pH_h2(self): | ||
return pyo.Expr_if( | ||
self.pH > self.params.pH_UL_h2, | ||
1, | ||
pyo.exp( | ||
-3 | ||
* ( | ||
(self.pH - self.params.pH_UL_h2) | ||
/ (self.params.pH_UL_h2 - self.params.pH_LL_h2) | ||
) | ||
** 2 | ||
), | ||
return ( | ||
-3 | ||
* ( | ||
smooth_max(0, self.params.pH_UL_h2 - self.pH, eps=1e-8) | ||
/ (self.params.pH_UL_h2 - self.params.pH_LL_h2) | ||
) | ||
** 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, these are log(I_pH_ac) and log(I_pH_h2). We should name the associated expressions accordingly.
smooth_max(0, self.params.pH_UL_h2 - self.pH, eps=1e-8) | ||
/ (self.params.pH_UL_h2 - self.params.pH_LL_h2) | ||
) | ||
** 2 | ||
) | ||
|
||
self.I_pH_h2 = pyo.Expression( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.I_pH_h2 = pyo.Expression( | |
self.log_I_pH_h2 = pyo.Expression( |
smooth_max(0, self.params.pH_UL_ac - self.pH, eps=1e-8) | ||
/ (self.params.pH_UL_ac - self.params.pH_LL_ac) | ||
) | ||
** 2 | ||
) | ||
|
||
self.I_pH_ac = pyo.Expression( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.I_pH_ac = pyo.Expression( | |
self.log_I_pH_ac = pyo.Expression( |
** 2 | ||
), | ||
return ( | ||
-3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as before- should rename expressions to indicate logarithmic form as well as doc string descriptions.
watertap/property_models/anaerobic_digestion/tests/test_adm1_reaction.py
Show resolved
Hide resolved
assert value(model.fs.unit.liquid_phase.reactions[0].pKW, Var) == pytest.approx( | ||
-log10(2.08e-14), rel=1e-2 | ||
) | ||
assert value( | ||
model.fs.unit.liquid_phase.reactions[0].K_a_co2, Var | ||
) == pytest.approx(4.94e-7, rel=1e-2) | ||
model.fs.unit.liquid_phase.reactions[0].pK_a_co2, Var | ||
) == pytest.approx(-log10(4.94e-7), rel=1e-2) | ||
assert value( | ||
model.fs.unit.liquid_phase.reactions[0].K_a_IN, Var | ||
) == pytest.approx(1.11e-9, rel=1e-2) | ||
model.fs.unit.liquid_phase.reactions[0].pK_a_IN, Var | ||
) == pytest.approx(-log10(1.11e-9), rel=1e-2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarcusHolly can we verify whether updates to documentation will be needed based on the changes in this PR to some variables/constraints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, let's track with an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adam-a-a Yes - it appears some changes will need to be made to the ADM1 and modified ADM1 documentation. I will add it to the master issue and get to it when I have the time.
m.fs.unit.inlet.conc_mass_comp[0, "X_su"].fix(1e-8) | ||
m.fs.unit.inlet.conc_mass_comp[0, "X_aa"].fix(1e-8) | ||
m.fs.unit.inlet.conc_mass_comp[0, "X_fa"].fix(1e-8) | ||
m.fs.unit.inlet.conc_mass_comp[0, "X_c4"].fix(1e-8) | ||
m.fs.unit.inlet.conc_mass_comp[0, "X_pro"].fix(1e-8) | ||
m.fs.unit.inlet.conc_mass_comp[0, "X_ac"].fix(1e-8) | ||
m.fs.unit.inlet.conc_mass_comp[0, "X_h2"].fix(1e-8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why 0s were able to be set for other model specifications after changes but not here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change affected the translators
watertap/examples/flowsheets/case_studies/BSM2/ASM_ADM_integration.py
Outdated
Show resolved
Hide resolved
…into dewatering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have several suggestions that I think can be handled in a subsequent PR. Let's get this in and keep the locomotive moving! Great job!
NOTE: @agarciadiego @MarcusHolly @luohezhiming @TimBartholomew - I renamed the BSM2 folder as "full_water_resource_recovery_facility" since the fixed values specified in the flowsheet deviate from that of BSM2 defaults. Our other implementation of this flowsheet, with BSM2 defaults, is intended to be conveyed through Jupyter Notebook. Also, we talked a bit about this but after some more thought, since we plan to export BSM2 to the GUI, we should probably consider replacing values in the |
Summary/Motivation:
BSM2 full flowsheet #934
Changes proposed in this PR:
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: