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

Dewatering and thickener unit models BSM2 #1010

Merged
merged 23 commits into from
Apr 27, 2023

Conversation

agarciadiego
Copy link
Contributor

@agarciadiego agarciadiego commented Apr 20, 2023

Summary/Motivation:

Unit model necessary for BSM2 flowsheet. Addresses point in Issue #934

Changes proposed in this PR:

  • Include dewatering unit model
  • Include thickener unit model

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@agarciadiego agarciadiego added Priority:Normal Normal Priority Issue or PR iedo labels Apr 20, 2023
@agarciadiego agarciadiego self-assigned this Apr 20, 2023
@agarciadiego agarciadiego marked this pull request as draft April 20, 2023 19:54
@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Attention: Patch coverage is 97.22222% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.82%. Comparing base (a4fed99) to head (84585e5).
Report is 335 commits behind head on main.

Files with missing lines Patch % Lines
watertap/unit_models/thickener.py 96.29% 2 Missing ⚠️
watertap/unit_models/dewatering.py 98.07% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1010    +/-   ##
========================================
  Coverage   95.81%   95.82%            
========================================
  Files         296      298     +2     
  Lines       28475    28583   +108     
========================================
+ Hits        27284    27389   +105     
- Misses       1191     1194     +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@agarciadiego agarciadiego marked this pull request as ready for review April 25, 2023 18:00
@agarciadiego agarciadiego changed the title Dewatering unit model BSM2 Dewatering and thickener unit models BSM2 Apr 25, 2023
Copy link
Contributor

@MarcusHolly MarcusHolly left a comment

Choose a reason for hiding this comment

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

LGTM - I will add the documentation under a separate PR.

"and underflow as outlets.".format(self.name)
)

self.p_dewat = Param(
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 shoot for more elaborate naming schemes. My guess without referring back to the literature is that you went with matching symbols in the literature. While that seems reasonable for the popular ASM and ADM models, I wonder if it might be more useful to offer up our own names in these unit cases for improved clarity. This is a broad comment regarding any parameter/variable names, when I compare those names with the associated doc string and question their alignment.

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 think if we are following ASM and ADM convention for names of our property, reaction package, etc. following naming convention from BSM2 paper would avoid confusion for users specially if they are following the paper we added as references.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough - the documentation will probably help things.

)
def non_particulate_components(blk, t, i):
return blk.split_fraction[t, "overflow", i] == 1 - blk.f_q_du[t]

Copy link
Contributor

Choose a reason for hiding this comment

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

So, for both units, I'm aware that you didn't add initialize_build and calcualte_scaling_factors methods, likely because the separator handles those. I still wonder though if we should include them here anyway, even if, for example, we just have loggers setup for initialization and run super().calculate_scaling_factors(). @andrewlee94 curious to hear your thoughts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you inherit from another model or base class, then any methods you do not overload will use that of the parent. For initialization this might be OK as long as the additions in the new model are relatively simple. However, for scaling, the new model is adding new variables and constraints (otherwise it wouldn't be a new model), and the parent's scaling methods won't touch these leaving part of the model unscaled.

On a related note, be aware that IDAES plans to rebuild both initialization and scaling this year. The new scaling API is already in place if you want to start looking at it: https://idaes-pse.readthedocs.io/en/latest/reference_guides/initialization/index.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I figured we could technically get away with it since the Separator's initialization and calculate_scaling_factors are essentially being used here, but that it might just be good practice and make for better readability/consistency between models for [new] developers. Furthermore, there are probably some unscaled vars that are added here but simple enough that additional scaling doesn't seem necessary at this point. I think we could put a pin in it for now and revisit if issues arise when analyzing the BSM2 flowsheet later.

And thanks for the note on the new scaling API.

Comment on lines +184 to +195
@pytest.mark.solver
@pytest.mark.skipif(solver is None, reason="Solver not available")
@pytest.mark.component
def test_initialize(self, du):

iscale.calculate_scaling_factors(du)
initialization_tester(du)

@pytest.mark.solver
@pytest.mark.skipif(solver is None, reason="Solver not available")
@pytest.mark.component
def test_solve(self, du):
Copy link
Contributor

Choose a reason for hiding this comment

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

There should typically be a test to check for badly scaled variables here. I checked, and a few will crop up. We can be lenient about it and make a note to revisit in our master issue, considering the whole effort here for the BSM2 flowsheet, or you could add the typical test to check for badly scaled vars and eliminate any that exist by adding scaling. Though the badly scaled vars are probably attributed to zero components, it's hard to say whether this will end up impacting model stability at the flowsheet level later on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, through our off-GH discussion, you made it clear that the badly scaled vars stem from the lack of scaling on the ASM1 property model, which we have noted in our master issue (#934)

@adam-a-a adam-a-a enabled auto-merge (squash) April 27, 2023 18:43
Copy link
Contributor

@adam-a-a adam-a-a left a comment

Choose a reason for hiding this comment

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

LGTM

@adam-a-a adam-a-a merged commit a305488 into watertap-org:main Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iedo Priority:Normal Normal Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants