Exemple #1
0
    def test_graph_representation(self):

        LiEC_RN_entry = entries["LiEC"]
        LiEC_RO_RN_entry = entries["LiEC_RO"]
        LiEC_ind = LiEC_RN_entry.parameters["ind"]
        LiEC_RO_ind = LiEC_RO_RN_entry.parameters["ind"]

        reaction = IntramolSingleBondChangeReaction(LiEC_RN_entry,
                                                    LiEC_RO_RN_entry)
        reaction.electron_free_energy = -2.15
        graph = reaction.graph_representation()
        # print(graph.nodes, graph.edges)
        # print(graph.get_edge_data(LiEC_ind, str(LiEC_ind) + "," + str(LiEC_RO_ind)))
        self.assertCountEqual(
            list(graph.nodes),
            [
                LiEC_ind,
                LiEC_RO_ind,
                str(LiEC_ind) + "," + str(LiEC_RO_ind),
                str(LiEC_RO_ind) + "," + str(LiEC_ind),
            ],
        )
        self.assertEqual(len(graph.edges), 4)
        self.assertEqual(
            graph.get_edge_data(LiEC_ind,
                                str(LiEC_ind) + "," +
                                str(LiEC_RO_ind))["softplus"],
            0.15092362164364986,
        )
Exemple #2
0
    def test_graph_representation(self):

        RN = ReactionNetwork.from_input_entries(self.LiEC_reextended_entries)
        # print(RN.entries["C3 H4 Li1 O3"][11][0][0].molecule)

        LiEC_ind = None
        LiEC_RO_ind = None
        LiEC_RN_entry = None
        LiEC_RO_RN_entry = None
        for entry in RN.entries["C3 H4 Li1 O3"][12][0]:
            if self.LiEC_mg.isomorphic_to(entry.mol_graph):
                LiEC_ind = entry.parameters["ind"]
                LiEC_RN_entry = entry
                break
        for entry in RN.entries["C3 H4 Li1 O3"][11][0]:
            if self.LiEC_RO_mg.isomorphic_to(entry.mol_graph):
                LiEC_RO_ind = entry.parameters["ind"]
                LiEC_RO_RN_entry = entry
                break
        reaction = IntramolSingleBondChangeReaction(LiEC_RN_entry,
                                                    LiEC_RO_RN_entry)
        reaction.electron_free_energy = -2.15
        graph = reaction.graph_representation()
        print(graph.nodes, graph.edges)
        print(
            graph.get_edge_data(LiEC_ind,
                                str(LiEC_ind) + "," + str(LiEC_RO_ind)))
        self.assertCountEqual(
            list(graph.nodes),
            [
                LiEC_ind,
                LiEC_RO_ind,
                str(LiEC_ind) + "," + str(LiEC_RO_ind),
                str(LiEC_RO_ind) + "," + str(LiEC_ind),
            ],
        )
        self.assertEqual(len(graph.edges), 4)
        self.assertEqual(
            graph.get_edge_data(LiEC_ind,
                                str(LiEC_ind) + "," +
                                str(LiEC_RO_ind))["softplus"],
            0.15092362164364986,
        )