def test_unique_confs_none(): conf1 = Conformer() conf1.energy = 0.1 # Conformer with energy just below the threshold conf2 = Conformer() conf2.energy = 0.1 + (0.9 / Constants.ha2kJmol) unique_confs = get_unique_confs(conformers=[conf1, conf2], energy_threshold_kj=1) assert len(unique_confs) == 1 # If the energy is above the threshold there should be two unique # conformers conf2.energy += 0.2 / Constants.ha2kJmol unique_confs = get_unique_confs(conformers=[conf1, conf2], energy_threshold_kj=1) assert len(unique_confs) == 2
def find_lowest_energy_conformer(self, lmethod=None, hmethod=None): """ For a molecule object find the lowest conformer in energy and set the molecule.atoms and molecule.energy Arguments: lmethod (autode.wrappers.ElectronicStructureMethod): hmethod (autode.wrappers.ElectronicStructureMethod): """ logger.info('Finding lowest energy conformer') if self.n_atoms <= 2: logger.warning('Cannot have conformers of a species with 2 atoms ' 'or fewer') return None if lmethod is None: logger.info('Getting the default low level method') lmethod = get_lmethod() methods.add('Low energy conformers located with the') self._generate_conformers() # For all generated conformers optimise with the low level of theory method_string = f'and optimised using {lmethod.name}' if hmethod is not None: method_string += f' then with {hmethod.name}' methods.add(f'{method_string}.') for conformer in self.conformers: conformer.optimise(lmethod) # Strip conformers that are similar based on an energy criteria or # don't have an energy self.conformers = get_unique_confs(conformers=self.conformers) if hmethod is not None: # Re-evaluate the energy of all the conformers with the higher # level of theory for conformer in self.conformers: if Config.hmethod_sp_conformers: assert hmethod.keywords.low_sp is not None conformer.single_point(hmethod) else: # Otherwise run a full optimisation conformer.optimise(hmethod) self._set_lowest_energy_conformer() logger.info(f'Lowest energy conformer found. E = {self.energy}') return None
def test_unique_confs(): conf1 = Conformer() conf2 = Conformer() conf3 = Conformer() # Set two energies the same and leave one as none.. conf1.energy = 1 conf2.energy = 1 unique_confs = get_unique_confs(conformers=[conf1, conf2, conf3]) assert len(unique_confs) == 1 assert type(unique_confs[0]) is Conformer assert unique_confs[0].energy == 1
def find_lowest_energy_conformer(self, lmethod=None, hmethod=None): """ For a molecule object find the lowest conformer in energy and set the molecule.atoms and molecule.energy Arguments: lmethod (autode.wrappers.ElectronicStructureMethod): hmethod (autode.wrappers.ElectronicStructureMethod): """ logger.info('Finding lowest energy conformer') if self.n_atoms <= 2: logger.warning('Cannot have conformers of a species with 2 atoms ' 'or fewer') return None if lmethod is None: logger.info('Getting the default low level method') lmethod = get_lmethod() try: self._generate_conformers() except NotImplementedError: logger.error('Could not generate conformers. generate_conformers()' ' not implemented') return None # For all generated conformers optimise with the low level of theory for conformer in self.conformers: conformer.optimise(lmethod) # Strip conformers that are similar based on an energy criteria or # don't have an energy self.conformers = get_unique_confs(conformers=self.conformers) if hmethod is not None: # Re-optimise all the conformers with the higher level of theory # to get more accurate energies for conformer in self.conformers: conformer.optimise(hmethod) self._set_lowest_energy_conformer() logger.info(f'Lowest energy conformer found. E = {self.energy}') return None