n2p2 - A neural network potential package
|
Base class for all NNP applications. More...
#include <Mode.h>
Public Types | |
enum class | NNPType { SHORT_ONLY , SHORT_CHARGE_NN } |
Public Member Functions | |
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 | |
ElementMap | elementMap |
Global element map, populated by setupElementMap(). More... | |
Log | log |
Global log file. More... | |
Protected Member Functions | |
void | readNeuralNetworkWeights (std::string const &type, std::string const &fileName) |
Read in weights for a specific type of neural network. More... | |
Protected Attributes | |
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< Element > | elements |
Base class for all NNP applications.
This top-level class is the anchor point for existing and future applications. It contains functions to set up an existing neural network potential and calculate energies and forces for configurations given as Structure. A minimal setup requires some consecutive functions calls as this minimal example shows:
To load weights and scaling information from files add these lines:
The NNP is now ready! If we load a structure from a data file:
we can finally predict the energy and forces from the neural network potential:
The resulting potential energy is stored in Structure::energy, the forces on individual atoms are located within the Structure::atoms vector in Atom::f.
|
strong |
Mode::Mode | ( | ) |
Definition at line 37 of file Mode.cpp.
void Mode::initialize | ( | ) |
Write welcome message with version information.
Definition at line 50 of file Mode.cpp.
References log, N2P2_GIT_BRANCH, N2P2_GIT_REV, N2P2_GIT_VERSION, and N2P2_VERSION.
Referenced by nnp::InterfaceLammps::initialize(), main(), and nnp::Prediction::setup().
void Mode::loadSettingsFile | ( | std::string const & | fileName = "input.nn" | ) |
Open settings file and load all keywords into memory.
[in] | fileName | Settings file name. |
Definition at line 156 of file Mode.cpp.
References nnp::Settings::info(), nnp::Settings::keywordExists(), nnp::Settings::loadFile(), log, nnpType, settings, SHORT_CHARGE_NN, SHORT_ONLY, nnp::strpr(), and useChargeNN.
Referenced by nnp::InterfaceLammps::initialize(), main(), and nnp::Prediction::setup().
void Mode::setupGeneric | ( | bool | skipNormalize = false | ) |
Combine multiple setup routines and provide a basic NNP setup.
[in] | skipNormalize | Whether to skip normalization setup. |
Sets up elements, symmetry functions, symmetry function groups, neural networks. No symmetry function scaling data is read, no weights are set.
Definition at line 197 of file Mode.cpp.
References setupCutoff(), setupElementMap(), setupElements(), setupNeuralNetwork(), setupNormalization(), setupSymmetryFunctionCache(), setupSymmetryFunctionGroups(), setupSymmetryFunctionMemory(), and setupSymmetryFunctions().
Referenced by nnp::InterfaceLammps::initialize(), main(), and nnp::Prediction::setup().
void Mode::setupNormalization | ( | bool | standalone = true | ) |
Set up normalization.
[in] | standalone | Whether to write section header and footer. |
If the keywords mean_energy
, conv_length
and conv_length
are present, the provided conversion factors are used to internally use a different unit system.
Definition at line 218 of file Mode.cpp.
References convEnergy, convLength, nnp::Settings::keywordExists(), log, meanEnergy, normalize, settings, and nnp::strpr().
Referenced by nnp::Training::dataSetNormalization(), and setupGeneric().
|
virtual |
Set up the element map.
Uses keyword elements
. This function should follow immediately after settings are loaded via loadSettingsFile().
Reimplemented in nnp::ModeCabana< t_device >.
Definition at line 273 of file Mode.cpp.
References nnp::ElementMap::atomicNumber(), elementMap, log, nnp::ElementMap::registerElements(), settings, nnp::ElementMap::size(), and nnp::strpr().
Referenced by main(), and setupGeneric().
|
virtual |
Set up all Element instances.
Uses keywords number_of_elements
and atom_energy
. This function should follow immediately after setupElementMap().
Reimplemented in nnp::ModeCabana< t_device >.
Definition at line 294 of file Mode.cpp.
References elementMap, elements, nnp::Settings::getValues(), nnp::Settings::keywordExists(), log, numElements, nnp::reduce(), settings, nnp::ElementMap::size(), nnp::split(), and nnp::strpr().
Referenced by main(), and setupGeneric().
void Mode::setupCutoff | ( | ) |
Set up cutoff function for all symmetry functions.
Uses keyword cutoff_type
. Cutoff parameters are read from settings keywords and stored internally. As soon as setupSymmetryFunctions() is called the settings are restored and used for all symmetry functions. Thus, this function must be called before setupSymmetryFunctions().
Definition at line 340 of file Mode.cpp.
References nnp::CutoffFunction::CT_COS, nnp::CutoffFunction::CT_EXP, nnp::CutoffFunction::CT_HARD, nnp::CutoffFunction::CT_POLY1, nnp::CutoffFunction::CT_POLY2, nnp::CutoffFunction::CT_POLY3, nnp::CutoffFunction::CT_POLY4, nnp::CutoffFunction::CT_TANH, nnp::CutoffFunction::CT_TANHU, cutoffAlpha, cutoffType, log, settings, nnp::split(), and nnp::strpr().
Referenced by main(), and setupGeneric().
|
virtual |
Set up all symmetry functions.
Uses keyword symfunction_short
. Reads all symmetry functions from settings and automatically assigns them to the correct element.
Reimplemented in nnp::ModeCabana< t_device >.
Definition at line 435 of file Mode.cpp.
References convLength, cutoffAlpha, cutoffType, elementMap, elements, nnp::Settings::getValues(), log, maxCutoffRadius, minCutoffRadius, minNeighbors, normalize, numElements, nnp::reduce(), settings, nnp::split(), and nnp::strpr().
Referenced by nnp::Training::dataSetNormalization(), main(), and setupGeneric().
void Mode::setupSymmetryFunctionScalingNone | ( | ) |
Set up "empy" symmetry function scaling.
Does not use any keywords. Sets no scaling for all symmetry functions. Call after setupSymmetryFunctions(). Alternatively set scaling via setupSymmetryFunctionScaling().
Definition at line 512 of file Mode.cpp.
Referenced by main().
|
virtual |
Set up symmetry function scaling from file.
[in] | fileName | Scaling file name. |
Uses keywords scale_symmetry_functions
, center_symmetry_functions
, scale_symmetry_functions_sigma
, scale_min_short
and scale_max_short
. Reads in scaling information and sets correct scaling behavior for all symmetry functions. Call after setupSymmetryFunctions().
Reimplemented in nnp::ModeCabana< t_device >.
Definition at line 532 of file Mode.cpp.
References elements, nnp::Settings::keywordExists(), log, scalingType, settings, nnp::SymFnc::ST_CENTER, nnp::SymFnc::ST_NONE, nnp::SymFnc::ST_SCALE, nnp::SymFnc::ST_SCALECENTER, nnp::SymFnc::ST_SCALESIGMA, and nnp::strpr().
Referenced by nnp::Training::dataSetNormalization(), nnp::InterfaceLammps::initialize(), main(), and nnp::Prediction::setup().
|
virtual |
Set up symmetry function groups.
Does not use any keywords. Call after setupSymmetryFunctions() and ensure that correct scaling behavior has already been set.
Reimplemented in nnp::ModeCabana< t_device >.
Definition at line 662 of file Mode.cpp.
References elements, log, and nnp::strpr().
Referenced by nnp::Training::dataSetNormalization(), and setupGeneric().
|
virtual |
Set up symmetry function cache.
[in] | verbose | If true, print more cache information. |
Searches symmetry functions for identical cutoff functions or compact function (i.e. all cachable stuff) and sets up a caching index.
Definition at line 804 of file Mode.cpp.
References elementMap, elements, nnp::SymFnc::getCacheIdentifiers(), nnp::SymFnc::getIndex(), nnp::Element::getSymbol(), nnp::Element::getSymmetryFunction(), log, numElements, nnp::Element::numSymmetryFunctions(), nnp::Element::setCacheIndices(), nnp::split(), and nnp::strpr().
Referenced by nnp::Training::dataSetNormalization(), and setupGeneric().
void Mode::setupSymmetryFunctionMemory | ( | bool | verbose = false | ) |
Extract required memory dimensions for symmetry function derivatives.
[in] | verbose | If true, print all symmetry function lines. |
Call after symmetry functions have been set up and sorted.
Definition at line 714 of file Mode.cpp.
References elementMap, elements, nnp::SymFnc::getIndex(), nnp::SymFnc::getIndexPerElement(), log, numElements, nnp::SymFnc::parameterLine(), and nnp::strpr().
Referenced by nnp::Training::dataSetNormalization(), and setupGeneric().
void Mode::setupSymmetryFunctionStatistics | ( | bool | collectStatistics, |
bool | collectExtrapolationWarnings, | ||
bool | writeExtrapolationWarnings, | ||
bool | stopOnExtrapolationWarnings | ||
) |
Set up symmetry function statistics collection.
[in] | collectStatistics | Whether statistics (min, max, mean, sigma) is collected. |
[in] | collectExtrapolationWarnings | Whether extrapolation warnings are logged. |
[in] | writeExtrapolationWarnings | Write extrapolation warnings immediately when they occur. |
[in] | stopOnExtrapolationWarnings | Throw error immediately when an extrapolation warning occurs. |
Does not use any keywords. Calling this setup function is not required, by default no statistics collection is enabled (all arguments false
). Call after setupElements().
Definition at line 923 of file Mode.cpp.
References checkExtrapolationWarnings, elements, log, and nnp::strpr().
Referenced by nnp::Training::dataSetNormalization(), nnp::InterfaceLammps::initialize(), main(), and nnp::Prediction::setup().
|
virtual |
Set up neural networks for all elements.
Uses keywords global_hidden_layers_short
, global_nodes_short
, global_activation_short
, normalize_nodes
. Call after setupSymmetryFunctions(), only then the number of input layer neurons is known.
Reimplemented in nnp::ModeCabana< t_device >.
Definition at line 963 of file Mode.cpp.
References nnp::NeuralNetwork::AF_COS, nnp::NeuralNetwork::AF_EXP, nnp::NeuralNetwork::AF_GAUSSIAN, nnp::NeuralNetwork::AF_HARMONIC, nnp::NeuralNetwork::AF_IDENTITY, nnp::NeuralNetwork::AF_LOGISTIC, nnp::NeuralNetwork::AF_RELU, nnp::NeuralNetwork::AF_REVLOGISTIC, nnp::NeuralNetwork::AF_SOFTPLUS, nnp::NeuralNetwork::AF_TANH, elementMap, elements, nnp::Element::getSymbol(), nnp::Settings::getValues(), nnp::Settings::keywordExists(), log, nnp::Element::neuralNetworks, nnpType, numElements, nnp::Element::numSymmetryFunctions(), nnp::reduce(), settings, SHORT_CHARGE_NN, nnp::split(), nnp::strpr(), and useChargeNN.
Referenced by setupGeneric().
|
virtual |
Set up neural network weights from files.
[in] | fileNameFormatShort | Format for weights file name. The string must contain one placeholder for the atomic number. |
[in] | fileNameFormatCharge | Format for charge NN weights file name. The string must contain one placeholder for the atomic number. |
Does not use any keywords. The weight files should contain one weight per line, see NeuralNetwork::setConnections() for the correct order.
Definition at line 1126 of file Mode.cpp.
References log, readNeuralNetworkWeights(), nnp::strpr(), and useChargeNN.
Referenced by nnp::InterfaceLammps::initialize(), main(), and nnp::Prediction::setup().
void Mode::calculateSymmetryFunctions | ( | Structure & | structure, |
bool const | derivatives | ||
) |
Calculate all symmetry functions for all atoms in given structure.
[in] | structure | Input structure. |
[in] | derivatives | If true calculate also derivatives of symmetry functions. |
This function should be replaced by calculateSymmetryFunctionGroups() whenever possible. Results are stored in Atom::G. If derivatives are calculated, additional results are stored in Atom::dGdr and Atom::Neighbor::dGdr.
Definition at line 1150 of file Mode.cpp.
References nnp::Atom::allocate(), nnp::Structure::atoms, nnp::Atom::cacheSizePerElement, nnp::Element::calculateSymmetryFunctions(), checkExtrapolationWarnings, nnp::Atom::element, elements, nnp::Element::getCacheSizes(), nnp::Element::getIndex(), nnp::Atom::getNumNeighbors(), nnp::Element::getSymmetryFunctionNumTable(), nnp::Atom::hasSymmetryFunctionDerivatives, nnp::Structure::hasSymmetryFunctionDerivatives, nnp::Atom::hasSymmetryFunctions, nnp::Structure::hasSymmetryFunctions, nnp::Atom::index, nnp::Atom::indexStructure, log, minCutoffRadius, minNeighbors, nnpType, nnp::Atom::numSymmetryFunctionDerivatives, nnp::Atom::numSymmetryFunctions, nnp::Element::numSymmetryFunctions(), SHORT_CHARGE_NN, nnp::strpr(), nnp::Element::updateSymmetryFunctionStatistics(), and nnp::Atom::useChargeNeuron.
Referenced by nnp::Training::calculateError(), nnp::Training::calculateWeightDerivatives(), nnp::Training::dataSetNormalization(), main(), nnp::Prediction::predict(), nnp::InterfaceLammps::process(), and nnp::Training::update().
void Mode::calculateSymmetryFunctionGroups | ( | Structure & | structure, |
bool const | derivatives | ||
) |
Calculate all symmetry function groups for all atoms in given structure.
[in] | structure | Input structure. |
[in] | derivatives | If true calculate also derivatives of symmetry functions. |
This function replaces calculateSymmetryFunctions() when symmetry function groups are enabled (faster, default behavior). Results are stored in Atom::G. If derivatives are calculated, additional results are stored in Atom::dGdr and Atom::Neighbor::dGdr.
Definition at line 1230 of file Mode.cpp.
References nnp::Atom::allocate(), nnp::Structure::atoms, nnp::Atom::cacheSizePerElement, nnp::Element::calculateSymmetryFunctionGroups(), checkExtrapolationWarnings, nnp::Atom::element, elements, nnp::Element::getCacheSizes(), nnp::Element::getIndex(), nnp::Atom::getNumNeighbors(), nnp::Element::getSymmetryFunctionNumTable(), nnp::Atom::hasSymmetryFunctionDerivatives, nnp::Structure::hasSymmetryFunctionDerivatives, nnp::Atom::hasSymmetryFunctions, nnp::Structure::hasSymmetryFunctions, nnp::Atom::index, nnp::Atom::indexStructure, log, minCutoffRadius, minNeighbors, nnpType, nnp::Atom::numSymmetryFunctionDerivatives, nnp::Atom::numSymmetryFunctions, nnp::Element::numSymmetryFunctions(), SHORT_CHARGE_NN, nnp::strpr(), nnp::Element::updateSymmetryFunctionStatistics(), and nnp::Atom::useChargeNeuron.
Referenced by nnp::Training::calculateError(), nnp::Training::calculateWeightDerivatives(), nnp::Training::dataSetNormalization(), main(), nnp::Prediction::predict(), nnp::InterfaceLammps::process(), and nnp::Training::update().
void Mode::calculateAtomicNeuralNetworks | ( | Structure & | structure, |
bool const | derivatives | ||
) |
Calculate a single atomic neural network for a given atom and nn type.
[in] | nnId | Neural network identifier, e.g. "short", "charge". |
[in] | atom | Input atom. |
[in] | derivatives | If true calculate also derivatives of neural networks with respect to input layer neurons (required for force calculation). |
The atomic energy and charge is stored in Atom::energy and Atom::charge, respectively. If derivatives are calculated the results are stored in Atom::dEdG or Atom::dQdG. Calculate atomic neural networks for all atoms in given structure.
[in] | structure | Input structure. |
[in] | derivatives | If true calculate also derivatives of neural networks with respect to input layer neurons (required for force calculation). |
This internally calls calculateAtomicNeuralNetwork with appropriate neural network identifiers depending on the NNP type.
Definition at line 1310 of file Mode.cpp.
References nnp::Structure::atoms, nnp::NeuralNetwork::calculateDEdG(), elements, nnp::NeuralNetwork::getOutput(), nnpType, nnp::NeuralNetwork::propagate(), nnp::NeuralNetwork::setInput(), SHORT_CHARGE_NN, and SHORT_ONLY.
Referenced by nnp::Training::calculateError(), nnp::Training::dataSetNormalization(), nnp::Training::dPdcN(), main(), nnp::Prediction::predict(), nnp::InterfaceLammps::process(), and nnp::Training::update().
void Mode::calculateEnergy | ( | Structure & | structure | ) | const |
Calculate potential energy for a given structure.
[in] | structure | Input structure. |
Sum up potential energy from atomic energy contributions. Result is stored in Structure::energy.
Definition at line 1366 of file Mode.cpp.
References nnp::Structure::atoms, and nnp::Structure::energy.
Referenced by nnp::Training::calculateError(), nnp::Training::dataSetNormalization(), nnp::Training::dPdcN(), main(), nnp::Prediction::predict(), nnp::InterfaceLammps::process(), and nnp::Training::update().
void Mode::calculateCharge | ( | Structure & | structure | ) | const |
Calculate total charge for a given structure.
[in] | structure | Input structure. |
Sum up charge from atomic charge contributions. Result is stored in Structure::charge.
Definition at line 1379 of file Mode.cpp.
References nnp::Structure::atoms, and nnp::Structure::charge.
Referenced by nnp::Prediction::predict().
void Mode::calculateForces | ( | Structure & | structure | ) | const |
Calculate forces for all atoms in given structure.
[in] | structure | Input structure. |
Combine intermediate results from symmetry function and neural network computation to atomic forces. Results are stored in Atom::f.
Definition at line 1392 of file Mode.cpp.
References nnp::Structure::atoms, nnp::Atom::dEdG, nnp::Atom::dGdr, nnp::Atom::element, elements, nnp::Atom::f, nnp::Atom::index, nnp::Atom::neighbors, nnp::Atom::neighborsUnique, and nnp::Atom::numSymmetryFunctions.
Referenced by nnp::Training::calculateError(), nnp::Training::dataSetNormalization(), nnp::Training::dPdcN(), main(), nnp::Prediction::predict(), and nnp::Training::update().
void Mode::addEnergyOffset | ( | Structure & | structure, |
bool | ref = true |
||
) |
Add atomic energy offsets to reference energy.
[in] | structure | Input structure. |
[in] | ref | If true, use reference energy, otherwise use NN energy. |
Definition at line 1461 of file Mode.cpp.
References elements, nnp::Structure::energy, nnp::Structure::energyRef, nnp::Structure::numAtomsPerElement, and numElements.
Referenced by main(), nnp::Prediction::predict(), nnp::InterfaceLammps::process(), and nnp::Training::writeSetsToFiles().
void Mode::removeEnergyOffset | ( | Structure & | structure, |
bool | ref = true |
||
) |
Remove atomic energy offsets from reference energy.
[in] | structure | Input structure. |
[in] | ref | If true, use reference energy, otherwise use NN energy. |
This function should be called immediately after structures are read in.
Definition at line 1480 of file Mode.cpp.
References elements, nnp::Structure::energy, nnp::Structure::energyRef, nnp::Structure::numAtomsPerElement, and numElements.
Referenced by nnp::Dataset::distributeStructures(), nnp::Prediction::readStructureFromFile(), and nnp::Training::writeSetsToFiles().
double Mode::getEnergyOffset | ( | Structure const & | structure | ) | const |
Get atomic energy offset for given structure.
[in] | structure | Input structure. |
Definition at line 1499 of file Mode.cpp.
References elements, nnp::Structure::numAtomsPerElement, and numElements.
Referenced by main(), and nnp::Dataset::writeSymmetryFunctionFile().
double Mode::getEnergyWithOffset | ( | Structure const & | structure, |
bool | ref = true |
||
) | const |
Add atomic energy offsets and return energy.
[in] | structure | Input structure. |
[in] | ref | If true, use reference energy, otherwise use NN energy. |
Definition at line 1512 of file Mode.cpp.
References elements, nnp::Structure::energy, nnp::Structure::energyRef, nnp::Structure::numAtomsPerElement, and numElements.
Referenced by nnp::Training::dataSetNormalization(), and main().
double Mode::normalized | ( | std::string const & | property, |
double | value | ||
) | const |
Apply normalization to given property.
[in] | property | One of "energy", "force". |
[in] | value | Input property value in physical units. |
Definition at line 1527 of file Mode.cpp.
References convEnergy, and convLength.
double Mode::normalizedEnergy | ( | Structure const & | structure, |
bool | ref = true |
||
) | const |
Apply normalization to given energy of structure.
[in] | structure | Input structure with energy in physical units. |
[in] | ref | If true, use reference energy, otherwise use NN energy. |
Definition at line 1535 of file Mode.cpp.
References convEnergy, nnp::Structure::energy, nnp::Structure::energyRef, meanEnergy, and nnp::Structure::numAtoms.
double Mode::physical | ( | std::string const & | property, |
double | value | ||
) | const |
Undo normalization for a given property.
[in] | property | One of "energy", "force". |
[in] | value | Input property value in normalized units. |
Definition at line 1549 of file Mode.cpp.
References convEnergy, and convLength.
Referenced by nnp::InterfaceLammps::getAtomicEnergy(), main(), nnp::Training::printEpoch(), and nnp::Training::writeLearningCurve().
double Mode::physicalEnergy | ( | Structure const & | structure, |
bool | ref = true |
||
) | const |
Undo normalization for a given energy of structure.
[in] | structure | Input structure with energy in normalized units. |
[in] | ref | If true, use reference energy, otherwise use NN energy. |
Definition at line 1557 of file Mode.cpp.
References convEnergy, nnp::Structure::energy, nnp::Structure::energyRef, meanEnergy, and nnp::Structure::numAtoms.
Referenced by main(), nnp::InterfaceLammps::process(), and nnp::Dataset::writeSymmetryFunctionFile().
void Mode::convertToNormalizedUnits | ( | Structure & | structure | ) | const |
Convert one structure to normalized units.
[in,out] | structure | Input structure. |
Definition at line 1570 of file Mode.cpp.
References convEnergy, convLength, meanEnergy, and nnp::Structure::toNormalizedUnits().
void Mode::convertToPhysicalUnits | ( | Structure & | structure | ) | const |
Convert one structure to physical units.
[in,out] | structure | Input structure. |
Definition at line 1577 of file Mode.cpp.
References convEnergy, convLength, meanEnergy, and nnp::Structure::toPhysicalUnits().
Referenced by main().
size_t Mode::getNumExtrapolationWarnings | ( | ) | const |
Count total number of extrapolation warnings encountered for all elements and symmetry functions.
Definition at line 1595 of file Mode.cpp.
References elements.
Referenced by LAMMPS_NS::PairNNP::handleExtrapolationWarnings(), and main().
void Mode::resetExtrapolationWarnings | ( | ) |
Erase all extrapolation warnings and reset counters.
Definition at line 1584 of file Mode.cpp.
References elements.
Referenced by main().
|
inline |
|
inline |
Getter for Mode::meanEnergy.
Definition at line 548 of file Mode.h.
References meanEnergy.
Referenced by main().
|
inline |
Getter for Mode::convEnergy.
Definition at line 553 of file Mode.h.
References convEnergy.
Referenced by main().
|
inline |
Getter for Mode::convLength.
Definition at line 558 of file Mode.h.
References convLength.
Referenced by main().
|
inline |
Getter for Mode::maxCutoffRadius.
The maximum cutoff radius is determined by setupSymmetryFunctions().
Definition at line 563 of file Mode.h.
References maxCutoffRadius.
Referenced by main(), and nnp::SetupAnalysis::writeSymmetryFunctionShape().
|
inline |
Getter for Mode::numElements.
The number of elements is determined by setupElements().
Definition at line 568 of file Mode.h.
References numElements.
Referenced by main().
vector< size_t > Mode::getNumSymmetryFunctions | ( | ) | const |
Get number of symmetry functions per element.
Definition at line 1609 of file Mode.cpp.
References elements.
Referenced by main().
|
inline |
bool Mode::settingsKeywordExists | ( | std::string const & | keyword | ) | const |
Check if keyword was found in settings file.
[in] | keyword | Keyword for which value is requested. |
true
if keyword exists, false
otherwise. Definition at line 1622 of file Mode.cpp.
References nnp::Settings::keywordExists(), and settings.
Referenced by main().
string Mode::settingsGetValue | ( | std::string const & | keyword | ) | const |
Get value for given keyword in Settings instance.
[in] | keyword | Keyword for which value is requested. |
Definition at line 1627 of file Mode.cpp.
References nnp::Settings::getValue(), and settings.
vector< size_t > Mode::pruneSymmetryFunctionsRange | ( | double | threshold | ) |
Prune symmetry functions according to their range and write settings file.
[in] | threshold | Symmetry functions with range (max - min) smaller than this threshold will be pruned. |
Definition at line 1657 of file Mode.cpp.
References elements, nnp::SymFnc::getGmax(), and nnp::SymFnc::getGmin().
Referenced by main().
vector< size_t > Mode::pruneSymmetryFunctionsSensitivity | ( | double | threshold, |
std::vector< std::vector< double > > | sensitivity | ||
) |
Prune symmetry functions with sensitivity analysis data.
[in] | threshold | Symmetry functions with sensitivity lower than this threshold will be pruned. |
[in] | sensitivity | Sensitivity data for each element and symmetry function. |
Definition at line 1678 of file Mode.cpp.
References elements, and numElements.
Referenced by main().
void Mode::writePrunedSettingsFile | ( | std::vector< std::size_t > | prune, |
std::string | fileName = "output.nn" |
||
) | const |
Copy settings file but comment out lines provided.
[in] | prune | List of line numbers to comment out. |
[in] | fileName | Output file name. |
Definition at line 1633 of file Mode.cpp.
References nnp::Settings::getSettingsLines(), and settings.
Referenced by main().
void Mode::writeSettingsFile | ( | std::ofstream *const & | file | ) | const |
Write complete settings file.
[in,out] | file | Settings file. |
Definition at line 1650 of file Mode.cpp.
References settings, and nnp::Settings::writeSettingsFile().
Referenced by nnp::Training::dataSetNormalization(), and main().
|
protected |
Read in weights for a specific type of neural network.
[in] | type | Actual network type to initialize ("short" or "charge"). |
[in] | fileNameFormat | Weights file name format. |
Definition at line 1699 of file Mode.cpp.
References elements, log, nnp::readColumnsFromFile(), nnp::NeuralNetwork::setConnections(), and nnp::strpr().
Referenced by nnp::Training::initializeWeights(), setupNeuralNetworkWeights(), and nnp::Training::setupNumericDerivCheck().
ElementMap nnp::Mode::elementMap |
Global element map, populated by setupElementMap().
Definition at line 508 of file Mode.h.
Referenced by nnp::Dataset::distributeStructures(), nnp::InterfaceLammps::initialize(), main(), nnp::Dataset::prepareNumericForces(), nnp::Prediction::readStructureFromFile(), nnp::Training::selectSets(), setupElementMap(), setupElements(), setupNeuralNetwork(), setupSymmetryFunctionCache(), setupSymmetryFunctionMemory(), setupSymmetryFunctions(), nnp::Dataset::writeAtomicEnvironmentFile(), nnp::Dataset::writeNeighborLists(), nnp::Dataset::writeSymmetryFunctionFile(), nnp::Dataset::writeSymmetryFunctionHistograms(), and nnp::Training::writeUpdaterStatus().
Log nnp::Mode::log |
Global log file.
Definition at line 510 of file Mode.h.
Referenced by nnp::Training::allocateArrays(), nnp::Training::calculateNeighborLists(), calculateSymmetryFunctionGroups(), calculateSymmetryFunctions(), nnp::Training::checkSelectionMode(), nnp::Dataset::collectSymmetryFunctionStatistics(), nnp::Training::dataSetNormalization(), nnp::Dataset::distributeStructures(), LAMMPS_NS::PairNNP::init_style(), initialize(), nnp::InterfaceLammps::initialize(), nnp::Training::initializeWeights(), nnp::Training::initializeWeightsMemory(), loadSettingsFile(), nnp::Training::loop(), main(), nnp::Training::printEpoch(), nnp::Training::printHeader(), nnp::Training::randomizeNeuralNetworkWeights(), readNeuralNetworkWeights(), nnp::Training::selectSets(), setupCutoff(), setupElementMap(), setupElements(), nnp::Training::setupFileOutput(), nnp::Dataset::setupMPI(), setupNeuralNetwork(), setupNeuralNetworkWeights(), setupNormalization(), nnp::Training::setupNumericDerivCheck(), nnp::Dataset::setupRandomNumberGenerator(), nnp::Training::setupSelectionMode(), setupSymmetryFunctionCache(), setupSymmetryFunctionGroups(), setupSymmetryFunctionMemory(), setupSymmetryFunctions(), setupSymmetryFunctionScaling(), setupSymmetryFunctionScalingNone(), setupSymmetryFunctionStatistics(), nnp::Training::setupTraining(), nnp::Training::setupUpdatePlan(), nnp::Dataset::sortNeighborLists(), nnp::Dataset::writeAtomicEnvironmentFile(), nnp::InterfaceLammps::writeExtrapolationWarnings(), nnp::Dataset::writeNeighborHistogram(), nnp::Dataset::writeNeighborLists(), nnp::Training::writeSetsToFiles(), nnp::Dataset::writeSymmetryFunctionFile(), nnp::Dataset::writeSymmetryFunctionHistograms(), nnp::Dataset::writeSymmetryFunctionScaling(), and nnp::SetupAnalysis::writeSymmetryFunctionShape().
|
protected |
Definition at line 513 of file Mode.h.
Referenced by calculateAtomicNeuralNetworks(), calculateSymmetryFunctionGroups(), calculateSymmetryFunctions(), nnp::Training::dataSetNormalization(), getNnpType(), nnp::Training::initializeWeights(), loadSettingsFile(), nnp::Prediction::predict(), nnp::Training::setStage(), setupNeuralNetwork(), nnp::Training::setupNumericDerivCheck(), nnp::Training::setupTraining(), nnp::Training::update(), nnp::Training::writeLearningCurve(), nnp::Training::writeNeuronStatisticsEpoch(), nnp::Training::writeTimingData(), nnp::Training::writeUpdaterStatus(), and nnp::Training::writeWeightsEpoch().
|
protected |
Definition at line 514 of file Mode.h.
Referenced by nnp::InterfaceLammps::addNeighbor(), nnp::Training::calculateNeighborLists(), nnp::Training::dataSetNormalization(), nnp::InterfaceLammps::getAtomicEnergy(), nnp::InterfaceLammps::getForces(), nnp::InterfaceLammps::getMaxCutoffRadius(), nnp::Prediction::predict(), nnp::Training::printEpoch(), nnp::InterfaceLammps::process(), nnp::Prediction::readStructureFromFile(), setupNormalization(), setupSymmetryFunctions(), useNormalization(), nnp::Training::writeLearningCurve(), and nnp::Dataset::writeSymmetryFunctionFile().
|
protected |
Definition at line 515 of file Mode.h.
Referenced by calculateSymmetryFunctionGroups(), calculateSymmetryFunctions(), and setupSymmetryFunctionStatistics().
|
protected |
Definition at line 516 of file Mode.h.
Referenced by loadSettingsFile(), setupNeuralNetwork(), and setupNeuralNetworkWeights().
|
protected |
Definition at line 517 of file Mode.h.
Referenced by addEnergyOffset(), nnp::Training::calculateWeightDerivatives(), nnp::Training::dPdcN(), getEnergyOffset(), getEnergyWithOffset(), getNumElements(), nnp::Training::getWeights(), nnp::Training::initializeWeightsMemory(), pruneSymmetryFunctionsSensitivity(), nnp::Training::randomizeNeuralNetworkWeights(), removeEnergyOffset(), nnp::Training::selectSets(), nnp::InterfaceLammps::setLocalAtoms(), setupElements(), setupNeuralNetwork(), setupSymmetryFunctionCache(), setupSymmetryFunctionMemory(), setupSymmetryFunctions(), nnp::Training::setWeights(), nnp::Training::update(), nnp::Dataset::writeAtomicEnvironmentFile(), nnp::Dataset::writeNeighborLists(), nnp::Training::writeNeuronStatistics(), nnp::SetupAnalysis::writeSymmetryFunctionShape(), and nnp::Training::writeWeights().
|
protected |
Definition at line 518 of file Mode.h.
Referenced by calculateSymmetryFunctionGroups(), calculateSymmetryFunctions(), setupSymmetryFunctions(), and nnp::Dataset::writeNeighborHistogram().
|
protected |
Definition at line 519 of file Mode.h.
Referenced by calculateSymmetryFunctionGroups(), calculateSymmetryFunctions(), and setupSymmetryFunctions().
|
protected |
Definition at line 520 of file Mode.h.
Referenced by nnp::Training::calculateNeighborLists(), nnp::Training::dataSetNormalization(), getMaxCutoffRadius(), nnp::InterfaceLammps::getMaxCutoffRadius(), nnp::Prediction::predict(), and setupSymmetryFunctions().
|
protected |
Definition at line 521 of file Mode.h.
Referenced by setupCutoff(), and setupSymmetryFunctions().
|
protected |
Definition at line 522 of file Mode.h.
Referenced by convertToNormalizedUnits(), convertToPhysicalUnits(), nnp::Training::dataSetNormalization(), nnp::InterfaceLammps::getAtomicEnergy(), getMeanEnergy(), normalizedEnergy(), physicalEnergy(), nnp::Prediction::predict(), nnp::Prediction::readStructureFromFile(), setupNormalization(), nnp::Dataset::toNormalizedUnits(), and nnp::Dataset::toPhysicalUnits().
|
protected |
Definition at line 523 of file Mode.h.
Referenced by convertToNormalizedUnits(), convertToPhysicalUnits(), nnp::Training::dataSetNormalization(), getConvEnergy(), nnp::InterfaceLammps::getForces(), normalized(), normalizedEnergy(), physical(), physicalEnergy(), nnp::Prediction::predict(), nnp::Prediction::readStructureFromFile(), setupNormalization(), nnp::Dataset::toNormalizedUnits(), and nnp::Dataset::toPhysicalUnits().
|
protected |
Definition at line 524 of file Mode.h.
Referenced by nnp::InterfaceLammps::addNeighbor(), nnp::Training::calculateNeighborLists(), convertToNormalizedUnits(), convertToPhysicalUnits(), nnp::Training::dataSetNormalization(), getConvLength(), nnp::InterfaceLammps::getForces(), nnp::InterfaceLammps::getMaxCutoffRadius(), normalized(), physical(), nnp::Prediction::predict(), nnp::Prediction::readStructureFromFile(), setupNormalization(), setupSymmetryFunctions(), nnp::Dataset::toNormalizedUnits(), and nnp::Dataset::toPhysicalUnits().
|
protected |
Definition at line 525 of file Mode.h.
Referenced by nnp::Training::dataSetNormalization(), nnp::Training::initializeWeights(), loadSettingsFile(), nnp::Training::randomizeNeuralNetworkWeights(), nnp::Training::selectSets(), nnp::Training::setStage(), settingsGetValue(), settingsKeywordExists(), setupCutoff(), setupElementMap(), setupElements(), nnp::Training::setupFileOutput(), setupNeuralNetwork(), setupNormalization(), nnp::Dataset::setupRandomNumberGenerator(), nnp::Training::setupSelectionMode(), setupSymmetryFunctions(), setupSymmetryFunctionScaling(), nnp::Training::setupTraining(), nnp::Training::setupUpdatePlan(), writePrunedSettingsFile(), and writeSettingsFile().
|
protected |
Definition at line 526 of file Mode.h.
Referenced by setupSymmetryFunctionScaling().
|
protected |
Definition at line 527 of file Mode.h.
Referenced by setupCutoff(), and setupSymmetryFunctions().
|
protected |
Definition at line 528 of file Mode.h.
Referenced by addEnergyOffset(), calculateAtomicNeuralNetworks(), calculateForces(), calculateSymmetryFunctionGroups(), calculateSymmetryFunctions(), nnp::Training::calculateWeightDerivatives(), nnp::InterfaceLammps::clearExtrapolationWarnings(), nnp::Training::collectDGdxia(), nnp::Dataset::collectSymmetryFunctionStatistics(), nnp::Training::dataSetNormalization(), nnp::Training::dPdc(), nnp::InterfaceLammps::extractEWBuffer(), nnp::InterfaceLammps::fillEWBuffer(), nnp::InterfaceLammps::getAtomicEnergy(), nnp::Training::getConnectionOffsets(), getEnergyOffset(), getEnergyWithOffset(), nnp::InterfaceLammps::getEWBufferSize(), nnp::InterfaceLammps::getForces(), nnp::Training::getNumConnections(), nnp::Training::getNumConnectionsPerElement(), getNumExtrapolationWarnings(), getNumSymmetryFunctions(), nnp::Training::getWeights(), nnp::Training::initializeWeightsMemory(), pruneSymmetryFunctionsRange(), pruneSymmetryFunctionsSensitivity(), nnp::Training::randomizeNeuralNetworkWeights(), readNeuralNetworkWeights(), removeEnergyOffset(), resetExtrapolationWarnings(), nnp::Training::resetNeuronStatistics(), setupElements(), setupNeuralNetwork(), setupSymmetryFunctionCache(), setupSymmetryFunctionGroups(), setupSymmetryFunctionMemory(), setupSymmetryFunctions(), setupSymmetryFunctionScaling(), setupSymmetryFunctionScalingNone(), setupSymmetryFunctionStatistics(), nnp::Training::setupTraining(), nnp::Training::setWeights(), nnp::Training::update(), nnp::InterfaceLammps::writeExtrapolationWarnings(), nnp::Training::writeNeuronStatistics(), nnp::Dataset::writeSymmetryFunctionHistograms(), nnp::Dataset::writeSymmetryFunctionScaling(), nnp::SetupAnalysis::writeSymmetryFunctionShape(), and nnp::Training::writeWeights().