示例#1
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 = Cation(default={"charge": +1})

        return m
示例#2
0
    def test_not_electrolye(self):
        m = ConcreteModel()

        m.meta_object = PropertyClassMetadata()

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

        with pytest.raises(
                PropertyPackageError,
                match="comp Ion Component types should only be used with "
                "Aqueous Phases"):
            m.comp = Cation(default={"_electrolyte": False})
示例#3
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.cation_set = Set()

        m.comp = Cation(default={"charge": +1, "_electrolyte": True})

        return m
示例#4
0
 def test_no_charge(self, m):
     with pytest.raises(ConfigurationError,
                        match="cat was not provided with a value "
                        "for charge."):
         m.cat = Cation()
示例#5
0
 def test_invalid_charge(self, m):
     with pytest.raises(ConfigurationError,
                        match="cat received invalid value for charge "
                        "configuration argument."
                        " Cations must have a positive charge."):
         m.cat = Cation(default={"charge": -1})
示例#6
0
 def test_no_charge(self, m):
     with pytest.raises(ConfigurationError,
                        match="cat was not provided with a value "
                        "for charge."):
         m.cat = Cation(default={"_electrolyte": True})