def test_is_phase_valid_vapor(self, m):
        m.comp4 = Solute(default={"valid_phase_types": PhaseType.vaporPhase})

        assert not m.comp4._is_phase_valid(m.Liq)
        assert not m.comp4._is_phase_valid(m.Sol)
        assert m.comp4._is_phase_valid(m.Vap)
        assert not m.comp4._is_phase_valid(m.Aqu)
        assert not m.comp4._is_phase_valid(m.Phase)
示例#2
0
    def test_is_phase_valid_aqueous(self, m):
        m.comp6 = Solute(default={"valid_phase_types": PhaseType.aqueousPhase})

        assert not m.comp6._is_phase_valid(m.Liq)
        assert not m.comp6._is_phase_valid(m.Sol)
        assert not m.comp6._is_phase_valid(m.Vap)
        assert m.comp6._is_phase_valid(m.Aqu)
        assert not m.comp6._is_phase_valid(m.Phase)
示例#3
0
    def test_is_phase_valid_solid(self, m):
        m.comp5 = Solute(default={"valid_phase_types": PhaseType.solidPhase})

        assert not m.comp5._is_phase_valid(m.Liq)
        assert m.comp5._is_phase_valid(m.Sol)
        assert not m.comp5._is_phase_valid(m.Vap)
        assert not m.comp5._is_phase_valid(m.Aqu)
        assert not m.comp5._is_phase_valid(m.Phase)
示例#4
0
    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,
                             mutable=False,
                             initialize=extract_data(mw_comp_data),
                             units=pyunits.kg / pyunits.mol,
                             doc="Molecular weight")

        self.dens_mass = Param(mutable=False,
                               initialize=1000,
                               units=pyunits.kg / pyunits.m**3,
                               doc="Density")

        self.cp = Param(mutable=False,
                        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)
示例#5
0
    def test_is_phase_valid_LV(self, m):
        m.comp7 = Solute(default={
            "valid_phase_types": [PhaseType.liquidPhase, PhaseType.vaporPhase]
        })

        assert m.comp7._is_phase_valid(m.Liq)
        assert not m.comp7._is_phase_valid(m.Sol)
        assert m.comp7._is_phase_valid(m.Vap)
        assert not m.comp7._is_phase_valid(m.Aqu)
        assert not m.comp7._is_phase_valid(m.Phase)
    def build(self):
        '''
        Callable method for Block construction.
        '''
        super().build()

        self._state_block_class = WaterStateBlock

        self.Liq = LiquidPhase()

        self.H2O = Solvent()

        # Get component set from database if provided
        comp_set = None
        if self.config.database is not None:
            comp_set = self.config.database.get_solute_set(
                self.config.water_source)

        # Check definition of solute list
        solute_list = self.config.solute_list
        if solute_list is None:
            # No user-provided solute list, look up list from database
            if comp_set is None:
                # No solute list in database and none provided.
                raise ConfigurationError(
                    f"{self.name} no solute_list or database was defined. "
                    f"Users must provide at least one of these arguments.")
            else:
                solute_list = comp_set
        elif self.config.database is not None:
            # User provided custom list and database - check that all
            # components are supported
            for j in solute_list:
                if j not in comp_set:
                    _log.info(f"{self.name} component {j} is not defined in "
                              f"the water_sources database file.")
        else:
            # User provided list but no database - assume they know what they
            # are doing
            pass

        for j in solute_list:
            self.add_component(str(j), Solute())

        # Define default value for mass density of solution
        self.dens_mass_default = 1000 * pyunits.kg / pyunits.m**3
        # Define default value for dynamic viscosity of solution
        self.visc_d_default = 0.001 * pyunits.kg / pyunits.m / pyunits.s

        # ---------------------------------------------------------------------
        # Set default scaling factors
        self.default_scaling_factor = {
            ("flow_vol"): 1e3,
            ("conc_mass_comp"): 1e2
        }
示例#7
0
    def m(self):
        m = ConcreteModel()

        m.meta_object = PropertyClassMetadata()

        def get_metadata(self):
            return m.meta_object

        m.get_metadata = types.MethodType(get_metadata, m)

        m.comp = Solute()

        return m
