Process Block


ProcessBlock is used to simplify inheritance of Pyomo’s Block. The code below provides an example of how a new ProcessBlock class can be implemented. The new ProcessBlock class has a ConfigBlock that allows each element of the block to be passed configuration options that affect how a block is built. ProcessBlocks have a rule set by default that calls the build method of the contained ProcessBlockData class.

from pyomo.environ import *
from pyomo.common.config import ConfigValue
from idaes.core import ProcessBlockData, declare_process_block_class

class MyBlockData(ProcessBlockData):
    CONFIG = ProcessBlockData.CONFIG()
    CONFIG.declare("xinit", ConfigValue(default=1001, domain=float))
    CONFIG.declare("yinit", ConfigValue(default=1002, domain=float))
    def build(self):
        super(MyBlockData, self).build()
        self.x = Var(initialize=self.config.xinit)
        self.y = Var(initialize=self.config.yinit)

The following example demonstrates creating a scalar instance of the new class. The keyword arguments are used to pass information on the MyBlockData ConfigBlock.

m = ConcreteModel()
m.b = MyBlock(xinit=1, yinit=2)

The next example creates an indexed MyBlock instance. In this case, each block is configured the same, using the keyword arguments.

m = ConcreteModel()
m.b = MyBlock([0,1,2,3,4], xinit=1, yinit=2)

The next example uses the initialize argument to override the default configuration for block 0. Initialize is a dictionary of dictionaries where the key is the block index and the value is the configuration dictionary.

m = ConcreteModel()
m.b = MyBlock(
    [0,1,2,3,4], xinit=1, yinit=2, initialize={0:{"xinit":1, "yinit":2}}

The next example shows a more complicated configuration where there are three configurations, one for the first block, one for the last block, and one for the interior blocks. This is accomplished by providing the idx_map argument to MyBlock, which is a function that maps a block index to a index in the initialize dictionary. In this case 0 is mapped to 0, 4 is mapped to 4, and all elements between 0 and 4 are mapped to 1. A lambda function is used to convert the block index to the correct index in initialize.

m = ConcreteModel()
m.b = MyBlock(
    idx_map = lambda i: 1 if i > 0 and i < 4 else i,
    initialize={0:{"xinit":2001, "yinit":2002},
                1:{"xinit":5001, "yinit":5002},
                4:{"xinit":7001, "yinit":7002}})

The build method

The core part of any IDAES Block is the build method, which contains the instructions on how to construct the variables, constraints and other components that make up the model. The build method serves as the default rule for constructing an instance of an IDAES Block, and is triggered automatically whenever an instance of an IDAES Block is created unless a custom rule is provided by the user.

ProcessBlock Class

idaes.core.base.process_block.declare_process_block_class(name, block_class=<class 'idaes.core.base.process_block.ProcessBlock'>, doc='')[source]

Declare a new ProcessBlock subclass.

This is a decorator function for a class definition, where the class is derived from Pyomo’s _BlockData. It creates a ProcessBlock subclass to contain the decorated class. The only requirment is that the subclass of _BlockData contain a build() method. The purpose of this decorator is to simplify subclassing Pyomo’s block class.

  • name – name of class to create

  • block_class – ProcessBlock or a subclass of ProcessBlock, this allows you to use a subclass of ProcessBlock if needed. The typical use case for Subclassing ProcessBlock is to implement methods that operate on elements of an indexed block.

  • doc – Documentation for the class. This should play nice with sphinx.


Decorator function

class idaes.core.base.process_block.ProcessBlock(*args, **kwds)[source]

ProcessBlock is a Pyomo Block that is part of a system to make Pyomo Block easier to subclass. The main difference between a Pyomo Block and ProcessBlock from the user perspective is that a ProcessBlock has a rule assigned by default that calls the build() method for the contained ProcessBlockData objects. The default rule can be overridden, but the new rule should always call build() for the ProcessBlockData object.

  • 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

  • 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.


(ProcessBlock) New instance

class idaes.core.base.process_base.ProcessBlockData(component)[source]

Base class for most IDAES process models and classes.

The primary purpose of this class is to create the local config block to handle arguments provided by the user when constructing an object and to ensure that these arguments are stored in the config block.

Additionally, this class contains a number of methods common to all IDAES classes.


The build method is called by the default ProcessBlock rule. If a rule is sepecified other than the default it is important to call ProcessBlockData’s build method to put information from the “default” and “initialize” arguments to a ProcessBlock derived class into the BlockData object’s ConfigBlock.

The the build method should usually be overloaded in a subclass derived from ProcessBlockData. This method would generally add Pyomo components such as variables, expressions, and constraints to the object. It is important for build() methods implemented in derived classes to call build() from the super class.






This method fixes the initial conditions for dynamic models.


state – initial state to use for simulation (default = ‘steady-state’)

Returns :



This method returns the components parent flowsheet object, i.e. the flowsheet component to which the model is attached. If the component has no parent flowsheet, the method returns None.




Flowsheet object or None


Return the performance contents and stream table

NOTE: There is the possiblity of a ConfigurationError because the names of the inlets and outlets of the unit model may not be standard. If this occurs then return an empty dataframe


time_point – The time


Pandas dataframe with the performance contents stream_table: Pandas dataframe with the stream table for a unit model

Return type



This method unfixed the initial conditions for dynamic models.



Returns :