n2p2 - A neural network potential package
nnp::Prediction Class Reference

#include <Prediction.h>

Inheritance diagram for nnp::Prediction:
Collaboration diagram for nnp::Prediction:

Public Member Functions

 Prediction ()
 
void readStructureFromFile (std::string const &fileName="input.data")
 
void setup ()
 
void predict ()
 
- Public Member Functions inherited from nnp::Mode
 Mode ()
 
void initialize ()
 Write welcome message with version information. More...
 
void loadSettingsFile (std::string const &fileName="input.nn")
 Open settings file and load all keywords into memory. More...
 
void setupGeneric (bool skipNormalize=false)
 Combine multiple setup routines and provide a basic NNP setup. More...
 
void setupNormalization (bool standalone=true)
 Set up normalization. More...
 
virtual void setupElementMap ()
 Set up the element map. More...
 
virtual void setupElements ()
 Set up all Element instances. More...
 
void setupCutoff ()
 Set up cutoff function for all symmetry functions. More...
 
virtual void setupSymmetryFunctions ()
 Set up all symmetry functions. More...
 
void setupSymmetryFunctionScalingNone ()
 Set up "empy" symmetry function scaling. More...
 
virtual void setupSymmetryFunctionScaling (std::string const &fileName="scaling.data")
 Set up symmetry function scaling from file. More...
 
virtual void setupSymmetryFunctionGroups ()
 Set up symmetry function groups. More...
 
virtual void setupSymmetryFunctionCache (bool verbose=false)
 Set up symmetry function cache. More...
 
void setupSymmetryFunctionMemory (bool verbose=false)
 Extract required memory dimensions for symmetry function derivatives. More...
 
void setupSymmetryFunctionStatistics (bool collectStatistics, bool collectExtrapolationWarnings, bool writeExtrapolationWarnings, bool stopOnExtrapolationWarnings)
 Set up symmetry function statistics collection. More...
 
virtual void setupNeuralNetwork ()
 Set up neural networks for all elements. More...
 
virtual void setupNeuralNetworkWeights (std::string const &fileNameFormatShort="weights.%03zu.data", std::string const &fileNameFormatCharge="weightse.%03zu.data")
 Set up neural network weights from files. More...
 
void calculateSymmetryFunctions (Structure &structure, bool const derivatives)
 Calculate all symmetry functions for all atoms in given structure. More...
 
void calculateSymmetryFunctionGroups (Structure &structure, bool const derivatives)
 Calculate all symmetry function groups for all atoms in given structure. More...
 
void calculateAtomicNeuralNetworks (Structure &structure, bool const derivatives)
 Calculate a single atomic neural network for a given atom and nn type. More...
 
void calculateEnergy (Structure &structure) const
 Calculate potential energy for a given structure. More...
 
void calculateCharge (Structure &structure) const
 Calculate total charge for a given structure. More...
 
void calculateForces (Structure &structure) const
 Calculate forces for all atoms in given structure. More...
 
void addEnergyOffset (Structure &structure, bool ref=true)
 Add atomic energy offsets to reference energy. More...
 
void removeEnergyOffset (Structure &structure, bool ref=true)
 Remove atomic energy offsets from reference energy. More...
 
double getEnergyOffset (Structure const &structure) const
 Get atomic energy offset for given structure. More...
 
double getEnergyWithOffset (Structure const &structure, bool ref=true) const
 Add atomic energy offsets and return energy. More...
 
double normalized (std::string const &property, double value) const
 Apply normalization to given property. More...
 
double normalizedEnergy (Structure const &structure, bool ref=true) const
 Apply normalization to given energy of structure. More...
 
double physical (std::string const &property, double value) const
 Undo normalization for a given property. More...
 
double physicalEnergy (Structure const &structure, bool ref=true) const
 Undo normalization for a given energy of structure. More...
 
void convertToNormalizedUnits (Structure &structure) const
 Convert one structure to normalized units. More...
 
void convertToPhysicalUnits (Structure &structure) const
 Convert one structure to physical units. More...
 
std::size_t getNumExtrapolationWarnings () const
 Count total number of extrapolation warnings encountered for all elements and symmetry functions. More...
 
void resetExtrapolationWarnings ()
 Erase all extrapolation warnings and reset counters. More...
 
NNPType getNnpType () const
 Getter for Mode::nnpType. More...
 
double getMeanEnergy () const
 Getter for Mode::meanEnergy. More...
 
double getConvEnergy () const
 Getter for Mode::convEnergy. More...
 
double getConvLength () const
 Getter for Mode::convLength. More...
 
double getMaxCutoffRadius () const
 Getter for Mode::maxCutoffRadius. More...
 
std::size_t getNumElements () const
 Getter for Mode::numElements. More...
 
