diff --git a/Qt/PRISM-GUI.pro.user b/Qt/PRISM-GUI.pro.user index d2587a1e2..9f050eebd 100644 --- a/Qt/PRISM-GUI.pro.user +++ b/Qt/PRISM-GUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/SI100.XYZ b/SI100.XYZ new file mode 100644 index 000000000..29135b0ae --- /dev/null +++ b/SI100.XYZ @@ -0,0 +1,11 @@ +one unit cell of 100 silicon + 5.43 5.43 5.43 + 14 0.0000 0.0000 0.0000 1.0 0.076 + 14 2.7150 2.7150 0.0000 1.0 0.076 + 14 1.3575 4.0725 1.3575 1.0 0.076 + 14 4.0725 1.3575 1.3575 1.0 0.076 + 14 2.7150 0.0000 2.7150 1.0 0.076 + 14 0.0000 2.7150 2.7150 1.0 0.076 + 14 1.3575 1.3575 4.0725 1.0 0.076 + 14 4.0725 4.0725 4.0725 1.0 0.076 + -1 diff --git a/SRT.XYZ b/SRT.XYZ new file mode 100644 index 000000000..19b656da9 --- /dev/null +++ b/SRT.XYZ @@ -0,0 +1,10 @@ +one unit cell of strontium titanate + 3.9051 3.9051 3.9051 +38 0 0 0 1.0 0.08 + 8 1.95255 1.95255 0 1.0 0.08 +22 1.95255 1.95255 1.95255 1.0 0.08 + 8 1.95255 0 1.95255 1.0 0.08 + 8 0 1.95255 1.95255 1.0 0.08 +-1 + + diff --git a/include/atom.h b/include/atom.h index dad63b821..91fcf0fa1 100644 --- a/include/atom.h +++ b/include/atom.h @@ -56,5 +56,80 @@ namespace PRISM{ return atoms; }; + inline std::vector readAtoms_XYZ(const std::string& filename){ + std::vector atoms; + std::ifstream f(filename); + if (!f)throw std::runtime_error("Unable to open file.\n"); + std::string line; + std::string token; + size_t line_num = 0; + size_t atom_count = 0; + if (!std::getline(f,line)) throw std::runtime_error("Error reading comment line.\n"); + if (!std::getline(f,line)) throw std::runtime_error("Error reading unit cell params.\n"); + double a,b,c; // unit cell params + { + std::stringstream ss(line); + if (!(ss >> a)) + throw std::domain_error( + "Bad input data for unit cell dimension a.\n"); + if (!(ss >> b)) + throw std::domain_error( + "Bad input data for unit cell dimension a.\n"); + if (!(ss >> c)) + throw std::domain_error( + "Bad input data for unit cell dimension a.\n"); + } + std::cout << "Unit cell a, b, c = " << a << ", " << b << ", " << c << std::endl; + while (std::getline(f, line)) { + line = line.substr(line.find_first_not_of(" ")); + + if (line=="-1"){ + break; + } else { + std::cout << "line = " << line << std::endl; + } + { + std::string test("-1\n"); + if (test == "-1")std::cout<<"yes\n"; + std::cout << test << std::endl; + std::cout << line << std::endl; + std::cout << test.size() << std::endl; + std::cout << line.size() << std::endl; + } + ++atom_count; + ++line_num; + std::cout << "atom_count = " << atom_count << " line = " << line << std::endl; + } +// double tx, ty, tz; +// size_t tspecies; +// std::stringstream ss(line); +// if (!(ss >> tx)) +// throw std::domain_error( +// "Bad input data for X. The txt file should continue 4 comma separated values per line (x,y,z,species).\n"); +// if (ss.peek() == ',')ss.ignore(); +// if (!(ss >> ty)) +// throw std::domain_error( +// "Bad input data for Y. The txt file should continue 4 comma separated values per line (x,y,z,species).\n"); +// if (ss.peek() == ',')ss.ignore(); +// if (!(ss >> tz)) +// throw std::domain_error( +// "Bad input data for Z. The txt file should continue 4 comma separated values per line (x,y,z,species).\n"); +// if (ss.peek() == ',')ss.ignore(); +// if (!(ss >> tspecies)) +// throw std::domain_error( +// "Bad input data for atomic species. The txt file should continue 4 comma separated values per line (x,y,z,species).\n"); +// if (ss.peek() == ',')ss.ignore(); +// atoms.emplace_back(atom{tx, ty, tz, tspecies}); +// } +// if (atom_count == 0) { +// std::domain_error("Bad input data. No atoms were found in this file.\n"); +// } else { +// std::cout << "extracted " << atom_count << " atoms from " << line_num << " lines in " << filename +// << std::endl; +// } + + return atoms; + }; + } #endif //PRISM_ATOM_H diff --git a/include/params.h b/include/params.h index 6b2e275e4..b6919b353 100644 --- a/include/params.h +++ b/include/params.h @@ -134,7 +134,8 @@ namespace PRISM{ pixelSize[0] /= (T)imageSize[0]; pixelSize[1] /= (T)imageSize[1]; try { - atoms = readAtoms(meta.filename_atoms); +// atoms = readAtoms(meta.filename_atoms); + atoms = readAtoms_XYZ(meta.filename_atoms); } catch (const std::runtime_error &e) { std::cout << "PRISM: Error opening " << meta.filename_atoms << std::endl;