Potentials#

Directory: libfly/potential

The potential folder contains a collection of potential energy functions. Everything is contained within the namespace fly::potential.

Generic potential#

File: libfly/potential/generic.hpp

Generic potential energy class.

The potential completely describes the interatomic interactions present in a system.

class Generic#

Generalised interatomic potential.

Essentially a std::variant of all supported potentials.

Public Functions

template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<variant, Args&&...>>>
inline explicit Generic(Args&&... args)#

Construct a new Generic object.

Parameters:

args – Forwarded to std::variant’s constructor.

Generic(Generic&&) = default#

Construct a new Generic object.

Generic(Generic const&) = default#

Construct a new Generic object.

inline auto energy(system::SoA<TypeID const&, Frozen const&> in, neigh::List const &nl, int threads = 1) -> double#

Compute the potential energy.

Can assume the neighbour list are ready.

Parameters:
Returns:

The potential energy of the system of atoms.

inline auto gradient(system::SoA<PotentialGradient&> out, system::SoA<TypeID const&, Frozen const&> in, neigh::List const &nl, int threads = 1) -> void#

Compute potential energy gradient.

Can assume the neighbour list are ready, force on frozen atoms must be zero.

Parameters:
  • out – Result is written here.

  • in – Per-atom data used by potential for computation.

  • nl – Neighbour list (in ready state i.e. neigh::List::update() or neigh::List::rebuild() called) configured with a cut-off at least r_cut().

  • threads – Number of openMP threads to use.

inline auto hessian(system::Hessian &out, system::SoA<TypeID const&, Frozen const&> in, neigh::List const &nl, int threads = 1) -> void#

Compute hessian matrix.

Can assume the neighbour list are ready. The resulting hessian must be n by n (n = number of atoms * spatial dims) and only include contributions from the m active atoms i.e. have zeros for frozen atoms. As hessian matrices are always symmetric this function is only required to compute the lower diagonal portion.

Parameters:
  • in – Per-atom data used by hessian for computation.

  • out – Hessian matrix to write output to.

  • nl – Neighbour list (in ready state i.e. neigh::List::update() or neigh::List::rebuild() called) configured with a cut-off at least r_cut().

  • threads – Number of openMP threads to use.

inline auto r_cut() const noexcept -> double#

Get this potentials cut-off radius.

This is the maximum distance two atoms can interact. The neighbour::List passed to the other functions should be configured with a cut-off equal or greater than this.

EAM#

Parsing#

File: libfly/potential/EAM/data.hpp

EAM parsing and storage.

class DataEAM#

Parses/stores tabulated EAM data and reconstructs f, phi, v smoothly via splines.

Public Functions

DataEAM(Options const &opt, std::ifstream in)#

Parse the LAMMPS-style eam/fs stream and construct an DataEAM object.

For detail on file specification see: https://docs.lammps.org/pair_eam.html

inline auto f(TypeID::scalar_t id) const -> Spline const&#

Fetch the embedding energy function.

Parameters:

id – The TypeID of the Type whose function you want to fetch.

inline auto phi(TypeID::scalar_t a, TypeID::scalar_t b) const -> Spline const&#

Fetch the electron density function.

Corresponding to the atom pair with TypeID’s a and b.

Parameters:
  • a – The TypeID of the Type of the first atom of the pair.

  • b – The TypeID of the Type of the second atom of the pair.

inline auto r_cut() const noexcept -> double#

Fetch the cut-off radius.

inline auto type_map() const noexcept -> system::TypeMap<Mass> const&#

Fetch the TypeMap.

The map stores the mapping from TypeID’s to Types that this potential has been tabulated as.

inline Spline const &v(TypeID::scalar_t a, TypeID::scalar_t b) const#

Fetch the symmetric pair-potential function.

Corresponding to the atom pair with TypeID’s a and b.

Parameters:
  • a – The TypeID of the Type of the first atom of the pair.

  • b – The TypeID of the Type of the second atom of the pair.

struct Options#

Options for parsing the EAM file.

Public Members

bool debug = false#

Controls debug printing.

bool symmetric = false#

Assume symmetric phi.

Evaluating#

File: libfly/potential/EAM/eam.hpp

EAM potential implementation.

class EAM#

EAM potential child class.

Public Functions

inline EAM(system::TypeMap<> const &map, std::shared_ptr<DataEAM const> data)#

Construct a new EAM object.

Parameters:
  • map – TypeMap of expected types to find in data.

  • data – Tabulated EAM data.

auto energy(system::SoA<TypeID const&, Frozen const&> in, neigh::List const &nl, int threads = 1) -> double#

Compute the potential energy.

Assumes the neighbour list are ready, ignores contributions from the frozen atoms.

Parameters:
Returns:

double The potential energy of the system of atoms.

auto gradient(system::SoA<PotentialGradient&> out, system::SoA<TypeID const&, Frozen const&> in, neigh::List const &nl, int threads = 1) -> void#

Compute potential energy gradient.

Assumes the neighbour list are ready, force on frozen atoms will be zero.

Parameters:
auto hessian(system::Hessian &out, system::SoA<TypeID const&, Frozen const&> in, neigh::List const &nl, int threads = 1) -> void#

Compute hessian matrix.

Assumes the neighbour list are ready. The resulting hessian will be n by n (n = number of atoms) and only include contributions from the m active atoms i.e. have zeros for frozen atoms. As hessian matrices are always symmetric this function only computes the lower diagonal portion.

Parameters:
inline auto r_cut() const noexcept -> double#

Get this potentials cut-off radius.

This is the maximum distance two atom can interact. The neighbour::List passed to the other functions should be configured with a cut-off equal or greater than this.