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

Multi-effect crystallizer unit model #121

Merged
merged 92 commits into from
Oct 10, 2024

Conversation

Zhuoran29
Copy link
Collaborator

@Zhuoran29 Zhuoran29 commented Jul 18, 2024

This PR adds:

  • CrystallizerEffect unit model
  • MultiEffectCrystallizer unit model that is comprised of n CrystallizerEffect unit models connected via constraints
  • test files for both
  • costing for MultiEffectCrystallizer and CrystallizerEffect
  • importantly, this PR also points to watertap==1.0.0rc0 in setup.py

TODO:

  • check units on heat transfer equations
  • test file for CrystallizerEffect
  • determine if flow_vol_phase['Vap'] is the proper flow to cost for steam
  • remove name == "main" in unit model files

@kurbansitterley
Copy link
Contributor

@Zhuoran29 can you run black so we can see the results of the GH tests please?

@Zhuoran29 Zhuoran29 self-assigned this Jul 24, 2024
@Zhuoran29
Copy link
Collaborator Author

@Zhuoran29 can you run black so we can see the results of the GH tests please?

Sure, it seems the cost package is not adjusted well and I'll look into it.

def test_initialize(self, Crystallizer_frame):
# Add costing function, then initialize
m = Crystallizer_frame
# m.fs.costing = WaterTAPCosting()
Copy link
Contributor

Choose a reason for hiding this comment

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

@Zhuoran29 just skimming this from my phone, but maybe the failed tests are due to the costing lines being commented out here.

Copy link
Contributor

Choose a reason for hiding this comment

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

In any case, I’d recommend just having a separate test_costing test rather than bundle it up in the initialization test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now the costing package is rebuilt in REFLO and tested separately.

@Zhuoran29
Copy link
Collaborator Author

I added the costing package from the WaterTAP repo and a test file for the flowsheet, where both simulation and optimization modes were tested.

@Zhuoran29
Copy link
Collaborator Author

Hey @kurbansitterley @adam-a-a , forgot to tag you when I updated this PR.

opt = get_solver(solver, optarg)
for n, eff in self.effects.items():
if n == 1:
assert degrees_of_freedom(eff.effect) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This should raise an exception if DOF do not equal 0

Copy link
Contributor

Choose a reason for hiding this comment

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

addressed

return m


class TestMultiEffectCrystallizer_4Effects:
Copy link
Contributor

Choose a reason for hiding this comment

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

So 4 effects is the default, and you test for 4 effects and 3 effects. What happens if the user tries entering 1 effect? Similarly, what about 2 effects? I went scanned through the core code quickly, so I know I missed this. I just wonder if we should just add two quick, shortened versions of these tests just to ensure that we get what we'd expect from entering 1 effect or 2 effects. For example, in 2 effects, I might expect some special handling of the first and last effect, hence interest in this case. For 1 effect, I would expect the code to handle this case or throw an exception if the multieffect model is not setup to handle specification of 1 effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

addressed in e0b5b44.

Added test for 2 effects.
If the user tries to use MultiEffectCrystallizer with a single effect, it will raise ConfigurationError and they will be directed to use the CrystallizerEffect model.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. One thought I have--say you wanted to run optimization cases across a range of conditions and a range of number of effects, including a single effect. You'd need to add some logic in to such a script to toggle between the CrystallizerEffect model for the case where a single effect is optimized, and then toggle to the MultiEffectCrystallizer model for all other cases.

All that just to say, it might be useful to actually allow for a single effect via MultiEffectCrystallizer too. Definitely not something to consider for this PR--just food for thought.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about this now, I don't think it would be very hard to implement, maybe a little clunky, but I do like the idea of having all the functionality for a unit model within a single model rather than directing the user to use a different unit model. A consideration for the future.

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.

Quite an impressive bit of work here that I know must've taken a lot of thought and effort! Well done! I just have a couple of comments from a quick scan.

@adam-a-a
Copy link
Contributor

adam-a-a commented Oct 7, 2024

My other general comment is we definitely want to document the single and multieffect models thoroughly--though that can happen in a subsequent PR down the line and shouldn't hold this up.

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 - I had another comment or two to consider but I think this should be good to merge. We can make issues on any other gaps identified here.

@Zhuoran29
Copy link
Collaborator Author

Zhuoran29 commented Oct 10, 2024

I ran a few cases and the results are looking good to me! Also I added a test for an optimization scenario in case it's helpful to the case study. If the additions look good to you then I think it's good to go, but please feel free to not include it. @kurbansitterley

@kurbansitterley kurbansitterley merged commit 799a88e into watertap-org:main Oct 10, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants