EngineHelper
- class optking.opt_helper.EngineHelper(optimization_input, **kwargs)[source]
Bases:
Helper
- Perform an optimization using qcengine to compute properties. Use OptimizationInput to setup
a molecular system
calling compute() will perform a QCEngine calculation according to the provided QCInputSpecification.
calling optimize() after instantiation will perform an automatic optimization returning an OptimizationResult.
>>> import optking >>> import qcengine as qcng
>>> from qcelemental.models import Molecule, OptimizationInput >>> from qcelemental.models.common_models import Model >>> from qcelemental.models.procedures import QCInputSpecification
>>> molecule = Molecule.from_data( ... symbols = ["O", "O", "H", "H"], ... geometry = [ ... 0.0000000000, ... 0.0000000000, ... 0.0000000000, ... -0.0000000000, ... -0.0000000000, ... 2.7463569188, ... 1.3013018774, ... -1.2902977124, ... 2.9574871774, ... -1.3013018774, ... 1.2902977124, ... -0.2111302586, ... ], ... fix_com=True, ... fix_orientation=True, ... )
>>> model = Model(method="hf", basis="sto-3g") >>> input_spec = QCInputSpecification( ... driver="gradient", model=model, keywords={"d_convergence": 1e-7} # QC program options ... )
>>> opt_input = OptimizationInput( ... initial_molecule=molecule, ... input_specification=input_spec, ... keywords={"g_convergence": "GAU_TIGHT", "program": "psi4"}, # optimizer options ... )
>>> opt = optking.EngineHelper(opt_input) >>> # opt_result = opt.optimize() # optimize geometry - no interaction
>>> for step in range(30): ... # Compute one's own energy and gradient ... opt.compute() # process input. Get ready to take a step ... opt.take_step() ... conv = opt.test_convergence() ... if conv is True: ... print("Optimization SUCCESS:") ... break >>> else: ... print("Optimization FAILURE:
“)
>>> json_output = opt.close() # create an unvalidated OptimizationOutput like object >>> E = json_output["energies"][-1]
Methods Summary
from_dict
(d)Construct as far as possible the helper.
optimize
()Creating an EngineHelper and calling optimize() is equivalent to calling the deprecated optimize_qcengine() with an OptimizationInput.
Methods Documentation