31{
32 bool useForces = false;
33 int numProcs = 0;
34 int myRank = 0;
35 long memory = 0;
36 size_t count = 0;
37 ofstream myLog;
38
39 if (argc != 2)
40 {
41 cout << "USAGE: " << argv[0] << " <nbins>\n"
42 << " <nbins> ... Number of symmetry function"
43 " histogram bins.\n"
44 << " Execute in directory with these NNP files present:\n"
45 << " - input.data (structure file)\n"
46 << " - input.nn (NNP settings)\n";
47 return 1;
48 }
49
50 size_t numBins = (size_t)atoi(argv[1]);
51
52 MPI_Init(&argc, &argv);
53 MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
54 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
55
57 myLog.open(
strpr(
"nnp-scaling.log.%04d", myRank).c_str());
63
64
72
74 dataset.
log <<
"*** CALCULATING SYMMETRY FUNCTIONS ******"
75 "**************************************\n";
77
78 dataset.
log <<
"Check the log files of all (!) MPI processes"
79 " for warnings in this section!\n";
80
81 for (vector<Structure>::iterator it = dataset.
structures.begin();
83 {
85#ifdef N2P2_NO_SF_GROUPS
87#else
89#endif
91 count++;
92
93
94
95
96 for (vector<Atom>::iterator it2 = it->atoms.begin();
97 it2 != it->atoms.end(); ++it2)
98 {
99 it2->numNeighborsUnique = 0;
100 it2->neighborsUnique.clear();
101 vector<size_t>(it2->neighborsUnique).swap(it2->neighborsUnique);
102
103 it2->numNeighborsPerElement.clear();
104 vector<size_t>(it2->numNeighborsPerElement).swap(
105 it2->numNeighborsPerElement);
106
107 it2->dEdG.clear();
108 vector<double>(it2->dEdG).swap(it2->dEdG);
109
110#ifdef N2P2_FULL_SFD_MEMORY
111 it2->dGdxia.clear();
112 vector<double>(it2->dGdxia).swap(it2->dGdxia);
113#endif
114
115 it2->dGdr.clear();
116 vector<Vec3D>(it2->dGdr).swap(it2->dGdr);
117
118
119
120 it2->neighbors.clear();
121 vector<Atom::Neighbor>(it2->neighbors).swap(it2->neighbors);
122 }
123 }
124 dataset.
log <<
"*****************************************"
125 "**************************************\n";
126
132
134 dataset.
log <<
"*** MEMORY USAGE ESTIMATION *************"
135 "**************************************\n";
137 dataset.
log <<
"Estimated memory usage for training (keyword"
138 " \"memorize_symfunc_results\":\n";
139 if (useForces)
140 {
141 dataset.
log <<
"Valid for training of energies and forces.\n";
142 }
143 else
144 {
145 dataset.
log <<
"Valid for training of energies only.\n";
146 }
147 dataset.
log <<
strpr(
"Memory for local structures : "
148 "%15ld bytes (%.2f MiB = %.2f GiB).\n",
149 memory,
150 memory / 1024. / 1024.,
151 memory / 1024. / 1024. / 1024.);
152 MPI_Allreduce(MPI_IN_PLACE, &memory, 1, MPI_LONG , MPI_SUM, MPI_COMM_WORLD);
153 MPI_Allreduce(MPI_IN_PLACE, &count , 1,
MPI_SIZE_T, MPI_SUM, MPI_COMM_WORLD);
154 dataset.
log <<
strpr(
"Memory for all structures : "
155 "%15ld bytes (%.2f MiB = %.2f GiB).\n",
156 memory,
157 memory / 1024. / 1024.,
158 memory / 1024. / 1024. / 1024.);
159 dataset.
log <<
strpr(
"Average memory per structure : "
160 "%15.0f bytes (%.2f MiB).\n",
161 memory / (double)count,
162 memory / (double)count / 1024. / 1024.);
163 dataset.
log <<
"*****************************************"
164 "**************************************\n";
165
166 myLog.close();
167
168 MPI_Finalize();
169
170 return 0;
171}
Collect and process large data sets.
void writeSymmetryFunctionScaling(std::string const &fileName="scaling.data")
Write symmetry function scaling values to file.
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.
int calculateBufferSize(Structure const &structure) const
Calculate buffer size required to communicate structure via MPI.
void setupMPI()
Initialize MPI with MPI_COMM_WORLD.
std::vector< Structure > structures
All structures in this dataset.
void writeSymmetryFunctionFile(std::string fileName="function.data")
Write symmetry function legacy file ("function.data").
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.
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.
void setupSymmetryFunctionScalingNone()
Set up "empy" symmetry function scaling.
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.