def test_set_lowest_energy_conformer(): from autode.mol_graphs import make_graph hb = Atom('H', z=0.7) hydrogen = Species(name='H2', atoms=[h1, hb], charge=0, mult=1) make_graph(hydrogen) hydrogen_wo_e = Species(name='H2', atoms=[h1, hb], charge=0, mult=1) hydrogen_with_e = Species(name='H2', atoms=[h1, hb], charge=0, mult=1) hydrogen_with_e.energy = -1 hydrogen.conformers = [hydrogen_wo_e, hydrogen_with_e] hydrogen._set_lowest_energy_conformer() # Conformers without energy should be skipped assert hydrogen.energy == -1 # Conformers with a different molecular graph should be skipped h_atom = Species(name='H', atoms=[Atom('H')], charge=0, mult=1) h_atom.energy = -2 hydrogen.conformers = [hydrogen_with_e, h_atom] assert hydrogen.energy == -1
def test_species_isomorphism(): h2.graph = None h2_copy = Species(name='H2', atoms=[h_a, h_b], charge=0, mult=1) h2_copy.graph = None with pytest.raises(NoMolecularGraph): assert mol_graphs.species_are_isomorphic(h2, h2_copy) # With molecular graphs the species should be isomorphic mol_graphs.make_graph(h2) mol_graphs.make_graph(h2_copy) assert mol_graphs.species_are_isomorphic(h2, h2_copy) # Shift one of the atoms far away and remake the graph h2_copy.atoms[1].translate(vec=np.array([10, 0, 0])) mol_graphs.make_graph(h2_copy) assert mol_graphs.species_are_isomorphic(h2, h2_copy) is False # Generating a pair of conformers that are isomporhpic should return that # the species are again isomorphic h2.conformers = [ Conformer(name='h2_conf', atoms=[h_a, h_b], charge=0, mult=1) ] h2_copy.conformers = [ Conformer(name='h2_conf', atoms=[h_a, h_b], charge=0, mult=1) ] assert mol_graphs.species_are_isomorphic(h2, h2_copy)