The IDAES toolset contains a number of utility functions to assist users with initializing models.
This module contains utility functions for initialization of IDAES models.
- idaes.core.util.initialization.fix_state_vars(blk, state_args=None)¶
Method for fixing state variables within StateBlocks. Method takes an optional argument of values to use when fixing variables.
blk – An IDAES StateBlock object in which to fix the state variables
state_args – a dict containing values to use when fixing state variables. Keys must match with names used in the define_state_vars method, and indices of any variables must agree.
A dict keyed by block index, state variable name (as defined by define_state_variables) and variable index indicating the fixed status of each variable before the fix_state_vars method was applied.
- idaes.core.util.initialization.initialize_by_time_element(fs, time, **kwargs)¶
Function to initialize Flowsheet fs element-by-element along ContinuousSet time. Assumes sufficient initialization/correct degrees of freedom such that the first finite element can be solved immediately and each subsequent finite element can be solved by fixing differential and derivative variables at the initial time point of that finite element.
fs – Flowsheet to initialize
time – Set whose elements will be solved for individually
solver – Pyomo solver object initialized with user’s desired options
outlvl – IDAES logger outlvl
ignore_dof – Bool. If True, checks for square problems will be skipped.
- idaes.core.util.initialization.propagate_state(destination=None, source=None, arc=None, direction='forward', overwrite_fixed=False)¶
This method propagates values between Ports along Arcs. Values can be propagated in either direction using the direction argument.
destination (Port) – Port to copy values to or None if specifying arc
source (Port) – Port to copy values from or None if specifying arc
arc (Arc) – If arc is provided, use arc to define source and destination
direction (str) – Direction in which to propagate values. Default = ‘forward’ Valid values: ‘forward’, ‘backward’.
overwrite_fixed (bool) – If True overwrite fixed values, otherwise do not overwrite fixed values.
- idaes.core.util.initialization.revert_state_vars(blk, flags)¶
Method to revert the fixed state of the state variables within an IDAES StateBlock based on a set of flags of the previous state.
blk – an IDAES StateBlock
flags – a dict of bools indicating previous state with keys in the form (StateBlock index, state variable name (as defined by define_state_vars), var indices).
- idaes.core.util.initialization.solve_indexed_blocks(solver, blocks, **kwds)¶
This method allows for solving of Indexed Block components as if they were a single Block. A temporary Block object is created which is populated with the contents of the objects in the blocks argument and then solved.
solver – a Pyomo solver object to use when solving the Indexed Block
blocks – an object which inherits from Block, or a list of Blocks
kwds – a dict of arguments to be passed to the solver
A Pyomo solver results object