Description
Summary
When using the latex_printer
method on an IDAES model an "Internal Pyomo implementation error" is raised. This seems to happen for most any IDAES model. The model solves successfully, so this does not seem to be part of the issue. As far as I can tell this command should print a Latex representation of the IDAES model.
It seems this issue may well be related to issue #3048
Steps to reproduce the issue
-
Properly install Pyomo and IDAES as described in the IDAES documentation(Linux).
-
Run the following script
import pyomo.environ as pyo
from idaes.core import FlowsheetBlock
from pyomo.contrib.latex_printer import latex_printer
from idaes.models.properties.activity_coeff_models.BTX_activity_coeff_VLE import BTXParameterBlock
from idaes.models.unit_models import Flash
m = pyo.ConcreteModel()
m.fs = FlowsheetBlock(dynamic=False)
m.fs.properties = BTXParameterBlock(valid_phase=('Liq', 'Vap'), activity_coeff_model='Ideal', state_vars='FTPz')
m.fs.flash = Flash(property_package=m.fs.properties)
# Initialize the system to 0 degrees of freedom
m.fs.flash.inlet.flow_mol.fix(1.0)
m.fs.flash.inlet.mole_frac_comp[0, 'benzene'].fix(0.5)
m.fs.flash.heat_duty.fix(0)
m.fs.flash.inlet.flow_mol.fix(1)
m.fs.flash.inlet.temperature.fix(368)
m.fs.flash.inlet.pressure.fix(101325)
m.fs.flash.inlet.mole_frac_comp[0, "benzene"].fix(0.5)
m.fs.flash.inlet.mole_frac_comp[0, "toluene"].fix(0.5)
m.fs.flash.heat_duty.fix(0)
m.fs.flash.deltaP.fix(0)
m.fs.flash.initialize()
solver = pyo.SolverFactory('ipopt')
status = solver.solve(m, tee=True)
latex_printer(m)
Error Message
The model itself solves successfully, but raises the following exception when trying to print to Latex.
Traceback (most recent call last):
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/contrib/latex_printer/latex_printer.py", line 400, in exitNode
return self._operator_handles[node.__class__](self, node, *data)
KeyError: <class 'idaes.core.base.process_block._IndexedActivityCoeffStateBlock'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/contrib/latex_printer/latex_printer.py", line 904, in latex_printer
% (visitor.walk_expression(con_template), trailingAligner)
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/core/expr/visitor.py", line 268, in walk_expression
result = self._process_node(root, RECURSION_LIMIT)
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/core/expr/visitor.py", line 351, in _process_node_general
child_result = self._process_node(child, recursion_limit)
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/core/expr/visitor.py", line 351, in _process_node_general
child_result = self._process_node(child, recursion_limit)
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/core/expr/visitor.py", line 351, in _process_node_general
child_result = self._process_node(child, recursion_limit)
[Previous line repeated 3 more times]
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/core/expr/visitor.py", line 371, in _process_node_general
return self.exitNode(node, data)
File "/home/dhill25/miniconda3/envs/idaes/lib/python3.10/site-packages/pyomo/contrib/latex_printer/latex_printer.py", line 402, in exitNode
raise DeveloperError(
pyomo.common.errors.DeveloperError: Internal Pyomo implementation error:
"Latex printer encountered an error when processing type <class
'idaes.core.base.process_block._IndexedActivityCoeffStateBlock'>,
contact the developers"
Please report this to the Pyomo Developers.
Information on your system
Pyomo version: 6.7.0
Python version: 3.10.13
IDAES version: 2.2.0
Operating system: Linux 6.6.13 (Fedora)
How Pyomo was installed (PyPI, conda, source): Conda
Solver (if applicable): IPOPT (solution successful)
Additional information
This minimial working example is based on the simple IDAES flash unit model example, but seems to be an issue with most any IDAES model