n2p2 - A neural network potential package
|
Storage for one atomic configuration. More...
#include <Structure.h>
Public Types | |
enum | SampleType { ST_UNKNOWN , ST_TRAINING , ST_VALIDATION , ST_TEST } |
Enumerates different sample types (e.g. More... | |
Public Member Functions | |
Structure () | |
Constructor, initializes to zero. More... | |
void | setElementMap (ElementMap const &elementMap) |
Set element map of structure. More... | |
void | addAtom (Atom const &atom, std::string const &element) |
Add a single atom to structure. More... | |
void | readFromFile (std::string const fileName="input.data") |
Read configuration from file. More... | |
void | readFromFile (std::ifstream &file) |
Read configuration from file. More... | |
void | readFromLines (std::vector< std::string > const &lines) |
Read configuration from lines. More... | |
void | calculateMaxCutoffRadiusOverall (EwaldSetup &ewaldSetup, double rcutScreen, double maxCutoffRadius) |
Calculate maximal cut-off if cut-off of screening and real part Ewald summation are also considered. More... | |
void | calculateNeighborList (double cutoffRadius, bool sortByDistance=false) |
Calculate neighbor list for all atoms. More... | |
void | calculateNeighborList (double cutoffRadius, std::vector< std::vector< double > > &cutoffs) |
Calculate neighbor list for all atoms and setup neighbor cut-off map. More... | |
void | sortNeighborList () |
Sort all neighbor lists of this structure with respect to the distance. More... | |
void | setupNeighborCutoffMap (std::vector< std::vector< double > > cutoffs) |
Set up a neighbor cut-off map which gives the index (value) of the last needed neighbor corresponding to a specific cut-off (key). More... | |
void | calculatePbcCopies (double cutoffRadius, int(&pbc)[3]) |
Calculate required PBC copies. More... | |
void | calculateInverseBox () |
Calculate inverse box. More... | |
bool | canMinimumImageConventionBeApplied (double cutoffRadius) |
Check if cut-off radius is small enough to apply minimum image convention. More... | |
Vec3D | applyMinimumImageConvention (Vec3D const &dr) |
Calculate distance between two atoms in the minimum image convention. More... | |
void | calculateVolume () |
Calculate volume from box vectors. More... | |
double | calculateElectrostaticEnergy (EwaldSetup &ewaldSetup, Eigen::VectorXd hardness, Eigen::MatrixXd gammaSqrt2, Eigen::VectorXd sigmaSqrtPi, ScreeningFunction const &fs, double const fourPiEps, ErfcBuf &erfcBuf) |
Compute electrostatic energy with global charge equilibration. More... | |
double | calculateScreeningEnergy (Eigen::MatrixXd gammaSqrt2, Eigen::VectorXd sigmaSqrtPi, ScreeningFunction const &fs, double const fourPiEps) |
Calculate screening energy which needs to be added (!) to the electrostatic energy in order to remove contributions in the short range domain. More... | |
void | calculateDAdrQ (EwaldSetup &ewaldSetup, Eigen::MatrixXd gammaSqrt2, double const fourPiEps, ErfcBuf &erfcBuf) |
Calculates derivative of A-matrix with respect to the atoms positions and contract it with Q. More... | |
void | calculateDQdChi (std::vector< Eigen::VectorXd > &dQdChi) |
Calculates derivative of the charges with respect to electronegativities. More... | |
void | calculateDQdJ (std::vector< Eigen::VectorXd > &dQdJ) |
Calculates derivative of the charges with respect to atomic hardness. More... | |
void | calculateDQdr (std::vector< size_t > const &atomsIndices, std::vector< size_t > const &compIndices, double const maxCutoffRadius, std::vector< Element > const &elements) |
Calculates derivative of the charges with respect to the atom's position. More... | |
void | calculateElectrostaticEnergyDerivatives (Eigen::VectorXd hardness, Eigen::MatrixXd gammaSqrt2, Eigen::VectorXd sigmaSqrtPi, ScreeningFunction const &fs, double const fourPiEps) |
Calculates partial derivatives of electrostatic Energy with respect to atom's coordinates and charges. More... | |
Eigen::VectorXd const | calculateForceLambdaTotal () const |
Calculate lambda_total vector which is needed for the total force calculation in 4G NN. More... | |
Eigen::VectorXd const | calculateForceLambdaElec () const |
Calculate lambda_elec vector which is needed for the electrostatic force calculation in 4G NN. More... | |
void | remap () |
Translate all atoms back into box if outside. More... | |
void | remap (Atom &atom) |
Translate atom back into box if outside. More... | |
void | toNormalizedUnits (double meanEnergy, double convEnergy, double convLength, double convCharge) |
Normalize structure, shift energy and change energy, length and charge unit. More... | |
void | toPhysicalUnits (double meanEnergy, double convEnergy, double convLength, double convCharge) |
Switch to physical units, shift energy and change energy, length and charge unit. More... | |
std::size_t | getMaxNumNeighbors () const |
Find maximum number of neighbors. More... | |
void | freeAtoms (bool all, double const maxCutoffRadius=0.0) |
Free symmetry function memory for all atoms, see free() in Atom class. More... | |
void | reset () |
Reset everything but elementMap. More... | |
void | clearNeighborList () |
Clear neighbor list of all atoms. More... | |
void | clearElectrostatics (bool clearDQdr=false) |
Clear A-matrix, dAdrQ and optionally dQdr. More... | |
void | updateError (std::string const &property, std::map< std::string, double > &error, std::size_t &count) const |
Update property error metrics with this structure. More... | |
std::string | getEnergyLine () const |
Get reference and NN energy. More... | |
std::vector< std::string > | getForcesLines () const |
Get reference and NN forces for all atoms. More... | |
std::vector< std::string > | getChargesLines () const |
Get reference and NN charges for all atoms. More... | |
void | writeToFile (std::string const fileName="output.data", bool const ref=true, bool const append=false) const |
Write configuration to file. More... | |
void | writeToFile (std::ofstream *const &file, bool const ref=true) const |
Write configuration to file. More... | |
void | writeToFileXyz (std::ofstream *const &file) const |
Write configuration to xyz file. More... | |
void | writeToFilePoscar (std::ofstream *const &file) const |
Write configuration to POSCAR file. More... | |
void | writeToFilePoscar (std::ofstream *const &file, std::string const elements) const |
Write configuration to POSCAR file. More... | |
std::vector< std::string > | info () const |
Get structure information as a vector of strings. More... | |
Public Attributes | |
ElementMap | elementMap |
Copy of element map provided as constructor argument. More... | |
bool | isPeriodic |
If periodic boundary conditions apply. More... | |
bool | isTriclinic |
If the simulation box is triclinic. More... | |
bool | hasNeighborList |
If the neighbor list has been calculated. More... | |
bool | NeighborListIsSorted |
If the neighbor list has been sorted by distance. More... | |
bool | hasSymmetryFunctions |
If symmetry function values are saved for each atom. More... | |
bool | hasSymmetryFunctionDerivatives |
If symmetry function derivatives are saved for each atom. More... | |
std::size_t | index |
Index number of this structure. More... | |
std::size_t | numAtoms |
Total number of atoms present in this structure. More... | |
std::size_t | numElements |
Global number of elements (all structures). More... | |
std::size_t | numElementsPresent |
Number of elements present in this structure. More... | |
int | pbc [3] |
Number of PBC images necessary in each direction for max cut-off. More... | |
double | energy |
Potential energy determined by neural network. More... | |
double | energyRef |
Reference potential energy. More... | |
double | energyShort |
Short-range part of the potential energy predicted by NNP. More... | |
double | energyElec |
Electrostatics part of the potential energy predicted by NNP. More... | |
bool | hasCharges |
If all charges of this structure have been calculated (and stay the same, e.g. More... | |
double | charge |
Charge determined by neural network potential. More... | |
double | chargeRef |
Reference charge. More... | |
double | volume |
Simulation box volume. More... | |
double | maxCutoffRadiusOverall |
Maximum cut-off radius with respect to symmetry functions, screening function and Ewald summation. More... | |
double | lambda |
Lagrange multiplier used for charge equilibration. More... | |
SampleType | sampleType |
Sample type (training or test set). More... | |
std::string | comment |
Structure comment. More... | |
Vec3D | box [3] |
Simulation box vectors. More... | |
Vec3D | invbox [3] |
Inverse simulation box vectors. More... | |
Eigen::MatrixXd | A |
Global charge equilibration matrix A'. More... | |
bool | hasAMatrix |
If A matrix of this structure is currently stored. More... | |
std::vector< std::size_t > | numAtomsPerElement |
Number of atoms of each element in this structure. More... | |
std::vector< Atom > | atoms |
Vector of all atoms in this structure. More... | |
Storage for one atomic configuration.
Definition at line 38 of file Structure.h.
Enumerates different sample types (e.g.
training or test set).
Enumerator | |
---|---|
ST_UNKNOWN | Sample type not assigned yet. |
ST_TRAINING | Structure is part of the training set. |
ST_VALIDATION | Structure is part of validation set (currently unused). |
ST_TEST | Structure is part of the test set. |
Definition at line 42 of file Structure.h.
Structure::Structure | ( | ) |
Constructor, initializes to zero.
Definition at line 35 of file Structure.cpp.
void Structure::setElementMap | ( | ElementMap const & | elementMap | ) |
Set element map of structure.
[in] | elementMap | Reference to a map containing all possible (symbol, index)-pairs (see ElementMap). |
Definition at line 71 of file Structure.cpp.
References elementMap, numAtomsPerElement, numElements, and nnp::ElementMap::size().
Referenced by nnp::Dataset::distributeStructures(), nnp::InterfaceLammps::initialize(), main(), nnp::Dataset::prepareNumericForces(), nnp::Prediction::readStructureFromFile(), and LAMMPS_NS::PairHDNNPExternal::settings().
void Structure::addAtom | ( | Atom const & | atom, |
std::string const & | element | ||
) |
Add a single atom to structure.
Definition at line 80 of file Structure.cpp.
References atoms, elementMap, index, numAtoms, numAtomsPerElement, and nnp::ElementMap::size().
void Structure::readFromFile | ( | std::string const | fileName = "input.data" | ) |
Read configuration from file.
[in] | fileName | Input file name. |
Reads the first configuration found in the input file.
Definition at line 97 of file Structure.cpp.
References readFromFile().
Referenced by nnp::Dataset::distributeStructures(), main(), readFromFile(), and nnp::Prediction::readStructureFromFile().
void Structure::readFromFile | ( | std::ifstream & | file | ) |
Read configuration from file.
[in] | file | Input file stream (already opened). |
Expects that a file with configurations is open, first keyword on first line should be begin
. Reads until keyword is end
.
Definition at line 113 of file Structure.cpp.
References readFromLines(), nnp::reduce(), and nnp::split().
void Structure::readFromLines | ( | std::vector< std::string > const & | lines | ) |
Read configuration from lines.
[in] | lines | One configuration in form of a vector of strings. |
Read the configuration from a vector of strings.
Definition at line 142 of file Structure.cpp.
References atoms, box, calculateInverseBox(), calculateVolume(), chargeRef, comment, elementMap, energyRef, index, isPeriodic, isTriclinic, numAtoms, numAtomsPerElement, numElements, numElementsPresent, nnp::reduce(), remap(), sampleType, nnp::split(), ST_TEST, and ST_TRAINING.
Referenced by readFromFile().
void Structure::calculateMaxCutoffRadiusOverall | ( | EwaldSetup & | ewaldSetup, |
double | rcutScreen, | ||
double | maxCutoffRadius | ||
) |
Calculate maximal cut-off if cut-off of screening and real part Ewald summation are also considered.
[in] | ewaldSetup | Settings of Ewald summation. |
[in] | rcutScreen | Cut-off for Screening of the electrostatic interaction. |
[in] | maxCutoffRadius | maximal cut-off of symmetry functions. |
Definition at line 273 of file Structure.cpp.
References nnp::EwaldSetup::calculateParameters(), isPeriodic, maxCutoffRadiusOverall, numAtoms, nnp::EwaldSetup::params, nnp::EwaldParameters::rCut, and volume.
Referenced by nnp::Mode::evaluateNNP(), nnp::InterfaceLammps::finalizeNeighborList(), and nnp::InterfaceLammps::getMaxCutoffRadiusOverall().
void Structure::calculateNeighborList | ( | double | cutoffRadius, |
bool | sortByDistance = false |
||
) |
Calculate neighbor list for all atoms.
[in] | cutoffRadius | Atoms are neighbors if there distance is smaller than the cutoff radius. |
[in] | sortByDistance | Sort neighborlist from nearest to farthest neighbor. |
Definition at line 287 of file Structure.cpp.
References atoms, box, calculatePbcCopies(), hasNeighborList, isPeriodic, maxCutoffRadiusOverall, nnp::Vec3D::norm(), nnp::Vec3D::norm2(), numAtoms, pbc, and sortNeighborList().
Referenced by calculateNeighborList(), nnp::Mode::evaluateNNP(), and main().
void Structure::calculateNeighborList | ( | double | cutoffRadius, |
std::vector< std::vector< double > > & | cutoffs | ||
) |
Calculate neighbor list for all atoms and setup neighbor cut-off map.
[in] | cutoffRadius | Atoms are neighbors if there distance is smaller than the cutoff radius. |
[in] | cutoffs | Vector of all needed cutoffs (needed for cut-off map construction). |
Definition at line 401 of file Structure.cpp.
References calculateNeighborList(), and setupNeighborCutoffMap().
void Structure::sortNeighborList | ( | ) |
Sort all neighbor lists of this structure with respect to the distance.
Definition at line 409 of file Structure.cpp.
References atoms, NeighborListIsSorted, and numAtoms.
Referenced by calculateNeighborList(), and nnp::InterfaceLammps::finalizeNeighborList().
void Structure::setupNeighborCutoffMap | ( | std::vector< std::vector< double > > | cutoffs | ) |
Set up a neighbor cut-off map which gives the index (value) of the last needed neighbor corresponding to a specific cut-off (key).
[in] | cutoffs | Vector of all needed symmetry function cutoffs. Note that a local copy gets extended with maxCutoffRadiusOverall. |
Definition at line 423 of file Structure.cpp.
References atoms, nnp::Atom::Neighbor::d, maxCutoffRadiusOverall, NeighborListIsSorted, and nnp::vectorContains().
Referenced by calculateNeighborList(), and nnp::InterfaceLammps::finalizeNeighborList().
void Structure::calculatePbcCopies | ( | double | cutoffRadius, |
int(&) | pbc[3] | ||
) |
Calculate required PBC copies.
[in] | cutoffRadius | Cutoff radius for neighbor list. |
[in] | pbc | Array for storing the result. |
Called by calculateNeighborList().
Definition at line 486 of file Structure.cpp.
References box, nnp::Vec3D::cross(), nnp::Vec3D::normalize(), and pbc.
Referenced by calculateNeighborList().
void Structure::calculateInverseBox | ( | ) |
Calculate inverse box.
Simulation box looks like this:
\[ h = \begin{pmatrix} \phantom{a_x} & \phantom{b_x} & \phantom{c_x} \\ \vec{\mathbf{a}} & \vec{\mathbf{b}} & \vec{\mathbf{c}} \\ \phantom{a_z} & \phantom{b_z} & \phantom{c_z} \\ \end{pmatrix} = \begin{pmatrix} a_x & b_x & c_x \\ a_y & b_y & c_y \\ a_z & b_z & c_z \\ \end{pmatrix}, \]
where \(\vec{\mathbf{a}} = \) box[0]
, \(\vec{\mathbf{b}} = \) box[1]
and \(\vec{\mathbf{c}} = \) box[2]
. Thus, indices are column first, row second:
\[ h = \begin{pmatrix} \texttt{box[0][0]} & \texttt{box[1][0]} & \texttt{box[2][0]} \\ \texttt{box[0][1]} & \texttt{box[1][1]} & \texttt{box[2][1]} \\ \texttt{box[0][2]} & \texttt{box[1][2]} & \texttt{box[2][2]} \\ \end{pmatrix}. \]
The inverse box matrix (same scheme as above but with invbox
) can be used to calculate fractional coordinates:
\[ \begin{pmatrix} f_0 \\ f_1 \\ f_2 \end{pmatrix} = h^{-1} \; \vec{\mathbf{r}}. \]
Definition at line 519 of file Structure.cpp.
Referenced by readFromLines(), and nnp::InterfaceLammps::setBoxVectors().
bool Structure::canMinimumImageConventionBeApplied | ( | double | cutoffRadius | ) |
Check if cut-off radius is small enough to apply minimum image convention.
[in] | cutoffRadius | cut-off radius for which condition should be checked. |
Definition at line 548 of file Structure.cpp.
References box, nnp::Vec3D::cross(), and nnp::Vec3D::normalize().
Calculate distance between two atoms in the minimum image convention.
[in] | dr | Distance vector between two atoms of the same box. |
Definition at line 567 of file Structure.cpp.
void Structure::calculateVolume | ( | ) |
Calculate volume from box vectors.
Definition at line 581 of file Structure.cpp.
Referenced by readFromLines(), and nnp::InterfaceLammps::setBoxVectors().
double Structure::calculateElectrostaticEnergy | ( | EwaldSetup & | ewaldSetup, |
Eigen::VectorXd | hardness, | ||
Eigen::MatrixXd | gammaSqrt2, | ||
Eigen::VectorXd | sigmaSqrtPi, | ||
ScreeningFunction const & | fs, | ||
double const | fourPiEps, | ||
ErfcBuf & | erfcBuf | ||
) |
Compute electrostatic energy with global charge equilibration.
[in] | ewaldSetup | Settings of Ewald summation. |
[in] | hardness | Vector containing the hardness of all elements. |
[in] | gammaSqrt2 | Matrix combining gamma with prefactor. \( \text{gammaSqrt2}_{ij} = \sqrt{2} \gamma_{ij} = \sqrt{2} \sqrt{(\sigma_i^2 + \sigma_j^2)} \) |
[in] | sigmaSqrtPi | Vector combining sigma with prefactor, \( \text{sigmaSqrtPi}_i = \sqrt{\pi} \sigma_i \) |
[in] | fs | Screening function. |
[in] | fourPiEps | \( \text{fourPiEps} = 4 \pi \varepsilon_0 \). Value depends on unit system (e.g. normalization). |
[in] | erfcBuf | helper object to avoid repeated calculation of erfc(). |
Definition at line 588 of file Structure.cpp.
References A, atoms, box, calculateScreeningEnergy(), chargeRef, nnp::Atom::chi, nnp::Atom::element, energyElec, nnp::EwaldParameters::eta, nnp::ErfcBuf::getf(), nnp::Atom::getStoredMinNumNeighbors(), hasAMatrix, hasCharges, isPeriodic, nnp::KspaceGrid::kvectors, lambda, NeighborListIsSorted, nnp::Atom::neighbors, numAtoms, nnp::EwaldSetup::params, nnp::Atom::r, nnp::EwaldParameters::rCut, nnp::ErfcBuf::reset(), and nnp::KspaceGrid::setup().
Referenced by nnp::Mode::chargeEquilibration().
double Structure::calculateScreeningEnergy | ( | Eigen::MatrixXd | gammaSqrt2, |
Eigen::VectorXd | sigmaSqrtPi, | ||
ScreeningFunction const & | fs, | ||
double const | fourPiEps | ||
) |
Calculate screening energy which needs to be added (!) to the electrostatic energy in order to remove contributions in the short range domain.
[in] | gammaSqrt2 | Matrix combining gamma with prefactor. \( \text{gammaSqrt2}_{ij} = \sqrt{2} \gamma_{ij} = \sqrt{2} \sqrt{(\sigma_i^2 + \sigma_j^2)} \) |
[in] | sigmaSqrtPi | Vector combining sigma with prefactor, \( \text{sigmaSqrtPi}_i = \sqrt{\pi} \sigma_i \) |
[in] | fs | Screening function. |
[in] | fourPiEps | \( \text{fourPiEps} = 4 \pi \varepsilon_0 \). Value depends on unit system (e.g. normalization). |
Definition at line 746 of file Structure.cpp.
References A, atoms, nnp::Atom::charge, nnp::Atom::element, nnp::ScreeningFunction::f(), nnp::ScreeningFunction::getOuter(), nnp::Atom::getStoredMinNumNeighbors(), isPeriodic, nnp::Atom::neighbors, numAtoms, and nnp::Atom::r.
Referenced by calculateElectrostaticEnergy().
void Structure::calculateDAdrQ | ( | EwaldSetup & | ewaldSetup, |
Eigen::MatrixXd | gammaSqrt2, | ||
double const | fourPiEps, | ||
ErfcBuf & | erfcBuf | ||
) |
Calculates derivative of A-matrix with respect to the atoms positions and contract it with Q.
[in] | ewaldSetup | Settings of Ewald summation. |
[in] | gammaSqrt2 | Matrix combining gamma with prefactor. \( \text{gammaSqrt2}_{ij} = \sqrt{2} \gamma_{ij} = \sqrt{2} \sqrt{(\sigma_i^2 + \sigma_j^2)} \) |
[in] | fourPiEps | \( \text{fourPiEps} = 4 \pi \varepsilon_0 \). Value depends on unit system (e.g. normalization). |
[in] | erfcBuf | helper object to avoid repeated calculation of erfc(). |
Definition at line 844 of file Structure.cpp.
References atoms, box, nnp::Atom::charge, nnp::Atom::dAdrQ, nnp::Atom::element, nnp::EwaldParameters::eta, nnp::ErfcBuf::getf(), nnp::Atom::getStoredMinNumNeighbors(), isPeriodic, nnp::KspaceGrid::kvectors, nnp::Atom::neighbors, numAtoms, nnp::EwaldSetup::params, nnp::Atom::r, nnp::EwaldParameters::rCut, and nnp::KspaceGrid::setup().
Referenced by nnp::Mode::chargeEquilibration().
void Structure::calculateDQdChi | ( | std::vector< Eigen::VectorXd > & | dQdChi | ) |
Calculates derivative of the charges with respect to electronegativities.
[in] | dQdChi | vector to store the result. dQdChi[i](j) represents the derivative for the i-th electronegativity and the j-th charge. |
Definition at line 1005 of file Structure.cpp.
Referenced by nnp::Training::update().
void Structure::calculateDQdJ | ( | std::vector< Eigen::VectorXd > & | dQdJ | ) |
Calculates derivative of the charges with respect to atomic hardness.
[in] | dQdJ | vector to store the result. dQdJ[i](j) represents the derivative for the i-th hardness and the j-th charge. |
Definition at line 1020 of file Structure.cpp.
References A, atoms, nnp::Atom::charge, nnp::Atom::element, numAtoms, and numElements.
Referenced by nnp::Training::update().
void Structure::calculateDQdr | ( | std::vector< size_t > const & | atomsIndices, |
std::vector< size_t > const & | compIndices, | ||
double const | maxCutoffRadius, | ||
std::vector< Element > const & | elements | ||
) |
Calculates derivative of the charges with respect to the atom's position.
[in] | atomIndices | Vector containing indices of atoms for which the derivative should be calculated. |
[in] | compIndices | Vector containing indices of vector components for which the derivative should be calculated. |
[in] | maxCutoffRadius | Max. cutoff radius of symmetry functions. |
[in] | elements | Vector containing all elements (needed for symmetry function table). |
Definition at line 1039 of file Structure.cpp.
References A, atoms, nnp::Atom::calculateDChidr(), nnp::Atom::dAdrQ, nnp::Atom::dQdr, nnp::Atom::element, and numAtoms.
Referenced by nnp::Training::update().
void Structure::calculateElectrostaticEnergyDerivatives | ( | Eigen::VectorXd | hardness, |
Eigen::MatrixXd | gammaSqrt2, | ||
Eigen::VectorXd | sigmaSqrtPi, | ||
ScreeningFunction const & | fs, | ||
double const | fourPiEps | ||
) |
Calculates partial derivatives of electrostatic Energy with respect to atom's coordinates and charges.
[in] | hardness | Vector containing the hardness of all elements. |
[in] | gammaSqrt2 | Matrix combining gamma with prefactor. \( \text{gammaSqrt2}_{ij} = \sqrt{2} \gamma_{ij} = \sqrt{2} \sqrt{(\sigma_i^2 + \sigma_j^2)} \) |
[in] | sigmaSqrtPi | Vector combining sigma with prefactor, \( \text{sigmaSqrtPi}_i = \sqrt{\pi} \sigma_i \) |
[in] | fs | Screening function. |
[in] | fourPiEps | \( \text{fourPiEps} = 4 \pi \varepsilon_0 \). Value depends on unit system (e.g. normalization). |
Definition at line 1083 of file Structure.cpp.
References A, atoms, nnp::Atom::charge, nnp::Atom::dAdrQ, nnp::Atom::dEelecdQ, nnp::ScreeningFunction::df(), nnp::Atom::element, nnp::ScreeningFunction::f(), nnp::ScreeningFunction::getOuter(), isPeriodic, nnp::Atom::neighbors, numAtoms, nnp::Atom::pEelecpr, and nnp::Atom::r.
Referenced by nnp::Mode::chargeEquilibration().
VectorXd const Structure::calculateForceLambdaTotal | ( | ) | const |
Calculate lambda_total vector which is needed for the total force calculation in 4G NN.
Definition at line 1188 of file Structure.cpp.
References A, atoms, nnp::Atom::dEdG, nnp::Atom::dEelecdQ, and numAtoms.
Referenced by nnp::Mode::calculateForces(), and nnp::InterfaceLammps::getForces().
VectorXd const Structure::calculateForceLambdaElec | ( | ) | const |
Calculate lambda_elec vector which is needed for the electrostatic force calculation in 4G NN.
Definition at line 1201 of file Structure.cpp.
References A, atoms, nnp::Atom::dEelecdQ, and numAtoms.
Referenced by nnp::Mode::calculateForces().
void Structure::remap | ( | ) |
Translate all atoms back into box if outside.
Definition at line 1214 of file Structure.cpp.
References atoms, and remap().
Referenced by nnp::Dataset::prepareNumericForces(), readFromLines(), and remap().
void Structure::remap | ( | Atom & | atom | ) |
Translate atom back into box if outside.
[in,out] | atom | Atom to be remapped. |
Definition at line 1223 of file Structure.cpp.
References box, invbox, and nnp::Atom::r.
void Structure::toNormalizedUnits | ( | double | meanEnergy, |
double | convEnergy, | ||
double | convLength, | ||
double | convCharge | ||
) |
Normalize structure, shift energy and change energy, length and charge unit.
[in] | meanEnergy | Mean energy per atom (in old units). |
[in] | convEnergy | Multiplicative energy unit conversion factor. |
[in] | convLength | Multiplicative length unit conversion factor. |
[in] | convCharge | Multiplicative charge unit conversion factor. |
Definition at line 1249 of file Structure.cpp.
References atoms, box, charge, chargeRef, energy, energyRef, invbox, isPeriodic, numAtoms, and volume.
Referenced by nnp::Mode::convertToNormalizedUnits(), nnp::Prediction::readStructureFromFile(), and nnp::InterfaceLammps::writeToFile().
void Structure::toPhysicalUnits | ( | double | meanEnergy, |
double | convEnergy, | ||
double | convLength, | ||
double | convCharge | ||
) |
Switch to physical units, shift energy and change energy, length and charge unit.
[in] | meanEnergy | Mean energy per atom (in old units). |
[in] | convEnergy | Multiplicative energy unit conversion factor. |
[in] | convLength | Multiplicative length unit conversion factor. |
[in] | convCharge | Multiplicative charge unit conversion factor. |
Definition at line 1278 of file Structure.cpp.
References atoms, box, charge, chargeRef, energy, energyRef, invbox, isPeriodic, numAtoms, and volume.
Referenced by nnp::Mode::convertToPhysicalUnits(), nnp::Prediction::predict(), and nnp::InterfaceLammps::writeToFile().
size_t Structure::getMaxNumNeighbors | ( | ) | const |
Find maximum number of neighbors.
Definition at line 473 of file Structure.cpp.
References atoms.
void Structure::freeAtoms | ( | bool | all, |
double const | maxCutoffRadius = 0.0 |
||
) |
Free symmetry function memory for all atoms, see free() in Atom class.
[in] | all | See description in Atom. |
[in] | maxCutoffRadius | Maximum cutoff radius of symmetry functions. |
Definition at line 1307 of file Structure.cpp.
References atoms, hasSymmetryFunctionDerivatives, and hasSymmetryFunctions.
Referenced by nnp::Training::update().
void Structure::reset | ( | ) |
Reset everything but elementMap.
Definition at line 1319 of file Structure.cpp.
References atoms, box, charge, chargeRef, comment, elementMap, energy, energyRef, hasNeighborList, hasSymmetryFunctionDerivatives, hasSymmetryFunctions, index, invbox, isPeriodic, isTriclinic, numAtoms, numAtomsPerElement, numElements, numElementsPresent, pbc, sampleType, nnp::ElementMap::size(), ST_UNKNOWN, and volume.
Referenced by LAMMPS_NS::PairHDNNPExternal::compute(), main(), and nnp::Prediction::readStructureFromFile().
void Structure::clearNeighborList | ( | ) |
Clear neighbor list of all atoms.
Definition at line 1356 of file Structure.cpp.
References atoms, nnp::Atom::clearNeighborList(), hasNeighborList, hasSymmetryFunctionDerivatives, hasSymmetryFunctions, numAtoms, numElements, and nnp::Atom::numNeighborsPerElement.
void Structure::clearElectrostatics | ( | bool | clearDQdr = false | ) |
Clear A-matrix, dAdrQ and optionally dQdr.
[in] | clearDqdr | Specify if dQdr should also be cleared. |
Definition at line 1372 of file Structure.cpp.
References A, atoms, and hasAMatrix.
Referenced by nnp::Training::update().
void Structure::updateError | ( | std::string const & | property, |
std::map< std::string, double > & | error, | ||
std::size_t & | count | ||
) | const |
Update property error metrics with this structure.
[in] | property | One of "energy", "force" or "charge". |
[in,out] | error | Input error metric map to be updated. |
[in,out] | count | Input counter to be updated. |
The "energy" error metric map stores temporary sums for the following metrics:
key "RMSEpa": RMSE of energy per atom key "RMSE" : RMSE of energy key "MAEpa" : MAE of energy per atom key "MAE" : MAE of energy
The "force" error metric map stores temporary sums for the following metrics:
key "RMSE" : RMSE of forces key "MAE" : MAE of forces
The "charge" error metric map stores temporary sums for the following metrics:
key "RMSE" : RMSE of charges key "MAE" : MAE of charges
Definition at line 1386 of file Structure.cpp.
string Structure::getEnergyLine | ( | ) | const |
Get reference and NN energy.
Definition at line 1416 of file Structure.cpp.
References energy, energyRef, index, numAtoms, and nnp::strpr().
vector< string > Structure::getForcesLines | ( | ) | const |
Get reference and NN forces for all atoms.
Definition at line 1424 of file Structure.cpp.
References atoms.
vector< string > Structure::getChargesLines | ( | ) | const |
Get reference and NN charges for all atoms.
Definition at line 1437 of file Structure.cpp.
References atoms.
void Structure::writeToFile | ( | std::string const | fileName = "output.data" , |
bool const | ref = true , |
||
bool const | append = false |
||
) | const |
Write configuration to file.
[in,out] | fileName | Ouptut file name. |
[in] | ref | If true, write reference energy and forces, if false, write NNP results instead. |
[in] | append | If true, append to existing file. |
Definition at line 1449 of file Structure.cpp.
References writeToFile().
Referenced by LAMMPS_NS::PairHDNNPExternal::compute(), main(), nnp::InterfaceLammps::writeToFile(), and writeToFile().
void Structure::writeToFile | ( | std::ofstream *const & | file, |
bool const | ref = true |
||
) | const |
Write configuration to file.
[in,out] | file | Ouptut file. |
[in] | ref | If true, write reference energy and forces, if false, write NNP results instead. |
Definition at line 1474 of file Structure.cpp.
References atoms, box, charge, chargeRef, comment, elementMap, energy, energyRef, isPeriodic, and nnp::strpr().
void Structure::writeToFileXyz | ( | std::ofstream *const & | file | ) | const |
Write configuration to xyz file.
[in,out] | file | xyz output file. |
Definition at line 1533 of file Structure.cpp.
References atoms, box, elementMap, isPeriodic, numAtoms, and nnp::strpr().
Referenced by main().
void Structure::writeToFilePoscar | ( | std::ofstream *const & | file | ) | const |
Write configuration to POSCAR file.
[in,out] | file | POSCAR output file. |
Definition at line 1568 of file Structure.cpp.
References elementMap, nnp::ElementMap::getElementsString(), and writeToFilePoscar().
Referenced by main(), and writeToFilePoscar().
void Structure::writeToFilePoscar | ( | std::ofstream *const & | file, |
std::string const | elements | ||
) | const |
Write configuration to POSCAR file.
[in,out] | file | POSCAR output file. |
[in,out] | elements | User-defined order of elements, e.g. "Zn O Cu". |
Definition at line 1575 of file Structure.cpp.
References atoms, box, comment, elementMap, isPeriodic, numAtomsPerElement, nnp::ElementMap::size(), nnp::split(), and nnp::strpr().
vector< string > Structure::info | ( | ) | const |
Get structure information as a vector of strings.
Definition at line 1641 of file Structure.cpp.
References atoms, box, charge, chargeRef, comment, elementMap, energy, energyRef, hasNeighborList, hasSymmetryFunctionDerivatives, hasSymmetryFunctions, index, nnp::ElementMap::info(), invbox, isPeriodic, isTriclinic, numAtoms, numAtomsPerElement, numElements, numElementsPresent, pbc, sampleType, nnp::strpr(), and volume.
Referenced by main().
ElementMap nnp::Structure::elementMap |
Copy of element map provided as constructor argument.
Definition at line 59 of file Structure.h.
Referenced by addAtom(), info(), readFromLines(), reset(), setElementMap(), writeToFile(), writeToFilePoscar(), and writeToFileXyz().
bool nnp::Structure::isPeriodic |
If periodic boundary conditions apply.
Definition at line 61 of file Structure.h.
Referenced by calculateDAdrQ(), calculateElectrostaticEnergy(), calculateElectrostaticEnergyDerivatives(), calculateMaxCutoffRadiusOverall(), calculateNeighborList(), calculateScreeningEnergy(), LAMMPS_NS::PairHDNNPExternal::compute(), info(), main(), nnp::Dataset::prepareNumericForces(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), nnp::InterfaceLammps::setBoxVectors(), toNormalizedUnits(), toPhysicalUnits(), writeToFile(), writeToFilePoscar(), and writeToFileXyz().
bool nnp::Structure::isTriclinic |
If the simulation box is triclinic.
Definition at line 63 of file Structure.h.
Referenced by LAMMPS_NS::PairHDNNPExternal::compute(), info(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), and nnp::InterfaceLammps::setBoxVectors().
bool nnp::Structure::hasNeighborList |
If the neighbor list has been calculated.
Definition at line 65 of file Structure.h.
Referenced by calculateNeighborList(), clearNeighborList(), info(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), and nnp::InterfaceLammps::setLocalAtoms().
bool nnp::Structure::NeighborListIsSorted |
If the neighbor list has been sorted by distance.
Definition at line 67 of file Structure.h.
Referenced by calculateElectrostaticEnergy(), setupNeighborCutoffMap(), and sortNeighborList().
bool nnp::Structure::hasSymmetryFunctions |
If symmetry function values are saved for each atom.
Definition at line 69 of file Structure.h.
Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), clearNeighborList(), freeAtoms(), info(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), and nnp::InterfaceLammps::setLocalAtoms().
bool nnp::Structure::hasSymmetryFunctionDerivatives |
If symmetry function derivatives are saved for each atom.
Definition at line 71 of file Structure.h.
Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), clearNeighborList(), freeAtoms(), info(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), and nnp::InterfaceLammps::setLocalAtoms().
std::size_t nnp::Structure::index |
Index number of this structure.
Definition at line 73 of file Structure.h.
Referenced by addAtom(), nnp::Dataset::distributeStructures(), getEnergyLine(), info(), main(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Training::selectSets(), nnp::Dataset::sendStructure(), and nnp::InterfaceLammps::setLocalAtoms().
std::size_t nnp::Structure::numAtoms |
Total number of atoms present in this structure.
Definition at line 75 of file Structure.h.
Referenced by addAtom(), nnp::InterfaceLammps::allocateNeighborlists(), nnp::Training::calculateChargeErrorVec(), calculateDAdrQ(), calculateDQdChi(), calculateDQdJ(), calculateDQdr(), calculateElectrostaticEnergy(), calculateElectrostaticEnergyDerivatives(), calculateForceLambdaElec(), calculateForceLambdaTotal(), nnp::Mode::calculateForces(), calculateMaxCutoffRadiusOverall(), calculateNeighborList(), calculateScreeningEnergy(), clearNeighborList(), LAMMPS_NS::PairHDNNPExternal::compute(), nnp::Training::dPdc(), nnp::Training::dPdcN(), nnp::InterfaceLammps::getCharges(), getEnergyLine(), nnp::InterfaceLammps::getForces(), info(), main(), nnp::Mode::normalizedEnergy(), nnp::Mode::physicalEnergy(), nnp::Dataset::prepareNumericForces(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Training::selectSets(), nnp::Dataset::sendStructure(), nnp::InterfaceLammps::setLocalAtomPositions(), nnp::InterfaceLammps::setLocalAtoms(), sortNeighborList(), nnp::Training::sortUpdateCandidates(), toNormalizedUnits(), toPhysicalUnits(), nnp::Training::update(), updateError(), and writeToFileXyz().
std::size_t nnp::Structure::numElements |
Global number of elements (all structures).
Definition at line 77 of file Structure.h.
Referenced by calculateDQdJ(), clearNeighborList(), info(), main(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), and setElementMap().
std::size_t nnp::Structure::numElementsPresent |
Number of elements present in this structure.
Definition at line 79 of file Structure.h.
Referenced by info(), readFromLines(), nnp::Dataset::recvStructure(), reset(), and nnp::Dataset::sendStructure().
int nnp::Structure::pbc[3] |
Number of PBC images necessary in each direction for max cut-off.
Definition at line 81 of file Structure.h.
Referenced by calculateNeighborList(), calculatePbcCopies(), info(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), and Structure().
double nnp::Structure::energy |
Potential energy determined by neural network.
Definition at line 83 of file Structure.h.
Referenced by nnp::Mode::addEnergyOffset(), nnp::Mode::calculateEnergy(), nnp::Training::dPdcN(), nnp::InterfaceLammps::getEnergy(), getEnergyLine(), nnp::Mode::getEnergyWithOffset(), info(), main(), nnp::Mode::normalizedEnergy(), nnp::Mode::physicalEnergy(), nnp::InterfaceLammps::process(), nnp::Dataset::recvStructure(), nnp::Mode::removeEnergyOffset(), reset(), nnp::Dataset::sendStructure(), nnp::InterfaceLammps::setLocalAtoms(), nnp::Training::sortUpdateCandidates(), toNormalizedUnits(), toPhysicalUnits(), nnp::Training::update(), updateError(), and writeToFile().
double nnp::Structure::energyRef |
Reference potential energy.
Definition at line 85 of file Structure.h.
Referenced by nnp::Mode::addEnergyOffset(), getEnergyLine(), nnp::Mode::getEnergyWithOffset(), info(), main(), nnp::Mode::normalizedEnergy(), nnp::Mode::physicalEnergy(), readFromLines(), nnp::Dataset::recvStructure(), nnp::Mode::removeEnergyOffset(), reset(), nnp::Dataset::sendStructure(), nnp::Training::sortUpdateCandidates(), toNormalizedUnits(), toPhysicalUnits(), nnp::Training::update(), updateError(), and writeToFile().
double nnp::Structure::energyShort |
Short-range part of the potential energy predicted by NNP.
Definition at line 88 of file Structure.h.
Referenced by nnp::Mode::calculateEnergy().
double nnp::Structure::energyElec |
Electrostatics part of the potential energy predicted by NNP.
Definition at line 91 of file Structure.h.
Referenced by calculateElectrostaticEnergy(), nnp::Mode::calculateEnergy(), and main().
bool nnp::Structure::hasCharges |
If all charges of this structure have been calculated (and stay the same, e.g.
for stage 2).
Definition at line 94 of file Structure.h.
Referenced by calculateElectrostaticEnergy(), and nnp::Training::update().
double nnp::Structure::charge |
Charge determined by neural network potential.
Definition at line 96 of file Structure.h.
Referenced by nnp::Mode::calculateCharge(), info(), main(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), toNormalizedUnits(), toPhysicalUnits(), and writeToFile().
double nnp::Structure::chargeRef |
Reference charge.
Definition at line 98 of file Structure.h.
Referenced by calculateElectrostaticEnergy(), info(), main(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), toNormalizedUnits(), toPhysicalUnits(), and writeToFile().
double nnp::Structure::volume |
Simulation box volume.
Definition at line 100 of file Structure.h.
Referenced by calculateMaxCutoffRadiusOverall(), calculateVolume(), info(), main(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), toNormalizedUnits(), and toPhysicalUnits().
double nnp::Structure::maxCutoffRadiusOverall |
Maximum cut-off radius with respect to symmetry functions, screening function and Ewald summation.
Definition at line 103 of file Structure.h.
Referenced by calculateMaxCutoffRadiusOverall(), calculateNeighborList(), nnp::InterfaceLammps::getMaxCutoffRadiusOverall(), and setupNeighborCutoffMap().
double nnp::Structure::lambda |
Lagrange multiplier used for charge equilibration.
Definition at line 106 of file Structure.h.
Referenced by calculateElectrostaticEnergy().
SampleType nnp::Structure::sampleType |
Sample type (training or test set).
Definition at line 108 of file Structure.h.
Referenced by info(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Training::selectSets(), and nnp::Dataset::sendStructure().
std::string nnp::Structure::comment |
Structure comment.
Definition at line 110 of file Structure.h.
Referenced by nnp::Dataset::calculateBufferSize(), info(), main(), nnp::Dataset::prepareNumericForces(), readFromLines(), nnp::Dataset::recvStructure(), reset(), nnp::Dataset::sendStructure(), writeToFile(), and writeToFilePoscar().
Vec3D nnp::Structure::box[3] |
Simulation box vectors.
Definition at line 112 of file Structure.h.
Referenced by applyMinimumImageConvention(), calculateDAdrQ(), calculateElectrostaticEnergy(), calculateInverseBox(), calculateNeighborList(), calculatePbcCopies(), calculateVolume(), canMinimumImageConventionBeApplied(), LAMMPS_NS::PairHDNNPExternal::compute(), info(), main(), readFromLines(), nnp::Dataset::recvStructure(), remap(), reset(), nnp::Dataset::sendStructure(), nnp::InterfaceLammps::setBoxVectors(), Structure(), toNormalizedUnits(), toPhysicalUnits(), writeToFile(), writeToFilePoscar(), and writeToFileXyz().
Vec3D nnp::Structure::invbox[3] |
Inverse simulation box vectors.
Definition at line 114 of file Structure.h.
Referenced by applyMinimumImageConvention(), calculateInverseBox(), info(), nnp::Dataset::recvStructure(), remap(), reset(), nnp::Dataset::sendStructure(), Structure(), toNormalizedUnits(), and toPhysicalUnits().
Eigen::MatrixXd nnp::Structure::A |
Global charge equilibration matrix A'.
Definition at line 116 of file Structure.h.
Referenced by calculateDQdChi(), calculateDQdJ(), calculateDQdr(), calculateElectrostaticEnergy(), calculateElectrostaticEnergyDerivatives(), calculateForceLambdaElec(), calculateForceLambdaTotal(), calculateScreeningEnergy(), and clearElectrostatics().
bool nnp::Structure::hasAMatrix |
If A matrix of this structure is currently stored.
Definition at line 118 of file Structure.h.
Referenced by calculateElectrostaticEnergy(), clearElectrostatics(), and nnp::Training::update().
std::vector<std::size_t> nnp::Structure::numAtomsPerElement |
Number of atoms of each element in this structure.
Definition at line 120 of file Structure.h.
Referenced by addAtom(), nnp::Mode::addEnergyOffset(), nnp::Dataset::calculateBufferSize(), nnp::Mode::getEnergyOffset(), nnp::Mode::getEnergyWithOffset(), info(), main(), readFromLines(), nnp::Dataset::recvStructure(), nnp::Mode::removeEnergyOffset(), reset(), nnp::Training::selectSets(), nnp::Dataset::sendStructure(), setElementMap(), nnp::InterfaceLammps::setLocalAtoms(), nnp::Training::update(), and writeToFilePoscar().
std::vector<Atom> nnp::Structure::atoms |
Vector of all atoms in this structure.
Definition at line 122 of file Structure.h.
Referenced by addAtom(), nnp::InterfaceLammps::addNeighbor(), nnp::InterfaceLammps::allocateNeighborlists(), nnp::Mode::calculateAtomicNeuralNetworks(), nnp::Dataset::calculateBufferSize(), nnp::Mode::calculateCharge(), nnp::Training::calculateChargeErrorVec(), calculateDAdrQ(), calculateDQdJ(), calculateDQdr(), calculateElectrostaticEnergy(), calculateElectrostaticEnergyDerivatives(), nnp::Mode::calculateEnergy(), calculateForceLambdaElec(), calculateForceLambdaTotal(), nnp::Mode::calculateForces(), calculateNeighborList(), calculateScreeningEnergy(), nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), nnp::Training::calculateWeightDerivatives(), clearElectrostatics(), clearNeighborList(), LAMMPS_NS::PairHDNNPExternal::compute(), nnp::Training::dPdc(), nnp::Training::dPdcN(), nnp::Mode::evaluateNNP(), nnp::InterfaceLammps::finalizeNeighborList(), freeAtoms(), nnp::InterfaceLammps::getAtomicEnergy(), nnp::InterfaceLammps::getCharges(), getChargesLines(), nnp::InterfaceLammps::getForces(), getForcesLines(), getMaxNumNeighbors(), info(), main(), nnp::Dataset::prepareNumericForces(), readFromLines(), nnp::Dataset::recvStructure(), remap(), reset(), nnp::Training::selectSets(), nnp::Dataset::sendStructure(), nnp::InterfaceLammps::setLocalAtomPositions(), nnp::InterfaceLammps::setLocalAtoms(), nnp::InterfaceLammps::setLocalTags(), setupNeighborCutoffMap(), sortNeighborList(), nnp::Training::sortUpdateCandidates(), toNormalizedUnits(), toPhysicalUnits(), nnp::Training::update(), updateError(), writeToFile(), writeToFilePoscar(), and writeToFileXyz().