Defining systems¶
-
class System¶
A
System
deals with the storage of atoms and related information, as well as the computation of neighbor lists.This class only defines a pure virtual interface for
System
. In order to provide access to new system, users must create a child class implementing all virtual member functions.Subclassed by featomic::SimpleSystem, featomic_torch::SystemAdapter
Public Types
-
using CellMatrix = std::array<std::array<double, 3>, 3>¶
Unit cell representation as a 3x3 matrix. The cell should be written in row major order, i.e.
{{ax ay az}, {bx by bz}, {cx cy cz}}
, where a/b/c are the unit cell vectors.
Public Functions
-
virtual uintptr_t size() const = 0¶
Get the number of atoms in this system.
-
virtual const int32_t *types() const = 0¶
Get a pointer to the first element a contiguous array (typically
std::vector
or memory allocated withnew[]
) containing the atomic type of each atom in this system. Different atomics types should be identified with a different value. These values are usually the atomic number, but don’t have to be. The array should containSystem::size()
elements.
-
virtual const double *positions() const = 0¶
Get a pointer to the first element of a contiguous array containing the atomic cartesian coordinates.
positions[0], positions[1], positions[2]
must contain the x, y, z cartesian coordinates of the first atom, and so on. The array should contain3 x System::size()
elements.
-
virtual CellMatrix cell() const = 0¶
Get the matrix describing the unit cell.
-
virtual void compute_neighbors(double cutoff) = 0¶
Compute the neighbor list with the given
cutoff
, and store it for later access usingSystem::pairs
orSystem::pairs_containing
.
-
virtual const std::vector<featomic_pair_t> &pairs() const = 0¶
Get the list of pairs in this system
This list of pair should only contain each pair once (and not twice as
i-j
andj-i
), should not contain self pairs (i-i
); and should only contains pairs where the distance between atoms is actually bellow the cutoff passed in the last call toSystem::compute_neighbors
. This function is only valid to call after a call toSystem::compute_neighbors
.
-
virtual const std::vector<featomic_pair_t> &pairs_containing(uintptr_t atom) const = 0¶
Get the list of pairs in this system containing the
atom
at the given index.The same restrictions on the list of pairs as
System::pairs
applies, with the additional condition that the pairi-j
should be included both in the return ofSystem::pairs_containing(i)
andSystem::pairs_containing(j)
.
-
inline featomic_system_t as_featomic_system_t()¶
Convert a child instance of the
System
class to afeatomic_system_t
to be passed to the featomic functions.This is an advanced function that most users don’t need to call directly.
-
using CellMatrix = std::array<std::array<double, 3>, 3>¶
-
class SimpleSystem : public featomic::System¶
A very minimal implementation of the System interface, only providing data and no neighbor list calculation. This class must thus be used with
use_native_system=true
in the calculation options.Public Functions
-
inline SimpleSystem(CellMatrix cell = {{0}})¶
Create a new
SimpleSystem
, with the atoms contained in the give cell.
-
inline void add_atom(int32_t type, std::array<double, 3> position)¶
Add an atom with the given type and position to this system.
-
inline virtual uintptr_t size() const override¶
Get the number of atoms in this system.
-
inline virtual const int32_t *types() const override¶
Get a pointer to the first element a contiguous array (typically
std::vector
or memory allocated withnew[]
) containing the atomic type of each atom in this system. Different atomics types should be identified with a different value. These values are usually the atomic number, but don’t have to be. The array should containSystem::size()
elements.
-
inline virtual const double *positions() const override¶
Get a pointer to the first element of a contiguous array containing the atomic cartesian coordinates.
positions[0], positions[1], positions[2]
must contain the x, y, z cartesian coordinates of the first atom, and so on. The array should contain3 x System::size()
elements.
-
inline virtual CellMatrix cell() const override¶
Get the matrix describing the unit cell.
-
inline virtual void compute_neighbors(double) override¶
Compute the neighbor list with the given
cutoff
, and store it for later access usingSystem::pairs
orSystem::pairs_containing
.
-
inline virtual const std::vector<featomic_pair_t> &pairs() const override¶
Get the list of pairs in this system
This list of pair should only contain each pair once (and not twice as
i-j
andj-i
), should not contain self pairs (i-i
); and should only contains pairs where the distance between atoms is actually bellow the cutoff passed in the last call toSystem::compute_neighbors
. This function is only valid to call after a call toSystem::compute_neighbors
.
-
inline virtual const std::vector<featomic_pair_t> &pairs_containing(uintptr_t) const override¶
Get the list of pairs in this system containing the
atom
at the given index.The same restrictions on the list of pairs as
System::pairs
applies, with the additional condition that the pairi-j
should be included both in the return ofSystem::pairs_containing(i)
andSystem::pairs_containing(j)
.
-
inline SimpleSystem(CellMatrix cell = {{0}})¶