OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
OpenMD::NEP Class Reference

Public Member Functions

 NEP (const std::string &model_filename, int N_atoms, std::vector< RealType > box, std::vector< std::string > atom_symbols, std::vector< RealType > positions, std::vector< RealType > masses)
std::vector< RealType > getDescriptors ()
std::vector< RealType > getDipole ()
std::vector< RealType > getDipoleGradient (RealType displacement, int method, RealType charge)
std::vector< RealType > getPolarizability ()
std::vector< RealType > getPolarizabilityGradient (RealType displacement, std::vector< int > components)
std::vector< RealType > getLatentSpace ()
std::tuple< std::vector< RealType >, std::vector< RealType >, std::vector< RealType > > getPotentialForcesAndVirials ()
std::vector< std::string > _getAtomSymbols (std::string model_filename)
void _convertAtomTypeNEPIndex (int N, std::vector< std::string > atom_symbols, std::vector< std::string > model_atom_symbols, std::vector< int > &type)
void _getCenterOfMass (std::vector< RealType > center_of_mass)
void setPositions (std::vector< RealType > positions)
void setCell (std::vector< RealType > cell)
void setMasses (std::vector< RealType > masses)
void setSymbols (std::vector< std::string > atom_symbols)

Detailed Description

Definition at line 17 of file nep.hpp.

Constructor & Destructor Documentation

◆ NEP()

OpenMD::NEP::NEP ( const std::string & model_filename,
int N_atoms,
std::vector< RealType > box,
std::vector< std::string > atom_symbols,
std::vector< RealType > positions,
std::vector< RealType > masses )

Wrapper class for NEP3 in nep.cpp.

This class wraps the setup functionality of the NEP3 class in nep.cpp.

Parameters
model_filenamePath to the NEP model (/path/nep.txt).
N_atomsThe number of atoms in the structure.
cellThe cell vectors for the structure.
atom_symbolsThe atomic symbol for each atom in the structure.
positionsThe position for each atom in the structure.
massesThe mass for each atom in the structure.

Definition at line 12 of file nep.cpp.

References _convertAtomTypeNEPIndex(), and _getAtomSymbols().

Member Function Documentation

◆ _convertAtomTypeNEPIndex()

void OpenMD::NEP::_convertAtomTypeNEPIndex ( int N,
std::vector< std::string > atom_symbols,
std::vector< std::string > model_atom_symbols,
std::vector< int > & type )

Converts atom species to NEP index.

Converts atomic species to indicies, which are used in NEP.

Parameters
atom_symbolsList of atom symbols.
model_atom_symbolsList of atom symbols used in the model.
typeList of indices corresponding to atom type.

Definition at line 448 of file nep.cpp.

Referenced by NEP(), and setSymbols().

◆ _getAtomSymbols()

std::vector< std::string > OpenMD::NEP::_getAtomSymbols ( std::string model_filename)

Fetches atomic symbols

This function fetches the atomic symbols from the header of a NEP model. These are later used to ensure consistent indices for the atom types.

Parameters
model_filenamePath to the NEP model (/path/nep.txt).

Definition at line 421 of file nep.cpp.

Referenced by NEP(), and setSymbols().

◆ _getCenterOfMass()

void OpenMD::NEP::_getCenterOfMass ( std::vector< RealType > center_of_mass)

Computes the center of mass for current atoms object.

Computes the center of mass (COM) for the structure with positions defined by atoms.position. The COM will be written as a three vector, with in the order [x_component, y_component, z_component].

Parameters
center_of_massVector to hold the center of mass.

Definition at line 69 of file nep.cpp.

Referenced by getDipoleGradient().

◆ getDescriptors()

std::vector< RealType > OpenMD::NEP::getDescriptors ( )

Get NEP descriptors.

Calculates NEP descriptors for a given structure and NEP model.

Definition at line 38 of file nep.cpp.

◆ getDipole()

std::vector< RealType > OpenMD::NEP::getDipole ( )

Get dipole.

Calculates the dipole (a vector of length 3) for the whole box.

Definition at line 59 of file nep.cpp.

◆ getDipoleGradient()

std::vector< RealType > OpenMD::NEP::getDipoleGradient ( RealType displacement,
int method,
RealType charge )

Get dipole gradient through finite differences.

Calculates the dipole gradient, a (N_atoms, 3, 3) tensor for the gradients dµ_k/dr_ij, for atom i, Cartesian direction j (x, y, z) and dipole moment component k. Mode is either forward difference (method=0) or first or second order central difference (method=1 and method=2 respectively). Before computing the gradient the dipoles are corrected using the center of mass and the total system charge, supplied via the parameter charge.

Parameters
displacementDisplacement in Å.
method0 or 1, corresponding to forward or central differences.
chargeTotal system charge, used to correct dipoles.

Definition at line 92 of file nep.cpp.

References _getCenterOfMass().

◆ getLatentSpace()

std::vector< RealType > OpenMD::NEP::getLatentSpace ( )

Get the NEP latent space.

Calculates the latent space of a NEP model, i.e., the activations after the first layer.

Definition at line 48 of file nep.cpp.

◆ getPolarizability()

std::vector< RealType > OpenMD::NEP::getPolarizability ( )

Get polarizability.

Calculates the polarizability (a 2-tensor, represented as vector of length 9) for the whole box. Output order is pxx pxy pxz pyx pyy pyz pzx pzy pzz.

Definition at line 308 of file nep.cpp.

◆ getPolarizabilityGradient()

std::vector< RealType > OpenMD::NEP::getPolarizabilityGradient ( RealType displacement,
std::vector< int > components )

Get polarizability gradient through finite differences.

Calculates the polarizability gradient, a (N_atoms, 3, 6) tensor for the gradients dp_k/dr_ij, for atom i, Cartesian direction j (x, y, z) and polarizability component k, using second order finite differences.

Parameters
displacementDisplacement in Å.

Definition at line 321 of file nep.cpp.

◆ getPotentialForcesAndVirials()

std::tuple< std::vector< RealType >, std::vector< RealType >, std::vector< RealType > > OpenMD::NEP::getPotentialForcesAndVirials ( )

Calculate potential, forces and virials.

Calculates potential energy, forces and virials for a given structure and NEP model.

Definition at line 408 of file nep.cpp.

◆ setCell()

void OpenMD::NEP::setCell ( std::vector< RealType > cell)

Sets cell.

Sets the cell of the atoms object.

Parameters
CellCell vectors.

Definition at line 492 of file nep.cpp.

◆ setMasses()

void OpenMD::NEP::setMasses ( std::vector< RealType > masses)

Sets masses.

Sets the masses of the atoms object.

Parameters
CellAtom masses.

Definition at line 503 of file nep.cpp.

◆ setPositions()

void OpenMD::NEP::setPositions ( std::vector< RealType > positions)

Sets positions.

Sets the positions of the atoms object. Also updates the center of mass.

Parameters
positionsList of positions.

Definition at line 480 of file nep.cpp.

◆ setSymbols()

void OpenMD::NEP::setSymbols ( std::vector< std::string > atom_symbols)

Sets symbols.

Sets the symbols of the atoms object from the ones used in the model.

Parameters
atom_symbolsList of symbols.

Definition at line 514 of file nep.cpp.

References _convertAtomTypeNEPIndex(), and _getAtomSymbols().


The documentation for this class was generated from the following files: