File: calculators.rst

package info (click to toggle)
python-ase 3.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (284 lines) | stat: -rw-r--r-- 12,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
.. module:: ase.calculators
   :synopsis: Energy, force and stress calculators.

.. _calculators:

===========
Calculators
===========

For ASE, a calculator is a black box that can take atomic numbers and
atomic positions from an :class:`~ase.Atoms` object and calculate the
energy and forces and sometimes also stresses.

In order to calculate forces and energies, you need to attach a
calculator object to your atoms object:

>>> atoms = read('molecule.xyz')
>>> e = atoms.get_potential_energy()  # doctest: IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jjmo/ase/atoms/ase.py", line 399, in get_potential_energy
    raise RuntimeError('Atoms object has no calculator.')
RuntimeError: Atoms object has no calculator.
>>> from ase.calculators.abinit import Abinit
>>> calc = Abinit(...)
>>> atoms.calc = calc
>>> e = atoms.get_potential_energy()
>>> print(e)
-42.0

Here we attached
an instance of the :mod:`ase.calculators.abinit` class and then
we asked for the energy.


.. _supported calculators:

Supported calculators
=====================

The calculators can be divided in four groups:

1) Abacus_, ALIGNN_, AMS_, Asap_, BigDFT_, CHGNet_, DeePMD-kit_, DFTD3_, DFTD4_, DFTK_, EquiFormerV2_, FLEUR_, GPAW_, Hotbit_, M3GNet_, MACE_, OrbModels_, SevenNet_, TBLite_, and XTB_
   have their own native or external ASE interfaces.

2) ABINIT, AMBER, CP2K, CASTEP, deMon2k, DFTB+, ELK, EXCITING, FHI-aims, GAUSSIAN,
   Gromacs, LAMMPS, MOPAC, NWChem, Octopus, ONETEP, PLUMED, psi4, Q-Chem, Quantum ESPRESSO, SIESTA,
   TURBOMOLE and VASP, have Python wrappers in the ASE package, but the actual
   FORTRAN/C/C++ codes are not part of ASE.

3) Pure python implementations included in the ASE package: EMT, EAM,
   Lennard-Jones, Morse, Tersoff, and HarmonicCalculator.

4) Calculators that wrap others, included in the ASE package:

   - :class:`ase.calculators.checkpoint.CheckpointCalculator`
   - :class:`ase.calculators.fd.FiniteDifferenceCalculator`
   - :class:`ase.calculators.loggingcalc.LoggingCalculator`
   - :class:`ase.calculators.mixing.LinearCombinationCalculator`
   - :class:`ase.calculators.mixing.MixedCalculator`
   - :class:`ase.calculators.mixing.SumCalculator`
   - :class:`ase.calculators.mixing.AverageCalculator`
   - :class:`ase.calculators.socketio.SocketIOCalculator`

   - :ref:`Grimme-D3 <grimme>` potential

   - QM/MM calculators

     - :class:`~ase.calculators.qmmm.EIQMMM`
     - :class:`~ase.calculators.qmmm.SimpleQMMM`