std::vector< std::size_t > getNumSymmetryFunctions () const
 Get number of symmetry functions per element. More...
 
bool useNormalization () const
 Check if normalization is enabled. More...
 
bool settingsKeywordExists (std::string const &keyword) const
 Check if keyword was found in settings file. More...
 
std::string settingsGetValue (std::string const &keyword) const
 Get value for given keyword in Settings instance. More...
 
std::vector< std::size_t > pruneSymmetryFunctionsRange (double threshold)
 Prune symmetry functions according to their range and write settings file. More...
 
std::vector< std::size_t > pruneSymmetryFunctionsSensitivity (double threshold, std::vector< std::vector< double > > sensitivity)
 Prune symmetry functions with sensitivity analysis data. More...
 
void writePrunedSettingsFile (std::vector< std::size_t > prune, std::string fileName="output.nn") const
 Copy settings file but comment out lines provided. More...
 
void writeSettingsFile (std::ofstream *const &file) const
 Write complete settings file. More...
 

Public Attributes

std::string fileNameSettings
 
std::string fileNameScaling
 
std::string formatWeightsFilesShort
 
std::string formatWeightsFilesCharge
 
Structure structure
 
- Public Attributes inherited from nnp::Mode
ElementMap elementMap
 Global element map, populated by setupElementMap(). More...
 
Log log
 Global log file. More...
 

Additional Inherited Members

- Public Types inherited from nnp::Mode
enum class  NNPType { SHORT_ONLY , SHORT_CHARGE_NN }
 
- Protected Member Functions inherited from nnp::Mode
void readNeuralNetworkWeights (std::string const &type, std::string const &fileName)
 Read in weights for a specific type of neural network. More...
 
- Protected Attributes inherited from nnp::Mode
NNPType nnpType
 
bool normalize
 
bool checkExtrapolationWarnings
 
bool useChargeNN
 
std::size_t numElements
 
std::vector< std::size_t > minNeighbors
 
std::vector< double > minCutoffRadius
 
double maxCutoffRadius
 
double cutoffAlpha
 
double meanEnergy
 
double convEnergy
 
double convLength
 
Settings settings
 
SymFnc::ScalingType scalingType
 
CutoffFunction::CutoffType cutoffType
 
std::vector< Elementelements
 

Detailed Description

Definition at line 27 of file Prediction.h.

Constructor & Destructor Documentation

◆ Prediction()

Prediction::Prediction ( )

Definition at line 25 of file Prediction.cpp.

25 : Mode(),
26 fileNameSettings ("input.nn" ),
27 fileNameScaling ("scaling.data" ),
28 formatWeightsFilesShort ("weights.%03zu.data" ),
29 formatWeightsFilesCharge("weightse.%03zu.data")
30{
31}
Mode()
Definition: Mode.cpp:37
std::string fileNameSettings
Definition: Prediction.h:35
std::string formatWeightsFilesShort
Definition: Prediction.h:37
std::string formatWeightsFilesCharge
Definition: Prediction.h:38
std::string fileNameScaling
Definition: Prediction.h:36

Member Function Documentation

◆ readStructureFromFile()

void Prediction::readStructureFromFile ( std::string const &  fileName = "input.data")

Definition at line 44 of file Prediction.cpp.

45{
46 ifstream file;
47 file.open(fileName.c_str());
50 structure.readFromFile(fileName);
52 if (normalize)
53 {
55 }
56 file.close();
57
58 return;
59}
bool normalize
Definition: Mode.h:514
double convEnergy
Definition: Mode.h:523
ElementMap elementMap
Global element map, populated by setupElementMap().
Definition: Mode.h:508
double convLength
Definition: Mode.h:524
double meanEnergy
Definition: Mode.h:522
void removeEnergyOffset(Structure &structure, bool ref=true)
Remove atomic energy offsets from reference energy.
Definition: Mode.cpp:1480
Structure structure
Definition: Prediction.h:39
void setElementMap(ElementMap const &elementMap)
Set element map of structure.
Definition: Structure.cpp:60
void readFromFile(std::string const fileName="input.data")
Read configuration from file.
Definition: Structure.cpp:86
void reset()
Reset everything but elementMap.
Definition: Structure.cpp:543
void toNormalizedUnits(double meanEnergy, double convEnergy, double convLength)
Normalize structure, shift energy and change energy and length unit.
Definition: Structure.cpp:479

References nnp::Mode::convEnergy, nnp::Mode::convLength, nnp::Mode::elementMap, nnp::Mode::meanEnergy, nnp::Mode::normalize, nnp::Structure::readFromFile(), nnp::Mode::removeEnergyOffset(), nnp::Structure::reset(), nnp::Structure::setElementMap(), structure, and nnp::Structure::toNormalizedUnits().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup()

void Prediction::setup ( )

