For ASE, a calculator is a black box that can take atomic numbers and atomic positions from an 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:
>>> a = read('molecule.xyz')
>>> e = a.get_potential_energy()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jjmo/ase/ase/atoms.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(...)
>>> a.set_calculator(calc)
>>> e = a.get_potential_energy()
>>> print e
-42.0
Here, we used the set_calculator() method to attach an instance of the ase.calculators.abinit class and then we asked for the energy.
Alternatively, a calculator can be attached like this:
atoms = Atoms(..., calculator=Abinit(...))
or this:
atoms.calc = Abinit(...)
The calculators can be divided in three groups:
name | description |
---|---|
Asap | Highly efficient EMT code |
GPAW | Real-space/plane-wave/LCAO PAW code |
Hotbit | DFT based tight binding |
abinit | Plane-wave pseudopotential code |
castep | Plane-wave pseudopotential code |
cp2k | DFT and clasical potentials |
dftb | DFT based tight binding |
eam | Embedded Atom Method |
elk | Full Potential LAPW code |
exciting | Full Potential LAPW code |
aims | Numeric atomic orbital, full potential code |
fleur | Full Potential LAPW code |
gaussian | Gaussian based electronic structure code |
gromacs | Classical molecular dynamics code |
jacapo | Plane-wave ultra-soft pseudopotential code |
lammps | Classical molecular dynamics code |
mopac ... | |
nwchem | Gaussian based electronic structure code |
siesta | LCAO pseudopotential code |
turbomole | Fast atom orbital code |
vasp | Plane-wave PAW code |
emt | Effective Medium Theory calculator |
lj | Lennard-Jones potential |
morse | Morse potential |
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.
Example for a hypothetical ABC calculator:
Create ABC calculator
Brillouin zone sampling:
The smearing of occupation numbers. Must be a tuple:
Lower-case names are also allowed. The width parameter is given in eV units.
Not all of the above arguments make sense for all of ASE’s calculators. As an example, Gromacs will not accept DFT related keywords such as xc and smearing. In addition to the keywords mentioned above, each calculator may have native keywords that are specific to only that calculator.
Keyword arguments can also be set or changed at a later stage using the set() method:
For QMMM caculations, see ase.calculators.ase_qmmm_manyqm.
All calculators must have the following interface:
ASE calculator.
A calculator should store a copy of the atoms object used for the last calculation. When one of the get_potential_energy, get_forces, or get_stress methods is called, the calculator should check if anything has changed since the last calculation and only do the calculation if it’s really needed. Two sets of atoms are considered identical if they have the same positions, atomic numbers, unit cell and periodic boundary conditions.
Check if a calculation is required.
Check if the quantities in the quantities list have already been calculated for the atomic configuration atoms. The quantities can be one or more of: ‘energy’, ‘forces’, ‘stress’, ‘charges’ and ‘magmoms’.
This method is used to check if a quantity is available without further calculations. For this reason, calculators should react to unknown/unsupported quantities by returning True, indicating that the quantity is not available.
These calculators have wave functions, electron densities, eigenvalues and many other quantities. Therefore, it makes sense to have a set of standard methods for accessing those quantities:
Class for demonstrating the ASE interface to DFT-calculators.
Return all the k-points in the 1. Brillouin zone.
The coordinates are relative to reciprocal latice vectors.
Return k-points in the irreducible part of the Brillouin zone.
The coordinates are relative to reciprocal latice vectors.
Return the number of spins in the calculation.
Spin-paired calculations: 1, spin-polarized calculation: 2.
Return pseudo-density array.
If spin is not given, then the total density is returned. Otherwise, the spin up or down density is returned (spin=0 or 1).
Return pseudo-wave-function array.