Пример #1
0
    def test_free_energy(self):

        reaction = RedoxReaction(self.EC_0_entry, self.EC_1_entry)
        reaction.electron_free_energy = -2.15
        reaction.free_energy()
        self.assertEqual(reaction.free_energy_A, 6.231346035181195)
        self.assertEqual(reaction.free_energy_B, -6.231346035181195)
Пример #2
0
    def test_energy(self):

        reaction = RedoxReaction(self.EC_0_entry, self.EC_1_entry)
        reaction.electron_free_energy = -2.15
        reaction.energy()
        self.assertEqual(reaction.energy_A, 0.3149076465170424)
        self.assertEqual(reaction.energy_B, -0.3149076465170424)
Пример #3
0
    def test_graph_representation(self):

        reaction = RedoxReaction(entries["EC_0"], entries["EC_1"])
        reaction.electron_free_energy = -2.15
        graph = reaction.graph_representation()

        EC_0_ind = entries["EC_0"].parameters["ind"]
        EC_1_ind = entries["EC_1"].parameters["ind"]

        self.assertCountEqual(
            list(graph.nodes),
            [
                EC_0_ind,
                EC_1_ind,
                str(EC_0_ind) + "," + str(EC_1_ind),
                str(EC_1_ind) + "," + str(EC_0_ind),
            ],
        )
        self.assertEqual(len(graph.edges), 4)
        self.assertEqual(
            graph.get_edge_data(EC_0_ind,
                                str(EC_0_ind) + "," +
                                str(EC_1_ind))["softplus"],
            5.629805462349386,
        )
Пример #4
0
    def test_add_reactions(self):

        # set up RN
        RN = ReactionNetwork.from_input_entries(
            self.LiEC_reextended_entries, electron_free_energy=-2.15
        )

        # set up input variables
        EC_0_entry = None
        EC_minus_entry = None

        # print(RN.entries["C3 H4 O3"].keys())

        for entry in RN.entries["C3 H4 O3"][10][0]:
            if self.EC_mg.isomorphic_to(entry.mol_graph):
                EC_0_entry = entry
                break
        for entry in RN.entries["C3 H4 O3"][10][-1]:
            if self.EC_mg.isomorphic_to(entry.mol_graph):
                EC_minus_entry = entry
                break

        redox = RedoxReaction(EC_0_entry, EC_minus_entry)
        redox.electron_free_energy = -2.15
        redox_graph = redox.graph_representation()

        # run calc
        RN.add_reaction(redox_graph)

        # assert
        self.assertEqual(list(RN.graph.nodes), ["456,455", 456, 455, "455,456"])
        self.assertEqual(
            list(RN.graph.edges),
            [("456,455", 455), (456, "456,455"), (455, "455,456"), ("455,456", 456)],
        )
Пример #5
0
    def test_generate(self):

        reactions = RedoxReaction.generate(entries["RN"].entries)

        self.assertEqual(len(reactions), 273)

        for r in reactions:
            if r.reactant == entries["EC_0"]:
                self.assertEqual(r.product.entry_id, entries["EC_1"].entry_id)
            if r.reactant == entries["EC_-1"]:
                self.assertEqual(r.product.entry_id, entries["EC_0"].entry_id)
Пример #6
0
    def test_graph_representation(self):

        RN = ReactionNetwork.from_input_entries(self.LiEC_reextended_entries)

        EC_0_ind = None
        EC_1_ind = None
        EC_0_RN_entry = None
        EC_1_RN_entry = None
        for entry in RN.entries["C3 H4 O3"][10][0]:
            if self.EC_mg.isomorphic_to(entry.mol_graph):
                EC_0_ind = entry.parameters["ind"]
                EC_0_RN_entry = entry
                break
        for entry in RN.entries["C3 H4 O3"][10][1]:
            if self.EC_mg.isomorphic_to(entry.mol_graph):
                EC_1_ind = entry.parameters["ind"]
                EC_1_RN_entry = entry
                break

        reaction = RedoxReaction(EC_0_RN_entry, EC_1_RN_entry)
        reaction.electron_free_energy = -2.15
        graph = reaction.graph_representation()

        self.assertCountEqual(
            list(graph.nodes),
            [
                EC_0_ind,
                EC_1_ind,
                str(EC_0_ind) + "," + str(EC_1_ind),
                str(EC_1_ind) + "," + str(EC_0_ind),
            ],
        )
        self.assertEqual(len(graph.edges), 4)
        self.assertEqual(
            graph.get_edge_data(EC_0_ind,
                                str(EC_0_ind) + "," +
                                str(EC_1_ind))["softplus"],
            5.629805462349386,
        )
