ASE Calculator for AMS¶
AMSCalculator class is an ASE Calculator that lets you use any AMS engine (ADF, BAND, DFTB, ReaxFF, MLPotential, ForceField, …)
together with ASE.
Example: AMSCalculator: ASE geometry optimizer with AMS forces
Engine ASE: Couple external ASE calculators to the AMS Driver
Before using an AMSCalculator, you must call the
init() function from PLAMS. This is done automatically if you use the
Settings object is used to set up the AMS settings in the same way as for normal PLAMS jobs.
Currently only the energy, forces and stress tensor are provided through the ASE interface.
All other results can be accessed through
AMSCalculator.ams_results, which is an
AMSCalculator.ensure_property('stress') to ensure
these ASE properties are computed regardless of whether it was originally requested in the
There is currently no universal interface in ASE for the total charge of a system and is instead considered to be Calculator specific.
The easiest way to set the charge a calculation with the
AMSCalculator is to define
Additionally, when the charge needs to be treated extensively w.r.t. manipulations of the
Atoms object in ASE, the initial charge of each atom can also be set.
The total charge is thus obtained as
See the ASE documentation for details on initial charges and info.
Example: AMSCalculator: Access results files & Charged systems
AMS standalone and worker mode¶
AMS can run in two modes: standalone and worker.
In standalone mode (
amsworker=False), AMS is started for every new structure, and stores the normal AMS output. Use this mode if:
you need to access all results, or
you run a calculation not supported by the AMSworker (e.g., a PESScan)
In AMSworker mode (
amsworker=True), AMS is only started once. This significantly reduces overhead, especially for fast engines like ReaxFF. The downside is that you cannot access all results. Use this mode if:
you only need access to energy, forces, and stress tensor, and
you only need to run single point calculations, for example to use the
In AMSworker mode, make sure to use
AMSCalculator as a context manager, or explicitly
AMSCalculator.stop_worker() when you want to terminate the AMS process.
When creating a deepcopy of
AMSWorker is not copied and instead every copy of
AMSCalculator has a reference to the
AMSCalculator(settings=None, name='', amsworker=False, restart=True, molecule=None, extractors=)[source]¶
ASE Calculator which can run any AMS engine (ADF, BAND, DFTB, ReaxFF, MLPotential, ForceField, …).
The settings are specified with a PLAMS
Settingsobject in the same way as when running AMS through PLAMS.
Before initializing the AMSCalculator you need to call
from scm.plams import * init()
A Settings object representing the input for an AMSJob or AMSWorker. This also determines which implemented_properties are available: settings.input.ams.properties.gradients: force settings.input.ams.properties.stresstensor: stress
- namestr, optional
Name of the rundir of calculations done by this calculator. A counter is appended to the name for every calculation.
- amsworkerbool , optional
If True, use the AMSWorker to set up an interactive session. The AMSWorker will spawn a seperate process (an amsdriver). In order to make sure this process is closed, either use AMSCalculator as a context manager or ensure that AMSCalculator.stop_worker() is called before python is finished:
with AMSCalculator(settings=settings, amsworker=True) as calc: atoms.set_calculator(calc) atoms.get_potential_energy()
If False, use AMSJob to set up an io session (a normal AMS calculation storing all output on disk).
- restartbool , optional
Allow the engine to restart based on previous calculations.
- moleculeMolecule , optional
A Molecule object for which the calculation has to be performed. If settings.input.ams.system is defined it overrides the molecule argument. If AMSCalculator.calculate(atoms = atoms) is called with an atoms argument it overrides any earlier definition of the system and remembers it.
- extractors: List[BasePropertyExtractor] , optional
Define extractors for additional properties.
__new__(cls, settings=None, name='', amsworker=False, restart=True, molecule=None, extractors=)[source]¶
Dispatch object creation to AMSPipeCalculator or AMSJobCalculator depending on
Returns the list of properties that this calculator has implemented
calculate(atoms=None, properties=['energy'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]¶
Calculate the requested properties. If atoms is not set, it will reuse the last known Atoms object.
A list of ASE properties that the calculator will ensure are available from AMS or it gives an error.