Beispiel #1
0
    def test_is_phase_valid_solid(self, m):
        m.comp5 = Apparent(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)
Beispiel #2
0
    def test_is_phase_valid_vapor(self, m):
        m.comp4 = Apparent(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)
Beispiel #3
0
    def test_is_phase_valid_aqueous(self, m):
        m.comp6 = Apparent(
            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)
Beispiel #4
0
    def test_is_phase_valid_LV(self, m):
        m.comp7 = Apparent(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)
Beispiel #5
0
    def test_is_phase_valid_aqueous(self, m):
        m.comp6 = Apparent(default={
            "valid_phase_types": PhaseType.aqueousPhase,
            "dissociation_species": {"comp": 1},
            "_electrolyte": True})

        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)
Beispiel #6
0
    def test_is_phase_valid_LV(self, m):
        m.comp7 = Apparent(default={
            "valid_phase_types": [PhaseType.liquidPhase,
                                  PhaseType.vaporPhase],
            "dissociation_species": {"comp": 1},
            "_electrolyte": True})

        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)
Beispiel #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 = Apparent()

        return m
Beispiel #8
0
    def test_is_phase_valid_liquid(self, m):
        m.comp3 = Apparent(
            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)
Beispiel #9
0
    def test_is_phase_valid_liquid(self, m):
        m.comp3 = Apparent(default={
            "valid_phase_types": PhaseType.liquidPhase,
            "dissociation_species": {"comp": 1},
            "_electrolyte": True})

        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)
Beispiel #10
0
    def test_no_dissociation_species(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)

        with pytest.raises(
                ConfigurationError,
                match="dissoication_species argument was not set. "
                "Apparent components require the dissociation species to be "
                "defined."):
            m.comp = Apparent(default={"_electrolyte": False})
Beispiel #11
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._apparent_set = Set()

        m.comp = Apparent(default={"dissociation_species": {"comp": 1},
                                   "_electrolyte": True})

        return m
Beispiel #12
0
    def test_not_electrolye(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 = Apparent(default={"dissociation_species": {"comp": 1},
                                   "_electrolyte": False})

        for j in m.component_list:
            assert j in ["comp"]
        for j in m.solute_set:
            assert j in ["comp"]

        assert m.comp.config.dissociation_species == {"comp": 1}