Example #1
0
    def test_multiple_options(self):
        @register_reaction_mechanism([requirement1], True)
        def a(r, c):
            return ["a"]

        @register_reaction_mechanism([requirement1], True)
        def b(r, c):
            return ["b"]

        # The order is not guaranteed, but it should equal one of them.
        # This will be fixed once ordering is worked out.
        assert react(None, None, True) in (["a"], ["b"])
Example #2
0
    def test_multiple_options(self):
        @register_reaction_mechanism([requirement1], True)
        def a(r, c):
            return ["a"]

        @register_reaction_mechanism([requirement1], True)
        def b(r, c):
            return ["b"]

        # The order is not guaranteed, but it should equal one of them.
        # This will be fixed once ordering is worked out.
        assert react(None, None, True) in (["a"], ["b"])
Example #3
0
    def test_multiple_options_some_invalid(self):
        @register_reaction_mechanism([requirement1], True)
        def a(r, c):
            return ["a"]

        @register_reaction_mechanism([requirement1], True)
        def b(r, c):
            return ["b"]

        @register_reaction_mechanism([requirement2], True)
        def c(r, c_):
            return ["c"]

        assert react(None, None, True) in (["a"], ["b"])
Example #4
0
    def test_multiple_options_some_invalid(self):
        @register_reaction_mechanism([requirement1], True)
        def a(r, c):
            return ["a"]

        @register_reaction_mechanism([requirement1], True)
        def b(r, c):
            return ["b"]

        @register_reaction_mechanism([requirement2], True)
        def c(r, c_):
            return ["c"]

        assert react(None, None, True) in (["a"], ["b"])
Example #5
0
def test_simple_acid_base_reaction():
    acid = Molecule(
        {'a1': 'H', 'a2': 'H', 'a3': 'H', 'a4': 'O'},
        {'b1': {'nodes': ('a1', 'a4'), 'order': 1},
         'b2': {'nodes': ('a2', 'a4'), 'order': 1},
         'b3': {'nodes': ('a3', 'a4'), 'order': 1}
        },
        **{'id': 'Hydronium'}
    )

    base = Molecule(
        {'a1': 'H', 'a2': 'O'},
        {'b1': {'nodes': ('a1', 'a2'), 'order': 1}},
        **{'id': 'Hydroxide'}
    )

    conditions = {
        'pkas': {'Hydronium': -1.74, 'Hydroxide': 15.7},
        'pka_points': {'Hydronium': 'a1', 'Hydroxide': 'a2'}
    }

    products = react([acid, base], conditions)

    conjugate_acid = Molecule(
        {'a1': 'H', 'a2': 'H', 'a3': 'O'},
        {'b1': {'nodes': ('a1', 'a3'), 'order': 1},
         'b2': {'nodes': ('a2', 'a3'), 'order': 1}
        }
    )

    conjugate_base = Molecule(
        {'a1': 'H', 'a2': 'H', 'a3': 'O'},
        {'b1': {'nodes': ('a1', 'a3'), 'order': 1},
         'b2': {'nodes': ('a2', 'a3'), 'order': 1}
        }
    )

    assert products[0] == conjugate_acid
    assert products[1] == conjugate_base

    # Determining the salt isn't implemented
    assert products[2] is None
Example #6
0
    def test_single_option(self):
        @register_reaction_mechanism([requirement1], True)
        def a(r, c):
            return ["Hello, world!"]

        assert react(None, None, True) == ["Hello, world!"]
Example #7
0
    def test_single_option(self):
        @register_reaction_mechanism([requirement1], True)
        def a(r, c):
            return ["Hello, world!"]

        assert react(None, None, True) == ["Hello, world!"]