Main

This module is the main part of the Amp package.

Module contents

class amp.Amp(descriptor, model, label='amp', dblabel=None, cores=None, envcommand=None, logging=True, atoms=None)[source]

Bases: ase.calculators.calculator.Calculator, object

Atomistic Machine-Learning Potential (Amp) ASE calculator

Parameters:
  • descriptor (object) – Class representing local atomic environment.
  • model (object) – Class representing the regression model. Can be only NeuralNetwork for now. Input arguments for NeuralNetwork are hiddenlayers, activation, weights, and scalings; for more information see docstring for the class NeuralNetwork.
  • label (str) – Default prefix/location used for all files.
  • dblabel (str) – Optional separate prefix/location for database files, including fingerprints, fingerprint derivatives, and neighborlists. This file location can be shared between calculator instances to avoid re-calculating redundant information. If not supplied, just uses the value from label.
  • cores (int) – Can specify cores to use for parallel training; if None, will determine from environment
  • envcommand (string) – For parallel processing across nodes, a command can be supplied here to load the appropriate environment before starting workers.
  • logging (boolean) – Option to turn off logging; e.g., to speed up force calls.
  • atoms (object) – ASE atoms objects with positions, symbols, energy, and forces in ASE format.
calculate(atoms, properties, system_changes)[source]

Calculation of the energy of system and forces of all atoms.

cores

Get or set the cores for the parallel environment.

Parameters:cores (int or dictionary) – Parallel configuration. If cores is an integer, parallelizes over this many processes on machine localhost. cores can also be a dictionary of the type {‘node324’: 16, ‘node325’: 16}. If not specified, tries to determine from environment, using amp.utilities.assign_cores.
descriptor

Get or set the atomic descriptor.

Parameters:descriptor (object) – Class instance representing the local atomic environment.
implemented_properties = ['energy', 'forces']
classmethod load(Cls, file, Descriptor=None, Model=None, **kwargs)[source]

Attempts to load calculators and return a new instance of Amp.

Only a filename or file-like object is required, in typical cases.

If using a home-rolled descriptor or model, also supply uninstantiated classes to those models, as in Model=MyModel. (Not as Model=MyModel()!)

Any additional keyword arguments (such as label or dblabel) can be fed through to Amp.

Parameters:
  • file (str) – Name of the file to load data from.
  • Descriptor (object) – Class representing local atomic environment.
  • Model (object) – Class representing the regression model.
model

Get or set the machine-learning model.

Parameters:model (object) – Class instance representing the regression model.
save(filename, overwrite=False)[source]

Saves the calculator in a way that it can be re-opened with load.

Parameters:
  • filename (str) – File object or path to the file to write to.
  • overwrite (bool) – If an output file with the same name exists, overwrite it.
set(**kwargs)[source]

Function to set parameters.

For now, this doesn’t do anything as all parameters are within the model and descriptor.

set_label(label)[source]

Sets label, ensuring that any needed directories are made.

Parameters:label (str) – Default prefix/location used for all files.
train(images, overwrite=False)[source]

Fits the model to the training images.

Parameters:
  • images (list or str) – List of ASE atoms objects with positions, symbols, energies, and forces in ASE format. This is the training set of data. This can also be the path to an ASE trajectory (.traj) or database (.db) file. Energies can be obtained from any reference, e.g. DFT calculations.
  • overwrite (bool) – If an output file with the same name exists, overwrite it.
amp.get_git_commit(ampdirectory)[source]

Attempts to get the last git commit from the amp directory.

amp.importhelper(importname)[source]

Manually compiled list of available modules.

This is to prevent the execution of arbitrary (potentially malicious) code.

However, since there is an eval statement in string2dict maybe this is silly.