Beispiel #1
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)
Beispiel #2
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)
Beispiel #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,
        )
    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)],
        )
Beispiel #5
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,
        )
Beispiel #6
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)
Beispiel #7
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)