2.2. Generators¶
The Generator classes are not meant to be directly accessed by the user. Instead, they are used as components of the UniqueConformer classes.
There are two main generator classes, RDKitGenerator
and CRESTGenerator
, which have roughly the same interface,
but different settings.
All generators accept an instance of one of the UniqueConformers classes upon initiation.
This conformer set is generally expected to be empty, but is not required to be so.
The CREST method combines three separate methods to generate conformers: 1. CREST metadynamics 2. High temperature MD 3. A genetic combinatorial method that extends an existing conformer set. Each of these methods can be used separately, via their additional expert generator classes.
2.2.1. RDKitGenerator¶
This generator fills the conformer set of a molecule, using RDKit to call the ETKDG conformer generation approach, followed by geometry optimization with a specified AMS engine.
-
class
RDKitGenerator
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Machine that generates a set of unique conformers using RDKit
DOI: 10.1021/acs.jcim.5b00654
A simple example of (parallel) use:
>>> from scm.plams import Molecule >>> from scm.plams import init, finish >>> from scm.conformers import UniqueConformersAMS, RDKitGenerator >>> # Set up the molecular data >>> mol = Molecule('mol.xyz') >>> conformers = UniqueConformersAMS() >>> conformers.prepare_state(mol) >>> # Set up PLAMS settings >>> init() >>> # Create the generator and run >>> generator = RDKitGenerator(conformers, nproc=4) >>> generator.generate() >>> finish() >>> # Write the results to file >>> print(conformers) >>> conformers.write()
The default AMS engine used is the GFN1-xTB engine. A different engine can be provided upon initiation.
>>> engine_settings = Settings() >>> engine_settings.ForceField.Type = 'UFF' >>> generator = RDKitGenerator(conformers, engine_settings=engine, nproc=4)
-
__init__
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Initiates an instance of the RDKitGenerator class
conformers
– A UniqueConformers objectengine_settings
– PLAMS Settings object:>>> engine_settings = Settings() >>> engine_settings.DFTB.Model = 'GFN1-xTB'
nproc
– Number of processors to use in totalenergy_threshold
– Maximum accepted energy difference from lowest energy conformer
-
set_number_initial_conformers
(ngeoms=None)¶ Set the number of conformers created by RDKit, before geometry optimization and filtering
ngeoms
– The number of initial conformers created by RDKit. If not provided, this number will be generated based on the number of rotational bonds \(n\): \(3^n*self.settings.nconfs_estimation_factor\)
-
generate
()¶ Generate the conformer set
-
_estimate_runtime
()¶ Estimate the runtime based on the already stored timings for GO
-
_get_family
()¶ Find the names of the family of classes to which self belongs
-
static
_rdkit_call_from_thread
(mol, ngeoms, kwargs, queue)¶ Call RDKits conformer generation in parallel, via PLAMS get_conformations
-
_set_gotimes
(factor=1)¶ Run some geometry optimizations to make a reasonable estimate of the time and iteration
-
are_geometries_local_minima
(molecules)¶ Perform a PES point characterization for the molecules and return a list of booleans indicating whether the geometry is a local minimum or not
-
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
-
estimate_runtime
(factor=1)¶ Provides a reasonable estimate of the runtime, based on several geometry optimizations
factor
– Determines the number of GO optimizations that are performerd. The higher the value, the more accurate the estimate.The number of GOs will be 2*factor*nproc It converges, but generally to a value that is still a bit too high
-
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
-
optimize_and_filter
(geometries, conformers=None, level=None, name='go')¶ Run the geometry optimizations for the provided geometries and add to conformer set
geometries
– List of “math:n numpy arrays containing coordinates (n*(nats,3))level
– The quality level of the geometry optimization convergencename
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
optimize_conformers
(convergence_level, name='go')¶ (Re)-Optimize the conformers currently in the set
convergence_level
– One of the convergence options (‘Normal’, ‘Good’, ‘VeryGood’, ‘Excellent’)name
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
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
-
set_convergence_quality
(level=None)¶ Set the three levels of convergence, based on the middle one
-
set_max_energy
(max_energy)¶ Determines the highest energy a created conformer can have, relative to the most stable one
-
set_optimizer
(optimizer)¶ Change the optimizer of the generator object
optimizer
– ConformerOptimizer object
-
set_preoptimizer
(engine_settings)¶ Set a lower level optimizer, to be used for preoptimization
A selection will be made based on the energies, but the preoptimized geometries will not be used, so as not to rely on the low-level engine too much
-
set_printing_level
(verbose)¶ Set the printing level (verbose is True of False)
-
set_rngseed
(seed)¶ Set a seed for the random number generation
-
static
time_to_timestring
(time)¶ Convert time in seconds to a time string
-
to_json
()¶ Create a json settings object from self.settings
-
write_geometries
(geometries, name='unoptimized', filetype='xyz')¶ Write a set of geometries at any point
-
2.2.2. CRESTGenerator¶
This generator fills the conformer set of a molecule using the CREST method.
-
class
CRESTGenerator
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Machine that generates a set of conformers using the CREST workflow
A simple example of (parallel) use:
>>> from scm.plams import Molecule >>> from scm.plams import init, finish >>> from scm.conformers import UniqueConformersCrest, CRESTGenerator >>> # Set up the molecular data >>> mol = Molecule('mol.xyz') >>> conformers = UniqueConformersCrest() >>> conformers.prepare_state(mol) >>> # Set up PLAMS settings >>> init() >>> # Create the generator and run >>> generator = CRESTGenerator(conformers, nproc=4) >>> generator.generate() >>> finish() >>> # Write the results to file >>> print(conformers) >>> conformers.write()
The default AMS engine used is the GFN1-xTB engine. A different engine can be provided upon initiation.
>>> engine_settings = Settings() >>> engine_settings.ForceField.Type = 'UFF' >>> generator = CRESTGenerator(conformers, engine_settings=engine, nproc=4)
-
__init__
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Initiates an instance of the Optimizer class
conformers
– A UniqueConformers objectengine_settings
– PLAMS Settings object:>>> engine_settings = Settings() >>> engine_settings.DFTB.Model = 'GFN1-xTB'
nproc
– Number of processors to use in totalenergy_threshold
– Maximum accepted energy difference from lowest energy conformer
-
set_optimizer
(optimizer)¶ Change the optimizer of the generator object
optimizer
– ConformerOptimizer object
-
set_printing_level
(verbose)¶ Set the printing level (verbose is True of False)
-
set_shake
(shake=True)¶ Determine if SHAKE will be used
-
set_rngseed
(seed)¶ Set a seed for the random number generation
-
set_convergence_quality
(level=None)¶ Set the three levels of convergence, based on the middle one
-
set_max_energy
(max_energy)¶ Determines the highest energy a created conformer can have, relative to the most stable one
-
generate
()¶ Generate the conformer set
-
_estimate_runtime
()¶ Estimate the runtime based on the already stored timings for GO
-
_set_gotimes
(factor=1)¶ Run some geometry optimizations to make a reasonable estimate of the time and iteration
-
_generate_geometries
(ngeoms)¶ Call RDKit to generate a set of conformers
-
_get_family
()¶ Find the names of the family of classes to which self belongs
-
static
_rdkit_call_from_thread
(mol, ngeoms, kwargs, queue)¶ Call RDKits conformer generation in parallel, via PLAMS get_conformations
-
are_geometries_local_minima
(molecules)¶ Perform a PES point characterization for the molecules and return a list of booleans indicating whether the geometry is a local minimum or not
-
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
-
estimate_runtime
(factor=1)¶ Provides a reasonable estimate of the runtime, based on several geometry optimizations
factor
– Determines the number of GO optimizations that are performerd. The higher the value, the more accurate the estimate.The number of GOs will be 2*factor*nproc It converges, but generally to a value that is still a bit too high
-
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
-
optimize_and_filter
(geometries, conformers=None, level=None, name='go')¶ Run the geometry optimizations for the provided geometries and add to conformer set
geometries
– List of “math:n numpy arrays containing coordinates (n*(nats,3))level
– The quality level of the geometry optimization convergencename
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
optimize_conformers
(convergence_level, name='go')¶ (Re)-Optimize the conformers currently in the set
convergence_level
– One of the convergence options (‘Normal’, ‘Good’, ‘VeryGood’, ‘Excellent’)name
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
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
-
set_preoptimizer
(engine_settings)¶ Set a lower level optimizer, to be used for preoptimization
A selection will be made based on the energies, but the preoptimized geometries will not be used, so as not to rely on the low-level engine too much
-
static
time_to_timestring
(time)¶ Convert time in seconds to a time string
-
to_json
()¶ Create a json settings object from self.settings
-
2.2.3. MetadynamicsGenerator¶
This generator fills the conformer set of a molecule using only CREST metadynanics, followed by geometry optimization of the stored shapshots (step 1 of the CREST approach).
-
class
MetadynamicsGenerator
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Machine that produces a set of conformers from CREST metadynamics simulations
A simple example of (parallel) use:
>>> from scm.plams import Molecule >>> from scm.plams import init, finish >>> from scm.conformers import UniqueConformersCrest, MetadynamicsGenerator >>> # Set up the molecular data >>> mol = Molecule('mol.xyz') >>> conformers = UniqueConformersCrest() >>> conformers.prepare_state(mol) >>> # Set up PLAMS settings >>> init() >>> # Create the generator and run >>> generator = MetadynamicsGenerator(conformers, nproc=4) >>> generator.generate() >>> finish() >>> # Write the results to file >>> print(conformers) >>> conformers.write()
The default AMS engine used is the GFN1-xTB engine. A different engine can be provided upon initiation.
>>> engine_settings = Settings() >>> engine_settings.ForceField.Type = 'UFF' >>> generator = MetadynamicsGenerator(conformers, engine_settings=engine, nproc=4)
-
__init__
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Initiates an instance of the MetadynamicsGenerator class
conformers
– A UniqueConformers objectengine_settings
– PLAMS Settings object:>>> engine_settings = Settings() >>> engine_settings.DFTB.Model = 'GFN1-xTB'
nproc
– Number of processors to use in totalenergy_threshold
– Maximum accepted energy difference from lowest energy conformer
-
set_shake
(shake=True)¶ Determine if SHAKE will be used
-
set_convergence_quality
(level=None)¶ Set the three levels of convergence, based on the middle one
-
generate
()¶ Generate the conformer set
-
optimize_and_filter
(geometries)¶ Run dual-level geometry optimizations for the provided geometries and add to conformer set
geometries
– List of “math:n numpy arrays containing coordinates (n*(nats,3))
-
_finalize_settings
()¶ Get the number of steps
-
_rerun_failed_mtdjobs
(results, settings_list, multijob)¶ If a t large number of MD jobs failed, rerun with more lenient settings
Note: Also changes the settings in subsequent runs
-
_estimate_runtime
()¶ Estimate the runtime based on the already stored timings for GO
-
_generate_geometries
(ngeoms)¶ Call RDKit to generate a set of conformers
-
_get_family
()¶ Find the names of the family of classes to which self belongs
-
_get_timestep
()¶ Get the timestep out of the multiple parts of the input where it can be
-
_md_time_from_flexibility
(mu, shift=8, tmin=5.0, tmax=200.0)¶ Use the flexibility factor to compute the metadynamics time (in ps)
mu
– Crest flexibility factorshift
– A shift for the number of atoms, as found in the Crest code
- Note: This implementation is based on the Crest code, not on the paper.
According to the paper, the MTD time should be computed as: t_orig = 0.1*(N_eff + 0.1*N_eff**2) And the shift variable would equal 0
-
static
_rdkit_call_from_thread
(mol, ngeoms, kwargs, queue)¶ Call RDKits conformer generation in parallel, via PLAMS get_conformations
-
_run_job
(name='md')¶ Run all jobs (in parallel) and get results
-
_set_constraints
()¶ Set up the MD constraints based on the input
Iin some cases they can remain constraints, in others they have to be SHAKE or restraints
-
_set_gotimes
(factor=1)¶ Run some geometry optimizations to make a reasonable estimate of the time and iteration
-
_set_timestep
(timestep)¶ Set the timestep effectively
-
are_geometries_local_minima
(molecules)¶ Perform a PES point characterization for the molecules and return a list of booleans indicating whether the geometry is a local minimum or not
-
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
-
estimate_runtime
(factor=1)¶ Provides a reasonable estimate of the runtime, based on several geometry optimizations
factor
– Determines the number of GO optimizations that are performerd. The higher the value, the more accurate the estimate.The number of GOs will be 2*factor*nproc It converges, but generally to a value that is still a bit too high
-
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
-
optimize_conformers
(convergence_level, name='go')¶ (Re)-Optimize the conformers currently in the set
convergence_level
– One of the convergence options (‘Normal’, ‘Good’, ‘VeryGood’, ‘Excellent’)name
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
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
-
set_max_energy
(max_energy)¶ Determines the highest energy a created conformer can have, relative to the most stable one
-
set_optimizer
(optimizer)¶ Change the optimizer of the generator object
optimizer
– ConformerOptimizer object
-
set_preoptimizer
(engine_settings)¶ Set a lower level optimizer, to be used for preoptimization
A selection will be made based on the energies, but the preoptimized geometries will not be used, so as not to rely on the low-level engine too much
-
set_printing_level
(verbose)¶ Set the printing level (verbose is True of False)
-
set_rngseed
(seed)¶ Set a seed for the random number generation
-
static
time_to_timestring
(time)¶ Convert time in seconds to a time string
-
to_json
()¶ Create a json settings object from self.settings
-
2.2.4. MDExpander¶
This generator fills the conformer set of a molecule using only regular molecular dynamics, followed by geometry optimization of the stored shapshots (step 2 of the CREST approach).
-
class
MDExpander
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Machine that produces a set of conformers from molecular dynamics simulations (Step 2 of CREST approach)
A simple example of (parallel) use:
>>> from scm.plams import Molecule >>> from scm.plams import init, finish >>> from scm.conformers import UniqueConformersCrest, MDExpander >>> # Set up the molecular data >>> mol = Molecule('mol.xyz') >>> conformers = UniqueConformersCrest() >>> conformers.prepare_state(mol) >>> # Set up PLAMS settings >>> init() >>> # Create the generator and run >>> generator = MDExpander(conformers, nproc=4) >>> generator.generate() >>> finish() >>> # Write the results to file >>> print(conformers) >>> conformers.write()
The default AMS engine used is the GFN1-xTB engine. A different engine can be provided upon initiation.
>>> engine_settings = Settings() >>> engine_settings.ForceField.Type = 'UFF' >>> generator = MDExpander(conformers, engine_settings=engine, nproc=4)
-
__init__
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Initiates an instance of the MDExpander 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 MD simulationsenergy_threshold
– Maximum accepted energy difference from lowest energy conformer
-
set_shake
(shake=True)¶ Determine if SHAKE will be used
-
set_number_of_identical_mdruns
()¶ Sets the number of MD runs of each temperature (default=1)
-
set_number_of_starting_geometries
()¶ Set the number of conformers used to start the MD runs from (default=4)
-
generate
()¶ Generate the conformer set
-
_finalize_settings
()¶ Add the number of steps and settings
See: DOI: 10.1039/c9cp06869d
-
_estimate_runtime
()¶ Estimate the runtime based on the already stored timings for GO
-
_generate_geometries
(ngeoms)¶ Call RDKit to generate a set of conformers
-
_get_family
()¶ Find the names of the family of classes to which self belongs
-
_get_timestep
()¶ Get the timestep out of the multiple parts of the input where it can be
-
_md_time_from_flexibility
(mu, shift=8, tmin=5.0, tmax=200.0)¶ Use the flexibility factor to compute the metadynamics time (in ps)
mu
– Crest flexibility factorshift
– A shift for the number of atoms, as found in the Crest code
- Note: This implementation is based on the Crest code, not on the paper.
According to the paper, the MTD time should be computed as: t_orig = 0.1*(N_eff + 0.1*N_eff**2) And the shift variable would equal 0
-
static
_rdkit_call_from_thread
(mol, ngeoms, kwargs, queue)¶ Call RDKits conformer generation in parallel, via PLAMS get_conformations
-
_run_job
(name='md')¶ Run all jobs (in parallel) and get results
-
_set_constraints
()¶ Set up the MD constraints based on the input
Iin some cases they can remain constraints, in others they have to be SHAKE or restraints
-
_set_gotimes
(factor=1)¶ Run some geometry optimizations to make a reasonable estimate of the time and iteration
-
_set_timestep
(timestep)¶ Set the timestep effectively
-
are_geometries_local_minima
(molecules)¶ Perform a PES point characterization for the molecules and return a list of booleans indicating whether the geometry is a local minimum or not
-
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
-
estimate_runtime
(factor=1)¶ Provides a reasonable estimate of the runtime, based on several geometry optimizations
factor
– Determines the number of GO optimizations that are performerd. The higher the value, the more accurate the estimate.The number of GOs will be 2*factor*nproc It converges, but generally to a value that is still a bit too high
-
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
-
optimize_and_filter
(geometries, conformers=None, level=None, name='go')¶ Run the geometry optimizations for the provided geometries and add to conformer set
geometries
– List of “math:n numpy arrays containing coordinates (n*(nats,3))level
– The quality level of the geometry optimization convergencename
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
optimize_conformers
(convergence_level, name='go')¶ (Re)-Optimize the conformers currently in the set
convergence_level
– One of the convergence options (‘Normal’, ‘Good’, ‘VeryGood’, ‘Excellent’)name
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
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
-
set_convergence_quality
(level=None)¶ Set the three levels of convergence, based on the middle one
-
set_max_energy
(max_energy)¶ Determines the highest energy a created conformer can have, relative to the most stable one
-
set_optimizer
(optimizer)¶ Change the optimizer of the generator object
optimizer
– ConformerOptimizer object
-
set_preoptimizer
(engine_settings)¶ Set a lower level optimizer, to be used for preoptimization
A selection will be made based on the energies, but the preoptimized geometries will not be used, so as not to rely on the low-level engine too much
-
set_printing_level
(verbose)¶ Set the printing level (verbose is True of False)
-
set_rngseed
(seed)¶ Set a seed for the random number generation
-
static
time_to_timestring
(time)¶ Convert time in seconds to a time string
-
to_json
()¶ Create a json settings object from self.settings
-
2.2.5. GCExpander¶
This generator extends a conformer set of a molecule using only the CREST genetic combinatorial method (GC), followed by geometry optimization of the stored shapshots (step 3 of the CREST approach).
-
class
GCExpander
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Machine that extends a set of conformers using genetic structure crossing
DOI: 10.1002/anie.201708266 (Supporting Information)
A simple example of (parallel) use:
>>> from scm.plams import Molecule >>> from scm.plams import init, finish >>> from scm.conformers import UniqueConformersCrest, GCExpander >>> # Set up the molecular data >>> mol = Molecule('mol.xyz') >>> conformers = UniqueConformersCrest() >>> conformers.prepare_state(mol) >>> # Set up PLAMS settings >>> init() >>> # Create the generator and run >>> generator = GCExpander(conformers, nproc=1) >>> generator.generate() >>> finish() >>> # Write the results to file >>> print(conformers) >>> conformers.write()
The default AMS engine used is the GFN1-xTB engine. A different engine can be provided upon initiation.
>>> engine_settings = Settings() >>> engine_settings.ForceField.Type = 'UFF' >>> generator = GCExpander(conformers, engine_settings=engine, nproc=1)
-
__init__
(conformers=None, engine_settings=None, nproc=1, energy_threshold=None)¶ Initiates an instance of the GCExpander class
conformers
– A UniqueConformers objectengine_settings
– PLAMS Settings object:>>> engine_settings = Settings() >>> engine_settings.DFTB.Model = 'GFN1-xTB'
nproc
– Number of processors to use in totalenergy_threshold
– Maximum accepted energy difference from lowest energy conformer
-
generate
()¶ Generate a conformer set, based on the CREST method
-
set_maxgeoms
(mtd_generator=None)¶ Set the maximum number of geometries that can be produced, based on the molecules flexibility
-
determine_maxgeoms
(mtd_generator=None)¶ Determine the maximum number of geometries that can be produced, based on the molecules flexibility
-
get_rmsd_time
()¶ Get the time it takes to compute a single rmsd
-
estimate_gctime
(rmsd_time=None, nconformers=None, mtd_generator=None)¶ Provides a reasonable estimate of the runtime, based on the number of RMSDs to be computed
nconformers
– A likely estimate for the number of conformers provided to the GCExpander.A new large set will be created from all pairs of these conformers, and that set will be capped at maxgeoms. For the new large set, pairwise RMSD values are then computed. We assume the latter is always the bottleneck.
-
_get_rmsds
(geometries, row_indices=None, col_indices=None, no_first_column=False)¶ Get the pairwise RMSD values, in order to prune
rmsds
– The RMSD values for each geometry to the first reference geometry (can be used to save time)
-
_get_rmsds_double_loop
(geometries, row_indices=None, col_indices=None, no_first_column=False)¶ Get the pairwise RMSD values, in order to prune, using double loop over rowns and columns
rmsds
– The RMSD values for each geometry to the first reference geometry (can be used to save time)
Note: Alternative to _get_rmsds(). Currently not used. Load-balancing is less good than _get_rmsds()
-
_get_rmsds_parallel
(geometries, no_first_column=False)¶ Run _prune_geometries in a parallel fashion
-
_estimate_runtime
()¶ Estimate the runtime based on the already stored timings for GO
-
_generate_geometries
(ngeoms)¶ Call RDKit to generate a set of conformers
-
_get_family
()¶ Find the names of the family of classes to which self belongs
-
static
_rdkit_call_from_thread
(mol, ngeoms, kwargs, queue)¶ Call RDKits conformer generation in parallel, via PLAMS get_conformations
-
_set_gotimes
(factor=1)¶ Run some geometry optimizations to make a reasonable estimate of the time and iteration
-
are_geometries_local_minima
(molecules)¶ Perform a PES point characterization for the molecules and return a list of booleans indicating whether the geometry is a local minimum or not
-
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
-
estimate_runtime
(factor=1)¶ Provides a reasonable estimate of the runtime, based on several geometry optimizations
factor
– Determines the number of GO optimizations that are performerd. The higher the value, the more accurate the estimate.The number of GOs will be 2*factor*nproc It converges, but generally to a value that is still a bit too high
-
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
-
optimize_and_filter
(geometries, conformers=None, level=None, name='go')¶ Run the geometry optimizations for the provided geometries and add to conformer set
geometries
– List of “math:n numpy arrays containing coordinates (n*(nats,3))level
– The quality level of the geometry optimization convergencename
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
optimize_conformers
(convergence_level, name='go')¶ (Re)-Optimize the conformers currently in the set
convergence_level
– One of the convergence options (‘Normal’, ‘Good’, ‘VeryGood’, ‘Excellent’)name
– The base name of the PLAMS directories in which the geometry optimizations are performed
-
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
-
set_convergence_quality
(level=None)¶ Set the three levels of convergence, based on the middle one
-
set_max_energy
(max_energy)¶ Determines the highest energy a created conformer can have, relative to the most stable one
-
set_optimizer
(optimizer)¶ Change the optimizer of the generator object
optimizer
– ConformerOptimizer object
-
set_preoptimizer
(engine_settings)¶ Set a lower level optimizer, to be used for preoptimization
A selection will be made based on the energies, but the preoptimized geometries will not be used, so as not to rely on the low-level engine too much
-
set_printing_level
(verbose)¶ Set the printing level (verbose is True of False)
-
set_rngseed
(seed)¶ Set a seed for the random number generation
-
static
time_to_timestring
(time)¶ Convert time in seconds to a time string
-
to_json
()¶ Create a json settings object from self.settings
-