========================================= ===========================================
name                                      description
========================================= ===========================================
Abacus_                                   DFT supporting both pw and lcao basis
ALIGNN_                                   Atomistic Line Graph Neural Network force field
AMS_                                      Amsterdam Modeling Suite
Asap_                                     Highly efficient EMT code
BigDFT_                                   Wavelet based code for DFT
CHGNet_                                   Universal neural network  potential for charge-informed atomistics
DeePMD-kit_                               A deep learning package for many-body potential energy representation
DFTD3_                                    London-dispersion correction
DFTD4_                                    Charge-dependent London-dispersion correction
DFTK_                                     Plane-wave code for DFT and related models
EquiFormerV2_                             Equivariant graph-based denoising transformer universal potential
FLEUR_                                    Full Potential LAPW code
GPAW_                                     Real-space/plane-wave/LCAO PAW code
Hotbit_                                   DFT based tight binding
M3GNet_                                   Materials 3-body Graph Network universal potential
MACE_                                     Many-body potential using higher-order equivariant message passing
OrbModels_                                Fast, scalable, universal GNN potentials with diffusion pretraining
SevenNet_                                 Scalable EquiVariance Enabled Neural Network interatomic potential
TBLite_                                   Light-weight tight-binding framework
XTB_                                      Semiemprical extended tight-binding program package
:mod:`~ase.calculators.abinit`            Plane-wave pseudopotential code
:mod:`~ase.calculators.amber`             Classical molecular dynamics code
:mod:`~ase.calculators.castep`            Plane-wave pseudopotential code
:mod:`~ase.calculators.cp2k`              DFT and classical potentials
:mod:`~ase.calculators.demon`             Gaussian based DFT code
:mod:`~ase.calculators.demonnano`         DFT based tight binding code
:mod:`~ase.calculators.dftb`              DFT based tight binding
:mod:`~ase.calculators.dmol`              Atomic orbital DFT code
:mod:`~ase.calculators.eam`               Embedded Atom Method
:mod:`~ase.calculators.elk`               Full Potential LAPW code
:mod:`~ase.calculators.espresso`          Plane-wave pseudopotential code
:mod:`~ase.calculators.exciting`          Full Potential LAPW code
:mod:`~ase.calculators.aims`              Numeric atomic orbital, full potential code
:mod:`~ase.calculators.gamess_us`         Gaussian based electronic structure code
:mod:`~ase.calculators.gaussian`          Gaussian based electronic structure code
:mod:`~ase.calculators.gromacs`           Classical molecular dynamics code
:mod:`~ase.calculators.gulp`              Interatomic potential code
:mod:`~ase.calculators.harmonic`          Hessian based harmonic force-field code
:mod:`~ase.calculators.kim`               Classical MD with standardized models
:mod:`~ase.calculators.lammps`            Classical molecular dynamics code
:mod:`~ase.calculators.mixing`            Combination of multiple calculators
:mod:`~ase.calculators.mopac`             Semiempirical molecular orbital code
:mod:`~ase.calculators.nwchem`            Gaussian based electronic structure code
:mod:`~ase.calculators.octopus`           Real-space pseudopotential code
:mod:`~ase.calculators.onetep`            Linear-scaling pseudopotential code
:mod:`~ase.calculators.openmx`            LCAO pseudopotential code
:mod:`~ase.calculators.orca`              Gaussian based electronic structure code
:mod:`~ase.calculators.plumed`            Enhanced sampling method library
:mod:`~ase.calculators.psi4`              Gaussian based electronic structure code
:mod:`~ase.calculators.qchem`             Gaussian based electronic structure code
:mod:`~ase.calculators.siesta`            LCAO pseudopotential code
:mod:`~ase.calculators.turbomole`         Fast atom orbital code
:mod:`~ase.calculators.tersoff`           Tersoff bond-order potential
:mod:`~ase.calculators.vasp`              Plane-wave PAW code
:mod:`~ase.calculators.emt`               Effective Medium Theory calculator
lj                                        Lennard-Jones potential
morse                                     Morse potential
:mod:`~ase.calculators.checkpoint`        Checkpoint calculator
:mod:`~ase.calculators.fd`                Finite-difference calculator
:mod:`~ase.calculators.loggingcalc`       Logging calculator
:mod:`~ase.calculators.socketio`          Socket-based interface to calculators
:mod:`~ase.calculators.dftd3`             DFT-D3 dispersion correction calculator
:class:`~ase.calculators.qmmm.EIQMMM`     Explicit Interaction QM/MM
:class:`~ase.calculators.qmmm.SimpleQMMM` Subtractive (ONIOM style) QM/MM
========================================= ===========================================

.. index:: D3, Grimme
.. _grimme:

.. note::

    A Fortran implemetation of the Grimme-D3 potential, that can be used as
    an add-on to any ASE calculator, can be found here:
    https://gitlab.com/ehermes/ased3/tree/master.

The calculators included in ASE are used like this:

>>> from ase.calculators.abc import ABC
>>> calc = ABC(...)

where ``abc`` is the module name and ``ABC`` is the class name.

