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

Bug in flash routines with fixed phase #656

Closed
jowr opened this issue May 8, 2015 · 4 comments
Closed

Bug in flash routines with fixed phase #656

jowr opened this issue May 8, 2015 · 4 comments
Milestone

Comments

@jowr
Copy link
Member

jowr commented May 8, 2015

Calling FlashRoutines::PHSU_D_flash with a pre-specified phase flag does not populate the state object properly. There is something wrong with the if-clause, it seems to be misplaced, see https://github.com/CoolProp/CoolProp/blob/master/src/Backends/Helmholtz/FlashRoutines.cpp#L727-L733 .

import CoolProp
state = CoolProp.AbstractState('HEOS','R134a')
state.update(CoolProp.HmassP_INPUTS, 394738, 101325)
state.T()
CoolProp.CoolProp.PropsSI("T","H",394738,"P",101325,"R134a")
state.specify_phase(CoolProp.iphase_gas)
state.update(CoolProp.HmassP_INPUTS, 394738, 101325)
state.specify_phase(CoolProp.iphase_unknown)
state.update(CoolProp.HmassP_INPUTS, 394738, 101325)
state.specify_phase(CoolProp.iphase_not_imposed)
state.update(CoolProp.HmassP_INPUTS, 394738, 101325)
@jowr jowr changed the title Bug in FlashRoutines::PHSU_D_flash Bug in flash routines with fixed phase May 8, 2015
@jowr
Copy link
Member Author

jowr commented May 8, 2015

This one affects a couple of flash routines...

import CoolProp
state = CoolProp.AbstractState('HEOS','R134a')
state.update(CoolProp.HmassP_INPUTS, 394738, 101325)
T = state.T()
p = state.p()
h = state.hmass()
s = state.smass()
d = state.rhomass()
state.specify_phase(CoolProp.iphase_gas)
state.update(CoolProp.HmassP_INPUTS, h, p)
state.update(CoolProp.PSmass_INPUTS, p, s)
state.update(CoolProp.DmassP_INPUTS, d, p)
state.specify_phase(CoolProp.iphase_not_imposed)
state.update(CoolProp.HmassP_INPUTS, h, p)
state.update(CoolProp.PSmass_INPUTS, p, s)
state.update(CoolProp.DmassP_INPUTS, d, p)

@ibell
Copy link
Contributor

ibell commented May 15, 2015

What is wrong? Can you explain? I should be able to fix it if you can clarify.

@jowr
Copy link
Member Author

jowr commented May 15, 2015

Have you tried running the code above? Does it work for you?

Here is what I experienced:
In some of the flash routines, the if-clause if (HEOS.imposed_phase_index != iphase_not_imposed) seems to turn off all calculations and not only the phase determination. The state object does not get populated and the code fails because the internal temperature HEOS._T is not a number.

In short: I think the if-clauses have to be restructured to respect an imposed phase. If the phase is not imposed, everyhting is finde because the phase detection fills the variables required during the post update steps. I am not sure which flash routines are affected, but I found at least three (see above).

It should be fixable, but I do not feel comfortable making some sort of a hotfix because there still a few things in the HEOS backends that I do not understand completely.

@ibell
Copy link
Contributor

ibell commented May 15, 2015

Hmm, this does seem like a bug. Let me see what I can do.

On Fri, May 15, 2015 at 2:21 AM, Jorrit Wronski notifications@github.com
wrote:

Have you tried running the code above? Does it work for you?

Here is what I experienced:
In some of the flash routines, the if-clause if (HEOS.imposed_phase_index
!= iphase_not_imposed) seems to turn off all calculations and not only
the phase determination. The state object does not get populated and the
code fails because the internal temperature HEOS._T is not a number.

In short: I think the if-clauses have to be restructured to respect an
imposed phase. If the phase is not imposed, everyhting is finde because the
phase detection fills the variables required during the post update steps.
I am not sure which flash routines are affected, but I found at least three
(see above).

It should be fixable, but I do not feel comfortable making some sort of a
hotfix because there still a few things in the HEOS backends that I do not
understand completely.


Reply to this email directly or view it on GitHub
#656 (comment).

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

No branches or pull requests

2 participants