31{
32 bool useForces = false;
33 int numProcs = 0;
34 int myRank = 0;
35 ofstream myLog;
36
37 if (argc < 3)
38 {
39 cout << "USAGE: " << argv[0] << " <nbins> <ncutij> \n"
40 << " <nbins> ... Number of symmetry function"
41 " histogram bins.\n"
42 << " <ncutij> ... Maximum number of neighbor symmetry "
43 "functions written (for each element combination).\n"
44 << " Execute in directory with these NNP files present:\n"
45 << " - input.data (structure file)\n"
46 << " - input.nn (NNP settings)\n"
47 << " - scaling.data (symmetry function scaling data)\n";
48 return 1;
49 }
50
51 size_t numBins = (size_t)atoi(argv[1]);
52
53 MPI_Init(&argc, &argv);
54 MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
55 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
56
58 myLog.open(
strpr(
"nnp-atomenv.log.%04d", myRank).c_str());
70
72 if ((size_t)argc - 2 != n * n)
73 {
74 throw runtime_error("ERROR: Wrong number of neighbor cutoffs.\n");
75 }
76 vector<vector<size_t> > neighCutoff(n);
77 size_t count = 0;
78 for (size_t i = 0; i < n; ++i)
79 {
80 neighCutoff.at(i).resize(n, 0);
81 for (size_t j = 0; j < n; ++j)
82 {
83 neighCutoff.at(i).at(j) = atof(argv[count+2]);
84 count++;
85 }
86 }
88
90 dataset.
log <<
"*** CALCULATING SYMMETRY FUNCTIONS ******"
91 "**************************************\n";
93
94 for (vector<Structure>::iterator it = dataset.
structures.begin();
96 {
98#ifdef N2P2_NO_SF_GROUPS
100#else
102#endif
103
104
105 for (vector<Atom>::iterator it2 = it->atoms.begin();
106 it2 != it->atoms.end(); ++it2)
107 {
108 it2->numNeighborsUnique = 0;
109 it2->neighborsUnique.clear();
110 vector<size_t>(it2->neighborsUnique).swap(it2->neighborsUnique);
111
112 it2->dEdG.clear();
113 vector<double>(it2->dEdG).swap(it2->dEdG);
114
115#ifdef N2P2_FULL_SFD_MEMORY
116 it2->dGdxia.clear();
117 vector<double>(it2->dGdxia).swap(it2->dGdxia);
118#endif
119
120 if (!useForces)
121 {
122 it2->dGdr.clear();
123 vector<Vec3D>(it2->dGdr).swap(it2->dGdr);
124 }
125 }
126 }
127 dataset.
log <<
"*****************************************"
128 "**************************************\n";
129
132 "sf-scaled.%03zu.%04zu.histo");
137
138 myLog.close();
139
140 MPI_Finalize();
141
142 return 0;
143}
Collect and process large data sets.
void collectSymmetryFunctionStatistics()
Collect symmetry function statistics from all processors.
int distributeStructures(bool randomize, bool excludeRank0=false, std::string const &fileName="input.data")
Read data file and distribute structures among processors.
void sortNeighborLists()
Sort all neighbor lists according to element and distance.
void writeAtomicEnvironmentFile(std::vector< std::vector< std::size_t > > neighCutoff, bool derivatives, std::string const &fileNamePrefix="atomic-env")
Write atomic environment file.
void writeNeighborLists(std::string const &fileName="neighbor-list.data")
Write neighbor list file.
void setupMPI()
Initialize MPI with MPI_COMM_WORLD.
std::vector< Structure > structures
All structures in this dataset.
void writeSymmetryFunctionHistograms(std::size_t numBins, std::string fileNameFormat="sf.%03zu.%04zu.histo")
Calculate and write symmetry function histograms.
std::size_t writeNeighborHistogram(std::string const &fileNameHisto="neighbors.histo", std::string const &fileNameStructure="neighbors.out")
Calculate and write neighbor histogram and per-structure statistics.
void setupRandomNumberGenerator()
Initialize random number generator.
void toNormalizedUnits()
Switch all structures to normalized units.
void registerStreamPointer(std::ofstream *const &streamPointer)
Register new C++ ofstream pointer.
bool writeToStdout
Turn on/off output to stdout.
void initialize()
Write welcome message with version information.
std::size_t getNumElements() const
Getter for Mode::numElements.
void setupGeneric(std::string const &nnpDir="", bool skipNormalize=false, bool initialHardness=false)
Combine multiple setup routines and provide a basic NNP setup.
double getMaxCutoffRadius() const
Getter for Mode::maxCutoffRadius.
bool useNormalization() const
Check if normalization is enabled.
void calculateSymmetryFunctionGroups(Structure &structure, bool const derivatives)
Calculate all symmetry function groups for all atoms in given structure.
virtual void setupSymmetryFunctionScaling(std::string const &fileName="scaling.data")
Set up symmetry function scaling from file.
bool settingsKeywordExists(std::string const &keyword) const
Check if keyword was found in settings file.
void calculateSymmetryFunctions(Structure &structure, bool const derivatives)
Calculate all symmetry functions for all atoms in given structure.
void setupSymmetryFunctionStatistics(bool collectStatistics, bool collectExtrapolationWarnings, bool writeExtrapolationWarnings, bool stopOnExtrapolationWarnings)
Set up symmetry function statistics collection.
void loadSettingsFile(std::string const &fileName="input.nn")
Open settings file and load all keywords into memory.
string strpr(const char *format,...)
String version of printf function.