示例#8
0
    def test_is_phase_valid_liquid(self, m):
        m.comp3 = Solute(default={"valid_phase_types": PhaseType.liquidPhase})

        m.Liq = LiquidPhase()
        m.Sol = SolidPhase()
        m.Vap = VaporPhase()
        m.Aqu = AqueousPhase()
        m.Phase = Phase()

        assert m.comp3._is_phase_valid(m.Liq)
        assert not m.comp3._is_phase_valid(m.Sol)
        assert not m.comp3._is_phase_valid(m.Vap)
        assert not m.comp3._is_phase_valid(m.Aqu)
        assert not m.comp3._is_phase_valid(m.Phase)
示例#9
0
    def m(self):
        m = ConcreteModel()

        m.meta_object = PropertyClassMetadata()
        m.meta_object.add_default_units({
            'time': pyunits.s,
            'length': pyunits.m,
            'mass': pyunits.kg,
            'amount': pyunits.mol,
            'temperature': pyunits.K})

        def get_metadata(self):
            return m.meta_object
        m.get_metadata = types.MethodType(get_metadata, m)

        m.comp = Solute()

        return m
示例#10
0
    def build(self):
        '''
        Callable method for Block construction.
        '''
        super(NaClParameterData, self).build()

        self._state_block_class = NaClStateBlock

        # components
        self.H2O = Solvent()
        self.NaCl = Solute()

        # phases
        self.Liq = LiquidPhase()

        # reference
        # this package is developed from Bartholomew & Mauter (2019) https://doi.org/10.1016/j.memsci.2018.11.067
        # the enthalpy calculations are from Sharqawy et al. (2010) http://dx.doi.org/10.5004/dwt.2010.1079

        # molecular weight
        mw_comp_data = {'H2O': 18.01528E-3, 'NaCl': 58.44E-3}
        self.mw_comp = Param(self.component_list,
                             mutable=False,
                             initialize=extract_data(mw_comp_data),
                             units=pyunits.kg / pyunits.mol,
                             doc="Molecular weight kg/mol")

        # mass density parameters, eq 4 in Bartholomew
        dens_mass_param_dict = {'0': 995, '1': 756}
        self.dens_mass_param = Var(dens_mass_param_dict.keys(),
                                   domain=Reals,
                                   initialize=dens_mass_param_dict,
                                   units=pyunits.kg / pyunits.m**3,
                                   doc='Mass density parameters')

        # dynamic viscosity parameters, eq 5 in Bartholomew
        visc_d_param_dict = {'0': 9.80E-4, '1': 2.15E-3}
        self.visc_d_param = Var(visc_d_param_dict.keys(),
                                domain=Reals,
                                initialize=visc_d_param_dict,
                                units=pyunits.Pa * pyunits.s,
                                doc='Dynamic viscosity parameters')

        # diffusivity parameters, eq 6 in Bartholomew
        diffus_param_dict = {
            '0': 1.51e-9,
            '1': -2.00e-9,
            '2': 3.01e-8,
            '3': -1.22e-7,
            '4': 1.53e-7
        }
        self.diffus_param = Var(diffus_param_dict.keys(),
                                domain=Reals,
                                initialize=diffus_param_dict,
                                units=pyunits.m**2 / pyunits.s,
                                doc='Dynamic viscosity parameters')

        # osmotic coefficient parameters, eq. 3b in Bartholomew
        osm_coeff_param_dict = {'0': 0.918, '1': 8.89e-2, '2': 4.92}
        self.osm_coeff_param = Var(osm_coeff_param_dict.keys(),
                                   domain=Reals,
                                   initialize=osm_coeff_param_dict,
                                   units=pyunits.dimensionless,
                                   doc='Osmotic coefficient parameters')

        # TODO: update for NaCl solution, relationship from Sharqawy is for seawater
        # specific enthalpy parameters, eq. 55 and 43 in Sharqawy (2010)
        self.enth_mass_param_A1 = Var(within=Reals,
                                      initialize=124.790,
                                      units=pyunits.J / pyunits.kg,
                                      doc='Specific enthalpy parameter A1')
        self.enth_mass_param_A2 = Var(within=Reals,
                                      initialize=4203.075,
                                      units=(pyunits.J / pyunits.kg) *
                                      pyunits.K**-1,
                                      doc='Specific enthalpy parameter A2')
        self.enth_mass_param_A3 = Var(within=Reals,
                                      initialize=-0.552,
                                      units=(pyunits.J / pyunits.kg) *
                                      pyunits.K**-2,
                                      doc='Specific enthalpy parameter A3')
        self.enth_mass_param_A4 = Var(within=Reals,
                                      initialize=0.004,
                                      units=(pyunits.J / pyunits.kg) *
                                      pyunits.K**-3,
                                      doc='Specific enthalpy parameter A4')
        self.enth_mass_param_B1 = Var(within=Reals,
                                      initialize=27062.623,
                                      units=pyunits.dimensionless,
                                      doc='Specific enthalpy parameter B1')
        self.enth_mass_param_B2 = Var(within=Reals,
                                      initialize=4835.675,
                                      units=pyunits.dimensionless,
                                      doc='Specific enthalpy parameter B2')

        # traditional parameters are the only Vars currently on the block and should be fixed
        for v in self.component_objects(Var):
            v.fix()

        # ---default scaling---
        self.set_default_scaling('temperature', 1e-2)
        self.set_default_scaling('pressure', 1e-6)
        self.set_default_scaling('dens_mass_phase', 1e-3, index='Liq')
        self.set_default_scaling('visc_d_phase', 1e3, index='Liq')
        self.set_default_scaling('diffus_phase', 1e9, index='Liq')
        self.set_default_scaling('osm_coeff', 1e0)
        self.set_default_scaling('enth_mass_phase', 1e-5, index='Liq')
    def build(self):
        '''
        Callable method for Block construction.
        '''
        super(DSPMDEParameterData, self).build()

        self._state_block_class = DSPMDEStateBlock

        # components
        self.H2O = Solvent()

        for j in self.config.solute_list:
            self.add_component(str(j), Solute())

        # phases
        self.Liq = LiquidPhase()

        # reference
        # Todo: enter any relevant references

        # TODO: consider turning parameters into variables for future param estimation
        # molecular weight
        self.mw_comp = Param(
            self.component_list,
            mutable=True,
            default=18e-3,
            initialize=self.config.mw_data,
            units=pyunits.kg/pyunits.mol,
            doc="Molecular weight")
        # Stokes radius
        self.radius_stokes_comp = Param(
            self.solute_set,
            mutable=True,
            default=1e-10,
            initialize=self.config.stokes_radius_data,
            units=pyunits.m,
            doc="Stokes radius of solute")
        self.diffus_phase_comp = Param(
            self.phase_list,
            self.solute_set,
            mutable=True,
            default=1e-9,
            initialize=self.config.diffusivity_data,
            units=pyunits.m ** 2 * pyunits.s ** -1,
            doc="Bulk diffusivity of ion")
        self.visc_d_phase = Param(
            self.phase_list,
            mutable=True,
            default=1e-3,
            initialize=1e-3, #TODO:revisit- assuming ~ 1e-3 Pa*s for pure water
            units=pyunits.Pa * pyunits.s,
            doc="Fluid viscosity")
        # Ion charge
        self.charge_comp = Param(
            self.solute_set,
            mutable=True,
            default=1,
            initialize=self.config.charge,
            units=pyunits.dimensionless,
            doc="Ion charge")
        # Dielectric constant of water
        self.dielectric_constant = Param(
            mutable=True,
            default=80.4,
            initialize=80.4, #todo: make a variable with parameter values for coefficients in the function of temperature
            units=pyunits.dimensionless,
            doc="Dielectric constant of water")


        # ---default scaling---
        self.set_default_scaling('temperature', 1e-2)
        self.set_default_scaling('pressure', 1e-6)
        self.set_default_scaling('dens_mass_phase', 1e-3, index='Liq')
        self.set_default_scaling('visc_d_phase', 1e3, index='Liq')