def test_solvent():

    methane = Molecule(smiles='C')
    methane.solvent = 'water'

    # Calculation should be able to handle a solvent given as just a string
    assert get_solvent_name(molecule=methane, method=mopac) == 'water'

    # Unknown solvent should raise an exception
    with pytest.raises(SolventNotFound):
        methane.solvent = 'XXXX'
        get_solvent_name(molecule=methane, method=mopac)
Exemple #2
0
def test_dft():

    orca = ORCA()

    methods.clear()
    h2 = Molecule(smiles='[H][H]', solvent_name='water')
    h2.single_point(method=orca)

    assert 'PBE0' in str(methods)
    assert 'def2-TZVP' in str(methods)
    assert '4.2.1' in str(methods)

    # Default CPCM solvation in orca
    assert 'CPCM' in str(methods)
Exemple #3
0
from autode import Molecule
from autode.calculation import Calculation
from autode.methods import XTB
import matplotlib.pyplot as plt
import numpy as np

# Initialise the electronic structure method (XTB)
xtb = XTB()

water = Molecule(name='H2O', smiles='O')
rs = np.linspace(0.65, 2.0, num=20)

# List of energies to be populated for the single point (unrelaxed)
# and constrained optimisations (relaxed) calculations
sp_energies, opt_energies = [], []

for r in rs:

    o_atom, h_atom = water.atoms[:2]
    curr_r = water.get_distance(0, 1)  # current O-H distance

    # Shift the hydrogen atom to the required distance
    # vector =  (h_atom.coord - o_atom.coord) / curr_r * (r - curr_r)
    vector = (h_atom.coord - o_atom.coord) * (r / curr_r - 1)
    h_atom.translate(vector)

    # Set up and run the single point energy evaluation
    sp = Calculation(name=f'H2O_scan_unrelaxed_{r:.2f}',
                     molecule=water,
                     method=xtb,
                     keywords=xtb.keywords.sp)
Exemple #4
0
from autode import Molecule, Config
from autode.species import NCIComplex
from autode.wrappers.XTB import xtb

Config.num_complex_sphere_points = 5
Config.num_complex_random_rotations = 3

# Make a water molecule and optimise at the XTB level
water = Molecule(name='water', smiles='O')
water.optimise(method=xtb)

# Make the NCI complex and find the lowest energy structure
trimer = NCIComplex(water, water, water, name='water_trimer')
trimer.find_lowest_energy_conformer(lmethod=xtb)
trimer.print_xyz_file()
from autode import Molecule
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()