Source code for scm.input_classes.engines.ase

from __future__ import annotations
from pathlib import Path
from typing import Iterable, Literal, Sequence
from scm.pisa.block import DriverBlock,EngineBlock,FixedBlock,FreeBlock,InputBlock
from scm.pisa.key import BoolKey,FloatKey,FloatListKey,IntKey,IntListKey,MultipleChoiceKey,PathStringKey,StringKey,BoolType

[docs]class ASE(EngineBlock): r""" :ivar AllASEResults: Return all ASE results that are not also part of AMSResults. These values can be found in ase.rkf without any unit conversions. :vartype AllASEResults: BoolType | BoolKey :ivar ArgumentsFromFile: Specify the path to a yaml or python file defining the arguments to the function or class defined in `Calculator` or `Callable`. :vartype ArgumentsFromFile: str | Path | StringKey :ivar File: Specify the path to a Python file. This file should contain a callable (e.g. function or class) named `get_calculator` that returns an ASE Calculator and uses the arguments defined in `Arguments` or `ArgumentsFromFile`. You can find examples of suitable calculator.py files (possibly requiring additional installations of packages) in ``$AMSHOME/scripting/scm/external_engines/backends``. :vartype File: str | Path | StringKey :ivar Import: Specify the module and name of a Calculator installed in the used Python stack. This is case sensitive. Builtin ASE examples: ase.calculators.emt.EMT Other examples requiring special installations: scm.external_engines.backends._psi4.calculator.get_calculator scm.external_engines.backends._tblite.calculator.get_calculator scm.external_engines.backends._mace.calculator.get_calculator :vartype Import: str | StringKey :ivar Performance: Choose which option most accurately corresponds to how long a calculation with the calculator takes. :vartype Performance: Literal["Fast", "ForceField", "DFTB", "DFT", "Slow"] :ivar Results: The data of this key in the results dictionary of the Calculator is stored in the engine rkf. Multiple results keys can be specified. This is case sensitive. :vartype Results: str | StringKey :ivar Type: Select how to specify which calculator to use. :vartype Type: Literal["File", "Import"] :ivar Arguments: Arguments to the function or constructor initializing the Calculator. Give each argument on a separate line. This is case sensitive. Note: Do not perform any Python imports here. Only use Python builtin types. Arguments containing paths must be absolute. Example: cutoff = 3.14 title = 'my_string' my_list_arg = [1, 4, 5] options_dictionary = {'key1': 11, 'key2': 22} my_boolean_flag = True my_path = '/this/must/be/an/absolute/path' :vartype Arguments: str | Sequence[str] | FreeBlock :ivar Python: Specify which Python to run. :vartype Python: ASE._Python """
[docs] class _Arguments(FreeBlock): r""" Arguments to the function or constructor initializing the Calculator. Give each argument on a separate line. This is case sensitive. Note: Do not perform any Python imports here. Only use Python builtin types. Arguments containing paths must be absolute. Example: cutoff = 3.14 title = 'my_string' my_list_arg = [1, 4, 5] options_dictionary = {'key1': 11, 'key2': 22} my_boolean_flag = True my_path = '/this/must/be/an/absolute/path' """ def __post_init__(self): pass
[docs] class _Python(FixedBlock): r""" Specify which Python to run. :ivar Conda: Name of conda environment. Only used when ``Python%Type = Conda``. You may also define the conda environment setting the environment variable SCM_ASE_PYTHON_TYPE=conda:name-of-environment. If the value is an absolute path it will be executed with ``conda run -p``, otherwise it is assumed to be a name of a conda environment that can be executed with ``conda run -n``. The ``conda`` executable shell script must exist on your ``$PATH``. To see available environments, run ``conda env list``. :vartype Conda: str | StringKey :ivar Type: Type of Python environment. If ``Conda``, set the name or path of the environment under ``Python%Conda``. If ``Current``, the default ``python`` (or ``python.exe`` on Windows) command will be used. :vartype Type: Literal["amspython", "Conda", "Current"] """ def __post_init__(self): self.Conda: str | StringKey = StringKey(name='Conda', comment='Name of conda environment. Only used when ``Python%Type = Conda``. You may also define the conda environment setting the environment variable SCM_ASE_PYTHON_TYPE=conda:name-of-environment.\n\nIf the value is an absolute path it will be executed with ``conda run -p``, otherwise it is assumed to be a name of a conda environment that can be executed with ``conda run -n``.\n\nThe ``conda`` executable shell script must exist on your ``$PATH``. To see available environments, run ``conda env list``.', default='') self.Type: Literal["amspython", "Conda", "Current"] = MultipleChoiceKey(name='Type', comment='Type of Python environment. If ``Conda``, set the name or path of the environment under ``Python%Conda``. If ``Current``, the default ``python`` (or ``python.exe`` on Windows) command will be used.', gui_name='Python environment:', default='amspython', choices=['amspython', 'Conda', 'Current'])
def __post_init__(self): self.AllASEResults: BoolType | BoolKey = BoolKey(name='AllASEResults', comment='Return all ASE results that are not also part of AMSResults. These values can be found in ase.rkf without any unit conversions.', gui_name='All ASE results', default=True) self.ArgumentsFromFile: str | Path | StringKey = PathStringKey(name='ArgumentsFromFile', comment='Specify the path to a yaml or python file defining the arguments to the function or class defined in `Calculator` or `Callable`.', default='', ispath=True) self.File: str | Path | StringKey = PathStringKey(name='File', comment='Specify the path to a Python file. This file should contain a callable (e.g. function or class) named `get_calculator` that returns an ASE Calculator and uses the arguments defined in `Arguments` or `ArgumentsFromFile`.\n\nYou can find examples of suitable calculator.py files (possibly requiring additional installations of packages) in ``$AMSHOME/scripting/scm/external_engines/backends``.', default='', ispath=True) self.Import: str | StringKey = StringKey(name='Import', comment='Specify the module and name of a Calculator installed in the used Python stack. This is case sensitive.\n\nBuiltin ASE examples:\nase.calculators.emt.EMT\n\nOther examples requiring special installations:\nscm.external_engines.backends._psi4.calculator.get_calculator\nscm.external_engines.backends._tblite.calculator.get_calculator\nscm.external_engines.backends._mace.calculator.get_calculator', default='') self.Performance: Literal["Fast", "ForceField", "DFTB", "DFT", "Slow"] = MultipleChoiceKey(name='Performance', comment='Choose which option most accurately corresponds to how long a calculation with the calculator takes.', default='DFTB', choices=['Fast', 'ForceField', 'DFTB', 'DFT', 'Slow']) self.Results: str | StringKey = StringKey(name='Results', comment='The data of this key in the results dictionary of the Calculator is stored in the engine rkf. Multiple results keys can be specified. This is case sensitive.', unique=False) self.Type: Literal["File", "Import"] = MultipleChoiceKey(name='Type', comment='Select how to specify which calculator to use.', gui_name='Calculator from:', default='File', choices=['File', 'Import']) self.Arguments: str | Sequence[str] | FreeBlock = self._Arguments(name='Arguments', comment="Arguments to the function or constructor initializing the Calculator. Give each argument on a separate line. This is case sensitive.\n\nNote: Do not perform any Python imports here. Only use Python builtin types. Arguments containing paths must be absolute. \n\nExample:\ncutoff = 3.14\ntitle = 'my_string'\nmy_list_arg = [1, 4, 5]\noptions_dictionary = {'key1': 11, 'key2': 22}\nmy_boolean_flag = True\nmy_path = '/this/must/be/an/absolute/path'", gui_type='-height 5') self.Python: ASE._Python = self._Python(name='Python', comment='Specify which Python to run.')