Unit Models¶
Contents
Introduction¶
The UnitBlock is class is designed to form the basis of all IDAES UnitModels, and contains a number of methods which are common to all Unit Models.
UnitBlock Construction Arguments¶
The UnitBlock class by default has only one construction argument, which is listed below. However, most models inheriting from UnitBlock should declare their own set of configuration arguments which contain more information on how the model should be constructed.
- dynamic - indicates whether the Unit model should be dynamic or steady-state, and if dynamic = True, the unit is declared to be a dynamic model. dynamic defaults to ‘use_parent_value’ if not provided when instantiating the Unit model (see below for more details). It is possible to declare steady-state Unit models as part of dynamic Flowsheets if desired, however the reverse is not true (cannot have dynamic Unit models within steady-state Flowsheets).
Collecting Time Domain¶
The next task of the UnitBlock class is to establish the time domain for the unit by collecting the necessary information from the parent Flowsheet model. If the dynamic construction argument is set to ‘use_parent_value’ then the Unit model looks to its parent model for the dynamic argument, otherwise the value provided at construction is used. Next, the UnitBlock collects the time domain from its parent model and sets this as the time domain for the Unit model.
Finally, if the Unit model has the ‘include_holdup’ construction argument, then this is checked to ensure that if dynamic = True then include_holdup is also True. If this check fails then a warning is raised and the include_holdup argument automatically set to be True.
Modeling Support Methods¶
The UnitBlock class also contains a number of methods designed to facilitate the construction of common components of a model, and these are described below.
Build Inlets Method¶
All (or almost all) Unit Mmodels will have inlets and outlets which allow material to flow in and out of the unit being modeled. In order to save the model developer from having to write the code for each inlet themselves, UnitBlock contains a method named build_inlets which can automatically create an inlet (or set of inlets) to a specified Holdup block. The build_inlets method supports connecting multiple inlets to a single Holdup block, in which case an inlet Mixer Block will be created to mix the inlets prior to entering the Holdup (see documentation for Ports). The build_inlets method is described in more detail in the documentation below.
Build Outlets Method¶
Similar to build_inlets, UnitBlock also has a method named build_outlets for constructing outlets from Unit models. build_outlets also supports multiple outlets from a single holdup, in which case an outlet Splitter Block is created to split the outlet flow (see documentation for Ports). The build_outlets method is described in more detail in the documentation below.
Model Check Method¶
In order to support the IDAES Model Check tools, UnitBlock contains a simple model_check method which assumes a single Holdup block and calls the model_check method on this block. Model developers are encouraged to create their own model_check methods for their particular applications.
Initialization Routine¶
All UnitModels need to have an initialization routine, which should be customized for each Unit model, In order to ensure that all Unit models have at least a basic initialization routine, UnitBlock contains a generic initialization procedure which may be sufficient for simple models with only one Holdup Block. Model developers are strongly encouraged to write their own initialization routines rather than relying on the default method.
UnitBlock Classes¶
-
class
idaes.core.unit_model.
UnitBlock
(*args, **kwargs)¶ Parameters: - rule – (Optional) A rule function or None. Default rule calls build().
- concrete – If True, make this a toplevel model. Default - False.
- ctype – (Optional) Pyomo ctype of the Block.
- dynamic – Indicates whether this model will be dynamic or not (default = ‘use_parent_value’). ‘use_parent_value’ - get flag from parent (default = False) True - set as a dynamic model False - set as a steady-state model
Returns: New UnitBlock instance
-
class
idaes.core.unit_model.
UnitBlockData
(component)[source]¶ This is the class for process unit operations models. These are models that would generally appear in a process flowsheet or superstructure.
-
build
()[source]¶ General build method for UnitBlockData. This method calls a number of sub-methods which automate the construction of expected attributes of unit models.
Inheriting models should call super().build.
Parameters: None – Returns: None
-
build_inlets
(holdup=None, inlets=None, num_inlets=None)[source]¶ This is a method to build inlet Port objects in a unit model and connect these to holdup blocks as needed. This method supports an arbitary number of inlets and holdup blocks, and works for both simple (0D) and 1D IDAES holdup blocks.
Keyword Arguments: - = holdup block to which inlets are associated. If left None, (holdup) – assumes a default holdup (default = None).
- = argument defining inlet names (default (inlets) –
None). inlets may be None or list. - None - assumes a single inlet. - list - use names provided in list for inlets (can be
other iterables, but not a string or dict) - = argument indication number (num_inlets) –
construct (default = None). Not used if inlets arg is provided. - None - use inlets arg instead - int - Inlets will be named with sequential numbers from 1
to num_inlets.
Returns: A Pyomo Port object and assoicated components.
-
build_outlets
(holdup=None, outlets=None, num_outlets=None, material_split_type='flow', energy_split_type='temperature')[source]¶ This is a method to build outlet Port objects in a unit model and connect these to holdup blocks as needed. This method supports an arbitary number of outlets and holdup blocks, and works for both simple (0D) and 1D IDAES holdup blocks.
Keyword Arguments: - = holdup block to which inlets are associated. If left None, (holdup) – assumes a default holdup (default = None).
- = argument defining outlet names (default (outlets) –
None). outlets may be None or list. - None - assumes a single outlet. - list - use names provided in list for outlets (can be
other iterables, but not a string or dict) - = argument indication number (num_outlets) –
construct (default = None). Not used if outlets arg is provided. - None - use outlets arg instead - int - Outlets will be named with sequential numbers from
1 to num_outlets. - = argument defining method to use to split (energy_split_type) –
outlet material flow in case of multiple outlets (default = ‘flow’).
- ’flow’ - outlets are split by total flow
- ’phase’ - outlets are split by phase
- ’component’ - outlets are split by component
- ’total’ - outlets are split by both phase and
- component
- ’duplicate’ - all outlets are duplicates of the
- total outlet stream.
- = argument defining method to use to split –
outlet energy flow in case of multiple outlets (default = ‘temperature’).
- ’temperature’ - equate temperatures in outlets
- ’enth_mol’ - equate molar enthalpies in outlets
- ’enth_mass’ - equate mass enthalpies in outlets
- ’energy_balance’ - outlets energy split using split
- fractions
Returns: A Pyomo Port object and assoicated components.
-
display_variables
(simple=True, descend_into=True)[source]¶ Display all variables associated with the UnitBlockData.
Parameters: simple (bool, optional) – Print a simplified version showing only variable values.
-
initialize
(state_args=None, outlvl=0, solver='ipopt', optarg={'tol': 1e-06})[source]¶ This is a general purpose initialization routine for simple unit models. This method assumes a single Holdup block called holdup, and first initializes this and then attempts to solve the entire unit.
More complex models should overload this method with their own initialization routines,
Keyword Arguments: - state_args – a dict of arguments to be passed to the property package(s) to provide an initial state for initialization (see documentation of the specific property package) (default = {}).
- outlvl –
sets output level of initialisation routine
- 0 = no output (default)
- 1 = return solver state for each step in routine
- 2 = return solver state for each step in subroutines
- 3 = include solver output infomation (tee=True)
- optarg – solver options dictionary object (default={‘tol’: 1e-6})
- solver – str indicating whcih solver to use during initialization (default = ‘ipopt’)
Returns: None
-
model_check
()[source]¶ This is a general purpose initialization routine for simple unit models. This method assumes a single Holdup block called holdup and tries to call the model_check method of the holdup block. If an AttributeError is raised, the check is passed.
More complex models should overload this method with a model_check suited to the particular application, especially if there are multiple Holdup blocks present.
Parameters: None – Returns: None
-