n2p2 - A neural network potential package
InterfaceLammps.h
Go to the documentation of this file.
1// n2p2 - A neural network potential package
2// Copyright (C) 2018 Andreas Singraber (University of Vienna)
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17#ifndef INTERFACELAMMPS_H
18#define INTERFACELAMMPS_H
19
20#include "Mode.h"
21#include "Structure.h"
22#include <map> // std::map
23#include <cstddef> // std::size_t
24#include <cstdint> // int64_t
25#include <string> // std::string
26
27namespace nnp
28{
29
30class InterfaceLammps : public Mode
31{
32public:
34
53 void initialize(char const* const& directory,
54 char const* const& emap,
55 bool showew,
56 bool resetew,
57 int showewsum,
58 int maxew,
59 double cflength,
60 double cfenergy,
61 double lammpsCutoff,
62 int lammpsNtypes,
63 int myRank);
69 void setLocalAtoms(int numAtomsLocal,
70 int const* const atomType);
75 void setLocalTags(int const* const atomTag);
80 void setLocalTags(int64_t const* const atomTag);
94 void addNeighbor(int i,
95 int j,
96 int64_t tag,
97 int type,
98 double dx,
99 double dy,
100 double dz,
101 double d2);
105 void process();
110 double getEnergy() const;
119 double getAtomicEnergy(int index) const;
124 void getForces(double* const* const& atomF) const;
129 bool isInitialized() const;
134 double getMaxCutoffRadius() const;
139 long getEWBufferSize() const;
145 void fillEWBuffer(char* const& buf, int bs) const;
151 void extractEWBuffer(char const* const& buf, int bs);
158
159protected:
165 bool showew;
171 int maxew;
173 double cflength;
175 double cfenergy;
177 std::string emap;
179 std::vector<size_t> indexMap;
181 std::map<int, bool> ignoreType;
183 std::map<int, std::size_t> mapTypeToElement;
185 std::map<std::size_t, int> mapElementToType;
188};
189
191// Inlined function definitions //
193
195{
196 return initialized;
197}
198
199}
200
201#endif
Structure structure
Structure containing local atoms.
long getEWBufferSize() const
Calculate buffer size for extrapolation warning communication.
bool initialized
Initialization state.
void process()
Calculate symmetry functions, atomic neural networks and sum of local energy contributions.
void extractEWBuffer(char const *const &buf, int bs)
Extract given buffer to symmetry function statistics class.
std::map< int, bool > ignoreType
True if atoms of this LAMMPS type will be ignored.
void setLocalTags(int const *const atomTag)
Set atom tags (int version, -DLAMMPS_SMALLBIG).
std::map< int, std::size_t > mapTypeToElement
Map from LAMMPS type to n2p2 element index.
double getEnergy() const
Return sum of local energy contributions.
void fillEWBuffer(char *const &buf, int bs) const
Fill provided buffer with extrapolation warning entries.
double getAtomicEnergy(int index) const
Return energy contribution of one atom.
void getForces(double *const *const &atomF) const
Calculate forces and add to LAMMPS atomic force arrays.
bool resetew
Corresponds to LAMMPS resetew keyword.
bool isInitialized() const
Check if this interface is correctly initialized.
void writeExtrapolationWarnings()
Write extrapolation warnings to log.
std::vector< size_t > indexMap
Map from LAMMPS index to n2p2 atom index.
double cfenergy
Corresponds to LAMMPS cfenergy keyword.
void setLocalAtoms(int numAtomsLocal, int const *const atomType)
(Re)set structure to contain only local LAMMPS atoms.
bool showew
Corresponds to LAMMPS showew keyword.
int showewsum
Corresponds to LAMMPS showewsum keyword.
void clearExtrapolationWarnings()
Clear extrapolation warnings storage.
std::map< std::size_t, int > mapElementToType
Map from n2p2 element index to LAMMPS type.
int myRank
Process rank.
double getMaxCutoffRadius() const
Get largest cutoff.
int maxew
Corresponds to LAMMPS maxew keyword.
void addNeighbor(int i, int j, int64_t tag, int type, double dx, double dy, double dz, double d2)
Add one neighbor to atom (int64_t version, -DLAMMPS_BIGBIG).
double cflength
Corresponds to LAMMPS cflength keyword.
std::string emap
Corresponds to LAMMPS map keyword.
Base class for all NNP applications.
Definition: Mode.h:83
void initialize()
Write welcome message with version information.
Definition: Mode.cpp:50
Definition: Atom.h:28
Storage for one atomic configuration.
Definition: Structure.h:34