watertap.core.util package
Subpackages
Submodules
watertap.core.util.chemistry module
- watertap.core.util.chemistry.get_charge(watertap_name: str) int [source]
Gets charge from WaterTAP formatted names. :param watertap_name: string name of a solute in WaterTAP format :return charge: integer value of charge
- watertap.core.util.chemistry.get_charge_group(charge: int) str [source]
Categorizes molecule based on its charge.
- Parameters:
charge – integer value for charge
- Return group:
string name for charge group
- watertap.core.util.chemistry.get_molar_mass(watertap_name: str) float [source]
Extracts atomic weight data from a periodic table file to generate the molar mass of a chemical substance. TODO: additional testing for complex solutes such as CH3CO2H, [UO2]2[OH]4, etc. :param watertap_name: string name of a solute in WaterTAP format :return molar_mass: float value for molar mass of solute
- watertap.core.util.chemistry.get_molar_mass_quantity(watertap_name: str, units=<pyomo.core.expr.numeric_expr.NPV_DivisionExpression object>)[source]
Extracts atomic weight data from a periodic table file to generate the molar mass of a chemical substance in pint units. Since get_molar_mass returns only the value, which has inherent units of g/mol, this function converts to kg/mol by default, the units used for molecular weight by convention in WaterTAP.
- Parameters:
watertap_name – string name of a solute in WaterTAP format
- Return desired_quantity:
molar mass of solute in pint units. Conversion from g/mol to kg/mol by default.
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.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.interval_initializer(blk, feasibility_tol=1e-06, default_initial_value=0.0, logger=<LoggerAdapter idaes.watertap.core.util.initialization (INFO)>)[source]
Improve the initialization of
blk
utilizing interval arithmetic.- Keyword Arguments:
blk – block to initialize
feasibility_tol – tolerance to use for FBBT (default: 1e-6)
default_initial_value – set uninitialized variables to this value (default: 0.0)
logger – logger to use (default: watertap.core.util.initialization)
- Returns:
None
watertap.core.util.misc module
watertap.core.util.scaling module
This module contains a utility function for the scaling of WaterTAP property model constraints.