idaes.ui package

Submodules

idaes.ui.expr_repn module

idaes.ui.flowsheet module

DrawFlowsheet.py

  • Widget to display/edit the flowsheet

John Eslick, 2017

class idaes.ui.flowsheet.DrawFlowsheet(parent=None, ui_setup=None)[source]

Bases: PyQt5.QtWidgets.QGraphicsView

This is the a QGraphicsView widget for viewing and editing a flowsheet most of the important stuff is in the accosicated scene object

center()[source]

Center the view on the center of the flowsheet

clearSelection()[source]
createScene()[source]

Put items in the scene, these items have refences back to the original Pyomo components for editing and displaying and such

delete_selected()[source]

Delete selected nodes and edges, also deletes any edges connected to a deleted node.

highlightSingleNode(o)[source]
set_mouse_mode(mode)[source]

Set the mouse mode to selection

Parameters:mode – The mouse mode for the scene in [FlowsheetScene.MODE_SELECT, FlowsheetScene.MODE_ADDNODE, FlowsheetScene.MODE_ADDEDGE]
class idaes.ui.flowsheet.FlowsheetScene(parent=None, ui_setup=None)[source]

Bases: PyQt5.QtWidgets.QGraphicsScene

QGraphicsScene class for viewing and editing a Pyomo model block stucture

ITEM_EDGE = 2
ITEM_NODE = 1
ITEM_NONE = 0
MODE_ADDEDGE = 3
MODE_ADDNODE = 2
MODE_SELECT = 1
addTextCenteredOn(x=0, y=0, text='None')[source]

Add text vertically and horizontally centered on (x, y)

Parameters:
  • x – x coordinate of text center
  • y – y coordinate of text center
  • text – text to draw
deleteSelected()[source]

Delete the selected nodes and edges then redraw the flowsheet

drawEdge(x1, y1, x2, y2, index, curve=0)[source]

Draw an edge from x1, y1 to x2, y2. (should connect two blocks)

Parameters:
  • index – the edge index
  • curve – positive or negitive bow in edge (to prevent overlap)
  • tear – if True draw in tear edge style
draw_grid()[source]

Draw the grid for the drawing area

draw_node(x, y, o=None)[source]

Draw a node centered at x,y. Text lines are centered under the node for the node name and node type

Parameters:
  • x – x coordinate of node
  • y – y coordinate of node
  • o – subclass of Pyomo Block
load_brushes()[source]

Put the settings from the brush dict into the brushes used to draw scene

load_font()[source]

Put the font settings into the font used to draw scene

load_pens()[source]

Put the settings from the pen dict into the pens used to draw scene

mouseMoveEvent(evnt)[source]

Mouse move event handler. If mouse button is down move selected nodes

Parameters:evnt – event
mousePressEvent(evnt, dbg_evnt={})[source]

This handles a mouse press event on the flowsheet scene. The dbg_ arguments allow you to simulate a mouse press event. This could be handy for testing and scripting.

Parameters:
  • evnt – Qt mouse press event
  • dbg_evnt – simulated press information dict keys: x, y, mod…
nearestGrid(x, y)[source]

Find the nearest minor grid to a point.

Parameters:
  • x – x coord of point to find nearest grid intersection to
  • y – y coord of point to find nearest grid intersection to

idaes.ui.log_monitor module

Simple flask log viewer. This is just a very prliminary start on a logging viewer that can be used along side a jupyter notebook so that you can see what’s going on in your web browser without junking up the jupyter notbook with a bunch of log messages. This could use a lot of work, but it’s something.

idaes.ui.log_monitor.get_last_updated()[source]
idaes.ui.log_monitor.index()[source]
idaes.ui.log_monitor.lines_str()[source]
idaes.ui.log_monitor.log()[source]
idaes.ui.log_monitor.set_settings()[source]

idaes.ui.model_browser module

A simple GUI viewer for Pyomo models.

class idaes.ui.model_browser.ComponentDataItem(parent, o, ui_setup)[source]

Bases: object

This is a container for a Pyomo component to be displayed in a model tree view.

add_child(o)[source]
calculate()[source]
calculate_children()[source]
clear_cache()[source]
data_items()[source]
get(a)[source]
set(a, val)[source]
class idaes.ui.model_browser.ComponentDataModel(parent, ui_setup, columns=['name', 'value'], components=(<class 'pyomo.core.base.var.Var'>,), editable=[])[source]

Bases: PyQt5.QtCore.QAbstractItemModel

This is a data model to provide the tree structure and information to the tree viewer

columnCount(parent=<PyQt5.QtCore.QModelIndex object>)[source]

Return the number of columns

data(self, QModelIndex, role: int = Qt.DisplayRole) → Any[source]
flags(self, QModelIndex) → Qt.ItemFlags[source]
headerData(i, orientation, role=0)[source]

Return the column headings for the horizontal header and index numbers for the vertical header.

index(self, int, int, parent: QModelIndex = QModelIndex()) → QModelIndex[source]
parent(self, QModelIndex) → QModelIndex[source]

parent(self) -> QObject

