uf3.forcefield.lammps.UFLammps

class UFLammps(*args, **kwargs)[source]

Bases: ase.calculators.lammpslib.LAMMPSlib

ASE Calculator extending ASE.lammpslib with relaxation, elastic constants, and phonon properties.

Basic calculator implementation.

restart: str

Prefix for restart file. May contain a directory. Default is None: don’t restart.

ignore_bad_restart_file: bool

Deprecated, please do not use. Passing more than one positional argument to Calculator() is deprecated and will stop working in the future. Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.

directory: str or PurePath

Working directory in which to read and write files and perform calculations.

label: str

Name used for all files. Not supported by all calculators. May contain a directory, but please use the directory parameter for that instead.

atoms: Atoms object

Optional Atoms object to which the calculator will be attached. When restarting, atoms will get its positions and unit-cell updated from file.

Methods

band_structure

Create band-structure object for plotting.

calculate

Do the calculation.

calculate_numerical_forces

Calculate numerical forces using finite difference.

calculate_numerical_stress

Calculate numerical stress using finite difference.

calculate_properties

This method is experimental; currently for internal use.

calculation_required

check_state

Check for any system changes since last calculation.

export_properties

get_atoms

get_charges

get_default_parameters

get_dipole_moment

get_elastic_constants

Compute elastic constants.

get_forces

get_magnetic_moment

get_magnetic_moments

Calculate magnetic moments projected onto atoms.

get_phonon_data

Compute phonon spectra.

get_potential_energies

get_potential_energy

get_property

Get the named property.

get_stress

get_stresses

the calculator should return intensive stresses, i.e., such that stresses.sum(axis=0) == stress

initialise_lammps

lammpsbc

Determine LAMMPS boundary types based on ASE pbc settings.

propagate

"atoms: Atoms object

read

Read atoms, parameters and calculated properties from output file.

read_atoms

rebuild

redo_atom_types

relax

Relax with LAMMPS.

reset

Clear all information from old calculation.

restart_lammps

set

Set parameters like set(key1=value1, key2=value2, ...).

set_cell

set_label

Set label and convert label to directory and prefix.

set_lammps_pos

start_lammps

todict

Attributes

default_parameters

Default parameters

directory

discard_results_on_any_change

Whether we purge the results following any change in the set() method.

ignored_changes

Properties of Atoms which we ignore for the purposes of cache

implemented_properties

Properties calculator can handle (energy, forces, ...)

initialized

label

started

band_structure()

Create band-structure object for plotting.

calculate(atoms, properties, system_changes)

Do the calculation.

properties: list of str

List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.

system_changes: list of str

List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.

Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:

self.results = {'energy': 0.0,
                'forces': np.zeros((len(atoms), 3)),
                'stress': np.zeros(6),
                'dipole': np.zeros(3),
                'charges': np.zeros(len(atoms)),
                'magmom': 0.0,
                'magmoms': np.zeros(len(atoms))}

The subclass implementation should first call this implementation to set the atoms attribute and create any missing directories.

calculate_numerical_forces(atoms, d=0.001)

Calculate numerical forces using finite difference.

All atoms will be displaced by +d and -d in all directions.

calculate_numerical_stress(atoms, d=1e-06, voigt=True)

Calculate numerical stress using finite difference.

calculate_properties(atoms, properties)

This method is experimental; currently for internal use.

check_state(atoms, tol=1e-15)

Check for any system changes since last calculation.

get_elastic_constants(atoms)[source]

Compute elastic constants. TODO: include parameters.

get_magnetic_moments(atoms=None)

Calculate magnetic moments projected onto atoms.

get_phonon_data(atoms, n_super=5, disp=0.05)[source]

Compute phonon spectra.

get_property(name, atoms=None, allow_calculation=True)

Get the named property.

get_stresses(atoms=None)

the calculator should return intensive stresses, i.e., such that stresses.sum(axis=0) == stress

lammpsbc(atoms)

Determine LAMMPS boundary types based on ASE pbc settings. For non-periodic dimensions, if the cell length is finite then fixed BCs (‘f’) are used; if the cell length is approximately zero, shrink-wrapped BCs (‘s’) are used.

propagate(atoms, properties, system_changes, n_steps, dt=None, dt_not_real_time=False, velocity_field=None)
“atoms: Atoms object

Contains positions, unit-cell, …

properties: list of str

List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.

system_changes: list of str

List of what has changed since last calculation. Can be any combination of these five: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘charges’ and ‘magmoms’.

read(label)

Read atoms, parameters and calculated properties from output file.

Read result from self.label file. Raise ReadError if the file is not there. If the file is corrupted or contains an error message from the calculation, a ReadError should also be raised. In case of succes, these attributes must set:

atoms: Atoms object

The state of the atoms from last calculation.

parameters: Parameters object

The parameter dictionary.

results: dict

Calculated properties like energy and forces.

The FileIOCalculator.read() method will typically read atoms and parameters and get the results dict by calling the read_results() method.

relax(atoms)[source]

Relax with LAMMPS. TODO: Include more options.

reset()

Clear all information from old calculation.

set(**kwargs)

Set parameters like set(key1=value1, key2=value2, …).

A dictionary containing the parameters that have been changed is returned.

Subclasses must implement a set() method that will look at the chaneged parameters and decide if a call to reset() is needed. If the changed parameters are harmless, like a change in verbosity, then there is no need to call reset().

The special keyword ‘parameters’ can be used to read parameters from a file.

set_label(label)

Set label and convert label to directory and prefix.

Examples:

  • label=’abc’: (directory=’.’, prefix=’abc’)

  • label=’dir1/abc’: (directory=’dir1’, prefix=’abc’)

  • label=None: (directory=’.’, prefix=None)