From d76667d19bab2630a1747ae8abad3f398db02c19 Mon Sep 17 00:00:00 2001 From: Alma Walmsley Date: Mon, 23 Dec 2024 11:18:39 +1300 Subject: [PATCH] activate constraints tagged with the `defining_state_var` attribute --- .../modular_properties/base/generic_property.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/idaes/models/properties/modular_properties/base/generic_property.py b/idaes/models/properties/modular_properties/base/generic_property.py index 2dcb428bea..4f98a9b9e0 100644 --- a/idaes/models/properties/modular_properties/base/generic_property.py +++ b/idaes/models/properties/modular_properties/base/generic_property.py @@ -1488,6 +1488,11 @@ def initialization_routine( # constraint at this stage. if "flow_mol_phase_comp" not in b.define_state_vars(): c.activate() + elif getattr(c, "defining_state_var", False): + # Allow using a constraint to define a state var + # (rather than fixing it directly) by setting + # c.defining_state_var = True. + c.activate() for pp in b.params._pe_pairs: # Activate formulation specific constraints @@ -1938,6 +1943,12 @@ def initialize( # constraint at this stage. if "flow_mol_phase_comp" not in b.define_state_vars(): c.activate() + elif getattr(c, "defining_state_var", False): + # Allow using a constraint to define a state var + # (rather than fixing it directly) by setting + # c.defining_state_var = True. This can be used in + # conjunction with setting state_vars_fixed = True + c.activate() for pp in b.params._pe_pairs: # Activate formulation specific constraints