Utilities for Dynamic Flowsheets

These are utility functions for working with dynamic IDAES flowsheets.

Methods

This module contains utility functions for dynamic IDAES models.

idaes.core.util.dyn_utils.copy_non_time_indexed_values(fs_tgt, fs_src, copy_fixed=True)[source]

Function to set the values of all variables that are not (implicitly or explicitly) indexed by time to their values in a different flowsheet.

Parameters:
  • fs_tgt – Flowsheet into which values will be copied.
  • fs_src – Flowsheet from which values will be copied.
  • copy_fixed – Bool marking whether or not to copy over fixed variables in the target flowsheet.
Returns:

None

idaes.core.util.dyn_utils.copy_values_at_time(fs_tgt, fs_src, t_target, t_source, copy_fixed=True, outlvl=0)[source]

Function to set the values of all (explicitly or implicitly) time-indexed variables in a flowsheet to similar values (with the same name) but at different points in time and (potentially) in different flowsheets.

Parameters:
  • fs_tgt – Target flowsheet, whose variables’ values will get set
  • fs_src – Source flowsheet, whose variables’ values will be used to set those of the target flowsheet. Could be the target flowsheet
  • t_target – Target time point
  • t_source – Source time point
  • copy_fixed – Bool of whether or not to copy over fixed variables in target model
  • outlvl – IDAES logger output level
Returns:

None

idaes.core.util.dyn_utils.deactivate_constraints_unindexed_by(b, time)[source]

Searches block b for and constraints not indexed by time and deactivates them.

Parameters:
  • b – Block to search
  • time – Set with respect to which to find unindexed constraints
Returns:

List of constraints deactivated

idaes.core.util.dyn_utils.deactivate_model_at(b, cset, pts, outlvl=0)[source]

Finds any block or constraint in block b, indexed explicitly (and not implicitly) by cset, and deactivates it at points specified. Implicitly indexed components are excluded because one of their parent blocks will be deactivated, so deactivating them too would be redundant.

Parameters:
  • b – Block to search
  • cset – ContinuousSet of interest
  • pts – Value or list of values, in ContinuousSet, to deactivate at
Returns:

A dictionary mapping points in pts to lists of component data that have been deactivated there

idaes.core.util.dyn_utils.fix_vars_unindexed_by(b, time)[source]

Searches block b for variables not indexed by time and fixes them.

Parameters:
  • b – Block to search
  • time – Set with respect to which to find unindexed variables
Returns:

List of variables fixed

idaes.core.util.dyn_utils.get_activity_dict(b)[source]

Function that builds a dictionary telling whether or not each ConstraintData and BlockData object in a model is active. Uses the objects’ ids as the hash.

Parameters:b – A Pyomo Block to be searched for active components
Returns:A dictionary mapping id of constraint and block data objects to a bool indicating if they are active
idaes.core.util.dyn_utils.get_derivatives_at(b, time, pts)[source]

Finds derivatives with respect to time at points specified. No distinction made for multiple derivatives or mixed partials.

Parameters:
  • b – Block to search for derivatives
  • time – ContinuousSet to look for derivatives with respect to
  • pts – Value or list of values in time set at which to return derivatives
Returns
Dictionary mapping time points to lists of derivatives at those points
idaes.core.util.dyn_utils.get_index_set_except(comp, *sets)[source]

Function for getting indices of a component over a product of its indexing sets other than those specified. Indices for the specified sets can be used to construct indices of the proper dimension for the original component via the index_getter function.

Parameters:
  • comp – Component whose indexing sets are to be manipulated
  • sets – Sets to omit from the set_except product
Returns:

A dictionary. Maps ‘set_except’ to a Pyomo Set or SetProduct of comp’s index set, excluding those in sets. Maps ‘index_getter’ to a function that returns an index of the proper dimension for comp, given an element of set_except and a value for each set excluded. These values must be provided in the same order their Sets were provided in the sets argument.

idaes.core.util.dyn_utils.is_explicitly_indexed_by(comp, *sets)[source]

Function for determining whether a pyomo component is indexed by a set or group of sets.

Parameters:
  • comp – some Pyomo component, possibly indexed
  • sets – Pyomo Sets to check indexing by
Returns:

A bool that is True if comp is directly indexed each set in sets.

idaes.core.util.dyn_utils.is_implicitly_indexed_by(comp, s, stop_at=None)[source]

Function for determining whether a component is contained in a block that is indexed by a particular set.

Parameters:
  • comp – Component whose parent blocks are checked
  • s – Set for which indices are checked
  • stop_at – Block at which to stop searching if reached, regardless of whether or not it is indexed by s
Returns:

Bool that is true if comp is contained in a block indexed by s

idaes.core.util.dyn_utils.path_from_block(comp, blk, include_comp=False)[source]

Returns a list of tuples with (local_name, index) pairs required to locate comp from blk

Parameters:
  • comp – Component(Data) object to locate
  • blk – Block(Data) to locate comp from
  • include_comp – Bool of whether or not to include the local_name, index of the component itself
Returns:

A list of string, index tuples that can be used to locate comp from blk