diff --git a/property_packages/modular/modular_extended.py b/property_packages/modular/modular_extended.py index c3c5b4d..cbaab3e 100644 --- a/property_packages/modular/modular_extended.py +++ b/property_packages/modular/modular_extended.py @@ -2,6 +2,7 @@ from pyomo.core.base.expression import ScalarExpression from pyomo.core.base.var import ScalarVar, _GeneralVarData, VarData from idaes.core import declare_process_block_class +from idaes.core.util.exceptions import ConfigurationError from idaes.models.properties.modular_properties.base.generic_property import ( _GenericStateBlock, GenericParameterData, @@ -136,7 +137,9 @@ def constrain(self, name: str, value: float): # Value must be a float. TODO: Handle unit conversion. var = getattr(self, name) if type(var) == ScalarExpression: - self.constraints.add_component(name, Constraint(expr=var == value)) + c = Constraint(expr=var == value) + c.abcdef = True + self.constraints.add_component(name, c) elif type(var) in (ScalarVar, _GeneralVarData, VarData): var.fix(value) else: diff --git a/test.py b/test.py index 817a300..4e37047 100644 --- a/test.py +++ b/test.py @@ -16,7 +16,7 @@ def report_vars(blk, file): with open(file, "w") as f: for c in blk.component_data_objects(Var, descend_into=True, active=True): - f.write(f"{c}: {c.value} {"fixed" if c.fixed else "unfixed"}\n") + f.write(f"{c}: {c.value} {'fixed' if c.fixed else 'unfixed'}\n") # with open("file8.txt", "r") as f: # with open(f"{file}_diff", "w") as f2: # for c in blk.component_data_objects(Var, descend_into=True):