Пример #7
0
    def test_atom_mapping(self):

        entries = bucket_mol_entries(
            [self.EC_minus_entry, self.EC_0_entry, self.EC_1_entry])

        reactions, families = RedoxReaction.generate(entries)
        self.assertEqual(len(reactions), 2)

        for r in reactions:
            self.assertEqual(
                r.reactants_atom_mapping,
                [{
                    0: 0,
                    1: 1,
                    2: 2,
                    3: 3,
                    4: 4,
                    5: 5,
                    6: 6,
                    7: 7,
                    8: 8,
                    9: 9
                }],
            )
            self.assertEqual(
                r.products_atom_mapping,
                [{
                    0: 0,
                    1: 1,
                    2: 2,
                    3: 3,
                    4: 4,
                    5: 5,
                    6: 6,
                    7: 7,
                    8: 8,
                    9: 9
                }],
            )
Пример #8
0
    def test_atom_mapping(self):
        ents = bucket_mol_entries(
            [entries["EC_-1"], entries["EC_0"], entries["EC_1"]])

        reactions = RedoxReaction.generate(ents)
        self.assertEqual(len(reactions), 2)

        for r in reactions:
            self.assertEqual(
                r.reactants_atom_mapping,
                [{
                    0: 0,
                    1: 1,
                    2: 2,
                    3: 3,
                    4: 4,
                    5: 5,
                    6: 6,
                    7: 7,
                    8: 8,
                    9: 9
                }],
            )
            self.assertEqual(
                r.products_atom_mapping,
                [{
                    0: 0,
                    1: 1,
                    2: 2,
                    3: 3,
                    4: 4,
                    5: 5,
                    6: 6,
                    7: 7,
                    8: 8,
                    9: 9
                }],
            )
Пример #9
0
 def test_reaction_type(self):
     reaction = RedoxReaction(self.EC_0_entry, self.EC_1_entry)
     self.assertEqual(reaction.rxn_type_A, "One electron oxidation")
     self.assertEqual(reaction.rxn_type_B, "One electron reduction")
Пример #10
0
    def test_generate(self):

        RN = ReactionNetwork.from_input_entries(self.LiEC_reextended_entries)
        reactions, families = RedoxReaction.generate(RN.entries)

        self.assertEqual(len(reactions), 273)
Пример #11
0
 def test_reaction_type(self):
     reaction = RedoxReaction(entries["EC_0"], entries["EC_1"])
     self.assertEqual(reaction.__class__.__name__, "RedoxReaction")
     self.assertEqual(reaction.rxn_type_A, "One electron oxidation")
     self.assertEqual(reaction.rxn_type_B, "One electron reduction")
Пример #12
0
 def test_energy(self):
     reaction = RedoxReaction(entries["EC_0"], entries["EC_1"])
     reaction.electron_free_energy = -2.15
     self.assertEqual(reaction.energy_A, 0.3149076465170424)
     self.assertEqual(reaction.energy_B, -0.3149076465170424)
Пример #13
0
 def test_free_energy(self):
     reaction = RedoxReaction(entries["EC_0"], entries["EC_1"])
     reaction.electron_free_energy = -2.15
     reaction.set_free_energy()
     self.assertEqual(reaction.free_energy_A, 6.231346035181195)
     self.assertEqual(reaction.free_energy_B, -6.231346035181195)