Definition at line 33 of file Prediction.cpp.

34{
35 initialize();
41 setupSymmetryFunctionStatistics(false, false, true, false);
42}
void initialize()
Write welcome message with version information.
Definition: Mode.cpp:50
virtual void setupNeuralNetworkWeights(std::string const &fileNameFormatShort="weights.%03zu.data", std::string const &fileNameFormatCharge="weightse.%03zu.data")
Set up neural network weights from files.
Definition: Mode.cpp:1126
virtual void setupSymmetryFunctionScaling(std::string const &fileName="scaling.data")
Set up symmetry function scaling from file.
Definition: Mode.cpp:532
void setupGeneric(bool skipNormalize=false)
Combine multiple setup routines and provide a basic NNP setup.
Definition: Mode.cpp:197
void setupSymmetryFunctionStatistics(bool collectStatistics, bool collectExtrapolationWarnings, bool writeExtrapolationWarnings, bool stopOnExtrapolationWarnings)
Set up symmetry function statistics collection.
Definition: Mode.cpp:923
void loadSettingsFile(std::string const &fileName="input.nn")
Open settings file and load all keywords into memory.
Definition: Mode.cpp:156

References fileNameScaling, fileNameSettings, formatWeightsFilesCharge, formatWeightsFilesShort, nnp::Mode::initialize(), nnp::Mode::loadSettingsFile(), nnp::Mode::setupGeneric(), nnp::Mode::setupNeuralNetworkWeights(), nnp::Mode::setupSymmetryFunctionScaling(), and nnp::Mode::setupSymmetryFunctionStatistics().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ predict()

void Prediction::predict ( )

Definition at line 61 of file Prediction.cpp.

62{
64#ifdef N2P2_NO_SF_GROUPS
66#else
68#endif
73 if (normalize)
74 {
76 }
79
80 return;
81}
NNPType nnpType
Definition: Mode.h:513
void addEnergyOffset(Structure &structure, bool ref=true)
Add atomic energy offsets to reference energy.
Definition: Mode.cpp:1461
double maxCutoffRadius
Definition: Mode.h:520
@ SHORT_CHARGE_NN
Short range NNP with additional charge NN (M. Bircher).
void calculateAtomicNeuralNetworks(Structure &structure, bool const derivatives)
Calculate a single atomic neural network for a given atom and nn type.
Definition: Mode.cpp:1310
void calculateEnergy(Structure &structure) const
Calculate potential energy for a given structure.
Definition: Mode.cpp:1366
void calculateSymmetryFunctionGroups(Structure &structure, bool const derivatives)
Calculate all symmetry function groups for all atoms in given structure.
Definition: Mode.cpp:1230
void calculateCharge(Structure &structure) const
Calculate total charge for a given structure.
Definition: Mode.cpp:1379
void calculateSymmetryFunctions(Structure &structure, bool const derivatives)
Calculate all symmetry functions for all atoms in given structure.
Definition: Mode.cpp:1150
void calculateForces(Structure &structure) const
Calculate forces for all atoms in given structure.
Definition: Mode.cpp:1392
void toPhysicalUnits(double meanEnergy, double convEnergy, double convLength)
Switch to physical units, shift energy and change energy and length unit.
Definition: Structure.cpp:505
void calculateNeighborList(double cutoffRadius)
Calculate neighbor list for all atoms.
Definition: Structure.cpp:253

References nnp::Mode::addEnergyOffset(), nnp::Mode::calculateAtomicNeuralNetworks(), nnp::Mode::calculateCharge(), nnp::Mode::calculateEnergy(), nnp::Mode::calculateForces(), nnp::Structure::calculateNeighborList(), nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), nnp::Mode::convEnergy, nnp::Mode::convLength, nnp::Mode::maxCutoffRadius, nnp::Mode::meanEnergy, nnp::Mode::nnpType, nnp::Mode::normalize, nnp::Mode::SHORT_CHARGE_NN, structure, and nnp::Structure::toPhysicalUnits().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fileNameSettings

std::string nnp::Prediction::fileNameSettings

Definition at line 35 of file Prediction.h.

Referenced by setup().

◆ fileNameScaling

std::string nnp::Prediction::fileNameScaling

Definition at line 36 of file Prediction.h.

Referenced by setup().

◆ formatWeightsFilesShort

std::string nnp::Prediction::formatWeightsFilesShort

Definition at line 37 of file Prediction.h.

Referenced by setup().

◆ formatWeightsFilesCharge

std::string nnp::Prediction::formatWeightsFilesCharge

Definition at line 38 of file Prediction.h.

Referenced by setup().

◆ structure

Structure nnp::Prediction::structure

Definition at line 39 of file Prediction.h.

Referenced by main(), predict(), and readStructureFromFile().


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