From eb43a2dc569c9e6d27e27e550366ec4c0408ad28 Mon Sep 17 00:00:00 2001 From: Adam Atia Date: Fri, 29 Mar 2024 01:40:31 -0400 Subject: [PATCH 1/7] delete sw prop files --- .../property_models/seawater_ion_generic.py | 263 -------- .../property_models/seawater_ion_prop_pack.py | 580 ------------------ .../tests/test_seawater_ion_generic.py | 81 --- 3 files changed, 924 deletions(-) delete mode 100644 watertap/property_models/seawater_ion_generic.py delete mode 100644 watertap/property_models/seawater_ion_prop_pack.py delete mode 100644 watertap/property_models/tests/test_seawater_ion_generic.py diff --git a/watertap/property_models/seawater_ion_generic.py b/watertap/property_models/seawater_ion_generic.py deleted file mode 100644 index 95f270dbe9..0000000000 --- a/watertap/property_models/seawater_ion_generic.py +++ /dev/null @@ -1,263 +0,0 @@ -################################################################################# -# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, -# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, -# National Renewable Energy Laboratory, and National Energy Technology -# Laboratory (subject to receipt of any required approvals from the U.S. Dept. -# of Energy). All rights reserved. -# -# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license -# information, respectively. These files are also available online at the URL -# "https://github.com/watertap-org/watertap/" -################################################################################# -""" -Artificial seawater properties comprising Na+, Cl-, Ca_2+, SO4_2-, Mg_2+ -Equation of state: eNRTL - -eNRTL property configuration dicts for synthetic hard water based on [1] - -References: - -[1] Islam, R.I., et al., Molecular thermodynamics for scaling prediction: Case -of membrane distillation, Separation and Purification Technology, 2021, -Vol. 276. -""" - -from pyomo.environ import Param, units as pyunits - -from idaes.core import ( - AqueousPhase, - Solvent, - Apparent, - Anion, - Cation, - MaterialFlowBasis, -) -from idaes.models.properties.modular_properties.eos.enrtl import ENRTL -from idaes.models.properties.modular_properties.eos.enrtl_reference_states import ( - Symmetric, -) -from idaes.models.properties.modular_properties.base.generic_property import StateIndex -from idaes.models.properties.modular_properties.state_definitions import FpcTP -from idaes.models.properties.modular_properties.pure.electrolyte import ( - relative_permittivity_constant, -) -import idaes.logger as idaeslog - -# Set up logger -_log = idaeslog.getLogger(__name__) - - -class VolMolH2O: - def build_parameters(self): - self.vol_mol_pure = Param( - initialize=18e-6, units=pyunits.m**3 / pyunits.mol, mutable=True - ) - - def return_expression(self, cobj, T): - return cobj.vol_mol_pure - - -class VolMolNaCl: - def build_parameters(self): - self.vol_mol_pure = Param( - initialize=58.44e-6, units=pyunits.m**3 / pyunits.mol, mutable=True - ) - - def return_expression(self, cobj, T): - return cobj.vol_mol_pure - - -class VolMolNa2SO4: - def build_parameters(self): - self.vol_mol_pure = Param( - initialize=142.04e-6, units=pyunits.m**3 / pyunits.mol, mutable=True - ) - - def return_expression(self, cobj, T): - return cobj.vol_mol_pure - - -class VolMolCaCl2: - def build_parameters(self): - self.vol_mol_pure = Param( - initialize=110.98e-6, units=pyunits.m**3 / pyunits.mol, mutable=True - ) - - def return_expression(self, cobj, T): - return cobj.vol_mol_pure - - -class VolMolCaSO4: - def build_parameters(self): - self.vol_mol_pure = Param( - initialize=136.14e-6, units=pyunits.m**3 / pyunits.mol, mutable=True - ) - - def return_expression(self, cobj, T): - return cobj.vol_mol_pure - - -class VolMolMgCl2: - def build_parameters(self): - self.vol_mol_pure = Param( - initialize=95.21e-6, units=pyunits.m**3 / pyunits.mol, mutable=True - ) - - def return_expression(self, cobj, T): - return cobj.vol_mol_pure - - -class VolMolMgSO4: - def build_parameters(self): - self.vol_mol_pure = Param( - initialize=120.37e-6, units=pyunits.m**3 / pyunits.mol, mutable=True - ) - - def return_expression(self, cobj, T): - return cobj.vol_mol_pure - - -configuration = { - "components": { - "H2O": { - "type": Solvent, - "vol_mol_liq_comp": VolMolH2O, - "relative_permittivity_liq_comp": relative_permittivity_constant, - "parameter_data": { - "mw": (18e-3, pyunits.kg / pyunits.mol), - "relative_permittivity_liq_comp": 78.54, - }, - }, - "NaCl": { - "type": Apparent, - "dissociation_species": {"Na_+": 1, "Cl_-": 1}, - "vol_mol_liq_comp": VolMolNaCl, - "parameter_data": {"mw": (58.44e-3, pyunits.kg / pyunits.mol)}, - }, - "Na2SO4": { - "type": Apparent, - "dissociation_species": {"Na_+": 2, "SO4_2-": 1}, - "vol_mol_liq_comp": VolMolNa2SO4, - "parameter_data": {"mw": (142.04e-3, pyunits.kg / pyunits.mol)}, - }, - "CaCl2": { - "type": Apparent, - "dissociation_species": {"Ca_2+": 1, "Cl_-": 2}, - "vol_mol_liq_comp": VolMolCaCl2, - "parameter_data": {"mw": (110.98e-3, pyunits.kg / pyunits.mol)}, - }, - "CaSO4": { - "type": Apparent, - "dissociation_species": {"Ca_2+": 1, "SO4_2-": 1}, - "vol_mol_liq_comp": VolMolCaSO4, - "parameter_data": {"mw": (136.14e-3, pyunits.kg / pyunits.mol)}, - }, - "MgCl2": { - "type": Apparent, - "dissociation_species": {"Mg_2+": 1, "Cl_-": 2}, - "vol_mol_liq_comp": VolMolMgCl2, - "parameter_data": {"mw": (95.21e-3, pyunits.kg / pyunits.mol)}, - }, - "MgSO4": { - "type": Apparent, - "dissociation_species": {"Mg_2+": 1, "SO4_2-": 1}, - "vol_mol_liq_comp": VolMolMgSO4, - "parameter_data": {"mw": (120.37e-3, pyunits.kg / pyunits.mol)}, - }, - "Na_+": {"type": Cation, "charge": +1, "parameter_data": {"mw": 23e-3}}, - "Ca_2+": {"type": Cation, "charge": +2, "parameter_data": {"mw": 40e-3}}, - "Mg_2+": {"type": Cation, "charge": +2, "parameter_data": {"mw": 24.3e-3}}, - "Cl_-": {"type": Anion, "charge": -1, "parameter_data": {"mw": 35.45e-3}}, - "SO4_2-": {"type": Anion, "charge": -2, "parameter_data": {"mw": 96.06e-3}}, - }, - "phases": { - "Liq": { - "type": AqueousPhase, - "equation_of_state": ENRTL, - "equation_of_state_options": {"reference_state": Symmetric}, - } - }, - "base_units": { - "time": pyunits.s, - "length": pyunits.m, - "mass": pyunits.kg, - "amount": pyunits.mol, - "temperature": pyunits.K, - }, - "state_definition": FpcTP, - "state_components": StateIndex.true, - "reaction_basis": MaterialFlowBasis.molar, - "pressure_ref": 1e5, - "temperature_ref": 298.15, - "parameter_data": { - "Liq_tau": { # Table 1 [1] - ("H2O", "Na_+, Cl_-"): 8.866, - ("Na_+, Cl_-", "H2O"): -4.451, - ("H2O", "Ca_2+, Cl_-"): 10.478, - ("Ca_2+, Cl_-", "H2O"): -5.231, - ("H2O", "Mg_2+, Cl_-"): 10.854, - ("Mg_2+, Cl_-", "H2O"): -5.409, - ("H2O", "Na_+, SO4_2-"): 8.012, - ("Na_+, SO4_2-", "H2O"): -3.903, - ("H2O", "Ca_2+, SO4_2-"): 6.932, - ("Ca_2+, SO4_2-", "H2O"): -3.466, - ("H2O", "Mg_2+, SO4_2-"): 8.808, - ("Mg_2+, SO4_2-", "H2O"): -4.383, - ("Na_+, Cl_-", "Ca_2+, Cl_-"): -0.468, - ("Ca_2+, Cl_-", "Na_+, Cl_-"): 0.41, - ("Na_+, Cl_-", "Mg_2+, Cl_-"): -0.328, - ("Mg_2+, Cl_-", "Na_+, Cl_-"): -0.981, - ("Ca_2+, Cl_-", "Mg_2+, Cl_-"): 0.22, - ("Mg_2+, Cl_-", "Ca_2+, Cl_-"): 0.322, - ("Na_+, SO4_2-", "Ca_2+, SO4_2-"): -0.761, - ("Ca_2+, SO4_2-", "Na_+, SO4_2-"): 0.368, - ("Na_+, SO4_2-", "Mg_2+, SO4_2-"): -0.327, - ("Mg_2+, SO4_2-", "Na_+, SO4_2-"): 0.799, - ("Ca_2+, SO4_2-", "Mg_2+, SO4_2-"): 0, - ("Mg_2+, SO4_2-", "Ca_2+, SO4_2-"): 0.383, - ("Na_+, Cl_-", "Na_+, SO4_2-"): 0.803, - ("Na_+, SO4_2-", "Na_+, Cl_-"): -0.634, - ("Ca_2+, Cl_-", "Ca_2+, SO4_2-"): 0, - ("Ca_2+, SO4_2-", "Ca_2+, Cl_-"): -0.264, - ("Mg_2+, Cl_-", "Mg_2+, SO4_2-"): -0.707, - ("Mg_2+, SO4_2-", "Mg_2+, Cl_-"): -0.841, - } - }, - "default_scaling_factors": { - ("flow_mol_phase_comp", ("Liq", "Na_+")): 1e1, - ("flow_mol_phase_comp", ("Liq", "Ca_2+")): 1e3, - ("flow_mol_phase_comp", ("Liq", "Mg_2+")): 1e2, - ("flow_mol_phase_comp", ("Liq", "SO4_2-")): 1e2, - ("flow_mol_phase_comp", ("Liq", "Cl_-")): 1e1, - ("flow_mol_phase_comp", ("Liq", "H2O")): 1e-1, - ("mole_frac_comp", "Na_+"): 1e2, - ("mole_frac_comp", "Ca_2+"): 1e4, - ("mole_frac_comp", "Mg_2+"): 1e3, - ("mole_frac_comp", "SO4_2-"): 1e3, - ("mole_frac_comp", "Cl_-"): 1e2, - ("mole_frac_comp", "H2O"): 1, - ("mole_frac_phase_comp", ("Liq", "Na_+")): 1e2, - ("mole_frac_phase_comp", ("Liq", "Ca_2+")): 1e4, - ("mole_frac_phase_comp", ("Liq", "Mg_2+")): 1e3, - ("mole_frac_phase_comp", ("Liq", "SO4_2-")): 1e3, - ("mole_frac_phase_comp", ("Liq", "Cl_-")): 1e2, - ("mole_frac_phase_comp", ("Liq", "H2O")): 1, - ("flow_mol_phase_comp_apparent", ("Liq", "NaCl")): 1e1, - ("flow_mol_phase_comp_apparent", ("Liq", "Na2SO4")): 1e2, - ("flow_mol_phase_comp_apparent", ("Liq", "CaCl2")): 1e2, - ("flow_mol_phase_comp_apparent", ("Liq", "CaSO4")): 1e3, - ("flow_mol_phase_comp_apparent", ("Liq", "MgCl2")): 1e2, - ("flow_mol_phase_comp_apparent", ("Liq", "MgSO4")): 1e3, - ("flow_mol_phase_comp_apparent", ("Liq", "H2O")): 1e-1, - ( - "mole_frac_phase_comp_apparent", - ("Liq", "NaCl"), - ): 1e3, # TODO: these seem to be 1 orders of magnitude too low - ("mole_frac_phase_comp_apparent", ("Liq", "Na2SO4")): 1e4, - ("mole_frac_phase_comp_apparent", ("Liq", "CaCl2")): 1e4, - ("mole_frac_phase_comp_apparent", ("Liq", "CaSO4")): 1e5, - ("mole_frac_phase_comp_apparent", ("Liq", "MgCl2")): 1e4, - ("mole_frac_phase_comp_apparent", ("Liq", "MgSO4")): 1e5, - ("mole_frac_phase_comp_apparent", ("Liq", "H2O")): 1, - }, -} diff --git a/watertap/property_models/seawater_ion_prop_pack.py b/watertap/property_models/seawater_ion_prop_pack.py deleted file mode 100644 index 00fb4d3de4..0000000000 --- a/watertap/property_models/seawater_ion_prop_pack.py +++ /dev/null @@ -1,580 +0,0 @@ -################################################################################# -# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, -# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, -# National Renewable Energy Laboratory, and National Energy Technology -# Laboratory (subject to receipt of any required approvals from the U.S. Dept. -# of Energy). All rights reserved. -# -# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license -# information, respectively. These files are also available online at the URL -# "https://github.com/watertap-org/watertap/" -################################################################################# - -""" -Simple property package for Na-Ca-Mg-SO4-Cl solution represented with ions -""" - -from pyomo.environ import ( - Constraint, - Var, - Param, - Expression, - NonNegativeReals, - Suffix, -) -from pyomo.environ import units as pyunits - -# Import IDAES cores -from idaes.core import ( - declare_process_block_class, - MaterialFlowBasis, - PhysicalParameterBlock, - StateBlockData, - StateBlock, - MaterialBalanceType, - EnergyBalanceType, -) -from idaes.core.base.components import Solute, Solvent -from idaes.core.base.phases import LiquidPhase -from idaes.core.util.initialization import ( - fix_state_vars, - revert_state_vars, - solve_indexed_blocks, -) -from idaes.core.util.model_statistics import ( - degrees_of_freedom, - number_unfixed_variables, -) -from idaes.core.util.exceptions import PropertyPackageError -from idaes.core.util.misc import extract_data -import idaes.core.util.scaling as iscale -import idaes.logger as idaeslog -from idaes.core.solvers import get_solver - -# Set up logger -_log = idaeslog.getLogger(__name__) - - -@declare_process_block_class("PropParameterBlock") -class PropParameterData(PhysicalParameterBlock): - CONFIG = PhysicalParameterBlock.CONFIG() - - def build(self): - """ - Callable method for Block construction. - """ - super(PropParameterData, self).build() - - self._state_block_class = PropStateBlock - - # phases - self.Liq = LiquidPhase() - - # components - self.H2O = Solvent() - self.Na = Solute() - self.Ca = Solute() - self.Mg = Solute() - self.SO4 = Solute() - self.Cl = Solute() - - # molecular weight - mw_comp_data = { - "H2O": 18.015e-3, - "Na": 22.990e-3, - "Ca": 40.078e-3, - "Mg": 24.305e-3, - "SO4": 96.06e-3, - "Cl": 35.453e-3, - } - - self.mw_comp = Param( - self.component_list, - initialize=extract_data(mw_comp_data), - units=pyunits.kg / pyunits.mol, - doc="Molecular weight", - ) - - self.dens_mass = Param( - initialize=1000, - units=pyunits.kg / pyunits.m**3, - doc="Density", - ) - - self.cp = Param(initialize=4.2e3, units=pyunits.J / (pyunits.kg * pyunits.K)) - - # ---default scaling--- - self.set_default_scaling("temperature", 1e-2) - self.set_default_scaling("pressure", 1e-6) - - @classmethod - def define_metadata(cls, obj): - """Define properties supported and units.""" - obj.add_properties( - { - "flow_mass_phase_comp": {"method": None}, - "temperature": {"method": None}, - "pressure": {"method": None}, - "mass_frac_phase_comp": {"method": "_mass_frac_phase_comp"}, - "flow_vol": {"method": "_flow_vol"}, - "flow_mol_phase_comp": {"method": "_flow_mol_phase_comp"}, - "conc_mol_phase_comp": {"method": "_conc_mol_phase_comp"}, - } - ) - - obj.define_custom_properties( - { - "enth_flow": {"method": "_enth_flow"}, - } - ) - - obj.add_default_units( - { - "time": pyunits.s, - "length": pyunits.m, - "mass": pyunits.kg, - "amount": pyunits.mol, - "temperature": pyunits.K, - } - ) - - -class _PropStateBlock(StateBlock): - """ - This Class contains methods which should be applied to Property Blocks as a - whole, rather than individual elements of indexed Property Blocks. - """ - - def initialize( - self, - state_args=None, - state_vars_fixed=False, - hold_state=False, - outlvl=idaeslog.NOTSET, - solver=None, - optarg=None, - ): - """ - Initialization routine for property package. - Keyword Arguments: - state_args : Dictionary with initial guesses for the state vars - chosen. Note that if this method is triggered - through the control volume, and if initial guesses - were not provided at the unit model level, the - control volume passes the inlet values as initial - guess.The keys for the state_args dictionary are: - - flow_mass_phase_comp : value at which to initialize - phase component flows - pressure : value at which to initialize pressure - temperature : value at which to initialize temperature - outlvl : sets output level of initialization routine (default=idaeslog.NOTSET) - optarg : solver options dictionary object (default=None) - state_vars_fixed: Flag to denote if state vars have already been - fixed. - - True - states have already been fixed by the - control volume 1D. Control volume 0D - does not fix the state vars, so will - be False if this state block is used - with 0D blocks. - - False - states have not been fixed. The state - block will deal with fixing/unfixing. - solver : Solver object to use during initialization if None is provided - it will use the default solver for IDAES (default = None) - hold_state : flag indicating whether the initialization routine - should unfix any state variables fixed during - initialization (default=False). - - True - states variables are not unfixed, and - a dict of returned containing flags for - which states were fixed during - initialization. - - False - state variables are unfixed after - initialization by calling the - release_state method - Returns: - If hold_states is True, returns a dict containing flags for - which states were fixed during initialization. - """ - # Get loggers - init_log = idaeslog.getInitLogger(self.name, outlvl, tag="properties") - solve_log = idaeslog.getSolveLogger(self.name, outlvl, tag="properties") - - # Set solver and options - opt = get_solver(solver, optarg) - - # Fix state variables - flags = fix_state_vars(self, state_args) - # Check when the state vars are fixed already result in dof 0 - for k in self.keys(): - dof = degrees_of_freedom(self[k]) - if dof != 0: - raise PropertyPackageError( - "\nWhile initializing {sb_name}, the degrees of freedom " - "are {dof}, when zero is required. \nInitialization assumes " - "that the state variables should be fixed and that no other " - "variables are fixed. \nIf other properties have a " - "predetermined value, use the calculate_state method " - "before using initialize to determine the values for " - "the state variables and avoid fixing the property variables." - "".format(sb_name=self.name, dof=dof) - ) - - # --------------------------------------------------------------------- - skip_solve = True # skip solve if only state variables are present - for k in self.keys(): - if number_unfixed_variables(self[k]) != 0: - skip_solve = False - - if not skip_solve: - # Initialize properties - with idaeslog.solver_log(solve_log, idaeslog.DEBUG) as slc: - results = solve_indexed_blocks(opt, [self], tee=slc.tee) - init_log.info_high( - "Property initialization: {}.".format(idaeslog.condition(results)) - ) - - # --------------------------------------------------------------------- - # If input block, return flags, else release state - if state_vars_fixed is False: - if hold_state is True: - return flags - else: - self.release_state(flags) - - def release_state(self, flags, outlvl=idaeslog.NOTSET): - """ - Method to release state variables fixed during initialisation. - - Keyword Arguments: - flags : dict containing information of which state variables - were fixed during initialization, and should now be - unfixed. This dict is returned by initialize if - hold_state=True. - outlvl : sets output level of of logging - """ - # Unfix state variables - init_log = idaeslog.getInitLogger(self.name, outlvl, tag="properties") - revert_state_vars(self, flags) - init_log.info_high("{} State Released.".format(self.name)) - - -@declare_process_block_class("PropStateBlock", block_class=_PropStateBlock) -class PropStateBlockData(StateBlockData): - def build(self): - """Callable method for Block construction.""" - super(PropStateBlockData, self).build() - - self.scaling_factor = Suffix(direction=Suffix.EXPORT) - - seawater_mass_frac_dict = { - ("Liq", "Na"): 11122e-6, - ("Liq", "Ca"): 382e-6, - ("Liq", "Mg"): 1394e-6, - ("Liq", "SO4"): 2136e-6, - ("Liq", "Cl"): 20300e-6, - } - seawater_mass_frac_dict[("Liq", "H2O")] = 1 - sum( - x for x in seawater_mass_frac_dict.values() - ) - - # Add state variables - self.flow_mass_phase_comp = Var( - self.params.phase_list, - self.params.component_list, - initialize=seawater_mass_frac_dict, - bounds=(0.0, 100), - domain=NonNegativeReals, - units=pyunits.kg / pyunits.s, - doc="Mass flow rate", - ) - - self.temperature = Var( - initialize=298.15, - bounds=(273.15, 1000), - domain=NonNegativeReals, - units=pyunits.degK, - doc="State temperature", - ) - - self.pressure = Var( - initialize=101325, - bounds=(1e5, 5e7), - domain=NonNegativeReals, - units=pyunits.Pa, - doc="State pressure", - ) - - # ----------------------------------------------------------------------------- - # Property Methods - def _mass_frac_phase_comp(self): - self.mass_frac_phase_comp = Var( - self.params.phase_list, - self.params.component_list, - initialize=0.1, - bounds=(0.0, None), - units=pyunits.dimensionless, - doc="Mass fraction", - ) - - def rule_mass_frac_phase_comp(b, j): - return b.mass_frac_phase_comp["Liq", j] == b.flow_mass_phase_comp[ - "Liq", j - ] / sum( - b.flow_mass_phase_comp["Liq", j] for j in self.params.component_list - ) - - self.eq_mass_frac_phase_comp = Constraint( - self.params.component_list, rule=rule_mass_frac_phase_comp - ) - - def _flow_vol(self): - self.flow_vol = Var( - initialize=1e-3, - bounds=(0.0, None), - units=pyunits.m**3 / pyunits.s, - doc="Volumetric flow rate", - ) - - def rule_flow_vol(b): - return ( - b.flow_vol - == sum( - b.flow_mass_phase_comp["Liq", j] for j in b.params.component_list - ) - / b.params.dens_mass - ) - - self.eq_flow_vol = Constraint(rule=rule_flow_vol) - - def _flow_mol_phase_comp(self): - self.flow_mol_phase_comp = Var( - self.params.phase_list, - self.params.component_list, - initialize=1, - bounds=(0.0, None), - units=pyunits.mol / pyunits.s, - doc="Molar flowrate", - ) - - def rule_flow_mol_phase_comp(b, j): - return ( - b.flow_mol_phase_comp["Liq", j] - == b.flow_mass_phase_comp["Liq", j] / b.params.mw_comp[j] - ) - - self.eq_flow_mol_phase_comp = Constraint( - self.params.component_list, rule=rule_flow_mol_phase_comp - ) - - def _conc_mol_phase_comp(self): - self.conc_mol_phase_comp = Var( - self.params.phase_list, - self.params.component_list, - initialize=1, - bounds=(0.0, 1e6), - units=pyunits.mol / pyunits.m**3, - doc="Molarity", - ) - - def rule_conc_mol_phase_comp(b, j): - return ( - b.flow_vol * b.conc_mol_phase_comp["Liq", j] - == b.flow_mol_phase_comp["Liq", j] - ) - - self.eq_conc_mol_phase_comp = Constraint( - self.params.component_list, rule=rule_conc_mol_phase_comp - ) - - def _enth_flow(self): - # enthalpy flow expression for get_enthalpy_flow_terms method - temperature_ref = 273.15 * pyunits.K - - def rule_enth_flow(b): # enthalpy flow [J/s] - return ( - b.params.cp - * sum(b.flow_mass_phase_comp["Liq", j] for j in b.params.component_list) - * (b.temperature - temperature_ref) - ) - - self.enth_flow = Expression(rule=rule_enth_flow) - - # ----------------------------------------------------------------------------- - # General Methods - # NOTE: For scaling in the control volume to work properly, these methods must - # return a pyomo Var or Expression - - def get_material_flow_terms(self, p, j): - """Create material flow terms for control volume.""" - return self.flow_mass_phase_comp[p, j] - - def get_enthalpy_flow_terms(self, p): - """Create enthalpy flow terms.""" - return self.enth_flow - - # TODO: make property package compatible with dynamics - # def get_material_density_terms(self, p, j): - # """Create material density terms.""" - - # def get_enthalpy_density_terms(self, p): - # """Create enthalpy density terms.""" - - def default_material_balance_type(self): - return MaterialBalanceType.componentTotal - - def default_energy_balance_type(self): - return EnergyBalanceType.enthalpyTotal - - def get_material_flow_basis(self): - return MaterialFlowBasis.mass - - def define_state_vars(self): - """Define state vars.""" - return { - "flow_mass_phase_comp": self.flow_mass_phase_comp, - "temperature": self.temperature, - "pressure": self.pressure, - } - - # ----------------------------------------------------------------------------- - # Scaling methods - def calculate_scaling_factors(self): - super().calculate_scaling_factors() - - # setting scaling factors for variables - - # default scaling factors have already been set with - # idaes.core.property_base.calculate_scaling_factors() - - # scaling factors for parameters - for j, v in self.params.mw_comp.items(): - if iscale.get_scaling_factor(v) is None: - iscale.set_scaling_factor(self.params.mw_comp[j], 1e2) - - if iscale.get_scaling_factor(self.params.dens_mass) is None: - iscale.set_scaling_factor(self.params.dens_mass, 1e-3) - - if iscale.get_scaling_factor(self.params.cp) is None: - iscale.set_scaling_factor(self.params.cp, 1e-3) - - # these variables should have user input - if iscale.get_scaling_factor(self.flow_mass_phase_comp["Liq", "H2O"]) is None: - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "H2O"], default=1, warning=True - ) - iscale.set_scaling_factor(self.flow_mass_phase_comp["Liq", "H2O"], sf) - - if iscale.get_scaling_factor(self.flow_mass_phase_comp["Liq", "Na"]) is None: - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "Na"], default=1e2, warning=True - ) - iscale.set_scaling_factor(self.flow_mass_phase_comp["Liq", "Na"], sf) - - if iscale.get_scaling_factor(self.flow_mass_phase_comp["Liq", "Ca"]) is None: - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "Ca"], default=1e4, warning=True - ) - iscale.set_scaling_factor(self.flow_mass_phase_comp["Liq", "Ca"], sf) - - if iscale.get_scaling_factor(self.flow_mass_phase_comp["Liq", "Mg"]) is None: - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "Mg"], default=1e3, warning=True - ) - iscale.set_scaling_factor(self.flow_mass_phase_comp["Liq", "Mg"], sf) - - if iscale.get_scaling_factor(self.flow_mass_phase_comp["Liq", "SO4"]) is None: - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "SO4"], default=1e3, warning=True - ) - iscale.set_scaling_factor(self.flow_mass_phase_comp["Liq", "SO4"], sf) - - if iscale.get_scaling_factor(self.flow_mass_phase_comp["Liq", "Cl"]) is None: - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "Cl"], default=1e2, warning=True - ) - iscale.set_scaling_factor(self.flow_mass_phase_comp["Liq", "Cl"], sf) - - # these variables do not typically require user input, - # will not override if the user does provide the scaling factor - if self.is_property_constructed("mass_frac_phase_comp"): - for j in self.params.component_list: - if ( - iscale.get_scaling_factor(self.mass_frac_phase_comp["Liq", j]) - is None - ): - if j == "H2O": - iscale.set_scaling_factor( - self.mass_frac_phase_comp["Liq", j], 1 - ) - else: - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", j] - ) / iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "H2O"] - ) - iscale.set_scaling_factor( - self.mass_frac_phase_comp["Liq", j], sf - ) - - if self.is_property_constructed("flow_vol"): - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", "H2O"] - ) / iscale.get_scaling_factor(self.params.dens_mass) - iscale.set_scaling_factor(self.flow_vol, sf) - - if self.is_property_constructed("flow_mol_phase_comp"): - for j in self.params.component_list: - if ( - iscale.get_scaling_factor(self.flow_mol_phase_comp["Liq", j]) - is None - ): - sf = iscale.get_scaling_factor( - self.flow_mass_phase_comp["Liq", j] - ) / iscale.get_scaling_factor(self.params.mw_comp[j]) - iscale.set_scaling_factor(self.flow_mol_phase_comp["Liq", j], sf) - - if self.is_property_constructed("conc_mol_phase_comp"): - for j in self.params.component_list: - if ( - iscale.get_scaling_factor(self.conc_mol_phase_comp["Liq", j]) - is None - ): - sf = iscale.get_scaling_factor( - self.flow_mol_phase_comp["Liq", j] - ) / iscale.get_scaling_factor(self.flow_vol) - iscale.set_scaling_factor(self.conc_mol_phase_comp["Liq", j], sf) - - if self.is_property_constructed("enth_flow"): - if iscale.get_scaling_factor(self.enth_flow) is None: - sf = ( - iscale.get_scaling_factor(self.params.cp) - * iscale.get_scaling_factor(self.flow_mass_phase_comp["Liq", "H2O"]) - * 1e-1 - ) # temperature change on the order of 1e1 - iscale.set_scaling_factor(self.enth_flow, sf) - - # transforming constraints - # property relationships with no index, simple constraint - v_str_lst_simple = ["flow_vol"] - for v_str in v_str_lst_simple: - if self.is_property_constructed(v_str): - v = getattr(self, v_str) - sf = iscale.get_scaling_factor(v, default=1, warning=True) - c = getattr(self, "eq_" + v_str) - iscale.constraint_scaling_transform(c, sf) - - # property relationships indexed by component and phase - v_str_lst_phase_comp = [ - "mass_frac_phase_comp", - "flow_mol_phase_comp", - "conc_mol_phase_comp", - ] - for v_str in v_str_lst_phase_comp: - if self.is_property_constructed(v_str): - v_comp = getattr(self, v_str) - c_comp = getattr(self, "eq_" + v_str) - for j, c in c_comp.items(): - sf = iscale.get_scaling_factor( - v_comp["Liq", j], default=1, warning=True - ) - iscale.constraint_scaling_transform(c, sf) diff --git a/watertap/property_models/tests/test_seawater_ion_generic.py b/watertap/property_models/tests/test_seawater_ion_generic.py deleted file mode 100644 index 9f683e86c2..0000000000 --- a/watertap/property_models/tests/test_seawater_ion_generic.py +++ /dev/null @@ -1,81 +0,0 @@ -################################################################################# -# WaterTAP Copyright (c) 2020-2024, The Regents of the University of California, -# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, -# National Renewable Energy Laboratory, and National Energy Technology -# Laboratory (subject to receipt of any required approvals from the U.S. Dept. -# of Energy). All rights reserved. -# -# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license -# information, respectively. These files are also available online at the URL -# "https://github.com/watertap-org/watertap/" -################################################################################# - -import pytest -from pyomo.environ import ConcreteModel, assert_optimal_termination, value -from idaes.core import FlowsheetBlock -import idaes.core.util.scaling as iscale -from pyomo.util.check_units import assert_units_consistent -from idaes.models.properties.modular_properties.base.generic_property import ( - GenericParameterBlock, -) -from watertap.property_models.seawater_ion_generic import configuration -from watertap.core.util.initialization import check_dof -from idaes.core.solvers import get_solver - -solver = get_solver() -# ----------------------------------------------------------------------------- - - -@pytest.mark.component -def test_property_seawater_ions(): - m = ConcreteModel() - - m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = GenericParameterBlock(**configuration) - m.fs.stream = m.fs.properties.build_state_block([0], defined_state=True) - - # specify - m.fs.stream[0].flow_mol_phase_comp["Liq", "Na_+"].fix(0.008845) - m.fs.stream[0].flow_mol_phase_comp["Liq", "Ca_2+"].fix(0.000174) - m.fs.stream[0].flow_mol_phase_comp["Liq", "Mg_2+"].fix(0.001049) - m.fs.stream[0].flow_mol_phase_comp["Liq", "SO4_2-"].fix(0.000407) - m.fs.stream[0].flow_mol_phase_comp["Liq", "Cl_-"].fix(0.010479) - m.fs.stream[0].flow_mol_phase_comp["Liq", "H2O"].fix(0.979046) - m.fs.stream[0].temperature.fix(273.15 + 25) - m.fs.stream[0].pressure.fix(101325) - - # # scaling - iscale.calculate_scaling_factors(m.fs) - - # checking state block - assert_units_consistent(m) - - # check dof = 0 - check_dof(m, fail_flag=True) - - # initialize - m.fs.stream.initialize() - - # check solve - results = solver.solve(m) - assert_optimal_termination(results) - - # # check values - assert value(m.fs.stream[0].mole_frac_phase_comp["Liq", "Na_+"]) == pytest.approx( - 8.845e-3, rel=1e-3 - ) - assert value(m.fs.stream[0].mole_frac_phase_comp["Liq", "Ca_2+"]) == pytest.approx( - 1.74e-4, rel=1e-3 - ) - assert value(m.fs.stream[0].mole_frac_phase_comp["Liq", "Cl_-"]) == pytest.approx( - 1.048e-2, rel=1e-3 - ) - assert value(m.fs.stream[0].mole_frac_phase_comp["Liq", "H2O"]) == pytest.approx( - 0.9790, rel=1e-3 - ) - assert value(m.fs.stream[0].mole_frac_phase_comp["Liq", "Mg_2+"]) == pytest.approx( - 1.049e-3, rel=1e-3 - ) - assert value(m.fs.stream[0].mole_frac_phase_comp["Liq", "SO4_2-"]) == pytest.approx( - 4.07e-4, rel=1e-3 - ) From a9fa432ec73729c5369ee43b18b4901387b857ae Mon Sep 17 00:00:00 2001 From: Adam Atia Date: Fri, 29 Mar 2024 01:50:18 -0400 Subject: [PATCH 2/7] remove instances of sw ion generic --- .../property_models/index.rst | 1 - .../tests/test_nanofiltration_ZO.py | 79 +------------------ 2 files changed, 2 insertions(+), 78 deletions(-) diff --git a/docs/technical_reference/property_models/index.rst b/docs/technical_reference/property_models/index.rst index e3d9bad97f..7cb736f31d 100644 --- a/docs/technical_reference/property_models/index.rst +++ b/docs/technical_reference/property_models/index.rst @@ -8,7 +8,6 @@ Property Models NaCl NaCl_T_dep seawater - seawater_ion_generic coagulation ASM1 ASM2D diff --git a/watertap/unit_models/tests/test_nanofiltration_ZO.py b/watertap/unit_models/tests/test_nanofiltration_ZO.py index 72c6809358..66e37ff97f 100644 --- a/watertap/unit_models/tests/test_nanofiltration_ZO.py +++ b/watertap/unit_models/tests/test_nanofiltration_ZO.py @@ -29,8 +29,7 @@ from idaes.models.properties.modular_properties.base.generic_property import ( GenericParameterBlock, ) -from watertap.property_models.seawater_ion_generic import configuration -import watertap.property_models.seawater_ion_prop_pack as props +import watertap.property_models.multicomp_aq_sol_prop_pack as props from watertap.core.util.initialization import assert_no_degrees_of_freedom from pyomo.util.check_units import assert_units_consistent @@ -59,7 +58,7 @@ def test_config(): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = props.PropParameterBlock() + m.fs.properties = props.MCASParameterBlock() m.fs.unit = NanofiltrationZO(property_package=m.fs.properties) assert len(m.fs.unit.config) == 9 @@ -263,77 +262,3 @@ def test_solution(self, unit_frame): @pytest.mark.unit def test_report(self, unit_frame): unit_frame.fs.unit.report() - - @pytest.mark.component - def test_NF_with_generic_property_model(self): - m = ConcreteModel() - m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = GenericParameterBlock(**configuration) - m.fs.unit = NanofiltrationZO( - property_package=m.fs.properties, has_pressure_change=False - ) - - # fully specify system - m.fs.unit.inlet.flow_mol_phase_comp[0, "Liq", "Na_+"].fix(0.008845) - m.fs.unit.inlet.flow_mol_phase_comp[0, "Liq", "Ca_2+"].fix(0.000174) - m.fs.unit.inlet.flow_mol_phase_comp[0, "Liq", "Mg_2+"].fix(0.001049) - m.fs.unit.inlet.flow_mol_phase_comp[0, "Liq", "SO4_2-"].fix(0.000407) - m.fs.unit.inlet.flow_mol_phase_comp[0, "Liq", "Cl_-"].fix(0.010479) - m.fs.unit.inlet.flow_mol_phase_comp[0, "Liq", "H2O"].fix(0.979046) - m.fs.unit.feed_side.properties_in[0].pressure.fix(4e5) - m.fs.unit.feed_side.properties_in[0].temperature.fix(298.15) - - m.fs.unit.flux_vol_solvent.fix(1.67e-6) - m.fs.unit.recovery_vol_phase.fix(0.86) - m.fs.unit.properties_permeate[0].pressure.fix(101325) - - m.fs.unit.rejection_phase_comp[0, "Liq", "Na_+"].fix(0.01) - m.fs.unit.rejection_phase_comp[0, "Liq", "Ca_2+"].fix(0.79) - m.fs.unit.rejection_phase_comp[0, "Liq", "Mg_2+"].fix(0.94) - m.fs.unit.rejection_phase_comp[0, "Liq", "SO4_2-"].fix(0.87) - m.fs.unit.rejection_phase_comp[ - 0, "Liq", "Cl_-" - ] = 0.15 # guess, but electroneutrality enforced below - charge_comp = {"Na_+": 1, "Ca_2+": 2, "Mg_2+": 2, "SO4_2-": -2, "Cl_-": -1} - m.fs.unit.eq_electroneutrality = Constraint( - expr=0 - == sum( - charge_comp[j] - * m.fs.unit.feed_side.properties_out[0].conc_mol_phase_comp["Liq", j] - for j in charge_comp - ) - ) - constraint_scaling_transform(m.fs.unit.eq_electroneutrality, 1) - - assert_units_consistent(m) - - assert_no_degrees_of_freedom(m) - - calculate_scaling_factors(m) - - initialization_tester(m) - - results = solver.solve(m) - - # Check for optimal solution - assert_optimal_termination(results) - - assert pytest.approx(0.868, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].flow_mass_phase_comp["Liq", "H2O"] - / m.fs.unit.feed_side.properties_in[0].flow_mass_phase_comp["Liq", "H2O"] - ) - assert pytest.approx(1.978, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Ca_2+"] - ) - assert pytest.approx(479.1, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Cl_-"] - ) - assert pytest.approx(3.407, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Mg_2+"] - ) - assert pytest.approx(473.9, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Na_+"] - ) - assert pytest.approx(2.864, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "SO4_2-"] - ) From 721110543959a114b699131288ba6948d46a14bc Mon Sep 17 00:00:00 2001 From: Adam Atia Date: Fri, 29 Mar 2024 02:09:25 -0400 Subject: [PATCH 3/7] clean up nf0d test file --- .../tests/test_nanofiltration_ZO.py | 76 ++++++++----------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/watertap/unit_models/tests/test_nanofiltration_ZO.py b/watertap/unit_models/tests/test_nanofiltration_ZO.py index 66e37ff97f..d11fb780ac 100644 --- a/watertap/unit_models/tests/test_nanofiltration_ZO.py +++ b/watertap/unit_models/tests/test_nanofiltration_ZO.py @@ -15,7 +15,6 @@ ConcreteModel, value, Var, - Constraint, assert_optimal_termination, ) from pyomo.network import Port @@ -26,9 +25,7 @@ MomentumBalanceType, ) from watertap.unit_models.nanofiltration_ZO import NanofiltrationZO -from idaes.models.properties.modular_properties.base.generic_property import ( - GenericParameterBlock, -) + import watertap.property_models.multicomp_aq_sol_prop_pack as props from watertap.core.util.initialization import assert_no_degrees_of_freedom @@ -43,7 +40,6 @@ from idaes.core.util.testing import initialization_tester from idaes.core.util.scaling import ( calculate_scaling_factors, - constraint_scaling_transform, unscaled_variables_generator, unscaled_constraints_generator, badly_scaled_var_generator, @@ -58,7 +54,7 @@ def test_config(): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = props.MCASParameterBlock() + m.fs.properties = props.MCASParameterBlock(solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"]) m.fs.unit = NanofiltrationZO(property_package=m.fs.properties) assert len(m.fs.unit.config) == 9 @@ -76,7 +72,7 @@ def test_config(): def test_option_has_pressure_change(): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = props.PropParameterBlock() + m.fs.properties = props.MCASParameterBlock(solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"]) m.fs.unit = NanofiltrationZO( property_package=m.fs.properties, has_pressure_change=True ) @@ -91,18 +87,19 @@ def unit_frame(self): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = props.PropParameterBlock() + m.fs.properties = props.MCASParameterBlock(solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"], + material_flow_basis=props.MaterialFlowBasis.mass) m.fs.unit = NanofiltrationZO(property_package=m.fs.properties) # fully specify system feed_flow_mass = 1 feed_mass_frac = { - "Na": 11122e-6, - "Ca": 382e-6, - "Mg": 1394e-6, - "SO4": 2136e-6, - "Cl": 20316.88e-6, + "Na_+": 11122e-6, + "Ca_2+": 382e-6, + "Mg_2+": 1394e-6, + "SO4_2-": 2136e-6, + "Cl_-": 20316.88e-6, } m.fs.unit.feed_side.properties_in[0].flow_mass_phase_comp["Liq", "H2O"].fix( feed_flow_mass * (1 - sum(x for x in feed_mass_frac.values())) @@ -118,23 +115,13 @@ def unit_frame(self): m.fs.unit.area.fix(500) m.fs.unit.properties_permeate[0].pressure.fix(101325) - m.fs.unit.rejection_phase_comp[0, "Liq", "Na"].fix(0.01) - m.fs.unit.rejection_phase_comp[0, "Liq", "Ca"].fix(0.79) - m.fs.unit.rejection_phase_comp[0, "Liq", "Mg"].fix(0.94) - m.fs.unit.rejection_phase_comp[0, "Liq", "SO4"].fix(0.87) - m.fs.unit.rejection_phase_comp[ - 0, "Liq", "Cl" - ] = 0.15 # guess, but electroneutrality enforced below - charge_comp = {"Na": 1, "Ca": 2, "Mg": 2, "SO4": -2, "Cl": -1} - m.fs.unit.eq_electroneutrality = Constraint( - expr=0 - == sum( - charge_comp[j] - * m.fs.unit.feed_side.properties_out[0].conc_mol_phase_comp["Liq", j] - for j in charge_comp - ) - ) - constraint_scaling_transform(m.fs.unit.eq_electroneutrality, 1) + m.fs.unit.rejection_phase_comp[0, "Liq", "Na_+"].fix(0.01) + m.fs.unit.rejection_phase_comp[0, "Liq", "Ca_2+"].fix(0.79) + m.fs.unit.rejection_phase_comp[0, "Liq", "Mg_2+"].fix(0.94) + m.fs.unit.rejection_phase_comp[0, "Liq", "SO4_2-"].fix(0.87) + m.fs.unit.rejection_phase_comp[0, "Liq", "Cl_-"].fix(0.15) + + m.fs.unit.feed_side.properties_in[0].assert_electroneutrality(defined_state=True, adjust_by_ion='Cl_-') return m @@ -152,9 +139,10 @@ def test_build(self, unit_frame): assert isinstance(port, Port) # test statistics - assert number_variables(m) == 89 - assert number_total_constraints(m) == 74 - assert number_unused_variables(m) == 1 + assert number_variables(m) == 117 + assert number_total_constraints(m) == 86 + assert number_unused_variables(m) == 16 + assert_units_consistent(m) @pytest.mark.unit def test_dof(self, unit_frame): @@ -169,19 +157,19 @@ def test_calculate_scaling(self, unit_frame): "flow_mass_phase_comp", 1, index=("Liq", "H2O") ) m.fs.properties.set_default_scaling( - "flow_mass_phase_comp", 1e2, index=("Liq", "Na") + "flow_mass_phase_comp", 1e2, index=("Liq", "Na_+") ) m.fs.properties.set_default_scaling( - "flow_mass_phase_comp", 1e4, index=("Liq", "Ca") + "flow_mass_phase_comp", 1e4, index=("Liq", "Ca_2+") ) m.fs.properties.set_default_scaling( - "flow_mass_phase_comp", 1e3, index=("Liq", "Mg") + "flow_mass_phase_comp", 1e3, index=("Liq", "Mg_2+") ) m.fs.properties.set_default_scaling( - "flow_mass_phase_comp", 1e3, index=("Liq", "SO4") + "flow_mass_phase_comp", 1e3, index=("Liq", "SO4_2-") ) m.fs.properties.set_default_scaling( - "flow_mass_phase_comp", 1e2, index=("Liq", "Cl") + "flow_mass_phase_comp", 1e2, index=("Liq", "Cl_-") ) calculate_scaling_factors(m) @@ -241,19 +229,19 @@ def test_solution(self, unit_frame): m.fs.unit.properties_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ) assert pytest.approx(2.002, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Ca"] + m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Ca_2+"] ) - assert pytest.approx(484.0, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Cl"] + assert pytest.approx(487.116, rel=1e-3) == value( + m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Cl_-"] ) assert pytest.approx(3.441, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Mg"] + m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Mg_2+"] ) assert pytest.approx(478.9, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Na"] + m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "Na_+"] ) assert pytest.approx(2.891, rel=1e-3) == value( - m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "SO4"] + m.fs.unit.properties_permeate[0].conc_mol_phase_comp["Liq", "SO4_2-"] ) assert pytest.approx(0.86, rel=1e-3) == value( m.fs.unit.recovery_vol_phase[0, "Liq"] From 5a8b60ccfeb5b1a45ee4fadbdd15d8c599a6d304 Mon Sep 17 00:00:00 2001 From: Adam Atia Date: Fri, 29 Mar 2024 10:30:02 -0400 Subject: [PATCH 4/7] black --- watertap/core/tests/test_zero_order_base.py | 18 +- watertap/core/tests/test_zero_order_sido.py | 2 +- watertap/core/util/tests/test_misc.py | 8 +- watertap/core/util/tests/test_scaling.py | 1 + watertap/core/zero_order_electricity.py | 4 +- watertap/costing/watertap_costing_package.py | 22 +- .../tests/test_unit_parameter_files.py | 2 +- watertap/edb/tests/data.py | 52 ++--- watertap/edb/tests/test_commands.py | 16 +- .../tests/test_demo_simple_filter.py | 1 + watertap/examples/edb/the_basics.py | 1 + ...D_single_stage_continuous_recirculation.py | 6 +- .../examples/flowsheets/MD/tests/test_MD.py | 1 + ...test_RO_with_energy_recovery_simulation.py | 1 + .../activated_sludge/ASM2D_flowsheet.py | 4 +- .../activated_sludge/ASM2D_flowsheet_noPHA.py | 4 +- .../case_studies/electroNP/multi_sweep.py | 6 +- .../BSM2_P_extension.py | 4 +- .../tests/test_biomembrane_filtration.py | 1 + .../dye_desalination_withRO.py | 8 +- .../test_suboxic_activated_sludge_process.py | 1 + .../swine_wwt/swine_wwt.py | 1 + watertap/examples/flowsheets/lsrro/lsrro.py | 8 +- .../examples/flowsheets/lsrro/multi_sweep.py | 6 +- .../flowsheets/mvc/mvc_single_stage.py | 49 +++-- .../flowsheets/oaro/tests/test_oaro.py | 1 + .../flowsheets/oaro/tests/test_oaro_multi.py | 1 + .../property_models/NaCl_T_dep_prop_pack.py | 9 + .../tests/test_asm1_integration.py | 4 +- .../anaerobic_digestion/adm1_reactions.py | 4 +- .../modified_adm1_reactions.py | 4 +- watertap/property_models/cryst_prop_pack.py | 9 +- .../property_models/seawater_prop_pack.py | 12 ++ .../tests/property_test_harness.py | 10 +- .../tests/test_NDMA_prop_pack.py | 1 + .../tests/test_NaCl_T_dep_prop_pack.py | 1 + .../tests/test_NaCl_prop_pack.py | 1 + .../tests/test_coag_prop_pack.py | 1 + .../tests/test_multicomp_aq_sol_prop_pack.py | 2 + .../tests/test_seawater_prop_pack.py | 1 + .../tests/test_water_prop_pack.py | 1 + watertap/property_models/water_prop_pack.py | 8 +- .../analysis_tools/loop_tool/loop_tool.py | 18 +- watertap/tools/oli_api/credentials.py | 1 + watertap/tools/oli_api/flash.py | 1 - .../tools/parameter_sweep/parameter_sweep.py | 46 ++--- .../parameter_sweep_differential.py | 14 +- watertap/unit_models/boron_removal.py | 1 + watertap/unit_models/coag_floc_model.py | 1 + watertap/unit_models/crystallizer.py | 13 +- watertap/unit_models/cstr_injection.py | 1 + watertap/unit_models/dewatering.py | 6 +- watertap/unit_models/electroNP_ZO.py | 6 +- watertap/unit_models/electrodialysis_0D.py | 19 +- watertap/unit_models/electrodialysis_1D.py | 45 ++-- watertap/unit_models/ion_exchange_0D.py | 6 +- .../tests/test_chen_heat_exchanger.py | 1 + .../tests/test_complete_condenser.py | 1 + .../mvc/components/tests/test_compressor.py | 1 + .../mvc/components/tests/test_evaporator.py | 1 + .../unit_models/nanofiltration_DSPMDE_0D.py | 192 +++++++++--------- watertap/unit_models/nanofiltration_ZO.py | 6 +- ...motically_assisted_reverse_osmosis_base.py | 84 ++++---- watertap/unit_models/pressure_exchanger.py | 6 +- watertap/unit_models/reverse_osmosis_base.py | 48 ++--- .../tests/test_anaerobic_digester.py | 144 ++++++------- .../unit_models/tests/test_boron_removal.py | 3 +- .../unit_models/tests/test_coag_floc_model.py | 1 + .../unit_models/tests/test_crystallizer.py | 18 +- .../unit_models/tests/test_dewatering_unit.py | 1 + .../tests/test_electrodialysis_0D.py | 1 + .../tests/test_nanofiltration_ZO.py | 23 ++- ...osmotically_assisted_reverse_osmosis_0D.py | 1 + ...osmotically_assisted_reverse_osmosis_1D.py | 1 + .../tests/test_reverse_osmosis_0D.py | 84 ++++---- .../tests/test_reverse_osmosis_1D.py | 132 ++++++------ watertap/unit_models/thickener.py | 6 +- .../tests/test_translator_adm1_asm1.py | 1 + .../tests/test_translator_adm1_asm2d.py | 1 + .../test_translator_adm1_simple_asm2d.py | 1 + .../tests/test_translator_asm2d_adm1.py | 41 +--- watertap/unit_models/uv_aop.py | 1 + watertap/unit_models/zero_order/CANDOP_zo.py | 6 +- .../anaerobic_digestion_reactive_zo.py | 6 +- .../zero_order/brine_concentrator_zo.py | 6 +- .../unit_models/zero_order/chlorination_zo.py | 12 +- .../zero_order/coag_and_floc_zo.py | 22 +- .../electrochemical_nutrient_removal_zo.py | 6 +- .../zero_order/electrocoagulation_zo.py | 8 +- .../zero_order/electrodialysis_reversal_zo.py | 6 +- watertap/unit_models/zero_order/gac_zo.py | 6 +- .../zero_order/gas_sparged_membrane_zo.py | 6 +- .../unit_models/zero_order/ion_exchange_zo.py | 12 +- .../iron_and_manganese_removal_zo.py | 6 +- watertap/unit_models/zero_order/mabr_zo.py | 6 +- watertap/unit_models/zero_order/magprex_zo.py | 6 +- watertap/unit_models/zero_order/mbr_zo.py | 6 +- .../zero_order/nanofiltration_zo.py | 9 +- watertap/unit_models/zero_order/ozone_zo.py | 6 +- .../peracetic_acid_disinfection_zo.py | 18 +- .../zero_order/sedimentation_zo.py | 18 +- .../zero_order/tests/test_feed_zo.py | 4 +- .../tests/test_gas_sparged_membrane.py | 2 +- watertap/unit_models/zero_order/uv_zo.py | 6 +- .../unit_models/zero_order/well_field_zo.py | 3 +- 105 files changed, 723 insertions(+), 738 deletions(-) diff --git a/watertap/core/tests/test_zero_order_base.py b/watertap/core/tests/test_zero_order_base.py index af925fedcd..313ddf8399 100644 --- a/watertap/core/tests/test_zero_order_base.py +++ b/watertap/core/tests/test_zero_order_base.py @@ -371,22 +371,22 @@ def test_get_performance_contents(self, model): use_default_removal=True, ) - model.fs.unit._perf_var_dict[ - "Solute Removal" - ] = model.fs.unit.removal_frac_mass_comp + model.fs.unit._perf_var_dict["Solute Removal"] = ( + model.fs.unit.removal_frac_mass_comp + ) model.fs.unit.time_indexed_performance_var = Var( model.fs.time, doc="test variable" ) - model.fs.unit._perf_var_dict[ - "Test Variable 1" - ] = model.fs.unit.time_indexed_performance_var + model.fs.unit._perf_var_dict["Test Variable 1"] = ( + model.fs.unit.time_indexed_performance_var + ) model.fs.unit.nonindexed_performance_var = Var(doc="test_variable") - model.fs.unit._perf_var_dict[ - "Test Variable 2" - ] = model.fs.unit.nonindexed_performance_var + model.fs.unit._perf_var_dict["Test Variable 2"] = ( + model.fs.unit.nonindexed_performance_var + ) perf_dict = model.fs.unit._get_performance_contents() diff --git a/watertap/core/tests/test_zero_order_sido.py b/watertap/core/tests/test_zero_order_sido.py index 4bfe316932..b43924f6ce 100644 --- a/watertap/core/tests/test_zero_order_sido.py +++ b/watertap/core/tests/test_zero_order_sido.py @@ -219,7 +219,7 @@ def test_solution(self, model): @pytest.mark.component def test_conservation(self, model): - for (t, j) in model.fs.unit.inlet.flow_mass_comp.keys(): + for t, j in model.fs.unit.inlet.flow_mass_comp.keys(): assert ( abs( value( diff --git a/watertap/core/util/tests/test_misc.py b/watertap/core/util/tests/test_misc.py index 0c3f73eea0..2fa6de8a30 100644 --- a/watertap/core/util/tests/test_misc.py +++ b/watertap/core/util/tests/test_misc.py @@ -41,9 +41,7 @@ def test_is_constant_up_to_units(): m.fixed_param_2 = Param(initialize=6.28) # test expression of fixed params with units - assert is_constant_up_to_units( - (m.fixed_param**2) * m.fixed_param_2 * units.m**2 - ) + assert is_constant_up_to_units((m.fixed_param**2) * m.fixed_param_2 * units.m**2) m.mutable_param = Param(initialize=42, mutable=True) @@ -72,9 +70,7 @@ def test_is_constant_up_to_units(): assert not is_constant_up_to_units(m.fixed_variable * m.fixed_param * units.m**2) assert not is_constant_up_to_units(m.fixed_variable * 42.0 * units.m**2) - assert not is_constant_up_to_units( - m.unfixed_variable * m.fixed_param * units.m**2 - ) + assert not is_constant_up_to_units(m.unfixed_variable * m.fixed_param * units.m**2) assert not is_constant_up_to_units(m.unfixed_variable * 42.0 * units.m**2) assert not is_constant_up_to_units( diff --git a/watertap/core/util/tests/test_scaling.py b/watertap/core/util/tests/test_scaling.py index 72c8fed1a7..9f5b40df64 100644 --- a/watertap/core/util/tests/test_scaling.py +++ b/watertap/core/util/tests/test_scaling.py @@ -34,6 +34,7 @@ # Set up solver solver = get_solver() + # Start test class # TODO: Consider using dummy metadata rather than importing property package class TestScaling: diff --git a/watertap/core/zero_order_electricity.py b/watertap/core/zero_order_electricity.py index f97e2cf207..b7b93e81a5 100644 --- a/watertap/core/zero_order_electricity.py +++ b/watertap/core/zero_order_electricity.py @@ -65,9 +65,7 @@ def constant_intensity(self): def electricity_consumption(b, t): return b.electricity[t] == ( b.energy_electric_flow_vol_inlet - * pyunits.convert( - b.get_inlet_flow(t), to_units=pyunits.m**3 / pyunits.hour - ) + * pyunits.convert(b.get_inlet_flow(t), to_units=pyunits.m**3 / pyunits.hour) ) self._fixed_perf_vars.append(self.energy_electric_flow_vol_inlet) diff --git a/watertap/costing/watertap_costing_package.py b/watertap/costing/watertap_costing_package.py index 2cdd046783..4d4f67ed7b 100644 --- a/watertap/costing/watertap_costing_package.py +++ b/watertap/costing/watertap_costing_package.py @@ -94,9 +94,7 @@ def add_specific_energy_consumption( name, pyo.Expression( expr=self.aggregate_flow_electricity - / pyo.units.convert( - flow_rate, to_units=pyo.units.m**3 / pyo.units.hr - ), + / pyo.units.convert(flow_rate, to_units=pyo.units.m**3 / pyo.units.hr), doc=f"Specific energy consumption based on flow {flow_rate.name}", ), ) @@ -151,9 +149,7 @@ def add_specific_electrical_carbon_intensity( pyo.Expression( expr=self.aggregate_flow_electricity * self.electrical_carbon_intensity - / pyo.units.convert( - flow_rate, to_units=pyo.units.m**3 / pyo.units.hr - ), + / pyo.units.convert(flow_rate, to_units=pyo.units.m**3 / pyo.units.hr), doc=f"Specific electrical carbon intensity based on flow {flow_rate.name}", ), ) @@ -195,12 +191,14 @@ def build_process_costs(self): self.total_variable_operating_cost = pyo.Expression( expr=( - self.aggregate_variable_operating_cost - + sum(self.aggregate_flow_costs[f] for f in self.used_flows) - * self.utilization_factor - ) - if self.used_flows - else self.aggregate_variable_operating_cost, + ( + self.aggregate_variable_operating_cost + + sum(self.aggregate_flow_costs[f] for f in self.used_flows) + * self.utilization_factor + ) + if self.used_flows + else self.aggregate_variable_operating_cost + ), doc="Total variable operating cost of process per operating period", ) diff --git a/watertap/data/techno_economic/tests/test_unit_parameter_files.py b/watertap/data/techno_economic/tests/test_unit_parameter_files.py index 3d764ea699..f3a09f0c10 100644 --- a/watertap/data/techno_economic/tests/test_unit_parameter_files.py +++ b/watertap/data/techno_economic/tests/test_unit_parameter_files.py @@ -136,7 +136,7 @@ def test_unit_parameter_files(tech): # Check for specific removal fractions if "removal_frac_mass_comp" in k.keys(): - for (j, c_data) in k["removal_frac_mass_comp"].items(): + for j, c_data in k["removal_frac_mass_comp"].items(): assert "units" in c_data.keys() assert_units_equivalent(c_data["units"], units.dimensionless) assert "value" in c_data.keys() diff --git a/watertap/edb/tests/data.py b/watertap/edb/tests/data.py index 456b800c68..dd96f4b9e5 100644 --- a/watertap/edb/tests/data.py +++ b/watertap/edb/tests/data.py @@ -247,31 +247,19 @@ "A": (30.09200, pyunits.J / pyunits.mol / pyunits.K), "B": ( 6.832514, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-1, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-1, ), "C": ( 6.793435, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-2, ), "D": ( -2.534480, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-3, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-3, ), "E": ( 0.082139, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**2, ), "F": (-250.8810, pyunits.kJ / pyunits.mol), "G": (223.3967, pyunits.J / pyunits.mol / pyunits.K), @@ -311,31 +299,19 @@ "A": (24.99735, pyunits.J / pyunits.mol / pyunits.K), "B": ( 55.18696, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-1, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-1, ), "C": ( -33.69137, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-2, ), "D": ( 7.948387, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**-3, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**-3, ), "E": ( -0.136638, - pyunits.J - * pyunits.mol**-1 - * pyunits.K**-1 - * pyunits.kiloK**2, + pyunits.J * pyunits.mol**-1 * pyunits.K**-1 * pyunits.kiloK**2, ), "F": (-403.6075, pyunits.kJ / pyunits.mol), "G": (228.2431, pyunits.J / pyunits.mol / pyunits.K), @@ -572,7 +548,7 @@ ("Liq", "H_+"): 1, ("Liq", "OH_-"): 1, }, - } + }, # End parameter_data }, # End R1 @@ -597,7 +573,7 @@ ("Liq", "CO2"): -1, ("Liq", "H2O"): 0, }, - } + }, # End parameter_data }, # End R2 @@ -622,7 +598,7 @@ ("Liq", "H_+"): 1, ("Liq", "HCO3_-"): 1, }, - } + }, # End parameter_data }, # End R3 @@ -647,10 +623,10 @@ ("Liq", "H_+"): 1, ("Liq", "CO3_2-"): 1, }, - } + }, # End parameter_data - } + }, # End R4 - } + }, # End equilibrium_reactions } diff --git a/watertap/edb/tests/test_commands.py b/watertap/edb/tests/test_commands.py index a6ac754f38..f6afc70a1c 100644 --- a/watertap/edb/tests/test_commands.py +++ b/watertap/edb/tests/test_commands.py @@ -388,13 +388,15 @@ class TestSchema: @pytest.fixture( scope="function", params=[ - fmt - if is_available - else pytest.param( - fmt, - marks=pytest.mark.xfail( - reason=f"Schema output format '{fmt}' not yet supported" - ), + ( + fmt + if is_available + else pytest.param( + fmt, + marks=pytest.mark.xfail( + reason=f"Schema output format '{fmt}' not yet supported" + ), + ) ) for fmt, is_available in format_available.items() ], diff --git a/watertap/examples/custom_model_demo/tests/test_demo_simple_filter.py b/watertap/examples/custom_model_demo/tests/test_demo_simple_filter.py index 51bb912854..1562d7350c 100644 --- a/watertap/examples/custom_model_demo/tests/test_demo_simple_filter.py +++ b/watertap/examples/custom_model_demo/tests/test_demo_simple_filter.py @@ -18,6 +18,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.component def test_demo_simple_prop_pack(): diff --git a/watertap/examples/edb/the_basics.py b/watertap/examples/edb/the_basics.py index 0c63a24be0..cc4e246244 100644 --- a/watertap/examples/edb/the_basics.py +++ b/watertap/examples/edb/the_basics.py @@ -92,6 +92,7 @@ __author__ = "Austin Ladshaw" + # ========================== (4) ================================ # By default, invoking the 'ElectrolyteDB' object (with no args) # will attempt to connect to the local host database. You can diff --git a/watertap/examples/flowsheets/MD/MD_single_stage_continuous_recirculation.py b/watertap/examples/flowsheets/MD/MD_single_stage_continuous_recirculation.py index 6c03890926..c3282d2eec 100644 --- a/watertap/examples/flowsheets/MD/MD_single_stage_continuous_recirculation.py +++ b/watertap/examples/flowsheets/MD/MD_single_stage_continuous_recirculation.py @@ -415,9 +415,9 @@ def set_operating_conditions(m): m.fs.chiller.control_volume.properties_out[0].flow_mass_phase_comp[ "Liq", "TDS" ].value = 0 - m.fs.chiller.control_volume.properties_out[0].flow_mass_phase_comp[ - "Liq", "H2O" - ] = m.fs.heater.control_volume.properties_out[0].flow_mass_phase_comp["Liq", "H2O"] + m.fs.chiller.control_volume.properties_out[0].flow_mass_phase_comp["Liq", "H2O"] = ( + m.fs.heater.control_volume.properties_out[0].flow_mass_phase_comp["Liq", "H2O"] + ) # check degrees of freedom if degrees_of_freedom(m) != 0: diff --git a/watertap/examples/flowsheets/MD/tests/test_MD.py b/watertap/examples/flowsheets/MD/tests/test_MD.py index 0ebe06d032..9b05928f1c 100644 --- a/watertap/examples/flowsheets/MD/tests/test_MD.py +++ b/watertap/examples/flowsheets/MD/tests/test_MD.py @@ -39,6 +39,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- class TestMDContinuousRecirculation: @pytest.fixture(scope="class") diff --git a/watertap/examples/flowsheets/RO_with_energy_recovery/tests/test_RO_with_energy_recovery_simulation.py b/watertap/examples/flowsheets/RO_with_energy_recovery/tests/test_RO_with_energy_recovery_simulation.py index c6a3bc4593..34d52c3836 100644 --- a/watertap/examples/flowsheets/RO_with_energy_recovery/tests/test_RO_with_energy_recovery_simulation.py +++ b/watertap/examples/flowsheets/RO_with_energy_recovery/tests/test_RO_with_energy_recovery_simulation.py @@ -45,6 +45,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- class TestROwithPX: @pytest.fixture(scope="class") diff --git a/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet.py b/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet.py index b08b90b2e9..929648ca9e 100644 --- a/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet.py +++ b/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet.py @@ -212,9 +212,7 @@ def mass_transfer_R7(self, t): m.fs.FeedWater.conc_mass_comp[0, "X_PP"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_PHA"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_AUT"].fix(1e-6 * pyo.units.g / pyo.units.m**3) - m.fs.FeedWater.conc_mass_comp[0, "X_MeOH"].fix( - 1e-6 * pyo.units.g / pyo.units.m**3 - ) + m.fs.FeedWater.conc_mass_comp[0, "X_MeOH"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_MeP"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_TSS"].fix(180 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.alkalinity.fix(7 * pyo.units.mol / pyo.units.m**3) diff --git a/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet_noPHA.py b/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet_noPHA.py index aaaf089197..2edf25e5da 100644 --- a/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet_noPHA.py +++ b/watertap/examples/flowsheets/case_studies/activated_sludge/ASM2D_flowsheet_noPHA.py @@ -182,9 +182,7 @@ def mass_transfer_R4(self, t): m.fs.FeedWater.conc_mass_comp[0, "X_PP"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_PHA"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_AUT"].fix(1e-6 * pyo.units.g / pyo.units.m**3) - m.fs.FeedWater.conc_mass_comp[0, "X_MeOH"].fix( - 1e-6 * pyo.units.g / pyo.units.m**3 - ) + m.fs.FeedWater.conc_mass_comp[0, "X_MeOH"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_MeP"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_TSS"].fix(180 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.alkalinity.fix(7 * pyo.units.mol / pyo.units.m**3) diff --git a/watertap/examples/flowsheets/case_studies/electroNP/multi_sweep.py b/watertap/examples/flowsheets/case_studies/electroNP/multi_sweep.py index 4239554e58..402ba7f48a 100644 --- a/watertap/examples/flowsheets/case_studies/electroNP/multi_sweep.py +++ b/watertap/examples/flowsheets/case_studies/electroNP/multi_sweep.py @@ -29,9 +29,9 @@ def set_up_sensitivity(m): m.fs.costing.aggregate_flow_costs["electricity"] / m.fs.AD.inlet.flow_vol[0], to_units=pyunits.USD_2018 / pyunits.m**3, ) - outputs[ - "S_PO4 Concentration, treated effluent stream" - ] = m.fs.electroNP.treated.conc_mass_comp[0, "S_PO4"] + outputs["S_PO4 Concentration, treated effluent stream"] = ( + m.fs.electroNP.treated.conc_mass_comp[0, "S_PO4"] + ) return outputs, optimize_kwargs, opt_function diff --git a/watertap/examples/flowsheets/case_studies/full_water_resource_recovery_facility/BSM2_P_extension.py b/watertap/examples/flowsheets/case_studies/full_water_resource_recovery_facility/BSM2_P_extension.py index 91a5b2ad12..a4fd30a076 100644 --- a/watertap/examples/flowsheets/case_studies/full_water_resource_recovery_facility/BSM2_P_extension.py +++ b/watertap/examples/flowsheets/case_studies/full_water_resource_recovery_facility/BSM2_P_extension.py @@ -397,9 +397,7 @@ def set_operating_conditions(m): m.fs.FeedWater.conc_mass_comp[0, "X_PHA"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "X_AUT"].fix(1e-6 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "S_IC"].fix(5.652 * pyo.units.g / pyo.units.m**3) - m.fs.FeedWater.conc_mass_comp[0, "S_K"].fix( - 374.6925 * pyo.units.g / pyo.units.m**3 - ) + m.fs.FeedWater.conc_mass_comp[0, "S_K"].fix(374.6925 * pyo.units.g / pyo.units.m**3) m.fs.FeedWater.conc_mass_comp[0, "S_Mg"].fix(20 * pyo.units.g / pyo.units.m**3) # Primary Clarifier diff --git a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/biomembrane_filtration/tests/test_biomembrane_filtration.py b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/biomembrane_filtration/tests/test_biomembrane_filtration.py index 136d09a62e..75d5f30442 100644 --- a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/biomembrane_filtration/tests/test_biomembrane_filtration.py +++ b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/biomembrane_filtration/tests/test_biomembrane_filtration.py @@ -16,6 +16,7 @@ main, ) + # ----------------------------------------------------------------------------- @pytest.mark.component def test_biomembrane_filtration(): diff --git a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/dye_desalination/dye_desalination_withRO.py b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/dye_desalination/dye_desalination_withRO.py index dd6567c299..4ec438bddf 100644 --- a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/dye_desalination/dye_desalination_withRO.py +++ b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/dye_desalination/dye_desalination_withRO.py @@ -1284,16 +1284,12 @@ def display_costing(m): lcot = value(pyunits.convert(m.fs.LCOT, to_units=pyunits.USD_2020 / pyunits.m**3)) lcot_wo_rev = value( - pyunits.convert( - m.fs.LCOT_wo_revenue, to_units=pyunits.USD_2020 / pyunits.m**3 - ) + pyunits.convert(m.fs.LCOT_wo_revenue, to_units=pyunits.USD_2020 / pyunits.m**3) ) lcow = value(pyunits.convert(m.fs.LCOW, to_units=pyunits.USD_2020 / pyunits.m**3)) lcow_wo_rev = value( - pyunits.convert( - m.fs.LCOW_wo_revenue, to_units=pyunits.USD_2020 / pyunits.m**3 - ) + pyunits.convert(m.fs.LCOW_wo_revenue, to_units=pyunits.USD_2020 / pyunits.m**3) ) sec = m.fs.specific_energy_intensity() diff --git a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/suboxic_activated_sludge_process/tests/test_suboxic_activated_sludge_process.py b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/suboxic_activated_sludge_process/tests/test_suboxic_activated_sludge_process.py index 7bc2f19702..7a5fc0dff6 100644 --- a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/suboxic_activated_sludge_process/tests/test_suboxic_activated_sludge_process.py +++ b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/suboxic_activated_sludge_process/tests/test_suboxic_activated_sludge_process.py @@ -16,6 +16,7 @@ main, ) + # ----------------------------------------------------------------------------- @pytest.mark.component def test_suboxicASM(): diff --git a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/swine_wwt/swine_wwt.py b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/swine_wwt/swine_wwt.py index ba171d29ff..fb19b93236 100644 --- a/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/swine_wwt/swine_wwt.py +++ b/watertap/examples/flowsheets/case_studies/wastewater_resource_recovery/swine_wwt/swine_wwt.py @@ -476,6 +476,7 @@ def add_costing(m): ), doc="Annual food waste tipping fee revenue", ) + # Combine results from costing packages and calculate overall metrics @m.Expression() def total_capital_cost(b): diff --git a/watertap/examples/flowsheets/lsrro/lsrro.py b/watertap/examples/flowsheets/lsrro/lsrro.py index dda1c6dada..c73bff19cf 100644 --- a/watertap/examples/flowsheets/lsrro/lsrro.py +++ b/watertap/examples/flowsheets/lsrro/lsrro.py @@ -240,9 +240,11 @@ def build( # Add EnergyRecoveryDevices m.fs.EnergyRecoveryDeviceSet = Set( - initialize=[m.fs.FirstStage, m.fs.LastStage] - if m.fs.FirstStage < m.fs.LastStage - else [m.fs.LastStage] + initialize=( + [m.fs.FirstStage, m.fs.LastStage] + if m.fs.FirstStage < m.fs.LastStage + else [m.fs.LastStage] + ) ) m.fs.EnergyRecoveryDevices = EnergyRecoveryDevice( m.fs.EnergyRecoveryDeviceSet, property_package=m.fs.properties diff --git a/watertap/examples/flowsheets/lsrro/multi_sweep.py b/watertap/examples/flowsheets/lsrro/multi_sweep.py index 520a518125..ba38bf2d3f 100644 --- a/watertap/examples/flowsheets/lsrro/multi_sweep.py +++ b/watertap/examples/flowsheets/lsrro/multi_sweep.py @@ -129,9 +129,9 @@ def run_case(number_of_stages, nx, output_filename=None): outputs["Indirect Capex LCOW"] = m.fs.costing.indirect_capex_lcow outputs["Electricity LCOW"] = m.fs.costing.electricity_lcow outputs["Membrane Replacement LCOW"] = m.fs.costing.membrane_replacement_lcow - outputs[ - "Chem-labor-maintenance LCOW" - ] = m.fs.costing.chemical_labor_maintenance_lcow + outputs["Chem-labor-maintenance LCOW"] = ( + m.fs.costing.chemical_labor_maintenance_lcow + ) outputs["Pumping Energy Agg LCOW"] = m.fs.costing.pumping_energy_aggregate_lcow outputs["Membrane Agg LCOW"] = m.fs.costing.membrane_aggregate_lcow diff --git a/watertap/examples/flowsheets/mvc/mvc_single_stage.py b/watertap/examples/flowsheets/mvc/mvc_single_stage.py index 5846bbf53e..3d34ca6be5 100644 --- a/watertap/examples/flowsheets/mvc/mvc_single_stage.py +++ b/watertap/examples/flowsheets/mvc/mvc_single_stage.py @@ -440,17 +440,16 @@ def initialize_system(m, solver=None): m.fs.evaporator.properties_vapor[0].flow_mass_phase_comp["Liq", "H2O"] = 0 # Propagate brine salinity and flow rate - m.fs.evaporator.properties_brine[0].mass_frac_phase_comp[ - "Liq", "TDS" - ] = m.fs.feed.properties[0].mass_frac_phase_comp["Liq", "TDS"] / ( - 1 - m.fs.recovery[0] + m.fs.evaporator.properties_brine[0].mass_frac_phase_comp["Liq", "TDS"] = ( + m.fs.feed.properties[0].mass_frac_phase_comp["Liq", "TDS"] + / (1 - m.fs.recovery[0]) ) m.fs.evaporator.properties_brine[0].mass_frac_phase_comp["Liq", "H2O"] = ( 1 - m.fs.evaporator.properties_brine[0].mass_frac_phase_comp["Liq", "TDS"].value ) - m.fs.evaporator.properties_brine[0].flow_mass_phase_comp[ - "Liq", "TDS" - ] = m.fs.feed.properties[0].flow_mass_phase_comp["Liq", "TDS"] + m.fs.evaporator.properties_brine[0].flow_mass_phase_comp["Liq", "TDS"] = ( + m.fs.feed.properties[0].flow_mass_phase_comp["Liq", "TDS"] + ) m.fs.evaporator.properties_brine[0].flow_mass_phase_comp["Liq", "H2O"] = ( m.fs.feed.properties[0].flow_mass_phase_comp["Liq", "H2O"] - m.fs.evaporator.properties_vapor[0].flow_mass_phase_comp["Vap", "H2O"] @@ -476,9 +475,9 @@ def initialize_system(m, solver=None): # initialize distillate heat exchanger propagate_state(m.fs.s03) - m.fs.hx_distillate.cold_outlet.temperature[ - 0 - ] = m.fs.evaporator.inlet_feed.temperature[0].value + m.fs.hx_distillate.cold_outlet.temperature[0] = ( + m.fs.evaporator.inlet_feed.temperature[0].value + ) m.fs.hx_distillate.cold_outlet.pressure[0] = m.fs.evaporator.inlet_feed.pressure[ 0 ].value @@ -486,9 +485,9 @@ def initialize_system(m, solver=None): m.fs.evaporator.properties_vapor[0].flow_mass_phase_comp["Vap", "H2O"].value ) m.fs.hx_distillate.hot_inlet.flow_mass_phase_comp[0, "Liq", "TDS"] = 1e-4 - m.fs.hx_distillate.hot_inlet.temperature[ - 0 - ] = m.fs.evaporator.outlet_brine.temperature[0].value + m.fs.hx_distillate.hot_inlet.temperature[0] = ( + m.fs.evaporator.outlet_brine.temperature[0].value + ) m.fs.hx_distillate.hot_inlet.pressure[0] = 101325 m.fs.hx_distillate.initialize() @@ -498,12 +497,12 @@ def initialize_system(m, solver=None): 0 ].value m.fs.hx_brine.cold_outlet.pressure[0] = m.fs.evaporator.inlet_feed.pressure[0].value - m.fs.hx_brine.hot_inlet.flow_mass_phase_comp[ - 0, "Liq", "H2O" - ] = m.fs.evaporator.properties_brine[0].flow_mass_phase_comp["Liq", "H2O"] - m.fs.hx_brine.hot_inlet.flow_mass_phase_comp[ - 0, "Liq", "TDS" - ] = m.fs.evaporator.properties_brine[0].flow_mass_phase_comp["Liq", "TDS"] + m.fs.hx_brine.hot_inlet.flow_mass_phase_comp[0, "Liq", "H2O"] = ( + m.fs.evaporator.properties_brine[0].flow_mass_phase_comp["Liq", "H2O"] + ) + m.fs.hx_brine.hot_inlet.flow_mass_phase_comp[0, "Liq", "TDS"] = ( + m.fs.evaporator.properties_brine[0].flow_mass_phase_comp["Liq", "TDS"] + ) m.fs.hx_brine.hot_inlet.temperature[0] = m.fs.evaporator.outlet_brine.temperature[ 0 ].value @@ -540,12 +539,12 @@ def initialize_system(m, solver=None): # initialize distillate pump propagate_state(m.fs.s13) # to translator block propagate_state(m.fs.s14) # from translator block to pump - m.fs.pump_distillate.control_volume.properties_in[ - 0 - ].temperature = m.fs.condenser.control_volume.properties_out[0].temperature.value - m.fs.pump_distillate.control_volume.properties_in[ - 0 - ].pressure = m.fs.condenser.control_volume.properties_out[0].pressure.value + m.fs.pump_distillate.control_volume.properties_in[0].temperature = ( + m.fs.condenser.control_volume.properties_out[0].temperature.value + ) + m.fs.pump_distillate.control_volume.properties_in[0].pressure = ( + m.fs.condenser.control_volume.properties_out[0].pressure.value + ) m.fs.pump_distillate.initialize(optarg=optarg) # propagate brine state diff --git a/watertap/examples/flowsheets/oaro/tests/test_oaro.py b/watertap/examples/flowsheets/oaro/tests/test_oaro.py index c8800d5d24..f022c56c32 100644 --- a/watertap/examples/flowsheets/oaro/tests/test_oaro.py +++ b/watertap/examples/flowsheets/oaro/tests/test_oaro.py @@ -38,6 +38,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- class TestOAROwithTurbine: @pytest.fixture(scope="class") diff --git a/watertap/examples/flowsheets/oaro/tests/test_oaro_multi.py b/watertap/examples/flowsheets/oaro/tests/test_oaro_multi.py index a9d44156f7..107e1b3907 100644 --- a/watertap/examples/flowsheets/oaro/tests/test_oaro_multi.py +++ b/watertap/examples/flowsheets/oaro/tests/test_oaro_multi.py @@ -32,6 +32,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- class TestOAROwithTurbine: @pytest.fixture(scope="class") diff --git a/watertap/property_models/NaCl_T_dep_prop_pack.py b/watertap/property_models/NaCl_T_dep_prop_pack.py index 37cd4332b7..cc938ed33c 100644 --- a/watertap/property_models/NaCl_T_dep_prop_pack.py +++ b/watertap/property_models/NaCl_T_dep_prop_pack.py @@ -1044,6 +1044,7 @@ def _dens_mass_phase(self): units=pyunits.kg * pyunits.m**-3, doc="Mass density", ) + # Sparrow 2003, Eq. 7, 0-300 C def rule_dens_mass_phase(b, p): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1199,6 +1200,7 @@ def _solubility_comp(self): units=pyunits.dimensionless, doc="solubility_comp", ) + # Sparrow 2003, Eq 5, 0-450 C def rule_solubility_comp(b, j): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1218,6 +1220,7 @@ def _pressure_sat(self): units=pyunits.Pa, doc="Vapor Pressure", ) + # Sparrow 2003, Eq. 6, 0-150 C def rule_pressure_sat(b): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1262,6 +1265,7 @@ def _visc_d_phase(self): units=pyunits.Pa * pyunits.s, doc="Viscosity", ) + # Regressed from Zaytsev & Aseev (1992), 0-200 C def rule_visc_d_phase(b, p): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1303,6 +1307,7 @@ def _therm_cond_phase(self): units=pyunits.W / (pyunits.m * pyunits.K), doc="Thermal Conductivity", ) + # Regressed from Zaytsev & Aseev (1992), 0-155 C def rule_therm_cond_phase(b, p): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1342,6 +1347,7 @@ def _cp_mass_phase(self): units=pyunits.J * pyunits.kg**-1 * pyunits.K**-1, doc="specific heat", ) + # Regressed from Zaytsev & Aseev (1992), 0-200 C def rule_cp_mass_phase(b, p): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1382,6 +1388,7 @@ def _diffus_phase_comp(self): units=pyunits.m**2 * pyunits.s**-1, doc="Diffusivity", ) + # Regressed from Zaytsev & Aseev (1992), 0-60 C def rule_diffus_phase_comp(b, p, j): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1422,6 +1429,7 @@ def _osm_coeff(self): units=pyunits.dimensionless, doc="Osmotic coefficient", ) + # Regressed from Pitzer et. al. (1984), 0-300 C def rule_osm_coeff(b): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K @@ -1493,6 +1501,7 @@ def _enth_mass_phase(self): units=pyunits.J * pyunits.kg**-1, doc="Specific enthalpy", ) + # Sparrow 2003, Eq 8, 0-300 C def rule_enth_mass_phase(b, p): t = (b.temperature - 273.15 * pyunits.K) / pyunits.K diff --git a/watertap/property_models/activated_sludge/tests/test_asm1_integration.py b/watertap/property_models/activated_sludge/tests/test_asm1_integration.py index 66f428b9b6..f0715aedaf 100644 --- a/watertap/property_models/activated_sludge/tests/test_asm1_integration.py +++ b/watertap/property_models/activated_sludge/tests/test_asm1_integration.py @@ -71,9 +71,7 @@ def test_ASM1_reactor(): m.fs.R1.inlet.conc_mass_comp[0, "S_S"].fix(14.6112 * pyo.units.g / pyo.units.m**3) m.fs.R1.inlet.conc_mass_comp[0, "X_I"].fix(1149 * pyo.units.g / pyo.units.m**3) m.fs.R1.inlet.conc_mass_comp[0, "X_S"].fix(89.324 * pyo.units.g / pyo.units.m**3) - m.fs.R1.inlet.conc_mass_comp[0, "X_BH"].fix( - 2542.03 * pyo.units.g / pyo.units.m**3 - ) + m.fs.R1.inlet.conc_mass_comp[0, "X_BH"].fix(2542.03 * pyo.units.g / pyo.units.m**3) m.fs.R1.inlet.conc_mass_comp[0, "X_BA"].fix(148.6 * pyo.units.g / pyo.units.m**3) m.fs.R1.inlet.conc_mass_comp[0, "X_P"].fix(448 * pyo.units.g / pyo.units.m**3) m.fs.R1.inlet.conc_mass_comp[0, "S_O"].fix(0.3928 * pyo.units.g / pyo.units.m**3) diff --git a/watertap/property_models/anaerobic_digestion/adm1_reactions.py b/watertap/property_models/anaerobic_digestion/adm1_reactions.py index 3f5dfe9fc4..5f6e7de77f 100644 --- a/watertap/property_models/anaerobic_digestion/adm1_reactions.py +++ b/watertap/property_models/anaerobic_digestion/adm1_reactions.py @@ -1364,9 +1364,7 @@ def IN_acid_base_equilibrium_rule(self, t): ) def rule_pH(self): - return self.pH == -pyo.log10( - self.S_H / (pyo.units.kmole / pyo.units.m**3) - ) + return self.pH == -pyo.log10(self.S_H / (pyo.units.kmole / pyo.units.m**3)) self.pH_calc = pyo.Constraint(rule=rule_pH, doc="pH of solution") diff --git a/watertap/property_models/anaerobic_digestion/modified_adm1_reactions.py b/watertap/property_models/anaerobic_digestion/modified_adm1_reactions.py index 086b55266e..3301d66069 100644 --- a/watertap/property_models/anaerobic_digestion/modified_adm1_reactions.py +++ b/watertap/property_models/anaerobic_digestion/modified_adm1_reactions.py @@ -1937,9 +1937,7 @@ def IN_acid_base_equilibrium_rule(self, t): ) def rule_pH(self): - return self.pH == -pyo.log10( - self.S_H / (pyo.units.kmole / pyo.units.m**3) - ) + return self.pH == -pyo.log10(self.S_H / (pyo.units.kmole / pyo.units.m**3)) self.pH_calc = pyo.Constraint(rule=rule_pH, doc="pH of solution") diff --git a/watertap/property_models/cryst_prop_pack.py b/watertap/property_models/cryst_prop_pack.py index d1182d1c81..fb323e3423 100644 --- a/watertap/property_models/cryst_prop_pack.py +++ b/watertap/property_models/cryst_prop_pack.py @@ -1363,8 +1363,7 @@ def rule_cp_mass_solvent(b, p): C = b.params.cp_phase_param_C1 D = b.params.cp_phase_param_D1 return ( - b.cp_mass_solvent["Liq"] - == (A + B * t + C * t**2 + D * t**3) * 1000 + b.cp_mass_solvent["Liq"] == (A + B * t + C * t**2 + D * t**3) * 1000 ) elif p == "Vap": t = b.temperature / 1000 @@ -1551,9 +1550,7 @@ def rule_pressure_sat(b): # vapor pressure, eq6 in Sparrow (2003) + (b.params.pressure_sat_param_E5 * x**4) ) - p_sat = ( - ps_a + (ps_b * t) + (ps_c * t**2) + (ps_d * t**3) + (ps_e * t**4) - ) + p_sat = ps_a + (ps_b * t) + (ps_c * t**2) + (ps_d * t**3) + (ps_e * t**4) return b.pressure_sat == pyunits.convert(p_sat, to_units=pyunits.Pa) self.eq_pressure_sat = Constraint(rule=rule_pressure_sat) @@ -2141,7 +2138,7 @@ def calculate_scaling_factors(self): if self.is_property_constructed(v_str): v = getattr(self, v_str) c_phase = getattr(self, "eq_" + v_str) - for (ind, c) in c_phase.items(): + for ind, c in c_phase.items(): sf = iscale.get_scaling_factor(v[ind], default=1, warning=True) iscale.constraint_scaling_transform(c, sf) diff --git a/watertap/property_models/seawater_prop_pack.py b/watertap/property_models/seawater_prop_pack.py index 91607ffefd..36f2ed3ea4 100644 --- a/watertap/property_models/seawater_prop_pack.py +++ b/watertap/property_models/seawater_prop_pack.py @@ -1092,6 +1092,7 @@ def _dens_mass_phase(self): units=pyunits.kg * pyunits.m**-3, doc="Mass density of seawater", ) + # Sharqawy et al. (2010), eq. 8, 0-180 C, 0-150 g/kg, 0-12 MPa def rule_dens_mass_phase(b, p): t = b.temperature - 273.15 * pyunits.K @@ -1117,6 +1118,7 @@ def _dens_mass_solvent(self): units=pyunits.kg * pyunits.m**-3, doc="Mass density of pure water", ) + # Sharqawy et al. (2010), eq. 8, 0-180 C def rule_dens_mass_solvent(b): t = b.temperature - 273.15 * pyunits.K @@ -1252,6 +1254,7 @@ def _visc_d_phase(self): units=pyunits.Pa * pyunits.s, doc="Viscosity", ) + # Sharqawy et al. (2010), eq. 22 and 23, 0-180 C, 0-150 g/kg def rule_visc_d_phase(b, p): # temperature in degC, but pyunits are K @@ -1291,6 +1294,7 @@ def _diffus_phase_comp(self): units=pyunits.m**2 * pyunits.s**-1, doc="Diffusivity", ) + # Bartholomew & Mauter (2019), eq. 6 (substituting NaCl w/ TDS), 25 C def rule_diffus_phase_comp(b, p, j): return b.diffus_phase_comp[p, j] == ( @@ -1312,6 +1316,7 @@ def _osm_coeff(self): units=pyunits.dimensionless, doc="Osmotic coefficient", ) + # Sharqawy et al. (2010), eq. 49, 0-200 C, 0-120 g/kg def rule_osm_coeff(b): s = b.mass_frac_phase_comp["Liq", "TDS"] @@ -1341,6 +1346,7 @@ def _pressure_osm_phase(self): units=pyunits.Pa, doc="Osmotic pressure", ) + # Nayar et al. (2016), eq. 48, 0-200 C, 0-120 g/kg def rule_pressure_osm_phase(b, p): i = 2 # number of ionic species @@ -1366,6 +1372,7 @@ def _enth_mass_phase(self): units=pyunits.J * pyunits.kg**-1, doc="Specific enthalpy", ) + # Nayar et al. (2016), eq. 25 and 26, 10-120 C, 0-120 g/kg, 0-12 MPa def rule_enth_mass_phase(b, p): # temperature in degC, but pyunits in K @@ -1427,6 +1434,7 @@ def _pressure_sat(self): self.pressure_sat = Var( initialize=1e3, bounds=(1, 1e8), units=pyunits.Pa, doc="Vapor pressure" ) + # Nayar et al.(2016), eq. 5 and 6, 0-180 C, 0-160 g/kg def rule_pressure_sat(b): t = b.temperature @@ -1457,6 +1465,7 @@ def _cp_mass_phase(self): units=pyunits.J / pyunits.kg / pyunits.K, doc="Specific heat capacity", ) + # Sharqawy et al. (2010), eq. 9, 0-180 C, 0-180 g/kg, 0-12 MPa def rule_cp_mass_phase(b, p): # Convert T90 to T68, eq. 4 in Sharqawy et al. (2010); primary reference from Rusby (1991) @@ -1496,6 +1505,7 @@ def _therm_cond_phase(self): units=pyunits.W / pyunits.m / pyunits.K, doc="Thermal conductivity", ) + # Sharqawy et al. (2010), eq. 13, 0-180 C, 0-160 g/kg def rule_therm_cond_phase(b, p): # Convert T90 to T68, eq. 4 in Sharqawy et al. (2010); primary reference from Rusby (1991) @@ -1537,6 +1547,7 @@ def _dh_vap_mass(self): units=pyunits.J / pyunits.kg, doc="Latent heat of vaporization", ) + # Sharqawy et al. (2010), eq. 37 and 54, 0-200 C, 0-240 g/kg def rule_dh_vap_mass(b): t = b.temperature - 273.15 * pyunits.K @@ -1560,6 +1571,7 @@ def _boiling_point_elevation_phase(self): units=pyunits.K, doc="Boiling point elevation", ) + # Sharqawy et al. (2010), eq. 36, 0-200 C, 0-120 g/kg def rule_boiling_point_elevation_phase(b, p): t = b.temperature - 273.15 * pyunits.K diff --git a/watertap/property_models/tests/property_test_harness.py b/watertap/property_models/tests/property_test_harness.py index c2721aed30..86c76fc7ca 100644 --- a/watertap/property_models/tests/property_test_harness.py +++ b/watertap/property_models/tests/property_test_harness.py @@ -335,7 +335,7 @@ def test_badly_scaled(self, frame_stateblock): ) if len(badly_scaled_var_list) != 0: lst = [] - for (var, val) in badly_scaled_var_list: + for var, val in badly_scaled_var_list: lst.append((var.name, val)) raise PropertyValueError( "The following variable(s) are poorly scaled: {lst}".format(lst=lst) @@ -530,9 +530,7 @@ def test_property_regression(self): # check if any variables are badly scaled lst = [] - for (var, val) in badly_scaled_var_generator( - m, large=1e2, small=1e-2, zero=1e-8 - ): + for var, val in badly_scaled_var_generator(m, large=1e2, small=1e-2, zero=1e-8): lst.append((var.name, val)) print(var.name, var.value) if lst: @@ -626,9 +624,7 @@ def test_calculate_state(self): # check if any variables are badly scaled lst = [] - for (var, val) in badly_scaled_var_generator( - m, large=1e2, small=1e-2, zero=1e-8 - ): + for var, val in badly_scaled_var_generator(m, large=1e2, small=1e-2, zero=1e-8): lst.append((var.name, val)) print(var.name, var.value) if lst: diff --git a/watertap/property_models/tests/test_NDMA_prop_pack.py b/watertap/property_models/tests/test_NDMA_prop_pack.py index a7a929ca48..db15810271 100644 --- a/watertap/property_models/tests/test_NDMA_prop_pack.py +++ b/watertap/property_models/tests/test_NDMA_prop_pack.py @@ -21,6 +21,7 @@ PropertyCalculateStateTest, ) + # ----------------------------------------------------------------------------- @pytest.mark.unit class TestNDMAroperty_idaes(PropertyTestHarness_idaes): diff --git a/watertap/property_models/tests/test_NaCl_T_dep_prop_pack.py b/watertap/property_models/tests/test_NaCl_T_dep_prop_pack.py index 4e9af1f832..12a85c0a49 100644 --- a/watertap/property_models/tests/test_NaCl_T_dep_prop_pack.py +++ b/watertap/property_models/tests/test_NaCl_T_dep_prop_pack.py @@ -20,6 +20,7 @@ PropertyRegressionTest, ) + # ----------------------------------------------------------------------------- @pytest.mark.unit class TestNaClProperty_idaes(PropertyTestHarness_idaes): diff --git a/watertap/property_models/tests/test_NaCl_prop_pack.py b/watertap/property_models/tests/test_NaCl_prop_pack.py index fbe7a0cf5a..96121af86b 100644 --- a/watertap/property_models/tests/test_NaCl_prop_pack.py +++ b/watertap/property_models/tests/test_NaCl_prop_pack.py @@ -21,6 +21,7 @@ PropertyCalculateStateTest, ) + # ----------------------------------------------------------------------------- @pytest.mark.unit class TestNaClProperty_idaes(PropertyTestHarness_idaes): diff --git a/watertap/property_models/tests/test_coag_prop_pack.py b/watertap/property_models/tests/test_coag_prop_pack.py index 4cead9a179..2b7473574f 100644 --- a/watertap/property_models/tests/test_coag_prop_pack.py +++ b/watertap/property_models/tests/test_coag_prop_pack.py @@ -39,6 +39,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- # Start test class class TestCoagulationPropPack: diff --git a/watertap/property_models/tests/test_multicomp_aq_sol_prop_pack.py b/watertap/property_models/tests/test_multicomp_aq_sol_prop_pack.py index 2ead60510e..2602b70c94 100644 --- a/watertap/property_models/tests/test_multicomp_aq_sol_prop_pack.py +++ b/watertap/property_models/tests/test_multicomp_aq_sol_prop_pack.py @@ -80,6 +80,8 @@ solver = get_solver() + + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): diff --git a/watertap/property_models/tests/test_seawater_prop_pack.py b/watertap/property_models/tests/test_seawater_prop_pack.py index 318d9be4ee..f362b3cb94 100644 --- a/watertap/property_models/tests/test_seawater_prop_pack.py +++ b/watertap/property_models/tests/test_seawater_prop_pack.py @@ -20,6 +20,7 @@ PropertyCalculateStateTest, ) + # ----------------------------------------------------------------------------- class TestSeawaterProperty_idaes(PropertyTestHarness_idaes): def configure(self): diff --git a/watertap/property_models/tests/test_water_prop_pack.py b/watertap/property_models/tests/test_water_prop_pack.py index c01bb29451..190a82fb48 100644 --- a/watertap/property_models/tests/test_water_prop_pack.py +++ b/watertap/property_models/tests/test_water_prop_pack.py @@ -19,6 +19,7 @@ PropertyRegressionTest, ) + # ----------------------------------------------------------------------------- class TestWaterProperty_idaes(PropertyTestHarness_idaes): def configure(self): diff --git a/watertap/property_models/water_prop_pack.py b/watertap/property_models/water_prop_pack.py index d799ce51fb..cb864c04fa 100644 --- a/watertap/property_models/water_prop_pack.py +++ b/watertap/property_models/water_prop_pack.py @@ -767,6 +767,7 @@ def _dens_mass_phase(self): units=pyunits.kg * pyunits.m**-3, doc="Mass density of seawater", ) + # Sharqawy et al. (2010), eq. 8, 0-180 C def rule_dens_mass_phase(b, phase): t = b.temperature - 273.15 * pyunits.K @@ -868,6 +869,7 @@ def _enth_mass_phase(self): units=pyunits.J * pyunits.kg**-1, doc="Specific enthalpy", ) + # Nayar et al. (2016), eq. 25 and 26, 0-120 C def rule_enth_mass_phase(b, p): # temperature in degC, but pyunits in K @@ -966,8 +968,7 @@ def rule_cp_mass_phase(b, phase): C = b.params.cp_phase_param_C1 D = b.params.cp_phase_param_D1 return ( - b.cp_mass_phase[phase] - == (A + B * t + C * t**2 + D * t**3) * 1000 + b.cp_mass_phase[phase] == (A + B * t + C * t**2 + D * t**3) * 1000 ) # phase == 'Vap' else: @@ -992,6 +993,7 @@ def _dh_vap_mass(self): units=pyunits.J / pyunits.kg, doc="Latent heat of vaporization", ) + # Sharqawy et al. (2010), eq. 54, 0-200 C def rule_dh_vap_mass(b): t = b.temperature - 273.15 * pyunits.K @@ -1014,6 +1016,7 @@ def _visc_d_phase(self): units=pyunits.Pa * pyunits.s, doc="Dynamic viscosity", ) + # Sharqawy et al. (2010), eq. 22 and 23, 0-180 C def rule_visc_d_phase(b, p): if p == "Liq": @@ -1040,6 +1043,7 @@ def _therm_cond_phase(self): units=pyunits.W / pyunits.m / pyunits.K, doc="Thermal conductivity", ) + # Sharqawy et al. (2010), eq. 13, 0-180 C def rule_therm_cond_phase(b, p): if p == "Liq": diff --git a/watertap/tools/analysis_tools/loop_tool/loop_tool.py b/watertap/tools/analysis_tools/loop_tool/loop_tool.py index 98289cabc4..f163223827 100644 --- a/watertap/tools/analysis_tools/loop_tool/loop_tool.py +++ b/watertap/tools/analysis_tools/loop_tool/loop_tool.py @@ -620,9 +620,9 @@ def run_parameter_sweep(self): ps_kwargs["initialize_kwargs"] = self.combined_init_defaults ps_kwargs["initialize_before_sweep"] = self.initialize_before_sweep - ps_kwargs[ - "update_sweep_params_before_init" - ] = self.update_sweep_params_before_init + ps_kwargs["update_sweep_params_before_init"] = ( + self.update_sweep_params_before_init + ) ps_kwargs["custom_do_param_sweep"] = self.custom_do_param_sweep ps_kwargs["custom_do_param_sweep_kwargs"] = self.custom_do_param_sweep_kwargs @@ -681,9 +681,9 @@ def run_diff_parameter_sweep(self): ps_kwargs["initialize_kwargs"] = self.combined_init_defaults ps_kwargs["initialize_before_sweep"] = self.initialize_before_sweep - ps_kwargs[ - "update_sweep_params_before_init" - ] = self.update_sweep_params_before_init + ps_kwargs["update_sweep_params_before_init"] = ( + self.update_sweep_params_before_init + ) ps_kwargs["custom_do_param_sweep"] = self.custom_do_param_sweep ps_kwargs["custom_do_param_sweep_kwargs"] = self.custom_do_param_sweep_kwargs @@ -702,9 +702,9 @@ def run_diff_parameter_sweep(self): ps_kwargs["build_outputs"] = self.build_outputs ps_kwargs["build_outputs_kwargs"] = self.build_outputs_kwargs - ps_kwargs[ - "build_differential_sweep_specs" - ] = ParameterSweepReader()._dict_to_diff_spec + ps_kwargs["build_differential_sweep_specs"] = ( + ParameterSweepReader()._dict_to_diff_spec + ) ps_kwargs["build_differential_sweep_specs_kwargs"] = { "input_dict": self.differential_sweep_specs } diff --git a/watertap/tools/oli_api/credentials.py b/watertap/tools/oli_api/credentials.py index b12fc7275a..cd997ed6f7 100644 --- a/watertap/tools/oli_api/credentials.py +++ b/watertap/tools/oli_api/credentials.py @@ -71,6 +71,7 @@ _logger.addHandler(handler) _logger.setLevel(logging.DEBUG) + # TODO: consider letting user set logging level instead of using interactive mode class CredentialManager: """ diff --git a/watertap/tools/oli_api/flash.py b/watertap/tools/oli_api/flash.py index f0cc41f441..bd30dbb3fc 100644 --- a/watertap/tools/oli_api/flash.py +++ b/watertap/tools/oli_api/flash.py @@ -382,7 +382,6 @@ def configure_flash_analysis( use_scaling_rigorous=True, file_name=None, ): - """ Configure Flash Analysis JSON input. diff --git a/watertap/tools/parameter_sweep/parameter_sweep.py b/watertap/tools/parameter_sweep/parameter_sweep.py index c3c75328e5..82a8f057f4 100644 --- a/watertap/tools/parameter_sweep/parameter_sweep.py +++ b/watertap/tools/parameter_sweep/parameter_sweep.py @@ -515,9 +515,9 @@ def _create_local_output_skeleton(self, model, sweep_params, outputs, num_sample # Store the inputs for param_name, sampling_obj in sweep_params.items(): var = sampling_obj.pyomo_object - output_dict["sweep_params"][ - param_name - ] = self._create_component_output_skeleton(var, num_samples) + output_dict["sweep_params"][param_name] = ( + self._create_component_output_skeleton(var, num_samples) + ) if outputs is None: # No outputs are specified, so every Var, Expression, and Objective on the model should be saved @@ -527,21 +527,21 @@ def _create_local_output_skeleton(self, model, sweep_params, outputs, num_sample # We do however need to make sure that the short name for the inputs is used here for param_name, sampling_obj in sweep_params.items(): if pyo_obj.name == sampling_obj.pyomo_object.name: - output_dict["outputs"][ - param_name - ] = self._create_component_output_skeleton(pyo_obj, num_samples) + output_dict["outputs"][param_name] = ( + self._create_component_output_skeleton(pyo_obj, num_samples) + ) else: - output_dict["outputs"][ - pyo_obj.name - ] = self._create_component_output_skeleton(pyo_obj, num_samples) + output_dict["outputs"][pyo_obj.name] = ( + self._create_component_output_skeleton(pyo_obj, num_samples) + ) else: # Save only the outputs specified in the outputs dictionary for short_name, pyo_obj in outputs.items(): - output_dict["outputs"][ - short_name - ] = self._create_component_output_skeleton( - self._get_object(model, pyo_obj), num_samples + output_dict["outputs"][short_name] = ( + self._create_component_output_skeleton( + self._get_object(model, pyo_obj), num_samples + ) ) return output_dict @@ -905,9 +905,9 @@ def _filter_recursive_solves( for key, item in content.items(): if key != "solve_successful": for subkey, subitem in item.items(): - local_filtered_dict[key][subkey]["value"][ - offset:stop - ] = subitem["value"][optimal_indices] + local_filtered_dict[key][subkey]["value"][offset:stop] = ( + subitem["value"][optimal_indices] + ) # Place the solve status local_filtered_dict["solve_successful"].extend( @@ -1053,13 +1053,13 @@ def parameter_sweep( local_values, ) else: - local_output_collection[ - loop_ctr - ] = self.self.config.custom_do_param_sweep( - sweep_params, - outputs, - local_values, - **self.config.custom_do_param_sweep_kwargs, + local_output_collection[loop_ctr] = ( + self.self.config.custom_do_param_sweep( + sweep_params, + outputs, + local_values, + **self.config.custom_do_param_sweep_kwargs, + ) ) # Get the number of successful solves on this proc (sum of boolean flags) diff --git a/watertap/tools/parameter_sweep/parameter_sweep_differential.py b/watertap/tools/parameter_sweep/parameter_sweep_differential.py index a3ac55ec98..f794f3742c 100644 --- a/watertap/tools/parameter_sweep/parameter_sweep_differential.py +++ b/watertap/tools/parameter_sweep/parameter_sweep_differential.py @@ -273,12 +273,14 @@ def _append_differential_results( # This loop shouldn't run if the above set is empty for subkey in missing_sub_keys: # We are picking the unchanged sweep_params from the outputs. In the ideal world, they would be the same. - local_output_dict["sweep_params"][subkey][ - "value" - ] = np.concatenate( - ( - local_output_dict["sweep_params"][subkey]["value"], - diff_sol["outputs"][subkey]["value"], + local_output_dict["sweep_params"][subkey]["value"] = ( + np.concatenate( + ( + local_output_dict["sweep_params"][subkey][ + "value" + ], + diff_sol["outputs"][subkey]["value"], + ) ) ) diff --git a/watertap/unit_models/boron_removal.py b/watertap/unit_models/boron_removal.py index 048e870d86..3454cc4820 100644 --- a/watertap/unit_models/boron_removal.py +++ b/watertap/unit_models/boron_removal.py @@ -47,6 +47,7 @@ _log = idaeslog.getLogger(__name__) + # Name of the unit model @declare_process_block_class("BoronRemoval") class BoronRemovalData(InitializationMixin, UnitModelBlockData): diff --git a/watertap/unit_models/coag_floc_model.py b/watertap/unit_models/coag_floc_model.py index d62a1e7660..46a48f0d9c 100644 --- a/watertap/unit_models/coag_floc_model.py +++ b/watertap/unit_models/coag_floc_model.py @@ -46,6 +46,7 @@ _log = idaeslog.getLogger(__name__) + # Name of the unit model @declare_process_block_class("CoagulationFlocculation") class CoagulationFlocculationData(InitializationMixin, UnitModelBlockData): diff --git a/watertap/unit_models/crystallizer.py b/watertap/unit_models/crystallizer.py index 70d1842010..63dc2e3281 100644 --- a/watertap/unit_models/crystallizer.py +++ b/watertap/unit_models/crystallizer.py @@ -46,6 +46,7 @@ __author__ = "Oluwamayowa Amusat" + # when using this file the name "Filtration" is what is imported @declare_process_block_class("Crystallization") class CrystallizationData(InitializationMixin, UnitModelBlockData): @@ -774,12 +775,12 @@ def _get_performance_contents(self, time_point=0): var_dict["Slurry density (Kg/m3)"] = self.dens_mass_slurry var_dict["Heat requirement"] = self.work_mechanical[time_point] var_dict["Crystallizer diameter (m)"] = self.diameter_crystallizer - var_dict[ - "Magma circulation flow rate (m**3/s)" - ] = self.magma_circulation_flow_vol - var_dict[ - "Vol. frac. of solids in suspension, 1-E" - ] = self.product_volumetric_solids_fraction + var_dict["Magma circulation flow rate (m**3/s)"] = ( + self.magma_circulation_flow_vol + ) + var_dict["Vol. frac. of solids in suspension, 1-E"] = ( + self.product_volumetric_solids_fraction + ) var_dict["Residence time"] = self.t_res var_dict["Crystallizer minimum active volume (m**3)"] = self.volume_suspension var_dict["Suspension height in crystallizer (m)"] = self.height_slurry diff --git a/watertap/unit_models/cstr_injection.py b/watertap/unit_models/cstr_injection.py index a2a949cb65..05e751e1a2 100644 --- a/watertap/unit_models/cstr_injection.py +++ b/watertap/unit_models/cstr_injection.py @@ -430,6 +430,7 @@ def eq_mass_transfer(self, t): mutable=True, doc="Electricity intensity with respect to inlet flow", ) + # Electricity constraint @self.Constraint( self.flowsheet().time, diff --git a/watertap/unit_models/dewatering.py b/watertap/unit_models/dewatering.py index fe51946f8e..a5c14b00b2 100644 --- a/watertap/unit_models/dewatering.py +++ b/watertap/unit_models/dewatering.py @@ -229,9 +229,9 @@ def _get_performance_contents(self, time_point=0): if k[0] == time_point: var_dict[f"Split Fraction [{str(k[1:])}]"] = self.split_fraction[k] var_dict["Electricity consumption"] = self.electricity_consumption[time_point] - param_dict[ - "Specific electricity consumption" - ] = self.energy_electric_flow_vol_inlet[time_point] + param_dict["Specific electricity consumption"] = ( + self.energy_electric_flow_vol_inlet[time_point] + ) var_dict["Unit Volume"] = self.volume[time_point] var_dict["Hydraulic Retention Time"] = self.hydraulic_retention_time[time_point] return {"vars": var_dict, "params": param_dict} diff --git a/watertap/unit_models/electroNP_ZO.py b/watertap/unit_models/electroNP_ZO.py index 842e6f9f01..e144526ef1 100644 --- a/watertap/unit_models/electroNP_ZO.py +++ b/watertap/unit_models/electroNP_ZO.py @@ -197,9 +197,9 @@ def _get_performance_contents(self, time_point=0): ] var_dict["Electricity Demand"] = self.electricity[time_point] var_dict["Electricity Intensity"] = self.energy_electric_flow_mass - var_dict[ - "Dosage of magnesium chloride per treated phosphorus" - ] = self.magnesium_chloride_dosage + var_dict["Dosage of magnesium chloride per treated phosphorus"] = ( + self.magnesium_chloride_dosage + ) var_dict["Magnesium Chloride Demand"] = self.MgCl2_flowrate[time_point] return {"vars": var_dict} diff --git a/watertap/unit_models/electrodialysis_0D.py b/watertap/unit_models/electrodialysis_0D.py index 82346d9f59..5f5183024a 100644 --- a/watertap/unit_models/electrodialysis_0D.py +++ b/watertap/unit_models/electrodialysis_0D.py @@ -1867,9 +1867,7 @@ def eq_Re(self): ) def eq_Sc(self): - return ( - self.N_Sc == self.visc_d * self.dens_mass**-1 * self.diffus_mass**-1 - ) + return self.N_Sc == self.visc_d * self.dens_mass**-1 * self.diffus_mass**-1 @self.Constraint( doc="To calculate Sh", @@ -1936,10 +1934,7 @@ def eq_friction_factor(self): ): return ( self.friction_factor - == 4 - * 50.6 - * self.spacer_porosity**-7.06 - * self.N_Re**-1 + == 4 * 50.6 * self.spacer_porosity**-7.06 * self.N_Re**-1 ) elif ( self.config.friction_factor_method @@ -1996,10 +1991,12 @@ def initialize_build( self[k].diluate.properties_out[0].flow_mol_phase_comp["Liq", j] = value( self[k].diluate.properties_in[0].flow_mol_phase_comp["Liq", j] ) - self[k].concentrate.properties_out[0].flow_mol_phase_comp[ - "Liq", j - ] = value( - self[k].concentrate.properties_in[0].flow_mol_phase_comp["Liq", j] + self[k].concentrate.properties_out[0].flow_mol_phase_comp["Liq", j] = ( + value( + self[k] + .concentrate.properties_in[0] + .flow_mol_phase_comp["Liq", j] + ) ) if hasattr(self[k], "conc_mem_surf_mol_ioa"): for mem in self[k].membrane_set: diff --git a/watertap/unit_models/electrodialysis_1D.py b/watertap/unit_models/electrodialysis_1D.py index 67d89ae31e..1ea2c7ccd3 100644 --- a/watertap/unit_models/electrodialysis_1D.py +++ b/watertap/unit_models/electrodialysis_1D.py @@ -1847,9 +1847,7 @@ def eq_Re(self): ) def eq_Sc(self): - return ( - self.N_Sc == self.visc_d * self.dens_mass**-1 * self.diffus_mass**-1 - ) + return self.N_Sc == self.visc_d * self.dens_mass**-1 * self.diffus_mass**-1 @self.Constraint( doc="To calculate Sc", @@ -1919,10 +1917,7 @@ def eq_friction_factor(self): ): return ( self.friction_factor - == 4 - * 50.6 - * self.spacer_porosity**-7.06 - * self.N_Re**-1 + == 4 * 50.6 * self.spacer_porosity**-7.06 * self.N_Re**-1 ) elif ( self.config.friction_factor_method @@ -1997,24 +1992,24 @@ def initialize_build( in self[k].diluate.properties[set].define_state_vars() ): for ind in self[k].diluate.properties[set].flow_mol_phase_comp: - self[k].diluate.properties[set].flow_mol_phase_comp[ - ind - ] = value( - self[k] - .diluate.properties[(0.0, 0.0)] - .flow_mol_phase_comp[ind] + self[k].diluate.properties[set].flow_mol_phase_comp[ind] = ( + value( + self[k] + .diluate.properties[(0.0, 0.0)] + .flow_mol_phase_comp[ind] + ) ) if ( "flow_mass_phase_comp" in self[k].diluate.properties[set].define_state_vars() ): for ind in self[k].diluate.properties[set].flow_mass_phase_comp: - self[k].diluate.properties[set].flow_mass_phase_comp[ - ind - ] = value( - self[k] - .diluate.properties[(0.0, 0.0)] - .flow_mass_phase_comp[ind] + self[k].diluate.properties[set].flow_mass_phase_comp[ind] = ( + value( + self[k] + .diluate.properties[(0.0, 0.0)] + .flow_mass_phase_comp[ind] + ) ) if hasattr(self[k], "conc_mem_surf_mol_x"): for mem in self[k].membrane_set: @@ -2056,12 +2051,12 @@ def initialize_build( in self[k].concentrate.properties[set].define_state_vars() ): for ind in self[k].concentrate.properties[set].flow_mol_phase_comp: - self[k].concentrate.properties[set].flow_mol_phase_comp[ - ind - ] = value( - self[k] - .concentrate.properties[(0.0, 0.0)] - .flow_mol_phase_comp[ind] + self[k].concentrate.properties[set].flow_mol_phase_comp[ind] = ( + value( + self[k] + .concentrate.properties[(0.0, 0.0)] + .flow_mol_phase_comp[ind] + ) ) if ( "flow_mass_phase_comp" diff --git a/watertap/unit_models/ion_exchange_0D.py b/watertap/unit_models/ion_exchange_0D.py index 7bb16b700b..3251fb26af 100644 --- a/watertap/unit_models/ion_exchange_0D.py +++ b/watertap/unit_models/ion_exchange_0D.py @@ -1467,9 +1467,9 @@ def _get_performance_contents(self, time_point=0): var_dict["Dimensionless Time"] = self.dimensionless_time var_dict["Partition Ratio"] = self.partition_ratio var_dict[f"Langmuir Coeff. [{target_ion}]"] = self.langmuir[target_ion] - var_dict[ - f"Fluid Mass Transfer Coeff. [{target_ion}]" - ] = self.fluid_mass_transfer_coeff[target_ion] + var_dict[f"Fluid Mass Transfer Coeff. [{target_ion}]"] = ( + self.fluid_mass_transfer_coeff[target_ion] + ) elif self.config.isotherm == IsothermType.freundlich: var_dict[f"BV at Breakthrough"] = self.bv var_dict[f"BV at 50% Breakthrough"] = self.bv_50 diff --git a/watertap/unit_models/mvc/components/tests/test_chen_heat_exchanger.py b/watertap/unit_models/mvc/components/tests/test_chen_heat_exchanger.py index 13ccff9fb7..215f818a14 100644 --- a/watertap/unit_models/mvc/components/tests/test_chen_heat_exchanger.py +++ b/watertap/unit_models/mvc/components/tests/test_chen_heat_exchanger.py @@ -29,6 +29,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.requires_idaes_solver @pytest.mark.component diff --git a/watertap/unit_models/mvc/components/tests/test_complete_condenser.py b/watertap/unit_models/mvc/components/tests/test_complete_condenser.py index f0ec833393..e72b4cf87c 100644 --- a/watertap/unit_models/mvc/components/tests/test_complete_condenser.py +++ b/watertap/unit_models/mvc/components/tests/test_complete_condenser.py @@ -23,6 +23,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.component def test_complete_condense(): diff --git a/watertap/unit_models/mvc/components/tests/test_compressor.py b/watertap/unit_models/mvc/components/tests/test_compressor.py index 4d6b18c987..cb856989fa 100644 --- a/watertap/unit_models/mvc/components/tests/test_compressor.py +++ b/watertap/unit_models/mvc/components/tests/test_compressor.py @@ -23,6 +23,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.component def test_compressor(): diff --git a/watertap/unit_models/mvc/components/tests/test_evaporator.py b/watertap/unit_models/mvc/components/tests/test_evaporator.py index 8bc5a8753e..0ba02d116a 100644 --- a/watertap/unit_models/mvc/components/tests/test_evaporator.py +++ b/watertap/unit_models/mvc/components/tests/test_evaporator.py @@ -24,6 +24,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.requires_idaes_solver @pytest.mark.component diff --git a/watertap/unit_models/nanofiltration_DSPMDE_0D.py b/watertap/unit_models/nanofiltration_DSPMDE_0D.py index c167704f82..18c45f3013 100644 --- a/watertap/unit_models/nanofiltration_DSPMDE_0D.py +++ b/watertap/unit_models/nanofiltration_DSPMDE_0D.py @@ -1564,16 +1564,16 @@ def _get_performance_contents(self, time_point=0): if self.feed_side.properties_in[time_point].is_property_constructed( "flow_vol_phase" ): - var_dict[ - f"Volumetric flow rate @ feed inlet" - ] = self.feed_side.properties_in[time_point].flow_vol_phase["Liq"] + var_dict[f"Volumetric flow rate @ feed inlet"] = ( + self.feed_side.properties_in[time_point].flow_vol_phase["Liq"] + ) if self.feed_side.properties_out[time_point].is_property_constructed( "flow_vol_phase" ): - var_dict[ - f"Volumetric flow rate @ feed outlet" - ] = self.feed_side.properties_out[time_point].flow_vol_phase["Liq"] + var_dict[f"Volumetric flow rate @ feed outlet"] = ( + self.feed_side.properties_out[time_point].flow_vol_phase["Liq"] + ) var_dict[f"Volumetric flow rate @ final permeate"] = self.mixed_permeate[ time_point @@ -1587,26 +1587,26 @@ def _get_performance_contents(self, time_point=0): time_point, "Liq", j ] # Molar flowrates - var_dict[ - f"Molar flow rate of {j} @ feed inlet" - ] = self.feed_side.properties_in[time_point].flow_mol_phase_comp["Liq", j] - var_dict[ - f"Molar flow rate of {j} @ feed outlet" - ] = self.feed_side.properties_out[time_point].flow_mol_phase_comp["Liq", j] + var_dict[f"Molar flow rate of {j} @ feed inlet"] = ( + self.feed_side.properties_in[time_point].flow_mol_phase_comp["Liq", j] + ) + var_dict[f"Molar flow rate of {j} @ feed outlet"] = ( + self.feed_side.properties_out[time_point].flow_mol_phase_comp["Liq", j] + ) var_dict[f"Molar flow rate of {j} @ mixed permeate"] = self.mixed_permeate[ time_point ].flow_mol_phase_comp["Liq", j] - var_dict[ - f"Molar Concentration of {j} @ Feed Inlet" - ] = self.feed_side.properties_in[time_point].conc_mol_phase_comp["Liq", j] - var_dict[ - f"Molar Concentration of {j} @ Feed Outlet" - ] = self.feed_side.properties_out[time_point].conc_mol_phase_comp["Liq", j] - var_dict[ - f"Molar Concentration of {j} @ Final Permeate" - ] = self.mixed_permeate[time_point].conc_mol_phase_comp["Liq", j] + var_dict[f"Molar Concentration of {j} @ Feed Inlet"] = ( + self.feed_side.properties_in[time_point].conc_mol_phase_comp["Liq", j] + ) + var_dict[f"Molar Concentration of {j} @ Feed Outlet"] = ( + self.feed_side.properties_out[time_point].conc_mol_phase_comp["Liq", j] + ) + var_dict[f"Molar Concentration of {j} @ Final Permeate"] = ( + self.mixed_permeate[time_point].conc_mol_phase_comp["Liq", j] + ) for x in self.io_list: if not x: @@ -1616,22 +1616,20 @@ def _get_performance_contents(self, time_point=0): io = "Outlet" prop_feed = self.feed_side.properties_out[time_point] - var_dict[ - f"Molar Concentration of {j} @ Membrane Interface, {io}" - ] = self.feed_side.properties_interface[ - time_point, x - ].conc_mol_phase_comp[ - "Liq", j - ] - var_dict[ - f"Molar Concentration of {j} @ Pore Entrance, {io}" - ] = self.pore_entrance[time_point, x].conc_mol_phase_comp["Liq", j] - var_dict[ - f"Molar Concentration of {j} @ Pore Exit, {io}" - ] = self.pore_exit[time_point, x].conc_mol_phase_comp["Liq", j] - var_dict[ - f"Molar Concentration of {j} @ Permeate, {io}" - ] = self.permeate_side[time_point, x].conc_mol_phase_comp["Liq", j] + var_dict[f"Molar Concentration of {j} @ Membrane Interface, {io}"] = ( + self.feed_side.properties_interface[ + time_point, x + ].conc_mol_phase_comp["Liq", j] + ) + var_dict[f"Molar Concentration of {j} @ Pore Entrance, {io}"] = ( + self.pore_entrance[time_point, x].conc_mol_phase_comp["Liq", j] + ) + var_dict[f"Molar Concentration of {j} @ Pore Exit, {io}"] = ( + self.pore_exit[time_point, x].conc_mol_phase_comp["Liq", j] + ) + var_dict[f"Molar Concentration of {j} @ Permeate, {io}"] = ( + self.permeate_side[time_point, x].conc_mol_phase_comp["Liq", j] + ) for j in ( self.config.property_package.solute_set @@ -1643,56 +1641,56 @@ def _get_performance_contents(self, time_point=0): expr_dict[f"Stokes:Pore Radius Ratio of {j}"] = self.lambda_comp[ time_point, j ] - expr_dict[ - f"Diffusive Hindrance Factor of {j}" - ] = self.hindrance_factor_diffusive_comp[time_point, j] - expr_dict[ - f"Convective Hindrance Factor of {j}" - ] = self.hindrance_factor_convective_comp[time_point, j] + expr_dict[f"Diffusive Hindrance Factor of {j}"] = ( + self.hindrance_factor_diffusive_comp[time_point, j] + ) + expr_dict[f"Convective Hindrance Factor of {j}"] = ( + self.hindrance_factor_convective_comp[time_point, j] + ) expr_dict[f"Pore Diffusivity of {j}"] = self.diffus_pore_comp[time_point, j] - expr_dict[ - f"Gibbs Free Energy of Solvation of {j}" - ] = self.gibbs_solvation_comp[time_point, j] - expr_dict[ - f"Born Solvation Energy Partitioning Factor of {j}" - ] = self.partition_factor_born_solvation_comp[time_point, j] - expr_dict[ - f"Steric Hindrance Partitioning Factor of {j}" - ] = self.partition_factor_steric_comp[time_point, j] - expr_dict[ - f"Donnan Partitioning Factor of {j} @ Feed-side Inlet" - ] = self.partition_factor_donnan_comp_feed[time_point, 0, j] - expr_dict[ - f"Donnan Partitioning Factor of {j} @ Permeate-side Inlet" - ] = self.partition_factor_donnan_comp_permeate[time_point, 0, j] - expr_dict[ - f"Donnan Partitioning Factor of {j} @ Feed-side Outlet" - ] = self.partition_factor_donnan_comp_feed[time_point, 1, j] - expr_dict[ - f"Donnan Partitioning Factor of {j} @ Permeate-side Outlet" - ] = self.partition_factor_donnan_comp_permeate[time_point, 1, j] - - var_dict[ - f"Intrinsic Rejection of {j}" - ] = self.rejection_intrinsic_phase_comp[time_point, "Liq", j] - - expr_dict[ - f"Observed Rejection of {j}" - ] = self.rejection_observed_phase_comp[time_point, "Liq", j] + expr_dict[f"Gibbs Free Energy of Solvation of {j}"] = ( + self.gibbs_solvation_comp[time_point, j] + ) + expr_dict[f"Born Solvation Energy Partitioning Factor of {j}"] = ( + self.partition_factor_born_solvation_comp[time_point, j] + ) + expr_dict[f"Steric Hindrance Partitioning Factor of {j}"] = ( + self.partition_factor_steric_comp[time_point, j] + ) + expr_dict[f"Donnan Partitioning Factor of {j} @ Feed-side Inlet"] = ( + self.partition_factor_donnan_comp_feed[time_point, 0, j] + ) + expr_dict[f"Donnan Partitioning Factor of {j} @ Permeate-side Inlet"] = ( + self.partition_factor_donnan_comp_permeate[time_point, 0, j] + ) + expr_dict[f"Donnan Partitioning Factor of {j} @ Feed-side Outlet"] = ( + self.partition_factor_donnan_comp_feed[time_point, 1, j] + ) + expr_dict[f"Donnan Partitioning Factor of {j} @ Permeate-side Outlet"] = ( + self.partition_factor_donnan_comp_permeate[time_point, 1, j] + ) + + var_dict[f"Intrinsic Rejection of {j}"] = ( + self.rejection_intrinsic_phase_comp[time_point, "Liq", j] + ) + + expr_dict[f"Observed Rejection of {j}"] = ( + self.rejection_observed_phase_comp[time_point, "Liq", j] + ) if self.feed_side.properties_in[time_point].is_property_constructed( "pressure_osm_phase" ): - var_dict[ - f"Osmotic Pressure @ Bulk Feed, Inlet (Pa)" - ] = self.feed_side.properties_in[time_point].pressure_osm_phase["Liq"] + var_dict[f"Osmotic Pressure @ Bulk Feed, Inlet (Pa)"] = ( + self.feed_side.properties_in[time_point].pressure_osm_phase["Liq"] + ) if self.feed_side.properties_out[time_point].is_property_constructed( "pressure_osm_phase" ): - var_dict[ - f"Osmotic Pressure @ Bulk Feed, Outlet (Pa)" - ] = self.feed_side.properties_out[time_point].pressure_osm_phase["Liq"] + var_dict[f"Osmotic Pressure @ Bulk Feed, Outlet (Pa)"] = ( + self.feed_side.properties_out[time_point].pressure_osm_phase["Liq"] + ) for x in self.io_list: if not x: @@ -1702,17 +1700,15 @@ def _get_performance_contents(self, time_point=0): io = "Outlet" prop_feed = self.feed_side.properties_out[time_point] - var_dict[ - f"Osmotic Pressure @ Membrane Interface, {io} (Pa)" - ] = self.feed_side.properties_interface[ - time_point, x - ].pressure_osm_phase[ - "Liq" - ] - - var_dict[ - f"Osmotic Pressure @ Permeate, {io} (Pa)" - ] = self.permeate_side[time_point, x].pressure_osm_phase["Liq"] + var_dict[f"Osmotic Pressure @ Membrane Interface, {io} (Pa)"] = ( + self.feed_side.properties_interface[ + time_point, x + ].pressure_osm_phase["Liq"] + ) + + var_dict[f"Osmotic Pressure @ Permeate, {io} (Pa)"] = ( + self.permeate_side[time_point, x].pressure_osm_phase["Liq"] + ) expr_dict[f"Net Driving Pressure, {io} (Pa)"] = ( prop_feed.pressure - self.permeate_side[time_point, x].pressure @@ -1723,15 +1719,15 @@ def _get_performance_contents(self, time_point=0): - self.permeate_side[time_point, x].pressure_osm_phase["Liq"] ) ) - var_dict[ - f"Electric Potential @ Pore Entrance, {io}" - ] = self.electric_potential[time_point, x, "pore_entrance"] - var_dict[ - f"Electric Potential @ Pore Exit, {io}" - ] = self.electric_potential[time_point, x, "pore_exit"] - var_dict[ - f"Electric Potential @ Permeate, {io}" - ] = self.electric_potential[time_point, x, "permeate"] + var_dict[f"Electric Potential @ Pore Entrance, {io}"] = ( + self.electric_potential[time_point, x, "pore_entrance"] + ) + var_dict[f"Electric Potential @ Pore Exit, {io}"] = ( + self.electric_potential[time_point, x, "pore_exit"] + ) + var_dict[f"Electric Potential @ Permeate, {io}"] = ( + self.electric_potential[time_point, x, "permeate"] + ) if hasattr(self, "electric_potential_grad_feed_interface"): var_dict[ f"Electric Potential Gradient @ Feed-Membrane Interface, {io}" diff --git a/watertap/unit_models/nanofiltration_ZO.py b/watertap/unit_models/nanofiltration_ZO.py index 616bddd7ca..bbba83ef02 100644 --- a/watertap/unit_models/nanofiltration_ZO.py +++ b/watertap/unit_models/nanofiltration_ZO.py @@ -612,9 +612,9 @@ def _get_performance_contents(self, time_point=0): obj_dict[f"{j} Molar Concentration @Inlet"] = self.feed_side.properties_in[ time_point ].conc_mol_phase_comp["Liq", j] - obj_dict[ - f"{j} Molar Concentration @Outlet" - ] = self.feed_side.properties_out[time_point].conc_mol_phase_comp["Liq", j] + obj_dict[f"{j} Molar Concentration @Outlet"] = ( + self.feed_side.properties_out[time_point].conc_mol_phase_comp["Liq", j] + ) obj_dict[f"{j} Molar Concentration @Permeate"] = self.properties_permeate[ time_point ].conc_mol_phase_comp["Liq", j] diff --git a/watertap/unit_models/osmotically_assisted_reverse_osmosis_base.py b/watertap/unit_models/osmotically_assisted_reverse_osmosis_base.py index 9e8648327d..881d137ff2 100644 --- a/watertap/unit_models/osmotically_assisted_reverse_osmosis_base.py +++ b/watertap/unit_models/osmotically_assisted_reverse_osmosis_base.py @@ -246,9 +246,9 @@ def eq_recovery_vol_phase(b, t): self.config.property_package.phase_list, self.config.property_package.component_list, initialize=lambda b, t, p, j: 0.4037 if j in solvent_set else 0.0033, - bounds=lambda b, t, p, j: (0, 1 - 1e-6) - if j in solvent_set - else (1e-5, 1 - 1e-6), + bounds=lambda b, t, p, j: ( + (0, 1 - 1e-6) if j in solvent_set else (1e-5, 1 - 1e-6) + ), units=pyunits.dimensionless, doc="Mass-based component recovery", ) @@ -732,88 +732,88 @@ def _get_performance_contents(self, time_point=0): feed_interface_inlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Feed Concentration @Inlet,Membrane-Interface " - ] = feed_interface_inlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Feed Concentration @Inlet,Membrane-Interface "] = ( + feed_interface_inlet.conc_mass_phase_comp["Liq", j] + ) if ( feed_interface_outlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Feed Concentration @Outlet,Membrane-Interface " - ] = feed_interface_outlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Feed Concentration @Outlet,Membrane-Interface "] = ( + feed_interface_outlet.conc_mass_phase_comp["Liq", j] + ) if ( feed_inlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Feed Concentration @Inlet,Bulk" - ] = feed_inlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Feed Concentration @Inlet,Bulk"] = ( + feed_inlet.conc_mass_phase_comp["Liq", j] + ) if ( feed_outlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Feed Concentration @Outlet,Bulk" - ] = feed_outlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Feed Concentration @Outlet,Bulk"] = ( + feed_outlet.conc_mass_phase_comp["Liq", j] + ) if ( permeate_interface_inlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Permeate Concentration @Inlet,Membrane-Interface " - ] = permeate_interface_inlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Permeate Concentration @Inlet,Membrane-Interface "] = ( + permeate_interface_inlet.conc_mass_phase_comp["Liq", j] + ) if ( permeate_interface_outlet.is_property_constructed( "conc_mass_phase_comp" ) and self.config.has_full_reporting ): - var_dict[ - f"{j} Permeate Concentration @Outlet,Membrane-Interface " - ] = permeate_interface_outlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Permeate Concentration @Outlet,Membrane-Interface "] = ( + permeate_interface_outlet.conc_mass_phase_comp["Liq", j] + ) if ( permeate_inlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Permeate Concentration @Inlet,Bulk" - ] = permeate_inlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Permeate Concentration @Inlet,Bulk"] = ( + permeate_inlet.conc_mass_phase_comp["Liq", j] + ) if ( permeate_outlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Permeate Concentration @Outlet,Bulk" - ] = permeate_outlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Permeate Concentration @Outlet,Bulk"] = ( + permeate_outlet.conc_mass_phase_comp["Liq", j] + ) if ( feed_interface_outlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting ): - var_dict[ - "Feed Osmotic Pressure @Outlet,Membrane-Interface " - ] = feed_interface_outlet.pressure_osm_phase["Liq"] + var_dict["Feed Osmotic Pressure @Outlet,Membrane-Interface "] = ( + feed_interface_outlet.pressure_osm_phase["Liq"] + ) if ( permeate_outlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting ): - var_dict[ - "Feed Osmotic Pressure @Outlet,Bulk" - ] = feed_outlet.pressure_osm_phase["Liq"] + var_dict["Feed Osmotic Pressure @Outlet,Bulk"] = ( + feed_outlet.pressure_osm_phase["Liq"] + ) if ( feed_interface_inlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting ): - var_dict[ - "Feed Osmotic Pressure @Inlet,Membrane-Interface" - ] = feed_interface_inlet.pressure_osm_phase["Liq"] + var_dict["Feed Osmotic Pressure @Inlet,Membrane-Interface"] = ( + feed_interface_inlet.pressure_osm_phase["Liq"] + ) if ( feed_inlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting ): - var_dict[ - "Feed Osmotic Pressure @Inlet,Bulk" - ] = feed_inlet.pressure_osm_phase["Liq"] + var_dict["Feed Osmotic Pressure @Inlet,Bulk"] = ( + feed_inlet.pressure_osm_phase["Liq"] + ) # TODO: add all corresponding values for permeate side for relevant # vars/expressions from osmotic pressure and whatever is below if ( @@ -838,9 +838,9 @@ def _get_performance_contents(self, time_point=0): self.flux_mass_phase_comp_avg[time_point, "Liq", "H2O"] * 3.6e3 ) if hasattr(self.feed_side, "N_Re_avg"): - expr_dict[ - "Average Feed-side Reynolds Number" - ] = self.feed_side.N_Re_avg[time_point] + expr_dict["Average Feed-side Reynolds Number"] = ( + self.feed_side.N_Re_avg[time_point] + ) for j in self.config.property_package.solute_set: expr_dict[f"{j} Average Solute Flux (GMH)"] = ( self.flux_mass_phase_comp_avg[time_point, "Liq", j] * 3.6e6 diff --git a/watertap/unit_models/pressure_exchanger.py b/watertap/unit_models/pressure_exchanger.py index 4c2795fe07..21bf908854 100644 --- a/watertap/unit_models/pressure_exchanger.py +++ b/watertap/unit_models/pressure_exchanger.py @@ -463,9 +463,9 @@ def propogate_state(sb1, sb2): self.high_pressure_side.properties_in[0], self.high_pressure_side.properties_out[0], ) - self.high_pressure_side.properties_out[ - 0 - ].pressure.value = self.low_pressure_side.properties_in[0].pressure.value + self.high_pressure_side.properties_out[0].pressure.value = ( + self.low_pressure_side.properties_in[0].pressure.value + ) init_log.info_high("Initialize outlets complete") # Solve unit diff --git a/watertap/unit_models/reverse_osmosis_base.py b/watertap/unit_models/reverse_osmosis_base.py index 431dc33a5b..cec49d3226 100644 --- a/watertap/unit_models/reverse_osmosis_base.py +++ b/watertap/unit_models/reverse_osmosis_base.py @@ -204,9 +204,9 @@ def eq_recovery_vol_phase(b, t): self.config.property_package.phase_list, self.config.property_package.component_list, initialize=lambda b, t, p, j: 0.4037 if j in solvent_set else 0.0033, - bounds=lambda b, t, p, j: (1e-2, 1 - 1e-6) - if j in solvent_set - else (1e-5, 1 - 1e-6), + bounds=lambda b, t, p, j: ( + (1e-2, 1 - 1e-6) if j in solvent_set else (1e-5, 1 - 1e-6) + ), units=pyunits.dimensionless, doc="Mass-based component recovery", ) @@ -349,9 +349,9 @@ def _add_flux_balance(self): self.config.property_package.phase_list, self.config.property_package.component_list, initialize=lambda b, t, x, p, j: 5e-4 if j in solvent_set else 1e-6, - bounds=lambda b, t, x, p, j: (1e-4, 3e-2) - if j in solvent_set - else (1e-8, 1e-3), + bounds=lambda b, t, x, p, j: ( + (1e-4, 3e-2) if j in solvent_set else (1e-8, 1e-3) + ), units=units_meta("mass") * units_meta("length") ** -2 * units_meta("time") ** -1, @@ -684,30 +684,30 @@ def _get_performance_contents(self, time_point=0): interface_inlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Concentration @Inlet,Membrane-Interface " - ] = interface_inlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Concentration @Inlet,Membrane-Interface "] = ( + interface_inlet.conc_mass_phase_comp["Liq", j] + ) if ( interface_outlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Concentration @Outlet,Membrane-Interface " - ] = interface_outlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Concentration @Outlet,Membrane-Interface "] = ( + interface_outlet.conc_mass_phase_comp["Liq", j] + ) if ( feed_inlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Concentration @Inlet,Bulk" - ] = feed_inlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Concentration @Inlet,Bulk"] = ( + feed_inlet.conc_mass_phase_comp["Liq", j] + ) if ( feed_outlet.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting ): - var_dict[ - f"{j} Concentration @Outlet,Bulk" - ] = feed_outlet.conc_mass_phase_comp["Liq", j] + var_dict[f"{j} Concentration @Outlet,Bulk"] = ( + feed_outlet.conc_mass_phase_comp["Liq", j] + ) if ( permeate.is_property_constructed("conc_mass_phase_comp") and self.config.has_full_reporting @@ -719,9 +719,9 @@ def _get_performance_contents(self, time_point=0): interface_outlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting ): - var_dict[ - "Osmotic Pressure @Outlet,Membrane-Interface " - ] = interface_outlet.pressure_osm_phase["Liq"] + var_dict["Osmotic Pressure @Outlet,Membrane-Interface "] = ( + interface_outlet.pressure_osm_phase["Liq"] + ) if ( feed_outlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting @@ -733,9 +733,9 @@ def _get_performance_contents(self, time_point=0): interface_inlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting ): - var_dict[ - "Osmotic Pressure @Inlet,Membrane-Interface" - ] = interface_inlet.pressure_osm_phase["Liq"] + var_dict["Osmotic Pressure @Inlet,Membrane-Interface"] = ( + interface_inlet.pressure_osm_phase["Liq"] + ) if ( feed_inlet.is_property_constructed("pressure_osm_phase") and self.config.has_full_reporting diff --git a/watertap/unit_models/tests/test_anaerobic_digester.py b/watertap/unit_models/tests/test_anaerobic_digester.py index 4edf2fad58..04d51f505b 100644 --- a/watertap/unit_models/tests/test_anaerobic_digester.py +++ b/watertap/unit_models/tests/test_anaerobic_digester.py @@ -121,85 +121,85 @@ def configure(self): self.unit_solutions[m.fs.unit.liquid_outlet.pressure[0]] = 101325 self.unit_solutions[m.fs.unit.liquid_outlet.temperature[0]] = 308.15 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_I"] - ] = 0.3287724 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_aa"] - ] = 0.00531408 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_ac"] - ] = 0.1977833 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_bu"] - ] = 0.0132484 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_ch4"] - ] = 0.0549707 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_fa"] - ] = 0.0986058 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_h2"] - ] = 2.35916e-07 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_pro"] - ] = 0.0157813 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_su"] - ] = 0.01195333 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_va"] - ] = 0.011622969 + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_I"]] = ( + 0.3287724 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_aa"]] = ( + 0.00531408 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_ac"]] = ( + 0.1977833 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_bu"]] = ( + 0.0132484 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_ch4"]] = ( + 0.0549707 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_fa"]] = ( + 0.0986058 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_h2"]] = ( + 2.35916e-07 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_pro"]] = ( + 0.0157813 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_su"]] = ( + 0.01195333 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_va"]] = ( + 0.011622969 + ) self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_I"]] = 25.6217 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_aa"] - ] = 1.1793147 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_ac"] - ] = 0.760653 + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_aa"]] = ( + 1.1793147 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_ac"]] = ( + 0.760653 + ) self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_c"]] = 0.308718 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_c4"] - ] = 0.431974 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_ch"] - ] = 0.027947465 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_fa"] - ] = 0.2430681 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_h2"] - ] = 0.3170629 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_li"] - ] = 0.0294834 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_pr"] - ] = 0.102574392 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_pro"] - ] = 0.137323 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_su"] - ] = 0.420219 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_IC"] - ] = 1.8320212 - self.unit_solutions[ - m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_IN"] - ] = 1.8235307 + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_c4"]] = ( + 0.431974 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_ch"]] = ( + 0.027947465 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_fa"]] = ( + 0.2430681 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_h2"]] = ( + 0.3170629 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_li"]] = ( + 0.0294834 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_pr"]] = ( + 0.102574392 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_pro"]] = ( + 0.137323 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "X_su"]] = ( + 0.420219 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_IC"]] = ( + 1.8320212 + ) + self.unit_solutions[m.fs.unit.liquid_outlet.conc_mass_comp[0, "S_IN"]] = ( + 1.8235307 + ) self.unit_solutions[m.fs.unit.liquid_outlet.anions[0]] = 0.0200033 self.unit_solutions[m.fs.unit.liquid_outlet.cations[0]] = 0.0400066 self.unit_solutions[m.fs.unit.vapor_outlet.pressure[0]] = 106659.5225 self.unit_solutions[m.fs.unit.vapor_outlet.temperature[0]] = 308.15 self.unit_solutions[m.fs.unit.vapor_outlet.flow_vol[0]] = 0.03249637 - self.unit_solutions[ - m.fs.unit.vapor_outlet.conc_mass_comp[0, "S_ch4"] - ] = 1.6216465 - self.unit_solutions[ - m.fs.unit.vapor_outlet.conc_mass_comp[0, "S_co2"] - ] = 0.169417 + self.unit_solutions[m.fs.unit.vapor_outlet.conc_mass_comp[0, "S_ch4"]] = ( + 1.6216465 + ) + self.unit_solutions[m.fs.unit.vapor_outlet.conc_mass_comp[0, "S_co2"]] = ( + 0.169417 + ) self.unit_solutions[m.fs.unit.KH_co2[0]] = 0.02714666 self.unit_solutions[m.fs.unit.KH_ch4[0]] = 0.001161902 self.unit_solutions[m.fs.unit.KH_h2[0]] = 0.0007384652 diff --git a/watertap/unit_models/tests/test_boron_removal.py b/watertap/unit_models/tests/test_boron_removal.py index 7b2e9afa9b..e722c30e0d 100644 --- a/watertap/unit_models/tests/test_boron_removal.py +++ b/watertap/unit_models/tests/test_boron_removal.py @@ -71,6 +71,7 @@ solver = get_solver() + # Helper function for multiple test setup def model_setup( m, @@ -1300,7 +1301,7 @@ def boron_removal_bad_configs_gen(self): ("Liq", "H_+"): 1, ("Liq", "OH_-"): 1, }, - } + }, # End parameter_data } # End R1 diff --git a/watertap/unit_models/tests/test_coag_floc_model.py b/watertap/unit_models/tests/test_coag_floc_model.py index 38c4ce6692..c8081ded72 100644 --- a/watertap/unit_models/tests/test_coag_floc_model.py +++ b/watertap/unit_models/tests/test_coag_floc_model.py @@ -36,6 +36,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- # Start test class class TestCoagulation_withChemicals: diff --git a/watertap/unit_models/tests/test_crystallizer.py b/watertap/unit_models/tests/test_crystallizer.py index 0a1b6d51c9..f8b52f7aa6 100644 --- a/watertap/unit_models/tests/test_crystallizer.py +++ b/watertap/unit_models/tests/test_crystallizer.py @@ -176,15 +176,15 @@ def configure(self): m.fs.costing.cost_process() iscale.set_scaling_factor(m.fs.unit.costing.capital_cost, 1e-5) - self.unit_solutions[ - m.fs.unit.solids.flow_mass_phase_comp[0, "Sol", "NaCl"] - ] = 0.08504096 - self.unit_solutions[ - m.fs.unit.outlet.flow_mass_phase_comp[0, "Liq", "NaCl"] - ] = 0.12756 - self.unit_solutions[ - m.fs.unit.outlet.flow_mass_phase_comp[0, "Liq", "H2O"] - ] = 0.34570767 + self.unit_solutions[m.fs.unit.solids.flow_mass_phase_comp[0, "Sol", "NaCl"]] = ( + 0.08504096 + ) + self.unit_solutions[m.fs.unit.outlet.flow_mass_phase_comp[0, "Liq", "NaCl"]] = ( + 0.12756 + ) + self.unit_solutions[m.fs.unit.outlet.flow_mass_phase_comp[0, "Liq", "H2O"]] = ( + 0.34570767 + ) self.unit_solutions[ m.fs.unit.properties_out[0].mass_frac_phase_comp["Liq", "NaCl"] ] = 0.26953035 diff --git a/watertap/unit_models/tests/test_dewatering_unit.py b/watertap/unit_models/tests/test_dewatering_unit.py index e80bfc25eb..b15cd7078c 100644 --- a/watertap/unit_models/tests/test_dewatering_unit.py +++ b/watertap/unit_models/tests/test_dewatering_unit.py @@ -76,6 +76,7 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): diff --git a/watertap/unit_models/tests/test_electrodialysis_0D.py b/watertap/unit_models/tests/test_electrodialysis_0D.py index 4caef6da34..9680b33faf 100644 --- a/watertap/unit_models/tests/test_electrodialysis_0D.py +++ b/watertap/unit_models/tests/test_electrodialysis_0D.py @@ -49,6 +49,7 @@ solver = get_solver() + # ----------------------------------------------------------------------------- # Start test class class TestElectrodialysisVoltageConst: diff --git a/watertap/unit_models/tests/test_nanofiltration_ZO.py b/watertap/unit_models/tests/test_nanofiltration_ZO.py index d11fb780ac..df2a74f684 100644 --- a/watertap/unit_models/tests/test_nanofiltration_ZO.py +++ b/watertap/unit_models/tests/test_nanofiltration_ZO.py @@ -49,12 +49,15 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = props.MCASParameterBlock(solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"]) + m.fs.properties = props.MCASParameterBlock( + solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"] + ) m.fs.unit = NanofiltrationZO(property_package=m.fs.properties) assert len(m.fs.unit.config) == 9 @@ -72,7 +75,9 @@ def test_config(): def test_option_has_pressure_change(): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = props.MCASParameterBlock(solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"]) + m.fs.properties = props.MCASParameterBlock( + solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"] + ) m.fs.unit = NanofiltrationZO( property_package=m.fs.properties, has_pressure_change=True ) @@ -87,8 +92,10 @@ def unit_frame(self): m = ConcreteModel() m.fs = FlowsheetBlock(dynamic=False) - m.fs.properties = props.MCASParameterBlock(solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"], - material_flow_basis=props.MaterialFlowBasis.mass) + m.fs.properties = props.MCASParameterBlock( + solute_list=["Na_+", "Ca_2+", "Mg_2+", "SO4_2-", "Cl_-"], + material_flow_basis=props.MaterialFlowBasis.mass, + ) m.fs.unit = NanofiltrationZO(property_package=m.fs.properties) @@ -119,9 +126,11 @@ def unit_frame(self): m.fs.unit.rejection_phase_comp[0, "Liq", "Ca_2+"].fix(0.79) m.fs.unit.rejection_phase_comp[0, "Liq", "Mg_2+"].fix(0.94) m.fs.unit.rejection_phase_comp[0, "Liq", "SO4_2-"].fix(0.87) - m.fs.unit.rejection_phase_comp[0, "Liq", "Cl_-"].fix(0.15) - - m.fs.unit.feed_side.properties_in[0].assert_electroneutrality(defined_state=True, adjust_by_ion='Cl_-') + m.fs.unit.rejection_phase_comp[0, "Liq", "Cl_-"].fix(0.15) + + m.fs.unit.feed_side.properties_in[0].assert_electroneutrality( + defined_state=True, adjust_by_ion="Cl_-" + ) return m diff --git a/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_0D.py b/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_0D.py index 72add308f9..ff6f074b49 100644 --- a/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_0D.py +++ b/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_0D.py @@ -60,6 +60,7 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): diff --git a/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_1D.py b/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_1D.py index 7379731dd9..8f9d239ced 100644 --- a/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_1D.py +++ b/watertap/unit_models/tests/test_osmotically_assisted_reverse_osmosis_1D.py @@ -59,6 +59,7 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): diff --git a/watertap/unit_models/tests/test_reverse_osmosis_0D.py b/watertap/unit_models/tests/test_reverse_osmosis_0D.py index 5a25d5c144..92861260be 100644 --- a/watertap/unit_models/tests/test_reverse_osmosis_0D.py +++ b/watertap/unit_models/tests/test_reverse_osmosis_0D.py @@ -94,12 +94,12 @@ class TestReverseOsmosis0D(UnitTestHarness): def configure(self): m = build() - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.004721771 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 1.5757670e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.004721771 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 1.5757670e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.23608853 @@ -170,12 +170,12 @@ class TestReverseOsmosis0D_SKK(UnitTestHarness): def configure(self): m = build_SKK() - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.006710409 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 3.1094137e-5 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.006710409 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 3.1094137e-5 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.33552046 @@ -245,12 +245,12 @@ class TestReverseOsmosis0D_kf_fixed(UnitTestHarness): def configure(self): m = build_kf_fixed() - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.0038152554 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 1.6673684e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.0038152554 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 1.6673684e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.19076277 @@ -332,12 +332,12 @@ class TestReverseOsmosis0D_kf_calculated(UnitTestHarness): def configure(self): m = build_kf_calculated() - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.00456244 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 1.5926761e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.00456244 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 1.5926761e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.22812202 @@ -424,12 +424,12 @@ def configure(self): self.unit_solutions[m.fs.unit.feed_side.velocity[0, 0]] = 0.2360863 self.unit_solutions[m.fs.unit.feed_side.N_Re[0, 1]] = 191.1195577 self.unit_solutions[m.fs.unit.feed_side.velocity[0, 1]] = 0.1187048845 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.007089 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 2.1880044e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.007089 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 2.1880044e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.134691 @@ -512,12 +512,12 @@ class TestReverseOsmosis0D_p_drop_fixed_per_unit_length(UnitTestHarness): def configure(self): m = build_p_drop_calculation_fixed_per_unit_length() - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.0045624403 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 1.5926761e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.0045624403 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 1.5926761e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.22812202 @@ -603,12 +603,12 @@ def configure(self): self.unit_solutions[m.fs.unit.feed_side.velocity[0, 0]] = 0.2360863 self.unit_solutions[m.fs.unit.feed_side.N_Re[0, 1]] = 191.3192807 self.unit_solutions[m.fs.unit.feed_side.velocity[0, 1]] = 0.1188201 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.00708203 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 2.18590835e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.00708203 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 2.18590835e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.13455865 diff --git a/watertap/unit_models/tests/test_reverse_osmosis_1D.py b/watertap/unit_models/tests/test_reverse_osmosis_1D.py index c3f429a1b4..44faf1ec90 100644 --- a/watertap/unit_models/tests/test_reverse_osmosis_1D.py +++ b/watertap/unit_models/tests/test_reverse_osmosis_1D.py @@ -109,18 +109,18 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 2.113811e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.00248645 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 2.593074e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.005036466 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 2.372961e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.00248645 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 2.593074e-6 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.005036466 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 2.372961e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.1341274 @@ -199,12 +199,12 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 1.628559e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.001019483 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 1.99996e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.001019483 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 1.99996e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.3895746 @@ -289,18 +289,18 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 7.4932174e-5 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.006690554 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 5.422075e-5 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"] - ] = 0.0094392 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"] - ] = 6.5286415e-5 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.006690554 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 5.422075e-5 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "H2O"]] = ( + 0.0094392 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp_avg[0, "Liq", "NaCl"]] = ( + 6.5286415e-5 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.1341274 @@ -380,12 +380,12 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 1.863938e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.000359974 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 2.051563e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.000359974 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 2.051563e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.3894809 @@ -464,12 +464,12 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 1.83061e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.0007081512 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 2.027294e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.0007081512 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 2.027294e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.3895265 @@ -547,12 +547,12 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 1.8703962e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.000626977 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 2.0339201e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.000626977 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 2.0339201e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.3895066 @@ -632,12 +632,12 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 1.494063e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.00474506 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 1.559319e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.00474506 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 1.559319e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.1010762 @@ -719,12 +719,12 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 1.872372e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.000551092 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 2.0075516e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.000551092 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 2.0075516e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.3894964 @@ -807,12 +807,12 @@ def configure(self): self.unit_solutions[ m.fs.unit.flux_mass_phase_comp[0, x_interface_in, "Liq", "NaCl"] ] = 1.871967e-6 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"] - ] = 0.000566998 - self.unit_solutions[ - m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"] - ] = 2.0134278e-6 + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "H2O"]] = ( + 0.000566998 + ) + self.unit_solutions[m.fs.unit.flux_mass_phase_comp[0, 1, "Liq", "NaCl"]] = ( + 2.0134278e-6 + ) self.unit_solutions[ m.fs.unit.mixed_permeate[0].flow_mass_phase_comp["Liq", "H2O"] ] = 0.3894987 diff --git a/watertap/unit_models/thickener.py b/watertap/unit_models/thickener.py index be53f470cb..6d3f818f37 100644 --- a/watertap/unit_models/thickener.py +++ b/watertap/unit_models/thickener.py @@ -252,9 +252,9 @@ def _get_performance_contents(self, time_point=0): if k[0] == time_point: var_dict[f"Split Fraction [{str(k[1:])}]"] = self.split_fraction[k] var_dict["Electricity consumption"] = self.electricity_consumption[time_point] - param_dict[ - "Specific electricity consumption" - ] = self.energy_electric_flow_vol_inlet[time_point] + param_dict["Specific electricity consumption"] = ( + self.energy_electric_flow_vol_inlet[time_point] + ) var_dict["Unit Volume"] = self.volume[time_point] var_dict["Hydraulic Retention Time"] = self.hydraulic_retention_time[time_point] var_dict["Unit Height"] = self.height diff --git a/watertap/unit_models/translators/tests/test_translator_adm1_asm1.py b/watertap/unit_models/translators/tests/test_translator_adm1_asm1.py index 837a19ab59..b4689f04ee 100644 --- a/watertap/unit_models/translators/tests/test_translator_adm1_asm1.py +++ b/watertap/unit_models/translators/tests/test_translator_adm1_asm1.py @@ -60,6 +60,7 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): diff --git a/watertap/unit_models/translators/tests/test_translator_adm1_asm2d.py b/watertap/unit_models/translators/tests/test_translator_adm1_asm2d.py index 675fd04610..bd7fc769dc 100644 --- a/watertap/unit_models/translators/tests/test_translator_adm1_asm2d.py +++ b/watertap/unit_models/translators/tests/test_translator_adm1_asm2d.py @@ -64,6 +64,7 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): diff --git a/watertap/unit_models/translators/tests/test_translator_adm1_simple_asm2d.py b/watertap/unit_models/translators/tests/test_translator_adm1_simple_asm2d.py index 56370112f7..53363749dc 100644 --- a/watertap/unit_models/translators/tests/test_translator_adm1_simple_asm2d.py +++ b/watertap/unit_models/translators/tests/test_translator_adm1_simple_asm2d.py @@ -65,6 +65,7 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): diff --git a/watertap/unit_models/translators/tests/test_translator_asm2d_adm1.py b/watertap/unit_models/translators/tests/test_translator_asm2d_adm1.py index dc0f8e50a5..cac700dafe 100644 --- a/watertap/unit_models/translators/tests/test_translator_asm2d_adm1.py +++ b/watertap/unit_models/translators/tests/test_translator_asm2d_adm1.py @@ -66,6 +66,7 @@ # Get default solver for testing solver = get_solver() + # ----------------------------------------------------------------------------- @pytest.mark.unit def test_config(): @@ -139,16 +140,10 @@ def asmadm(self): m.fs.unit.inlet.conc_mass_comp[0, "S_F"].fix(0.02644 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_A"].fix(0.01766 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_I"].fix(0.02723 * units.kg / units.m**3) - m.fs.unit.inlet.conc_mass_comp[0, "S_NH4"].fix( - 0.01858 * units.kg / units.m**3 - ) + m.fs.unit.inlet.conc_mass_comp[0, "S_NH4"].fix(0.01858 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_N2"].fix(0.00507 * units.kg / units.m**3) - m.fs.unit.inlet.conc_mass_comp[0, "S_NO3"].fix( - 0.00002 * units.kg / units.m**3 - ) - m.fs.unit.inlet.conc_mass_comp[0, "S_PO4"].fix( - 0.00469 * units.kg / units.m**3 - ) + m.fs.unit.inlet.conc_mass_comp[0, "S_NO3"].fix(0.00002 * units.kg / units.m**3) + m.fs.unit.inlet.conc_mass_comp[0, "S_PO4"].fix(0.00469 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_IC"].fix(0.07899 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "X_I"].fix(10.96441 * units.kg / units.m**3) @@ -156,12 +151,8 @@ def asmadm(self): m.fs.unit.inlet.conc_mass_comp[0, "X_H"].fix(9.47939 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "X_PAO"].fix(3.8622 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "X_PP"].fix(0.45087 * units.kg / units.m**3) - m.fs.unit.inlet.conc_mass_comp[0, "X_PHA"].fix( - 0.02464 * units.kg / units.m**3 - ) - m.fs.unit.inlet.conc_mass_comp[0, "X_AUT"].fix( - 0.33379 * units.kg / units.m**3 - ) + m.fs.unit.inlet.conc_mass_comp[0, "X_PHA"].fix(0.02464 * units.kg / units.m**3) + m.fs.unit.inlet.conc_mass_comp[0, "X_AUT"].fix(0.33379 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_K"].fix(0.01979 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_Mg"].fix(0.18987 * units.kg / units.m**3) @@ -426,16 +417,10 @@ def asmadm(self): m.fs.unit.inlet.conc_mass_comp[0, "S_F"].fix(0.02644 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_A"].fix(0.01766 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_I"].fix(0.02723 * units.kg / units.m**3) - m.fs.unit.inlet.conc_mass_comp[0, "S_NH4"].fix( - 0.01858 * units.kg / units.m**3 - ) + m.fs.unit.inlet.conc_mass_comp[0, "S_NH4"].fix(0.01858 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_N2"].fix(0.00507 * units.kg / units.m**3) - m.fs.unit.inlet.conc_mass_comp[0, "S_NO3"].fix( - 0.00002 * units.kg / units.m**3 - ) - m.fs.unit.inlet.conc_mass_comp[0, "S_PO4"].fix( - 0.00469 * units.kg / units.m**3 - ) + m.fs.unit.inlet.conc_mass_comp[0, "S_NO3"].fix(0.00002 * units.kg / units.m**3) + m.fs.unit.inlet.conc_mass_comp[0, "S_PO4"].fix(0.00469 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_IC"].fix(0.07899 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "X_I"].fix(10.96441 * units.kg / units.m**3) @@ -443,12 +428,8 @@ def asmadm(self): m.fs.unit.inlet.conc_mass_comp[0, "X_H"].fix(9.47939 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "X_PAO"].fix(3.8622 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "X_PP"].fix(0.45087 * units.kg / units.m**3) - m.fs.unit.inlet.conc_mass_comp[0, "X_PHA"].fix( - 0.02464 * units.kg / units.m**3 - ) - m.fs.unit.inlet.conc_mass_comp[0, "X_AUT"].fix( - 0.33379 * units.kg / units.m**3 - ) + m.fs.unit.inlet.conc_mass_comp[0, "X_PHA"].fix(0.02464 * units.kg / units.m**3) + m.fs.unit.inlet.conc_mass_comp[0, "X_AUT"].fix(0.33379 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_K"].fix(0.01979 * units.kg / units.m**3) m.fs.unit.inlet.conc_mass_comp[0, "S_Mg"].fix(0.18987 * units.kg / units.m**3) diff --git a/watertap/unit_models/uv_aop.py b/watertap/unit_models/uv_aop.py index b542b2ee12..44996138da 100644 --- a/watertap/unit_models/uv_aop.py +++ b/watertap/unit_models/uv_aop.py @@ -50,6 +50,7 @@ _log = idaeslog.getLogger(__name__) + # --------------------------------------------------------------------- class UVDoseType(Enum): fixed = auto() # uv dose is a user specified value diff --git a/watertap/unit_models/zero_order/CANDOP_zo.py b/watertap/unit_models/zero_order/CANDOP_zo.py index 2bbf317cf9..60d099f706 100644 --- a/watertap/unit_models/zero_order/CANDOP_zo.py +++ b/watertap/unit_models/zero_order/CANDOP_zo.py @@ -89,9 +89,9 @@ def electricity_consumption(b, t): doc="Oxygen consumed - nitrogen reacted ratio", ) self._fixed_perf_vars.append(self.oxygen_nitrogen_ratio) - self._perf_var_dict[ - "Oxygen consumed / nitrogen reacted ratio (mass basis)" - ] = self.oxygen_nitrogen_ratio + self._perf_var_dict["Oxygen consumed / nitrogen reacted ratio (mass basis)"] = ( + self.oxygen_nitrogen_ratio + ) @self.Constraint( self.flowsheet().time, doc="Constraint for oxygen consumption." diff --git a/watertap/unit_models/zero_order/anaerobic_digestion_reactive_zo.py b/watertap/unit_models/zero_order/anaerobic_digestion_reactive_zo.py index f217226c9a..2d1fd0fdc7 100644 --- a/watertap/unit_models/zero_order/anaerobic_digestion_reactive_zo.py +++ b/watertap/unit_models/zero_order/anaerobic_digestion_reactive_zo.py @@ -51,9 +51,9 @@ def build(self): bounds=(0, None), doc="Ratio of m^3 biogas produced / kg TSS in influent", ) - self._perf_var_dict[ - "Ratio of m^3 biogas produced / kg TSS in influent" - ] = self.biogas_tss_ratio + self._perf_var_dict["Ratio of m^3 biogas produced / kg TSS in influent"] = ( + self.biogas_tss_ratio + ) self._fixed_perf_vars.append(self.biogas_tss_ratio) self.biogas_production = Var( diff --git a/watertap/unit_models/zero_order/brine_concentrator_zo.py b/watertap/unit_models/zero_order/brine_concentrator_zo.py index 2ad64a49d0..a5e675b9b7 100644 --- a/watertap/unit_models/zero_order/brine_concentrator_zo.py +++ b/watertap/unit_models/zero_order/brine_concentrator_zo.py @@ -115,9 +115,9 @@ def electricity_constraint(b, t): return b.electricity[t] == b.electricity_intensity[t] * q_in self._perf_var_dict["Power Consumption (kW)"] = self.electricity - self._perf_var_dict[ - "Electricity intensity per Inlet Flowrate (kWh/m3)" - ] = self.electricity_intensity + self._perf_var_dict["Electricity intensity per Inlet Flowrate (kWh/m3)"] = ( + self.electricity_intensity + ) @property def default_costing_method(self): diff --git a/watertap/unit_models/zero_order/chlorination_zo.py b/watertap/unit_models/zero_order/chlorination_zo.py index be761cf9f1..89e9945751 100644 --- a/watertap/unit_models/zero_order/chlorination_zo.py +++ b/watertap/unit_models/zero_order/chlorination_zo.py @@ -78,14 +78,14 @@ def chlorine_dose_constraint(b, t): ) self._perf_var_dict["Chlorine Dose (mg/L)"] = self.chlorine_dose - self._perf_var_dict[ - "Initial Chlorine Demand (mg/L)" - ] = self.initial_chlorine_demand + self._perf_var_dict["Initial Chlorine Demand (mg/L)"] = ( + self.initial_chlorine_demand + ) self._perf_var_dict["Contact Time (hr)"] = self.contact_time self._perf_var_dict["CT Value ((mg*min)/L)"] = self.concentration_time - self._perf_var_dict[ - "Chlorine Decay Rate (mg/(L*hr))" - ] = self.chlorine_decay_rate + self._perf_var_dict["Chlorine Decay Rate (mg/(L*hr))"] = ( + self.chlorine_decay_rate + ) @property def default_costing_method(self): diff --git a/watertap/unit_models/zero_order/coag_and_floc_zo.py b/watertap/unit_models/zero_order/coag_and_floc_zo.py index 07c4b84277..644a6fd3e9 100644 --- a/watertap/unit_models/zero_order/coag_and_floc_zo.py +++ b/watertap/unit_models/zero_order/coag_and_floc_zo.py @@ -94,9 +94,7 @@ def build(self): doc="Floc Retention Time", ) - self.rapid_mix_basin_vol = Var( - units=pyunits.m**3, doc="Rapid Mix Basin Volume" - ) + self.rapid_mix_basin_vol = Var(units=pyunits.m**3, doc="Rapid Mix Basin Volume") self.floc_basin_vol = Var(units=pyunits.m**3, doc="Floc Basin Volume") @@ -174,16 +172,16 @@ def build(self): ] self._perf_var_dict["Rapid Mix Basin Volume (m^3)"] = self.rapid_mix_basin_vol self._perf_var_dict["Floc Basin Volume (m^3)"] = self.floc_basin_vol - self._perf_var_dict[ - "Rapid Mix Retention Time (s)" - ] = self.rapid_mix_retention_time + self._perf_var_dict["Rapid Mix Retention Time (s)"] = ( + self.rapid_mix_retention_time + ) self._perf_var_dict["Floc Retention Time (min)"] = self.floc_retention_time - self._perf_var_dict[ - "Rapid Mix Velocity Gradient (1/s)" - ] = self.velocity_gradient_rapid_mix - self._perf_var_dict[ - "Floc Velocity Gradient (1/s)" - ] = self.velocity_gradient_floc + self._perf_var_dict["Rapid Mix Velocity Gradient (1/s)"] = ( + self.velocity_gradient_rapid_mix + ) + self._perf_var_dict["Floc Velocity Gradient (1/s)"] = ( + self.velocity_gradient_floc + ) self._perf_var_dict["Rapid Mix Power (kW)"] = self.power_rapid_mix self._perf_var_dict["Floc Power (kW)"] = self.power_floc self._perf_var_dict["Total Power Consumption (kW)"] = self.electricity diff --git a/watertap/unit_models/zero_order/electrochemical_nutrient_removal_zo.py b/watertap/unit_models/zero_order/electrochemical_nutrient_removal_zo.py index ba4395afdf..09ce1e4128 100644 --- a/watertap/unit_models/zero_order/electrochemical_nutrient_removal_zo.py +++ b/watertap/unit_models/zero_order/electrochemical_nutrient_removal_zo.py @@ -76,9 +76,9 @@ def electricity_consumption(b, t): self._fixed_perf_vars.append(self.magnesium_chloride_dosage) - self._perf_var_dict[ - "Dosage of magnesium chloride per phosphorus removal" - ] = self.magnesium_chloride_dosage + self._perf_var_dict["Dosage of magnesium chloride per phosphorus removal"] = ( + self.magnesium_chloride_dosage + ) self.MgCl2_flowrate = Var( self.flowsheet().time, diff --git a/watertap/unit_models/zero_order/electrocoagulation_zo.py b/watertap/unit_models/zero_order/electrocoagulation_zo.py index 3dc4a86232..2a09779b7a 100644 --- a/watertap/unit_models/zero_order/electrocoagulation_zo.py +++ b/watertap/unit_models/zero_order/electrocoagulation_zo.py @@ -471,10 +471,10 @@ def cost_electrocoagulation(blk): ) # Get parameter dict from database - blk.parameter_dict = ( - parameter_dict - ) = blk.unit_model.config.database.get_unit_operation_parameters( - blk.unit_model._tech_type, subtype=blk.unit_model.config.process_subtype + blk.parameter_dict = parameter_dict = ( + blk.unit_model.config.database.get_unit_operation_parameters( + blk.unit_model._tech_type, subtype=blk.unit_model.config.process_subtype + ) ) # Get costing parameter sub-block for this technology diff --git a/watertap/unit_models/zero_order/electrodialysis_reversal_zo.py b/watertap/unit_models/zero_order/electrodialysis_reversal_zo.py index a55d275a78..dcf0499aeb 100644 --- a/watertap/unit_models/zero_order/electrodialysis_reversal_zo.py +++ b/watertap/unit_models/zero_order/electrodialysis_reversal_zo.py @@ -90,6 +90,6 @@ def electricity_constraint(b, t): return b.electricity[t] == b.electricity_intensity[t] * q_in self._perf_var_dict["Power Consumption (kW)"] = self.electricity - self._perf_var_dict[ - "Electricity intensity per Inlet Flowrate (kWh/m3)" - ] = self.electricity_intensity + self._perf_var_dict["Electricity intensity per Inlet Flowrate (kWh/m3)"] = ( + self.electricity_intensity + ) diff --git a/watertap/unit_models/zero_order/gac_zo.py b/watertap/unit_models/zero_order/gac_zo.py index 047b297664..28e165c845 100644 --- a/watertap/unit_models/zero_order/gac_zo.py +++ b/watertap/unit_models/zero_order/gac_zo.py @@ -88,9 +88,9 @@ def electricity_consumption(b, t): self._fixed_perf_vars.append(self.electricity_intensity_parameter) self._perf_var_dict["Electricity Demand"] = self.electricity - self._perf_var_dict[ - "Electricity Intensity" - ] = self.energy_electric_flow_vol_inlet + self._perf_var_dict["Electricity Intensity"] = ( + self.energy_electric_flow_vol_inlet + ) # Demand for activated carbon self.activated_carbon_replacement = Var( diff --git a/watertap/unit_models/zero_order/gas_sparged_membrane_zo.py b/watertap/unit_models/zero_order/gas_sparged_membrane_zo.py index ff95208840..0622539880 100644 --- a/watertap/unit_models/zero_order/gas_sparged_membrane_zo.py +++ b/watertap/unit_models/zero_order/gas_sparged_membrane_zo.py @@ -133,9 +133,9 @@ def build(self): self._perf_var_dict[ "Mass of gas extracted per mass flow of influent(kg/d/(kg/d)" ] = self.gas_mass_influent_ratio - self._perf_var_dict[ - "Mass flow of gas extracted (kg/s))" - ] = self.flow_mass_gas_extraction + self._perf_var_dict["Mass flow of gas extracted (kg/s))"] = ( + self.flow_mass_gas_extraction + ) # Add performance constraints # Water recovery diff --git a/watertap/unit_models/zero_order/ion_exchange_zo.py b/watertap/unit_models/zero_order/ion_exchange_zo.py index 0ad8e0a78c..3dfbe31adc 100644 --- a/watertap/unit_models/zero_order/ion_exchange_zo.py +++ b/watertap/unit_models/zero_order/ion_exchange_zo.py @@ -121,12 +121,12 @@ def solids_mass_flow_constraint(b, t): / b.nitrogen_clay_ratio[t] ) - self._perf_var_dict[ - "Nitrogen-Clay Mixture Ratio (kg/kg)" - ] = self.nitrogen_clay_ratio - self._perf_var_dict[ - "Final mass flow of clay and nitrogen (kg/s)" - ] = self.final_solids_mass + self._perf_var_dict["Nitrogen-Clay Mixture Ratio (kg/kg)"] = ( + self.nitrogen_clay_ratio + ) + self._perf_var_dict["Final mass flow of clay and nitrogen (kg/s)"] = ( + self.final_solids_mass + ) else: raise KeyError( "ammonium_as_nitrogen should be defined in solute_list for this subtype." diff --git a/watertap/unit_models/zero_order/iron_and_manganese_removal_zo.py b/watertap/unit_models/zero_order/iron_and_manganese_removal_zo.py index fb11b78309..95939af37d 100644 --- a/watertap/unit_models/zero_order/iron_and_manganese_removal_zo.py +++ b/watertap/unit_models/zero_order/iron_and_manganese_removal_zo.py @@ -111,9 +111,9 @@ def electricity_constraint(b, t): return b.electricity[t] == b.electricity_intensity[t] * q_in self._perf_var_dict["Power Consumption (kW)"] = self.electricity - self._perf_var_dict[ - "Electricity intensity per Inlet Flowrate (kWh/m3)" - ] = self.electricity_intensity + self._perf_var_dict["Electricity intensity per Inlet Flowrate (kWh/m3)"] = ( + self.electricity_intensity + ) @property def default_costing_method(self): diff --git a/watertap/unit_models/zero_order/mabr_zo.py b/watertap/unit_models/zero_order/mabr_zo.py index 88dc46b1eb..b36f8930e4 100644 --- a/watertap/unit_models/zero_order/mabr_zo.py +++ b/watertap/unit_models/zero_order/mabr_zo.py @@ -119,9 +119,9 @@ def electricity_consumption(b, t): ) self._fixed_perf_vars.append(self.energy_electric_flow_vol_inlet) - self._perf_var_dict[ - "Electricity Intensity" - ] = self.energy_electric_flow_vol_inlet + self._perf_var_dict["Electricity Intensity"] = ( + self.energy_electric_flow_vol_inlet + ) @property def default_costing_method(self): diff --git a/watertap/unit_models/zero_order/magprex_zo.py b/watertap/unit_models/zero_order/magprex_zo.py index 4627365d0f..62f7c9e3c1 100644 --- a/watertap/unit_models/zero_order/magprex_zo.py +++ b/watertap/unit_models/zero_order/magprex_zo.py @@ -47,9 +47,9 @@ def build(self): self._fixed_perf_vars.append(self.magnesium_chloride_dosage) - self._perf_var_dict[ - "Dosage of magnesium chloride per phosphates" - ] = self.magnesium_chloride_dosage + self._perf_var_dict["Dosage of magnesium chloride per phosphates"] = ( + self.magnesium_chloride_dosage + ) self.MgCl2_flowrate = Var( self.flowsheet().time, diff --git a/watertap/unit_models/zero_order/mbr_zo.py b/watertap/unit_models/zero_order/mbr_zo.py index 55af7ec0a2..5089f734fa 100644 --- a/watertap/unit_models/zero_order/mbr_zo.py +++ b/watertap/unit_models/zero_order/mbr_zo.py @@ -89,6 +89,6 @@ def electricity_constraint(b, t): return b.electricity[t] == b.electricity_intensity[t] * q_in self._perf_var_dict["Power Consumption (kW)"] = self.electricity - self._perf_var_dict[ - "Electricity intensity per Inlet Flowrate (kWh/m3)" - ] = self.electricity_intensity + self._perf_var_dict["Electricity intensity per Inlet Flowrate (kWh/m3)"] = ( + self.electricity_intensity + ) diff --git a/watertap/unit_models/zero_order/nanofiltration_zo.py b/watertap/unit_models/zero_order/nanofiltration_zo.py index 44670d366c..79180047a6 100644 --- a/watertap/unit_models/zero_order/nanofiltration_zo.py +++ b/watertap/unit_models/zero_order/nanofiltration_zo.py @@ -92,9 +92,9 @@ def rejection_constraint(b, t, j): self._perf_var_dict["Membrane Area (m^2)"] = self.area self._perf_var_dict["Net Driving Pressure (bar)"] = self.applied_pressure - self._perf_var_dict[ - "Water Permeability Coefficient (LMH/bar)" - ] = self.water_permeability_coefficient + self._perf_var_dict["Water Permeability Coefficient (LMH/bar)"] = ( + self.water_permeability_coefficient + ) self._perf_var_dict[f"Rejection"] = self.rejection_comp @property @@ -164,8 +164,7 @@ def cost_membrane(blk): ) capex_expr = pyo.units.convert( - mem_cost - * pyo.units.convert(blk.unit_model.area, to_units=pyo.units.m**2), + mem_cost * pyo.units.convert(blk.unit_model.area, to_units=pyo.units.m**2), to_units=blk.config.flowsheet_costing_block.base_currency, ) diff --git a/watertap/unit_models/zero_order/ozone_zo.py b/watertap/unit_models/zero_order/ozone_zo.py index a7bb376bf4..f5203d33a1 100644 --- a/watertap/unit_models/zero_order/ozone_zo.py +++ b/watertap/unit_models/zero_order/ozone_zo.py @@ -126,9 +126,9 @@ def electricity_constraint(b, t): self._perf_var_dict["Ozone Contact Time (min)"] = self.contact_time self._perf_var_dict["Ozone CT Value ((mg*min)/L)"] = self.concentration_time - self._perf_var_dict[ - "Ozone Mass Transfer Efficiency" - ] = self.mass_transfer_efficiency + self._perf_var_dict["Ozone Mass Transfer Efficiency"] = ( + self.mass_transfer_efficiency + ) self._perf_var_dict["Ozone Mass Flow (lb/hr)"] = self.ozone_flow_mass self._perf_var_dict["Ozone Unit Power Demand (kW)"] = self.electricity diff --git a/watertap/unit_models/zero_order/peracetic_acid_disinfection_zo.py b/watertap/unit_models/zero_order/peracetic_acid_disinfection_zo.py index 36287227c8..54f55a3459 100644 --- a/watertap/unit_models/zero_order/peracetic_acid_disinfection_zo.py +++ b/watertap/unit_models/zero_order/peracetic_acid_disinfection_zo.py @@ -65,9 +65,9 @@ def build(self): bounds=(0, 1), doc="Weight fraction of PAA in disinfection solution", ) - self._perf_var_dict[ - "Weight fraction PAA in disinfection solution" - ] = self.disinfection_solution_wt_frac_PAA + self._perf_var_dict["Weight fraction PAA in disinfection solution"] = ( + self.disinfection_solution_wt_frac_PAA + ) self._fixed_perf_vars.append(self.disinfection_solution_wt_frac_PAA) # Create variable for disinfection solution density @@ -76,9 +76,9 @@ def build(self): bounds=(0, None), doc="Disinfection solution density", ) - self._perf_var_dict[ - "disinfection solution density" - ] = self.disinfection_solution_density + self._perf_var_dict["disinfection solution density"] = ( + self.disinfection_solution_density + ) self._fixed_perf_vars.append(self.disinfection_solution_density) # Create variable for disinfection solution volumetric flowrate @@ -88,9 +88,9 @@ def build(self): bounds=(0, None), doc="Volumetric flowrate of disinfection solution", ) - self._perf_var_dict[ - "Disinfection solution volumetric flowrate" - ] = self.disinfection_solution_flow_vol + self._perf_var_dict["Disinfection solution volumetric flowrate"] = ( + self.disinfection_solution_flow_vol + ) # Create constraint to calculate disinfection solution flowrate @self.Constraint( diff --git a/watertap/unit_models/zero_order/sedimentation_zo.py b/watertap/unit_models/zero_order/sedimentation_zo.py index 88f22511fd..85f25a182e 100644 --- a/watertap/unit_models/zero_order/sedimentation_zo.py +++ b/watertap/unit_models/zero_order/sedimentation_zo.py @@ -76,9 +76,9 @@ def rule_basin_surface_area(b, t): ) self._fixed_perf_vars.append(self.phosphorus_solids_ratio) - self._perf_var_dict[ - "Phosphorus-Solids Ratio (kg/kg)" - ] = self.phosphorus_solids_ratio + self._perf_var_dict["Phosphorus-Solids Ratio (kg/kg)"] = ( + self.phosphorus_solids_ratio + ) # This subtype is intended to be used explicitly for phosphorous capture. # If the user provides TSS, the amount of settled phosphate would be determined based on @@ -111,9 +111,9 @@ def solids_mass_flow_constraint(b, t): / b.phosphorus_solids_ratio[t] ) - self._perf_var_dict[ - "Final mass flow of settled solids (kg/s)" - ] = self.final_solids_mass + self._perf_var_dict["Final mass flow of settled solids (kg/s)"] = ( + self.final_solids_mass + ) elif "tss" in self.config.property_package.solute_set: self.final_phosphate_mass = Var( @@ -133,9 +133,9 @@ def phosphate_mass_flow_constraint(b, t): * b.phosphorus_solids_ratio[t] ) - self._perf_var_dict[ - "Final mass flow of settled phosphate (kg/s)" - ] = self.final_phosphate_mass + self._perf_var_dict["Final mass flow of settled phosphate (kg/s)"] = ( + self.final_phosphate_mass + ) else: # Raise this error in case the user is intended to make use of the subtype but entered diff --git a/watertap/unit_models/zero_order/tests/test_feed_zo.py b/watertap/unit_models/zero_order/tests/test_feed_zo.py index b5a217aa43..f3e8ba5ebc 100644 --- a/watertap/unit_models/zero_order/tests/test_feed_zo.py +++ b/watertap/unit_models/zero_order/tests/test_feed_zo.py @@ -45,7 +45,7 @@ def model(self): @pytest.mark.unit def test_build(self, model): assert isinstance(model.fs.unit.outlet.flow_mass_comp, Var) - for (t, j) in model.fs.unit.outlet.flow_mass_comp.keys(): + for t, j in model.fs.unit.outlet.flow_mass_comp.keys(): assert t == 0 assert j in model.db.get_solute_set() or j == "H2O" @@ -53,7 +53,7 @@ def test_build(self, model): assert len(model.fs.unit.flow_vol) == 1 assert isinstance(model.fs.unit.conc_mass_comp, Var) - for (t, j) in model.fs.unit.conc_mass_comp.keys(): + for t, j in model.fs.unit.conc_mass_comp.keys(): assert t == 0 assert j in model.db.get_solute_set() diff --git a/watertap/unit_models/zero_order/tests/test_gas_sparged_membrane.py b/watertap/unit_models/zero_order/tests/test_gas_sparged_membrane.py index 3c0d4564a7..0e449f7c03 100644 --- a/watertap/unit_models/zero_order/tests/test_gas_sparged_membrane.py +++ b/watertap/unit_models/zero_order/tests/test_gas_sparged_membrane.py @@ -225,7 +225,7 @@ def test_solution(self, model): @pytest.mark.component def test_conservation(self, model): - for (t, j) in model.fs.unit.inlet.flow_mass_comp.keys(): + for t, j in model.fs.unit.inlet.flow_mass_comp.keys(): if j != "H2O": assert ( abs( diff --git a/watertap/unit_models/zero_order/uv_zo.py b/watertap/unit_models/zero_order/uv_zo.py index 720f8a9a7b..63a2fd4fec 100644 --- a/watertap/unit_models/zero_order/uv_zo.py +++ b/watertap/unit_models/zero_order/uv_zo.py @@ -54,9 +54,9 @@ def build(self): self._fixed_perf_vars.append(self.uv_reduced_equivalent_dose) self._fixed_perf_vars.append(self.uv_transmittance_in) - self._perf_var_dict[ - "UV Reduced Equivalent Dosage (mJ/cm^2)" - ] = self.uv_reduced_equivalent_dose + self._perf_var_dict["UV Reduced Equivalent Dosage (mJ/cm^2)"] = ( + self.uv_reduced_equivalent_dose + ) self._perf_var_dict["UV Transmittance of Feed"] = self.uv_transmittance_in @property diff --git a/watertap/unit_models/zero_order/well_field_zo.py b/watertap/unit_models/zero_order/well_field_zo.py index 6d58a7b187..8823358dc0 100644 --- a/watertap/unit_models/zero_order/well_field_zo.py +++ b/watertap/unit_models/zero_order/well_field_zo.py @@ -90,8 +90,7 @@ def cost_well_field(blk): ) Q = pyo.units.convert( - blk.unit_model.properties[t0].flow_vol - / (pyo.units.m**3 / pyo.units.hour), + blk.unit_model.properties[t0].flow_vol / (pyo.units.m**3 / pyo.units.hour), to_units=pyo.units.dimensionless, ) expr = pyo.units.convert( From f2181802d3ee2e9c288a9080e5c5d5e1b4eeb966 Mon Sep 17 00:00:00 2001 From: Adam Atia Date: Fri, 29 Mar 2024 10:43:17 -0400 Subject: [PATCH 5/7] delete rst file --- .../property_models/seawater_ion_generic.rst | 93 ------------------- 1 file changed, 93 deletions(-) delete mode 100644 docs/technical_reference/property_models/seawater_ion_generic.rst diff --git a/docs/technical_reference/property_models/seawater_ion_generic.rst b/docs/technical_reference/property_models/seawater_ion_generic.rst deleted file mode 100644 index ed752c475a..0000000000 --- a/docs/technical_reference/property_models/seawater_ion_generic.rst +++ /dev/null @@ -1,93 +0,0 @@ -Seawater Ion Generic Property Package -===================================== - -This package implements property relationships for artificial seawater as provided in `Islam et al. (2021) `_. - -This artificial seawater property package: - * supports only 'H2O', 'Na_+', 'Ca_2+', 'Mg_2+', 'Cl\_-', 'SO4_2-' - * supports only liquid phase - * is formulated on a molar basis - * does not support dynamics - -This package uses the eNRTL equation of state and has been used to predict mineral scaling in full treatment -where reverse osmosis is the primary desalination technology. Additionally, this property package is -formulated as an extension of `IDAES's modular property framework `_ (GenericParameterBlock). -In other words, this property package is a configuration file that gets passed into IDAES's generic/modular property framework. - -Sets ----- -.. csv-table:: - :header: "Description", "Symbol", "Indices" - - "Components", ":math:`j`", "['H2O', 'Na_+', 'Ca_2+', 'Mg_2+', 'Cl\_-', 'SO4_2-']" - "Phases", ":math:`p`", "['Liq']" - -State variables ---------------- -.. csv-table:: - :header: "Description", "Symbol", "Variable", "Index", "Units" - - "Component molar flowrate", ":math:`N_j`", "flow_mol_phase_comp", "[p, j]", ":math:`\text{mole/s}`" - "Temperature", ":math:`T`", "temperature", "None", ":math:`\text{K}`" - "Pressure", ":math:`P`", "pressure", "None", ":math:`\text{Pa}`" - -Properties ----------- -.. csv-table:: - :header: "Description", "Symbol", "Variable", "Index", "Units" - - "Component mole fraction", ":math:`y_j`", "mole_frac_phase_comp", "[p, j]", ":math:`\text{dimensionless}`" - "Component mole flowrate", ":math:`N_j`", "flow_mol_phase_comp", "[p, j]", ":math:`\text{mole/s}`" - "Interaction parameter", ":math:`τ`", "Liq_tau", "[j_1, j_2, j_3]", ":math:`\text{dimensionless}`" - "Component molar volume", ":math:`V_j`", "vol_mol_liq_comp", "[j]", ":math:`\text{m}^3\text{/mole}`" - -Relationships -------------- -.. csv-table:: - :header: "Description", "Equation" - - "Component mole flowrate", ":math:`N_j = \frac{M_j}{MW_j}`" - "Component mole fraction", ":math:`y_j = \frac{N_j}{\sum_{j} N_j}`" - - - -Scaling -------- -This artificial seawater property package includes support for scaling, such as default or user-supplied scaling factors for all variables. - -The default scaling factors are as follows: - - * 1e1 for 'Na_+' mole flowrate - * 1e3 for 'Ca_2+' mole flowrate - * 1e2 for 'Mg_2+' mole flowrate - * 1e2 for 'SO4_2-' mole flowrate - * 1e1 for 'Cl\_-' mole flowrate - * 1e-1 for 'H2O' mole flowrate - * 1e2 for 'Na_+' mole fraction - * 1e4 for 'Ca_2+' mole fraction - * 1e3 for 'Mg_2+' mole fraction - * 1e3 for 'SO4_2-' mole fraction - * 1e2 for 'Cl\_-' mole fraction - * 1 for 'H2O' mole fraction - * 1e1 for 'NaCl' apparent mole flowrate - * 1e2 for 'Na2SO4' apparent mole flowrate - * 1e2 for 'CaCl2' apparent mole flowrate - * 1e3 for 'CaSO4' apparent mole flowrate - * 1e2 for 'MgCl2' apparent mole flowrate - * 1e3 for 'MgSO4' apparent mole flowrate - * 1e-1 for 'H2O' apparent mole flowrate - * 1e3 for 'NaCl' apparent mole fraction - * 1e4 for 'Na2SO4' apparent mole fraction - * 1e4 for 'CaCl2' apparent mole fraction - * 1e5 for 'CaSO4' apparent mole fraction - * 1e4 for 'MgCl2' apparent mole fraction - * 1e5 for 'MgSO4' apparent mole fraction - * 1 for 'H2O' apparent mole fraction - -Scaling factors for other variables can be calculated based on their relationships with the user-supplied or default scaling factors. - -Reference ---------- - -M.R.Islam, I.Hsieh, B.Lin, A.K.Thakur, C.Chen, M.Malmali, Molecular thermodynamics for scaling prediction: Case of membrane distillation, Separation and Purification Technology, 2021,Vol. 276. https://www.sciencedirect.com/science/article/abs/pii/S1383586621009412 - From ef1534c26d059bd3d11ce4aafbb9c067442018d7 Mon Sep 17 00:00:00 2001 From: Adam Atia Date: Fri, 29 Mar 2024 10:47:29 -0400 Subject: [PATCH 6/7] undo erroneous merge resolution --- watertap/unit_models/pressure_exchanger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/watertap/unit_models/pressure_exchanger.py b/watertap/unit_models/pressure_exchanger.py index 59c95faa5c..b9dd225aa5 100644 --- a/watertap/unit_models/pressure_exchanger.py +++ b/watertap/unit_models/pressure_exchanger.py @@ -582,8 +582,8 @@ def propogate_state(sb1, sb2): self.brine_side.properties_in[0], self.brine_side.properties_out[0], ) - self.high_pressure_side.properties_out[0].pressure.value = ( - self.low_pressure_side.properties_in[0].pressure.value + self.brine_side.properties_out[0].pressure.value = ( + self.feed_side.properties_in[0].pressure.value ) init_log.info_high("Initialize outlets complete") From 7e68581bb9e374849b2d91a852058e0b069a84a4 Mon Sep 17 00:00:00 2001 From: Adam Atia Date: Fri, 29 Mar 2024 11:07:07 -0400 Subject: [PATCH 7/7] blk --- watertap/unit_models/pressure_exchanger.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/watertap/unit_models/pressure_exchanger.py b/watertap/unit_models/pressure_exchanger.py index b9dd225aa5..dedc766a68 100644 --- a/watertap/unit_models/pressure_exchanger.py +++ b/watertap/unit_models/pressure_exchanger.py @@ -582,9 +582,9 @@ def propogate_state(sb1, sb2): self.brine_side.properties_in[0], self.brine_side.properties_out[0], ) - self.brine_side.properties_out[0].pressure.value = ( - self.feed_side.properties_in[0].pressure.value - ) + self.brine_side.properties_out[0].pressure.value = self.feed_side.properties_in[ + 0 + ].pressure.value init_log.info_high("Initialize outlets complete") # Solve unit