watertap.tools.oli_api.util package

Submodules

watertap.tools.oli_api.util.fixed_keys_dict module

class watertap.tools.oli_api.util.fixed_keys_dict.FixedKeysDict(d)[source]

Bases: UserDict

__init__(d)[source]

watertap.tools.oli_api.util.state_block_helper_functions module

watertap.tools.oli_api.util.state_block_helper_functions.convert_to_state_block_units(state_variable, source: dict, key)[source]

Converts state variable values from input source to state block units.

Parameters:
  • state_variable – state block attribute (i.e. temperature, pressure, concentration) to convert

  • source – input source with initial value

  • key – lookup key in input source for specified state variable

watertap.tools.oli_api.util.state_block_helper_functions.create_property_model_input(components, property_model_type: str = '')[source]

Builds property package inputs.

Parameters:
  • components – dictionary containing solute concentrations in mg/L

  • property_model_type – string specifying property model to use

Return property_model_inputs:

dict containing inputs needed to build property model

watertap.tools.oli_api.util.state_block_helper_functions.create_state_block(source_water)[source]

Creates a state block using the Multi Component Aqueous Solution (MCAS) property model.

Parameters:

source_water – dictionary containing state variables and units

Return m:

ConcreteModel containing MCAS state block

watertap.tools.oli_api.util.state_block_helper_functions.extract_state_vars(state_block, conc_var, units)[source]

Extracts state variables from state block into a dictionary.

Parameters:
  • state_block – input source to extract values from

  • conc_var – state block attribute containing concentrations

  • units – dict containing PYOMO unit objects

Return state_vars:

dictionary containing state variables

watertap.tools.oli_api.util.watertap_to_oli_helper_functions module

This file contains methods to convert WaterTAP naming conventions to OLI and generate molecular weight and charge dictionaries from molecular formulae.

It calculates molecular weights using the periodic_table.csv from: https://gist.github.com/GoodmanSciences/c2dd862cd38f21b0ad36b8f96b4bf1ee.

class watertap.tools.oli_api.util.watertap_to_oli_helper_functions.OLIName(oli_name, watertap_name, charge, charge_group, molar_mass)

Bases: tuple

charge

Alias for field number 2

charge_group

Alias for field number 3

molar_mass

Alias for field number 4

oli_name

Alias for field number 0

watertap_name

Alias for field number 1

watertap.tools.oli_api.util.watertap_to_oli_helper_functions.get_charge(watertap_name: str) int[source]

Gets charge from WaterTAP formatted names.

Parameters:

watertap_name – string name of a solute in WaterTAP format

Return charge:

integer value of charge

watertap.tools.oli_api.util.watertap_to_oli_helper_functions.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.tools.oli_api.util.watertap_to_oli_helper_functions.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.

Parameters:

watertap_name – string name of a solute in WaterTAP format

Return molar_mass:

float value for molar mass of solute

watertap.tools.oli_api.util.watertap_to_oli_helper_functions.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.tools.oli_api.util.watertap_to_oli_helper_functions.get_oli_name(watertap_name: str) str[source]

Converts an WaterTAP formatted name, i.e., “Na_+” into an OLI formatted name, i.e., “NAION”.

Parameters:

watertap_name – string name of a solute in WaterTAP format

Return oli_name:

string name of a solute in OLI format

watertap.tools.oli_api.util.watertap_to_oli_helper_functions.get_oli_names(source: dict)[source]

Updates source dictionary with data to populate MCAS property model.

Parameters:

source – dictionary containing WaterTAP names as keys

Return source:

dictionary with OLIName named tuples as keys

watertap.tools.oli_api.util.watertap_to_oli_helper_functions.oli_reverse_lookup(oli_name: str, names_db) OLIName[source]

Looks up WaterTAP formatted name for solute in OLI format, if listed in names_db dictionary.

Parameters:

oli_name – string name of a solute in OLI format

Return watertap_name:

string name of a solute in WaterTAP format

watertap.tools.oli_api.util.watertap_to_oli_helper_functions.watertap_to_oli(watertap_name: str) OLIName[source]

This method creates a named tuple which can be passed directly into OLI or into MCAS property models.

Parameters:

watertap_name – string name of substance in WaterTAP format, i.e., B[OH]4_-

Return OLIName:

named tuple containing attributes derived from molecular formula

Module contents