Skip to content

Add custom PhaseDiagram constructor#113

Merged
prehner merged 2 commits intomainfrom
phase_diagram_python
Jan 17, 2023
Merged

Add custom PhaseDiagram constructor#113
prehner merged 2 commits intomainfrom
phase_diagram_python

Conversation

@prehner
Copy link
Copy Markdown
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
Copy Markdown
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