34int main(
int argc,
char* argv[])
38 cout <<
"USAGE: " << argv[0] <<
" <format> <elem1 <elem2 ...>>\n"
39 <<
" <format> ... Structure file output format "
41 <<
" <elemN> .... Symbol for Nth element.\n"
42 <<
" Execute in directory with these NNP files present:\n"
43 <<
" - input.data (structure file)\n";
48 logFile.open(
"nnp-convert.log");
53 log <<
"*** NNP-CONVERT *************************"
54 "**************************************\n";
57 string format = argv[1];
58 log <<
strpr(
"Requested file format : %s\n", format.c_str());
59 string outputFileName;
60 string outputFileNamePrefix;
63 outputFileName =
"input.xyz";
64 log <<
strpr(
"Output file name : %s\n", outputFileName.c_str());
66 else if (format ==
"poscar")
68 outputFileNamePrefix =
"POSCAR";
69 log <<
strpr(
"Output file name prefix: %s\n",
70 outputFileNamePrefix.c_str());
74 log <<
"ERROR: Unknown output file format.\n";
77 size_t numElements = argc - 2;
78 log <<
strpr(
"Number of elements : %zu\n", numElements);
81 for (
size_t i = 3; i < numElements + 2; ++i)
86 log <<
strpr(
"Element string : %s\n", elements.c_str());
87 log <<
"*****************************************"
88 "**************************************\n";
94 inputFile.open(
"input.data");
98 size_t countStructures = 0;
102 outputFile.open(outputFileName.c_str());
105 while (inputFile.peek() != EOF)
112 else if (format ==
"poscar")
114 outputFileName =
strpr(
"%s_%d",
115 outputFileNamePrefix.c_str(),
116 countStructures + 1);
117 outputFile.open(outputFileName.c_str());
122 log <<
strpr(
"Configuration %7zu: %7zu atoms\n",
133 log <<
"*****************************************"
134 "**************************************\n";
std::size_t registerElements(std::string const &elementLine)
Extract all elements and store in element map.
Logging class for library output.
void registerStreamPointer(std::ofstream *const &streamPointer)
Register new C++ ofstream pointer.
string strpr(const char *format,...)
String version of printf function.
int main(int argc, char *argv[])
Storage for one atomic configuration.
void setElementMap(ElementMap const &elementMap)
Set element map of structure.
void writeToFilePoscar(std::ofstream *const &file) const
Write configuration to POSCAR file.
void writeToFileXyz(std::ofstream *const &file) const
Write configuration to xyz file.
void readFromFile(std::string const fileName="input.data")
Read configuration from file.
void reset()
Reset everything but elementMap.
std::size_t numAtoms
Total number of atoms present in this structure.