66 static std::vector<std::array<double,4>>
ReadXYZ(std::string FileName)
68 std::vector<std::array<double,4>> refcoord;
70 std::string comments =
"";
72 infile.open(FileName, std::ios::in);
75 throw std::runtime_error(
"ReadFile.h: File " + FileName +
" does not exist.");
79 std::getline(infile, line);
83 numatoms = std::stoi(line);
85 catch (
const std::invalid_argument&)
87 throw std::runtime_error(
"ReadFile.h: Invalid number of atoms defined in File.");
91 throw std::runtime_error(
"ReadFile.h: Must be more than 0 atoms defined in File.");
94 refcoord.resize(numatoms);
96 std::getline(infile, comments);
99 std::array<double,4> row;
100 while(infile >> row[0] >> row[1] >> row[2] >> row[3])
102 if(i < numatoms) refcoord[i] = row;
107 throw std::runtime_error(
108 "ReadFile: Header specified " + std::to_string(numatoms) +
109 " atoms, but read in " + std::to_string(i) +
". " +
110 "Check the format of " + FileName +
"."
Utility class to read file.
~ReadFile()
Deconstructor.
static std::vector< std::array< double, 4 > > ReadXYZ(std::string FileName)
Read xyz file.