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)
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)
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)
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.calculation import Calculation from autode.methods import ORCA import matplotlib.pyplot as plt import numpy as np # Initialise the electronic structure method and a list of different # single point energy keywords orca = ORCA() keywords_list = { 'PBE': SinglePointKeywords(['PBE', 'def2-SVP']), 'PBE0': SinglePointKeywords(['PBE0', 'def2-SVP']), 'B3LYP': SinglePointKeywords(['B3LYP', 'def2-SVP']) } water = Molecule(name='H2O', smiles='O') # For the three different DFT functionals calculate the PES and plot the line for dft_name, keywords in keywords_list.items(): # Create arrays for OH distances and their energies rs = np.linspace(0.65, 2.0, num=15) energies = [] # Calculate the energy array for r in rs: o_atom, h_atom = water.atoms[:2] curr_r = water.distance(0, 1) vector = (h_atom.coord - o_atom.coord) * (r / curr_r - 1)
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()
from autode import Molecule from autode.pes.pes_1d import PES1d from autode.methods import XTB import numpy as np # Initialise the electronic structure method (XTB) and water molecule xtb = XTB() water = Molecule(name='H2O', smiles='O') # Initialise a potential energy surface where the reactant and product is # the same. A product is required to call pes.products_made() to check products # are generated somewhere on the surface via graph isomorphism pes = PES1d(reactant=water, product=water, rs=np.linspace(0.65, 2.0, num=20), r_idxs=(0, 1)) # Calculate the potential energy surface at the XTB level optimising # all degrees of freedom other than the O-H distance pes.calculate(name='OH_PES', method=xtb, keywords=xtb.keywords.low_opt) # Print the r values and energies for i in range(pes.n_points): print(f'{pes.rs[i, 0]:.3f} {pes.species[i].energy:.4f}')
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.distance(1, 2), (1, 3): vaskas.distance(1, 3), (1, 4): vaskas.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()