Unit Model Class

The UnitModelBlock is class is designed to form the basis of all IDAES Unit Models, and contains a number of methods which are common to all Unit Models.

UnitModelBlock Construction Arguments

The UnitModelBlock class by default has only one construction argument, which is listed below. However, most models inheriting from UnitModelBlock 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 useDefault 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 UnitModelBlock 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 useDefault then the Unit model looks to its parent model for the dynamic argument, otherwise the value provided at construction is used.

Finally, if the Unit model has a construction argument named “has_holdup” (not part of the base class), then this is checked to ensure that if dynamic = True then has_holdup is also True. If this check fails then a ConfigurationError exception will be thrown.

Modeling Support Methods

The UnitModelBlock 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 Models 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, UnitModelBlock contains a method named build_inlet_port which can automatically create an inlet to a specified ControlVolume block (or linked to a specified StateBlock). The build_inlet_port method is described in more detail in the documentation below.

Build Outlets Method

Similar to build_inlet_port, UnitModelBlock also has a method named build_outlet_port for constructing outlets from Unit models. The build_outlet_port method is described in more detail in the documentation below.

Model Check Method

In order to support the IDAES Model Check tools, UnitModelBlock 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 Unit Models 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, UnitModelBlock 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.

UnitModelBlock Classes

class idaes.core.unit_model.UnitModelBlockData(component)[source]

This is the class for process unit operations models. These are models that would generally appear in a process flowsheet or superstructure.

add_inlet_port(name=None, block=None, doc=None)[source]

This is a method to build inlet Port objects in a unit model and connect these to a specified control volume or state block.

The name and block arguments are optional, but must be used together. i.e. either both arguments are provided or neither.

Keyword Arguments
  • name – name to use for Port object (default = “inlet”).

  • block – an instance of a ControlVolume or StateBlock to use as the source to populate the Port object. If a ControlVolume is provided, the method will use the inlet state block as defined by the ControlVolume. If not provided, method will attempt to default to an object named control_volume.

  • doc – doc string for Port object (default = “Inlet Port”)

Returns

A Pyomo Port object and associated components.

add_outlet_port(name=None, block=None, doc=None)[source]

This is a method to build outlet Port objects in a unit model and connect these to a specified control volume or state block.

The name and block arguments are optional, but must be used together. i.e. either both arguments are provided or neither.

Keyword Arguments
  • name – name to use for Port object (default = “outlet”).

  • block – an instance of a ControlVolume or StateBlock to use as the source to populate the Port object. If a ControlVolume is provided, the method will use the outlet state block as defined by the ControlVolume. If not provided, method will attempt to default to an object named control_volume.

  • doc – doc string for Port object (default = “Outlet Port”)

Returns

A Pyomo Port object and associated components.

add_port(name=None, block=None, doc=None)[source]

This is a method to build Port objects in a unit model and connect these to a specified StateBlock.

Keyword Arguments
  • name – name to use for Port object.

  • block – an instance of a StateBlock to use as the source to populate the Port object

  • doc – doc string for Port object

Returns

A Pyomo Port object and associated components.

add_state_material_balances(balance_type, state_1, state_2)[source]

Method to add material balances linking two State Blocks in a Unit Model. This method is not intended to replace Control Volumes, but to automate writing material balances linking isolated State Blocks in those models where this is required.

Parameters
  • type (balance_type - a MaterialBalanceType Enum indicating the) – of material balances to write

  • balances (state_2 - second State Block to be linked by) –

  • balances

Returns

None

build()[source]

General build method for UnitModelBlockData. 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

del_component(name_or_object)[source]

Delete a component from this block. Need to introduce code to handle un-registering costing blocks

initialize(*args, **kwargs)[source]

Initialization routine for Unit Model objects and associated components.

This method is intended for initializing IDAES unit models and any modeling components attached to them, such as costing blocks. This method iterates through all objects in blk._initialization_order and deactivates them, followed by calling blk.initialize_build. Finally, it iterates through all objects in blk._initialization_order in reverse and re-activates these whilst calling the associated initialize method.

Currently, parsing of arguments to the initialize method of attached blocks is hard coded - this will be addressed in a future PR. Currently, the method supports the following attached components:

  • UnitModelCostingBlocks

Parameters

block (costing_args - dict arguments to be passed to costing) – initialize method

For other arguments, see the initilize_unit method.

initialize_build(state_args=None, outlvl=0, solver=None, optarg=None)[source]

This is a general purpose initialization routine for simple unit models. This method assumes a single ControlVolume block called controlVolume, 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 initialization routine

  • optarg – solver options dictionary object (default=None, use default solver options)

  • solver – str indicating which solver to use during initialization (default = None, use default IDAES solver)

Returns

None

model_check()[source]

This is a general purpose initialization routine for simple unit models. This method assumes a single ControlVolume block called controlVolume and tries to call the model_check method of the controlVolume 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 ControlVolume blocks present.

Parameters

None

Returns

None

class idaes.core.unit_model.UnitModelBlock(*args, **kwds)
Parameters
  • rule (function) – A rule function or None. Default rule calls build().

  • concrete (bool) – If True, make this a toplevel model. Default - False.

  • ctype (class) – Pyomo ctype of the block. Default - pyomo.environ.Block

  • default (dict) –

    Default ProcessBlockData config

    Keys
    dynamic

    Indicates whether this model will be dynamic or not, default = useDefault. Valid values: { useDefault - get flag from parent (default = False), True - set as a dynamic model, False - set as a steady-state model.}

    has_holdup

    Indicates whether holdup terms should be constructed or not. Must be True if dynamic = True, default - False. Valid values: { useDefault - get flag from parent (default = False), True - construct holdup terms, False - do not construct holdup terms}

  • initialize (dict) – ProcessBlockData config for individual elements. Keys are BlockData indexes and values are dictionaries described under the “default” argument above.

  • idx_map (function) – Function to take the index of a BlockData element and return the index in the initialize dict from which to read arguments. This can be provided to overide the default behavior of matching the BlockData index exactly to the index in initialize.

Returns

(UnitModelBlock) New instance