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

Add custom PhaseDiagram constructor #113

Merged
merged 2 commits into from
Jan 17, 2023
Merged

Add custom PhaseDiagram constructor #113

merged 2 commits into from
Jan 17, 2023

Conversation

prehner
Copy link
Contributor

@prehner prehner commented Jan 16, 2023

This allows code like

PhaseDiagram(
    [
        State(eos, temperature, pressure=p, moles=feed).tp_flash()
        for p in pressure
        if not State(eos, temperature, pressure=p, moles=feed).is_stable()
    ]
)

From the resulting PhaseDiagram object, the properties can then be obtained without having to write loops.

Similar to that StateVec is exposed in Python and gets a corresponding constructor, that can be used like this:

StateVec([State(eos, temperature, pressure=p, moles=feed) for p in pressure])

Other smaller changes:

  • PhaseDiagram "inherits" the const generic that indicates the number of phases from PhaseEquilibrium. It was a somewhat unnecessary limitation, that could make future additions breaking changes. In Python PhaseDiagram is still fixed to 2 phases and there is currently no analog to ThreePhaseEquilibrium as it isn't needed.
  • StateVec::moles is added as an additional getter. A small inconvenience: At this point it is not possible to index SIArray2s in Python.

@prehner prehner marked this pull request as ready for review January 17, 2023 15:00
@prehner prehner requested a review from g-bauer January 17, 2023 15:00
Copy link
Contributor

@g-bauer g-bauer left a comment

Choose a reason for hiding this comment

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

Very nice additions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants