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=None, engine_settings=None, nproc=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=4) >>> geometries = [mol.as_array()] >>> geometries, energies = optimizer.optimize_geometries(geometries, level='good') >>> 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=4)
- __init__(mol=None, engine_settings=None, nproc=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 to use in total for the optimizations
- property last_timings¶
Stores the timings of the last optimization call performed
- 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_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=None, name='go', watch=True)¶
Optimize a set of geometries
geometries
– An iterator over molecular coordinates (matching self.mol)
- optimize_molecules(molecules, level=None, name='go', watch=True)¶
Optimize a set of molecules (they have to represent different conformers of the same molecule)
- geometry_writer(results, num_jobs, event, t)¶
Writes the optimized geometries to file during the optimization process
- convert_key_to_camelcase(key)¶
Convert the key to json format
- convert_key_to_underscore_case(key)¶
Revert back to original value, and see if it works
- convert_keys_to_camelcase(settings)¶
Convert all keys to CamelCase (except the last json ones like _type, _default, etc)
- convert_keys_to_underscore_case(settings)¶
Revert all the keys to the Python settings
- static create_json_entry(typename, value, unique=True, choices=None, include=None)¶
Create a single entry
- get_json_settings()¶
Convert the settings object in self to a json style settings object
- handle_input(inp, names, handle_nested_objects)¶
Get the settings from the input, convert to underscore case, and insert them
inp
- Input objectnames
- The names (self._name) of all the classes in the family of classes of selfhandle_nested_objects
- Boolean specifying if there can be encapsulated objects of the same family,for which settings are needed
- pass_settings(settings, encaps_settings=False)¶
Set the settings object into self
- read_settings(inp, names)¶
Get the settings for the conformers object from the input in the required format
inp
- Input objectnames
- The classnames of all the classes in the family of classes of obj
Note: This is complicated by the fact that a single family of classes may be spread over multiple input blocks.
- set_blocknames(blocknames)¶
Provide the relevant blocknames for the family of classes
blocknames
– List of strings representing the input blocks relevant for this family of classes
- to_json()¶
Create a json settings object from self.settings