Source code for scine_puffin.jobs.scine_geometry_optimization

# -*- coding: utf-8 -*-
__copyright__ = """ This code is licensed under the 3-clause BSD license.
Copyright ETH Zurich, Laboratory of Physical Chemistry, Reiher Group.
See LICENSE.txt for details.
"""

from scine_puffin.config import Configuration
from .templates.job import calculation_context, job_configuration_wrapper
from .templates.scine_optimization_job import OptimizationJob


[docs]class ScineGeometryOptimization(OptimizationJob): """ A job optimizing the geometry of a given structure, in search of a local minimum on the potential energy surface. Optimizing a given structure's geometry, generating a new minimum energy structure, if successful. **Order Name** ``scine_geometry_optimization`` **Optional Settings** Optional settings are read from the ``settings`` field, which is part of any ``Calculation`` stored in a SCINE Database. Possible settings for this job are: All settings recognized by ReaDuct's geometry optimization task. Common examples are: optimizer :: str The name of the optimizer to be used, e.g. 'bfgs', 'lbfgs', 'nr' or 'sd'. convergence_max_iterations :: int The maximum number of geometry optimization cycles. convergence_delta_value :: float The convergence criterion for the electronic energy difference between two steps. convergence_gradient_max_coefficient :: float The convergence criterion for the maximum absolute gradient. contribution. convergence_step_rms :: float The convergence criterion for root mean square of the geometric gradient. convergence_step_max_coefficient :: float The convergence criterion for the maximum absolute coefficient in the last step taken in the geometry optimization. convergence_gradient_rms :: float The convergence criterion for root mean square of the last step taken in the geometry optimization. For a complete list see the `ReaDuct manual <https://scine.ethz.ch/static/download/readuct_manual.pdf>`_ All settings that are recognized by the SCF program chosen. Common examples are: max_scf_iterations :: int The number of allowed SCF cycles until convergence. **Required Packages** - SCINE: Database (present by default) - SCINE: Readuct (present by default) - SCINE: Utils (present by default) - A program implementing the SCINE Calculator interface, e.g. Sparrow **Generated Data** If successful the following data will be generated and added to the database: Structures A new minimum energy structure. Properties The ``electronic_energy`` associated with the new structure. """ def __init__(self): super().__init__() self.name = "Scine Geometry Optimization" @job_configuration_wrapper def run(self, manager, calculation, config: Configuration) -> bool: import scine_database as db import scine_readuct as readuct # preprocessing of structure structure = db.Structure(calculation.get_structures()[0], self._structures) settings_manager, program_helper = self.create_helpers(structure) try: new_label = self.determine_new_label(structure) except Exception: return False # actual calculation with calculation_context(self): systems, keys = settings_manager.prepare_readuct_task( structure, calculation, calculation.get_settings(), config["resources"] ) if program_helper is not None: program_helper.calculation_preprocessing(systems[keys[0]], calculation.get_settings()) systems, success = readuct.run_opt_task(systems, keys, **settings_manager.task_settings) self.optimization_postprocessing( success, systems, keys, structure, new_label, program_helper ) return self.postprocess_calculation_context()