Esempio n. 1
0
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)
Esempio n. 2
0
def test_isomorphic_no_active():
    os.chdir(os.path.join(here, 'data'))

    ts_syn = Conformer(name='syn_ts', charge=-1, mult=0, atoms=xyz_file_to_atoms('E2_ts_syn.xyz'))
    mol_graphs.make_graph(ts_syn)
    mol_graphs.set_active_mol_graph(ts_syn, active_bonds=[(8, 5), (0, 5), (1, 2)])

    ts_anti = Conformer(name='anti_ts', charge=-1, mult=0, atoms=xyz_file_to_atoms('E2_ts.xyz'))
    mol_graphs.make_graph(ts_anti)

    assert mol_graphs.is_isomorphic(ts_syn.graph, ts_anti.graph, ignore_active_bonds=True)

    os.chdir(here)
Esempio n. 3
0
def test_conformers():

    methane = Molecule(name='methane', smiles='C')

    # Function requiring a molecule having a conformer attribute
    @utils.requires_conformers()
    def test(mol):
        print(mol.conformers[0].n_atoms)

    with pytest.raises(NoConformers):
        test(methane)

    # Populating a species conformers should allow this function to be called
    methane.conformers = [Conformer(name='conf0', atoms=methane.atoms)]
    test(methane)
Esempio n. 4
0
def test_species_conformers_isomorphic():
    h2_a = Molecule(name='H2', atoms=[Atom('H'), Atom('H', x=0.7)])

    h2_b = Molecule(name='H2', atoms=[Atom('H'), Atom('H', x=1.5)])

    assert not mol_graphs.species_are_isomorphic(h2_a, h2_b)

    # Should raise an exception for two non-isomorphic graphs
    with pytest.raises(NoMapping):
        mol_graphs.get_mapping(h2_a.graph, h2_b.graph)

    h2_a.conformers = None
    h2_b.conformers = [
        Conformer(name='H2', atoms=[Atom('H'), Atom('H', x=0.7)])
    ]

    assert mol_graphs.species_are_isomorphic(h2_a, h2_b)
Esempio n. 5
0
from autode.input_output import xyz_file_to_atoms
from autode.conformers import conf_gen, Conformer
from autode.methods import XTB

# Initialise the complex from a .xyz file containing a square planar structure
vaskas = Molecule(name='vaskas', atoms=xyz_file_to_atoms('vaskas.xyz'))

# Set up some distance constraints where the keys are the atom indexes and
# the value the distance in Å. Fixing the Cl-P, Cl-P and Cl-C(=O) distances
# enforces a square planar geometry
distance_constraints = {
    (1, 2): vaskas.get_distance(1, 2),
    (1, 3): vaskas.get_distance(1, 3),
    (1, 4): vaskas.get_distance(1, 4)
}

# Generate 5 conformers
for n in range(5):

    # Apply random displacements to each atom and minimise under a bonded +
    # repulsive forcefield including the distance constraints
    atoms = conf_gen.get_simanl_atoms(species=vaskas,
                                      dist_consts=distance_constraints,
                                      conf_n=n)

    # Generate a conformer from these atoms then optimise with XTB
    conformer = Conformer(name=f'vaskas_conf{n}', atoms=atoms)

    conformer.optimise(method=XTB())
    conformer.print_xyz_file()