Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ccp/config/fluids.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ def get_name(name):

try:
fluid_name = CP.get_REFPROPname(name)
# CoolProp returns empty string for invalid fluid names
if not fluid_name:
raise ValueError(f"Fluid {name} not available. See ccp.fluid_list. ")
except RuntimeError:
# CoolProp raises RuntimeError (v7) or ValueError (v8) for unknown fluids,
# and returns an empty string for invalid names
except (RuntimeError, ValueError):
fluid_name = ""
if not fluid_name:
raise ValueError(f"Fluid {name} not available. See ccp.fluid_list. ")

return fluid_name
Expand Down
8 changes: 4 additions & 4 deletions ccp/tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_eos():
)
assert state.p().units == "pascal"
assert state.T().units == "kelvin"
assert state.p().magnitude == 100000
assert_allclose(state.p().magnitude, 100000)
assert state.T().magnitude == 300
assert_allclose(state.rhomass(), 0.6445687063978816, rtol=1e-6)

Expand All @@ -61,7 +61,7 @@ def test_eos():
)
assert state.p().units == "pascal"
assert state.T().units == "kelvin"
assert state.p().magnitude == 100000
assert_allclose(state.p().magnitude, 100000)
assert state.T().magnitude == 300
assert_allclose(state.rhomass(), 0.6442384800595821, rtol=1e-6)

Expand All @@ -88,15 +88,15 @@ def test_eos_config():
state = State(p=100000, T=300, fluid={"Methane": 1 - 1e-15, "Ethane": 1e-15})
assert state.p().units == "pascal"
assert state.T().units == "kelvin"
assert state.p().magnitude == 100000
assert_allclose(state.p().magnitude, 100000)
assert state.T().magnitude == 300
assert_allclose(state.rhomass(), 0.6445687063978816, rtol=1e-6)

ccp.config.EOS = "SRK"
state = State(p=100000, T=300, fluid={"Methane": 1 - 1e-15, "Ethane": 1e-15})
assert state.p().units == "pascal"
assert state.T().units == "kelvin"
assert state.p().magnitude == 100000
assert_allclose(state.p().magnitude, 100000)
assert state.T().magnitude == 300
assert_allclose(state.rhomass(), 0.6442384800595821, rtol=1e-6)

Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,3 @@ dev = [

[tool.uv]
package = true
# Dev/CI resolution constraint only (does not affect published metadata):
# CoolProp 8 changed the exception type raised for unknown fluids and the
# cubic-EOS roundoff, breaking three tests. Remove once ccp is adapted.
constraint-dependencies = ["coolprop<8"]