.. _Abacus: https://gitlab.com/1041176461/ase-abacus
.. _ALIGNN: https://github.com/usnistgov/alignn?tab=readme-ov-file#alignnff
.. _AMS: https://www.scm.com/doc/plams/examples/AMSCalculator/ASECalculator.html#asecalculatorexample
.. _Asap: https://wiki.fysik.dtu.dk/asap
.. _BigDFT: https://l_sim.gitlab.io/bigdft-suite/tutorials/Interoperability-Simulation.html#ASE-Interoperability
.. _CHGNet: https://github.com/CederGroupHub/chgnet/blob/e2a2b82bf2c64e5a3d39cd75d0addfa864a2771a/chgnet/model/dynamics.py#L63
.. _GPAW: https://gpaw.readthedocs.io
.. _Hotbit: https://github.com/pekkosk/hotbit
.. _DFTK: https://dftk.org
.. _DeePMD-kit: https://github.com/deepmodeling/deepmd-kit
.. _DFTD4: https://github.com/dftd4/dftd4/tree/main/python
.. _DFTD3: https://dftd3.readthedocs.io/en/latest/api/python.html#module-dftd3.ase
.. _EquiFormerV2: https://github.com/FAIR-Chem/fairchem#quick-start
.. _FLEUR: https://github.com/JuDFTteam/ase-fleur
.. _M3GNet: https://matgl.ai/matgl.ext.html#class-matglextasem3gnetcalculatorpotential-potential-state_attr-torchtensor--none--none-stress_weight-float--10-kwargs
.. _MACE: https://mace-docs.readthedocs.io/en/latest/guide/ase.html
.. _OrbModels: https://github.com/orbital-materials/orb-models/tree/main#usage-with-ase-calculator
.. _SevenNet: https://github.com/MDIL-SNU/SevenNet#ase-calculator
.. _TBLite: https://tblite.readthedocs.io/en/latest/users/ase.html
.. _XTB: https://xtb-python.readthedocs.io/en/latest/ase-calculator.html

.. _calculator-configuration:

Calculator configuration
========================

Calculators that depend on external codes or files are generally
configurable.  ASE loads the configuration from a configfile located
at ``~/.config/ase/config.ini``.  The default path can be overriden by
setting the environment variable ``ASE_CONFIG_PATH`` to another path
or paths separated by colon.

To see the full configuration on a given machine, run
:command:`ase info --calculators`.

An example of a config file is as follows::

    [abinit]
    command = mpiexec /usr/bin/abinit
    pp_paths = /usr/share/abinit/pseudopotentials

    [espresso]
    command = mpiexec pw.x
    pseudo_path = /home/ase/upf_pseudos

Calculators build a full command by appending command-line arguments
to the configured command.  Therefore, the command should normally consist
of any parallel arguments followed by the binary, but should not
include further flags unless desired for a specific reason.
The command is also used to build a full command for e.g.
socket I/O calculators.

The Espresso calculator can then invoked in the following way::

    >>> from ase.build import bulk
    >>> from ase.calculators.espresso import Espresso
    >>> espresso = Espresso(
                       input_data = {
                            'system': {
                               'ecutwfc': 60,
                            }},
                       pseudopotentials = {'Si': 'si_lda_v1.uspp.F.UPF'},
                       )
    >>> si = bulk('Si')
    >>> si.calc = espresso
    >>> si.get_potential_energy()
    -244.76638508140397

It can be useful for software libraries to override the local
configuration.  To do so, the code should supply the configurable
information by instantiating a “profile”, e.g.,
``Abinit(profile=AbinitProfile(command=command))``.  The profile
encloses the configurable information specific to a particular code,
so this may differ depending on which code.  It can also be
useful for software libraries that manage their own configuration
to set the ``ASE_CONFIG_PATH`` to an empty string.


.. toctree::
   :maxdepth: 1

   eam
   emt
   abinit
   amber
   castep
   cp2k
   crystal
   demon
   demonnano
   dftb
   dmol
   elk
   espresso
   exciting
   FHI-aims
   fleur
   gamess_us
   gaussian
   gromacs
   gulp
   harmonic
   socketio/socketio
   jacapo
   kim
   lammps
   mopac
   nwchem
   octopus
   onetep
   openmx
   orca
   plumed
   psi4
   qchem
   siesta
   turbomole
   tersoff
   vasp
   qmmm
   checkpointing
   fd
   loggingcalc
   mixing
   dftd3
   others
   test
   ace