} 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) h_atom.translate(vector) # Set up and run the calculation calc = Calculation(name=f'H2O_scan_{r:.2f}', molecule=water, method=orca, keywords=keywords) calc.run() # Get the potential energy from the calculation energy = calc.get_energy() energies.append(energy)
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.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) sp.run() sp_energies.append(sp.get_energy()) # Set up the constrained optimisation calculation where the distance
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()