From b0f915623d5e6bfe07d6caf16419d06f7c1fe620 Mon Sep 17 00:00:00 2001 From: dallan-keylogic <88728506+dallan-keylogic@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:11:42 -0500 Subject: [PATCH] Deprecate old Cubic EoS (#1519) * cubic_deprecation * Deprecation tests and update docs * run Black * remove deprecation of stateblock and derived class * remove unused import * Try converting plain text reference to preferred implementation to Sphinx link --------- Co-authored-by: Ludovico Bianchi --- .../generic/property_models/ceos.rst | 3 +++ .../models/properties/cubic_eos/cubic_prop_pack.py | 13 +++++++++++++ .../properties/cubic_eos/tests/test_BT_example.py | 8 +++++--- .../cubic_eos/tests/test_cubic_prop_pack.py | 8 +++++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/reference_guides/model_libraries/generic/property_models/ceos.rst b/docs/reference_guides/model_libraries/generic/property_models/ceos.rst index 697a500895..d15a75e4bf 100644 --- a/docs/reference_guides/model_libraries/generic/property_models/ceos.rst +++ b/docs/reference_guides/model_libraries/generic/property_models/ceos.rst @@ -1,6 +1,9 @@ Cubic Equations of State ======================== +.. deprecated:: 2.7 + Use :class:`idaes.models.properties.modular_properties.eos.ceos` in the Modular Property Framework instead. + This property package implements a general form of a cubic equation of state which can be used for most cubic-type equations of state. This package supports phase equilibrium calculations with a smooth phase transition formulation that makes it amenable for equation oriented optimization. The following equations of state are currently supported: * Peng-Robinson diff --git a/idaes/models/properties/cubic_eos/cubic_prop_pack.py b/idaes/models/properties/cubic_eos/cubic_prop_pack.py index 42ca44340c..dfb914f839 100644 --- a/idaes/models/properties/cubic_eos/cubic_prop_pack.py +++ b/idaes/models/properties/cubic_eos/cubic_prop_pack.py @@ -50,6 +50,7 @@ ) from pyomo.common.config import ConfigDict, ConfigValue, In from pyomo.contrib.incidence_analysis import solve_strongly_connected_components +from pyomo.common.deprecation import deprecated # Import IDAES cores from idaes.core import ( @@ -97,6 +98,12 @@ _log = idaeslog.getLogger(__name__) +@deprecated( + msg="The standalone cubic property package has been deprecated in favor of the " + "cubic equation of state for the modular property framework. This class will be " + "removed in the May 2025 release.", + version="2.7.0", +) @declare_process_block_class("CubicParameterBlock") class CubicParameterData(PhysicalParameterBlock): """ @@ -222,6 +229,12 @@ def define_metadata(cls, obj): ) +@deprecated( + msg="The standalone cubic property package has been deprecated in favor of the " + "cubic equation of state for the modular property framework. This class will be " + "removed in the May 2025 release.", + version="2.7.0", +) class CubicEoSInitializer(InitializerBase): """ Initializer for CubicEoS property packages. diff --git a/idaes/models/properties/cubic_eos/tests/test_BT_example.py b/idaes/models/properties/cubic_eos/tests/test_BT_example.py index b9b3a43ff1..9a452062e3 100644 --- a/idaes/models/properties/cubic_eos/tests/test_BT_example.py +++ b/idaes/models/properties/cubic_eos/tests/test_BT_example.py @@ -26,6 +26,7 @@ ) from pyomo.util.check_units import assert_units_consistent +import idaes.logger as idaeslog from idaes.models.properties.tests.test_harness import PropertyTestHarness from idaes.core.solvers import get_solver @@ -76,12 +77,13 @@ def configure(self): @pytest.mark.skipif(not prop_available, reason="Cubic root finder not available") class TestBTExample(object): @pytest.mark.component - def test_units(self): + def test_units(self, caplog): m = ConcreteModel() - m.fs = FlowsheetBlock(dynamic=False) - m.fs.props = BT_PR.BTParameterBlock(valid_phase=("Vap", "Liq")) + with caplog.at_level(idaeslog.WARNING): + m.fs.props = BT_PR.BTParameterBlock(valid_phase=("Vap", "Liq")) + assert "May 2025 release." in caplog.text m.fs.state = m.fs.props.build_state_block([0], defined_state=True) diff --git a/idaes/models/properties/cubic_eos/tests/test_cubic_prop_pack.py b/idaes/models/properties/cubic_eos/tests/test_cubic_prop_pack.py index 6bd4a945e0..c641acdbb4 100644 --- a/idaes/models/properties/cubic_eos/tests/test_cubic_prop_pack.py +++ b/idaes/models/properties/cubic_eos/tests/test_cubic_prop_pack.py @@ -24,6 +24,7 @@ ) from idaes.core import FlowsheetBlock, Component +import idaes.logger as idaeslog from idaes.models.properties.cubic_eos.cubic_prop_pack import ( CubicParameterBlock, CubicStateBlock, @@ -51,12 +52,13 @@ class TestParameterBlock(object): not cubic_roots_available(), reason="Cubic functions not available" ) @pytest.mark.unit - def test_build_default(self): + def test_build_default(self, caplog): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - - m.fs.params = CubicParameterBlock() + with caplog.at_level(idaeslog.WARNING): + m.fs.params = CubicParameterBlock() + assert "May 2025 release." in caplog.text assert m.fs.params.state_block_class is CubicStateBlock assert m.fs.params.config.valid_phase == ("Vap", "Liq")