watertap.core.util package
Submodules
watertap.core.util.infeasible module
This module contains utility functions for infeasibility diagnostics of WaterTAP models.
- watertap.core.util.infeasible.print_close_to_bounds(m, rel_tol=0.0001, abs_tol=1e-12)[source]
Print variables and constraints which are near their bounds
- watertap.core.util.infeasible.print_constraints_close_to_bounds(m, rel_tol=0.0001, abs_tol=1e-05)[source]
print constraints close to their bounds
- watertap.core.util.infeasible.print_infeasible_bounds(m, tol=1e-06, output_file=None)[source]
print the infeasible variable bounds in the model
watertap.core.util.initialization module
This module contains utility functions for initialization of WaterTAP models.
- watertap.core.util.initialization.assert_degrees_of_freedom(blk, expected_dof)[source]
Assert that degrees of freedom are
expected_dof
. If notexpected_dof
, throw an error and stop.- Keyword Arguments
blk – block to check
expected_dof – Integer number of degrees of freedom
blk
should have
- Returns
None
- watertap.core.util.initialization.assert_no_degrees_of_freedom(blk)[source]
Assert that degrees of freedom are 0. If
blk
has non-zero degrees of freedom, throw an error and stop.- Keyword Arguments
blk – block to check
- Returns
None
- watertap.core.util.initialization.assert_no_initialization_perturbation(blk, optarg=None, solver=None)[source]
Assert that IPOPT will not move the initialization
- Parameters
blk – Pyomo block
optarg – IPOPT options (default=None) (Should be None if solver is specified)
solver – Pyomo IPOPT solver instance (default=None) (Should be None if optarg is specified).
- Returns
None
- watertap.core.util.initialization.check_dof(blk, fail_flag=False, logger=<LoggerAdapter idaes.watertap.core.util.initialization (INFO)>, expected_dof=0)[source]
Check that degrees of freedom are 0, or the expected amount
expected_dof
. If not 0 orexpected_dof
, either throw a warning and continue or throw an error and stop.- Keyword Arguments
blk – block to check
fail_flag – Boolean argument to specify error or warning
(Default – fail_flag=False produces logger warning. Set fail_flag=True to raise an error and stop the initialization routine.)
logger – Optional argument for loading idaes.getInitLogger object (e.g., logger=init_log)
expected_dof – Integer number of degrees of freedom
blk
should have
- Returns
None
- watertap.core.util.initialization.check_solve(results, checkpoint=None, logger=<LoggerAdapter idaes.watertap.core.util.initialization (INFO)>, fail_flag=False)[source]
Check that solver termination is optimal and OK in an initialization routine. If the check fails, proceed through initialization with only a logger warning by default, or set fail_flag=True to raise an error. This should also work for checking a solve outside of an initialization routine.
- Keyword Arguments
results – solver results
checkpoint – Optional string argument to specify the step of initialization being checked (e.g., checkpoint=”Initialization step 1: solve indexed blocks”)
logger – Optional argument for loading idaes.getInitLogger object (e.g., logger=init_log)
fail_flag – Boolean argument to specify error or warning (Default: fail_flag=False produces logger warning. set fail_flag=True to raise an error and stop the initialization routine.)
- Returns
None
- watertap.core.util.initialization.generate_initialization_perturbation(blk, bound_push=0.01, bound_frac=0.01, bound_relax_factor=1e-08, user_scaling=False)[source]
Generate the initialization perturbations performed by IPOPT for a given Block
- Parameters
blk – Pyomo block
bound_push – bound_push to evaluate (same as IPOPT option) (default=1e-2)
bound_frac – bound_frac to evaluate (same as IPOPT option) (default=1e-2)
bound_relax_factor – bound_relax_factor to evaluate (same as IPOPT option) (default=1e-8)
user_scaling – If True, the variables are scaled as if nlp_scaling_method = user-scaling is used. (default=False)
- Yields
tuple – (pyo.Var object, current_value, perturbed_value)
- watertap.core.util.initialization.print_initialization_perturbation(blk, bound_push=0.01, bound_frac=0.01, bound_relax_factor=1e-08, user_scaling=False)[source]
Print the initialization perturbations performed by IPOPT for a given Block
- Parameters
blk – Pyomo block
bound_push – bound_push to evaluate (same as IPOPT option) (default=1e-2)
bound_frac – bound_frac to evaluate (same as IPOPT option) (default=1e-2)
bound_relax_factor – bound_relax_factor to evaluate (same as IPOPT option) (default=1e-8)
user_scaling – If True, the variables are scaled as if nlp_scaling_method = user-scaling is used. (default=False)
- Returns
None