Skip to content

Commit

Permalink
make critical phase hook optional
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelcortes committed Aug 29, 2022
1 parent d7d9749 commit 7bbb637
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions thermosteam/base/phase_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,19 @@ def show(self):

class PhaseTHandle(PhaseHandle):
__slots__ = ()
force_gas_critical_phase = False

def __call__(self, phase, T, P=None):
if self.Tc is not None and T > self.Tc: phase = 'g'
if self.force_gas_critical_phase and T > self.Tc: phase = 'g'
return getattr(self, phase)(T)


class PhaseTPHandle(PhaseHandle):
__slots__ = ()
force_gas_critical_phase = False

def __call__(self, phase, T, P):
if self.Tc is not None and T > self.Tc: phase = 'g'
if self.force_gas_critical_phase and T > self.Tc: phase = 'g'
return getattr(self, phase)(T, P)


Expand Down

5 comments on commit 7bbb637

@yoelcortes
Copy link
Member Author

Choose a reason for hiding this comment

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

@BenPortner, the critical phase hook turned out to be problematic for several mixtures in biorefineries since some liquid components are supposed to be liquid when part of a mixture (the mixture critical point is different than the pure component critical point). To force components to use gas phase when the temperature is above the pure component critical point, please run the following:

>>> from thermosteam.base import PhaseTPHandle, PhaseTHandle
>>> PhaseTPHandle.force_gas_critical_phase = PhaseTHandle.force_gas_critical_phase  = True

Thanks

@BenPortner
Copy link
Collaborator

Choose a reason for hiding this comment

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

@yoelcortes Doesn't the hook decide the phase for each chemical individually? If yes, one chemical's liquid state should not be affected by another chemical's supercritical state. Are you sure there isn't another problem here?

@yoelcortes
Copy link
Member Author

Choose a reason for hiding this comment

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

Ohh, I meant that some supercritical components are not actually supercritical when in a mixture, so letting those use liquid volumes (among other properties) is needed. A better long term solution is to use mixture equations of state, but that's still not in BioSTEAM's capabilities...

@BenPortner
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. How about going back to using the maximum of all critical temperatures in the mixture? I expect that Tc,mix <= max(Tc,i) for all chemicals i in the mixture?

@yoelcortes
Copy link
Member Author

@yoelcortes yoelcortes commented on 7bbb637 Aug 29, 2022

Choose a reason for hiding this comment

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

@BenPortner, that can work for chemicals that don't have positive interactions (when Tc_mixture is not higher that max(Tcs)), I'm just afraid of how this would affect energy balances. But I am thinking it may better to solve the problem at the VLE algorithm... I am wondering why would N2 or H2 show as a liquid above the critical point? I'll try to find a solution to this within a couple of days so that we don't need a fancy hook anymore.

Please sign in to comment.