2.3. ConformerOptimizer

The ConformerOptimizer is not meant to be directly called by the user, but exists as a component of the Generator classes. It is also used under the hood by the UniqueConformers.optimize() method.

This class organizes parallel geometry optimizations for different geometries of a single molecule

class ConformerOptimizer(mol, engine_settings=None, nproc=1, maxjobs=1)

Machine that can optimize the geometry of a set of structures

A simple example of (parallel) use:

>>> from scm.plams import Molecule
>>> from scm.plams import init, finish
>>> from scm.conformers import UniqueConformersCrest, ConformerOptimizer

>>> # Set up the molecular data
>>> mol = Molecule('mol.xyz')
>>> conformers = UniqueConformersCrest()
>>> conformers.prepare_state(mol)

>>> # Set up PLAMS settings
>>> init()

>>> # Create the optimizer and run
>>> optimizer = ConformerOptimizer(mol, nproc=1, maxjobs=1)
>>> geometries = [mol.as_array()]
>>> geometries, energies = optimizer.optimize_geometries(geometries, level='ams')

>>> finish()

The default AMS engine used is the UFF engine. A different engine can be provided upon initiation.

>>> engine_settings = Settings()
>>> engine_settings.DFTB.Model = 'GFN1-xTB'
>>> optimizer = ConformerOptimizer(geometries, engine_settings=engine, nproc=1, maxjobs=12)
__init__(mol, engine_settings=None, nproc=1, maxjobs=1)

Initiates an instance of the Optimizer class

  • engine_settings – PLAMS Settings object:
    engine_settings = Settings() engine_settings.DFTB.Model = ‘GFN1-xTB’
  • nproc – Number of processors used for each single call to AMS
  • maxjobs – Maximum number of parallel AMS processes
set_atom_types()

In case the GAFF ForceField will be called, make sure atom-typing happens only once

FIXME: This also requires a patch file!

set_jobrunner(jobrunner)

Set a jobrunner to organize parallelization

  • jobrunner – Instance of the PLAMS Jobrunner class
set_cleaning_preference(keep=None)

Sets the preferences for the files saved to disc

  • keep – None or ‘all’. The former will clean PLAMS folders of all files after runtime, the latter will leave all files as they are. See PLAMS for more details.
keep_ams_running(keep=True)

Technical setting for a set of (serial) geometry optimizations

  • keep – Each of the parallel processes will most likely be passed multiple geometries. If keep=True, AMS will be kept running in the background, and geometries will be passed via a pipe. If keep=False, each geometry optimization will start a new AMS process.
optimize_geometries(geometries, level='ams', name='go')

Optimize a set of geometries

  • geometries – An iterator over molecular coordinates (matching self.mol)
optimize_molecules(molecules, level='ams', name='go')

Optimize a set of molecules (they have to represent different conformers of the same molecule)