rowCount(self, parent: QModelIndex = QModelIndex()) → int[source]
setData(self, QModelIndex, Any, role: int = Qt.EditRole) → bool[source]
update_model()[source]
class idaes.ui.model_browser.ModelBrowser(ui_setup, parent=None, standard='Var')[source]

Bases: idaes.ui.model_browser._ModelBrowser, idaes.ui.model_browser._ModelBrowserUI

calculate_all()[source]
refresh()[source]
toggle()[source]
update_model()[source]

idaes.ui.report module

idaes.ui.report.active_equalities(blk)[source]

Generator returning active equality constraints in a model.

Parameters:blk – a Pyomo block in which to look for variables.
idaes.ui.report.active_equality_set(blk)[source]

Generator returning active equality constraints in a model.

Parameters:blk – a Pyomo block in which to look for variables.
idaes.ui.report.connections(blk)[source]

Returns a list of connected blocks at the level under blk, this only goes one level deep, used for displaying a flowsheet.

idaes.ui.report.count_equality_constraints(blk)[source]

Count active equality constraints.

idaes.ui.report.count_free_variables(blk)[source]

Count free variables that are in active equality constraints. Ignore inequalities, because this is used in the degrees of freedom calculations

idaes.ui.report.degrees_of_freedom(blk)[source]

Return the degrees of freedom.

idaes.ui.report.fixed_variables(blk)[source]

Generator returning fixed variables in a model.

Parameters:blk – a Pyomo block in which to look for variables.
idaes.ui.report.free_variables(blk)[source]

Generator returning free variables in a model. same as unfixed

Parameters:blk – a Pyomo block in which to look for variables.
idaes.ui.report.free_variables_in_active_equalities_set(blk)[source]

Return a set of variables that are contined in active equalities.

idaes.ui.report.large_residuals(blk, tol=1e-05)[source]

Generator return active Pyomo constraints with residuals greater than tol.

Parameters:
  • blk – a Pyomo block in which to look for constraints
  • tol – show constraints with residuals greated than tol
idaes.ui.report.stale_variables(blk)[source]

Generator returning stale variables in a model.

Parameters:blk – a Pyomo block in which to look for variables.
idaes.ui.report.unfixed_variables(blk)[source]

Generator returning free variables in a model.

Parameters:blk – a Pyomo block in which to look for variables.
idaes.ui.report.variables_in_active_equalities_set(blk)[source]

Return a set of variables that are contined in active equalities.

idaes.ui.ui module

A simple GUI viewer for Pyomo models.

class idaes.ui.ui.MainWindow(*args, **kwargs)[source]

Bases: idaes.ui.ui._MainWindow, idaes.ui.ui._MainWindowUI

closeEvent(event)[source]

Handel the colse event by asking for confirmation

exit_action()[source]

Selecting exit from the UI, triggers the close event on this mainwindow

load_state_action()[source]

File dialog to load the model state from json file

model_information()[source]

Put some useful model information into a message box

Displays: * number of active equality constraints * number of free variables in equality constraints * degrees of freedom

Other things that could be added * number of deactivated equalities * number of active inequlaity constraints * number of deactivated inequality constratins * number of free variables not appearing in active constraints * number of fixed variables not appearing in active constraints * number of free variables not appearing in any constraints * number of fixed variables not appearing in any constraints * number of fixed variables appearing in constraints

refresh_on_execute()[source]

This is the call back function that happens when code is executed in the ipython kernel. The main purpose of this right now it to refresh the UI display so that it matches the current state of the model.

save_state_action()[source]

File dialog to save the model state to json file

toggle_always_on_top()[source]

This toggles the always on top hint. Weather this has any effect after the main window is created probably depends on the system.

update_model()[source]
class idaes.ui.ui.UISetup(model=None, model_str='model')[source]

Bases: PyQt5.QtCore.QObject

begin_update()[source]

Lets the model setup be changed without emitting the updated signal until the end_update function is called.

emit_update()[source]
end_update(noemit=False)[source]

Start automatically emitting update signal again when properties are changed and emit update for changes made between begin_update and end_update

model
model_str
updated
idaes.ui.ui.get_mainwindow_nb(model=None, model_str='model', show=True)[source]

Create a UI MainWindow to be used with a Jupyter notebook.

Parameters:
  • model – A Pyomo model to work with
  • model_str – A string that is the model variable in the notebook
  • show – show the window after it is created
idaes.ui.ui.setup_environment(kexec=True)[source]

Setup the standard environment

idaes.ui.util module

Simple GUI utility functions

idaes.ui.util.add_cell()[source]
idaes.ui.util.close_page()[source]
idaes.ui.util.cut_cell()[source]
idaes.ui.util.insert_jupyter_code(code='')[source]
idaes.ui.util.kernel_execute(code)[source]
idaes.ui.util.kernel_interupt()[source]
idaes.ui.util.move_cell_down()[source]
idaes.ui.util.move_cell_up()[source]
idaes.ui.util.run_cells_below()[source]
idaes.ui.util.save_notebook()[source]
idaes.ui.util.show_jupyter_header()[source]
idaes.ui.util.toggle_jupyter_header()[source]