70 static std::vector<std::array<double,4>>
ReadXYZ(std::string FileName)
72 std::vector<std::array<double,4>> refcoord;
74 std::string comments =
"";
76 infile.open(FileName, std::ios::in);
78 throw std::runtime_error(
"File " + FileName +
" does not exist.");
82 std::getline(infile, ignore);
84 numatoms = std::atoi(ignore.c_str());
86 throw std::runtime_error(
"Must be more than 0 atoms or invalid number atoms defined.");
88 refcoord.resize(numatoms);
90 std::getline(infile, comments);
97 std::getline(infile,line);
98 std::istringstream iss(line);
99 if (!(iss >> refcoord[i][0] >> refcoord[i][1] >> refcoord[i][2] >> refcoord[i][3]))
100 throw std::runtime_error(
"Bad file format for " + FileName +
" for atom " + std::to_string(i+1));
104 if(std::getline(infile, line) && !line.empty())
105 throw std::runtime_error(
"Bad end line, possibly too many atoms defined.");
108 throw std::runtime_error(
"Number atoms specified does not match number of atoms defined");
Utility class to read file.
static std::vector< std::array< double, 4 > > ReadXYZ(std::string FileName)
Read xyz file.
~ReadFile()
Deconstructor.